Pruned defunct and unused contributions from Huawei
Change-Id: I8f1c611682e0f282bc41eb7a4ff4ff23b91a48e5
diff --git a/apps/cip/BUILD b/apps/cip/BUILD
deleted file mode 100644
index 2e5780e..0000000
--- a/apps/cip/BUILD
+++ /dev/null
@@ -1,10 +0,0 @@
-osgi_jar_with_tests(
- deps = CORE_DEPS,
-)
-
-onos_app(
- category = "Utility",
- description = "ONOS Cluster IP alias application.",
- title = "Cluster IP Alias",
- url = "http://onosproject.org",
-)
diff --git a/apps/cip/src/main/java/org/onosproject/cip/ClusterIpManager.java b/apps/cip/src/main/java/org/onosproject/cip/ClusterIpManager.java
deleted file mode 100644
index fd8bb40..0000000
--- a/apps/cip/src/main/java/org/onosproject/cip/ClusterIpManager.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.cip;
-
-import com.google.common.io.ByteStreams;
-import org.onosproject.cfg.ComponentConfigService;
-import org.onosproject.cluster.ClusterService;
-import org.onosproject.cluster.LeadershipEvent;
-import org.onosproject.cluster.LeadershipEventListener;
-import org.onosproject.cluster.LeadershipService;
-import org.onosproject.cluster.NodeId;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Modified;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.Dictionary;
-import java.util.Objects;
-import java.util.Properties;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static org.onlab.util.Tools.get;
-import static org.onosproject.cip.OsgiPropertyConstants.ALIAS_ADAPTER;
-import static org.onosproject.cip.OsgiPropertyConstants.ALIAS_ADAPTER_DEFAULT;
-import static org.onosproject.cip.OsgiPropertyConstants.ALIAS_IP;
-import static org.onosproject.cip.OsgiPropertyConstants.ALIAS_IP_DEFAULT;
-import static org.onosproject.cip.OsgiPropertyConstants.ALIAS_MASK;
-import static org.onosproject.cip.OsgiPropertyConstants.ALIAS_MASK_DEFAULT;
-
-/**
- * Manages cluster IP address alias.
- *
- * To use the application, simply install it on ONOS and then configure it
- * with the desired alias IP/mask/adapter configuration.
- *
- * If you are running it using upstart, you can also add the following
- * command to the /opt/onos/options file:
- *
- * sudo ifconfig eth0:0 down # use the desired alias adapter
- *
- * This will make sure that if the process is killed abruptly, the IP alias
- * will be dropped upon respawn.
- */
-@Component(
- immediate = true,
- property = {
- ALIAS_IP + "=" + ALIAS_IP_DEFAULT,
- ALIAS_MASK + "=" + ALIAS_MASK_DEFAULT,
- ALIAS_ADAPTER + "=" + ALIAS_ADAPTER_DEFAULT
- }
-)
-public class ClusterIpManager {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private static final String CLUSTER_IP = "cluster/ip";
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected ClusterService clusterService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LeadershipService leadershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected ComponentConfigService cfgService;
-
- private final LeadershipEventListener listener = new InternalLeadershipListener();
-
- private NodeId localId;
- private boolean wasLeader = false;
-
- /** Alias IP address. */
- private String aliasIp = ALIAS_IP_DEFAULT;
-
- /** Alias IP mask. */
- private String aliasMask = ALIAS_MASK_DEFAULT;
-
- /** Alias IP adapter. */
- private String aliasAdapter = ALIAS_ADAPTER_DEFAULT;
-
- @Activate
- protected void activate(ComponentContext context) {
- cfgService.registerProperties(getClass());
-
- localId = clusterService.getLocalNode().id();
- processLeaderChange(leadershipService.getLeader(CLUSTER_IP));
-
- leadershipService.addListener(listener);
- leadershipService.runForLeadership(CLUSTER_IP);
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate(ComponentContext context) {
- cfgService.unregisterProperties(getClass(), false);
-
- removeIpAlias(aliasIp, aliasMask, aliasAdapter);
-
- leadershipService.removeListener(listener);
- leadershipService.withdraw(CLUSTER_IP);
- log.info("Stopped");
- }
-
- @Modified
- protected void modified(ComponentContext context) {
- log.info("Received configuration change...");
- Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();
- String newIp = get(properties, ALIAS_IP);
- String newMask = get(properties, ALIAS_MASK);
- String newAdapter = get(properties, ALIAS_ADAPTER);
-
- // Process any changes in the parameters...
- if (!Objects.equals(newIp, aliasIp) ||
- !Objects.equals(newMask, aliasMask) ||
- !Objects.equals(newAdapter, aliasAdapter)) {
- synchronized (this) {
- log.info("Reconfiguring with aliasIp={}, aliasMask={}, aliasAdapter={}, wasLeader={}",
- newIp, newMask, newAdapter, wasLeader);
- if (wasLeader) {
- removeIpAlias(aliasIp, aliasMask, aliasAdapter);
- addIpAlias(newIp, newMask, newAdapter);
- }
- aliasIp = newIp;
- aliasMask = newMask;
- aliasAdapter = newAdapter;
- }
- }
- }
-
- private synchronized void processLeaderChange(NodeId newLeader) {
- boolean isLeader = Objects.equals(newLeader, localId);
- log.info("Processing leadership change; wasLeader={}, isLeader={}", wasLeader, isLeader);
- if (!wasLeader && isLeader) {
- // Gaining leadership, so setup the IP alias
- addIpAlias(aliasIp, aliasMask, aliasAdapter);
- wasLeader = true;
- } else if (wasLeader && !isLeader) {
- // Losing leadership, so drop the IP alias
- removeIpAlias(aliasIp, aliasMask, aliasAdapter);
- wasLeader = false;
- }
- }
-
- private synchronized void addIpAlias(String ip, String mask, String adapter) {
- if (!isNullOrEmpty(ip) && !isNullOrEmpty(mask) && !isNullOrEmpty(adapter)) {
- log.info("Adding IP alias {}/{} to {}", ip, mask, adapter);
- execute("sudo ifconfig " + adapter + " " + ip + " netmask " + mask + " up", false);
- execute("sudo /usr/sbin/arping -c 1 -I " + adapter + " " + ip, true);
- }
- }
-
- private synchronized void removeIpAlias(String ip, String mask, String adapter) {
- if (!isNullOrEmpty(ip) && !isNullOrEmpty(mask) && !isNullOrEmpty(adapter)) {
- log.info("Removing IP alias from {}", adapter, false);
- execute("sudo ifconfig " + adapter + " down", true);
- }
- }
-
- private void execute(String command, boolean ignoreCode) {
- try {
- log.info("Executing [{}]", command);
- Process process = Runtime.getRuntime().exec(command);
- byte[] output = ByteStreams.toByteArray(process.getInputStream());
- byte[] error = ByteStreams.toByteArray(process.getErrorStream());
- int code = process.waitFor();
- if (code != 0 && !ignoreCode) {
- log.info("Command failed: status={}, output={}, error={}",
- code, new String(output), new String(error));
- }
- } catch (IOException e) {
- log.error("Unable to execute command {}", command, e);
- } catch (InterruptedException e) {
- log.error("Interrupted executing command {}", command, e);
- Thread.currentThread().interrupt();
- }
- }
-
- // Listens for leadership changes.
- private class InternalLeadershipListener implements LeadershipEventListener {
-
- @Override
- public boolean isRelevant(LeadershipEvent event) {
- return CLUSTER_IP.equals(event.subject().topic());
- }
-
- @Override
- public void event(LeadershipEvent event) {
- processLeaderChange(event.subject().leaderNodeId());
- }
- }
-
-}
diff --git a/apps/cip/src/main/java/org/onosproject/cip/OsgiPropertyConstants.java b/apps/cip/src/main/java/org/onosproject/cip/OsgiPropertyConstants.java
deleted file mode 100644
index c6bcb52..0000000
--- a/apps/cip/src/main/java/org/onosproject/cip/OsgiPropertyConstants.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.cip;
-
-public final class OsgiPropertyConstants {
- private OsgiPropertyConstants() {
- }
-
- static final String ALIAS_IP = "aliasIp";
- static final String ALIAS_IP_DEFAULT = "";
-
- static final String ALIAS_MASK = "aliasMask";
- static final String ALIAS_MASK_DEFAULT = "255.255.0.0";
-
- static final String ALIAS_ADAPTER = "aliasAdapter";
- static final String ALIAS_ADAPTER_DEFAULT = "eth0:0";
-}
diff --git a/apps/cip/src/main/java/org/onosproject/cip/package-info.java b/apps/cip/src/main/java/org/onosproject/cip/package-info.java
deleted file mode 100644
index fbc9ae9..0000000
--- a/apps/cip/src/main/java/org/onosproject/cip/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Cluster IP Manager, which is responsible for managing the cluster IP
- * address alias.
- */
-package org.onosproject.cip;
diff --git a/apps/configsync-netconf/BUILD b/apps/configsync-netconf/BUILD
deleted file mode 100644
index 63c06c1..0000000
--- a/apps/configsync-netconf/BUILD
+++ /dev/null
@@ -1,26 +0,0 @@
-APPS = [
- "org.onosproject.configsync",
- "org.onosproject.yang",
- "org.onosproject.netconf",
-]
-
-COMPILE_DEPS = CORE_DEPS + [
- "@onos_yang_model//jar",
- "@onos_yang_runtime//jar",
- "//protocols/netconf/api:onos-protocols-netconf-api",
- "//apps/config:onos-apps-config",
- "//apps/configsync:onos-apps-configsync",
-]
-
-osgi_jar_with_tests(
- test_deps = TEST_ADAPTERS,
- deps = COMPILE_DEPS,
-)
-
-onos_app(
- category = "Utility",
- description = "Application to support the Dynamic configuration service.",
- required_apps = APPS,
- title = "Dynamic Configuration Synchronizer for NETCONF",
- url = "http://onosproject.org",
-)
diff --git a/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerComponent.java b/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerComponent.java
deleted file mode 100644
index d107da7..0000000
--- a/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerComponent.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.d.config.sync.impl.netconf;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onosproject.d.config.sync.DeviceConfigSynchronizationProviderRegistry;
-import org.onosproject.d.config.sync.DeviceConfigSynchronizationProviderService;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.netconf.NetconfController;
-import org.onosproject.yang.model.SchemaContextProvider;
-import org.onosproject.yang.runtime.YangRuntimeService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Main component of Dynamic config synchronizer for NETCONF.
- *
- * <ul>
- * <li> bootstrap Active and Passive synchronization modules
- * <li> start background anti-entropy mechanism for offline device configuration
- * </ul>
- */
-@Component(immediate = true)
-public class NetconfDeviceConfigSynchronizerComponent {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- /**
- * NETCONF dynamic config synchronizer provider ID.
- */
- public static final ProviderId PID =
- new ProviderId("netconf", "org.onosproject.d.config.sync.netconf");
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceConfigSynchronizationProviderRegistry registry;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetconfController netconfController;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected YangRuntimeService yangRuntimeService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected SchemaContextProvider schemaContextProvider;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceService deviceService;
-
- private NetconfDeviceConfigSynchronizerProvider provider;
-
- private DeviceConfigSynchronizationProviderService providerService;
-
-
- @Activate
- protected void activate() {
- provider = new NetconfDeviceConfigSynchronizerProvider(PID, new InnerNetconfContext());
- providerService = registry.register(provider);
-
- // TODO (Phase 2 or later)
- // listen to NETCONF events (new Device appeared, etc.)
- // for PASSIVE "state" synchronization upward
-
- // TODO listen to DeviceEvents (Offline pre-configuration scenario)
-
- // TODO background anti-entropy mechanism
-
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- registry.unregister(provider);
- log.info("Stopped");
- }
-
- /**
- * Context object to provide reference to OSGi services, etc.
- */
- @Beta
- public static interface NetconfContext {
-
- /**
- * Returns DeviceConfigSynchronizationProviderService interface.
- *
- * @return DeviceConfigSynchronizationProviderService
- */
- DeviceConfigSynchronizationProviderService providerService();
-
- SchemaContextProvider schemaContextProvider();
-
- YangRuntimeService yangRuntime();
-
- NetconfController netconfController();
-
- }
-
- class InnerNetconfContext implements NetconfContext {
-
- @Override
- public NetconfController netconfController() {
- return netconfController;
- }
-
- @Override
- public YangRuntimeService yangRuntime() {
- return yangRuntimeService;
- }
-
- @Override
- public SchemaContextProvider schemaContextProvider() {
- return schemaContextProvider;
- }
-
- @Override
- public DeviceConfigSynchronizationProviderService providerService() {
- return providerService;
- }
- }
-}
diff --git a/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerProvider.java b/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerProvider.java
deleted file mode 100644
index 2ab2bbc..0000000
--- a/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerProvider.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.d.config.sync.impl.netconf;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static java.util.concurrent.CompletableFuture.completedFuture;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.concurrent.CompletableFuture;
-import org.onlab.util.XmlString;
-import org.onosproject.d.config.ResourceIds;
-import org.onosproject.d.config.sync.DeviceConfigSynchronizationProvider;
-import org.onosproject.d.config.sync.impl.netconf.NetconfDeviceConfigSynchronizerComponent.NetconfContext;
-import org.onosproject.d.config.sync.operation.SetRequest;
-import org.onosproject.d.config.sync.operation.SetRequest.Change;
-import org.onosproject.d.config.sync.operation.SetRequest.Change.Operation;
-import org.onosproject.d.config.sync.operation.SetResponse;
-import org.onosproject.d.config.sync.operation.SetResponse.Code;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.netconf.NetconfDevice;
-import org.onosproject.netconf.NetconfException;
-import org.onosproject.netconf.NetconfSession;
-import org.onosproject.yang.model.DataNode;
-import org.onosproject.yang.model.DefaultResourceData;
-import org.onosproject.yang.model.InnerNode;
-import org.onosproject.yang.model.ResourceData;
-import org.onosproject.yang.model.ResourceId;
-import org.onosproject.yang.runtime.AnnotatedNodeInfo;
-import org.onosproject.yang.runtime.Annotation;
-import org.onosproject.yang.runtime.CompositeData;
-import org.onosproject.yang.runtime.CompositeStream;
-import org.onosproject.yang.runtime.DefaultAnnotatedNodeInfo;
-import org.onosproject.yang.runtime.DefaultAnnotation;
-import org.onosproject.yang.runtime.DefaultCompositeData;
-import org.onosproject.yang.runtime.DefaultRuntimeContext;
-import org.onosproject.yang.runtime.RuntimeContext;
-import org.slf4j.Logger;
-import com.google.common.io.CharStreams;
-
-/**
- * Dynamic config synchronizer provider for NETCONF.
- *
- * <ul>
- * <li> Converts POJO YANG into XML.
- * <li> Adds NETCONF envelope around it.
- * <li> Send request down to the device over NETCONF
- * </ul>
- */
-public class NetconfDeviceConfigSynchronizerProvider
- extends AbstractProvider
- implements DeviceConfigSynchronizationProvider {
-
- private static final Logger log = getLogger(NetconfDeviceConfigSynchronizerProvider.class);
-
- // TODO this should probably be defined on YRT Serializer side
- /**
- * {@link RuntimeContext} parameter Dataformat specifying XML.
- */
- private static final String DATAFORMAT_XML = "xml";
-
- private static final String XMLNS_XC = "xmlns:xc";
- private static final String NETCONF_1_0_BASE_NAMESPACE =
- "urn:ietf:params:xml:ns:netconf:base:1.0";
-
- /**
- * Annotation to add xc namespace declaration.
- * {@value #XMLNS_XC}={@value #NETCONF_1_0_BASE_NAMESPACE}
- */
- private static final DefaultAnnotation XMLNS_XC_ANNOTATION =
- new DefaultAnnotation(XMLNS_XC, NETCONF_1_0_BASE_NAMESPACE);
-
- private static final String XC_OPERATION = "xc:operation";
-
-
- private NetconfContext context;
-
- protected NetconfDeviceConfigSynchronizerProvider(ProviderId id,
- NetconfContext context) {
- super(id);
- this.context = checkNotNull(context);
- }
-
- @Override
- public CompletableFuture<SetResponse> setConfiguration(DeviceId deviceId,
- SetRequest request) {
- // sanity check and handle empty change?
-
- // TODOs:
- // - Construct convert request object into XML
- // -- [FutureWork] may need to introduce behaviour for Device specific
- // workaround insertion
-
- StringBuilder rpc = new StringBuilder();
-
- // - Add NETCONF envelope
- rpc.append("<rpc xmlns=\"").append(NETCONF_1_0_BASE_NAMESPACE).append('"')
- .append(">");
-
- rpc.append("<edit-config>");
- rpc.append("<target>");
- // TODO directly writing to running for now
- rpc.append("<running/>");
- rpc.append("</target>\n");
- rpc.append("<config ")
- .append(XMLNS_XC).append("=\"").append(NETCONF_1_0_BASE_NAMESPACE).append("\">");
- // TODO netconf SBI should probably be adding these envelopes once
- // netconf SBI is in better shape
- // TODO In such case netconf sbi need to define namespace externally visible.
- // ("xc" in above instance)
- // to be used to add operations on config tree nodes
-
-
- // Convert change(s) into a DataNode tree
- for (Change change : request.changes()) {
- log.trace("change={}", change);
-
- // TODO switch statement can probably be removed
- switch (change.op()) {
- case REPLACE:
- case UPDATE:
- case DELETE:
- // convert DataNode -> ResourceData
- ResourceData data = toResourceData(change);
-
- // build CompositeData
- DefaultCompositeData.Builder compositeData =
- DefaultCompositeData.builder();
-
- // add ResourceData
- compositeData.resourceData(data);
-
- // add AnnotatedNodeInfo operation
- compositeData.addAnnotatedNodeInfo(toAnnotatedNodeInfo(change.op(), change.path()));
-
- RuntimeContext yrtContext = new DefaultRuntimeContext.Builder()
- .setDataFormat(DATAFORMAT_XML)
- .addAnnotation(XMLNS_XC_ANNOTATION)
- .build();
- CompositeData cdata = compositeData.build();
- log.trace("CompositeData:{}", cdata);
- CompositeStream xml = context.yangRuntime().encode(cdata,
- yrtContext);
- try {
- CharStreams.copy(new InputStreamReader(xml.resourceData(), UTF_8), rpc);
- } catch (IOException e) {
- log.error("IOException thrown", e);
- // FIXME handle error
- }
- break;
-
- default:
- log.error("Should never reach here. {}", change);
- break;
- }
- }
-
- // - close NETCONF envelope
- // TODO eventually these should be handled by NETCONF SBI side
- rpc.append('\n');
- rpc.append("</config>");
- rpc.append("</edit-config>");
- rpc.append("</rpc>");
-
- // - send requests down to the device
- NetconfSession session = getNetconfSession(deviceId);
- if (session == null) {
- log.error("No session available for {}", deviceId);
- return completedFuture(SetResponse.response(request,
- Code.FAILED_PRECONDITION,
- "No session for " + deviceId));
- }
- try {
- // FIXME Netconf async API is currently screwed up, need to fix
- // NetconfSession, etc.
- CompletableFuture<String> response = session.rpc(rpc.toString());
- log.trace("raw request:\n{}", rpc);
- log.trace("prettified request:\n{}", XmlString.prettifyXml(rpc));
- return response.handle((resp, err) -> {
- if (err == null) {
- log.trace("reply:\n{}", XmlString.prettifyXml(resp));
- // FIXME check response properly
- return SetResponse.ok(request);
- } else {
- return SetResponse.response(request, Code.UNKNOWN, err.getMessage());
- }
- });
- } catch (NetconfException e) {
- // TODO Handle error
- log.error("NetconfException thrown", e);
- return completedFuture(SetResponse.response(request, Code.UNKNOWN, e.getMessage()));
-
- }
- }
-
- // overridable for ease of testing
- /**
- * Returns a session for the specified deviceId.
- *
- * @param deviceId for which we wish to retrieve a session
- * @return a NetconfSession with the specified node
- * or null if this node does not have the session to the specified Device.
- */
- protected NetconfSession getNetconfSession(DeviceId deviceId) {
- NetconfDevice device = context.netconfController().getNetconfDevice(deviceId);
- checkNotNull(device, "The specified deviceId could not be found by the NETCONF controller.");
- NetconfSession session = device.getSession();
- checkNotNull(session, "A session could not be retrieved for the specified deviceId.");
- return session;
- }
-
- /**
- * Creates AnnotatedNodeInfo for {@code node}.
- *
- * @param op operation
- * @param parent resourceId
- * @param node the node
- * @return AnnotatedNodeInfo
- */
- static AnnotatedNodeInfo annotatedNodeInfo(Operation op,
- ResourceId parent,
- DataNode node) {
- return DefaultAnnotatedNodeInfo.builder()
- .resourceId(ResourceIds.resourceId(parent, node))
- .addAnnotation(toAnnotation(op))
- .build();
- }
-
- /**
- * Creates AnnotatedNodeInfo for specified resource path.
- *
- * @param op operation
- * @param path resourceId
- * @return AnnotatedNodeInfo
- */
- static AnnotatedNodeInfo toAnnotatedNodeInfo(Operation op,
- ResourceId path) {
- return DefaultAnnotatedNodeInfo.builder()
- .resourceId(path)
- .addAnnotation(toAnnotation(op))
- .build();
- }
-
- /**
- * Transform DataNode into a ResourceData.
- *
- * @param change object
- * @return ResourceData
- */
- static ResourceData toResourceData(Change change) {
- DefaultResourceData.Builder builder = DefaultResourceData.builder();
- builder.resourceId(change.path());
- if (change.op() != Change.Operation.DELETE) {
- DataNode dataNode = change.val();
- if (dataNode instanceof InnerNode) {
- ((InnerNode) dataNode).childNodes().values().forEach(builder::addDataNode);
- } else {
- log.error("Unexpected DataNode encountered", change);
- }
- }
-
- return builder.build();
- }
-
- static Annotation toAnnotation(Operation op) {
- switch (op) {
- case DELETE:
- return new DefaultAnnotation(XC_OPERATION, "remove");
- case REPLACE:
- return new DefaultAnnotation(XC_OPERATION, "replace");
- case UPDATE:
- return new DefaultAnnotation(XC_OPERATION, "merge");
- default:
- throw new IllegalArgumentException("Unknown operation " + op);
- }
- }
-
-}
diff --git a/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/package-info.java b/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/package-info.java
deleted file mode 100644
index bc3c75a..0000000
--- a/apps/configsync-netconf/src/main/java/org/onosproject/d/config/sync/impl/netconf/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of NETCONF dynamic config synchronizer provider.
- */
-package org.onosproject.d.config.sync.impl.netconf;
diff --git a/apps/configsync-netconf/src/test/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerProviderTest.java b/apps/configsync-netconf/src/test/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerProviderTest.java
deleted file mode 100644
index 28fad43..0000000
--- a/apps/configsync-netconf/src/test/java/org/onosproject/d/config/sync/impl/netconf/NetconfDeviceConfigSynchronizerProviderTest.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.d.config.sync.impl.netconf;
-
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.stringContainsInOrder;
-import static org.junit.Assert.*;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.function.BiFunction;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.io.input.ReaderInputStream;
-import org.hamcrest.Matchers;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.util.XmlString;
-import org.onosproject.d.config.sync.DeviceConfigSynchronizationProviderService;
-import org.onosproject.d.config.sync.impl.netconf.NetconfDeviceConfigSynchronizerComponent.NetconfContext;
-import org.onosproject.d.config.sync.operation.SetRequest;
-import org.onosproject.d.config.sync.operation.SetResponse;
-import org.onosproject.d.config.sync.operation.SetResponse.Code;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.netconf.NetconfController;
-import org.onosproject.netconf.NetconfException;
-import org.onosproject.netconf.NetconfSession;
-import org.onosproject.netconf.NetconfSessionAdapter;
-import org.onosproject.yang.model.DataNode;
-import org.onosproject.yang.model.DataNode.Type;
-import org.onosproject.yang.model.InnerNode;
-import org.onosproject.yang.model.LeafNode;
-import org.onosproject.yang.model.ResourceData;
-import org.onosproject.yang.model.ResourceId;
-import org.onosproject.yang.model.SchemaContextProvider;
-import org.onosproject.yang.runtime.AnnotatedNodeInfo;
-import org.onosproject.yang.runtime.CompositeData;
-import org.onosproject.yang.runtime.CompositeStream;
-import org.onosproject.yang.runtime.DefaultAnnotatedNodeInfo;
-import org.onosproject.yang.runtime.DefaultAnnotation;
-import org.onosproject.yang.runtime.DefaultCompositeStream;
-import org.onosproject.yang.runtime.RuntimeContext;
-import org.onosproject.yang.runtime.YangRuntimeService;
-import com.google.common.io.CharSource;
-
-public class NetconfDeviceConfigSynchronizerProviderTest {
-
- private static final ProviderId PID = new ProviderId("netconf", "test");
- private static final DeviceId DID = DeviceId.deviceId("netconf:testDevice");
-
- private static final String XMLNS_XC = "xmlns:xc";
- private static final String NETCONF_1_0_BASE_NAMESPACE =
- "urn:ietf:params:xml:ns:netconf:base:1.0";
-
- private static final DefaultAnnotation XC_ANNOTATION =
- new DefaultAnnotation(XMLNS_XC, NETCONF_1_0_BASE_NAMESPACE);
-
- private static final DefaultAnnotation AN_XC_REPLACE_OPERATION =
- new DefaultAnnotation("xc:operation", "replace");
-
- private static final DefaultAnnotation AN_XC_REMOVE_OPERATION =
- new DefaultAnnotation("xc:operation", "remove");
-
- /**
- * Yang namespace for test config data.
- */
- private static final String TEST_NS = "testNS";
-
- private static final ResourceId RID_INTERFACES =
- ResourceId.builder().addBranchPointSchema("interfaces", TEST_NS).build();
-
- private NetconfDeviceConfigSynchronizerProvider sut;
-
- private NetconfContext ncCtx;
-
-
- // Set following accordingly to suite test scenario
- NetconfSession testNcSession;
- YangRuntimeService testYangRuntime;
-
-
- @Before
- public void setUp() throws Exception {
-
- ncCtx = new TestNetconfContext();
-
- sut = new NetconfDeviceConfigSynchronizerProvider(PID, ncCtx) {
- // overriding to avoid mocking whole NetconController and all that.
- @Override
- protected NetconfSession getNetconfSession(DeviceId deviceId) {
- assertEquals(DID, deviceId);
- return testNcSession;
- }
- };
- }
-
- @Test
- public void testReplaceOperation() throws Exception {
- // plug drivers with assertions
- testYangRuntime = onEncode((data, context) -> {
- assertEquals("xml", context.getDataFormat());
- assertThat(context.getProtocolAnnotations(), hasItem(XC_ANNOTATION));
-
- // assert CompositeData
- ResourceData rData = data.resourceData();
- List<AnnotatedNodeInfo> infos = data.annotatedNodesInfo();
-
- ResourceId interfacesRid = RID_INTERFACES;
- AnnotatedNodeInfo intfsAnnot = DefaultAnnotatedNodeInfo.builder()
- .resourceId(interfacesRid)
- .addAnnotation(AN_XC_REPLACE_OPERATION)
- .build();
- assertThat("interfaces has replace operation", infos, hasItem(intfsAnnot));
-
- // assertion for ResourceData.
- assertEquals(RID_INTERFACES, rData.resourceId());
- assertThat("has 1 child", rData.dataNodes(), hasSize(1));
- assertThat("which is interface",
- rData.dataNodes().get(0).key().schemaId().name(),
- is("interface"));
- // todo: assert the rest of the tree if it make sense.
-
- // FIXME it's unclear what URI is expected here
- String id = URI.create("netconf:testDevice").toString();
-
- String inXml = deviceConfigAsXml("replace");
-
- return toCompositeStream(id, inXml);
- });
- testNcSession = new TestEditNetconfSession();
-
-
- // building test data
- ResourceId interfacesId = RID_INTERFACES;
- DataNode interfaces = deviceConfigNode();
- SetRequest request = SetRequest.builder()
- .replace(interfacesId, interfaces)
- .build();
-
- // test start
- CompletableFuture<SetResponse> f = sut.setConfiguration(DID, request);
- SetResponse response = f.get(5, TimeUnit.MINUTES);
-
- assertEquals(Code.OK, response.code());
- assertEquals(request.subjects(), response.subjects());
- }
-
-
- @Test
- public void testDeleteOperation() throws Exception {
- // plug drivers with assertions
- testYangRuntime = onEncode((data, context) -> {
- assertEquals("xml", context.getDataFormat());
- assertThat(context.getProtocolAnnotations(), hasItem(XC_ANNOTATION));
-
- // assert CompositeData
- ResourceData rData = data.resourceData();
- List<AnnotatedNodeInfo> infos = data.annotatedNodesInfo();
-
- ResourceId interfacesRid = RID_INTERFACES;
- AnnotatedNodeInfo intfsAnnot = DefaultAnnotatedNodeInfo.builder()
- .resourceId(interfacesRid)
- .addAnnotation(AN_XC_REMOVE_OPERATION)
- .build();
- assertThat("interfaces has replace operation", infos, hasItem(intfsAnnot));
-
- // assertion for ResourceData.
- assertEquals(RID_INTERFACES, rData.resourceId());
- assertThat("has no child", rData.dataNodes(), hasSize(0));
-
- // FIXME it's unclear what URI is expected here
- String id = URI.create("netconf:testDevice").toString();
-
- String inXml = deviceConfigAsXml("remove");
-
- return toCompositeStream(id, inXml);
- });
- testNcSession = new TestEditNetconfSession();
-
- // building test data
- ResourceId interfacesId = RID_INTERFACES;
- SetRequest request = SetRequest.builder()
- .delete(interfacesId)
- .build();
-
- // test start
- CompletableFuture<SetResponse> f = sut.setConfiguration(DID, request);
-
- SetResponse response = f.get(5, TimeUnit.MINUTES);
- assertEquals(Code.OK, response.code());
- assertEquals(request.subjects(), response.subjects());
- }
-
- /**
- * DataNode for testing.
- *
- * <pre>
- * +-interfaces
- * |
- * +- interface{intf-name="en0"}
- * |
- * +- speed = "10G"
- * +- state = "up"
- *
- * </pre>
- * @return DataNode
- */
- private DataNode deviceConfigNode() {
- InnerNode.Builder intfs = InnerNode.builder("interfaces", TEST_NS);
- intfs.type(Type.SINGLE_INSTANCE_NODE);
- InnerNode.Builder intf = intfs.createChildBuilder("interface", TEST_NS);
- intf.type(Type.SINGLE_INSTANCE_LEAF_VALUE_NODE);
- intf.addKeyLeaf("name", TEST_NS, "Ethernet0/0");
- LeafNode.Builder speed = intf.createChildBuilder("mtu", TEST_NS, "1500");
- speed.type(Type.SINGLE_INSTANCE_LEAF_VALUE_NODE);
-
- intf.addNode(speed.build());
- intfs.addNode(intf.build());
- return intfs.build();
- }
-
- /**
- * {@link #deviceConfigNode()} as XML.
- *
- * @param operation xc:operation value on {@code interfaces} node
- * @return XML
- */
- private String deviceConfigAsXml(String operation) {
- return "<interfaces xmlns=\"http://example.com/schema/1.2/config\""
- + " xc:operation=\"" + operation + "\">\n" +
- " <interface>\n" +
- " <name>Ethernet0/0</name>\n" +
- " <mtu>1500</mtu>\n" +
- " </interface>\n" +
- "</interfaces>";
- }
-
- private String rpcReplyOk(int messageid) {
- return "<rpc-reply message-id=\"" + messageid + "\"\n" +
- " xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
- " <ok/>\n" +
- "</rpc-reply>";
- }
-
- private int fetchMessageId(String request) {
- int messageid;
- Pattern msgId = Pattern.compile("message-id=['\"]([0-9]+)['\"]");
- Matcher matcher = msgId.matcher(request);
- if (matcher.find()) {
- messageid = Integer.parseInt(matcher.group(1));
- } else {
- messageid = -1;
- }
- return messageid;
- }
-
-
- protected CompositeStream toCompositeStream(String id, String inXml) {
- try {
- InputStream xml = new ReaderInputStream(
- CharSource.wrap(inXml)
- .openStream());
-
- return new DefaultCompositeStream(id, xml);
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
-
- /**
- * Asserts that it received edit-config message and reply Ok.
- */
- private class TestEditNetconfSession extends NetconfSessionAdapter {
- @Override
- public CompletableFuture<String> rpc(String request)
- throws NetconfException {
- System.out.println("TestEditNetconfSession received:");
- System.out.println(XmlString.prettifyXml(request));
-
- // Extremely naive request rpc message check
- assertThat(request, stringContainsInOrder(Arrays.asList(
- "<rpc",
- "<edit-config",
- "<target",
- "<config",
-
- "</config>",
- "</edit-config>",
- "</rpc>")));
-
- assertThat("XML namespace decl exists",
- request, Matchers.containsString("xmlns:xc"));
-
- assertThat("netconf operation exists",
- request, Matchers.containsString("xc:operation"));
-
- return CompletableFuture.completedFuture(rpcReplyOk(fetchMessageId(request)));
- }
- }
-
- /**
- * Creates mock YangRuntimeService.
- *
- * @param body to execute when {@link YangRuntimeService#encode(CompositeData, RuntimeContext)} was called.
- * @return YangRuntimeService instance
- */
- TestYangRuntimeService onEncode(BiFunction<CompositeData, RuntimeContext, CompositeStream> body) {
- return new TestYangRuntimeService() {
- @Override
- public CompositeStream encode(CompositeData internal,
- RuntimeContext context) {
- return body.apply(internal, context);
- }
- };
- }
-
- private abstract class TestYangRuntimeService implements YangRuntimeService {
-
- @Override
- public CompositeStream encode(CompositeData internal,
- RuntimeContext context) {
- fail("stub not implemented");
- return null;
- }
- @Override
- public CompositeData decode(CompositeStream external,
- RuntimeContext context) {
- fail("stub not implemented");
- return null;
- }
- }
-
- private final class TestNetconfContext implements NetconfContext {
- @Override
- public DeviceConfigSynchronizationProviderService providerService() {
- fail("Add stub driver as necessary");
- return null;
- }
-
- @Override
- public SchemaContextProvider schemaContextProvider() {
- fail("Add stub driver as necessary");
- return null;
- }
-
- @Override
- public YangRuntimeService yangRuntime() {
- return testYangRuntime;
- }
-
- @Override
- public NetconfController netconfController() {
- fail("Add stub driver as necessary");
- return null;
- }
- }
-
-}
diff --git a/apps/configsync/BUILD b/apps/configsync/BUILD
deleted file mode 100644
index 38b4fe7..0000000
--- a/apps/configsync/BUILD
+++ /dev/null
@@ -1,20 +0,0 @@
-APPS = [
- # dynamic config
- "org.onosproject.config",
-]
-
-COMPILE_DEPS = CORE_DEPS + ONOS_YANG + [
- "//apps/config:onos-apps-config",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
-
-onos_app(
- category = "Utility",
- description = "Application to support the Dynamic configuration service.",
- required_apps = APPS,
- title = "Dynamic Configuration Synchronizer",
- url = "http://onosproject.org",
-)
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProvider.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProvider.java
deleted file mode 100644
index eed008f..0000000
--- a/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProvider.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.d.config.sync;
-
-import java.util.concurrent.CompletableFuture;
-
-import org.onosproject.d.config.sync.operation.SetRequest;
-import org.onosproject.d.config.sync.operation.SetResponse;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.provider.Provider;
-
-import com.google.common.annotations.Beta;
-
-// TODO might want to remove Device~ prefix, class name too long.
-/**
- * Abstraction of a device config synchronization provider.
- * <p>
- * Provides a mean for propagating dynamic config triggered change down to
- * the device.
- */
-@Beta
-public interface DeviceConfigSynchronizationProvider extends Provider {
-
- // TODO API to propagate dynamic config subsystem side change down to the
- // device
-
- /**
- * Requests a device to set configuration as specified.
- *
- * @param deviceId target Device identifier
- * @param request configuration requests
- * @return result
- */
- CompletableFuture<SetResponse> setConfiguration(DeviceId deviceId, SetRequest request);
-
- // TODO API for Get from Device
- // CompletableFuture<GetResponse> getConfiguration(DeviceId deviceId, GetRequest request);
-
-}
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProviderRegistry.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProviderRegistry.java
deleted file mode 100644
index edf1eba..0000000
--- a/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProviderRegistry.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.d.config.sync;
-
-import org.onosproject.net.provider.ProviderRegistry;
-
-/**
- * Abstraction of a device config synchronization provider registry.
- */
-public interface DeviceConfigSynchronizationProviderRegistry
- extends ProviderRegistry<DeviceConfigSynchronizationProvider,
- DeviceConfigSynchronizationProviderService> {
-
-}
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProviderService.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProviderService.java
deleted file mode 100644
index 8fa0ee3..0000000
--- a/apps/configsync/src/main/java/org/onosproject/d/config/sync/DeviceConfigSynchronizationProviderService.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.d.config.sync;
-
-import org.onosproject.net.provider.ProviderService;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Service which configuration synchronization provider can interact
- * with the service.
- * <p>
- * Provides a mean to propagate device triggered change event upward to
- * dynamic config subsystem.
- */
-@Beta
-public interface DeviceConfigSynchronizationProviderService
- extends ProviderService<DeviceConfigSynchronizationProvider> {
-
- // TODO API to propagate device detected change upwards
- // e.g., in reaction to NETCONF async notification,
- // report polling result up to DynConfig subsystem
-}
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/impl/DynamicDeviceConfigSynchronizer.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/impl/DynamicDeviceConfigSynchronizer.java
deleted file mode 100644
index 1236364..0000000
--- a/apps/configsync/src/main/java/org/onosproject/d/config/sync/impl/DynamicDeviceConfigSynchronizer.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.d.config.sync.impl;
-
-import com.google.common.annotations.Beta;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import org.onlab.util.Tools;
-import org.onosproject.config.DynamicConfigEvent;
-import org.onosproject.config.DynamicConfigEvent.Type;
-import org.onosproject.config.DynamicConfigListener;
-import org.onosproject.config.DynamicConfigService;
-import org.onosproject.config.Filter;
-import org.onosproject.d.config.DataNodes;
-import org.onosproject.d.config.DeviceResourceIds;
-import org.onosproject.d.config.ResourceIds;
-import org.onosproject.d.config.sync.DeviceConfigSynchronizationProvider;
-import org.onosproject.d.config.sync.DeviceConfigSynchronizationProviderRegistry;
-import org.onosproject.d.config.sync.DeviceConfigSynchronizationProviderService;
-import org.onosproject.d.config.sync.operation.SetRequest;
-import org.onosproject.d.config.sync.operation.SetResponse;
-import org.onosproject.d.config.sync.operation.SetResponse.Code;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.provider.AbstractProviderRegistry;
-import org.onosproject.net.provider.AbstractProviderService;
-import org.onosproject.store.primitives.TransactionId;
-import org.onosproject.yang.model.DataNode;
-import org.onosproject.yang.model.ResourceId;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.time.Duration;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-import java.util.stream.Collectors;
-
-import static java.util.concurrent.CompletableFuture.completedFuture;
-import static org.onosproject.d.config.DeviceResourceIds.isUnderDeviceRootNode;
-import static org.onosproject.d.config.DeviceResourceIds.toDeviceId;
-import static org.onosproject.d.config.DeviceResourceIds.toResourceId;
-import static org.onosproject.d.config.sync.operation.SetResponse.response;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Component to bridge Dynamic Config store and the Device configuration state.
- *
- * <ul>
- * <li> Propagate DynamicConfig service change downward to Device side via provider.
- * <li> Propagate Device triggered change event upward to DyamicConfig service.
- * </ul>
- */
-@Beta
-@Component(immediate = true, service = DeviceConfigSynchronizationProviderRegistry.class)
-public class DynamicDeviceConfigSynchronizer
- extends AbstractProviderRegistry<DeviceConfigSynchronizationProvider,
- DeviceConfigSynchronizationProviderService>
- implements DeviceConfigSynchronizationProviderRegistry {
-
- private static final Logger log = getLogger(DynamicDeviceConfigSynchronizer.class);
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DynamicConfigService dynConfigService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigService netcfgService;
-
- private DynamicConfigListener listener = new InnerDyConListener();
-
- // FIXME hack for unconsolidated event bug
- private Duration quietPeriod = Duration.ofSeconds(2);
- private long quietUntil = 0;
-
- @Activate
- public void activate() {
- // TODO start background task to sync Controller and Device?
- dynConfigService.addListener(listener);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- dynConfigService.removeListener(listener);
- log.info("Stopped");
- }
-
-
- @Override
- protected DeviceConfigSynchronizationProviderService createProviderService(
- DeviceConfigSynchronizationProvider provider) {
- return new InternalConfigSynchronizationServiceProvider(provider);
- }
-
- @Override
- protected DeviceConfigSynchronizationProvider defaultProvider() {
- // TODO return provider instance which can deal with "general" provider?
- return super.defaultProvider();
- }
-
- /**
- * Proxy to relay Device change event for propagating running "state"
- * information up to dynamic configuration service.
- */
- class InternalConfigSynchronizationServiceProvider
- extends AbstractProviderService<DeviceConfigSynchronizationProvider>
- implements DeviceConfigSynchronizationProviderService {
-
- protected InternalConfigSynchronizationServiceProvider(DeviceConfigSynchronizationProvider provider) {
- super(provider);
- }
-
- // TODO API for passive information propagation to be added later on
- }
-
- /**
- * DynamicConfigListener to trigger active synchronization toward the device.
- */
- class InnerDyConListener implements DynamicConfigListener {
-
- @Override
- public boolean isRelevant(DynamicConfigEvent event) {
- // TODO NetconfActiveComponent.isRelevant(DynamicConfigEvent)
- // seems to be doing some filtering
- // Logic filtering for L3VPN is probably a demo hack,
- // but is there any portion of it which is really needed?
- // e.g., listen only for device tree events?
-
- ResourceId path = event.subject();
- // TODO only device tree related event is relevant.
- // 1) path is under device tree
- // 2) path is root, and DataNode contains element under node
- // ...
- return true;
- }
-
- @Override
- public void event(DynamicConfigEvent event) {
- // Note: removed accumulator in the old code assuming,
- // event accumulation will happen on Device Config Event level.
-
- // TODO execute off event dispatch thread
- processEventNonBatch(event);
- }
-
- }
-
- void processEventNonBatch(DynamicConfigEvent event) {
- if (System.currentTimeMillis() < quietUntil) {
- log.trace("Ignoring {}. Quiet period until {}",
- event, Tools.defaultOffsetDataTime(quietUntil));
- return;
- }
-
- ResourceId path = event.subject();
- if (isUnderDeviceRootNode(path)) {
- log.trace("processing event:{}", event);
-
- DeviceId deviceId = DeviceResourceIds.toDeviceId(path);
- ResourceId deviceRootPath = DeviceResourceIds.toResourceId(deviceId);
-
- ResourceId absPath = ResourceIds.concat(ResourceIds.ROOT_ID, path);
- ResourceId relPath = ResourceIds.relativize(deviceRootPath, absPath);
- // give me everything Filter
- Filter giveMeEverything = Filter.builder().build();
-
- DataNode node = dynConfigService.readNode(path, giveMeEverything);
- SetRequest request;
- switch (event.type()) {
-
- case NODE_ADDED:
- case NODE_REPLACED:
- request = SetRequest.builder().replace(relPath, node).build();
- break;
- case NODE_UPDATED:
- // Event has no pay load, only thing we can do is replace.
- request = SetRequest.builder().replace(relPath, node).build();
- break;
- case NODE_DELETED:
- request = SetRequest.builder().delete(relPath).build();
- break;
- case UNKNOWN_OPRN:
- default:
- log.error("Unexpected event {}, aborting", event);
- return;
- }
-
- log.info("Dispatching {} request {}", deviceId, request);
- CompletableFuture<SetResponse> response = dispatchRequest(deviceId, request);
- response.whenComplete((resp, e) -> {
- if (e == null) {
- if (resp.code() == Code.OK) {
- log.info("{} for {} complete", resp, deviceId);
- } else {
- log.warn("{} for {} had problem", resp, deviceId);
- }
- } else {
- log.error("Request to {} failed {}", deviceId, response, e);
- }
- });
-
- // FIXME hack for unconsolidated event bug
- quietUntil = System.currentTimeMillis() + quietPeriod.toMillis();
- } else {
- log.debug("Ignored event's ResourceId: {}", event.subject());
- }
- }
-
-
- // was sketch to handle case, where event could contain batch of things...
- private void processEvent(DynamicConfigEvent event) {
- // TODO assuming event object will contain batch of (atomic) change event
-
- // What the new event will contain:
- Type evtType = event.type();
-
- // Transaction ID, can be null
- TransactionId txId = null;
-
- // TODO this might change into collection of (path, val_before, val_after)
-
- ResourceId path = event.subject();
- // data node (can be tree) representing change, it could be incremental update
- DataNode val = null;
-
- // build per-Device SetRequest
- // val could be a tree, containing multiple Device tree,
- // break them down into per-Device sub-tree
- Map<DeviceId, SetRequest.Builder> requests = new HashMap<>();
-
- if (isUnderDeviceRootNode(path)) {
- // about single device
- buildDeviceRequest(requests, evtType, path, toDeviceId(path), val);
-
- } else if (DeviceResourceIds.isRootOrDevicesNode(path)) {
- // => potentially contain changes spanning multiple Devices
- Map<DeviceId, DataNode> perDevices = perDevices(path, val);
-
- perDevices.forEach((did, dataNode) -> {
- buildDeviceRequest(requests, evtType, toResourceId(did), did, dataNode);
- });
-
- // TODO special care is probably required for delete cases
- // especially delete all under devices
-
- } else {
- log.warn("Event not related to a Device?");
- }
-
-
- // TODO assuming event is a batch,
- // potentially containing changes for multiple devices,
- // who will process/coordinate the batch event?
-
-
- // TODO loop through per-Device change set
- List<CompletableFuture<SetResponse>> responses =
- requests.entrySet().stream()
- .map(entry -> dispatchRequest(entry.getKey(), entry.getValue().build()))
- .collect(Collectors.toList());
-
- // wait for all responses
- List<SetResponse> allResults = Tools.allOf(responses).join();
- // TODO deal with partial failure case (multi-device coordination)
- log.info("DEBUG: results: {}", allResults);
- }
-
- // might make sense to make this public
- CompletableFuture<SetResponse> dispatchRequest(DeviceId devId, SetRequest req) {
-
- // determine appropriate provider for this Device
- DeviceConfigSynchronizationProvider provider = this.getProvider(devId);
-
- if (provider == null) {
- // no appropriate provider found
- // return completed future with failed SetResponse
- return completedFuture(response(req,
- SetResponse.Code.FAILED_PRECONDITION,
- "no provider found for " + devId));
- }
-
- // dispatch request
- return provider.setConfiguration(devId, req)
- .handle((resp, err) -> {
- if (err == null) {
- // set complete
- log.info("DEBUG: Req:{}, Resp:{}", req, resp);
- return resp;
- } else {
- // fatal error
- log.error("Fatal error on {}", req, err);
- return response(req,
- SetResponse.Code.UNKNOWN,
- "Unknown error " + err);
- }
- });
- }
-
-
- // may eventually reuse with batch event
- /**
- * Build device request about a Device.
- *
- * @param requests map containing request builder to populate
- * @param evtType change request type
- * @param path to {@code val}
- * @param did DeviceId which {@code path} is about
- * @param val changed node to write
- */
- private void buildDeviceRequest(Map<DeviceId, SetRequest.Builder> requests,
- Type evtType,
- ResourceId path,
- DeviceId did,
- DataNode val) {
-
- SetRequest.Builder request =
- requests.computeIfAbsent(did, d -> SetRequest.builder());
-
- switch (evtType) {
- case NODE_ADDED:
- case NODE_REPLACED:
- request.replace(path, val);
- break;
-
- case NODE_UPDATED:
- // TODO Auto-generated method stub
- request.update(path, val);
- break;
-
- case NODE_DELETED:
- // TODO Auto-generated method stub
- request.delete(path);
- break;
-
- case UNKNOWN_OPRN:
- default:
- log.warn("Ignoring unexpected {}", evtType);
- break;
- }
- }
-
- /**
- * Breaks down tree {@code val} into per Device subtree.
- *
- * @param path pointing to {@code val}
- * @param val tree which contains only 1 Device.
- * @return Device node relative DataNode for each DeviceId
- * @throws IllegalArgumentException
- */
- private static Map<DeviceId, DataNode> perDevices(ResourceId path, DataNode val) {
- if (DeviceResourceIds.isUnderDeviceRootNode(path)) {
- // - if path is device root or it's subtree, path alone is sufficient
- return ImmutableMap.of(DeviceResourceIds.toDeviceId(path), val);
-
- } else if (DeviceResourceIds.isRootOrDevicesNode(path)) {
- // - if path is "/" or devices, it might be constructible from val tree
- final Collection<DataNode> devicesChildren;
- if (DeviceResourceIds.isRootNode(path)) {
- // root
- devicesChildren = DataNodes.childOnlyByName(val, DeviceResourceIds.DEVICES_NAME)
- .map(dn -> DataNodes.children(dn))
- .orElse(ImmutableList.of());
- } else {
- // devices
- devicesChildren = DataNodes.children(val);
- }
-
- return devicesChildren.stream()
- // TODO use full schemaId for filtering when ready
- .filter(dn -> dn.key().schemaId().name().equals(DeviceResourceIds.DEVICE_NAME))
- .collect(Collectors.toMap(dn -> DeviceResourceIds.toDeviceId(dn.key()),
- dn -> dn));
-
- }
- throw new IllegalArgumentException(path + " not related to Device");
- }
-
-}
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/impl/package-info.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/impl/package-info.java
deleted file mode 100644
index 23fa201..0000000
--- a/apps/configsync/src/main/java/org/onosproject/d/config/sync/impl/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * Implementation of dynamic config synchronizer.
- */
-package org.onosproject.d.config.sync.impl;
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/SetRequest.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/SetRequest.java
deleted file mode 100644
index d4d3254..0000000
--- a/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/SetRequest.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.d.config.sync.operation;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Objects;
-import java.util.Optional;
-
-import org.apache.commons.lang3.tuple.Pair;
-import org.onosproject.d.config.sync.operation.SetRequest.Change.Operation;
-import org.onosproject.yang.model.DataNode;
-import org.onosproject.yang.model.ResourceId;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableList;
-
-// One SetRequest is expected to be a transaction, all-or-nothing
-/**
- * Collection of changes about a single Device,
- * intended to be applied to the Device transactionally.
- */
-@Beta
-public final class SetRequest {
-
- private final Collection<Change> changes;
-
- SetRequest(Collection<Change> changes) {
- this.changes = ImmutableList.copyOf(changes);
- }
-
- public Collection<Change> changes() {
- return changes;
- }
-
- public Collection<Pair<Operation, ResourceId>> subjects() {
- return changes.stream()
- .map(c -> Pair.of(c.op(), c.path()))
- .collect(ImmutableList.toImmutableList());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof SetRequest) {
- SetRequest that = (SetRequest) obj;
- return Objects.equals(this.changes, that.changes);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(changes);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("changes", changes)
- .toString();
- }
- public static SetRequest.Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private final List<Change> changes = new ArrayList<>();
-
- /**
- * Returns changes contained in this builder.
- *
- * @return unmodifiable list view of Changes
- */
- public List<Change> changes() {
- return Collections.unmodifiableList(changes);
- }
-
- /**
- * Adds request to remove specified {@code path}.
- *
- * @param path resource path relative to device root node
- * @return self
- */
- public SetRequest.Builder delete(ResourceId path) {
- changes.add(Change.delete(path));
- return this;
- }
-
- /**
- * Adds request to replace specified {@code path} with specified {@code val}.
- *
- * @param path resource path relative to device root node
- * @param val resource value
- * @return self
- */
- public SetRequest.Builder replace(ResourceId path, DataNode val) {
- changes.add(Change.replace(path, val));
- return this;
- }
-
- /**
- * Adds request to update/merge specified {@code val} to the {@code path}.
- *
- * @param path resource path relative to device root node
- * @param val resource value
- * @return self
- */
- public SetRequest.Builder update(ResourceId path, DataNode val) {
- changes.add(Change.update(path, val));
- return this;
- }
-
- public SetRequest build() {
- return new SetRequest(changes);
- }
- }
-
- public static final class Change {
-
- public enum Operation {
-
- // Note: equivalent to remove in netconf
- /**
- * Request to delete specified {@code path}.
- * If path does not exist, it is silently ignored.
- */
- DELETE,
- // Note: equivalent to replace in netconf
- /**
- * Request to replace specified {@code path} with specified {@code val}.
- */
- REPLACE,
- // Note: equivalent to merge in netconf
- /**
- * Request to update/merge specified {@code val} to the {@code path}.
- */
- UPDATE
- }
-
- private final Operation op;
- private final ResourceId path;
- private final Optional<DataNode> val;
-
- public static Change delete(ResourceId path) {
- return new Change(Operation.DELETE, path, Optional.empty());
- }
-
- public static Change replace(ResourceId path, DataNode val) {
- return new Change(Operation.REPLACE, path, Optional.of(val));
- }
-
- public static Change update(ResourceId path, DataNode val) {
- return new Change(Operation.UPDATE, path, Optional.of(val));
- }
-
- Change(Operation op, ResourceId path, Optional<DataNode> val) {
- this.op = checkNotNull(op);
- this.path = checkNotNull(path);
- this.val = checkNotNull(val);
- }
-
- /**
- * Returns type of change operation.
- *
- * @return Operation
- */
- public Operation op() {
- return op;
- }
-
- /**
- * Returns resource path to be changed.
- *
- * @return resource path relative to device root node
- */
- public ResourceId path() {
- return path;
- }
-
- /**
- * Returns the {@code val} specified.
- *
- * @return {@code val}
- * @throws NoSuchElementException if this object represent {@code DELETE} op.
- */
- public DataNode val() {
- return val.get();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof Change) {
- Change that = (Change) obj;
- return Objects.equals(this.op, that.op) &&
- Objects.equals(this.path, that.path) &&
- Objects.equals(this.val, that.val);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(op, path, val);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("op", op)
- .add("path", path)
- .add("val", val)
- .toString();
- }
- }
-}
\ No newline at end of file
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/SetResponse.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/SetResponse.java
deleted file mode 100644
index 0bc9502..0000000
--- a/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/SetResponse.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.d.config.sync.operation;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Collection;
-import java.util.Objects;
-
-import org.apache.commons.lang3.tuple.Pair;
-import org.onosproject.d.config.sync.operation.SetRequest.Change.Operation;
-import org.onosproject.yang.model.ResourceId;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableList;
-
-
-@Beta
-public final class SetResponse {
-
- // partially borrowed from io.grpc.Status.Code,
- // might want to borrow all of them
- public enum Code {
- OK,
- CANCELLED,
-
- UNKNOWN,
-
- INVALID_ARGUMENT,
-
- NOT_FOUND,
- ALREADY_EXISTS,
-
- FAILED_PRECONDITION,
- ABORTED,
- UNAVAILABLE,
- }
-
- private final Collection<Pair<Operation, ResourceId>> subjects;
-
- private final SetResponse.Code code;
-
- // human readable error message for logging purpose
- private final String message;
-
- SetResponse(Collection<Pair<Operation, ResourceId>> subjects,
- SetResponse.Code code,
- String message) {
- this.subjects = ImmutableList.copyOf(subjects);
- this.code = checkNotNull(code);
- this.message = checkNotNull(message);
- }
-
- public Collection<Pair<Operation, ResourceId>> subjects() {
- return subjects;
- }
-
- public Code code() {
- return code;
- }
-
- public String message() {
- return message;
- }
-
-
- /**
- * Creates SetResponse instance from request.
- *
- * @param request original request this response corresponds to
- * @param code response status code
- * @param message human readable error message for logging purpose.
- * can be left empty string on OK response.
- * @return SetResponse instance
- */
- public static SetResponse response(SetRequest request,
- Code code,
- String message) {
- return new SetResponse(request.subjects(), code, checkNotNull(message));
- }
-
- /**
- * Creates successful SetResponce instance from request.
- *
- * @param request original request this response corresponds to
- * @return SetResponse instance
- */
- public static SetResponse ok(SetRequest request) {
- return new SetResponse(request.subjects(), Code.OK, "");
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(subjects, code, message);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof SetResponse) {
- SetResponse that = (SetResponse) obj;
- return Objects.equals(this.subjects, that.subjects) &&
- Objects.equals(this.code, that.code) &&
- Objects.equals(this.message, that.message);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("code", code)
- .add("subjects", subjects)
- .add("message", message)
- .toString();
- }
-
-
-
-}
\ No newline at end of file
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/package-info.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/package-info.java
deleted file mode 100644
index d7612e9..0000000
--- a/apps/configsync/src/main/java/org/onosproject/d/config/sync/operation/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * Dynamic config synchronizer API related value objects.
- */
-package org.onosproject.d.config.sync.operation;
diff --git a/apps/configsync/src/main/java/org/onosproject/d/config/sync/package-info.java b/apps/configsync/src/main/java/org/onosproject/d/config/sync/package-info.java
deleted file mode 100644
index 8da2769..0000000
--- a/apps/configsync/src/main/java/org/onosproject/d/config/sync/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * Dynamic config synchronizer API.
- */
-package org.onosproject.d.config.sync;
diff --git a/apps/configsync/src/test/java/org/onosproject/d/config/sync/impl/DynamicDeviceConfigSynchronizerTest.java b/apps/configsync/src/test/java/org/onosproject/d/config/sync/impl/DynamicDeviceConfigSynchronizerTest.java
deleted file mode 100644
index bfdead6..0000000
--- a/apps/configsync/src/test/java/org/onosproject/d/config/sync/impl/DynamicDeviceConfigSynchronizerTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.d.config.sync.impl;
-
-import static org.junit.Assert.*;
-import static org.onosproject.d.config.ResourceIds.ROOT_ID;
-
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.function.BiFunction;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.config.DynamicConfigEvent;
-import org.onosproject.config.DynamicConfigServiceAdapter;
-import org.onosproject.config.Filter;
-import org.onosproject.d.config.DeviceResourceIds;
-import org.onosproject.d.config.ResourceIds;
-import org.onosproject.d.config.sync.DeviceConfigSynchronizationProvider;
-import org.onosproject.d.config.sync.operation.SetRequest;
-import org.onosproject.d.config.sync.operation.SetRequest.Change;
-import org.onosproject.d.config.sync.operation.SetRequest.Change.Operation;
-import org.onosproject.d.config.sync.operation.SetResponse;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.config.NetworkConfigServiceAdapter;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.yang.model.DataNode;
-import org.onosproject.yang.model.InnerNode;
-import org.onosproject.yang.model.LeafNode;
-import org.onosproject.yang.model.ResourceId;
-
-import com.google.common.collect.Iterables;
-
-public class DynamicDeviceConfigSynchronizerTest {
-
- static final String TEST_NS = "testNS";
-
- static final ResourceId REL_INTERFACES = ResourceId.builder()
- .addBranchPointSchema("interfaces", TEST_NS)
- .build();
-
- static final DeviceId DID = DeviceId.deviceId("test:device1");
-
- DynamicDeviceConfigSynchronizer sut;
-
- TestDynamicConfigService dyConService;
-
- CountDownLatch providerCalled = new CountDownLatch(1);
-
- /**
- * DynamicConfigService.readNode(ResourceId, Filter) stub.
- */
- BiFunction<ResourceId, Filter, DataNode> onDcsRead;
-
- BiFunction<DeviceId, SetRequest, CompletableFuture<SetResponse>> onSetConfiguration;
-
- @Before
- public void setUp() throws Exception {
-
- sut = new DynamicDeviceConfigSynchronizer();
- dyConService = new TestDynamicConfigService();
- sut.dynConfigService = dyConService;
- sut.netcfgService = new NetworkConfigServiceAdapter();
-
- sut.activate();
-
- sut.register(new MockDeviceConfigSynchronizerProvider());
- }
-
- @After
- public void tearDown() throws Exception {
- sut.deactivate();
- }
-
- @Test
- public void testDispatchRequest() throws Exception {
-
- ResourceId devicePath = DeviceResourceIds.toResourceId(DID);
- ResourceId cfgPath = REL_INTERFACES;
- ResourceId absPath = ResourceIds.concat(devicePath, cfgPath);
- ResourceId evtPath = ResourceIds.relativize(ROOT_ID, absPath);
- DynamicConfigEvent event = new DynamicConfigEvent(DynamicConfigEvent.Type.NODE_REPLACED, evtPath);
-
- // assertions
- onDcsRead = (path, filter) -> {
- assertTrue(filter.isEmptyFilter());
- assertEquals("DCService get access by root relative RID", evtPath, path);
- return deviceConfigNode();
- };
-
- onSetConfiguration = (deviceId, request) -> {
- assertEquals(DID, deviceId);
- assertEquals(1, request.changes().size());
- Change change = Iterables.get(request.changes(), 0);
- assertEquals("Provider get access by rel RID", REL_INTERFACES, change.path());
- assertEquals(Operation.REPLACE, change.op());
- assertEquals("interfaces", change.val().key().schemaId().name());
- // walk and test children if it adds value
-
- providerCalled.countDown();
- return CompletableFuture.completedFuture(SetResponse.ok(request));
- };
-
- // start test run
-
- // imitate event from DCS
- dyConService.postEvent(event);
-
- // assert that it reached the provider
- providerCalled.await(5, TimeUnit.HOURS);
- }
-
- /**
- * DataNode for testing.
- *
- * <pre>
- * +-interfaces
- * |
- * +- interface{intf-name="en0"}
- * |
- * +- speed = "10G"
- * +- state = "up"
- *
- * </pre>
- * @return DataNode
- */
- private DataNode deviceConfigNode() {
- InnerNode.Builder intfs = InnerNode.builder("interfaces", TEST_NS);
- intfs.type(DataNode.Type.SINGLE_INSTANCE_NODE);
- InnerNode.Builder intf = intfs.createChildBuilder("interface", TEST_NS);
- intf.type(DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE);
- intf.addKeyLeaf("name", TEST_NS, "Ethernet0/0");
- LeafNode.Builder speed = intf.createChildBuilder("mtu", TEST_NS, "1500");
- speed.type(DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE);
-
- intf.addNode(speed.build());
- intfs.addNode(intf.build());
- return intfs.build();
- }
-
- private class TestDynamicConfigService extends DynamicConfigServiceAdapter {
-
- public void postEvent(DynamicConfigEvent event) {
- listenerRegistry.process(event);
- }
-
- @Override
- public DataNode readNode(ResourceId path, Filter filter) {
- return onDcsRead.apply(path, filter);
- }
- }
-
- private class MockDeviceConfigSynchronizerProvider
- implements DeviceConfigSynchronizationProvider {
-
- @Override
- public ProviderId id() {
- return new ProviderId(DID.uri().getScheme(), "test-provider");
- }
-
- @Override
- public CompletableFuture<SetResponse> setConfiguration(DeviceId deviceId,
- SetRequest request) {
- return onSetConfiguration.apply(deviceId, request);
- }
- }
-
-}
diff --git a/apps/evpn-route-service/BUILD b/apps/evpn-route-service/BUILD
deleted file mode 100644
index d099839..0000000
--- a/apps/evpn-route-service/BUILD
+++ /dev/null
@@ -1,11 +0,0 @@
-BUNDLES = [
- "//apps/evpn-route-service/api:onos-apps-evpn-route-service-api",
- "//apps/evpn-route-service/app:onos-apps-evpn-route-service-app",
-]
-
-onos_app(
- category = "Traffic Engineering",
- included_bundles = BUNDLES,
- title = "EVPN Routing",
- url = "http://onosproject.org",
-)
diff --git a/apps/evpn-route-service/api/BUILD b/apps/evpn-route-service/api/BUILD
deleted file mode 100644
index f72e3bc..0000000
--- a/apps/evpn-route-service/api/BUILD
+++ /dev/null
@@ -1,3 +0,0 @@
-osgi_jar_with_tests(
- deps = CORE_DEPS,
-)
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstance.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstance.java
deleted file mode 100644
index 5288db7..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstance.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.List;
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Represents a evpn instance.
- */
-public final class EvpnInstance {
-
- private final RouteDistinguisher rd;
- private final List<VpnRouteTarget> importRtList;
- private final List<VpnRouteTarget> exportRtList;
- private final EvpnInstanceName evpnName;
-
- /**
- * Constructor to initialize the parameters.
- *
- * @param rd route distinguisher
- * @param importRtList import rotue targets
- * @param exportRtList export rotue targets
- * @param evpnName vpn instance name
- */
- private EvpnInstance(RouteDistinguisher rd,
- List<VpnRouteTarget> importRtList,
- List<VpnRouteTarget> exportRtList,
- EvpnInstanceName evpnName) {
- checkNotNull(rd);
- //checkNotNull(rt);
- checkNotNull(evpnName);
- this.rd = rd;
- this.importRtList = importRtList;
- this.exportRtList = exportRtList;
- this.evpnName = evpnName;
- }
-
- /**
- * Creats the instance of EvpnInstance.
- *
- * @param rd route distinguisher
- * @param importRtList import rotue targets
- * @param exportRtList export rotue targets
- * @param evpnName vpn instance name
- * @return EvpnInstance
- */
- public static EvpnInstance evpnInstance(RouteDistinguisher rd,
- List<VpnRouteTarget> importRtList,
- List<VpnRouteTarget> exportRtList,
- EvpnInstanceName evpnName) {
- return new EvpnInstance(rd, importRtList, exportRtList, evpnName);
- }
-
- /**
- * Getter of RouteDistinguisher.
- *
- * @return RouteDistinguisher
- */
- public RouteDistinguisher routeDistinguisher() {
- return rd;
- }
-
- /**
- * Returns the Route targets.
- *
- * @return RouteTarget List
- */
-
- public List<VpnRouteTarget> importRouteTarget() {
- return importRtList;
- }
-
- /**
- * Returns the Route targets.
- *
- * @return RouteTarget List
- */
- public List<VpnRouteTarget> exportRouteTarget() {
- return exportRtList;
- }
-
- /**
- * Getter of vpn instance name.
- *
- * @return evpnName
- */
- public EvpnInstanceName evpnName() {
- return evpnName;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rd, importRtList, exportRtList, evpnName);
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- if (!(other instanceof EvpnInstance)) {
- return false;
- }
-
- EvpnInstance that = (EvpnInstance) other;
-
- return Objects.equals(this.evpnName, that.evpnName)
- && Objects.equals(this.rd, that.rd)
- && Objects.equals(this.importRtList, that.importRtList)
- && Objects.equals(this.exportRtList, that.exportRtList);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("evpnName", this.evpnName)
- .add("rd", this.rd).add("import rt", this.importRtList)
- .add("export rt", this.exportRtList).toString();
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceName.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceName.java
deleted file mode 100644
index f1ea22a..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceName.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Represents the EvpnInstanceName.
- */
-public final class EvpnInstanceName {
- private final String evpnName;
-
- /**
- * Constructor to initialize the parameters.
- *
- * @param evpnName EvpnInstanceName
- */
- private EvpnInstanceName(String evpnName) {
- this.evpnName = evpnName;
- }
-
- /**
- * Creates instance of EvpnInstanceName.
- *
- * @param evpnName evpnName
- * @return evpnInstanceName
- */
- public static EvpnInstanceName evpnName(String evpnName) {
- return new EvpnInstanceName(evpnName);
- }
-
- /**
- * Get vpn instance name.
- *
- * @return evpnName
- */
- public String getEvpnName() {
- return evpnName;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(evpnName);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof EvpnInstanceName) {
- EvpnInstanceName other = (EvpnInstanceName) obj;
- return Objects.equals(this.evpnName, other.evpnName);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("evpnName", evpnName).toString();
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceNextHop.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceNextHop.java
deleted file mode 100644
index 49ad2c5..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceNextHop.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Represents a evpn instance nexthop.
- */
-public final class EvpnInstanceNextHop {
-
- private final IpAddress nextHop;
- private final Label label;
-
- /**
- * Constructor to initialize the parameters.
- *
- * @param nextHop nexthop
- * @param label label
- */
- private EvpnInstanceNextHop(IpAddress nextHop, Label label) {
- this.nextHop = nextHop;
- this.label = label;
- }
-
- /**
- * creates instance of EvpnInstanceNextHop.
- *
- * @param nextHop nexthop
- * @param label label
- * @return evpnInstanceNexthop
- */
- public static EvpnInstanceNextHop evpnNextHop(IpAddress nextHop,
- Label label) {
- return new EvpnInstanceNextHop(nextHop, label);
- }
-
- /**
- * Returns the next hop IP address.
- *
- * @return next hop
- */
- public IpAddress nextHop() {
- return nextHop;
- }
-
- /**
- * Returns the label.
- *
- * @return Label
- */
- public Label label() {
- return label;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(nextHop, label);
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- if (!(other instanceof EvpnInstanceNextHop)) {
- return false;
- }
-
- EvpnInstanceNextHop that = (EvpnInstanceNextHop) other;
-
- return Objects.equals(this.nextHop(), that.nextHop())
- && Objects.equals(this.label, that.label);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("nextHop", this.nextHop())
- .add("label", this.label).toString();
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstancePrefix.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstancePrefix.java
deleted file mode 100644
index 2f30538..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstancePrefix.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.Objects;
-
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Represents a evpn instance prefix.
- */
-public final class EvpnInstancePrefix {
-
- private final MacAddress macAddress;
- private final IpPrefix ipPrefix;
-
- /**
- * Constructor to initialize the parameters.
- *
- * @param macAddress Mac address
- * @param ipPrefix IP address
- */
- private EvpnInstancePrefix(MacAddress macAddress,
- IpPrefix ipPrefix) {
- checkNotNull(macAddress);
- this.macAddress = macAddress;
- this.ipPrefix = ipPrefix;
- }
-
- /**
- * Creates the instance of EvpnInstancePrefix.
- *
- * @param macAddress Mac address
- * @param ipPrefix IP address
- * @return Evpn instance prefix
- */
- public static EvpnInstancePrefix evpnPrefix(MacAddress macAddress,
- IpPrefix ipPrefix) {
- return new EvpnInstancePrefix(macAddress, ipPrefix);
- }
-
- /**
- * Returns the MAC of the route.
- *
- * @return MAC address
- */
- public MacAddress macAddress() {
- return macAddress;
- }
-
- /**
- * Returns the IP prefix of the route.
- *
- * @return IP prefix
- */
- public IpPrefix ipPrefix() {
- return ipPrefix;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(macAddress);
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- if (!(other instanceof EvpnInstancePrefix)) {
- return false;
- }
-
- EvpnInstancePrefix that = (EvpnInstancePrefix) other;
-
- return Objects.equals(this.macAddress, that.macAddress)
- && Objects.equals(this.ipPrefix, that.ipPrefix);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("macAddress", this.macAddress)
- .add("ipAddress", this.ipPrefix).toString();
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceRoute.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceRoute.java
deleted file mode 100644
index ca0c8bd8..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceRoute.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.List;
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Represents a evpn instance route.
- */
-public class EvpnInstanceRoute {
-
- private final EvpnInstanceName evpnName;
- private final RouteDistinguisher rd;
- private List<VpnRouteTarget> importRtList;
- private List<VpnRouteTarget> exportRtList;
- private final EvpnInstancePrefix evpnInstancePrefix;
- private final EvpnInstanceNextHop evpnInstanceNextHop;
- private final IpPrefix prefix;
- private final IpAddress nextHop;
- private final Label label;
-
- /**
- * Constructor to initialize the parameters.
- *
- * @param evpnName vpn instance name
- * @param rd route distinguisher
- * @param importRtList import route targets
- * @param exportRtList export route targets
- * @param evpnInstancePrefix evpn intance prefix
- * @param evpnInstanceNextHop evpn instance nexthop
- * @param prefix evpn prefix
- * @param nextHop evpn nexthop
- * @param label label
- */
- public EvpnInstanceRoute(EvpnInstanceName evpnName,
- RouteDistinguisher rd,
- List<VpnRouteTarget> importRtList,
- List<VpnRouteTarget> exportRtList,
- EvpnInstancePrefix evpnInstancePrefix,
- EvpnInstanceNextHop evpnInstanceNextHop,
- IpPrefix prefix,
- IpAddress nextHop,
- Label label) {
- checkNotNull(evpnName);
- checkNotNull(prefix);
- //checkNotNull(nextHop); //can be NULL in MP un reach
- checkNotNull(rd);
-
- this.evpnName = evpnName;
- this.rd = rd;
- this.importRtList = importRtList;
- this.exportRtList = exportRtList;
- this.prefix = prefix;
- this.nextHop = nextHop;
- this.evpnInstancePrefix = evpnInstancePrefix;
- this.evpnInstanceNextHop = evpnInstanceNextHop;
- this.label = label;
- }
-
- /**
- * Returns the evpnName.
- *
- * @return EvpnInstanceName
- */
- public EvpnInstanceName evpnInstanceName() {
- return evpnName;
- }
-
- /**
- * Returns the route distinguisher.
- *
- * @return RouteDistinguisher
- */
- public RouteDistinguisher routeDistinguisher() {
- return rd;
- }
-
- /**
- * Returns the Route targets.
- *
- * @return RouteTarget List
- */
-
- public List<VpnRouteTarget> importRouteTarget() {
- return importRtList;
- }
-
- /**
- * Returns the Route targets.
- *
- * @return RouteTarget List
- */
- public List<VpnRouteTarget> exportRouteTarget() {
- return exportRtList;
- }
-
- /**
- * Set import list.
- *
- * @param importRtList import list
- */
- public void setImportRtList(List<VpnRouteTarget> importRtList) {
- this.importRtList = importRtList;
- }
-
- /**
- * Set export list.
- *
- * @param exportRtList export list
- */
- public void setExportRtList(List<VpnRouteTarget> exportRtList) {
- this.exportRtList = exportRtList;
- }
-
- /**
- * Returns EvpnInstancePrefix of the evpn private route.
- *
- * @return EvpnInstancePrefix
- */
-
- public EvpnInstancePrefix getevpnInstancePrefix() {
- return evpnInstancePrefix;
- }
-
- /**
- * Returns EvpnInstanceNextHop of the evpn private route.
- *
- * @return EvpnInstancePrefix
- */
-
- public EvpnInstanceNextHop getEvpnInstanceNextHop() {
- return evpnInstanceNextHop;
- }
-
- /**
- * Returns prefix of the evpn private route.
- *
- * @return EvpnInstancePrefix
- */
- public IpPrefix prefix() {
- return prefix;
- }
-
- /**
- * Returns the label.
- *
- * @return EvpnInstanceName
- */
- public Label getLabel() {
- return label;
- }
-
- /**
- * Returns the label.
- *
- * @return EvpnInstanceName
- */
- public IpAddress getNextHopl() {
- return nextHop;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(evpnName, prefix, nextHop,
- rd, importRtList, exportRtList);
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- if (!(other instanceof EvpnInstanceRoute)) {
- return false;
- }
-
- EvpnInstanceRoute that = (EvpnInstanceRoute) other;
-
- return Objects.equals(prefix, that.prefix)
- && Objects.equals(nextHop, that.nextHop)
- && Objects.equals(evpnName, that.evpnName)
- && Objects.equals(rd, that.rd)
- && Objects.equals(importRtList, that.importRtList)
- && Objects.equals(exportRtList, that.exportRtList);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("prefix", prefix)
- .add("nextHop", nextHop)
- .add("rd", rd)
- .add("import rt", importRtList)
- .add("export rt", exportRtList)
- .add("evpnName", evpnName)
- .toString();
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInternalRouteEvent.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInternalRouteEvent.java
deleted file mode 100644
index 7a71875..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInternalRouteEvent.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import org.onosproject.event.AbstractEvent;
-
-/**
- * Route event for signalling between the store and the manager.
- */
-public class EvpnInternalRouteEvent extends
- AbstractEvent<EvpnInternalRouteEvent.Type, EvpnRouteSet> {
-
- /**
- * Internal route event type.
- */
- public enum Type {
- /**
- * Indicates a route was added to the store.
- */
- ROUTE_ADDED,
-
- /**
- * Indicates a route was removed from the store.
- */
- ROUTE_REMOVED
- }
-
- /**
- * Creates a new internal route event.
- *
- * @param type route event type
- * @param subject route set
- */
- public EvpnInternalRouteEvent(Type type, EvpnRouteSet subject) {
- super(type, subject);
- }
-
- public EvpnInternalRouteEvent(Type type, EvpnRouteSet subject, long time) {
- super(type, subject, time);
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnNextHop.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnNextHop.java
deleted file mode 100644
index ac1e06b..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnNextHop.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.List;
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Represents a evpn next hop.
- */
-public final class EvpnNextHop {
-
- private final IpAddress nextHop;
- private final List<VpnRouteTarget> importRtList;
- private final List<VpnRouteTarget> exportRtList;
- private final Label label;
-
- /**
- * Constructor to initialize the parameters.
- *
- * @param nextHop evpn next hop
- * @param importRtList import route targets
- * @param importRtList export route targets
- * @param label label
- */
- private EvpnNextHop(IpAddress nextHop, List<VpnRouteTarget> importRtList, List<VpnRouteTarget> exportRtList,
- Label label) {
- this.nextHop = nextHop;
- this.importRtList = importRtList;
- this.exportRtList = exportRtList;
- this.label = label;
- }
-
- /**
- * Creates the Evpn Next hop with given parameters.
- *
- * @param nextHop Next hop of the route
- * @param importRtList route target import list
- * @param exportRtList route target export list
- * @param label label of evpn route
- * @return EvpnNextHop
- */
- public static EvpnNextHop evpnNextHop(IpAddress nextHop, List<VpnRouteTarget> importRtList,
- List<VpnRouteTarget> exportRtList,
- Label label) {
- return new EvpnNextHop(nextHop, importRtList, exportRtList, label);
- }
-
- /**
- * Returns the next hop IP address.
- *
- * @return next hop
- */
- public IpAddress nextHop() {
- return nextHop;
- }
-
- /**
- * Returns the Route targets.
- *
- * @return RouteTarget List
- */
-
- public List<VpnRouteTarget> importRouteTarget() {
- return importRtList;
- }
-
- /**
- * Returns the Route targets.
- *
- * @return RouteTarget List
- */
- public List<VpnRouteTarget> exportRouteTarget() {
- return exportRtList;
- }
-
- /**
- * Returns the label of evpn route.
- *
- * @return Label
- */
- public Label label() {
- return label;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(nextHop, importRtList, exportRtList, label);
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- if (!(other instanceof EvpnNextHop)) {
- return false;
- }
-
- EvpnNextHop that = (EvpnNextHop) other;
-
- return Objects.equals(this.nextHop(), that.nextHop())
- && Objects.equals(this.importRtList, that.importRtList)
- && Objects.equals(this.exportRtList, that.exportRtList)
- && Objects.equals(this.label, that.label);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("nextHop", this.nextHop())
- .add("import rt list", this.importRtList).add("export rt list", this.exportRtList)
- .add("label", this.label).toString();
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnPrefix.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnPrefix.java
deleted file mode 100644
index 3f70ef5..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnPrefix.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.Objects;
-
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Represents a evpn prefix.
- */
-public final class EvpnPrefix {
-
- private final RouteDistinguisher rd;
- private final MacAddress macAddress;
- private final IpPrefix ipAddress;
-
- /**
- * Constructor to initialize the parameters.
- *
- * @param rd route distinguisher
- * @param macAddress mac address
- * @param ipAddress IP address
- */
- public EvpnPrefix(RouteDistinguisher rd, MacAddress macAddress,
- IpPrefix ipAddress) {
- checkNotNull(rd);
- checkNotNull(macAddress);
- checkNotNull(ipAddress);
- this.rd = rd;
- this.macAddress = macAddress;
- this.ipAddress = ipAddress;
- }
-
- /**
- * Creates the evpn prefix by given parameters.
- *
- * @param rd route distinguisher
- * @param macAddress mac address
- * @param ipAddress ip address
- * @return EvpnPrefix
- */
- public static EvpnPrefix evpnPrefix(RouteDistinguisher rd,
- MacAddress macAddress,
- IpPrefix ipAddress) {
- return new EvpnPrefix(rd, macAddress, ipAddress);
- }
-
- /**
- * Returns the route distinguisher.
- *
- * @return RouteDistinguisher
- */
- public RouteDistinguisher routeDistinguisher() {
- return rd;
- }
-
- /**
- * Returns the mac address.
- *
- * @return MacAddress
- */
- public MacAddress macAddress() {
- return macAddress;
- }
-
- /**
- * Returns the IP address.
- *
- * @return Ip4Address
- */
- public IpPrefix ipAddress() {
- return ipAddress;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rd, macAddress, ipAddress);
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- if (!(other instanceof EvpnPrefix)) {
- return false;
- }
-
- EvpnPrefix that = (EvpnPrefix) other;
-
- return Objects.equals(this.macAddress(), that.macAddress())
- && Objects.equals(this.ipAddress, that.ipAddress)
- && Objects.equals(this.rd, that.rd);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("macAddress", this.macAddress())
- .add("ipAddress", this.ipAddress()).add("rd", this.rd)
- .toString();
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRoute.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRoute.java
deleted file mode 100644
index 0f025d3..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRoute.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.List;
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Represents a evpn route.
- */
-public class EvpnRoute {
-
-
- /**
- * Source of the route.
- */
- public enum Source {
- /**
- * Route came from app source.
- */
- LOCAL,
-
- /**
- * Route came from remote bgp peer source.
- */
- REMOTE,
- }
-
- private final Source source;
- private final MacAddress prefixMac;
- private final IpPrefix prefix;
- private final IpAddress nextHop;
- private final RouteDistinguisher rd;
- private List<VpnRouteTarget> importRtList;
- private List<VpnRouteTarget> exportRtList;
- private final Label label;
-
- /**
- * Constructor to initialize the parameters.
- *
- * @param source route source
- * @param prefixMac mac address
- * @param prefix ip address
- * @param nextHop evpn nexthop
- * @param rd route distinguisher
- * @param importRtList import route targets
- * @param exportRtList export route targets
- * @param label evpn route label
- */
- public EvpnRoute(Source source,
- MacAddress prefixMac,
- IpPrefix prefix,
- IpAddress nextHop,
- RouteDistinguisher rd,
- List<VpnRouteTarget> importRtList,
- List<VpnRouteTarget> exportRtList,
- Label label) {
-
- checkNotNull(prefixMac);
- checkNotNull(prefix);
- //checkNotNull(nextHop);//next hop can be null in case of MP un reach.
- checkNotNull(rd);
- checkNotNull(label);
- this.source = checkNotNull(source);
- this.prefix = prefix;
- this.prefixMac = prefixMac;
- this.nextHop = nextHop;
- this.rd = rd;
- this.importRtList = importRtList;
- this.exportRtList = exportRtList;
- this.label = label;
- }
-
- /**
- * Constructor to initialize the parameters.
- *
- * @param source route source
- * @param prefixMac mac address
- * @param prefix ip address
- * @param nextHop evpn nexthop
- * @param rdToString route distinguisher
- * @param importRtList import route targets
- * @param exportRtList export route targets
- * @param labelToInt evpn route label
- */
- public EvpnRoute(Source source,
- MacAddress prefixMac,
- IpPrefix prefix,
- IpAddress nextHop,
- String rdToString,
- List<VpnRouteTarget> importRtList,
- List<VpnRouteTarget> exportRtList,
- int labelToInt) {
- checkNotNull(prefixMac);
- checkNotNull(prefix);
- //checkNotNull(nextHop); //next hop can be null in case of MP un reach.
- this.source = checkNotNull(source);
- this.prefix = prefix;
- this.prefixMac = prefixMac;
- this.nextHop = nextHop;
- this.rd = RouteDistinguisher.routeDistinguisher(rdToString);
- this.importRtList = importRtList;
- this.exportRtList = exportRtList;
- this.label = Label.label(labelToInt);
- }
-
- /**
- * Returns the route source.
- *
- * @return route source
- */
- public Source source() {
- return source;
- }
-
- /**
- * Returns the address.
- *
- * @return MacAddress
- */
- public MacAddress prefixMac() {
- return prefixMac;
- }
-
- /**
- * Returns the IPv4 address.
- *
- * @return Ip4Address
- */
- public IpPrefix prefixIp() {
- return prefix;
- }
-
- /**
- * Returns the IPv4 address.
- *
- * @return Ip4Address
- */
- public EvpnPrefix evpnPrefix() {
- return new EvpnPrefix(rd, prefixMac,
- prefix);
- }
-
-
- /**
- * Returns the next hop IP address.
- *
- * @return Ip4Address
- */
- public IpAddress ipNextHop() {
- return nextHop;
- }
-
- public EvpnNextHop nextHop() {
- return EvpnNextHop.evpnNextHop(nextHop,
- importRtList,
- exportRtList,
- label);
- }
-
- /**
- * Returns the routeDistinguisher.
- *
- * @return RouteDistinguisher
- */
- public RouteDistinguisher routeDistinguisher() {
- return rd;
- }
-
- /**
- * Returns the Route targets.
- *
- * @return RouteTarget List
- */
-
- public List<VpnRouteTarget> importRouteTarget() {
- return importRtList;
- }
-
- /**
- * Returns the Route targets.
- *
- * @return RouteTarget List
- */
- public List<VpnRouteTarget> exportRouteTarget() {
- return exportRtList;
- }
-
- /**
- * Set import list.
- *
- * @param importRtList import list
- */
- public void setImportRtList(List<VpnRouteTarget> importRtList) {
- this.importRtList = importRtList;
- }
-
- /**
- * Set export list.
- *
- * @param exportRtList export list
- */
- public void setExportRtList(List<VpnRouteTarget> exportRtList) {
- this.exportRtList = exportRtList;
- }
-
- /**
- * Returns the label.
- *
- * @return Label
- */
- public Label label() {
- return label;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(prefixMac,
- prefix,
- nextHop,
- rd,
- importRtList,
- exportRtList,
- label);
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- if (!(other instanceof EvpnRoute)) {
- return false;
- }
-
- EvpnRoute that = (EvpnRoute) other;
-
- return Objects.equals(prefixMac, that.prefixMac)
- && Objects.equals(prefix, that.prefix)
- && Objects.equals(nextHop, that.nextHop)
- && Objects.equals(this.rd, that.rd)
- && Objects.equals(this.importRtList, that.importRtList)
- && Objects.equals(this.exportRtList, that.exportRtList)
- && Objects.equals(this.label, that.label);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("prefixMac", prefixMac)
- .add("prefix", prefix)
- .add("nextHop", nextHop)
- .add("rd", this.rd)
- .add("import rt", this.importRtList)
- .add("export rt", this.exportRtList)
- .add("label", this.label)
- .toString();
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteAdminService.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteAdminService.java
deleted file mode 100644
index cc9e200..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteAdminService.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.Collection;
-
-/**
- * Service allowing mutation of EVPN routing state.
- */
-public interface EvpnRouteAdminService extends EvpnRouteService {
-
- /**
- * Updates the given routes in the route service.
- *
- * @param routes collection of routes to update
- */
- void update(Collection<EvpnRoute> routes);
-
- /**
- * Withdraws the given routes from the route service.
- *
- * @param routes collection of routes to withdraw
- */
- void withdraw(Collection<EvpnRoute> routes);
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteEvent.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteEvent.java
deleted file mode 100644
index 5e7f83a..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteEvent.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Objects;
-
-import org.onlab.util.Tools;
-import org.onosproject.event.AbstractEvent;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Describes an event about a route.
- */
-public class EvpnRouteEvent extends AbstractEvent<EvpnRouteEvent.Type,
- EvpnRoute> {
-
- private final EvpnRoute prevSubject;
- private final Collection<EvpnRoute> alternativeRoutes;
-
- /**
- * Route event type.
- */
- public enum Type {
-
- /**
- * Route is new and the next hop is resolved.
- * <p>
- * The subject of this event should be the route being added.
- * The prevSubject of this event should be null.
- * </p>
- */
- ROUTE_ADDED,
-
- /**
- * Route has updated information.
- * <p>
- * The subject of this event should be the new route.
- * The prevSubject of this event should be the old route.
- * </p>
- */
- ROUTE_UPDATED,
-
- /**
- * Route was removed or the next hop becomes unresolved.
- * <p>
- * The subject of this event should be the route being removed.
- * The prevSubject of this event should be null.
- * </p>
- */
- ROUTE_REMOVED,
-
- /**
- * The set of alternative routes for the subject's prefix has changed,
- * but the best route is still the same.
- * <p>
- * The subject is the best route for the prefix (which has already been
- * notified in a previous event).
- * The prevSubject of this event is null.
- * The alternatives contains the new set of alternative routes.
- * </p>
- */
- ALTERNATIVE_ROUTES_CHANGED
- }
-
- /**
- * Creates a new route event without specifying previous subject.
- *
- * @param type event type
- * @param subject event subject
- */
- public EvpnRouteEvent(Type type, EvpnRoute subject) {
- this(type, subject, null, Collections.emptySet());
- }
-
- /**
- * Creates a new route event without specifying previous subject.
- *
- * @param type event type
- * @param subject event subject
- * @param alternatives alternative routes for subject's prefix
- */
- public EvpnRouteEvent(Type type, EvpnRoute subject,
- Collection<EvpnRoute> alternatives) {
- this(type, subject, null, alternatives);
- }
-
- /**
- * Creates a new route event.
- *
- * @param type event type
- * @param subject event subject
- * @param time event time
- */
- protected EvpnRouteEvent(Type type, EvpnRoute subject, long time) {
- super(type, subject, time);
- this.prevSubject = null;
-
- this.alternativeRoutes = Collections.emptySet();
- }
-
- /**
- * Creates a new route event with previous subject.
- *
- * @param type event type
- * @param subject event subject
- * @param prevSubject previous subject
- */
- public EvpnRouteEvent(Type type, EvpnRoute subject, EvpnRoute prevSubject) {
- this(type, subject, prevSubject, Collections.emptySet());
- }
-
- /**
- * Creates a new route event with a previous subject and alternative routes.
- *
- * @param type event type
- * @param subject event subject
- * @param prevSubject previous subject
- * @param alternatives alternative routes for subject's prefix
- */
- public EvpnRouteEvent(Type type, EvpnRoute subject, EvpnRoute prevSubject,
- Collection<EvpnRoute> alternatives) {
- super(type, subject);
- this.prevSubject = prevSubject;
- this.alternativeRoutes = alternatives;
- }
-
- /**
- * Returns the previous subject of the event.
- *
- * @return previous subject to which this event pertains
- */
- public EvpnRoute prevSubject() {
- return prevSubject;
- }
-
- /**
- * Returns the set of alternative routes for the subject's prefix.
- *
- * @return alternative routes
- */
- public Collection<EvpnRoute> alternatives() {
- return alternativeRoutes;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(subject(), type(), prevSubject(), alternativeRoutes);
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- if (!(other instanceof EvpnRouteEvent)) {
- return false;
- }
-
- EvpnRouteEvent that = (EvpnRouteEvent) other;
-
- return Objects.equals(this.subject(), that.subject()) &&
- Objects.equals(this.type(), that.type()) &&
- Objects.equals(this.prevSubject, that.prevSubject) &&
- Objects.equals(this.alternativeRoutes, that.alternativeRoutes);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("time", Tools.defaultOffsetDataTime(time()))
- .add("type", type())
- .add("subject", subject())
- .add("prevSubject", prevSubject)
- .add("alternatives", alternativeRoutes)
- .toString();
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteListener.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteListener.java
deleted file mode 100644
index 32a35c2..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Listener for route events.
- */
-public interface EvpnRouteListener extends EventListener<EvpnRouteEvent> {
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteService.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteService.java
deleted file mode 100644
index ca9c031..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteService.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.Collection;
-
-import org.onosproject.event.ListenerService;
-
-/**
- * EVPN route service.
- */
-public interface EvpnRouteService extends ListenerService<EvpnRouteEvent,
- EvpnRouteListener> {
-
-
- /**
- * Returns the set of route tables in the system.
- *
- * @return collection of route table IDs.
- */
- Collection<EvpnRouteTableId> getRouteTables();
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteSet.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteSet.java
deleted file mode 100644
index 707df22..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteSet.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.Objects;
-import java.util.Set;
-
-import com.google.common.collect.ImmutableSet;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * A set of routes for a particular prefix in a route table.
- */
-public class EvpnRouteSet {
- private final EvpnRouteTableId tableId;
-
- private final EvpnPrefix prefix;
- private final Set<EvpnRoute> routes;
-
- /**
- * Creates a new route set.
- *
- * @param tableId route table ID
- * @param prefix IP prefix
- * @param routes routes for the given prefix
- */
- public EvpnRouteSet(EvpnRouteTableId tableId, EvpnPrefix prefix, Set<EvpnRoute>
- routes) {
- this.tableId = checkNotNull(tableId);
- this.prefix = checkNotNull(prefix);
- this.routes = ImmutableSet.copyOf(checkNotNull(routes));
- }
-
- /**
- * Returns the route table ID.
- *
- * @return route table ID
- */
- public EvpnRouteTableId tableId() {
- return tableId;
- }
-
- /**
- * Returns the IP prefix.
- *
- * @return IP prefix
- */
- public EvpnPrefix prefix() {
- return prefix;
- }
-
- /**
- * Returns the set of routes.
- *
- * @return routes
- */
- public Set<EvpnRoute> routes() {
- return routes;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(tableId, prefix, routes);
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- if (!(other instanceof EvpnRouteSet)) {
- return false;
- }
-
- EvpnRouteSet that = (EvpnRouteSet) other;
-
- return Objects.equals(this.tableId, that.tableId) &&
- Objects.equals(this.prefix, that.prefix) &&
- Objects.equals(this.routes, that.routes);
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteStore.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteStore.java
deleted file mode 100644
index c06704f..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteStore.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.onlab.packet.IpAddress;
-import org.onosproject.store.Store;
-
-/**
- * EVPN route store.
- */
-public interface EvpnRouteStore extends Store<EvpnInternalRouteEvent,
- EvpnRouteStoreDelegate> {
-
- /**
- * Adds or updates the given route in the store.
- *
- * @param route route to add or update
- */
- void updateRoute(EvpnRoute route);
-
- /**
- * Removes the given route from the store.
- *
- * @param route route to remove
- */
- void removeRoute(EvpnRoute route);
-
- /**
- * Returns the IDs for all route tables in the store.
- *
- * @return route table IDs
- */
- Set<EvpnRouteTableId> getRouteTables();
-
- /**
- * Returns the routes in the given route table, grouped by prefix.
- *
- * @param table route table ID
- * @return routes
- */
- Collection<EvpnRouteSet> getRoutes(EvpnRouteTableId table);
-
- /**
- * Returns the routes that point to the given next hop IP address.
- *
- * @param ip IP address of the next hop
- * @return routes for the given next hop
- */
- // TODO think about including route table info
- Collection<EvpnRoute> getRoutesForNextHop(IpAddress ip);
-
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteStoreDelegate.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteStoreDelegate.java
deleted file mode 100644
index d714adc..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteStoreDelegate.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import org.onosproject.store.StoreDelegate;
-
-/**
- * Route store delegate abstraction.
- */
-public interface EvpnRouteStoreDelegate extends
- StoreDelegate<EvpnInternalRouteEvent> {
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteTableId.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteTableId.java
deleted file mode 100644
index 846a8d1..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteTableId.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.Objects;
-
-/**
- * Identifier for an EVPN routing table.
- */
-public class EvpnRouteTableId {
- private final String name;
-
- /**
- * Creates a new route table ID.
- *
- * @param name unique name for the route table
- */
- public EvpnRouteTableId(String name) {
- this.name = name;
- }
-
- /**
- * Returns the name of the route table.
- *
- * @return table name
- */
- public String name() {
- return name;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof EvpnRouteTableId) {
- EvpnRouteTableId that = (EvpnRouteTableId) obj;
-
- return Objects.equals(this.name, that.name);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name);
- }
-
- @Override
- public String toString() {
- return name;
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnTable.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnTable.java
deleted file mode 100755
index 0b3379f..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnTable.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.Collection;
-
-import org.onlab.packet.IpAddress;
-
-/**
- * Represents a route table that stores routes.
- */
-public interface EvpnTable {
-
- /**
- * Adds a route to the route table.
- *
- * @param route route
- */
- void update(EvpnRoute route);
-
- /**
- * Removes a route from the route table.
- *
- * @param route route
- */
- void remove(EvpnRoute route);
-
- /**
- * Returns the route table ID.
- *
- * @return route table ID
- */
- EvpnRouteTableId id();
-
- /**
- * Returns all routes in the route table.
- *
- * @return collection of routes, grouped by prefix
- */
- Collection<EvpnRouteSet> getRoutes();
-
- /**
- * Returns the routes in this table pertaining to a given prefix.
- *
- * @param prefix IP prefix
- * @return routes for the prefix
- */
- EvpnRouteSet getRoutes(EvpnPrefix prefix);
-
- /**
- * Returns all routes that have the given next hop.
- *
- * @param nextHop next hop IP address
- * @return collection of routes
- */
- Collection<EvpnRoute> getRoutesForNextHop(IpAddress nextHop);
-
- /**
- * Releases route table resources held locally.
- */
- void shutdown();
-
- /**
- * Releases route table resources across the entire cluster.
- */
- void destroy();
-
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/Label.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/Label.java
deleted file mode 100644
index 8d90611..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/Label.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Represents label of the route.
- */
-public final class Label {
- private final int label;
-
- /**
- * Constructor to initialize parameters.
- *
- * @param label route label
- */
- private Label(int label) {
- this.label = label;
- }
-
- /**
- * Creates the label for evpn route.
- *
- * @param label label of evpn route
- * @return Label
- */
- public static Label label(int label) {
- return new Label(label);
- }
-
- /**
- * Returns the label.
- *
- * @return label
- */
- public int getLabel() {
- return label;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(label);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof Label) {
- Label other = (Label) obj;
- return Objects.equals(label, other.label);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("label", label).toString();
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/RouteDistinguisher.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/RouteDistinguisher.java
deleted file mode 100644
index ca217b6..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/RouteDistinguisher.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Represents Route Distinguisher of device in the network.
- */
-public final class RouteDistinguisher {
- private final String routeDistinguisher;
-
- /**
- * Constructor to initialize parameters.
- *
- * @param routeDistinguisher route distinguisher
- */
- private RouteDistinguisher(String routeDistinguisher) {
- this.routeDistinguisher = routeDistinguisher;
- }
-
- /**
- * Creates the route distinguisher.
- *
- * @param routeDistinguisher route distinguisher
- * @return RouteDistinguisher
- */
- public static RouteDistinguisher routeDistinguisher(String routeDistinguisher) {
- checkNotNull(routeDistinguisher);
- return new RouteDistinguisher(routeDistinguisher);
- }
-
- /**
- * get route distinguisher.
- *
- * @return distinguisher
- */
- public String getRouteDistinguisher() {
- return routeDistinguisher;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(routeDistinguisher);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof RouteDistinguisher) {
- RouteDistinguisher other = (RouteDistinguisher) obj;
- return Objects.equals(this.routeDistinguisher, other.routeDistinguisher);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("routeDistinguisher", this.routeDistinguisher).toString();
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/VpnRouteTarget.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/VpnRouteTarget.java
deleted file mode 100644
index 51a9a59..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/VpnRouteTarget.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Represents Route target of vpn instance.
- */
-public final class VpnRouteTarget {
- private final String routeTarget;
-
- /**
- * Constructor to initialize parameters.
- *
- * @param routeTarget route target
- */
- private VpnRouteTarget(String routeTarget) {
- this.routeTarget = routeTarget;
- }
-
- /**
- * Creates the vpn route target.
- *
- * @param routeTarget route target
- * @return route target
- */
- public static VpnRouteTarget routeTarget(String routeTarget) {
- return new VpnRouteTarget(routeTarget);
- }
-
- /**
- * get the route target.
- *
- * @return route target
- */
- public String getRouteTarget() {
- return routeTarget;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(routeTarget);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof VpnRouteTarget) {
- VpnRouteTarget other = (VpnRouteTarget) obj;
- return Objects.equals(routeTarget, other.routeTarget);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("routeTarget", routeTarget).toString();
- }
-}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/package-info.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/package-info.java
deleted file mode 100644
index 3514c80..0000000
--- a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Unicast routing service.
- */
-package org.onosproject.evpnrouteservice;
diff --git a/apps/evpn-route-service/app/BUILD b/apps/evpn-route-service/app/BUILD
deleted file mode 100644
index 6786730..0000000
--- a/apps/evpn-route-service/app/BUILD
+++ /dev/null
@@ -1,8 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + KRYO + [
- "//core/store/serializers:onos-core-serializers",
- "//apps/evpn-route-service/api:onos-apps-evpn-route-service-api",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
diff --git a/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/impl/EvpnListenerQueue.java b/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/impl/EvpnListenerQueue.java
deleted file mode 100644
index ce3d012..0000000
--- a/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/impl/EvpnListenerQueue.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice.impl;
-
-import org.onosproject.evpnrouteservice.EvpnRouteEvent;
-
-/**
- * Queues updates for a route listener to ensure they are received in the
- * correct order.
- */
-interface EvpnListenerQueue {
-
- /**
- * Posts an event to the listener.
- *
- * @param event event
- */
- void post(EvpnRouteEvent event);
-
- /**
- * Initiates event delivery to the listener.
- */
- void start();
-
- /**
- * Halts event delivery to the listener.
- */
- void stop();
-}
diff --git a/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/impl/EvpnRouteManager.java b/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/impl/EvpnRouteManager.java
deleted file mode 100644
index f13b89a..0000000
--- a/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/impl/EvpnRouteManager.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice.impl;
-
-import org.onosproject.evpnrouteservice.EvpnInternalRouteEvent;
-import org.onosproject.evpnrouteservice.EvpnRoute;
-import org.onosproject.evpnrouteservice.EvpnRouteAdminService;
-import org.onosproject.evpnrouteservice.EvpnRouteEvent;
-import org.onosproject.evpnrouteservice.EvpnRouteListener;
-import org.onosproject.evpnrouteservice.EvpnRouteService;
-import org.onosproject.evpnrouteservice.EvpnRouteSet;
-import org.onosproject.evpnrouteservice.EvpnRouteStore;
-import org.onosproject.evpnrouteservice.EvpnRouteStoreDelegate;
-import org.onosproject.evpnrouteservice.EvpnRouteTableId;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.concurrent.GuardedBy;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadFactory;
-
-import static java.util.concurrent.Executors.newSingleThreadExecutor;
-import static org.onlab.util.Tools.groupedThreads;
-
-/**
- * Implementation of the EVPN route service.
- */
-@Component(service = { EvpnRouteService.class, EvpnRouteAdminService.class })
-public class EvpnRouteManager implements EvpnRouteService,
- EvpnRouteAdminService {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected EvpnRouteStore evpnRouteStore;
-
- @GuardedBy(value = "this")
- private Map<EvpnRouteListener, EvpnListenerQueue> listeners = new
- HashMap<>();
-
- private ThreadFactory threadFactory;
-
- private EvpnRouteStoreDelegate evpnRouteStoreDelegate = new
- InternalEvpnRouteStoreDelegate();
-
- @Activate
- protected void activate() {
- threadFactory = groupedThreads("onos/route", "listener-%d", log);
- evpnRouteStore.setDelegate(evpnRouteStoreDelegate);
-
- }
-
- @Deactivate
- protected void deactivate() {
- evpnRouteStore.unsetDelegate(evpnRouteStoreDelegate);
- synchronized (this) {
- listeners.values().forEach(EvpnListenerQueue::stop);
- }
- }
-
- /**
- * {@inheritDoc}
- * <p>
- * In a departure from other services in ONOS, calling addListener will
- * cause all current routes to be pushed to the listener before any new
- * events are sent. This allows a listener to easily get the exact set of
- * routes without worrying about missing any.
- *
- * @param listener listener to be added
- */
- @Override
- public void addListener(EvpnRouteListener listener) {
- synchronized (this) {
- EvpnListenerQueue l = createListenerQueue(listener);
-
- evpnRouteStore.getRouteTables().forEach(routeTableId
- -> {
- Collection<EvpnRouteSet> routes
- = evpnRouteStore.getRoutes(routeTableId);
- if (routes != null) {
- routes.forEach(route -> {
- Collection<EvpnRoute> evpnRoutes = route.routes();
- for (EvpnRoute evpnRoute : evpnRoutes) {
- l.post(new EvpnRouteEvent(
- EvpnRouteEvent.Type.ROUTE_ADDED,
- evpnRoute,
- route.routes()));
- }
- });
- }
- });
- listeners.put(listener, l);
-
- l.start();
- log.debug("Route synchronization complete");
- }
- }
-
- @Override
- public void removeListener(EvpnRouteListener listener) {
- synchronized (this) {
- EvpnListenerQueue l = listeners.remove(listener);
- if (l != null) {
- l.stop();
- }
- }
- }
-
- /**
- * Posts an event to all listeners.
- *
- * @param event event
- */
-
- private void post(EvpnRouteEvent event) {
- if (event != null) {
- log.debug("Sending event {}", event);
- synchronized (this) {
- listeners.values().forEach(l -> l.post(event));
- }
- }
- }
-
-
- @Override
- public Collection<EvpnRouteTableId> getRouteTables() {
- return evpnRouteStore.getRouteTables();
- }
-
- @Override
- public void update(Collection<EvpnRoute> routes) {
- synchronized (this) {
- routes.forEach(route -> {
- log.debug("Received update {}", route);
- evpnRouteStore.updateRoute(route);
- });
- }
- }
-
- @Override
- public void withdraw(Collection<EvpnRoute> routes) {
- synchronized (this) {
- routes.forEach(route -> {
- log.debug("Received withdraw {}", route);
- evpnRouteStore.removeRoute(route);
- });
- }
- }
-
- /**
- * Creates a new listener queue.
- *
- * @param listener route listener
- * @return listener queue
- */
- DefaultListenerQueue createListenerQueue(EvpnRouteListener listener) {
- return new DefaultListenerQueue(listener);
- }
-
- /**
- * Default route listener queue.
- */
- private class DefaultListenerQueue implements EvpnListenerQueue {
-
- private final ExecutorService executorService;
- private final BlockingQueue<EvpnRouteEvent> queue;
- private final EvpnRouteListener listener;
-
- /**
- * Creates a new listener queue.
- *
- * @param listener route listener to queue updates for
- */
- public DefaultListenerQueue(EvpnRouteListener listener) {
- this.listener = listener;
- queue = new LinkedBlockingQueue<>();
- executorService = newSingleThreadExecutor(threadFactory);
- }
-
- @Override
- public void post(EvpnRouteEvent event) {
- queue.add(event);
- }
-
- @Override
- public void start() {
- executorService.execute(this::poll);
- }
-
- @Override
- public void stop() {
- executorService.shutdown();
- }
-
- private void poll() {
- while (true) {
- try {
- listener.event(queue.take());
- } catch (InterruptedException e) {
- log.info("Route listener event thread shutting down: {}", e.getMessage());
- Thread.currentThread().interrupt();
- break;
- } catch (Exception e) {
- log.warn("Exception during route event handler", e);
- }
- }
- }
- }
-
- /**
- * Delegate to receive events from the route store.
- */
- private class InternalEvpnRouteStoreDelegate implements
- EvpnRouteStoreDelegate {
- EvpnRouteSet routes;
-
- @Override
- public void notify(EvpnInternalRouteEvent event) {
- switch (event.type()) {
- case ROUTE_ADDED:
- routes = event.subject();
- if (routes != null) {
- Collection<EvpnRoute> evpnRoutes = routes.routes();
- for (EvpnRoute evpnRoute : evpnRoutes) {
- post(new EvpnRouteEvent(
- EvpnRouteEvent.Type.ROUTE_ADDED,
- evpnRoute,
- routes.routes()));
- }
- }
- break;
- case ROUTE_REMOVED:
- routes = event.subject();
- if (routes != null) {
- Collection<EvpnRoute> evpnRoutes = routes.routes();
- for (EvpnRoute evpnRoute : evpnRoutes) {
- post(new EvpnRouteEvent(
- EvpnRouteEvent.Type.ROUTE_REMOVED,
- evpnRoute,
- routes.routes()));
- }
- }
- break;
- default:
- break;
- }
- }
- }
-
-}
diff --git a/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/impl/package-info.java b/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/impl/package-info.java
deleted file mode 100644
index 80892c9..0000000
--- a/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of route service.
- */
-package org.onosproject.evpnrouteservice.impl;
diff --git a/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/store/DistributedEvpnRouteStore.java b/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/store/DistributedEvpnRouteStore.java
deleted file mode 100644
index 8917325..0000000
--- a/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/store/DistributedEvpnRouteStore.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice.store;
-
-import com.google.common.collect.ImmutableSet;
-import org.onlab.packet.IpAddress;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.evpnrouteservice.EvpnInternalRouteEvent;
-import org.onosproject.evpnrouteservice.EvpnRoute;
-import org.onosproject.evpnrouteservice.EvpnRouteSet;
-import org.onosproject.evpnrouteservice.EvpnRouteStore;
-import org.onosproject.evpnrouteservice.EvpnRouteStoreDelegate;
-import org.onosproject.evpnrouteservice.EvpnRouteTableId;
-import org.onosproject.evpnrouteservice.EvpnTable;
-import org.onosproject.store.AbstractStore;
-import org.onosproject.store.service.DistributedSet;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.SetEvent;
-import org.onosproject.store.service.SetEventListener;
-import org.onosproject.store.service.StorageService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import static org.onlab.util.Tools.groupedThreads;
-
-/**
- * Route store based on distributed storage.
- */
-@Component(service = EvpnRouteStore.class)
-public class DistributedEvpnRouteStore extends
- AbstractStore<EvpnInternalRouteEvent,
- EvpnRouteStoreDelegate>
- implements EvpnRouteStore {
-
- private static final Logger log = LoggerFactory
- .getLogger(DistributedEvpnRouteStore.class);
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- public StorageService storageService;
-
- private static final EvpnRouteTableId EVPN_IPV4 = new EvpnRouteTableId("evpn_ipv4");
- private static final EvpnRouteTableId EVPN_IPV6 = new EvpnRouteTableId("evpn_ipv6");
-
- private final SetEventListener<EvpnRouteTableId> masterRouteTableListener =
- new MasterRouteTableListener();
- private final EvpnRouteStoreDelegate ourDelegate = new
- InternalEvpnRouteStoreDelegate();
-
- // Stores the route tables that have been created
- public DistributedSet<EvpnRouteTableId> masterRouteTable;
- // Local memory map to store route table object
- public Map<EvpnRouteTableId, EvpnTable> routeTables;
-
- private ExecutorService executor;
-
-
- /**
- * Sets up distributed route store.
- */
- @Activate
- public void activate() {
- routeTables = new ConcurrentHashMap<>();
- executor = Executors.newSingleThreadExecutor(groupedThreads("onos/route", "store", log));
-
- KryoNamespace masterRouteTableSerializer = KryoNamespace.newBuilder()
- .register(EvpnRouteTableId.class)
- .build();
-
- masterRouteTable = storageService.<EvpnRouteTableId>setBuilder()
- .withName("onos-master-route-table")
- .withSerializer(Serializer.using(masterRouteTableSerializer))
- .build()
- .asDistributedSet();
-
- masterRouteTable.forEach(this::createRouteTable);
-
- masterRouteTable.addListener(masterRouteTableListener);
-
- // Add default tables (add is idempotent)
- masterRouteTable.add(EVPN_IPV4);
- masterRouteTable.add(EVPN_IPV6);
-
- log.info("Started");
- }
-
- /**
- * Cleans up distributed route store.
- */
- @Deactivate
- public void deactivate() {
- masterRouteTable.removeListener(masterRouteTableListener);
-
- routeTables.values().forEach(EvpnTable::shutdown);
-
- log.info("Stopped");
- }
-
- @Override
- public void updateRoute(EvpnRoute route) {
- getDefaultRouteTable(route).update(route);
- }
-
- @Override
- public void removeRoute(EvpnRoute route) {
- getDefaultRouteTable(route).remove(route);
- }
-
- @Override
- public Set<EvpnRouteTableId> getRouteTables() {
- return ImmutableSet.copyOf(masterRouteTable);
- }
-
- @Override
- public Collection<EvpnRouteSet> getRoutes(EvpnRouteTableId table) {
- EvpnTable routeTable = routeTables.get(table);
- if (routeTable == null) {
- return Collections.emptySet();
- } else {
- return ImmutableSet.copyOf(routeTable.getRoutes());
- }
- }
-
- @Override
- public Collection<EvpnRoute> getRoutesForNextHop(IpAddress ip) {
- return getDefaultRouteTable(ip).getRoutesForNextHop(ip);
- }
-
- private void createRouteTable(EvpnRouteTableId tableId) {
- routeTables.computeIfAbsent(tableId, id -> new EvpnRouteTable(id,
- ourDelegate, storageService, executor));
- }
-
- private void destroyRouteTable(EvpnRouteTableId tableId) {
- EvpnTable table = routeTables.remove(tableId);
- if (table != null) {
- table.destroy();
- }
- }
-
- private EvpnTable getDefaultRouteTable(EvpnRoute route) {
- return getDefaultRouteTable(route.prefixIp().address());
- }
-
- private EvpnTable getDefaultRouteTable(IpAddress ip) {
- EvpnRouteTableId routeTableId = (ip.isIp4()) ? EVPN_IPV4 : EVPN_IPV6;
- return routeTables.getOrDefault(routeTableId, EmptyEvpnRouteTable
- .instance());
- }
-
- private class InternalEvpnRouteStoreDelegate implements
- EvpnRouteStoreDelegate {
- @Override
- public void notify(EvpnInternalRouteEvent event) {
- executor.execute(() -> DistributedEvpnRouteStore
- .this.notifyDelegate(event));
- }
- }
-
- private class MasterRouteTableListener implements SetEventListener<EvpnRouteTableId> {
- @Override
- public void event(SetEvent<EvpnRouteTableId> event) {
- switch (event.type()) {
- case ADD:
- executor.execute(() -> createRouteTable(event.entry()));
- break;
- case REMOVE:
- executor.execute(() -> destroyRouteTable(event.entry()));
- break;
- default:
- break;
- }
- }
- }
-}
diff --git a/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/store/EmptyEvpnRouteTable.java b/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/store/EmptyEvpnRouteTable.java
deleted file mode 100644
index f49a174..0000000
--- a/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/store/EmptyEvpnRouteTable.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice.store;
-
-import org.onlab.packet.IpAddress;
-import org.onosproject.evpnrouteservice.EvpnPrefix;
-import org.onosproject.evpnrouteservice.EvpnRoute;
-import org.onosproject.evpnrouteservice.EvpnRouteSet;
-import org.onosproject.evpnrouteservice.EvpnRouteTableId;
-import org.onosproject.evpnrouteservice.EvpnTable;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * Route table that contains no routes.
- */
-public final class EmptyEvpnRouteTable implements EvpnTable {
-
- private final EvpnRouteTableId id = new EvpnRouteTableId("empty");
-
- private static final EmptyEvpnRouteTable INSTANCE = new EmptyEvpnRouteTable();
-
- /**
- * Returns the instance of the empty route table.
- *
- * @return empty route table
- */
- public static EmptyEvpnRouteTable instance() {
- return INSTANCE;
- }
-
- private EmptyEvpnRouteTable() {
- }
-
- @Override
- public void update(EvpnRoute route) {
-
- }
-
- @Override
- public void remove(EvpnRoute route) {
-
- }
-
- @Override
- public EvpnRouteTableId id() {
- return id;
- }
-
- @Override
- public Collection<EvpnRouteSet> getRoutes() {
- return Collections.emptyList();
- }
-
- @Override
- public EvpnRouteSet getRoutes(EvpnPrefix prefix) {
- return null;
- }
-
- @Override
- public Collection<EvpnRoute> getRoutesForNextHop(IpAddress nextHop) {
- return Collections.emptyList();
- }
-
- @Override
- public void shutdown() {
-
- }
-
- @Override
- public void destroy() {
-
- }
-}
diff --git a/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/store/EvpnRouteTable.java b/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/store/EvpnRouteTable.java
deleted file mode 100644
index 2c3e07b..0000000
--- a/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/store/EvpnRouteTable.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnrouteservice.store;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.evpnrouteservice.EvpnInternalRouteEvent;
-import org.onosproject.evpnrouteservice.EvpnPrefix;
-import org.onosproject.evpnrouteservice.EvpnRoute;
-import org.onosproject.evpnrouteservice.EvpnRouteSet;
-import org.onosproject.evpnrouteservice.EvpnRouteStoreDelegate;
-import org.onosproject.evpnrouteservice.EvpnRouteTableId;
-import org.onosproject.evpnrouteservice.EvpnTable;
-import org.onosproject.evpnrouteservice.Label;
-import org.onosproject.evpnrouteservice.RouteDistinguisher;
-import org.onosproject.evpnrouteservice.VpnRouteTarget;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.DistributedPrimitive;
-import org.onosproject.store.service.MapEvent;
-import org.onosproject.store.service.MapEventListener;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.Versioned;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Default implementation of a route table based on a consistent map.
- */
-public class EvpnRouteTable implements EvpnTable {
-
- private final EvpnRouteTableId id;
- private final ConsistentMap<EvpnPrefix, Set<EvpnRoute>> routes;
- private final EvpnRouteStoreDelegate delegate;
- private final ExecutorService executor;
- private final RouteTableListener listener = new RouteTableListener();
-
- private final Consumer<DistributedPrimitive.Status> statusChangeListener;
-
- /**
- * Creates a new route table.
- *
- * @param id route table ID
- * @param delegate route store delegate to notify of events
- * @param storageService storage service
- * @param executor executor service
- */
- public EvpnRouteTable(EvpnRouteTableId id, EvpnRouteStoreDelegate delegate,
- StorageService storageService, ExecutorService executor) {
- this.delegate = checkNotNull(delegate);
- this.id = checkNotNull(id);
- this.routes = buildRouteMap(checkNotNull(storageService));
- this.executor = checkNotNull(executor);
-
- statusChangeListener = status -> {
- if (status.equals(DistributedPrimitive.Status.ACTIVE)) {
- executor.execute(this::notifyExistingRoutes);
- }
- };
- routes.addStatusChangeListener(statusChangeListener);
-
- notifyExistingRoutes();
-
- routes.addListener(listener);
- }
-
- private void notifyExistingRoutes() {
- routes.entrySet().stream()
- .map(e -> new EvpnInternalRouteEvent(
- EvpnInternalRouteEvent.Type.ROUTE_ADDED,
- new EvpnRouteSet(id, e.getKey(), e.getValue().value())))
- .forEach(delegate::notify);
- }
-
- private ConsistentMap<EvpnPrefix, Set<EvpnRoute>> buildRouteMap(StorageService
- storageService) {
- KryoNamespace routeTableSerializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API)
- .register(KryoNamespaces.MISC)
- .register(EvpnRoute.class)
- .register(EvpnPrefix.class)
- .register(RouteDistinguisher.class)
- .register(MacAddress.class)
- .register(IpPrefix.class)
- .register(EvpnRoute.Source.class)
- .register(IpAddress.class)
- .register(VpnRouteTarget.class)
- .register(Label.class)
- .register(EvpnRouteTableId.class)
- .build();
- return storageService.<EvpnPrefix, Set<EvpnRoute>>consistentMapBuilder()
- .withName("onos-evpn-routes-" + id.name())
- .withRelaxedReadConsistency()
- .withSerializer(Serializer.using(routeTableSerializer))
- .build();
- }
-
- @Override
- public EvpnRouteTableId id() {
- return id;
- }
-
- @Override
- public void shutdown() {
- routes.removeStatusChangeListener(statusChangeListener);
- routes.removeListener(listener);
- }
-
- @Override
- public void destroy() {
- shutdown();
- routes.destroy();
- }
-
- @Override
- public void update(EvpnRoute route) {
- routes.compute(route.evpnPrefix(), (prefix, set) -> {
- if (set == null) {
- set = new HashSet<>();
- }
- set.add(route);
- return set;
- });
- }
-
- @Override
- public void remove(EvpnRoute route) {
- routes.compute(route.evpnPrefix(), (prefix, set) -> {
- if (set != null) {
- set.remove(route);
- if (set.isEmpty()) {
- return null;
- }
- return set;
- }
- return null;
- });
- }
-
- @Override
- public Collection<EvpnRouteSet> getRoutes() {
- return routes.entrySet().stream()
- .map(e -> new EvpnRouteSet(id, e.getKey(), e.getValue().value()))
- .collect(Collectors.toSet());
- }
-
- @Override
- public EvpnRouteSet getRoutes(EvpnPrefix prefix) {
- Versioned<Set<EvpnRoute>> routeSet = routes.get(prefix);
-
- if (routeSet != null) {
- return new EvpnRouteSet(id, prefix, routeSet.value());
- }
- return null;
- }
-
- @Override
- public Collection<EvpnRoute> getRoutesForNextHop(IpAddress nextHop) {
- // TODO index
- return routes.values().stream()
- .flatMap(v -> v.value().stream())
- .filter(r -> r.nextHop().equals(nextHop))
- .collect(Collectors.toSet());
- }
-
- private class RouteTableListener
- implements MapEventListener<EvpnPrefix, Set<EvpnRoute>> {
-
- private EvpnInternalRouteEvent createRouteEvent(
- EvpnInternalRouteEvent.Type type, MapEvent<EvpnPrefix, Set<EvpnRoute>>
- event) {
- Set<EvpnRoute> currentRoutes =
- (event.newValue() == null) ? Collections.emptySet() : event.newValue().value();
- return new EvpnInternalRouteEvent(type, new EvpnRouteSet(id, event
- .key(), currentRoutes));
- }
-
- @Override
- public void event(MapEvent<EvpnPrefix, Set<EvpnRoute>> event) {
- EvpnInternalRouteEvent ire = null;
- switch (event.type()) {
- case INSERT:
- ire = createRouteEvent(EvpnInternalRouteEvent.Type.ROUTE_ADDED, event);
- break;
- case UPDATE:
- if (event.newValue().value().size() > event.oldValue().value().size()) {
- ire = createRouteEvent(EvpnInternalRouteEvent.Type.ROUTE_ADDED, event);
- } else {
- ire = createRouteEvent(EvpnInternalRouteEvent.Type.ROUTE_REMOVED, event);
- }
- break;
- case REMOVE:
- ire = createRouteEvent(EvpnInternalRouteEvent.Type.ROUTE_REMOVED, event);
- break;
- default:
- break;
- }
- if (ire != null) {
- delegate.notify(ire);
- }
- }
- }
-
-}
-
diff --git a/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/store/package-info.java b/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/store/package-info.java
deleted file mode 100644
index 52e9d6c..0000000
--- a/apps/evpn-route-service/app/src/main/java/org/onosproject/evpnrouteservice/store/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the unicast routing service.
- */
-package org.onosproject.evpnrouteservice.store;
diff --git a/apps/evpnopenflow/BUILD b/apps/evpnopenflow/BUILD
deleted file mode 100644
index 9e83f90..0000000
--- a/apps/evpnopenflow/BUILD
+++ /dev/null
@@ -1,28 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + JACKSON + KRYO + CLI + [
- "//apps/tunnel/api:onos-apps-tunnel-api",
- "//core/store/serializers:onos-core-serializers",
- "//apps/gluon:onos-apps-gluon",
- "//apps/vtn/vtnrsc:onos-apps-vtn-vtnrsc",
- "//apps/route-service/api:onos-apps-route-service-api",
- "//apps/evpn-route-service/api:onos-apps-evpn-route-service-api",
-]
-
-osgi_jar_with_tests(
- karaf_command_packages = ["org.onosproject.evpnopenflow.rsc.cli"],
- deps = COMPILE_DEPS,
-)
-
-onos_app(
- category = "Traffic Engineering",
- description = "Ethernet VPN (EVPN) introduces a new model for Ethernet services delivery." +
- "It enables integrated Layer 2 service over Ethernet with multihoming.",
- required_apps = [
- "org.onosproject.route-service",
- "org.onosproject.evpn-route-service",
- "org.onosproject.gluon",
- "org.onosproject.tunnel",
- "org.onosproject.vtn",
- ],
- title = "EVPN OpenFlow",
- url = "http://onosproject.org",
-)
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/manager/EvpnService.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/manager/EvpnService.java
deleted file mode 100644
index 5a41454..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/manager/EvpnService.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.manager;
-
-import org.onosproject.evpnopenflow.rsc.VpnPort;
-import org.onosproject.evpnrouteservice.EvpnRoute;
-import org.onosproject.net.Host;
-
-/**
- * Service for interacting with the route and host events.
- */
-public interface EvpnService {
- /**
- * Transfer remote route to private route and set mpls flows out when
- * BgpRoute update.
- *
- * @param route evpn route
- */
- void onBgpEvpnRouteUpdate(EvpnRoute route);
-
- /**
- * Transfer remote route to private route and delete mpls flows out when
- * BgpRoute delete.
- *
- * @param route evpn route
- */
- void onBgpEvpnRouteDelete(EvpnRoute route);
-
- /**
- * Get VPN info from EVPN app store and create route, set flows when host
- * detected.
- *
- * @param host host information
- */
- void onHostDetected(Host host);
-
- /**
- * Get VPN info from EVPN app store and delete route, set flows when
- * host
- * vanished.
- *
- * @param host host information
- */
- void onHostVanished(Host host);
-
- /**
- * Get VPN info from EVPN app store and create route, set flows when
- * host
- * detected.
- *
- * @param vpnPort vpnPort information
- */
- void onVpnPortSet(VpnPort vpnPort);
-
- /**
- * Get VPN info from EVPN app store and delete route, set flows when host
- * vanished.
- *
- * @param vpnPort vpnPort information
- */
- void onVpnPortDelete(VpnPort vpnPort);
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/manager/impl/EvpnManager.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/manager/impl/EvpnManager.java
deleted file mode 100644
index edfbfd0..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/manager/impl/EvpnManager.java
+++ /dev/null
@@ -1,1130 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.manager.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.google.common.collect.Sets;
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onlab.packet.EthType;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MplsLabel;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.evpnopenflow.manager.EvpnService;
-import org.onosproject.evpnopenflow.rsc.VpnAfConfig;
-import org.onosproject.evpnopenflow.rsc.VpnInstance;
-import org.onosproject.evpnopenflow.rsc.VpnInstanceId;
-import org.onosproject.evpnopenflow.rsc.VpnPort;
-import org.onosproject.evpnopenflow.rsc.VpnPortId;
-import org.onosproject.evpnopenflow.rsc.baseport.BasePortService;
-import org.onosproject.evpnopenflow.rsc.vpnafconfig.VpnAfConfigEvent;
-import org.onosproject.evpnopenflow.rsc.vpnafconfig.VpnAfConfigListener;
-import org.onosproject.evpnopenflow.rsc.vpnafconfig.VpnAfConfigService;
-import org.onosproject.evpnopenflow.rsc.vpninstance.VpnInstanceService;
-import org.onosproject.evpnopenflow.rsc.vpnport.VpnPortEvent;
-import org.onosproject.evpnopenflow.rsc.vpnport.VpnPortListener;
-import org.onosproject.evpnopenflow.rsc.vpnport.VpnPortService;
-import org.onosproject.evpnrouteservice.EvpnInstanceName;
-import org.onosproject.evpnrouteservice.EvpnInstanceNextHop;
-import org.onosproject.evpnrouteservice.EvpnInstancePrefix;
-import org.onosproject.evpnrouteservice.EvpnInstanceRoute;
-import org.onosproject.evpnrouteservice.EvpnNextHop;
-import org.onosproject.evpnrouteservice.EvpnRoute;
-import org.onosproject.evpnrouteservice.EvpnRoute.Source;
-import org.onosproject.evpnrouteservice.EvpnRouteAdminService;
-import org.onosproject.evpnrouteservice.EvpnRouteEvent;
-import org.onosproject.evpnrouteservice.EvpnRouteListener;
-import org.onosproject.evpnrouteservice.EvpnRouteService;
-import org.onosproject.evpnrouteservice.EvpnRouteSet;
-import org.onosproject.evpnrouteservice.EvpnRouteStore;
-import org.onosproject.evpnrouteservice.Label;
-import org.onosproject.evpnrouteservice.RouteDistinguisher;
-import org.onosproject.evpnrouteservice.VpnRouteTarget;
-import org.onosproject.gluon.rsc.GluonConfig;
-import org.onosproject.incubator.net.resource.label.LabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.instructions.ExtensionTreatment;
-import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
-import org.onosproject.net.flowobjective.DefaultForwardingObjective;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.net.flowobjective.Objective.Operation;
-import org.onosproject.net.host.HostEvent;
-import org.onosproject.net.host.HostListener;
-import org.onosproject.net.host.HostService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.APP_ID;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ARP_PRIORITY;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ARP_RESPONSE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.BASEPORT;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.BGP_EVPN_ROUTE_DELETE_START;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.BGP_EVPN_ROUTE_UPDATE_START;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.BOTH;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.CANNOT_FIND_TUNNEL_PORT_DEVICE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.CANT_FIND_CONTROLLER_DEVICE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.CANT_FIND_VPN_INSTANCE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.CANT_FIND_VPN_PORT;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.DELETE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.EVPN_OPENFLOW_START;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.EVPN_OPENFLOW_STOP;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.EXPORT_EXTCOMMUNITY;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.FAILED_TO_SET_TUNNEL_DST;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.GET_PRIVATE_LABEL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.HOST_DETECT;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.HOST_VANISHED;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.IFACEID;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.IFACEID_OF_HOST_IS_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.IMPORT_EXTCOMMUNITY;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.INVALID_EVENT_RECEIVED;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.INVALID_ROUTE_TARGET_TYPE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.INVALID_TARGET_RECEIVED;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.MPLS_OUT_FLOWS;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.NETWORK_CONFIG_EVENT_IS_RECEIVED;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.NOT_MASTER_FOR_SPECIFIC_DEVICE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.RELEASE_LABEL_FAILED;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ROUTE_ADD_ARP_RULES;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ROUTE_REMOVE_ARP_RULES;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.SET;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.SLASH;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.SWITCH_CHANNEL_ID;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.TUNNEL_DST;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.UPDATE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_AF_TARGET;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_INSTANCE_TARGET;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_PORT_BIND;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_PORT_TARGET;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_PORT_UNBIND;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VXLAN;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Implementation of the EVPN service.
- */
-@Component(immediate = true, service = EvpnService.class)
-public class EvpnManager implements EvpnService {
- private final Logger log = getLogger(getClass());
- private static final EthType.EtherType ARP_TYPE = EthType.EtherType.ARP;
-
- protected ApplicationId appId;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected HostService hostService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected EvpnRouteService evpnRouteService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected EvpnRouteStore evpnRouteStore;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceService deviceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected EvpnRouteAdminService evpnRouteAdminService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected MastershipService mastershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LabelResourceAdminService labelAdminService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LabelResourceService labelService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected VpnInstanceService vpnInstanceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected FlowObjectiveService flowObjectiveService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DriverService driverService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected VpnPortService vpnPortService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected VpnAfConfigService vpnAfConfigService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigService configService;
-
- public Set<EvpnInstanceRoute> evpnInstanceRoutes = new HashSet<>();
- private final HostListener hostListener = new InnerHostListener();
- private final VpnPortListener vpnPortListner = new InnerVpnPortListener();
- private final VpnAfConfigListener vpnAfConfigListener = new
- InnerVpnAfConfigListener();
- private final InternalRouteEventListener routeListener = new
- InternalRouteEventListener();
-
- private final NetworkConfigListener configListener = new
- InternalNetworkConfigListener();
-
- @Activate
- public void activate() {
- appId = coreService.registerApplication(APP_ID);
- hostService.addListener(hostListener);
- vpnPortService.addListener(vpnPortListner);
- vpnAfConfigService.addListener(vpnAfConfigListener);
- configService.addListener(configListener);
- evpnRouteService.addListener(routeListener);
-
- labelAdminService
- .createGlobalPool(LabelResourceId.labelResourceId(1),
- LabelResourceId.labelResourceId(1000));
- log.info(EVPN_OPENFLOW_START);
- }
-
- @Deactivate
- public void deactivate() {
- hostService.removeListener(hostListener);
- vpnPortService.removeListener(vpnPortListner);
- vpnAfConfigService.removeListener(vpnAfConfigListener);
- configService.removeListener(configListener);
- log.info(EVPN_OPENFLOW_STOP);
- }
-
- @Override
- public void onBgpEvpnRouteUpdate(EvpnRoute route) {
- if (EvpnRoute.Source.LOCAL.equals(route.source())) {
- return;
- }
- log.info(BGP_EVPN_ROUTE_UPDATE_START, route);
- // deal with public route and transfer to private route
- if (vpnInstanceService.getInstances().isEmpty()) {
- log.info("unable to get instnaces from vpninstance");
- return;
- }
-
- vpnInstanceService.getInstances().forEach(vpnInstance -> {
- log.info("got instnaces from vpninstance but not entered here");
- List<VpnRouteTarget> vpnImportRouteRt = new
- LinkedList<>(vpnInstance.getImportRouteTargets());
- List<VpnRouteTarget> expRt = route.exportRouteTarget();
- List<VpnRouteTarget> similar = new LinkedList<>(expRt);
- similar.retainAll(vpnImportRouteRt);
-
- if (!similar.isEmpty()) {
- EvpnInstancePrefix evpnPrefix = EvpnInstancePrefix
- .evpnPrefix(route.prefixMac(), route.prefixIp());
-
- EvpnInstanceNextHop evpnNextHop = EvpnInstanceNextHop
- .evpnNextHop(route.ipNextHop(), route.label());
-
- EvpnInstanceRoute evpnPrivateRoute = new
- EvpnInstanceRoute(vpnInstance.vpnInstanceName(),
- route.routeDistinguisher(),
- vpnImportRouteRt,
- route.exportRouteTarget(),
- evpnPrefix,
- evpnNextHop,
- route.prefixIp(),
- route.ipNextHop(),
- route.label());
-
- //update route in route subsystem
- //TODO: added by shahid
- evpnInstanceRoutes.add(evpnPrivateRoute);
-
- }
- });
-
- deviceService.getAvailableDevices(Device.Type.SWITCH)
- .forEach(device -> {
- log.info("switch device is found");
- Set<Host> hosts = getHostsByVpn(device, route);
- for (Host h : hosts) {
- addArpFlows(device.id(),
- route,
- Objective.Operation.ADD,
- h);
- ForwardingObjective.Builder objective =
- getMplsOutBuilder(device.id(),
- route,
- h);
- log.info(MPLS_OUT_FLOWS, h);
- flowObjectiveService.forward(device.id(),
- objective.add());
- }
- });
- log.info("no switch device is found");
- }
-
- @Override
- public void onBgpEvpnRouteDelete(EvpnRoute route) {
- if (EvpnRoute.Source.LOCAL.equals(route.source())) {
- return;
- }
- log.info(BGP_EVPN_ROUTE_DELETE_START, route);
- // deal with public route deleted and transfer to private route
- vpnInstanceService.getInstances().forEach(vpnInstance -> {
- List<VpnRouteTarget> vpnRouteRt = new
- LinkedList<>(vpnInstance.getImportRouteTargets());
- List<VpnRouteTarget> localRt = route.exportRouteTarget();
- List<VpnRouteTarget> similar = new LinkedList<>(localRt);
- similar.retainAll(vpnRouteRt);
-
- if (!similar.isEmpty()) {
- EvpnInstancePrefix evpnPrefix = EvpnInstancePrefix
- .evpnPrefix(route.prefixMac(), route.prefixIp());
-
- EvpnInstanceNextHop evpnNextHop = EvpnInstanceNextHop
- .evpnNextHop(route.ipNextHop(), route.label());
-
- EvpnInstanceRoute evpnPrivateRoute = new
- EvpnInstanceRoute(vpnInstance.vpnInstanceName(),
- route.routeDistinguisher(),
- vpnRouteRt,
- route.exportRouteTarget(),
- evpnPrefix,
- evpnNextHop,
- route.prefixIp(),
- route.ipNextHop(),
- route.label());
- //TODO: Added by Shahid
- //evpnRouteAdminService.withdraw(Sets.newHashSet
- // (evpnPrivateRoute));
-
- }
- });
- deviceService.getAvailableDevices(Device.Type.SWITCH)
- .forEach(device -> {
- Set<Host> hosts = getHostsByVpn(device, route);
- for (Host h : hosts) {
- addArpFlows(device.id(),
- route,
- Objective.Operation.REMOVE,
- h);
- ForwardingObjective.Builder objective
- = getMplsOutBuilder(device.id(),
- route,
- h);
- flowObjectiveService.forward(device.id(),
- objective.remove());
- }
- });
- }
-
- private void addArpFlows(DeviceId deviceId,
- EvpnRoute route,
- Operation type,
- Host host) {
- DriverHandler handler = driverService.createHandler(deviceId);
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthType(ARP_TYPE.ethType().toShort())
- .matchArpTpa(route.prefixIp().address().getIp4Address())
- .matchInPort(host.location().port()).build();
-
- ExtensionTreatmentResolver resolver = handler
- .behaviour(ExtensionTreatmentResolver.class);
- ExtensionTreatment ethSrcToDst = resolver
- .getExtensionInstruction(ExtensionTreatmentType
- .ExtensionTreatmentTypes
- .NICIRA_MOV_ETH_SRC_TO_DST
- .type());
- ExtensionTreatment arpShaToTha = resolver
- .getExtensionInstruction(ExtensionTreatmentType
- .ExtensionTreatmentTypes
- .NICIRA_MOV_ARP_SHA_TO_THA
- .type());
- ExtensionTreatment arpSpaToTpa = resolver
- .getExtensionInstruction(ExtensionTreatmentType
- .ExtensionTreatmentTypes
- .NICIRA_MOV_ARP_SPA_TO_TPA
- .type());
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .extension(ethSrcToDst, deviceId).setEthSrc(route.prefixMac())
- .setArpOp(ARP_RESPONSE).extension(arpShaToTha, deviceId)
- .extension(arpSpaToTpa, deviceId).setArpSha(route.prefixMac())
- .setArpSpa(route.prefixIp().address().getIp4Address())
- .setOutput(PortNumber.IN_PORT)
- .build();
-
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(ForwardingObjective.Flag.SPECIFIC)
- .withPriority(ARP_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- log.info(ROUTE_ADD_ARP_RULES);
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- log.info(ROUTE_REMOVE_ARP_RULES);
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-
- private Set<Host> getHostsByVpn(Device device, EvpnRoute route) {
- Set<Host> vpnHosts = Sets.newHashSet();
- Set<Host> hosts = hostService.getConnectedHosts(device.id());
- for (Host h : hosts) {
- String ifaceId = h.annotations().value(IFACEID);
- if (!vpnPortService.exists(VpnPortId.vpnPortId(ifaceId))) {
- continue;
- }
-
- VpnPort vpnPort = vpnPortService
- .getPort(VpnPortId.vpnPortId(ifaceId));
- VpnInstanceId vpnInstanceId = vpnPort.vpnInstanceId();
-
- VpnInstance vpnInstance = vpnInstanceService
- .getInstance(vpnInstanceId);
-
- List<VpnRouteTarget> expRt = route.exportRouteTarget();
- List<VpnRouteTarget> similar = new LinkedList<>(expRt);
- similar.retainAll(vpnInstance.getImportRouteTargets());
- //TODO: currently checking for RT comparison.
- //TODO: Need to check about RD comparison is really required.
- //if (route.routeDistinguisher()
- //.equals(vpnInstance.routeDistinguisher())) {
- if (!similar.isEmpty()) {
- vpnHosts.add(h);
- }
- }
- return vpnHosts;
- }
-
- private ForwardingObjective.Builder getMplsOutBuilder(DeviceId deviceId,
- EvpnRoute route,
- Host h) {
- DriverHandler handler = driverService.createHandler(deviceId);
- ExtensionTreatmentResolver resolver = handler
- .behaviour(ExtensionTreatmentResolver.class);
- ExtensionTreatment treatment = resolver
- .getExtensionInstruction(NICIRA_SET_TUNNEL_DST.type());
- try {
- treatment.setPropertyValue(TUNNEL_DST, route.ipNextHop());
- } catch (Exception e) {
- log.error(FAILED_TO_SET_TUNNEL_DST, deviceId);
- }
- TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
- builder.extension(treatment, deviceId);
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(h.location().port()).matchEthSrc(h.mac())
- .matchEthDst(route.prefixMac()).build();
-
- TrafficTreatment build = builder.pushMpls()
- .setMpls(MplsLabel.mplsLabel(route.label().getLabel()))
- .setOutput(getTunnlePort(deviceId)).build();
-
- return DefaultForwardingObjective
- .builder().withTreatment(build).withSelector(selector)
- .fromApp(appId).withFlag(ForwardingObjective.Flag.SPECIFIC)
- .withPriority(60000);
-
- }
-
- private ForwardingObjective.Builder getMplsInBuilder(DeviceId deviceId,
- Host host,
- Label label) {
- TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(getTunnlePort(deviceId))
- .matchEthType(EthType.EtherType.MPLS_UNICAST.ethType()
- .toShort())
- .matchMplsBos(true)
- .matchMplsLabel(MplsLabel.mplsLabel(label.getLabel())).build();
- TrafficTreatment treatment = builder.popMpls(EthType
- .EtherType
- .IPV4.ethType())
- .setOutput(host.location().port()).build();
- return DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(ForwardingObjective.Flag.SPECIFIC)
- .withPriority(60000);
- }
-
- /**
- * Get local tunnel ports.
- *
- * @param ports Iterable of Port
- * @return Collection of PortNumber
- */
- private Collection<PortNumber> getLocalTunnelPorts(Iterable<Port>
- ports) {
- Collection<PortNumber> localTunnelPorts = new ArrayList<>();
- if (ports != null) {
- log.info("port value is not null {}", ports);
- Sets.newHashSet(ports).stream()
- .filter(p -> !p.number().equals(PortNumber.LOCAL))
- .forEach(p -> {
- log.info("number is not matched but no vxlan port");
- if (p.annotations().value(AnnotationKeys.PORT_NAME)
- .startsWith(VXLAN)) {
- localTunnelPorts.add(p.number());
- }
- });
- }
- return localTunnelPorts;
- }
-
- private PortNumber getTunnlePort(DeviceId deviceId) {
- Iterable<Port> ports = deviceService.getPorts(deviceId);
- Collection<PortNumber> localTunnelPorts = getLocalTunnelPorts(ports);
- if (localTunnelPorts.isEmpty()) {
- log.error(CANNOT_FIND_TUNNEL_PORT_DEVICE, deviceId);
- return null;
- }
- return localTunnelPorts.iterator().next();
- }
-
- private void setFlows(DeviceId deviceId, Host host, Label label,
- List<VpnRouteTarget> rtImport,
- Operation type) {
- log.info("Set the flows to OVS");
- ForwardingObjective.Builder objective = getMplsInBuilder(deviceId,
- host,
- label);
- if (type.equals(Objective.Operation.ADD)) {
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- flowObjectiveService.forward(deviceId, objective.remove());
- }
-
- // download remote flows if and only routes are present.
- evpnRouteStore.getRouteTables().forEach(routeTableId -> {
- Collection<EvpnRouteSet> routes
- = evpnRouteStore.getRoutes(routeTableId);
- if (routes != null) {
- routes.forEach(route -> {
- Collection<EvpnRoute> evpnRoutes = route.routes();
- for (EvpnRoute evpnRoute : evpnRoutes) {
- EvpnRoute evpnRouteTem = evpnRoute;
- Set<Host> hostByMac = hostService
- .getHostsByMac(evpnRouteTem
- .prefixMac());
-
- if (!hostByMac.isEmpty()
- || (!(compareLists(rtImport, evpnRouteTem
- .exportRouteTarget())))) {
- log.info("Route target import/export is not matched");
- continue;
- }
- log.info("Set the ARP flows");
- addArpFlows(deviceId, evpnRouteTem, type, host);
- ForwardingObjective.Builder build = getMplsOutBuilder(deviceId,
- evpnRouteTem,
- host);
- log.info("Set the MPLS flows");
- if (type.equals(Objective.Operation.ADD)) {
- flowObjectiveService.forward(deviceId, build.add());
- } else {
- flowObjectiveService.forward(deviceId, build.remove());
- }
- }
- });
- }
- });
- }
-
- /**
- * comparison for tow lists.
- *
- * @param list1 import list
- * @param list2 export list
- * @return true or false
- */
- public static boolean compareLists(List<VpnRouteTarget> list1,
- List<VpnRouteTarget> list2) {
- if (list1 == null && list2 == null) {
- return true;
- }
-
- if (list1 != null && list2 != null) {
- if (list1.size() == list2.size()) {
- for (VpnRouteTarget li1Long : list1) {
- boolean isEqual = false;
- for (VpnRouteTarget li2Long : list2) {
- if (li1Long.equals(li2Long)) {
- isEqual = true;
- break;
- }
- }
- if (!isEqual) {
- return false;
- }
- }
- } else {
- return false;
- }
- } else {
- return false;
- }
- return true;
- }
-
- @Override
- public void onHostDetected(Host host) {
- log.info(HOST_DETECT, host);
- DeviceId deviceId = host.location().deviceId();
- if (!mastershipService.isLocalMaster(deviceId)) {
- log.info(NOT_MASTER_FOR_SPECIFIC_DEVICE);
- return;
- }
-
- String ifaceId = host.annotations().value(IFACEID);
- if (ifaceId == null) {
- log.error(IFACEID_OF_HOST_IS_NULL);
- return;
- }
- VpnPortId vpnPortId = VpnPortId.vpnPortId(ifaceId);
- // Get VPN port id from EVPN app store
- if (!vpnPortService.exists(vpnPortId)) {
- log.info(CANT_FIND_VPN_PORT, ifaceId);
- return;
- }
-
- VpnPort vpnPort = vpnPortService.getPort(vpnPortId);
- VpnInstanceId vpnInstanceId = vpnPort.vpnInstanceId();
- if (!vpnInstanceService.exists(vpnInstanceId)) {
- log.info(CANT_FIND_VPN_INSTANCE, vpnInstanceId);
- return;
- }
-
- Label privateLabel = applyLabel();
- // create private route and get label
- setPrivateRoute(host, vpnInstanceId, privateLabel,
- Objective.Operation.ADD);
- VpnInstance vpnInstance = vpnInstanceService.getInstance(vpnInstanceId);
-
- List<VpnRouteTarget> rtImport
- = new LinkedList<>(vpnInstance.getImportRouteTargets());
- List<VpnRouteTarget> rtExport
- = new LinkedList<>(vpnInstance.getExportRouteTargets());
- //download flows
- setFlows(deviceId, host, privateLabel, rtImport,
- Objective.Operation.ADD);
- }
-
- /**
- * update or withdraw evpn route from route admin service.
- *
- * @param host host
- * @param vpnInstanceId vpn instance id
- * @param privateLabel private label
- * @param type operation type
- */
- private void setPrivateRoute(Host host, VpnInstanceId vpnInstanceId,
- Label privateLabel,
- Operation type) {
- DeviceId deviceId = host.location().deviceId();
- Device device = deviceService.getDevice(deviceId);
- VpnInstance vpnInstance = vpnInstanceService.getInstance(vpnInstanceId);
- RouteDistinguisher rd = vpnInstance.routeDistinguisher();
- Set<VpnRouteTarget> importRouteTargets
- = vpnInstance.getImportRouteTargets();
- Set<VpnRouteTarget> exportRouteTargets
- = vpnInstance.getExportRouteTargets();
- EvpnInstanceName instanceName = vpnInstance.vpnInstanceName();
- String url = device.annotations().value(SWITCH_CHANNEL_ID);
- String controllerIp = url.substring(0, url.lastIndexOf(":"));
-
- if (controllerIp == null) {
- log.error(CANT_FIND_CONTROLLER_DEVICE, device.id().toString());
- return;
- }
- IpAddress ipAddress = IpAddress.valueOf(controllerIp);
- // create private route
- EvpnInstanceNextHop evpnNextHop = EvpnInstanceNextHop
- .evpnNextHop(ipAddress, privateLabel);
- EvpnInstancePrefix evpnPrefix = EvpnInstancePrefix
- .evpnPrefix(host.mac(), IpPrefix.valueOf(host.ipAddresses()
- .iterator()
- .next()
- .getIp4Address(), 32));
- EvpnInstanceRoute evpnPrivateRoute
- = new EvpnInstanceRoute(instanceName,
- rd,
- new LinkedList<>(importRouteTargets),
- new LinkedList<>(exportRouteTargets),
- evpnPrefix,
- evpnNextHop,
- IpPrefix.valueOf(host.ipAddresses()
- .iterator()
- .next()
- .getIp4Address(), 32),
- ipAddress,
- privateLabel);
-
- // change to public route
- EvpnRoute evpnRoute
- = new EvpnRoute(Source.LOCAL,
- host.mac(),
- IpPrefix.valueOf(host.ipAddresses()
- .iterator()
- .next()
- .getIp4Address(), 32),
- ipAddress,
- rd,
- new LinkedList<>(importRouteTargets),
- new LinkedList<>(exportRouteTargets),
- privateLabel);
- if (type.equals(Objective.Operation.ADD)) {
- //evpnRouteAdminService.update(Sets.newHashSet(evpnPrivateRoute));
- evpnInstanceRoutes.add(evpnPrivateRoute);
- evpnRouteAdminService.update(Sets.newHashSet(evpnRoute));
-
- } else {
- //evpnRouteAdminService.withdraw(Sets.newHashSet(evpnPrivateRoute));
- evpnInstanceRoutes.remove(evpnPrivateRoute);
- evpnRouteAdminService.withdraw(Sets.newHashSet(evpnRoute));
- }
- }
-
- /**
- * Generate the label for evpn route from global pool.
- */
- private Label applyLabel() {
- Collection<LabelResource> privateLabels = labelService
- .applyFromGlobalPool(1);
- Label privateLabel = Label.label(0);
- if (!privateLabels.isEmpty()) {
- privateLabel = Label.label(Integer.parseInt(
- privateLabels.iterator().next()
- .labelResourceId().toString()));
- }
- log.info(GET_PRIVATE_LABEL, privateLabel);
- return privateLabel;
- }
-
- @Override
- public void onHostVanished(Host host) {
- log.info(HOST_VANISHED, host);
- DeviceId deviceId = host.location().deviceId();
- if (!mastershipService.isLocalMaster(deviceId)) {
- return;
- }
- String ifaceId = host.annotations().value(IFACEID);
- if (ifaceId == null) {
- log.error(IFACEID_OF_HOST_IS_NULL);
- return;
- }
- // Get info from Gluon Shim
- VpnPort vpnPort = vpnPortService.getPort(VpnPortId.vpnPortId(ifaceId));
- VpnInstanceId vpnInstanceId = vpnPort.vpnInstanceId();
- if (!vpnInstanceService.exists(vpnInstanceId)) {
- log.info(CANT_FIND_VPN_INSTANCE, vpnInstanceId);
- return;
- }
- VpnInstance vpnInstance = vpnInstanceService.getInstance(vpnInstanceId);
-
- Label label = releaseLabel(vpnInstance, host);
- // create private route and get label
- setPrivateRoute(host, vpnInstanceId, label, Objective.Operation.REMOVE);
- // download flows
- List<VpnRouteTarget> rtImport
- = new LinkedList<>(vpnInstance.getImportRouteTargets());
- List<VpnRouteTarget> rtExport
- = new LinkedList<>(vpnInstance.getExportRouteTargets());
- setFlows(deviceId, host, label, rtImport,
- Objective.Operation.REMOVE);
- }
-
- /**
- * Release the label from the evpn route.
- *
- * @param vpnInstance vpn instance
- * @param host host
- */
- private Label releaseLabel(VpnInstance vpnInstance, Host host) {
- EvpnInstanceName instanceName = vpnInstance.vpnInstanceName();
-
- //Get all vpn-instance routes and check for label.
- Label label = null;
- for (EvpnInstanceRoute evpnInstanceRoute : evpnInstanceRoutes) {
- if (evpnInstanceRoute.evpnInstanceName().equals(instanceName)) {
- label = evpnInstanceRoute.getLabel();
- // delete private route and get label ,change to public route
- boolean isRelease
- = labelService
- .releaseToGlobalPool(
- Sets.newHashSet(
- LabelResourceId
- .labelResourceId(label.getLabel())));
- if (!isRelease) {
- log.error(RELEASE_LABEL_FAILED, label.getLabel());
- }
- break;
- }
- }
- return label;
- }
-
- private class InternalRouteEventListener implements EvpnRouteListener {
-
- @Override
- public void event(EvpnRouteEvent event) {
- if (event.subject() != null) {
- EvpnRoute route = (EvpnRoute) event.subject();
- if (EvpnRouteEvent.Type.ROUTE_ADDED == event.type()) {
- onBgpEvpnRouteUpdate(route);
- } else if (EvpnRouteEvent.Type.ROUTE_REMOVED == event.type()) {
- onBgpEvpnRouteDelete(route);
- }
- } else {
- return;
- }
- }
- }
-
- private class InnerHostListener implements HostListener {
-
- @Override
- public void event(HostEvent event) {
- Host host = event.subject();
- if (HostEvent.Type.HOST_ADDED == event.type()) {
- onHostDetected(host);
- } else if (HostEvent.Type.HOST_REMOVED == event.type()) {
- onHostVanished(host);
- }
- }
-
- }
-
- private class InnerVpnPortListener implements VpnPortListener {
-
- @Override
- public void event(VpnPortEvent event) {
- VpnPort vpnPort = event.subject();
- if (VpnPortEvent.Type.VPN_PORT_DELETE == event.type()) {
- onVpnPortDelete(vpnPort);
- } else if (VpnPortEvent.Type.VPN_PORT_SET == event.type()) {
- onVpnPortSet(vpnPort);
- }
- }
- }
-
- @Override
- public void onVpnPortDelete(VpnPort vpnPort) {
- // delete the flows of this vpn
- hostService.getHosts().forEach(host -> {
- VpnPortId vpnPortId = vpnPort.id();
- VpnInstanceId vpnInstanceId = vpnPort.vpnInstanceId();
- if (!vpnInstanceService.exists(vpnInstanceId)) {
- log.error(CANT_FIND_VPN_INSTANCE, vpnInstanceId);
- return;
- }
- VpnInstance vpnInstance = vpnInstanceService
- .getInstance(vpnInstanceId);
- List<VpnRouteTarget> rtImport
- = new LinkedList<>(vpnInstance.getImportRouteTargets());
- List<VpnRouteTarget> rtExport
- = new LinkedList<>(vpnInstance.getExportRouteTargets());
-
- if (vpnPortId.vpnPortId()
- .equals(host.annotations().value(IFACEID))) {
- log.info(VPN_PORT_UNBIND);
- Label label = releaseLabel(vpnInstance, host);
- // create private route and get label
- DeviceId deviceId = host.location().deviceId();
- setPrivateRoute(host, vpnInstanceId, label,
- Objective.Operation.REMOVE);
- // download flows
- setFlows(deviceId, host, label, rtImport,
- Objective.Operation.REMOVE);
- }
- });
- }
-
- @Override
- public void onVpnPortSet(VpnPort vpnPort) {
- // delete the flows of this vpn
- hostService.getHosts().forEach(host -> {
- VpnPortId vpnPortId = vpnPort.id();
- VpnInstanceId vpnInstanceId = vpnPort.vpnInstanceId();
- VpnInstance vpnInstance = vpnInstanceService
- .getInstance(vpnInstanceId);
- if (vpnInstance == null) {
- log.info("why vpn instance is null");
- return;
- }
- List<VpnRouteTarget> rtImport
- = new LinkedList<>(vpnInstance.getImportRouteTargets());
-/* List<VpnRouteTarget> rtExport
- = new LinkedList<>(vpnInstance.getExportRouteTargets());*/
-
- if (!vpnInstanceService.exists(vpnInstanceId)) {
- log.error(CANT_FIND_VPN_INSTANCE, vpnInstanceId);
- return;
- }
-
- if (vpnPortId.vpnPortId()
- .equals(host.annotations().value(IFACEID))) {
- log.info(VPN_PORT_BIND);
- Label label = applyLabel();
- // create private route and get label
- DeviceId deviceId = host.location().deviceId();
- setPrivateRoute(host, vpnInstanceId, label,
- Objective.Operation.ADD);
- // download flows
- setFlows(deviceId, host, label, rtImport,
- Objective.Operation.ADD);
- }
- });
- }
-
- /**
- * process the gluon configuration and will update the configuration into
- * vpn port service.
- *
- * @param action action
- * @param key key
- * @param value json node
- */
- private void processEtcdResponse(String action, String key, JsonNode
- value) {
- String[] list = key.split(SLASH);
- String target = list[list.length - 2];
- switch (target) {
- case VPN_INSTANCE_TARGET:
- VpnInstanceService vpnInstanceService
- = DefaultServiceDirectory
- .getService(VpnInstanceService.class);
- vpnInstanceService.processGluonConfig(action, key, value);
- break;
- case VPN_PORT_TARGET:
- VpnPortService vpnPortService = DefaultServiceDirectory
- .getService(VpnPortService.class);
- vpnPortService.processGluonConfig(action, key, value);
- break;
- case VPN_AF_TARGET:
- VpnAfConfigService vpnAfConfigService =
- DefaultServiceDirectory.getService(VpnAfConfigService
- .class);
- vpnAfConfigService.processGluonConfig(action, key, value);
- break;
- case BASEPORT:
- BasePortService basePortService =
- DefaultServiceDirectory.getService(BasePortService
- .class);
- basePortService.processGluonConfig(action, key, value);
- break;
- default:
- log.info("why target type is invalid {}", target);
- log.info(INVALID_TARGET_RECEIVED);
- break;
- }
- }
-
- /**
- * parse the gluon configuration received from network config system.
- *
- * @param jsonNode json node
- * @param key key
- * @param action action
- */
- private void parseEtcdResponse(JsonNode jsonNode,
- String key,
- String action) {
- JsonNode modifyValue = null;
- if (action.equals(SET)) {
- modifyValue = jsonNode.get(key);
- }
- processEtcdResponse(action, key, modifyValue);
- }
-
- /**
- * Listener for network config events.
- */
- private class InternalNetworkConfigListener implements
- NetworkConfigListener {
-
- @Override
- public void event(NetworkConfigEvent event) {
- String subject;
- log.info(NETWORK_CONFIG_EVENT_IS_RECEIVED, event.type());
- if (!event.configClass().equals(GluonConfig.class)) {
- return;
- }
- log.info("Event is received from network configuration {}", event
- .type());
- switch (event.type()) {
- case CONFIG_UPDATED:
- subject = (String) event.subject();
- GluonConfig gluonConfig = configService
- .getConfig(subject, GluonConfig.class);
- JsonNode jsonNode = gluonConfig.node();
- parseEtcdResponse(jsonNode, subject, SET);
- break;
- case CONFIG_REMOVED:
- subject = (String) event.subject();
- parseEtcdResponse(null, subject, DELETE);
- break;
- default:
- log.info(INVALID_EVENT_RECEIVED);
- break;
- }
- }
- }
-
- /**
- * update import and export route target information in route admin service.
- *
- * @param evpnInstanceName evpn instance name
- * @param exportRouteTargets export route targets
- * @param importRouteTargets import route targets
- * @param action action holds update or delete
- */
- private void updateImpExpRtInRoute(EvpnInstanceName evpnInstanceName,
- Set<VpnRouteTarget> exportRouteTargets,
- Set<VpnRouteTarget> importRouteTargets,
- String action) {
-
- for (EvpnInstanceRoute evpnInstanceRoute : evpnInstanceRoutes) {
- if (evpnInstanceRoute.evpnInstanceName().equals(evpnInstanceName)) {
- evpnInstanceRoute
- .setExportRtList(new LinkedList<>(exportRouteTargets));
- evpnInstanceRoute
- .setImportRtList(new LinkedList<>(importRouteTargets));
- if (action.equals(UPDATE)) {
- evpnInstanceRoutes.add(evpnInstanceRoute);
- } else if (action.equals(DELETE)) {
- evpnInstanceRoutes.remove(evpnInstanceRoute);
- }
- //Get the public route and update route targets.
- EvpnNextHop evpnNextHop = EvpnNextHop
- .evpnNextHop(evpnInstanceRoute.getNextHopl(),
- evpnInstanceRoute.importRouteTarget(),
- evpnInstanceRoute.exportRouteTarget(),
- evpnInstanceRoute.getLabel());
- Collection<EvpnRoute> evpnPublicRoutes
- = evpnRouteStore.getRoutesForNextHop(evpnNextHop.nextHop());
- for (EvpnRoute pubRoute : evpnPublicRoutes) {
- EvpnRoute evpnPubRoute = pubRoute;
- if (evpnPubRoute.label().equals(evpnInstanceRoute
- .getLabel())) {
- evpnPubRoute
- .setExportRtList(new LinkedList<>(exportRouteTargets));
- evpnPubRoute
- .setImportRtList(new LinkedList<>(importRouteTargets));
- if (action.equals(UPDATE)) {
- evpnRouteAdminService.update(Sets.newHashSet(evpnPubRoute));
- } else if (action.equals(DELETE)) {
- evpnRouteAdminService
- .withdraw(Sets.newHashSet(evpnPubRoute));
- }
- }
- }
- }
- }
- }
-
- /**
- * update or withdraw evpn route based on vpn af configuration.
- *
- * @param vpnAfConfig vpn af configuration
- * @param action action holds update or delete
- */
-
- private void processEvpnRouteUpdate(VpnAfConfig vpnAfConfig,
- String action) {
- Collection<VpnInstance> instances
- = vpnInstanceService.getInstances();
- for (VpnInstance vpnInstance : instances) {
- Set<VpnRouteTarget> configRouteTargets
- = vpnInstance.getConfigRouteTargets();
- for (VpnRouteTarget vpnRouteTarget : configRouteTargets) {
- if (vpnRouteTarget.equals(vpnAfConfig.routeTarget())) {
- Set<VpnRouteTarget> exportRouteTargets
- = vpnInstance.getExportRouteTargets();
- Set<VpnRouteTarget> importRouteTargets
- = vpnInstance.getImportRouteTargets();
- String routeTargetType = vpnAfConfig.routeTargetType();
- if (action.equals(UPDATE)) {
- vpnInstanceService
- .updateImpExpRouteTargets(routeTargetType,
- exportRouteTargets,
- importRouteTargets,
- vpnRouteTarget);
- } else if (action.equals(DELETE)) {
- switch (routeTargetType) {
- case EXPORT_EXTCOMMUNITY:
- exportRouteTargets.remove(vpnRouteTarget);
- break;
- case IMPORT_EXTCOMMUNITY:
- importRouteTargets.remove(vpnRouteTarget);
- break;
- case BOTH:
- exportRouteTargets.remove(vpnRouteTarget);
- importRouteTargets.remove(vpnRouteTarget);
- break;
- default:
- log.info(INVALID_ROUTE_TARGET_TYPE);
- break;
- }
- }
- updateImpExpRtInRoute(vpnInstance.vpnInstanceName(),
- exportRouteTargets,
- importRouteTargets,
- action);
- }
- }
- }
- }
-
- private class InnerVpnAfConfigListener implements VpnAfConfigListener {
-
- @Override
- public void event(VpnAfConfigEvent event) {
- VpnAfConfig vpnAfConfig = event.subject();
- if (VpnAfConfigEvent.Type.VPN_AF_CONFIG_DELETE == event.type()) {
- processEvpnRouteUpdate(vpnAfConfig, DELETE);
- } else if (VpnAfConfigEvent.Type.VPN_AF_CONFIG_SET
- == event.type() || VpnAfConfigEvent.Type
- .VPN_AF_CONFIG_UPDATE == event.type()) {
- processEvpnRouteUpdate(vpnAfConfig, UPDATE);
- }
- }
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/manager/impl/package-info.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/manager/impl/package-info.java
deleted file mode 100644
index 8f83161..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/manager/impl/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * EVPN application that process configuration and host, vpn-port, route
- * events.
- */
-package org.onosproject.evpnopenflow.manager.impl;
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/manager/package-info.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/manager/package-info.java
deleted file mode 100644
index d93de24..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/manager/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * EVPN application that process configuration and host, vpn-port, route
- * events.
- */
-package org.onosproject.evpnopenflow.manager;
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/BasePort.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/BasePort.java
deleted file mode 100644
index 1b2455a..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/BasePort.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc;
-
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.SecurityGroup;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-
-import java.util.Collection;
-import java.util.Set;
-
-/**
- * Representation of a Base port.
- */
-public interface BasePort {
- /**
- * Coarse classification of the type of the virtual port.
- */
- enum State {
- /**
- * Signifies that a basePort is currently active,This state mean that
- * this basePort is available.
- */
- ACTIVE,
- /**
- * Signifies that a basePort is currently unavailable.
- */
- DOWN;
- }
-
- /**
- * Returns the basePort identifier.
- *
- * @return basePort identifier
- */
- BasePortId portId();
-
- /**
- * Returns the network identifier.
- *
- * @return tenantNetwork identifier
- */
- TenantNetworkId networkId();
-
- /**
- * Returns the symbolic name for the basePort.
- *
- * @return basePort name
- */
- String name();
-
- /**
- * Returns the administrative status of the port,which is up(true) or
- * down(false).
- *
- * @return true if the administrative status of the port is up
- */
- boolean adminStateUp();
-
- /**
- * Returns the state.
- *
- * @return state
- */
- String state();
-
- /**
- * Returns the MAC address.
- *
- * @return MAC Address
- */
- MacAddress macAddress();
-
- /**
- * Returns the port tenantId.
- *
- * @return port tenantId
- */
- TenantId tenantId();
-
- /**
- * Returns the device identifier.
- *
- * @return deviceId
- */
- DeviceId deviceId();
-
- /**
- * Returns the identifier of the entity that uses this port.
- *
- * @return deviceOwner
- */
- String deviceOwner();
-
- /**
- * Returns the basePort allowedAddressPairs.
- *
- * @return basePort allowedAddressPairs
- */
- Collection<AllowedAddressPair> allowedAddressPairs();
-
- /**
- * Returns set of IP addresses for the port, include the IP addresses and subnet
- * identity.
- *
- * @return FixedIps Set of fixedIp
- */
- Set<FixedIp> fixedIps();
-
- /**
- * Returns the basePort bindinghostId.
- *
- * @return basePort bindinghostId
- */
- BindingHostId bindingHostId();
-
- /**
- * Returns the basePort bindingVnicType.
- *
- * @return basePort bindingVnicType
- */
- String bindingVnicType();
-
- /**
- * Returns the basePort bindingVifType.
- *
- * @return basePort bindingVifType
- */
- String bindingVifType();
-
- /**
- * Returns the basePort bindingvifDetail.
- *
- * @return basePort bindingvifDetail
- */
- String bindingVifDetails();
-
- /**
- * Returns the security groups.
- *
- * @return port security groups
- */
- Iterable<SecurityGroup> securityGroups();
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/BasePortId.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/BasePortId.java
deleted file mode 100644
index 4eb120a..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/BasePortId.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc;
-
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a base port identifier.
- */
-public final class BasePortId extends Identifier<String> {
- // Public construction is prohibited
- private BasePortId(String basePortId) {
- super(checkNotNull(basePortId, "BasePortId cannot be null"));
- }
-
- public String portId() {
- return identifier;
- }
-
- /**
- * Creates a virtualPort id using the supplied portId.
- *
- * @param portId baseport identifier
- * @return BasePortId
- */
- public static BasePortId portId(String portId) {
- return new BasePortId(portId);
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/DefaultBasePort.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/DefaultBasePort.java
deleted file mode 100644
index ec9e59e..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/DefaultBasePort.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc;
-
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.SecurityGroup;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Default implementation of Base port.
- */
-public final class DefaultBasePort implements BasePort {
- private final BasePortId id;
- private final TenantNetworkId networkId;
- private final Boolean adminStateUp;
- private final String name;
- private final String state;
- private final MacAddress macAddress;
- private final TenantId tenantId;
- private final String deviceOwner;
- private final DeviceId deviceId;
- private final Set<FixedIp> fixedIps;
- private final BindingHostId bindingHostId;
- private final String bindingVnicType;
- private final String bindingVifType;
- private final String bindingVifDetails;
- private final Set<AllowedAddressPair> allowedAddressPairs;
- private final Set<SecurityGroup> securityGroups;
-
- /**
- * Creates a BasePort object.
- *
- * @param id the base port identifier
- * @param networkId the network identifier
- * @param adminStateUp adminStateup true or false
- * @param strMap the map of properties of base port
- * @param state base port state
- * @param macAddress the MAC address
- * @param tenantId the tenant identifier
- * @param deviceId the device identifier
- * @param fixedIps set of fixed IP
- * @param bindingHostId the binding host identifier
- * @param allowedAddressPairs the collection of allowdeAddressPairs
- * @param securityGroups the collection of securityGroups
- */
- public DefaultBasePort(BasePortId id,
- TenantNetworkId networkId,
- Boolean adminStateUp,
- Map<String, String> strMap,
- String state,
- MacAddress macAddress,
- TenantId tenantId,
- DeviceId deviceId,
- Set<FixedIp> fixedIps,
- BindingHostId bindingHostId,
- Set<AllowedAddressPair> allowedAddressPairs,
- Set<SecurityGroup> securityGroups) {
- this.id = id;
- this.networkId = networkId;
- this.adminStateUp = adminStateUp;
- this.name = strMap.get("name");
- this.state = state;
- this.macAddress = macAddress;
- this.tenantId = tenantId;
- this.deviceOwner = strMap.get("deviceOwner");
- this.deviceId = deviceId;
- this.fixedIps = fixedIps;
- this.bindingHostId = bindingHostId;
- this.bindingVnicType = strMap.get("bindingVnicType");
- this.bindingVifType = strMap.get("bindingVifType");
- this.bindingVifDetails = strMap.get("bindingVifDetails");
- this.allowedAddressPairs = allowedAddressPairs;
- this.securityGroups = securityGroups;
- }
-
- @Override
- public BasePortId portId() {
- return id;
- }
-
- @Override
- public TenantNetworkId networkId() {
- return networkId;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public boolean adminStateUp() {
- return adminStateUp;
- }
-
- @Override
- public String state() {
- return state;
- }
-
- @Override
- public MacAddress macAddress() {
- return macAddress;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public DeviceId deviceId() {
- return deviceId;
- }
-
- @Override
- public String deviceOwner() {
- return deviceOwner;
- }
-
- @Override
- public Collection<AllowedAddressPair> allowedAddressPairs() {
- return allowedAddressPairs;
- }
-
- @Override
- public Set<FixedIp> fixedIps() {
- return fixedIps;
- }
-
- @Override
- public BindingHostId bindingHostId() {
- return bindingHostId;
- }
-
- @Override
- public String bindingVnicType() {
- return bindingVifType;
- }
-
- @Override
- public String bindingVifType() {
- return bindingVifType;
- }
-
- @Override
- public String bindingVifDetails() {
- return bindingVifDetails;
- }
-
- @Override
- public Collection<SecurityGroup> securityGroups() {
- return securityGroups;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, networkId, adminStateUp, name, state,
- macAddress, tenantId, deviceId, deviceOwner,
- allowedAddressPairs, fixedIps, bindingHostId,
- bindingVnicType, bindingVifType, bindingVifDetails,
- securityGroups);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultBasePort) {
- final DefaultBasePort that = (DefaultBasePort) obj;
- return Objects.equals(this.id, that.id)
- && Objects.equals(this.networkId, that.networkId)
- && Objects.equals(this.adminStateUp, that.adminStateUp)
- && Objects.equals(this.state, that.state)
- && Objects.equals(this.name, that.name)
- && Objects.equals(this.tenantId, that.tenantId)
- && Objects.equals(this.macAddress, that.macAddress)
- && Objects.equals(this.deviceId, that.deviceId)
- && Objects.equals(this.deviceOwner, that.deviceOwner)
- && Objects.equals(this.allowedAddressPairs,
- that.allowedAddressPairs)
- && Objects.equals(this.fixedIps, that.fixedIps)
- && Objects.equals(this.bindingHostId, that.bindingHostId)
- && Objects.equals(this.bindingVifDetails,
- that.bindingVifDetails)
- && Objects.equals(this.bindingVifType, that.bindingVifType)
- && Objects.equals(this.bindingVnicType,
- that.bindingVnicType)
- && Objects.equals(this.securityGroups, that.securityGroups);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("id", id).add("network_id", networkId)
- .add("adminStateUp", adminStateUp).add("state", state)
- .add("name", name).add("state", state)
- .add("macAddress", macAddress).add("tenantId", tenantId)
- .add("deviced", deviceId).add("deviceOwner", deviceOwner)
- .add("allowedAddressPairs", allowedAddressPairs)
- .add("fixedIp", fixedIps).add("bindingHostId", bindingHostId)
- .add("bindingVnicType", bindingVnicType)
- .add("bindingVifDetails", bindingVifDetails)
- .add("bindingVifType", bindingVifType)
- .add("securityGroups", securityGroups).toString();
- }
-
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/DefaultVpnAfConfig.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/DefaultVpnAfConfig.java
deleted file mode 100644
index afa32a0..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/DefaultVpnAfConfig.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc;
-
-import org.onosproject.evpnrouteservice.VpnRouteTarget;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ID_CANNOT_BE_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.RT_CANNOT_BE_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.RT_TYPE_CANNOT_BE_NULL;
-
-/**
- * Default implementation of VPN AF configuration.
- */
-public class DefaultVpnAfConfig implements VpnAfConfig {
-
- private final String exportRoutePolicy;
- private final String importRoutePolicy;
- private final VpnRouteTarget routeTarget;
- private final String routeTargetType;
-
- /**
- * creates vpn af configuration object.
- *
- * @param exportRoutePolicy export route policy
- * @param importRoutePolicy import route policy
- * @param routeTarget route target value
- * @param routeTargetType route target type
- */
- public DefaultVpnAfConfig(String exportRoutePolicy,
- String importRoutePolicy,
- VpnRouteTarget routeTarget,
- String routeTargetType) {
- this.exportRoutePolicy = checkNotNull(exportRoutePolicy,
- ID_CANNOT_BE_NULL);
- this.importRoutePolicy = checkNotNull(importRoutePolicy,
- ID_CANNOT_BE_NULL);
- this.routeTarget = checkNotNull(routeTarget, RT_CANNOT_BE_NULL);
- this.routeTargetType = checkNotNull(routeTargetType,
- RT_TYPE_CANNOT_BE_NULL);
- }
-
- @Override
- public String exportRoutePolicy() {
- return exportRoutePolicy;
- }
-
- @Override
- public String importRoutePolicy() {
- return importRoutePolicy;
- }
-
- @Override
- public VpnRouteTarget routeTarget() {
- return routeTarget;
- }
-
- @Override
- public String routeTargetType() {
- return routeTargetType;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("exportRoutePolicy", exportRoutePolicy)
- .add("importRoutePolicy", importRoutePolicy)
- .add("routeTarget", routeTarget)
- .add("routeTargetType", routeTargetType)
- .toString();
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/DefaultVpnInstance.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/DefaultVpnInstance.java
deleted file mode 100644
index 62b1a70..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/DefaultVpnInstance.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc;
-
-import org.onosproject.evpnrouteservice.EvpnInstanceName;
-import org.onosproject.evpnrouteservice.RouteDistinguisher;
-import org.onosproject.evpnrouteservice.VpnRouteTarget;
-
-import java.util.Objects;
-import java.util.Set;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.CONFIG_RT_CANNOT_BE_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.DESCRIPTION;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.DESCRIPTION_CANNOT_BE_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.EXPORT_RT_CANNOT_BE_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ID;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ID_CANNOT_BE_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.IMPORT_RT_CANNOT_BE_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.INSTANCE_NAME_CANNOT_BE_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.RD_CANNOT_BE_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ROUTE_DISTINGUISHER;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPNINSTANCE_NAME;
-
-/**
- * Default implementation of VPN instance.
- */
-public class DefaultVpnInstance implements VpnInstance {
- private final VpnInstanceId id;
- private final String description;
- private final EvpnInstanceName name;
- private final RouteDistinguisher routeDistinguisher;
- private final Set<VpnRouteTarget> exportRtSet;
- private final Set<VpnRouteTarget> importRtSet;
- private final Set<VpnRouteTarget> configRtSet;
-
-
- /**
- * creates vpn instance object.
- *
- * @param id vpn instance identifier
- * @param instanceName the name of vpn instance
- * @param description the description of vpn instance
- * @param routeDistinguisher the routeDistinguisher of vpn instance
- * @param exportRtSet the export route target information
- * @param importRtSet the import route target information
- * @param configRtSet the config route target information
- */
- public DefaultVpnInstance(VpnInstanceId id, EvpnInstanceName instanceName,
- String description,
- RouteDistinguisher routeDistinguisher,
- Set<VpnRouteTarget> exportRtSet,
- Set<VpnRouteTarget> importRtSet,
- Set<VpnRouteTarget> configRtSet) {
- this.id = checkNotNull(id, ID_CANNOT_BE_NULL);
- this.name = checkNotNull(instanceName, INSTANCE_NAME_CANNOT_BE_NULL);
- this.description = checkNotNull(description,
- DESCRIPTION_CANNOT_BE_NULL);
- this.routeDistinguisher = checkNotNull(routeDistinguisher,
- RD_CANNOT_BE_NULL);
- this.exportRtSet = checkNotNull(exportRtSet, EXPORT_RT_CANNOT_BE_NULL);
- this.importRtSet = checkNotNull(importRtSet, IMPORT_RT_CANNOT_BE_NULL);
- this.configRtSet = checkNotNull(configRtSet, CONFIG_RT_CANNOT_BE_NULL);
- }
-
- @Override
- public VpnInstanceId id() {
- return id;
- }
-
- @Override
- public String description() {
- return description;
- }
-
- @Override
- public RouteDistinguisher routeDistinguisher() {
- return routeDistinguisher;
- }
-
- @Override
- public EvpnInstanceName vpnInstanceName() {
- return name;
- }
-
- @Override
- public Set<VpnRouteTarget> getExportRouteTargets() {
- return exportRtSet;
- }
-
- @Override
- public Set<VpnRouteTarget> getImportRouteTargets() {
- return importRtSet;
- }
-
- @Override
- public Set<VpnRouteTarget> getConfigRouteTargets() {
- return configRtSet;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, name, description, routeDistinguisher,
- exportRtSet, importRtSet, configRtSet);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultVpnInstance) {
- final DefaultVpnInstance that = (DefaultVpnInstance) obj;
- return Objects.equals(this.id, that.id)
- && Objects.equals(this.name, that.name)
- && Objects.equals(this.description, that.description)
- && Objects.equals(this.routeDistinguisher,
- that.routeDistinguisher)
- && Objects.equals(this.exportRtSet, that.exportRtSet)
- && Objects.equals(this.importRtSet, that.importRtSet)
- && Objects.equals(this.configRtSet, that.configRtSet);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add(ID, id)
- .add(DESCRIPTION, description)
- .add(VPNINSTANCE_NAME, name)
- .add(ROUTE_DISTINGUISHER, routeDistinguisher)
- .add("exportRtSet", exportRtSet)
- .add("importRtSet", importRtSet)
- .add("configRtSet", configRtSet)
- .toString();
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/DefaultVpnPort.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/DefaultVpnPort.java
deleted file mode 100644
index c036a5f..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/DefaultVpnPort.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ID;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ID_CANNOT_BE_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_INSTANCE_ID;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_INSTANCE_ID_CANNOT_BE_NULL;
-
-/**
- * Default implementation of VPN port.
- */
-public class DefaultVpnPort implements VpnPort {
-
- private final VpnPortId id;
- private final VpnInstanceId vpnInstanceId;
-
- /**
- * creates vpn port object.
- *
- * @param id vpn port id
- * @param vpnInstanceId vpn instance id
- */
- public DefaultVpnPort(VpnPortId id, VpnInstanceId vpnInstanceId) {
- this.id = checkNotNull(id, ID_CANNOT_BE_NULL);
- this.vpnInstanceId = checkNotNull(vpnInstanceId,
- VPN_INSTANCE_ID_CANNOT_BE_NULL);
- }
-
- @Override
- public VpnPortId id() {
- return id;
- }
-
- @Override
- public VpnInstanceId vpnInstanceId() {
- return vpnInstanceId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, vpnInstanceId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultVpnPort) {
- final DefaultVpnPort that = (DefaultVpnPort) obj;
- return Objects.equals(this.id, that.id)
- && Objects.equals(this.vpnInstanceId, that.vpnInstanceId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add(ID, id)
- .add(VPN_INSTANCE_ID, vpnInstanceId).toString();
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/EvpnConstants.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/EvpnConstants.java
deleted file mode 100644
index 3bb692c..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/EvpnConstants.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc;
-
-/**
- * Provides constants used in EVPN openflow application.
- */
-public final class EvpnConstants {
- private EvpnConstants() {
- }
-
- public static final String APP_ID = "org.onosproject.evpnopenflow";
- public static final String EVPN_OPENFLOW_START = "evpn-openflow app is " +
- "started";
- public static final String EVPN_OPENFLOW_STOP = "evpn-openflow app is " +
- "stopped";
- public static final String EVPN_VPN_PORT_START = "EVPN port started";
- public static final String EVPN_VPN_PORT_STOP = "EVPN port stopped";
- public static final String EVPN_VPN_INSTANCE_START = "EVPN instance " +
- "started";
- public static final String EVPN_VPN_INSTANCE_STOP = "EVPN instance " +
- "stopped";
- public static final String HOST_DETECT = "Host detected {}";
- public static final String HOST_VANISHED = "Host vanished {}";
- public static final String IFACEID = "ifaceid";
- public static final String IFACEID_OF_HOST_IS_NULL =
- "The ifaceId of host is null";
- public static final String CANT_FIND_VPN_PORT = "Can't find vpnport {}";
- public static final String CANT_FIND_VPN_INSTANCE = "EVPN instance {} is " +
- "not exist";
- public static final String CANT_FIND_CONTROLLER_DEVICE = "Can't find " +
- "controller of device: {}";
- public static final String GET_PRIVATE_LABEL = "Get private label {}";
- public static final String RELEASE_LABEL_FAILED = "Release resoure label " +
- "{} failed";
- public static final String VPN_PORT_UNBIND = "On EVPN port unbind";
- public static final String VPN_PORT_BIND = "On EVPN port bind";
- public static final String SLASH = "/";
- public static final String COMMA = ",";
- public static final String VPN_INSTANCE_TARGET = "VpnService";
- public static final String VPN_PORT_TARGET = "VpnBinding";
- public static final String BASEPORT = "Port";
- public static final String VPN_AF_TARGET = "VpnAfConfig";
- public static final String BGP_PEERING = "BGPPeering";
- public static final String DATA_PLANE_TUNNEL = "DataplaneTunnel";
- public static final String VPN_PORT_STORE = "evpn-port-store";
- public static final String BASE_PORT_STORE = "evpn-baseport-store";
- public static final String VPN_INSTANCE_STORE =
- "evpn-instance-store";
- public static final String VPN_PORT_ID_NOT_NULL = "EVPN port ID cannot be" +
- " null";
- public static final String VPN_PORT_NOT_NULL = "EVPN port cannot be null";
- public static final String RESPONSE_NOT_NULL = "JsonNode can not be null";
- public static final String LISTENER_NOT_NULL = "Listener cannot be null";
- public static final String EVENT_NOT_NULL = "Event cannot be null";
- public static final String DELETE = "delete";
- public static final String SET = "set";
- public static final String UPDATE = "update";
- public static final String VPN_PORT_ID = "EVPN port ID is {} ";
- public static final String VPN_PORT_CREATION_FAILED = "The EVPN port " +
- "creation is failed whose identifier is {} ";
- public static final String VPN_PORT_IS_NOT_EXIST = "The EVPN port is not " +
- "exist whose identifier is {}";
- public static final String VPN_PORT_UPDATE_FAILED = "The EVPN port update" +
- " is failed whose identifier is {}";
- public static final String VPN_PORT_DELETE_FAILED =
- "The EVPN port delete is failed whose identifier is {}";
- public static final String INTERFACE_ID = "interface_id";
- public static final String ID = "id";
- public static final String VPN_INSTANCE = "service_id";
- public static final String VPN_INSTANCE_ID_NOT_NULL = "EVPN instance ID " +
- "cannot be null";
- public static final String VPN_INSTANCE_NOT_NULL = "EVPN instance cannot " +
- "be null";
- public static final String JSON_NOT_NULL = "JsonNode can not be null";
- public static final String INSTANCE_ID = "EVPN instance ID is {} ";
- public static final String VPN_INSTANCE_CREATION_FAILED = "The " +
- "EVPN instance creation is failed whose identifier is {} ";
- public static final String VPN_INSTANCE_IS_NOT_EXIST = "The EVPN instance" +
- " is not exist whose identifier is {}";
- public static final String VPN_INSTANCE_UPDATE_FAILED = "The EVPN " +
- "instance update is failed whose identifier is {}";
- public static final String VPN_INSTANCE_DELETE_FAILED = "The EVPN " +
- "instance delete is failed whose identifier is {}";
- public static final String VPN_INSTANCE_NAME = "name";
- public static final String DESCRIPTION = "description";
- public static final String ROUTE_DISTINGUISHERS = "route_distinguishers";
- public static final String IPV4_FAMILY = "ipv4_family";
- static final String ID_CANNOT_BE_NULL = "ID cannot be null";
- static final String INSTANCE_NAME_CANNOT_BE_NULL = "Instance name cannot " +
- "be null";
- static final String DESCRIPTION_CANNOT_BE_NULL = "Description cannot be " +
- "null";
- static final String RD_CANNOT_BE_NULL = "RouteDistinguisher cannot be null";
- static final String RT_CANNOT_BE_NULL = "RouteTarget cannot be null";
- static final String VPNINSTANCE_NAME = "vpnInstanceName";
- static final String ROUTE_DISTINGUISHER = "routeDistinguisher";
- static final String VPN_INSTANCE_ID_CANNOT_BE_NULL = "EVPN instance ID " +
- "cannot be null";
- static final String VPN_INSTANCE_ID = "vpnInstanceId";
- public static final String FORMAT_VPN_INSTANCE = "Id=%s, description=%s,"
- + " name=%s, routeDistinguisher=%s, routeTarget=%s";
- public static final String FORMAT_VPN_PORT = " EVPN port id=%-32s, " +
- "EVPN instance id=%-18s";
- public static final String FORMAT_PRIVATE_ROUTE = " %-18s %-15s %-10s";
- public static final String FORMAT_PUBLIC_ROUTE = " %-18s %-18s %-10s";
- public static final String SWITCH_CHANNEL_ID = "channelId";
- public static final String NOT_MASTER_FOR_SPECIFIC_DEVICE = "The local " +
- "controller is not master for the specified deviceId";
- public static final String VPN_AF_CONFIG_STORE =
- "evpn-vpn-af-config-store";
- public static final String EVPN_VPN_AF_CONFIG_START = "EVPN af config" +
- " started";
- public static final String EVPN_VPN_AF_CONFIG_STOP = "EVPN af config" +
- " stopped";
- static final String RT_TYPE_CANNOT_BE_NULL = "Route target type " +
- "cannot be null";
- public static final String VPN_AF_CONFIG_NOT_NULL = "EVPN af config be " +
- "null";
- public static final String ROUTE_TARGET_VALUE = "Route target value is {} ";
- public static final String VPN_AF_CONFIG_CREATION_FAILED = "The " +
- "EVPN af config creation is failed whose route target is {} ";
- public static final String VPN_AF_CONFIG_UPDATE_FAILED = "The EVPN af " +
- "config update is failed whose identifier is {}";
- public static final String VPN_AF_CONFIG_IS_NOT_EXIST = "The EVPN AF " +
- "config is not exist whose identifier is {}";
- public static final String ROUTE_TARGET_CANNOT_NOT_NULL = "Route target " +
- "value cannot be null";
- public static final String ROUTE_TARGET_DELETE_FAILED = "The route target" +
- " delete is failed whose route target value is {}";
- static final String EXPORT_RT_CANNOT_BE_NULL = "export route " +
- "target set cannot be null";
- static final String IMPORT_RT_CANNOT_BE_NULL = "import route " +
- "target set cannot be null";
- static final String CONFIG_RT_CANNOT_BE_NULL = "import route " +
- "target set cannot be null";
- public static final String EXPORT_EXTCOMMUNITY = "export_extcommunity";
- public static final String IMPORT_EXTCOMMUNITY = "import_extcommunity";
- public static final String BOTH = "both";
- public static final String INVALID_ROUTE_TARGET_TYPE
- = "Invalid route target type has received";
- public static final String INVALID_EVENT_RECEIVED
- = "Invalid event is received while processing network " +
- "configuration event";
- public static final String NETWORK_CONFIG_EVENT_IS_RECEIVED
- = "Event is received from network configuration {}";
- public static final int ARP_PRIORITY = 0xffff;
- public static final short ARP_RESPONSE = 0x2;
- public static final String INVALID_TARGET_RECEIVED
- = "Invalid target type has received";
- public static final String INVALID_ACTION_VPN_AF_CONFIG
- = "Invalid action is received while processing VPN af" +
- " configuration";
- public static final String EXPORT_ROUTE_POLICY = "export_route_policy";
- public static final String IMPORT_ROUTE_POLICY = "import_route_policy";
- public static final String VRF_RT_TYPE = "vrf_rt_type";
- public static final String VRF_RT_VALUE = "vrf_rt_value";
- public static final String BGP_EVPN_ROUTE_UPDATE_START
- = "bgp evpn route update start {}";
- public static final String MPLS_OUT_FLOWS = "mpls out flows --> {}";
- public static final String BGP_EVPN_ROUTE_DELETE_START
- = "bgp route delete start {}";
- public static final String ROUTE_ADD_ARP_RULES = "Route ARP Rules-->ADD";
- public static final String ROUTE_REMOVE_ARP_RULES
- = "Route ARP Rules-->REMOVE";
- public static final String TUNNEL_DST = "tunnelDst";
- public static final String FAILED_TO_SET_TUNNEL_DST
- = "Failed to get extension instruction to set tunnel dst {}";
- public static final String VXLAN = "vxlan";
- public static final String CANNOT_FIND_TUNNEL_PORT_DEVICE =
- "Can't find tunnel port in device {}";
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnAfConfig.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnAfConfig.java
deleted file mode 100644
index 83d5686..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnAfConfig.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc;
-
-import org.onosproject.evpnrouteservice.VpnRouteTarget;
-
-/**
- * Representation of a VPN af configuration.
- */
-public interface VpnAfConfig {
-
- /**
- * Returns the export route policy information.
- *
- * @return export route policy
- */
- String exportRoutePolicy();
-
- /**
- * Returns the import route policy information.
- *
- * @return export route policy
- */
- String importRoutePolicy();
-
- /**
- * Returns the route target value.
- *
- * @return route target value
- */
- VpnRouteTarget routeTarget();
-
- /**
- * Returns the route target type.
- *
- * @return route target type
- */
- String routeTargetType();
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnInstance.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnInstance.java
deleted file mode 100644
index 3c2d062..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnInstance.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc;
-
-import org.onosproject.evpnrouteservice.EvpnInstanceName;
-import org.onosproject.evpnrouteservice.RouteDistinguisher;
-import org.onosproject.evpnrouteservice.VpnRouteTarget;
-
-import java.util.Set;
-
-/**
- * Representation of a VPN instance.
- */
-public interface VpnInstance {
-
- /**
- * Returns the VPN instance identifier.
- *
- * @return VPN instance identifier
- */
- VpnInstanceId id();
-
- /**
- * Returns the VPN instance description.
- *
- * @return VPN instance description
- */
- String description();
-
- /**
- * Returns the VPN instance route distinguishes.
- *
- * @return VPN instance route distinguishes
- */
- RouteDistinguisher routeDistinguisher();
-
- /**
- * Returns the VPN instance name.
- *
- * @return VPN instance name
- */
- EvpnInstanceName vpnInstanceName();
-
- /**
- * Returns the export route target information.
- *
- * @return export route target information
- */
- Set<VpnRouteTarget> getExportRouteTargets();
-
- /**
- * Returns the import route target information.
- *
- * @return VPN instance ipv4 family
- */
- Set<VpnRouteTarget> getImportRouteTargets();
-
- /**
- * Returns the config route target information.
- *
- * @return config route target information.
- */
- Set<VpnRouteTarget> getConfigRouteTargets();
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnInstanceId.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnInstanceId.java
deleted file mode 100644
index 03399ed..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnInstanceId.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc;
-
-import org.onlab.util.Identifier;
-
-/**
- * Immutable representation of a VPN instance identity.
- */
-public final class VpnInstanceId extends Identifier<String> {
- // Public construction is prohibited
- private VpnInstanceId(String vpnInstanceId) {
- super(vpnInstanceId);
- }
-
- /**
- * Creates a VPN instance identifier.
- *
- * @param vpnInstanceId VPN instance identify string
- * @return VPN instance identifier
- */
- public static VpnInstanceId vpnInstanceId(String vpnInstanceId) {
- return new VpnInstanceId(vpnInstanceId);
- }
-
- /**
- * Returns VPN instance identifier.
- *
- * @return the VPN instance identifier
- */
- public String vpnInstanceId() {
- return identifier;
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnPort.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnPort.java
deleted file mode 100644
index 82f5336..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnPort.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc;
-
-/**
- * Representation of a VPN port.
- */
-public interface VpnPort {
-
- /**
- * Returns the VPN port identifier.
- *
- * @return VPN port identifier
- */
- VpnPortId id();
-
- /**
- * Returns the VPN instance identifier.
- *
- * @return VPN instance identifier
- */
- VpnInstanceId vpnInstanceId();
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnPortId.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnPortId.java
deleted file mode 100644
index f900830..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/VpnPortId.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc;
-
-import org.onlab.util.Identifier;
-
-/**
- * Immutable representation of a VPN port identity.
- */
-public final class VpnPortId extends Identifier<String> {
- // Public construction is prohibited
- private VpnPortId(String vpnPortId) {
- super(vpnPortId);
- }
-
- /**
- * Creates a VPN port identifier.
- *
- * @param vpnPortId VPN port identifier
- * @return VPN port identifier
- */
- public static VpnPortId vpnPortId(String vpnPortId) {
- return new VpnPortId(vpnPortId);
- }
-
- /**
- * Returns VPN port identifier.
- *
- * @return the VPN port identifier
- */
- public String vpnPortId() {
- return identifier;
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/BasePortEvent.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/BasePortEvent.java
deleted file mode 100644
index acb762a..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/BasePortEvent.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.baseport;
-
-import org.onosproject.event.AbstractEvent;
-import org.onosproject.evpnopenflow.rsc.BasePort;
-
-/**
- * Describes base port event.
- */
-public class BasePortEvent extends AbstractEvent<BasePortEvent.Type,
- BasePort> {
- /**
- * Type of base port events.
- */
- public enum Type {
- /**
- * Signifies that base port has been created.
- */
- BASE_PORT_PUT,
- /**
- * Signifies that base port has been deleted.
- */
- BASE_PORT_DELETE,
- /**
- * Signifies that base port has been updated.
- */
- BASE_PORT_UPDATE
- }
-
- /**
- * Creates an event of a given type and for the specified base port.
- *
- * @param type base port event type
- * @param basePort base port subject
- */
- public BasePortEvent(Type type, BasePort basePort) {
- super(type, basePort);
- }
-
- /**
- * Creates an event of a given type and for the specified base port.
- *
- * @param type base port event type
- * @param basePort base port subject
- * @param time occurrence time
- */
- public BasePortEvent(Type type, BasePort basePort, long time) {
- super(type, basePort, time);
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/BasePortListener.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/BasePortListener.java
deleted file mode 100644
index 2822bb3..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/BasePortListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.baseport;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Entity capable of base port related events.
- */
-public interface BasePortListener extends EventListener<BasePortEvent> {
-
-}
\ No newline at end of file
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/BasePortService.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/BasePortService.java
deleted file mode 100644
index c3bdb2b..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/BasePortService.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.baseport;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onosproject.evpnopenflow.rsc.BasePort;
-import org.onosproject.evpnopenflow.rsc.BasePortId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-
-import java.util.Collection;
-
-
-/**
- * Service for interacting with the inventory of basePort.
- */
-public interface BasePortService {
- /**
- * Returns if the basePort is existed.
- *
- * @param basePortId basePort identifier
- * @return true or false if one with the given identifier is not existed.
- */
- boolean exists(BasePortId basePortId);
-
- /**
- * Returns the basePort with the identifier.
- *
- * @param basePortId basePort ID
- * @return BasePort or null if one with the given ID is not know.
- */
- BasePort getPort(BasePortId basePortId);
-
- /**
- * Returns the basePort associated with the fixedIP.
- *
- * @param fixedIP the fixedIP identifier
- * @return basePort.
- */
- BasePort getPort(FixedIp fixedIP);
-
- /**
- * Returns the basePort associated with the mac address.
- *
- * @param mac the mac address
- * @return basePort.
- */
- BasePort getPort(MacAddress mac);
-
- /**
- * Returns the basePort associated with the networkId and ip.
- *
- * @param networkId the TenantNetworkId identifier
- * @param ip the ip identifier
- * @return basePort.
- */
- BasePort getPort(TenantNetworkId networkId, IpAddress ip);
-
- /**
- * Returns the collection of the currently known basePort.
- *
- * @return collection of BasePort.
- */
- Collection<BasePort> getPorts();
-
- /**
- * Returns the collection of the basePorts associated with the networkId.
- *
- * @param networkId the network identifer
- * @return collection of basePort.
- */
- Collection<BasePort> getPorts(TenantNetworkId networkId);
-
- /**
- * Returns the collection of the basePorts associated with the tenantId.
- *
- * @param tenantId the tenant identifier
- * @return collection of basePorts.
- */
- Collection<BasePort> getPorts(TenantId tenantId);
-
- /**
- * Returns the collection of the basePorts associated with the deviceId.
- *
- * @param deviceId the device identifier
- * @return collection of basePort.
- */
- Collection<BasePort> getPorts(DeviceId deviceId);
-
- /**
- * Creates basePorts by basePorts.
- *
- * @param basePorts the iterable collection of basePorts
- * @return true if all given identifiers created successfully.
- */
- boolean createPorts(Iterable<BasePort> basePorts);
-
- /**
- * Updates basePorts by basePorts.
- *
- * @param basePorts the iterable collection of basePorts
- * @return true if all given identifiers updated successfully.
- */
- boolean updatePorts(Iterable<BasePort> basePorts);
-
- /**
- * Deletes basePortIds by basePortIds.
- *
- * @param basePortIds the iterable collection of basePort identifiers
- * @return true or false if one with the given identifier to delete is
- * successfully.
- */
- boolean removePorts(Iterable<BasePortId> basePortIds);
-
- /**
- * process gluon config for vpn port information.
- *
- * @param action can be either update or delete
- * @param key can contain the id and also target information
- * @param value content of the vpn port configuration
- */
- void processGluonConfig(String action, String key, JsonNode value);
-
- /**
- * Adds the specified listener to Vpn Port manager.
- *
- * @param listener Vpn Port listener
- */
- void addListener(BasePortListener listener);
-
- /**
- * Removes the specified listener to Vpn Port manager.
- *
- * @param listener Vpn Port listener
- */
- void removeListener(BasePortListener listener);
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/impl/BasePortManager.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/impl/BasePortManager.java
deleted file mode 100644
index 27f9fd7..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/impl/BasePortManager.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.baseport.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.google.common.collect.Sets;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.evpnopenflow.rsc.BasePort;
-import org.onosproject.evpnopenflow.rsc.BasePortId;
-import org.onosproject.evpnopenflow.rsc.DefaultBasePort;
-import org.onosproject.evpnopenflow.rsc.baseport.BasePortEvent;
-import org.onosproject.evpnopenflow.rsc.baseport.BasePortListener;
-import org.onosproject.evpnopenflow.rsc.baseport.BasePortService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.MultiValuedTimestamp;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.DefaultFloatingIp;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.FloatingIp;
-import org.onosproject.vtnrsc.FloatingIpId;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.SecurityGroup;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.TenantRouter;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.APP_ID;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.BASE_PORT_STORE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.LISTENER_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.RESPONSE_NOT_NULL;
-
-/**
- * Provides implementation of the BasePort APIs.
- */
-@Component(immediate = true, service = BasePortService.class)
-public class BasePortManager implements BasePortService {
-
- private final Set<BasePortListener> listeners = Sets
- .newCopyOnWriteArraySet();
- private final Logger log = LoggerFactory.getLogger(getClass());
- private static final String BASEPORT_ID_NULL = "BasePort ID cannot be " +
- "null";
- private static final String BASEPORT_NOT_NULL = "BasePort cannot be " +
- "null";
- private static final String TENANTID_NOT_NULL = "TenantId cannot be null";
- private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null";
- private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null";
- private static final String FIXEDIP_NOT_NULL = "FixedIp cannot be null";
- private static final String MAC_NOT_NULL = "Mac address cannot be null";
- private static final String IP_NOT_NULL = "Ip cannot be null";
- private static final String EVENT_NOT_NULL = "event cannot be null";
- private static final String SET = "set";
- private static final String UPDATE = "update";
- private static final String DELETE = "delete";
- private static final String SLASH = "/";
- private static final String PROTON_BASE_PORT = "Port";
- private static final String JSON_NOT_NULL = "JsonNode can not be null";
-
- protected EventuallyConsistentMap<BasePortId, BasePort> vPortStore;
- protected ApplicationId appId;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Activate
- public void activate() {
-
- appId = coreService.registerApplication(APP_ID);
-
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API)
- .register(MultiValuedTimestamp.class)
- .register(TenantNetworkId.class)
- .register(Host.class)
- .register(TenantNetwork.class)
- .register(TenantNetworkId.class)
- .register(TenantId.class)
- .register(SubnetId.class)
- .register(BasePortId.class)
- .register(BasePort.State.class)
- .register(AllowedAddressPair.class)
- .register(FixedIp.class)
- .register(FloatingIp.class)
- .register(FloatingIpId.class)
- .register(FloatingIp.Status.class)
- .register(UUID.class)
- .register(DefaultFloatingIp.class)
- .register(BindingHostId.class)
- .register(SecurityGroup.class)
- .register(IpAddress.class)
- .register(DefaultBasePort.class)
- .register(RouterId.class)
- .register(TenantRouter.class)
- .register(BasePort.class);
- vPortStore = storageService
- .<BasePortId, BasePort>eventuallyConsistentMapBuilder()
- .withName(BASE_PORT_STORE).withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp())
- .build();
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- vPortStore.destroy();
- log.info("Stoppped");
- }
-
- @Override
- public boolean exists(BasePortId vPortId) {
- checkNotNull(vPortId, BASEPORT_ID_NULL);
- return vPortStore.containsKey(vPortId);
- }
-
- @Override
- public BasePort getPort(BasePortId vPortId) {
- checkNotNull(vPortId, BASEPORT_ID_NULL);
- return vPortStore.get(vPortId);
- }
-
- @Override
- public BasePort getPort(FixedIp fixedIP) {
- checkNotNull(fixedIP, FIXEDIP_NOT_NULL);
- List<BasePort> vPorts = new ArrayList<>();
- vPortStore.values().forEach(p -> {
- for (FixedIp fixedIp : p.fixedIps()) {
- if (fixedIp.equals(fixedIP)) {
- vPorts.add(p);
- break;
- }
- }
- });
- if (vPorts.size() == 0) {
- return null;
- }
- return vPorts.get(0);
- }
-
- @Override
- public BasePort getPort(MacAddress mac) {
- checkNotNull(mac, MAC_NOT_NULL);
- List<BasePort> vPorts = new ArrayList<>();
- vPortStore.values().forEach(p -> {
- if (p.macAddress().equals(mac)) {
- vPorts.add(p);
- }
- });
- if (vPorts.size() == 0) {
- return null;
- }
- return vPorts.get(0);
- }
-
- @Override
- public BasePort getPort(TenantNetworkId networkId, IpAddress ip) {
- checkNotNull(networkId, NETWORKID_NOT_NULL);
- checkNotNull(ip, IP_NOT_NULL);
- List<BasePort> vPorts = new ArrayList<>();
- vPortStore.values().stream().filter(p -> p.networkId().equals(networkId))
- .forEach(p -> {
- for (FixedIp fixedIp : p.fixedIps()) {
- if (fixedIp.ip().equals(ip)) {
- vPorts.add(p);
- break;
- }
- }
- });
- if (vPorts.size() == 0) {
- return null;
- }
- return vPorts.get(0);
- }
-
- @Override
- public Collection<BasePort> getPorts() {
- return Collections.unmodifiableCollection(vPortStore.values());
- }
-
- @Override
- public Collection<BasePort> getPorts(TenantNetworkId networkId) {
- checkNotNull(networkId, NETWORKID_NOT_NULL);
- return vPortStore.values().stream().filter(d -> d.networkId().equals(networkId))
- .collect(Collectors.toList());
- }
-
- @Override
- public Collection<BasePort> getPorts(TenantId tenantId) {
- checkNotNull(tenantId, TENANTID_NOT_NULL);
- return vPortStore.values().stream().filter(d -> d.tenantId().equals(tenantId))
- .collect(Collectors.toList());
- }
-
- @Override
- public Collection<BasePort> getPorts(DeviceId deviceId) {
- checkNotNull(deviceId, DEVICEID_NOT_NULL);
- return vPortStore.values().stream().filter(d -> d.deviceId().equals(deviceId))
- .collect(Collectors.toList());
- }
-
- @Override
- public boolean createPorts(Iterable<BasePort> vPorts) {
- checkNotNull(vPorts, BASEPORT_NOT_NULL);
- for (BasePort vPort : vPorts) {
- log.info("vPortId is {} ", vPort.portId().toString());
- vPortStore.put(vPort.portId(), vPort);
- if (!vPortStore.containsKey(vPort.portId())) {
- log.info("The basePort is created failed whose identifier is" +
- " {} ",
- vPort.portId().toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean updatePorts(Iterable<BasePort> vPorts) {
- checkNotNull(vPorts, BASEPORT_NOT_NULL);
- for (BasePort vPort : vPorts) {
- vPortStore.put(vPort.portId(), vPort);
- if (!vPortStore.containsKey(vPort.portId())) {
- log.info("The basePort is not exist whose identifier is {}",
- vPort.portId().toString());
- return false;
- }
-
- vPortStore.put(vPort.portId(), vPort);
-
- if (!vPort.equals(vPortStore.get(vPort.portId()))) {
- log.info("The basePort is updated failed whose identifier " +
- "is {}",
- vPort.portId().toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean removePorts(Iterable<BasePortId> vPortIds) {
- checkNotNull(vPortIds, BASEPORT_ID_NULL);
- for (BasePortId vPortId : vPortIds) {
- vPortStore.remove(vPortId);
- if (vPortStore.containsKey(vPortId)) {
- log.info("The basePort is removed failed whose identifier is" +
- " {}",
- vPortId.toString());
- return false;
- }
- }
- return true;
- }
-
- /**
- * Returns a collection of basePorts from subnetNodes.
- *
- * @param vPortNodes the basePort json node
- * @return BasePort collection of vpn ports
- */
- private Collection<BasePort> changeJsonToSub(JsonNode vPortNodes) {
- checkNotNull(vPortNodes, JSON_NOT_NULL);
- Set<FixedIp> fixedIps = null;
- TenantNetworkId tenantNetworkId = null;
- Map<BasePortId, BasePort> vportMap = new HashMap<>();
- Map<String, String> strMap = new HashMap<>();
- BasePortId basePortId = BasePortId.portId(vPortNodes.get("id").asText());
- String name = vPortNodes.get("name").asText();
- TenantId tenantId = TenantId
- .tenantId(vPortNodes.get("tenant_id").asText());
- Boolean adminStateUp = vPortNodes.get("admin_state_up").asBoolean();
- String state = vPortNodes.get("status").asText();
- MacAddress macAddress = MacAddress
- .valueOf(vPortNodes.get("mac_address").asText());
- DeviceId deviceId = DeviceId
- .deviceId(vPortNodes.get("device_id").asText());
- String deviceOwner = vPortNodes.get("device_owner").asText();
- BindingHostId bindingHostId = BindingHostId
- .bindingHostId(vPortNodes.get("host_id").asText());
- String bindingVnicType = vPortNodes.get("vnic_type").asText();
- String bindingVifType = vPortNodes.get("vif_type").asText();
- String bindingVifDetails = vPortNodes.get("vif_details").asText();
- strMap.put("name", name);
- strMap.put("deviceOwner", deviceOwner);
- strMap.put("bindingVnicType", bindingVnicType);
- strMap.put("bindingVifType", bindingVifType);
- strMap.put("bindingVifDetails", bindingVifDetails);
- BasePort prevBasePort = getPort(basePortId);
- if (prevBasePort != null) {
- fixedIps = prevBasePort.fixedIps();
- tenantNetworkId = prevBasePort.networkId();
- }
- BasePort vPort = new DefaultBasePort(basePortId,
- tenantNetworkId,
- adminStateUp,
- strMap, state,
- macAddress, tenantId,
- deviceId, fixedIps,
- bindingHostId,
- null,
- null);
- vportMap.put(basePortId, vPort);
-
- return Collections.unmodifiableCollection(vportMap.values());
- }
-
- /**
- * Returns BasePort State.
- *
- * @param state the base port state
- * @return the basePort state
- */
- private BasePort.State isState(String state) {
- if (state.equals("ACTIVE")) {
- return BasePort.State.ACTIVE;
- } else {
- return BasePort.State.DOWN;
- }
-
- }
-
- /**
- * process Etcd response for port information.
- *
- * @param action can be either update or delete
- * @param key can contain the id and also target information
- * @param value content of the port configuration
- */
- @Override
- public void processGluonConfig(String action, String key, JsonNode value) {
- Collection<BasePort> basePorts;
- switch (action) {
- case DELETE:
- String[] list = key.split(SLASH);
- BasePortId basePortId
- = BasePortId.portId(list[list.length - 1]);
- Set<BasePortId> basePortIds = Sets.newHashSet(basePortId);
- removePorts(basePortIds);
- break;
- case SET:
- checkNotNull(value, RESPONSE_NOT_NULL);
- basePorts = changeJsonToSub(value);
- createPorts(basePorts);
- break;
- case UPDATE:
- checkNotNull(value, RESPONSE_NOT_NULL);
- basePorts = changeJsonToSub(value);
- updatePorts(basePorts);
- break;
- default:
- log.info("Invalid action is received while processing VPN " +
- "port configuration");
- }
- }
-
- private void parseEtcdResponse(JsonNode jsonNode,
- String key,
- String action) {
- JsonNode modifyValue = null;
- if (action.equals(SET)) {
- modifyValue = jsonNode.get(key);
- }
- String[] list = key.split(SLASH);
- String target = list[list.length - 2];
- if (target.equals(PROTON_BASE_PORT)) {
- processGluonConfig(action, key, modifyValue);
- }
- }
-
- @Override
- public void addListener(BasePortListener listener) {
- checkNotNull(listener, LISTENER_NOT_NULL);
- listeners.add(listener);
- }
-
- @Override
- public void removeListener(BasePortListener listener) {
- checkNotNull(listener, LISTENER_NOT_NULL);
- listeners.remove(listener);
- }
-
- /**
- * Notifies specify event to all listeners.
- *
- * @param event vpn af config event
- */
- private void notifyListeners(BasePortEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- listeners.forEach(listener -> listener.event(event));
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/impl/package-info.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/impl/package-info.java
deleted file mode 100644
index 366dc00..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VPN resources that used by l3vpn.
- */
-package org.onosproject.evpnopenflow.rsc.baseport.impl;
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/package-info.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/package-info.java
deleted file mode 100644
index 52f5d0c..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/baseport/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VPN resources that used by l3vpn.
- */
-package org.onosproject.evpnopenflow.rsc.baseport;
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/EvpnPrivateRouteListCommand.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/EvpnPrivateRouteListCommand.java
deleted file mode 100644
index d069bc3..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/EvpnPrivateRouteListCommand.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.cli;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.evpnopenflow.manager.EvpnService;
-import org.onosproject.evpnopenflow.manager.impl.EvpnManager;
-import org.onosproject.evpnrouteservice.EvpnInstanceRoute;
-
-import java.util.Collection;
-
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.FORMAT_PRIVATE_ROUTE;
-
-/**
- * Support for displaying EVPN private routes.
- */
-@Service
-@Command(scope = "onos", name = "evpn-private-routes", description = "Lists" +
- " all EVPN private routes")
-public class EvpnPrivateRouteListCommand extends AbstractShellCommand {
- private static final String FORMAT_HEADER =
- " VPN name Prefix Next Hop";
-
- @Override
- protected void doExecute() {
- EvpnService service = AbstractShellCommand.get(EvpnService.class);
- EvpnManager evpnManager = (EvpnManager) service;
- Collection<EvpnInstanceRoute> evpnRoutes = evpnManager.evpnInstanceRoutes;
- if (evpnRoutes != null) {
- print(FORMAT_HEADER);
- evpnRoutes.forEach(evpnInstanceRoute -> {
- print(FORMAT_PRIVATE_ROUTE, evpnInstanceRoute.evpnInstanceName(),
- evpnInstanceRoute.prefix().address().getIp4Address(), evpnInstanceRoute
- .getNextHopl());
- });
- }
- }
-
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/EvpnPublicRouteListCommand.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/EvpnPublicRouteListCommand.java
deleted file mode 100644
index 809090d..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/EvpnPublicRouteListCommand.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.cli;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.evpnrouteservice.EvpnRoute;
-import org.onosproject.evpnrouteservice.EvpnRouteSet;
-import org.onosproject.evpnrouteservice.EvpnRouteStore;
-
-import java.util.Collection;
-
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.FORMAT_PUBLIC_ROUTE;
-
-/**
- * Support for displaying EVPN public routes.
- */
-@Service
-@Command(scope = "onos", name = "evpn-public-routes", description = "Lists" +
- " all EVPN public routes")
-public class EvpnPublicRouteListCommand extends AbstractShellCommand {
- private static final String FORMAT_HEADER =
- " MAC Prefix Next Hop";
-
- @Override
- protected void doExecute() {
- EvpnRouteStore evpnRouteStore = AbstractShellCommand.get(EvpnRouteStore.class);
-
- evpnRouteStore.getRouteTables().forEach(routeTableId -> {
- Collection<EvpnRouteSet> routes
- = evpnRouteStore.getRoutes(routeTableId);
- if (routes != null) {
- routes.forEach(route -> {
- Collection<EvpnRoute> evpnRoutes = route.routes();
- print(FORMAT_HEADER);
- evpnRoutes.forEach(evpnRoute -> {
- print(FORMAT_PUBLIC_ROUTE, evpnRoute.prefixMac(),
- evpnRoute.prefixIp().address().getIp4Address(),
- evpnRoute.ipNextHop());
- });
- });
- }
- });
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/VpnInstListCommand.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/VpnInstListCommand.java
deleted file mode 100644
index 33074f7..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/VpnInstListCommand.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.cli;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.evpnopenflow.rsc.EvpnConstants;
-import org.onosproject.evpnopenflow.rsc.VpnInstance;
-import org.onosproject.evpnopenflow.rsc.vpninstance.VpnInstanceService;
-
-import java.util.Collection;
-
-/**
- * Support for displaying EVPN VPN instances.
- */
-@Service
-@Command(scope = "onos", name = "evpn-instance-list", description = "Lists " +
- "all EVPN instances")
-public class VpnInstListCommand extends AbstractShellCommand {
-
- @Override
- protected void doExecute() {
- VpnInstanceService service = get(VpnInstanceService.class);
- Collection<VpnInstance> vpnInstances = service
- .getInstances();
- vpnInstances.forEach(vpnInstance -> {
- print(EvpnConstants.FORMAT_VPN_INSTANCE, vpnInstance.id(),
- vpnInstance.description(),
- vpnInstance.vpnInstanceName(),
- vpnInstance.routeDistinguisher(),
- vpnInstance.getExportRouteTargets(),
- vpnInstance.getImportRouteTargets());
- });
- }
-
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/VpnPortListCommand.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/VpnPortListCommand.java
deleted file mode 100644
index a4c7da8..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/VpnPortListCommand.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.cli;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.evpnopenflow.rsc.VpnPort;
-import org.onosproject.evpnopenflow.rsc.vpnport.VpnPortService;
-
-import java.util.Collection;
-
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.FORMAT_VPN_PORT;
-
-/**
- * Support for displaying EVPN VPN ports.
- */
-@Service
-@Command(scope = "onos", name = "evpn-port-list", description = "Lists all" +
- "EVPN ports")
-public class VpnPortListCommand extends AbstractShellCommand {
-
- @Override
- protected void doExecute() {
- VpnPortService portService = get(VpnPortService.class);
- Collection<VpnPort> ports = portService.getPorts();
- ports.forEach(port -> {
- print(FORMAT_VPN_PORT, port.id(), port.vpnInstanceId());
- });
- }
-
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/package-info.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/package-info.java
deleted file mode 100644
index 3bc47c8..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/cli/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation CLI for EVPN services.
- */
-package org.onosproject.evpnopenflow.rsc.cli;
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/package-info.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/package-info.java
deleted file mode 100644
index c37dc81..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * EVPN resource package.
- */
-package org.onosproject.evpnopenflow.rsc;
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/VpnAfConfigEvent.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/VpnAfConfigEvent.java
deleted file mode 100644
index 944698c..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/VpnAfConfigEvent.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.vpnafconfig;
-
-import org.onosproject.event.AbstractEvent;
-import org.onosproject.evpnopenflow.rsc.VpnAfConfig;
-
-/**
- * Describes network VPN af config event.
- */
-public class VpnAfConfigEvent extends AbstractEvent<VpnAfConfigEvent.Type, VpnAfConfig> {
-
- /**
- * Type of VPN port events.
- */
- public enum Type {
- /**
- * Signifies that VPN af config has been set.
- */
- VPN_AF_CONFIG_SET,
- /**
- * Signifies that VPN af config has been deleted.
- */
- VPN_AF_CONFIG_DELETE,
- /**
- * Signifies that VPN af config has been updated.
- */
- VPN_AF_CONFIG_UPDATE
- }
-
- /**
- * Creates an event of a given type and for the specified VPN af config.
- *
- * @param type VPN af config type
- * @param vpnAfConfig VPN af config subject
- */
- public VpnAfConfigEvent(Type type, VpnAfConfig vpnAfConfig) {
- super(type, vpnAfConfig);
- }
-
- /**
- * Creates an event of a given type and for the specified VPN af config.
- *
- * @param type VPN af config type
- * @param vpnAfConfig VPN af config subject
- * @param time occurrence time
- */
- public VpnAfConfigEvent(Type type, VpnAfConfig vpnAfConfig, long time) {
- super(type, vpnAfConfig, time);
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/VpnAfConfigListener.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/VpnAfConfigListener.java
deleted file mode 100644
index 42db841..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/VpnAfConfigListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.vpnafconfig;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Entity capable of VPN af config related events.
- */
-public interface VpnAfConfigListener extends EventListener<VpnAfConfigEvent> {
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/VpnAfConfigService.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/VpnAfConfigService.java
deleted file mode 100644
index ecde40d..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/VpnAfConfigService.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.vpnafconfig;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.onosproject.evpnopenflow.rsc.VpnAfConfig;
-import org.onosproject.evpnrouteservice.VpnRouteTarget;
-
-import java.util.Collection;
-
-/**
- * Service for interacting with the inventory of VPN af config instance.
- */
-public interface VpnAfConfigService {
- /**
- * Returns if the route target is existed.
- *
- * @param routeTarget route target
- * @return true or false if one with the given route target is not existed.
- */
- boolean exists(VpnRouteTarget routeTarget);
-
- /**
- * Returns the VPN af config with the route target.
- *
- * @param routeTarget route target
- * @return VPN af config or null if one with the given route target is not
- * know.
- */
- VpnAfConfig getVpnAfConfig(VpnRouteTarget routeTarget);
-
- /**
- * Returns the collection of the currently known VPN af configurations.
- *
- * @return collection of VPN af configurations.
- */
- Collection<VpnAfConfig> getVpnAfConfigs();
-
- /**
- * Creates VPN af configurations by vpnAfConfigs.
- *
- * @param vpnAfConfigs the iterable collection of vpnAfConfigs
- * @return true if all given VPN af configs created successfully
- */
- boolean createVpnAfConfigs(Iterable<VpnAfConfig> vpnAfConfigs);
-
- /**
- * Updates VPN af configurations by vpnAfConfigs.
- *
- * @param vpnAfConfigs the iterable collection of vpnAfConfigs
- * @return true if all given VPN af configs created successfully.
- */
- boolean updateVpnAfConfigs(Iterable<VpnAfConfig> vpnAfConfigs);
-
- /**
- * Deletes vpnAfConfigs by route target.
- *
- * @param routeTarget the iterable collection of vpnAFConfigs
- * @return true or false if one with the given route target to delete is
- * successfully
- */
- boolean removeVpnAfConfigs(Iterable<VpnRouteTarget> routeTarget);
-
- /**
- * process gluon config for vpn af configuration.
- *
- * @param action can be either update or delete
- * @param key can contain the id and also target information
- * @param value content of the route targets configuration
- */
- void processGluonConfig(String action, String key, JsonNode value);
-
- /**
- * Adds the specified listener to Vpn Port manager.
- *
- * @param listener vpn af config listener
- */
- void addListener(VpnAfConfigListener listener);
-
- /**
- * Removes the specified listener to vpn af config manager.
- *
- * @param listener vpn af config listener
- */
- void removeListener(VpnAfConfigListener listener);
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/impl/VpnAfConfigManager.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/impl/VpnAfConfigManager.java
deleted file mode 100644
index a2ee02c..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/impl/VpnAfConfigManager.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.vpnafconfig.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.google.common.collect.Sets;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.CoreService;
-import org.onosproject.evpnopenflow.rsc.DefaultVpnAfConfig;
-import org.onosproject.evpnopenflow.rsc.VpnAfConfig;
-import org.onosproject.evpnopenflow.rsc.vpnafconfig.VpnAfConfigEvent;
-import org.onosproject.evpnopenflow.rsc.vpnafconfig.VpnAfConfigListener;
-import org.onosproject.evpnopenflow.rsc.vpnafconfig.VpnAfConfigService;
-import org.onosproject.evpnrouteservice.VpnRouteTarget;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.APP_ID;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.DELETE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.EVENT_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.EVPN_VPN_AF_CONFIG_START;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.EVPN_VPN_AF_CONFIG_STOP;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.EXPORT_ROUTE_POLICY;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.IMPORT_ROUTE_POLICY;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.INVALID_ACTION_VPN_AF_CONFIG;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.JSON_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.LISTENER_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.RESPONSE_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ROUTE_TARGET_CANNOT_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ROUTE_TARGET_DELETE_FAILED;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ROUTE_TARGET_VALUE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.SET;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.SLASH;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.UPDATE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_AF_CONFIG_CREATION_FAILED;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_AF_CONFIG_IS_NOT_EXIST;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_AF_CONFIG_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_AF_CONFIG_STORE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_AF_CONFIG_UPDATE_FAILED;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_INSTANCE_ID_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VRF_RT_TYPE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VRF_RT_VALUE;
-
-/**
- * Provides implementation of the VPN af config APIs.
- */
-@Component(immediate = true, service = VpnAfConfigService.class)
-public class VpnAfConfigManager implements VpnAfConfigService {
- private final Logger log = LoggerFactory.getLogger(getClass());
- private final Set<VpnAfConfigListener> listeners = Sets
- .newCopyOnWriteArraySet();
-
- protected EventuallyConsistentMap<VpnRouteTarget, VpnAfConfig>
- vpnAfConfigStore;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Activate
- public void activate() {
- coreService.registerApplication(APP_ID);
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API).register(VpnAfConfig.class)
- .register(VpnRouteTarget.class);
- vpnAfConfigStore = storageService
- .<VpnRouteTarget, VpnAfConfig>eventuallyConsistentMapBuilder()
- .withName(VPN_AF_CONFIG_STORE).withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp())
- .build();
- log.info(EVPN_VPN_AF_CONFIG_START);
- }
-
- @Deactivate
- public void deactivate() {
- vpnAfConfigStore.destroy();
- log.info(EVPN_VPN_AF_CONFIG_STOP);
- }
-
- @Override
- public boolean exists(VpnRouteTarget routeTarget) {
- checkNotNull(routeTarget, ROUTE_TARGET_CANNOT_NOT_NULL);
- return vpnAfConfigStore.containsKey(routeTarget);
- }
-
- @Override
- public VpnAfConfig getVpnAfConfig(VpnRouteTarget routeTarget) {
- checkNotNull(routeTarget, ROUTE_TARGET_CANNOT_NOT_NULL);
- return vpnAfConfigStore.get(routeTarget);
- }
-
- @Override
- public Collection<VpnAfConfig> getVpnAfConfigs() {
- return Collections.unmodifiableCollection(vpnAfConfigStore.values());
- }
-
- @Override
- public boolean createVpnAfConfigs(Iterable<VpnAfConfig> vpnAfConfigs) {
- checkNotNull(vpnAfConfigs, VPN_AF_CONFIG_NOT_NULL);
- for (VpnAfConfig vpnAfConfig : vpnAfConfigs) {
- log.info(ROUTE_TARGET_VALUE, vpnAfConfig
- .routeTarget().getRouteTarget());
- vpnAfConfigStore.put(vpnAfConfig.routeTarget(), vpnAfConfig);
- if (!vpnAfConfigStore.containsKey(vpnAfConfig.routeTarget())) {
- log.info(VPN_AF_CONFIG_CREATION_FAILED,
- vpnAfConfig.routeTarget().getRouteTarget());
- return false;
- }
- notifyListeners(new VpnAfConfigEvent(VpnAfConfigEvent
- .Type
- .VPN_AF_CONFIG_SET,
- vpnAfConfig));
- }
- return true;
- }
-
- @Override
- public boolean updateVpnAfConfigs(Iterable<VpnAfConfig> vpnAfConfigs) {
- checkNotNull(vpnAfConfigs, VPN_AF_CONFIG_NOT_NULL);
- for (VpnAfConfig vpnAfConfig : vpnAfConfigs) {
- if (!vpnAfConfigStore.containsKey(vpnAfConfig.routeTarget())) {
- log.info(VPN_AF_CONFIG_IS_NOT_EXIST,
- vpnAfConfig.routeTarget().getRouteTarget());
- return false;
- }
- vpnAfConfigStore.put(vpnAfConfig.routeTarget(), vpnAfConfig);
- if (!vpnAfConfig.equals(vpnAfConfigStore
- .get(vpnAfConfig.routeTarget()))) {
- log.info(VPN_AF_CONFIG_UPDATE_FAILED,
- vpnAfConfig.routeTarget().getRouteTarget());
- return false;
- }
- notifyListeners(new VpnAfConfigEvent(VpnAfConfigEvent
- .Type
- .VPN_AF_CONFIG_UPDATE,
- vpnAfConfig));
- }
- return true;
- }
-
- @Override
- public boolean removeVpnAfConfigs(Iterable<VpnRouteTarget> routeTargets) {
- checkNotNull(routeTargets, VPN_INSTANCE_ID_NOT_NULL);
- for (VpnRouteTarget routeTarget : routeTargets) {
- VpnAfConfig vpnAfConfig = vpnAfConfigStore.get(routeTarget);
- vpnAfConfigStore.remove(routeTarget);
- if (vpnAfConfigStore.containsKey(routeTarget)) {
- log.info(ROUTE_TARGET_DELETE_FAILED,
- routeTarget.getRouteTarget());
- return false;
- }
- notifyListeners(new VpnAfConfigEvent(VpnAfConfigEvent
- .Type
- .VPN_AF_CONFIG_DELETE,
- vpnAfConfig));
- }
- return true;
- }
-
- @Override
- public void processGluonConfig(String action, String key, JsonNode value) {
- Collection<VpnAfConfig> vpnAfConfigs;
- switch (action) {
- case DELETE:
- String[] list = key.split(SLASH);
- VpnRouteTarget routeTarget = VpnRouteTarget
- .routeTarget(list[list.length - 1]);
- Set<VpnRouteTarget> routeTargets
- = Sets.newHashSet(routeTarget);
- removeVpnAfConfigs(routeTargets);
- break;
- case SET:
- checkNotNull(value, RESPONSE_NOT_NULL);
- vpnAfConfigs = changeJsonToSub(value);
- createVpnAfConfigs(vpnAfConfigs);
- break;
- case UPDATE:
- checkNotNull(value, RESPONSE_NOT_NULL);
- vpnAfConfigs = changeJsonToSub(value);
- updateVpnAfConfigs(vpnAfConfigs);
- break;
- default:
- log.info(INVALID_ACTION_VPN_AF_CONFIG);
- break;
- }
- }
-
- /**
- * Returns a collection of vpn af configuration.
- *
- * @param vpnAfConfigNode the vpn af configuration json node
- * @return returns the collection of vpn af configuration
- */
- private Collection<VpnAfConfig> changeJsonToSub(JsonNode vpnAfConfigNode) {
- checkNotNull(vpnAfConfigNode, JSON_NOT_NULL);
- Map<VpnRouteTarget, VpnAfConfig> vpnAfConfigMap = new HashMap<>();
- String exportRoutePolicy
- = vpnAfConfigNode.get(EXPORT_ROUTE_POLICY).asText();
- String importRoutePolicy
- = vpnAfConfigNode.get(IMPORT_ROUTE_POLICY).asText();
- String routeTargetType = vpnAfConfigNode.get(VRF_RT_TYPE).asText();
- VpnRouteTarget routeTarget = VpnRouteTarget
- .routeTarget(vpnAfConfigNode.get(VRF_RT_VALUE).asText());
-
- VpnAfConfig vpnAfConfig = new DefaultVpnAfConfig(exportRoutePolicy,
- importRoutePolicy,
- routeTarget,
- routeTargetType);
- vpnAfConfigMap.put(routeTarget, vpnAfConfig);
-
- return Collections.unmodifiableCollection(vpnAfConfigMap.values());
- }
-
- @Override
- public void addListener(VpnAfConfigListener listener) {
- checkNotNull(listener, LISTENER_NOT_NULL);
- listeners.add(listener);
- }
-
- @Override
- public void removeListener(VpnAfConfigListener listener) {
- checkNotNull(listener, LISTENER_NOT_NULL);
- listeners.remove(listener);
- }
-
- /**
- * Notifies specify event to all listeners.
- *
- * @param event vpn af config event
- */
- private void notifyListeners(VpnAfConfigEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- listeners.forEach(listener -> listener.event(event));
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/impl/package-info.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/impl/package-info.java
deleted file mode 100644
index f2dd128..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VPN af configuration that used by l3vpn.
- */
-package org.onosproject.evpnopenflow.rsc.vpnafconfig.impl;
\ No newline at end of file
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/package-info.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/package-info.java
deleted file mode 100644
index 7c2e4f4..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnafconfig/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VPN resources that used by Evpn.
- */
-package org.onosproject.evpnopenflow.rsc.vpnafconfig;
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpninstance/VpnInstanceService.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpninstance/VpnInstanceService.java
deleted file mode 100644
index a61a811..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpninstance/VpnInstanceService.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.vpninstance;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.onosproject.evpnopenflow.rsc.VpnInstance;
-import org.onosproject.evpnopenflow.rsc.VpnInstanceId;
-import org.onosproject.evpnrouteservice.VpnRouteTarget;
-
-import java.util.Collection;
-import java.util.Set;
-
-/**
- * Service for interacting with the inventory of VPN instance.
- */
-public interface VpnInstanceService {
- /**
- * Returns if the vpnInstance is existed.
- *
- * @param vpnInstanceId vpnInstance identifier
- * @return true or false if one with the given identifier is not existed.
- */
- boolean exists(VpnInstanceId vpnInstanceId);
-
- /**
- * Returns the vpnInstance with the identifier.
- *
- * @param vpnInstanceId vpnInstance ID
- * @return VpnInstance or null if one with the given ID is not know.
- */
- VpnInstance getInstance(VpnInstanceId vpnInstanceId);
-
- /**
- * Returns the collection of the currently known vpnInstance.
- *
- * @return collection of VpnInstance.
- */
- Collection<VpnInstance> getInstances();
-
- /**
- * Creates vpnInstances by vpnInstances.
- *
- * @param vpnInstances the iterable collection of vpnInstances
- * @return true if all given identifiers created successfully.
- */
- boolean createInstances(Iterable<VpnInstance> vpnInstances);
-
- /**
- * Updates vpnInstances by vpnInstances.
- *
- * @param vpnInstances the iterable collection of vpnInstances
- * @return true if all given identifiers updated successfully.
- */
- boolean updateInstances(Iterable<VpnInstance> vpnInstances);
-
- /**
- * Deletes vpnInstanceIds by vpnInstanceIds.
- *
- * @param vpnInstanceIds the iterable collection of vpnInstance identifiers
- * @return true or false if one with the given identifier to delete is
- * successfully.
- */
- boolean removeInstances(Iterable<VpnInstanceId> vpnInstanceIds);
-
- /**
- * process gluon config for vpn instance information.
- *
- * @param action can be either update or delete
- * @param key can contain the id and also target information
- * @param value content of the vpn instance configuration
- */
- void processGluonConfig(String action, String key, JsonNode value);
-
- /**
- * process Etcd response for vpn instance information.
- *
- * @param routeTargetType route target type
- * @param exportRouteTargets export route targets
- * @param importRouteTargets import route targets
- * @param vpnRouteTarget vpn route target
- */
- void updateImpExpRouteTargets(String routeTargetType,
- Set<VpnRouteTarget> exportRouteTargets,
- Set<VpnRouteTarget> importRouteTargets,
- VpnRouteTarget vpnRouteTarget);
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpninstance/impl/VpnInstanceManager.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpninstance/impl/VpnInstanceManager.java
deleted file mode 100644
index 91eba1d..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpninstance/impl/VpnInstanceManager.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.vpninstance.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.google.common.collect.Sets;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.evpnopenflow.rsc.DefaultVpnInstance;
-import org.onosproject.evpnopenflow.rsc.VpnAfConfig;
-import org.onosproject.evpnopenflow.rsc.VpnInstance;
-import org.onosproject.evpnopenflow.rsc.VpnInstanceId;
-import org.onosproject.evpnopenflow.rsc.vpnafconfig.VpnAfConfigService;
-import org.onosproject.evpnopenflow.rsc.vpninstance.VpnInstanceService;
-import org.onosproject.evpnrouteservice.EvpnInstanceName;
-import org.onosproject.evpnrouteservice.RouteDistinguisher;
-import org.onosproject.evpnrouteservice.VpnRouteTarget;
-import org.onosproject.routeservice.RouteAdminService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.APP_ID;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.COMMA;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.DELETE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.DESCRIPTION;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.EVPN_VPN_INSTANCE_START;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.EVPN_VPN_INSTANCE_STOP;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ID;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.INSTANCE_ID;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.IPV4_FAMILY;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.JSON_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.RESPONSE_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.ROUTE_DISTINGUISHERS;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.SET;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.SLASH;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.UPDATE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_INSTANCE_CREATION_FAILED;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_INSTANCE_DELETE_FAILED;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_INSTANCE_ID_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_INSTANCE_IS_NOT_EXIST;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_INSTANCE_NAME;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_INSTANCE_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_INSTANCE_STORE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_INSTANCE_UPDATE_FAILED;
-
-
-/**
- * Provides implementation of the VpnInstance APIs.
- */
-@Component(immediate = true, service = VpnInstanceService.class)
-public class VpnInstanceManager implements VpnInstanceService {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- protected EventuallyConsistentMap<VpnInstanceId, VpnInstance> vpnInstanceStore;
- protected ApplicationId appId;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected RouteAdminService routeService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected VpnAfConfigService vpnAfConfigService;
-
- @Activate
- public void activate() {
- appId = coreService.registerApplication(APP_ID);
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API).register(VpnInstance.class)
- .register(VpnInstanceId.class);
- vpnInstanceStore = storageService
- .<VpnInstanceId, VpnInstance>eventuallyConsistentMapBuilder()
- .withName(VPN_INSTANCE_STORE).withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp())
- .build();
- log.info(EVPN_VPN_INSTANCE_START);
- }
-
- @Deactivate
- public void deactivate() {
- vpnInstanceStore.destroy();
- log.info(EVPN_VPN_INSTANCE_STOP);
- }
-
- @Override
- public boolean exists(VpnInstanceId vpnInstanceId) {
- checkNotNull(vpnInstanceId, VPN_INSTANCE_ID_NOT_NULL);
- return vpnInstanceStore.containsKey(vpnInstanceId);
- }
-
- @Override
- public VpnInstance getInstance(VpnInstanceId vpnInstanceId) {
- checkNotNull(vpnInstanceId, VPN_INSTANCE_ID_NOT_NULL);
- return vpnInstanceStore.get(vpnInstanceId);
- }
-
- @Override
- public Collection<VpnInstance> getInstances() {
- return Collections.unmodifiableCollection(vpnInstanceStore.values());
- }
-
- @Override
- public boolean createInstances(Iterable<VpnInstance> vpnInstances) {
- checkNotNull(vpnInstances, VPN_INSTANCE_NOT_NULL);
- for (VpnInstance vpnInstance : vpnInstances) {
- log.info(INSTANCE_ID, vpnInstance.id().toString());
- vpnInstanceStore.put(vpnInstance.id(), vpnInstance);
- if (!vpnInstanceStore.containsKey(vpnInstance.id())) {
- log.info(VPN_INSTANCE_CREATION_FAILED,
- vpnInstance.id().toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean updateInstances(Iterable<VpnInstance> vpnInstances) {
- checkNotNull(vpnInstances, VPN_INSTANCE_NOT_NULL);
- for (VpnInstance vpnInstance : vpnInstances) {
- if (!vpnInstanceStore.containsKey(vpnInstance.id())) {
- log.info(VPN_INSTANCE_IS_NOT_EXIST,
- vpnInstance.id().toString());
- return false;
- }
- vpnInstanceStore.put(vpnInstance.id(), vpnInstance);
- if (!vpnInstance.equals(vpnInstanceStore.get(vpnInstance.id()))) {
- log.info(VPN_INSTANCE_UPDATE_FAILED,
- vpnInstance.id().toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean removeInstances(Iterable<VpnInstanceId> vpnInstanceIds) {
- checkNotNull(vpnInstanceIds, VPN_INSTANCE_ID_NOT_NULL);
- for (VpnInstanceId vpnInstanceId : vpnInstanceIds) {
- vpnInstanceStore.remove(vpnInstanceId);
- if (vpnInstanceStore.containsKey(vpnInstanceId)) {
- log.info(VPN_INSTANCE_DELETE_FAILED, vpnInstanceId.toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public void processGluonConfig(String action, String key, JsonNode value) {
- Collection<VpnInstance> vpnInstances;
- switch (action) {
- case DELETE:
- String[] list = key.split(SLASH);
- VpnInstanceId vpnInstanceId = VpnInstanceId
- .vpnInstanceId(list[list.length - 1]);
- Set<VpnInstanceId> vpnInstanceIds
- = Sets.newHashSet(vpnInstanceId);
- removeInstances(vpnInstanceIds);
- break;
- case SET:
- checkNotNull(value, RESPONSE_NOT_NULL);
- vpnInstances = changeJsonToSub(value);
- createInstances(vpnInstances);
- break;
- case UPDATE:
- checkNotNull(value, RESPONSE_NOT_NULL);
- vpnInstances = changeJsonToSub(value);
- updateInstances(vpnInstances);
- break;
- default:
- log.info("Invalid action is received while processing VPN " +
- "instance configuration");
- }
- }
-
- @Override
- public void updateImpExpRouteTargets(String routeTargetType,
- Set<VpnRouteTarget> exportRouteTargets,
- Set<VpnRouteTarget> importRouteTargets,
- VpnRouteTarget vpnRouteTarget) {
- switch (routeTargetType) {
- case "export_extcommunity":
- exportRouteTargets.add(vpnRouteTarget);
- break;
- case "import_extcommunity":
- importRouteTargets.add(vpnRouteTarget);
- break;
- case "both":
- exportRouteTargets.add(vpnRouteTarget);
- importRouteTargets.add(vpnRouteTarget);
- break;
- default:
- log.info("Invalid route target type has received");
- break;
- }
- }
-
- /**
- * Returns a collection of vpnInstances from subnetNodes.
- *
- * @param vpnInstanceNodes the vpnInstance json node
- * @return returns the collection of vpn instances
- */
- private Collection<VpnInstance> changeJsonToSub(JsonNode vpnInstanceNodes) {
- checkNotNull(vpnInstanceNodes, JSON_NOT_NULL);
-
- Set<VpnRouteTarget> exportRouteTargets = new HashSet<>();
- Set<VpnRouteTarget> importRouteTargets = new HashSet<>();
- Set<VpnRouteTarget> configRouteTargets = new HashSet<>();
-
- Map<VpnInstanceId, VpnInstance> vpnInstanceMap = new HashMap<>();
- VpnInstanceId id = VpnInstanceId
- .vpnInstanceId(vpnInstanceNodes.get(ID).asText());
- EvpnInstanceName name = EvpnInstanceName
- .evpnName(vpnInstanceNodes.get(VPN_INSTANCE_NAME).asText());
- String description = vpnInstanceNodes.get(DESCRIPTION).asText();
- RouteDistinguisher routeDistinguisher = RouteDistinguisher
- .routeDistinguisher(vpnInstanceNodes.get(ROUTE_DISTINGUISHERS)
- .asText());
- String routeTargets = vpnInstanceNodes.get(IPV4_FAMILY).asText();
- String[] list = routeTargets.split(COMMA);
-
- for (String routeTarget : list) {
- // Converting route target string into route target object and
- // then storing into configuration route target set.
- VpnRouteTarget vpnRouteTarget
- = VpnRouteTarget.routeTarget(routeTarget);
- configRouteTargets.add(vpnRouteTarget);
- VpnAfConfig vpnAfConfig
- = vpnAfConfigService.getVpnAfConfig(vpnRouteTarget);
- if (vpnAfConfig == null) {
- log.info("Not able to find vpn af config for the give vpn " +
- "route target");
- break;
- }
- updateImpExpRouteTargets(vpnAfConfig.routeTargetType(),
- exportRouteTargets,
- importRouteTargets,
- vpnRouteTarget);
- }
-
- VpnInstance vpnInstance = new DefaultVpnInstance(id, name, description,
- routeDistinguisher,
- exportRouteTargets,
- importRouteTargets,
- configRouteTargets);
- vpnInstanceMap.put(id, vpnInstance);
- return Collections.unmodifiableCollection(vpnInstanceMap.values());
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpninstance/impl/package-info.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpninstance/impl/package-info.java
deleted file mode 100644
index 6cfc75e..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpninstance/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VPN resources that used by l3vpn.
- */
-package org.onosproject.evpnopenflow.rsc.vpninstance.impl;
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpninstance/package-info.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpninstance/package-info.java
deleted file mode 100644
index b68dbd0..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpninstance/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * EVPN VPN instance implementation.
- */
-package org.onosproject.evpnopenflow.rsc.vpninstance;
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/VpnPortEvent.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/VpnPortEvent.java
deleted file mode 100644
index acc28db..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/VpnPortEvent.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.vpnport;
-
-import org.onosproject.event.AbstractEvent;
-import org.onosproject.evpnopenflow.rsc.VpnPort;
-
-/**
- * Describes network VPN port event.
- */
-public class VpnPortEvent extends AbstractEvent<VpnPortEvent.Type, VpnPort> {
-
- /**
- * Type of VPN port events.
- */
- public enum Type {
- /**
- * Signifies that VPN port has been set.
- */
- VPN_PORT_SET,
- /**
- * Signifies that VPN port has been deleted.
- */
- VPN_PORT_DELETE,
- /**
- * Signifies that VPN port has been updated.
- */
- VPN_PORT_UPDATE
- }
-
- /**
- * Creates an event of a given type and for the specified VPN port.
- *
- * @param type VPN port type
- * @param vpnPort VPN port subject
- */
- public VpnPortEvent(Type type, VpnPort vpnPort) {
- super(type, vpnPort);
- }
-
- /**
- * Creates an event of a given type and for the specified VPN port.
- *
- * @param type VPN port type
- * @param vpnPort VPN port subject
- * @param time occurrence time
- */
- public VpnPortEvent(Type type, VpnPort vpnPort, long time) {
- super(type, vpnPort, time);
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/VpnPortListener.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/VpnPortListener.java
deleted file mode 100644
index 95eb797..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/VpnPortListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.vpnport;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Entity capable of VPN port related events.
- */
-public interface VpnPortListener extends EventListener<VpnPortEvent> {
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/VpnPortService.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/VpnPortService.java
deleted file mode 100644
index c7bce1b..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/VpnPortService.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.vpnport;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.onosproject.evpnopenflow.rsc.VpnPort;
-import org.onosproject.evpnopenflow.rsc.VpnPortId;
-
-import java.util.Collection;
-
-
-/**
- * Service for interacting with the inventory of VPN port.
- */
-public interface VpnPortService {
- /**
- * Returns if the vpnPort is existed.
- *
- * @param vpnPortId vpnPort identifier
- * @return true or false if one with the given identifier is not existed.
- */
- boolean exists(VpnPortId vpnPortId);
-
- /**
- * Returns the vpnPort with the identifier.
- *
- * @param vpnPortId vpnPort ID
- * @return VpnPort or null if one with the given ID is not know.
- */
- VpnPort getPort(VpnPortId vpnPortId);
-
- /**
- * Returns the collection of the currently known vpnPort.
- *
- * @return collection of VpnPort.
- */
- Collection<VpnPort> getPorts();
-
- /**
- * Creates vpnPorts by vpnPorts.
- *
- * @param vpnPorts the iterable collection of vpnPorts
- * @return true if all given identifiers created successfully.
- */
- boolean createPorts(Iterable<VpnPort> vpnPorts);
-
- /**
- * Updates vpnPorts by vpnPorts.
- *
- * @param vpnPorts the iterable collection of vpnPorts
- * @return true if all given identifiers updated successfully.
- */
- boolean updatePorts(Iterable<VpnPort> vpnPorts);
-
- /**
- * Deletes vpnPortIds by vpnPortIds.
- *
- * @param vpnPortIds the iterable collection of vpnPort identifiers
- * @return true or false if one with the given identifier to delete is
- * successfully.
- */
- boolean removePorts(Iterable<VpnPortId> vpnPortIds);
-
- /**
- * process gluon config for vpn port information.
- *
- * @param action can be either update or delete
- * @param key can contain the id and also target information
- * @param value content of the vpn port configuration
- */
- void processGluonConfig(String action, String key, JsonNode value);
-
- /**
- * Adds the specified listener to Vpn Port manager.
- *
- * @param listener Vpn Port listener
- */
- void addListener(VpnPortListener listener);
-
- /**
- * Removes the specified listener to Vpn Port manager.
- *
- * @param listener Vpn Port listener
- */
- void removeListener(VpnPortListener listener);
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/impl/VpnPortManager.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/impl/VpnPortManager.java
deleted file mode 100644
index b62d034..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/impl/VpnPortManager.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.evpnopenflow.rsc.vpnport.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.google.common.collect.Sets;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.evpnopenflow.rsc.BasePort;
-import org.onosproject.evpnopenflow.rsc.BasePortId;
-import org.onosproject.evpnopenflow.rsc.DefaultVpnPort;
-import org.onosproject.evpnopenflow.rsc.VpnInstanceId;
-import org.onosproject.evpnopenflow.rsc.VpnPort;
-import org.onosproject.evpnopenflow.rsc.VpnPortId;
-import org.onosproject.evpnopenflow.rsc.baseport.BasePortService;
-import org.onosproject.evpnopenflow.rsc.vpnport.VpnPortEvent;
-import org.onosproject.evpnopenflow.rsc.vpnport.VpnPortListener;
-import org.onosproject.evpnopenflow.rsc.vpnport.VpnPortService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.onosproject.vtnrsc.AllocationPool;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.DefaultSubnet;
-import org.onosproject.vtnrsc.DefaultTenantNetwork;
-import org.onosproject.vtnrsc.DefaultVirtualPort;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.HostRoute;
-import org.onosproject.vtnrsc.PhysicalNetwork;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.APP_ID;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.DELETE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.EVENT_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.EVPN_VPN_PORT_START;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.EVPN_VPN_PORT_STOP;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.INTERFACE_ID;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.JSON_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.LISTENER_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.RESPONSE_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.SET;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.SLASH;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.UPDATE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_INSTANCE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_PORT_CREATION_FAILED;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_PORT_DELETE_FAILED;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_PORT_ID;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_PORT_ID_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_PORT_IS_NOT_EXIST;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_PORT_NOT_NULL;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_PORT_STORE;
-import static org.onosproject.evpnopenflow.rsc.EvpnConstants.VPN_PORT_UPDATE_FAILED;
-
-/**
- * Provides implementation of the VpnPort service.
- */
-@Component(immediate = true, service = VpnPortService.class)
-public class VpnPortManager implements VpnPortService {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
- private final Set<VpnPortListener> listeners = Sets
- .newCopyOnWriteArraySet();
-
- protected EventuallyConsistentMap<VpnPortId, VpnPort> vpnPortStore;
- protected ApplicationId appId;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected BasePortService basePortService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected VirtualPortService virtualPortService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TenantNetworkService tenantNetworkService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected SubnetService subnetService;
-
- @Activate
-
- public void activate() {
- appId = coreService.registerApplication(APP_ID);
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API).register(VpnPort.class)
- .register(VpnPortId.class);
- vpnPortStore = storageService
- .<VpnPortId, VpnPort>eventuallyConsistentMapBuilder()
- .withName(VPN_PORT_STORE).withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp())
- .build();
- log.info(EVPN_VPN_PORT_START);
- }
-
- @Deactivate
- public void deactivate() {
- vpnPortStore.destroy();
- log.info(EVPN_VPN_PORT_STOP);
- }
-
- @Override
- public boolean exists(VpnPortId vpnPortId) {
- checkNotNull(vpnPortId, VPN_PORT_ID_NOT_NULL);
- return vpnPortStore.containsKey(vpnPortId);
- }
-
- @Override
- public VpnPort getPort(VpnPortId vpnPortId) {
- checkNotNull(vpnPortId, VPN_PORT_ID_NOT_NULL);
- return vpnPortStore.get(vpnPortId);
- }
-
- @Override
- public Collection<VpnPort> getPorts() {
- return Collections.unmodifiableCollection(vpnPortStore.values());
- }
-
- @Override
- public boolean createPorts(Iterable<VpnPort> vpnPorts) {
- checkNotNull(vpnPorts, VPN_PORT_NOT_NULL);
- for (VpnPort vpnPort : vpnPorts) {
- log.info(VPN_PORT_ID, vpnPort.id().toString());
- vpnPortStore.put(vpnPort.id(), vpnPort);
- if (!vpnPortStore.containsKey(vpnPort.id())) {
- log.info(VPN_PORT_CREATION_FAILED, vpnPort.id().toString());
- return false;
- }
- notifyListeners(new VpnPortEvent(VpnPortEvent.Type.VPN_PORT_SET,
- vpnPort));
- }
- return true;
- }
-
- @Override
- public boolean updatePorts(Iterable<VpnPort> vpnPorts) {
- checkNotNull(vpnPorts, VPN_PORT_NOT_NULL);
- for (VpnPort vpnPort : vpnPorts) {
- if (!vpnPortStore.containsKey(vpnPort.id())) {
- log.info(VPN_PORT_IS_NOT_EXIST, vpnPort.id().toString());
- return false;
- }
- vpnPortStore.put(vpnPort.id(), vpnPort);
- if (!vpnPort.equals(vpnPortStore.get(vpnPort.id()))) {
- log.info(VPN_PORT_UPDATE_FAILED, vpnPort.id().toString());
- return false;
- }
- notifyListeners(new VpnPortEvent(VpnPortEvent.Type.VPN_PORT_UPDATE,
- vpnPort));
- }
- return true;
- }
-
- @Override
- public boolean removePorts(Iterable<VpnPortId> vpnPortIds) {
- checkNotNull(vpnPortIds, VPN_PORT_NOT_NULL);
- for (VpnPortId vpnPortid : vpnPortIds) {
- VpnPort vpnPort = vpnPortStore.get(vpnPortid);
- vpnPortStore.remove(vpnPortid);
- if (vpnPortStore.containsKey(vpnPortid)) {
- log.info(VPN_PORT_DELETE_FAILED, vpnPortid.toString());
- return false;
- }
- notifyListeners(new VpnPortEvent(VpnPortEvent.Type.VPN_PORT_DELETE,
- vpnPort));
- }
- return true;
- }
-
- @Override
- public void processGluonConfig(String action, String key, JsonNode value) {
- Collection<VpnPort> vpnPorts;
- switch (action) {
- case DELETE:
- String[] list = key.split(SLASH);
- VpnPortId vpnPortId
- = VpnPortId.vpnPortId(list[list.length - 1]);
- Set<VpnPortId> vpnPortIds = Sets.newHashSet(vpnPortId);
- removePorts(vpnPortIds);
- // After removing vpn port and also remove virtual port from vtn
- VirtualPortId virtualPortId
- = VirtualPortId.portId(list[list.length - 1]);
- Set<VirtualPortId> virtualPortIds
- = Sets.newHashSet(virtualPortId);
- virtualPortService.removePorts(virtualPortIds);
- break;
- case SET:
- checkNotNull(value, RESPONSE_NOT_NULL);
- vpnPorts = changeJsonToSub(value);
- createPorts(vpnPorts);
- break;
- case UPDATE:
- checkNotNull(value, RESPONSE_NOT_NULL);
- vpnPorts = changeJsonToSub(value);
- updatePorts(vpnPorts);
- break;
- default:
- log.info("Invalid action is received while processing VPN " +
- "port configuration");
- }
- }
-
- /**
- * Creates dummy gluon network to the VTN.
- *
- * @param state the base port state
- * @param adminStateUp the base port admin status
- * @param tenantID the base port tenant ID
- */
- private void createDummyGluonNetwork(boolean adminStateUp, String state,
- TenantId tenantID) {
- String id = "11111111-1111-1111-1111-111111111111";
- String name = "GluonNetwork";
- String segmentationID = "50";
- String physicalNetwork = "None";
-
- TenantNetwork network = new DefaultTenantNetwork(TenantNetworkId.networkId(id), name,
- adminStateUp,
- TenantNetwork.State.valueOf(state),
- false, tenantID,
- false,
- TenantNetwork.Type.LOCAL,
- PhysicalNetwork.physicalNetwork(physicalNetwork),
- SegmentationId.segmentationId(segmentationID));
-
- Set<TenantNetwork> networksSet = Sets.newHashSet(network);
- tenantNetworkService.createNetworks(networksSet);
- }
-
-
- /**
- * Creates dummy gluon subnet to the VTN.
- *
- * @param tenantId the base port tenant ID
- */
- public void createDummySubnet(TenantId tenantId) {
- String id = "22222222-2222-2222-2222-222222222222";
- String subnetName = "GluonSubnet";
- String cidr = "0.0.0.0/0";
- String gatewayIp = "0.0.0.0";
- Set<HostRoute> hostRoutes = Sets.newHashSet();
- TenantNetworkId tenantNetworkId = null;
- Set<AllocationPool> allocationPools = Sets.newHashSet();
- Iterable<TenantNetwork> networks
- = tenantNetworkService.getNetworks();
-
- for (TenantNetwork tenantNetwork : networks) {
- if (tenantNetwork.name().equals("GluonNetwork")) {
- tenantNetworkId = tenantNetwork.id();
- break;
- }
- }
- Subnet subnet = new DefaultSubnet(SubnetId.subnetId(id), subnetName,
- tenantNetworkId,
- tenantId, IpAddress.Version.INET,
- IpPrefix.valueOf(cidr),
- IpAddress.valueOf(gatewayIp),
- false, false, hostRoutes,
- null,
- null,
- allocationPools);
-
- Set<Subnet> subnetsSet = Sets.newHashSet(subnet);
- subnetService.createSubnets(subnetsSet);
- }
-
- /**
- * Returns a collection of vpnPort from subnetNodes.
- *
- * @param vpnPortNodes the vpnPort json node
- * @return list of vpnports
- */
- private Collection<VpnPort> changeJsonToSub(JsonNode vpnPortNodes) {
- checkNotNull(vpnPortNodes, JSON_NOT_NULL);
- Map<VpnPortId, VpnPort> vpnPortMap = new HashMap<>();
- String interfaceId = vpnPortNodes.get(INTERFACE_ID).asText();
- VpnPortId vpnPortId = VpnPortId.vpnPortId(interfaceId);
- VpnInstanceId vpnInstanceId = VpnInstanceId
- .vpnInstanceId(vpnPortNodes.get(VPN_INSTANCE).asText());
- VpnPort vpnPort = new DefaultVpnPort(vpnPortId, vpnInstanceId);
- vpnPortMap.put(vpnPortId, vpnPort);
- // update ip address and tenant network information in vtn
- TenantNetworkId tenantNetworkId = null;
- Map<VirtualPortId, VirtualPort> vPortMap = new HashMap<>();
- BasePortId basePortId = BasePortId.portId(interfaceId);
- VirtualPortId virtualPortId = VirtualPortId.portId(interfaceId);
- BasePort bPort = basePortService.getPort(basePortId);
- if (bPort != null) {
- FixedIp fixedIp = FixedIp.fixedIp(SubnetId.subnetId(basePortId.toString()),
- IpAddress.valueOf(vpnPortNodes
- .get("ipaddress").asText()));
- Set<FixedIp> fixedIps = new HashSet<>();
- fixedIps.add(fixedIp);
- Map<String, String> strMap = new HashMap<>();
- boolean adminStateUp = bPort.adminStateUp();
- strMap.put("name", bPort.name());
- strMap.put("deviceOwner", bPort.deviceOwner());
- strMap.put("bindingVnicType", bPort.bindingVnicType());
- strMap.put("bindingVifType", bPort.bindingVifType());
- strMap.put("bindingVifDetails", bPort.bindingVifDetails());
- String state = bPort.state();
- MacAddress macAddress = bPort.macAddress();
- TenantId tenantId = bPort.tenantId();
- DeviceId deviceId = bPort.deviceId();
- BindingHostId bindingHostId = bPort.bindingHostId();
- // Creates Dummy Gluon Network and Subnet
- createDummyGluonNetwork(adminStateUp, state, tenantId);
- createDummySubnet(tenantId);
-
- Iterable<TenantNetwork> networks
- = tenantNetworkService.getNetworks();
-
- for (TenantNetwork tenantNetwork : networks) {
- if (tenantNetwork.name().equals("GluonNetwork")) {
- tenantNetworkId = tenantNetwork.id();
- break;
- }
- }
- if (tenantNetworkId != null) {
-
- DefaultVirtualPort vPort = new DefaultVirtualPort(virtualPortId,
- tenantNetworkId,
- adminStateUp,
- strMap, isState(state),
- macAddress, tenantId,
- deviceId, fixedIps,
- bindingHostId,
- null,
- null);
- vPortMap.put(virtualPortId, vPort);
- Collection<VirtualPort> virtualPorts
- = Collections.unmodifiableCollection(vPortMap.values());
- virtualPortService.createPorts(virtualPorts);
- }
- }
-
- return Collections.unmodifiableCollection(vpnPortMap.values());
- }
-
- /**
- * Returns BasePort State.
- *
- * @param state the base port state
- * @return the basePort state
- */
- private VirtualPort.State isState(String state) {
- if (state.equals("ACTIVE")) {
- return VirtualPort.State.ACTIVE;
- } else {
- return VirtualPort.State.DOWN;
- }
-
- }
-
- @Override
- public void addListener(VpnPortListener listener) {
- checkNotNull(listener, LISTENER_NOT_NULL);
- listeners.add(listener);
- }
-
- @Override
- public void removeListener(VpnPortListener listener) {
- checkNotNull(listener, LISTENER_NOT_NULL);
- listeners.remove(listener);
- }
-
- /**
- * Notifies specify event to all listeners.
- *
- * @param event Vpn Port event
- */
- private void notifyListeners(VpnPortEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- listeners.forEach(listener -> {
- listener.event(event);
- });
- }
-}
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/impl/package-info.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/impl/package-info.java
deleted file mode 100644
index 5dc98e9..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VPN resources that used by l3vpn.
- */
-package org.onosproject.evpnopenflow.rsc.vpnport.impl;
diff --git a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/package-info.java b/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/package-info.java
deleted file mode 100644
index aadae58..0000000
--- a/apps/evpnopenflow/src/main/java/org/onosproject/evpnopenflow/rsc/vpnport/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VPN resources that used by evpn.
- */
-package org.onosproject.evpnopenflow.rsc.vpnport;
diff --git a/apps/l3vpn/BUILD b/apps/l3vpn/BUILD
deleted file mode 100644
index 8e670a4..0000000
--- a/apps/l3vpn/BUILD
+++ /dev/null
@@ -1,43 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + KRYO + ONOS_YANG + [
- "//models/l3vpn:onos-models-l3vpn",
- "//apps/config:onos-apps-config",
- "//core/store/serializers:onos-core-serializers",
- "//apps/yang:onos-apps-yang",
- "//apps/pce/app:onos-apps-pce-app",
- "//apps/tunnel/api:onos-apps-tunnel-api",
- "//models/common:onos-models-common",
-]
-
-TEST_DEPS = TEST_ADAPTERS + [
- "//utils/osgi:onlab-osgi-tests",
-]
-
-APPS = [
- "org.onosproject.yang",
- "org.onosproject.yang-gui",
- "org.onosproject.config",
- "org.onosproject.restconf",
- "org.onosproject.protocols.restconfserver",
- "org.onosproject.tunnel",
- "org.onosproject.netconf",
- "org.onosproject.netconfsb",
- "org.onosproject.models.common",
- "org.onosproject.models.l3vpn",
- "org.onosproject.bgpcep",
- "org.onosproject.pcep",
- "org.onosproject.bgp",
-]
-
-osgi_jar_with_tests(
- test_deps = TEST_DEPS,
- deps = COMPILE_DEPS,
-)
-
-onos_app(
- app_name = "org.onosproject.l3vpn",
- category = "Traffic Engineering",
- description = "L3VPN YANG Application",
- required_apps = APPS,
- title = "YANG L3VPN",
- url = "http://onosproject.org",
-)
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/AccessInfo.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/AccessInfo.java
deleted file mode 100644
index 61f5170..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/AccessInfo.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-import com.google.common.base.Objects;
-
-/**
- * Representation of site network access information.
- */
-public class AccessInfo {
-
- /**
- * Site id from sites list.
- */
- private String siteId;
-
- /**
- * Site network access id from site network access list.
- */
- private String accessId;
-
- /**
- * Constructs access info with site id and access id.
- *
- * @param s site id
- * @param a access id
- */
- public AccessInfo(String s, String a) {
- siteId = s;
- accessId = a;
- }
-
- /**
- * Returns the site id.
- *
- * @return site id
- */
- public String siteId() {
- return siteId;
- }
-
- /**
- * Returns the access id.
- *
- * @return access id
- */
- public String accessId() {
- return accessId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(siteId, accessId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof AccessInfo) {
- AccessInfo that = (AccessInfo) object;
- return Objects.equal(siteId, that.siteId) &&
- Objects.equal(accessId, that.accessId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return "Access id : " + accessId + "\nSite id : " + siteId;
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/BgpDriverInfo.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/BgpDriverInfo.java
deleted file mode 100644
index 54ee93a..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/BgpDriverInfo.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-/**
- * Representation of BGP configuration required for driver to process.
- */
-public class BgpDriverInfo {
-
- /**
- * Model id level of the BGP information that needed to be added in store.
- */
- private ModelIdLevel modIdLevel;
-
- /**
- * Device id required for the creation of driver model object data.
- */
- private String devId;
-
- /**
- * Constructs BGP driver info.
- *
- * @param m model id level for BGP
- * @param d device id
- */
- public BgpDriverInfo(ModelIdLevel m, String d) {
- modIdLevel = m;
- devId = d;
- }
-
- /**
- * Returns the model id level of the BGP information to be added.
- *
- * @return model id level
- */
- public ModelIdLevel modIdLevel() {
- return modIdLevel;
- }
-
- /**
- * Returns the device id.
- *
- * @return device id
- */
- public String devId() {
- return devId;
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/BgpInfo.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/BgpInfo.java
deleted file mode 100644
index a0da969..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/BgpInfo.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Representation of BGP information which contains the protocol info and the
- * VPN name.
- */
-public class BgpInfo {
-
- /**
- * Map of route protocol and the protocol info for the BGP info.
- */
- private Map<RouteProtocol, ProtocolInfo> protocolInfo;
-
- /**
- * VPN name, to which the BGP info belongs.
- */
- private String vpnName;
-
- /**
- * Constructs BGP info.
- */
- public BgpInfo() {
- }
-
- /**
- * Returns the map of protocol info associated with the BGP info.
- *
- * @return protocol info map.
- */
- public Map<RouteProtocol, ProtocolInfo> protocolInfo() {
- return protocolInfo;
- }
-
- /**
- * Sets the map of protocol info with route protocol as key value.
- *
- * @param protocolInfo protocol info map
- */
- public void protocolInfo(Map<RouteProtocol, ProtocolInfo> protocolInfo) {
- this.protocolInfo = protocolInfo;
- }
-
- /**
- * Adds a protocol info with route protocol as key to the map.
- *
- * @param route route protocol
- * @param info protocol info
- */
- public void addProtocolInfo(RouteProtocol route, ProtocolInfo info) {
- if (protocolInfo == null) {
- protocolInfo = new HashMap<>();
- }
- protocolInfo.put(route, info);
- }
-
- /**
- * Returns the VPN name of the BGP info.
- *
- * @return VPN name
- */
- public String vpnName() {
- return vpnName;
- }
-
- /**
- * Sets the VPN name.
- *
- * @param vpnName VPN name
- */
- public void vpnName(String vpnName) {
- this.vpnName = vpnName;
- }
-
- @Override
- public String toString() {
- return "VPN name : " + vpnName;
- }
-}
-
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/DeviceInfo.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/DeviceInfo.java
deleted file mode 100644
index 9a2c49a..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/DeviceInfo.java
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.yang.model.ModelObjectData;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Representation of standard device model, with interface, instance and its
- * respective device id.
- */
-public class DeviceInfo {
-
- /**
- * Device id of the device.
- */
- private final DeviceId deviceId;
-
- /**
- * Type of the VPN.
- */
- private final VpnType type;
-
- /**
- * BGP information of the device.
- */
- private BgpInfo bgpInfo;
-
- /**
- * List of interface names of the device.
- */
- private List<String> ifNames;
-
- /**
- * List of network access of the device.
- */
- private List<AccessInfo> accesses;
-
- /**
- * List of tunnel names belonging to the device.
- */
- private List<String> tnlNames;
-
- /**
- * Status of tunnel policy being created for this device in this VPN.
- */
- private boolean isTnlPolCreated;
-
- /**
- * Constructs device info with a device id and VPN type.
- *
- * @param d device id
- * @param t VPN type
- */
- public DeviceInfo(DeviceId d, VpnType t) {
- deviceId = d;
- type = t;
- }
-
- /**
- * Returns the device id.
- *
- * @return device id
- */
- public DeviceId deviceId() {
- return deviceId;
- }
-
- /**
- * Returns the type of the VPN instance.
- *
- * @return VPN type
- */
- public VpnType type() {
- return type;
- }
-
- /**
- * Adds a interface name to the list.
- *
- * @param ifName interface name
- */
- public void addIfName(String ifName) {
- if (ifNames == null) {
- ifNames = new LinkedList<>();
- }
- ifNames.add(ifName);
- }
-
- /**
- * Returns the list of interface name.
- *
- * @return interface names
- */
- public List<String> ifNames() {
- return ifNames;
- }
-
- /**
- * Sets the list of interface name.
- *
- * @param ifNames interface names
- */
- public void ifNames(List<String> ifNames) {
- this.ifNames = ifNames;
- }
-
- /***
- * Returns the list of tunnel names.
- *
- * @return tunnel names
- */
- public List<String> tnlNames() {
- return tnlNames;
- }
-
- /**
- * Sets the list of tunnel names.
- *
- * @param tnlNames tunnel names
- */
- public void tnlNames(List<String> tnlNames) {
- this.tnlNames = tnlNames;
- }
-
- /**
- * Adds a tunnel name to the list.
- *
- * @param tnlName tunnel name
- */
- public void addTnlName(String tnlName) {
- if (tnlNames == null) {
- tnlNames = new LinkedList<>();
- }
- tnlNames.add(tnlName);
- }
-
- /**
- * Returns true if tunnel policy is created for this device in this VPN;
- * false otherwise.
- *
- * @return true if tunnel policy is created; false otherwise
- */
- public boolean isTnlPolCreated() {
- return isTnlPolCreated;
- }
-
- /**
- * Sets true if tunnel policy is created for this device in this VPN;
- * false otherwise.
- *
- * @param tnlPolCreated status of tunnel policy creation
- */
- public void setTnlPolCreated(boolean tnlPolCreated) {
- isTnlPolCreated = tnlPolCreated;
- }
-
- /**
- * Returns the BGP information.
- *
- * @return BGP info
- */
- public BgpInfo bgpInfo() {
- return bgpInfo;
- }
-
- /**
- * Sets the BGP information.
- *
- * @param bgpInfo BGP info
- */
- public void bgpInfo(BgpInfo bgpInfo) {
- this.bgpInfo = bgpInfo;
- }
-
- /**
- * Returns the list of network accesses.
- *
- * @return network accesses
- */
- public List<AccessInfo> accesses() {
- return accesses;
- }
-
- /**
- * Sets the list of network accesses.
- *
- * @param accesses network accesses
- */
- public void accesses(List<AccessInfo> accesses) {
- this.accesses = accesses;
- }
-
- /**
- * Adds a access info to the network accesses list.
- *
- * @param accessInfo access info
- */
- public void addAccessInfo(AccessInfo accessInfo) {
- if (accesses == null) {
- accesses = new LinkedList<>();
- }
- accesses.add(accessInfo);
- }
-
- /**
- * Processes the creation of VPN instance to the driver with the model
- * object data of standard device model. It returns the VPN instance of
- * driver constructed model object data.
- *
- * @param driverSvc driver service
- * @param modelData std device model object data
- * @return driver instance model object data
- */
- public ModelObjectData processCreateInstance(DriverService driverSvc,
- ModelObjectData modelData) {
- L3VpnConfig config = getL3VpnConfig(driverSvc);
- return config.createInstance(modelData);
- }
-
- /**
- * Processes the creation of interface to the driver with the model
- * object data of standard device model. It returns the interface of driver
- * constructed model object data.
- *
- * @param driverSvc driver service
- * @param modData std device model object data
- * @return driver interface model object data
- */
- public ModelObjectData processCreateInterface(DriverService driverSvc,
- ModelObjectData modData) {
- L3VpnConfig config = getL3VpnConfig(driverSvc);
- return config.bindInterface(modData);
- }
-
- /**
- * Processes the creation of BGP info to the driver with the BGP info and
- * the BGP driver configuration. It returns the BGP info of driver
- * constructed model object data.
- *
- * @param driverSvc driver service
- * @param bgpInfo BGP info
- * @param driverInfo driver config details
- * @return driver BGP model object data
- */
- public ModelObjectData processCreateBgpInfo(DriverService driverSvc,
- BgpInfo bgpInfo,
- BgpDriverInfo driverInfo) {
- L3VpnConfig config = getL3VpnConfig(driverSvc);
- return config.createBgpInfo(bgpInfo, driverInfo);
- }
-
- /**
- * Processes the creation of tunnel tree from the devices and device
- * level. It returns the tunnel info with devices and device of driver
- * constructed model object data.
- *
- * @param driverSvc driver service
- * @param tnlInfo tunnel info
- * @return driver model object data of tunnel info with devices and device
- */
- public ModelObjectData processCreateTnlDev(DriverService driverSvc,
- TunnelInfo tnlInfo) {
- L3VpnConfig config = getL3VpnConfig(driverSvc);
- return config.createTnlDev(tnlInfo);
- }
-
- /**
- * Processes the creation of tunnel policy in the tree from the tunnel
- * manager or tunnel policy level. It returns the tunnel info with
- * tunnel policy level of driver constructed model object data.
- *
- * @param driverSvc driver service
- * @param tnlInfo tunnel info
- * @return driver model object data of tunnel info with tunnel policy
- */
- public ModelObjectData processCreateTnlPol(DriverService driverSvc,
- TunnelInfo tnlInfo) {
- L3VpnConfig config = getL3VpnConfig(driverSvc);
- return config.createTnlPol(tnlInfo);
- }
-
- /**
- * Processes the creation of tunnel in the tree from the tunnel next hops
- * or only tunnel next hop. It returns the tunnel info with tunnel level
- * of driver constructed model object data
- *
- * @param driverSvc driver service
- * @param tnlInfo tunnel info
- * @return driver model object data of tunnel info with tunnel
- */
- public ModelObjectData processCreateTnl(DriverService driverSvc,
- TunnelInfo tnlInfo) {
- L3VpnConfig config = getL3VpnConfig(driverSvc);
- return config.createTnl(tnlInfo);
- }
-
- /**
- * Processes the binding of tunnel policy to the VPN instance. It returns
- * the VPN instance with tunnel policy of driver constructed model object
- * data.
- *
- * @param driverSvc driver service
- * @param tnlInfo tunnel info
- * @return driver model object data of VPN instance with tunnel
- */
- public ModelObjectData processBindTnl(DriverService driverSvc,
- TunnelInfo tnlInfo) {
- L3VpnConfig config = getL3VpnConfig(driverSvc);
- return config.bindTnl(tnlInfo);
- }
-
- /**
- * Processes the deletion of VPN instance to the driver with the model
- * object data of standard device model. It returns the VPN instance of
- * driver constructed model object data.
- *
- * @param driverSvc driver service
- * @param modData model object data
- * @return driver instance model object data
- */
- public ModelObjectData processDeleteInstance(DriverService driverSvc,
- ModelObjectData modData) {
- L3VpnConfig config = getL3VpnConfig(driverSvc);
- return config.deleteInstance(modData);
- }
-
- /**
- * Processes the deletion of interface to the driver with the model
- * object data of standard device model. It returns the interface of driver
- * constructed model object data.
- *
- * @param driverSvc driver service
- * @param objectData model object data
- * @return driver interface model object data
- */
- public ModelObjectData processDeleteInterface(DriverService driverSvc,
- ModelObjectData objectData) {
- // TODO: Need to call the behaviour.
- return null;
- }
-
- /**
- * Processes the deletion of BGP info to the driver with the BGP info and
- * the BGP driver configuration. It returns the BGP info of driver
- * constructed model object data.
- *
- * @param driverSvc driver service
- * @param bgpInfo BGP info
- * @param driverInfo driver config details
- * @return driver BGP model object data
- */
- public ModelObjectData processDeleteBgpInfo(DriverService driverSvc,
- BgpInfo bgpInfo,
- BgpDriverInfo driverInfo) {
- L3VpnConfig config = getL3VpnConfig(driverSvc);
- return config.deleteBgpInfo(bgpInfo, driverInfo);
- }
-
- /**
- * Processes the deletion of tunnel info according to the levels it has
- * to be deleted. It returns the tunnel info of driver constructed model
- * object data.
- *
- * @param driverSvc driver service
- * @param tnlInfo tunnel info
- * @return driver tunnel info model object data
- */
- public ModelObjectData processDeleteTnl(DriverService driverSvc,
- TunnelInfo tnlInfo) {
- L3VpnConfig config = getL3VpnConfig(driverSvc);
- return config.deleteTnl(tnlInfo);
- }
-
- /**
- * Returns the L3VPN config instance from the behaviour.
- *
- * @param driverSvc driver service
- * @return L3VPN config
- */
- private L3VpnConfig getL3VpnConfig(DriverService driverSvc) {
- DriverHandler handler = driverSvc.createHandler(deviceId);
- return handler.behaviour(L3VpnConfig.class);
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/FullMeshVpnConfig.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/FullMeshVpnConfig.java
deleted file mode 100644
index ebfe324..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/FullMeshVpnConfig.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-/**
- * Representation of the full mesh VPN configuration containing RT.
- */
-public class FullMeshVpnConfig extends VpnConfig {
-
- /**
- * Route target value.
- */
- private String rt;
-
- /** Constructs full mesh VPN config.
- *
- * @param r RT value
- */
- public FullMeshVpnConfig(String r) {
- rt = r;
- }
-
- /**
- * Returns the RT value.
- *
- * @return RT value
- */
- public String rt() {
- return rt;
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/HubSpokeVpnConfig.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/HubSpokeVpnConfig.java
deleted file mode 100644
index ae92e68..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/HubSpokeVpnConfig.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-/**
- * Representation of the hub and spoke VPN configuration containing import and
- * export RTs.
- */
-public class HubSpokeVpnConfig extends VpnConfig {
-
- /**
- * Hub import RT value.
- */
- private String hubImpRt;
-
- /**
- * Hub export RT value.
- */
- private String hubExpRt;
-
- /**
- * Spoke import RT value.
- */
- private String spokeImpRt;
-
- /**
- * Spoke export RT value.
- */
- private String spokeExpRt;
-
- /**
- * Creates hub and spoke VPN config.
- */
- public HubSpokeVpnConfig() {
- }
-
- /**
- * Returns hub import RT value.
- *
- * @return RT value
- */
- public String hubImpRt() {
- return hubImpRt;
- }
-
- /**
- * Sets hub import RT value.
- *
- * @param hubImpRt RT value
- */
- public void hubImpRt(String hubImpRt) {
- this.hubImpRt = hubImpRt;
- }
-
- /**
- * Returns hub export RT value.
- *
- * @return RT value
- */
- public String hubExpRt() {
- return hubExpRt;
- }
-
- /**
- * Sets hub export RT value.
- *
- * @param hubExpRt RT value
- */
- public void hubExpRt(String hubExpRt) {
- this.hubExpRt = hubExpRt;
- }
-
- /**
- * Returns spoke import RT value.
- *
- * @return RT value
- */
- public String spokeImpRt() {
- return spokeImpRt;
- }
-
- /**
- * Sets spoke import RT value.
- *
- * @param spokeImpRt RT value
- */
- public void spokeImpRt(String spokeImpRt) {
- this.spokeImpRt = spokeImpRt;
- }
-
- /**
- * Returns spoke export RT value.
- *
- * @return RT value
- */
- public String spokeExpRt() {
- return spokeExpRt;
- }
-
- /**
- * Sets spoke export RT value.
- *
- * @param spokeExpRt RT value
- */
- public void spokeExpRt(String spokeExpRt) {
- this.spokeExpRt = spokeExpRt;
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/InterfaceInfo.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/InterfaceInfo.java
deleted file mode 100644
index 25fa56c..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/InterfaceInfo.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-/**
- * Representation of interface information, which has the interface name and
- * its binding VPN name and the device info to which it belongs to.
- */
-public class InterfaceInfo {
-
- /**
- * Device info value.
- */
- private DeviceInfo devInfo;
-
- /**
- * Interface name.
- */
- private String intName;
-
- /**
- * VPN instance name.
- */
- private String vpnName;
-
- /**
- * Constructs interface info.
- *
- * @param d device info
- * @param i interface name
- * @param v VPN name
- */
- public InterfaceInfo(DeviceInfo d, String i, String v) {
- devInfo = d;
- intName = i;
- vpnName = v;
- }
-
- /**
- * Returns device info of the interface.
- *
- * @return device info
- */
- public DeviceInfo devInfo() {
- return devInfo;
- }
-
- /**
- * Returns the interface name.
- *
- * @return interface name
- */
- public String intName() {
- return intName;
- }
-
- /**
- * Returns the VPN name.
- *
- * @return VPN name
- */
- public String vpnName() {
- return vpnName;
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/L3VpnConfig.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/L3VpnConfig.java
deleted file mode 100644
index bfc8164..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/L3VpnConfig.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-import org.onosproject.net.driver.HandlerBehaviour;
-import org.onosproject.yang.model.ModelObjectData;
-
-/**
- * Behaviour for handling various drivers for l3vpn configurations.
- */
-public interface L3VpnConfig extends HandlerBehaviour {
-
- /**
- * Create virtual routing forwarding instance on requested device with
- * given standard device model object data.
- *
- * @param objectData standard device model object data
- * @return device model object data
- */
- ModelObjectData createInstance(ModelObjectData objectData);
-
- /**
- * Binds requested virtual routing forwarding instance to interface on the
- * requested device with given standard device model object data.
- *
- * @param objectData standard device model object data
- * @return device model object data
- */
- ModelObjectData bindInterface(ModelObjectData objectData);
-
- /**
- * Deletes virtual routing forwarding instance on requested device with
- * given standard device model object data.
- *
- * @param objectData standard device model object data
- * @return device model object data
- */
- ModelObjectData deleteInstance(ModelObjectData objectData);
-
- /**
- * Unbinds requested virtual routing forwarding instance to interface on the
- * requested device with given standard device model object data.
- *
- * @param objectData standard device model object data
- * @return device model object data
- */
- ModelObjectData unbindInterface(ModelObjectData objectData);
-
- /**
- * Deletes tunnel on requested device with the given tunnel info.
- *
- * @param tnlInfo tunnel info
- * @return device model object data
- */
- ModelObjectData deleteTnl(TunnelInfo tnlInfo);
-
- /**
- * Creates BGP routing protocol info on requested device with given
- * BGP info object.
- *
- * @param bgpInfo BGP info object
- * @param bgpConfig BGP driver config
- * @return device model object data
- */
- ModelObjectData createBgpInfo(BgpInfo bgpInfo, BgpDriverInfo bgpConfig);
-
- /**
- * Deletes BGP routing protocol info on requested device with given
- * BGP info object.
- *
- * @param bgpInfo BGP info object
- * @param bgpConfig BGP driver config
- * @return device model object data
- */
- ModelObjectData deleteBgpInfo(BgpInfo bgpInfo, BgpDriverInfo bgpConfig);
-
- /**
- * Creates device and devices level on requested device for tunnel creation.
- *
- * @param tnlInfo tunnel info
- * @return device model object data
- */
- ModelObjectData createTnlDev(TunnelInfo tnlInfo);
-
- /**
- * Creates tunnel policy on requested device with given tunnel info.
- *
- * @param tnlInfo tunnel info
- * @return device model object data
- */
- ModelObjectData createTnlPol(TunnelInfo tnlInfo);
-
- /**
- * Creates tunnel on requested device with given tunnel info.
- *
- * @param tnlInfo tunnel info
- * @return device model object data
- */
- ModelObjectData createTnl(TunnelInfo tnlInfo);
-
- /**
- * Binds requested tunnel policy name to the VPN to the requested device
- * with given tunnel info.
- *
- * @param tnlInfo tunnel info
- * @return device model object data
- */
- ModelObjectData bindTnl(TunnelInfo tnlInfo);
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/ModelIdLevel.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/ModelIdLevel.java
deleted file mode 100644
index 91bf248..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/ModelIdLevel.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-/**
- * Represents the model id level to add it in the store.
- * //TODO: Further levels has to be added.
- */
-public enum ModelIdLevel {
-
- /**
- * Requested model id level is not present, representing top node.
- */
- ROOT,
-
- /**
- * Requested model id level is devices container.
- */
- DEVICES,
-
- /**
- * Requested model id level is device list.
- */
- DEVICE,
-
- /**
- * Requested model id level is VPN list.
- */
- VPN,
-
- /**
- * Requested model id level is tunnel manager.
- */
- TNL_M,
-
- /**
- * Requested model id level is tunnel policy.
- */
- TNL_POL,
-
- /**
- * Requested model id level is tunnel hop.
- */
- TP_HOP
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/NetL3VpnException.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/NetL3VpnException.java
deleted file mode 100644
index 653fa11..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/NetL3VpnException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-/**
- * Representation of exception that needs to be handled by net l3 VPN.
- */
-public class NetL3VpnException extends RuntimeException {
-
- /**
- * Creates net l3 VPN exception with an exception message.
- *
- * @param excMsg message
- */
- public NetL3VpnException(String excMsg) {
- super(excMsg);
- }
-
- /**
- * Creates net l3 VPN exception with a cause for it.
- *
- * @param cause cause
- */
- public NetL3VpnException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/NetL3VpnStore.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/NetL3VpnStore.java
deleted file mode 100644
index db926a2..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/NetL3VpnStore.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-import org.onosproject.net.DeviceId;
-
-import java.util.Map;
-
-/**
- * Abstraction of an entity providing pool of available VPN instances
- * its associated devices and interface information.
- */
-public interface NetL3VpnStore {
-
- /**
- * Returns the freed ids that can be re-used for RD and RT generation.
- *
- * @return collection of freed ids
- */
- Iterable<Long> getFreedIdList();
-
- /**
- * Returns the VPN instance map available in the store.
- *
- * @return VPN instance map
- */
- Map<String, VpnInstance> getVpnInstances();
-
- /**
- * Returns the BGP info map available in the store.
- *
- * @return BGP info map
- */
- Map<BgpInfo, DeviceId> getBgpInfo();
-
- /**
- * Returns the interface information map available in the store.
- *
- * @return interface info map
- */
- Map<AccessInfo, InterfaceInfo> getInterfaceInfo();
-
- /**
- * Returns the tunnel information map available in the store, for a device.
- *
- * @return tunnel info map
- */
- Map<DeviceId, Integer> getTunnelInfo();
-
- /**
- * Adds freed id to the freed list in the store.
- *
- * @param id id
- */
- void addIdToFreeList(Long id);
-
- /**
- * Adds the VPN name and the VPN instance, if the map does'nt have the
- * value with it.
- *
- * @param name VPN name
- * @param instance VPN instance
- */
- void addVpnInsIfAbsent(String name, VpnInstance instance);
-
- /**
- * Adds the VPN name and the VPN instance to the map.
- *
- * @param name VPN name
- * @param instance VPN instance
- */
- void addVpnIns(String name, VpnInstance instance);
-
- /**
- * Adds the access info and the interface info to the map in store.
- *
- * @param accessInfo access info
- * @param intInfo interface info
- */
- void addInterfaceInfo(AccessInfo accessInfo, InterfaceInfo intInfo);
-
- /**
- * Adds the BGP info and the device id to the map in store.
- *
- * @param bgpInfo BGP info
- * @param devId device id
- */
- void addBgpInfo(BgpInfo bgpInfo, DeviceId devId);
-
- /**
- * Adds the device id and the number of tunnels created for that device.
- *
- * @param devId device id
- * @param count number of tunnels
- */
- void addTunnelInfo(DeviceId devId, Integer count);
-
- /**
- * Removes the interface info with the key access info from the store.
- *
- * @param accessInfo access info
- * @return true if removed; false otherwise
- */
- boolean removeInterfaceInfo(AccessInfo accessInfo);
-
- /**
- * Removes the VPN instance from the store with the key VPN name from the
- * store.
- *
- * @param vpnName VPN name
- * @return true if removed; false otherwise
- */
- boolean removeVpnInstance(String vpnName);
-
- /**
- * Removes the mentioned id from the freed list.
- *
- * @param id id
- * @return true if removed; false otherwise
- */
- boolean removeIdFromFreeList(Long id);
-
- /**
- * Removes the device id from the store with the key BGP info from the
- * store.
- *
- * @param bgpInfo BGP info
- * @return true if removed; false otherwise
- */
- boolean removeBgpInfo(BgpInfo bgpInfo);
-
- /**
- * Removes the device id from the store with the value count of number of
- * tunnels.
- *
- * @param id device id
- * @return true if removed; false otherwise
- */
- boolean removeTunnelInfo(DeviceId id);
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/ProtocolInfo.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/ProtocolInfo.java
deleted file mode 100644
index 0efad33..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/ProtocolInfo.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.l3vpn.netl3vpn;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Representation of protocol info of the BGP info. It contains the route
- * protocol and the interfaces which are associated with the information.
- */
-public class ProtocolInfo {
-
- /**
- * Route protocol.
- */
- private RouteProtocol routeProtocol;
-
- /**
- * Interface details which uses this protocol with respect to IPV4 address.
- */
- private List<AccessInfo> v4Accesses;
-
- /**
- * Interface details which uses this protocol with respect to IPV6 address.
- */
- private List<AccessInfo> v6Accesses;
-
- /**
- * Status of IPV4 address family available.
- */
- private boolean ipv4Af;
-
- /**
- * Status of IPV6 address family available.
- */
- private boolean ipv6Af;
-
- /**
- * Process id of the protocol info.
- */
- private String processId;
-
- /**
- * Constructs protocol info.
- */
- public ProtocolInfo() {
- }
-
- /**
- * Returns the route protocol.
- *
- * @return route protocol
- */
- public RouteProtocol routeProtocol() {
- return routeProtocol;
- }
-
- /**
- * Sets the route protocol.
- *
- * @param routeProtocol route protocol
- */
- public void routeProtocol(RouteProtocol routeProtocol) {
- this.routeProtocol = routeProtocol;
- }
-
- /**
- * Returns the process id.
- *
- * @return process id
- */
- public String processId() {
- return processId;
- }
-
- /**
- * Sets the process id.
- *
- * @param processId process id.
- */
- public void processId(String processId) {
- this.processId = processId;
- }
-
- /**
- * Returns true if the IPV4 address family uses the protocol info; false
- * otherwise.
- *
- * @return true if IPV4 address family uses; false otherwise
- */
- public boolean isIpv4Af() {
- return ipv4Af;
- }
-
- /**
- * Sets true if the IPV4 address family uses the protocol info; false
- * otherwise.
- *
- * @param ipv4Af true if IPV4 interface uses; false otherwise
- */
- public void ipv4Af(boolean ipv4Af) {
- this.ipv4Af = ipv4Af;
- }
-
- /**
- * Returns true if the IPV6 address family uses the protocol info; false
- * otherwise.
- *
- * @return true if IPV6 address family uses; false otherwise
- */
- public boolean isIpv6Af() {
- return ipv6Af;
- }
-
- /**
- * Sets true if the IPV6 address family uses the protocol info; false
- * otherwise.
- *
- * @param ipv6Af true if IPV6 interface uses; false otherwise
- */
- public void ipv6Af(boolean ipv6Af) {
- this.ipv6Af = ipv6Af;
- }
-
- /**
- * Returns the list of IPV4 network access information.
- *
- * @return IPV4 network accesses
- */
- public List<AccessInfo> v4Accesses() {
- return v4Accesses;
- }
-
- /**
- * Sets the list of IPV4 network access information.
- *
- * @param v4Accesses IPV4 network accesses
- */
- public void v4Accesses(List<AccessInfo> v4Accesses) {
- this.v4Accesses = v4Accesses;
- }
-
- /**
- * Adds a access info to the IPV4 network accesses.
- *
- * @param info IPV4 network access
- */
- public void addV4Access(AccessInfo info) {
- if (v4Accesses == null) {
- v4Accesses = new LinkedList<>();
- }
- v4Accesses.add(info);
- }
-
- /**
- * Returns the list of IPV6 network access information.
- *
- * @return IPV6 network accesses
- */
- public List<AccessInfo> v6Accesses() {
- return v6Accesses;
- }
-
- /**
- * Sets the list of IPV6 network access information.
- *
- * @param v6Accesses IPV6 network accesses
- */
- public void v6Accesses(List<AccessInfo> v6Accesses) {
- this.v4Accesses = v6Accesses;
- }
-
- /**
- * Adds a access info to the IPV6 network accesses.
- * @param info IPV4 network access
- */
- public void addV6Access(AccessInfo info) {
- if (v6Accesses == null) {
- v6Accesses = new LinkedList<>();
- }
- v6Accesses.add(info);
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/RouteProtocol.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/RouteProtocol.java
deleted file mode 100644
index f7c74be..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/RouteProtocol.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.l3vpn.netl3vpn;
-
-/**
- * Represents the route protocol of BGP info.
- */
-public enum RouteProtocol {
-
- /**
- * Requested route protocol type is of BGP.
- */
- BGP("bgp"),
-
- /**
- * Requested route protocol type is of direct.
- */
- DIRECT("direct"),
-
- /**
- * Requested route protocol type is of OSPF.
- */
- OSPF("ospf"),
-
- /**
- * Requested route protocol type is of RIP.
- */
- RIP("rip"),
-
- /**
- * Requested route protocol type is of RIPNG.
- */
- RIP_NG("ripng"),
-
- /**
- * Requested route protocol type is of VRRP.
- */
- VRRP("vrrp"),
-
- /**
- * Requested route protocol type is of static.
- */
- STATIC("yangautoprefixstatic");
-
- /**
- * Defined protocol type from the enum value.
- */
- private final String proType;
-
- /**
- * Constructs protocol type value from enum.
- *
- * @param proType value of enum
- */
- RouteProtocol(String proType) {
- this.proType = proType;
- }
-
- /**
- * Returns route protocol for corresponding protocol name.
- *
- * @param name protocol name
- * @return route protocol
- */
- public static RouteProtocol getProType(String name) {
- for (RouteProtocol protocol : values()) {
- if (protocol.proType.equals(name.toLowerCase())) {
- return protocol;
- }
- }
- throw new NetL3VpnException("There is no protocol type as " + name);
- }
-
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/TunnelInfo.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/TunnelInfo.java
deleted file mode 100644
index db8c9c6..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/TunnelInfo.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-/**
- * Represents the tunnel information.
- */
-public class TunnelInfo {
-
- /**
- * Destination ip address.
- */
- private final String desIp;
-
- /**
- * Tunnel name.
- */
- private final String tnlName;
-
- /**
- * Tunnel policy name.
- */
- private final String polName;
-
- /**
- * Device id.
- */
- private final String devId;
-
- /**
- * Level of the model.
- */
- private ModelIdLevel level;
-
- /**
- * Creates tunnel info with destination ip address, tunnel name, tunnel
- * policy name and device id.
- *
- * @param dIp destination ip
- * @param tName tunnel name
- * @param pName tunnel policy name
- * @param dId device id
- */
- public TunnelInfo(String dIp, String tName, String pName, String dId) {
- this.desIp = dIp;
- this.tnlName = tName;
- this.polName = pName;
- this.devId = dId;
- }
-
- /**
- * Returns the destination ip-address.
- *
- * @return destination ip-address
- */
- public String desIp() {
- return desIp;
- }
-
- /**
- * Returns the tunnel name.
- *
- * @return tunnel name
- */
- public String tnlName() {
- return tnlName;
- }
-
- /**
- * Returns the tunnel policy name.
- *
- * @return tunnel policy name
- */
- public String polName() {
- return polName;
- }
-
- /**
- * Returns the device id.
- *
- * @return device id
- */
- public String devId() {
- return devId;
- }
-
- /**
- * Returns the model id level.
- *
- * @return model id level
- */
- public ModelIdLevel level() {
- return level;
- }
-
- /**
- * Sets the model id level.
- *
- * @param level model id level
- */
- public void level(ModelIdLevel level) {
- this.level = level;
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/VpnConfig.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/VpnConfig.java
deleted file mode 100644
index 743cffa..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/VpnConfig.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-/**
- * Abstraction of VPN config which contains RD value for the VPN instance.
- */
-public class VpnConfig {
-
- /**
- * RD value for VPN instance.
- */
- private String rd;
-
- /**
- * Created VPN config.
- */
- public VpnConfig() {
- }
-
- /**
- * Returns RD value.
- *
- * @return RD value
- */
- public String rd() {
- return rd;
- }
-
- /**
- * Sets the RD value.
- *
- * @param rd RD value
- */
- public void rd(String rd) {
- this.rd = rd;
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/VpnInstance.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/VpnInstance.java
deleted file mode 100644
index 17a6ee8..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/VpnInstance.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-import org.onosproject.net.DeviceId;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Representation of stored VPN instance, which contains the configuration
- * such as RD and RT, also the device info and the VPN type.
- */
-public class VpnInstance<T extends VpnConfig> {
-
- /**
- * VPN instance name.
- */
- private String vpnName;
-
- /**
- * List of devices for the VPN.
- */
- private Map<DeviceId, DeviceInfo> devInfo;
-
- /**
- * Type of the VPN.
- */
- private VpnType type;
-
- /**
- * VPN config information.
- */
- private T vpnConfig;
-
- /**
- * Creates VPN instance with VPN name.
- *
- * @param v VPN name
- */
- public VpnInstance(String v) {
- vpnName = v;
- }
-
- /**
- * Returns the type of the VPN instance.
- *
- * @return VPN type
- */
- public VpnType type() {
- return type;
- }
-
- /**
- * Sets the type of the VPN instance.
- *
- * @param type VPN type
- */
- public void type(VpnType type) {
- this.type = type;
- }
-
- /**
- * Returns the configuration of VPN instance.
- *
- * @return VPN config
- */
- public T vpnConfig() {
- return vpnConfig;
- }
-
- /**
- * Sets the configuration of VPN instance.
- *
- * @param vpnConfig VPN config
- */
- public void vpnConfig(T vpnConfig) {
- this.vpnConfig = vpnConfig;
- }
-
- /**
- * Returns the device info map.
- *
- * @return device info map
- */
- public Map<DeviceId, DeviceInfo> devInfo() {
- return devInfo;
- }
-
- /**
- * Sets the device info map.
- *
- * @param devInfo device info map
- */
- public void devInfo(Map<DeviceId, DeviceInfo> devInfo) {
- this.devInfo = devInfo;
- }
-
- /**
- * Adds the content to device info map.
- *
- * @param id device id
- * @param info device info
- */
- public void addDevInfo(DeviceId id, DeviceInfo info) {
- if (devInfo == null) {
- devInfo = new HashMap<>();
- }
- devInfo.put(id, info);
- }
-
- /**
- * Returns the VPN instance name.
- *
- * @return VPN name
- */
- public String vpnName() {
- return vpnName;
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/VpnSiteRole.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/VpnSiteRole.java
deleted file mode 100644
index d190488..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/VpnSiteRole.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-/**
- * Representation of VPN instance name and its respective site role for each
- * site.
- */
-public class VpnSiteRole {
-
- /**
- * VPN instance name of the site.
- */
- private String name;
-
- /**
- * Site role of the site.
- */
- private VpnType role;
-
- /**
- * Creates VPN instance site role.
- *
- * @param n VPN name
- * @param r site role
- */
- public VpnSiteRole(String n, VpnType r) {
- name = n;
- role = r;
- }
-
- /**
- * Returns the VPN instance name of the site.
- *
- * @return VPN name
- */
- public String name() {
- return name;
- }
-
- /**
- * Returns the site role.
- *
- * @return site role
- */
- public VpnType role() {
- return role;
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/VpnType.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/VpnType.java
deleted file mode 100644
index 78b37e5..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/VpnType.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn;
-
-/**
- * Represents the type of VPN instance.
- */
-public enum VpnType {
-
- /**
- * Requested VPN type is of full mesh.
- */
- ANY_TO_ANY,
-
- /**
- * Requested VPN type is of hub.
- */
- HUB,
-
- /**
- * Requested VPN type is of spoke.
- */
- SPOKE
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/BgpConstructionUtil.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/BgpConstructionUtil.java
deleted file mode 100644
index bedc4a3..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/BgpConstructionUtil.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn.impl;
-
-import org.onosproject.l3vpn.netl3vpn.AccessInfo;
-import org.onosproject.l3vpn.netl3vpn.BgpInfo;
-import org.onosproject.l3vpn.netl3vpn.DeviceInfo;
-import org.onosproject.l3vpn.netl3vpn.NetL3VpnException;
-import org.onosproject.l3vpn.netl3vpn.ProtocolInfo;
-import org.onosproject.l3vpn.netl3vpn.RouteProtocol;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.RoutingProtocolType;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.siteattachmentipconnection.IpConnection;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.siterouting.routingprotocols.RoutingProtocol;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.onosproject.l3vpn.netl3vpn.RouteProtocol.DIRECT;
-import static org.onosproject.l3vpn.netl3vpn.RouteProtocol.STATIC;
-import static org.onosproject.l3vpn.netl3vpn.RouteProtocol.getProType;
-
-/**
- * Representation of utility for BGP info creation and deletion.
- */
-public final class BgpConstructionUtil {
-
- private static final String ZERO = "0";
-
- // No instantiation.
- private BgpConstructionUtil() {
- }
-
- /**
- * Creates the BGP info instance, from the routing protocols available.
- * It returns BGP info if for the first time, else returns null.
- *
- * @param routes route protocol
- * @param info device info
- * @param vpnName VPN name
- * @param connect ip connection
- * @param access access info
- * @return BGP info instance
- */
- public static BgpInfo createBgpInfo(List<RoutingProtocol> routes,
- DeviceInfo info, String vpnName,
- IpConnection connect, AccessInfo access) {
- BgpInfo devBgp = info.bgpInfo();
- BgpInfo infoBgp = new BgpInfo();
- infoBgp.vpnName(vpnName);
- if (devBgp != null) {
- infoBgp = updateDevBgpInfo(devBgp, infoBgp, connect, routes, access);
- } else {
- infoBgp = updateDevBgpInfo(null, infoBgp, connect, routes, access);
- info.bgpInfo(infoBgp);
- }
- if (infoBgp == null || infoBgp.protocolInfo() == null) {
- return null;
- }
- return infoBgp;
- }
-
- /**
- * Updates the device BGP info and also creates the BGP info which has to
- * be sent to driver, if it is called for the first time.
- *
- * @param devBgp device BGP info
- * @param driBgp driver BGP info
- * @param connect ip connection
- * @param routes route protocols
- * @param access access info
- * @return driver BGP info
- */
- private static BgpInfo updateDevBgpInfo(BgpInfo devBgp, BgpInfo driBgp,
- IpConnection connect,
- List<RoutingProtocol> routes,
- AccessInfo access) {
- for (RoutingProtocol route : routes) {
- ProtocolInfo ifInfo = getRoutePro(route.type(), connect, access);
- if (ifInfo != null) {
- if (devBgp != null) {
- ProtocolInfo info = addToDevBgp(ifInfo, devBgp, access);
- ifInfo = getUpdatedProInfo(info, ifInfo);
- }
- if (ifInfo != null) {
- driBgp.addProtocolInfo(ifInfo.routeProtocol(), ifInfo);
- }
- }
- }
- return driBgp;
- }
-
- /**
- * Returns the updated protocol info that has to be sent to driver. If
- * the protocol info is for the second time or more, the driver info's
- * protocol info will not be sent. It will return null if no info is
- * present or nothing to be sent to driver.
- *
- * @param devInfo device protocol info
- * @param driInfo driver protocol info
- * @return updated driver protocol info
- */
- private static ProtocolInfo getUpdatedProInfo(ProtocolInfo devInfo,
- ProtocolInfo driInfo) {
- if (driInfo.isIpv4Af() && driInfo.isIpv6Af()) {
- if ((getV4Size(devInfo) > 1) && (getV6Size(devInfo) > 1)) {
- return null;
- }
- if ((getV4Size(devInfo) > 1) && !(getV6Size(devInfo) > 1)) {
- driInfo.ipv4Af(false);
- } else if (!(getV4Size(devInfo) > 1) && (getV6Size(devInfo) > 1)) {
- driInfo.ipv6Af(false);
- }
- }
- if (driInfo.isIpv4Af() && !driInfo.isIpv6Af()) {
- if (getV4Size(devInfo) > 1) {
- return null;
- }
- }
- if (!driInfo.isIpv4Af() && driInfo.isIpv6Af()) {
- if (getV6Size(devInfo) > 1) {
- return null;
- }
- }
- return driInfo;
- }
-
- private static int getV4Size(ProtocolInfo proInfo) {
- return proInfo.v4Accesses().size();
- }
-
- private static int getV6Size(ProtocolInfo proInfo) {
- return proInfo.v6Accesses().size();
- }
-
- /**
- * Adds the protocol info to the device BGP info.
- *
- * @param proInfo protocol info
- * @param devBgp device BGP
- * @param access access info
- * @return protocol info
- */
- private static ProtocolInfo addToDevBgp(ProtocolInfo proInfo,
- BgpInfo devBgp, AccessInfo access) {
- Map<RouteProtocol, ProtocolInfo> devMap = devBgp.protocolInfo();
- ProtocolInfo devInfo = devMap.get(proInfo.routeProtocol());
- if (devInfo != null) {
- if (proInfo.isIpv4Af()) {
- devInfo.ipv4Af(proInfo.isIpv4Af());
- devInfo.addV4Access(access);
- }
- if (proInfo.isIpv6Af()) {
- devInfo.ipv6Af(proInfo.isIpv6Af());
- devInfo.addV6Access(access);
- }
- } else {
- devInfo = proInfo;
- devBgp.addProtocolInfo(proInfo.routeProtocol(), devInfo);
- }
- return devInfo;
- }
-
-
- /**
- * Returns the protocol info of BGP by taking values from the service files.
- *
- * @param type protocol type
- * @param connect IP connection
- * @param access access info
- * @return protocol info
- */
- private static ProtocolInfo getRoutePro(Class<? extends RoutingProtocolType> type,
- IpConnection connect, AccessInfo access) {
- ProtocolInfo protocolInfo = new ProtocolInfo();
- RouteProtocol protocol = getProType(type.getSimpleName());
- switch (protocol) {
- case DIRECT:
- protocolInfo.routeProtocol(DIRECT);
- protocolInfo.processId(ZERO);
- setAddressFamily(protocolInfo, connect, access);
- return protocolInfo;
-
- case STATIC:
- protocolInfo.routeProtocol(STATIC);
- protocolInfo.processId(ZERO);
- setAddressFamily(protocolInfo, connect, access);
- return protocolInfo;
-
- case BGP:
- case OSPF:
- case RIP:
- case RIP_NG:
- case VRRP:
- default:
- throw new NetL3VpnException(getRouteProErr(
- type.getSimpleName()));
- }
- }
-
- /**
- * Returns the route protocol error message for unsupported type.
- *
- * @param type route protocol type
- * @return error message
- */
- private static String getRouteProErr(String type) {
- return type + " routing protocol is not supported.";
- }
-
- /**
- * Sets the address family of the protocol info.
- *
- * @param proInfo protocol info
- * @param connect ip connection
- * @param access access info
- */
- private static void setAddressFamily(ProtocolInfo proInfo,
- IpConnection connect, AccessInfo access) {
- if (connect.ipv4() != null && connect.ipv4().addresses() != null &&
- connect.ipv4().addresses().providerAddress() != null) {
- proInfo.ipv4Af(true);
- proInfo.addV4Access(access);
- }
- if (connect.ipv6() != null && connect.ipv6().addresses() != null &&
- connect.ipv6().addresses().providerAddress() != null) {
- proInfo.ipv6Af(true);
- proInfo.addV6Access(access);
- }
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/DistributedNetL3VpnStore.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/DistributedNetL3VpnStore.java
deleted file mode 100644
index 5178d5e..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/DistributedNetL3VpnStore.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.l3vpn.netl3vpn.impl;
-
-import com.google.common.collect.ImmutableSet;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.l3vpn.netl3vpn.AccessInfo;
-import org.onosproject.l3vpn.netl3vpn.BgpInfo;
-import org.onosproject.l3vpn.netl3vpn.DeviceInfo;
-import org.onosproject.l3vpn.netl3vpn.FullMeshVpnConfig;
-import org.onosproject.l3vpn.netl3vpn.HubSpokeVpnConfig;
-import org.onosproject.l3vpn.netl3vpn.InterfaceInfo;
-import org.onosproject.l3vpn.netl3vpn.NetL3VpnStore;
-import org.onosproject.l3vpn.netl3vpn.ProtocolInfo;
-import org.onosproject.l3vpn.netl3vpn.RouteProtocol;
-import org.onosproject.l3vpn.netl3vpn.TunnelInfo;
-import org.onosproject.l3vpn.netl3vpn.VpnConfig;
-import org.onosproject.l3vpn.netl3vpn.VpnInstance;
-import org.onosproject.l3vpn.netl3vpn.VpnType;
-import org.onosproject.net.DeviceId;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.DistributedSet;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.yang.model.LeafListKey;
-import org.onosproject.yang.model.ListKey;
-import org.onosproject.yang.model.NodeKey;
-import org.onosproject.yang.model.ResourceId;
-import org.onosproject.yang.model.SchemaId;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Manages the pool of available VPN instances and its associated devices
- * and interface information.
- */
-@Component(immediate = true, service = NetL3VpnStore.class)
-public class DistributedNetL3VpnStore implements NetL3VpnStore {
-
- private static final Serializer L3VPN_SERIALIZER = Serializer
- .using(new KryoNamespace.Builder().register(KryoNamespaces.API)
- .register(KryoNamespaces.API)
- .register(VpnInstance.class)
- .register(VpnType.class)
- .register(VpnConfig.class)
- .register(FullMeshVpnConfig.class)
- .register(HubSpokeVpnConfig.class)
- .register(DeviceInfo.class)
- .register(ResourceId.class)
- .register(NodeKey.class)
- .register(SchemaId.class)
- .register(LeafListKey.class)
- .register(ListKey.class)
- .register(AccessInfo.class)
- .register(InterfaceInfo.class)
- .register(BgpInfo.class)
- .register(RouteProtocol.class)
- .register(ProtocolInfo.class)
- .register(TunnelInfo.class)
- .build());
-
- private static final String FREE_ID_NULL = "Free ID cannot be null";
- private static final String VPN_NAME_NULL = "VPN name cannot be null";
- private static final String VPN_INS_NULL = "VPN instance cannot be null";
- private static final String ACCESS_INFO_NULL = "Access info cannot be null";
- private static final String BGP_INFO_NULL = "BGP info cannot be null";
- private static final String INT_INFO_NULL = "Interface info cannot be null";
- private static final String DEV_ID_NULL = "Device Id cannot be null";
-
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- /**
- * Freed id list of NET L3VPN.
- */
- private DistributedSet<Long> freedIdList;
-
- /**
- * Map of interface info with access info as key.
- */
- private ConsistentMap<AccessInfo, InterfaceInfo> intInfoMap;
-
- /**
- * Map of VPN instance with VPN name as key.
- */
- private ConsistentMap<String, VpnInstance> vpnInsMap;
-
- /**
- * Map of BGP information and the device id.
- */
- private ConsistentMap<BgpInfo, DeviceId> bgpInfoMap;
-
- /**
- * Map of device id and tunnel count.
- */
- private ConsistentMap<DeviceId, Integer> tunnelInfoMap;
-
- @Activate
- protected void activate() {
- vpnInsMap = storageService.<String, VpnInstance>consistentMapBuilder()
- .withName("onos-l3vpn-instance-map")
- .withSerializer(L3VPN_SERIALIZER)
- .build();
-
- intInfoMap = storageService
- .<AccessInfo, InterfaceInfo>consistentMapBuilder()
- .withName("onos-l3vpn-int-info-map")
- .withSerializer(L3VPN_SERIALIZER)
- .build();
-
- bgpInfoMap = storageService.<BgpInfo, DeviceId>consistentMapBuilder()
- .withName("onos-l3vpn-bgp-info-map")
- .withSerializer(L3VPN_SERIALIZER)
- .build();
-
- tunnelInfoMap = storageService.<DeviceId, Integer>consistentMapBuilder()
- .withName("onos-l3vpn-tnl-info-map")
- .withSerializer(L3VPN_SERIALIZER)
- .build();
-
- freedIdList = storageService.<Long>setBuilder()
- .withName("onos-l3vpn-id-freed-list")
- .withSerializer(Serializer.using(KryoNamespaces.API))
- .build()
- .asDistributedSet();
-
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public Iterable<Long> getFreedIdList() {
- return ImmutableSet.copyOf(freedIdList);
- }
-
- @Override
- public Map<String, VpnInstance> getVpnInstances() {
- return vpnInsMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()
- .value()));
- }
-
- @Override
- public Map<BgpInfo, DeviceId> getBgpInfo() {
- return bgpInfoMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()
- .value()));
- }
-
- @Override
- public Map<AccessInfo, InterfaceInfo> getInterfaceInfo() {
- return intInfoMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()
- .value()));
- }
-
- @Override
- public Map<DeviceId, Integer> getTunnelInfo() {
- return tunnelInfoMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()
- .value()));
- }
-
- @Override
- public void addIdToFreeList(Long id) {
- checkNotNull(id, FREE_ID_NULL);
- freedIdList.add(id);
- }
-
- @Override
- public void addVpnInsIfAbsent(String name, VpnInstance instance) {
- checkNotNull(name, VPN_NAME_NULL);
- checkNotNull(instance, VPN_INS_NULL);
- vpnInsMap.putIfAbsent(name, instance);
- }
-
- @Override
- public void addVpnIns(String name, VpnInstance instance) {
- checkNotNull(name, VPN_NAME_NULL);
- checkNotNull(instance, VPN_INS_NULL);
- vpnInsMap.put(name, instance);
- }
-
- @Override
- public void addInterfaceInfo(AccessInfo accessInfo, InterfaceInfo intInfo) {
- checkNotNull(accessInfo, ACCESS_INFO_NULL);
- checkNotNull(intInfo, INT_INFO_NULL);
- intInfoMap.put(accessInfo, intInfo);
- }
-
- @Override
- public void addBgpInfo(BgpInfo bgpInfo, DeviceId devId) {
- checkNotNull(bgpInfo, BGP_INFO_NULL);
- checkNotNull(devId, DEV_ID_NULL);
- bgpInfoMap.put(bgpInfo, devId);
- }
-
- @Override
- public void addTunnelInfo(DeviceId devId, Integer count) {
- checkNotNull(devId, DEV_ID_NULL);
- tunnelInfoMap.put(devId, count);
- }
-
- @Override
- public boolean removeInterfaceInfo(AccessInfo accessInfo) {
- checkNotNull(accessInfo, ACCESS_INFO_NULL);
-
- if (intInfoMap.remove(accessInfo) == null) {
- log.error("Interface info deletion for access info {} has failed.",
- accessInfo.toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removeVpnInstance(String vpnName) {
- checkNotNull(vpnName, VPN_NAME_NULL);
-
- if (vpnInsMap.remove(vpnName) == null) {
- log.error("Vpn instance deletion for vpn name {} has failed.",
- vpnName);
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removeIdFromFreeList(Long id) {
- checkNotNull(id, FREE_ID_NULL);
-
- if (!freedIdList.remove(id)) {
- log.error("Id from free id list {} deletion has failed.",
- id.toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removeBgpInfo(BgpInfo bgpInfo) {
- checkNotNull(bgpInfo, BGP_INFO_NULL);
-
- if (bgpInfoMap.remove(bgpInfo) == null) {
- log.error("Device id deletion for BGP info {} has failed.",
- bgpInfo.toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removeTunnelInfo(DeviceId id) {
- checkNotNull(id, DEV_ID_NULL);
-
- if (tunnelInfoMap.remove(id) == null) {
- log.error("Device id deletion in tunnel info has failed.");
- return false;
- }
- return true;
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/InsConstructionUtil.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/InsConstructionUtil.java
deleted file mode 100644
index a883ef6..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/InsConstructionUtil.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn.impl;
-
-import org.onosproject.l3vpn.netl3vpn.FullMeshVpnConfig;
-import org.onosproject.l3vpn.netl3vpn.HubSpokeVpnConfig;
-import org.onosproject.l3vpn.netl3vpn.VpnInstance;
-import org.onosproject.l3vpn.netl3vpn.VpnSiteRole;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.devices.device.networkinstances.networkinstance.AugmentedNiNetworkInstance;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.devices.device.networkinstances.networkinstance.DefaultAugmentedNiNetworkInstance;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.devices.device.networkinstances.networkinstance.augmentedninetworkinstance.DefaultL3Vpn;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.devices.device.networkinstances.networkinstance.augmentedninetworkinstance.L3Vpn;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.l3vpnvrfparams.DefaultIpv4;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.l3vpnvrfparams.DefaultIpv6;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.l3vpnvrfparams.Ipv4;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.l3vpnvrfparams.Ipv6;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.l3vpnvrfparams.ipv4.DefaultUnicast;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.l3vpnvrfparams.ipv4.Unicast;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routedistinguisherparams.DefaultRouteDistinguisher;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routedistinguisherparams.RouteDistinguisher;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routetargetparams.DefaultRouteTargets;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routetargetparams.RouteTargets;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routetargetparams.routetargets.Config;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routetargetparams.routetargets.DefaultConfig;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routetargetset.DefaultRts;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routetargetset.Rts;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routetargetset.rts.RtTypeEnum;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.siteattachmentipconnection.IpConnection;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.device.DefaultNetworkInstances;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.device.NetworkInstances;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.device.networkinstances.DefaultNetworkInstance;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.device.networkinstances.NetworkInstance;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import static org.onosproject.l3vpn.netl3vpn.VpnType.ANY_TO_ANY;
-import static org.onosproject.l3vpn.netl3vpn.VpnType.HUB;
-import static org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routetargetset.rts.RtTypeEnum.BOTH;
-import static org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routetargetset.rts.RtTypeEnum.EXPORT;
-import static org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routetargetset.rts.RtTypeEnum.IMPORT;
-
-/**
- * Representation of utility for instance creation and deletion.
- */
-public final class InsConstructionUtil {
-
- // No instantiation.
- private InsConstructionUtil() {
- }
-
- /**
- * Creates network instance with augmented info such as RD and RT.
- *
- * @param vpnIns VPN instance
- * @param role VPN role
- * @param connect ip connection
- * @return network instance
- */
- public static NetworkInstances createInstance(VpnInstance vpnIns,
- VpnSiteRole role,
- IpConnection connect) {
- NetworkInstance ins = new DefaultNetworkInstance();
- NetworkInstances instances = new DefaultNetworkInstances();
- List<NetworkInstance> insList = new LinkedList<>();
-
- L3Vpn l3Vpn = buildRd(vpnIns);
- DefaultAugmentedNiNetworkInstance augIns =
- buildRt(connect, role, l3Vpn, vpnIns);
- ins.name(vpnIns.vpnName());
- insList.add(ins);
- ((DefaultNetworkInstance) ins).addAugmentation(augIns);
- instances.networkInstance(insList);
- return instances;
- }
-
- /**
- * Builds RT from l3 VPN according to the address family VPN belongs to.
- * It returns built aug network instance from l3 VPN.
- *
- * @param con ip connection
- * @param role site VPN role
- * @param l3Vpn l3 VPN
- * @param ins VPN instance
- * @return aug network instance
- */
- private static DefaultAugmentedNiNetworkInstance buildRt(IpConnection con,
- VpnSiteRole role,
- L3Vpn l3Vpn,
- VpnInstance ins) {
- Ipv4 ipv4 = null;
- Ipv6 ipv6 = null;
- if (con.ipv4() != null && con.ipv4().addresses()
- .providerAddress() != null) {
- ipv4 = buildIpv4Rt(role, ins);
- }
- if (con.ipv6() != null && con.ipv6()
- .addresses().providerAddress() != null) {
- ipv6 = buildIpv6Rt(role, ins);
- }
- l3Vpn.ipv4(ipv4);
- l3Vpn.ipv6(ipv6);
-
- AugmentedNiNetworkInstance augInst =
- new DefaultAugmentedNiNetworkInstance();
- augInst.l3Vpn(l3Vpn);
- return (DefaultAugmentedNiNetworkInstance) augInst;
- }
-
- /**
- * Builds ipv6 RT in the device model.
- *
- * @param role site VPN role
- * @param vpnIns VPN instance
- * @return ipv6
- */
- private static Ipv6 buildIpv6Rt(VpnSiteRole role, VpnInstance vpnIns) {
- RouteTargets rts6 = new DefaultRouteTargets();
- Ipv6 v6 = new DefaultIpv6();
- org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn
- .l3vpnvrfparams.ipv6.Unicast uni6 = new org.onosproject.yang
- .gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.l3vpnvrfparams
- .ipv6.DefaultUnicast();
-
- Config configV6 = configRouteTarget(vpnIns, role);
- rts6.config(configV6);
- uni6.routeTargets(rts6);
- v6.unicast(uni6);
- return v6;
- }
-
- /**
- * Builds ipv4 RT in the device model.
- *
- * @param role site VPN role
- * @param vpnIns VPN instance
- * @return ipv4
- */
- private static Ipv4 buildIpv4Rt(VpnSiteRole role, VpnInstance vpnIns) {
- RouteTargets rts4 = new DefaultRouteTargets();
- Unicast uni4 = new DefaultUnicast();
- Ipv4 v4 = new DefaultIpv4();
-
- Config configV4 = configRouteTarget(vpnIns, role);
- rts4.config(configV4);
- uni4.routeTargets(rts4);
- v4.unicast(uni4);
- return v4;
- }
-
- /**
- * Configures route target according to the site VPN role from the stored
- * VPN instance.
- *
- * @param ins VPN instance
- * @param role site VPN role
- * @return route target config
- */
- private static Config configRouteTarget(VpnInstance ins,
- VpnSiteRole role) {
- Rts rts1;
- Config config = new DefaultConfig();
- List<Rts> rtsList = new LinkedList<>();
-
- if (ins.type() == ANY_TO_ANY) {
- String rtVal = ((FullMeshVpnConfig) ins.vpnConfig()).rt();
- rts1 = getRtsVal(rtVal, BOTH);
- } else {
- String rtVal1;
- String rtVal2;
- HubSpokeVpnConfig conf = (HubSpokeVpnConfig) ins.vpnConfig();
- if (role.role() == HUB) {
- rtVal1 = conf.hubImpRt();
- rtVal2 = conf.hubExpRt();
- } else {
- rtVal1 = conf.spokeImpRt();
- rtVal2 = conf.spokeExpRt();
- }
- rts1 = getRtsVal(rtVal1, IMPORT);
- Rts rts2 = getRtsVal(rtVal2, EXPORT);
- rtsList.add(rts2);
- }
- rtsList.add(rts1);
- config.rts(rtsList);
- return config;
- }
-
- /**
- * Returns the device model RT from the RT type and RT value after
- * building it.
- *
- * @param rtVal RT value
- * @param type RT type
- * @return device model RT
- */
- private static Rts getRtsVal(String rtVal, RtTypeEnum type) {
- Rts rts = new DefaultRts();
- rts.rt(rtVal);
- rts.rtType(type);
- return rts;
- }
-
- /**
- * Builds RD from the stored device model VPN instance.
- *
- * @param vpn VPN instance
- * @return l3 VPN object
- */
- private static L3Vpn buildRd(VpnInstance vpn) {
- String rd = vpn.vpnConfig().rd();
- org.onosproject.yang.gen.v1.ietfbgpl3vpn
- .rev20160909.ietfbgpl3vpn.routedistinguisherparams
- .routedistinguisher.Config config = new org.onosproject.yang
- .gen.v1.ietfbgpl3vpn.rev20160909
- .ietfbgpl3vpn.routedistinguisherparams.routedistinguisher
- .DefaultConfig();
- config.rd(rd);
- RouteDistinguisher dist = new DefaultRouteDistinguisher();
- dist.config(config);
- L3Vpn l3vpn = new DefaultL3Vpn();
- l3vpn.routeDistinguisher(dist);
- return l3vpn;
- }
-
- /**
- * Constructs network instance for delete of VPN instance.
- *
- * @param vpnName VPN name
- * @return network instances
- */
- static NetworkInstances deleteInstance(String vpnName) {
- NetworkInstance nwInstance = new DefaultNetworkInstance();
- List<NetworkInstance> insList = new LinkedList<>();
- NetworkInstances instances = new DefaultNetworkInstances();
- nwInstance.name(vpnName);
- insList.add(nwInstance);
- instances.networkInstance(insList);
- return instances;
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/IntConstructionUtil.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/IntConstructionUtil.java
deleted file mode 100644
index 4d1c9d0..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/IntConstructionUtil.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn.impl;
-
-import org.onosproject.l3vpn.netl3vpn.NetL3VpnException;
-import org.onosproject.yang.gen.v1.ietfinettypes.rev20130715.ietfinettypes.Ipv4Address;
-import org.onosproject.yang.gen.v1.ietfinettypes.rev20130715.ietfinettypes.Ipv4AddressNoZone;
-import org.onosproject.yang.gen.v1.ietfinettypes.rev20130715.ietfinettypes.Ipv6Address;
-import org.onosproject.yang.gen.v1.ietfinettypes.rev20130715.ietfinettypes.Ipv6AddressNoZone;
-import org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.ietfinterfaces.devices.device.DefaultInterfaces;
-import org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.ietfinterfaces.devices.device.Interfaces;
-import org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.ietfinterfaces.devices.device.interfaces.DefaultYangAutoPrefixInterface;
-import org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.ietfinterfaces.devices.device.interfaces.YangAutoPrefixInterface;
-import org.onosproject.yang.gen.v1.ietfip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.AugmentedIfInterface;
-import org.onosproject.yang.gen.v1.ietfip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.DefaultAugmentedIfInterface;
-import org.onosproject.yang.gen.v1.ietfip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.augmentedifinterface.DefaultIpv4;
-import org.onosproject.yang.gen.v1.ietfip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.augmentedifinterface.DefaultIpv6;
-import org.onosproject.yang.gen.v1.ietfip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.augmentedifinterface.Ipv4;
-import org.onosproject.yang.gen.v1.ietfip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.augmentedifinterface.Ipv6;
-import org.onosproject.yang.gen.v1.ietfip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.augmentedifinterface.ipv4.Address;
-import org.onosproject.yang.gen.v1.ietfip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.augmentedifinterface.ipv4.DefaultAddress;
-import org.onosproject.yang.gen.v1.ietfip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.augmentedifinterface.ipv4.address.Subnet;
-import org.onosproject.yang.gen.v1.ietfip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.augmentedifinterface.ipv4.address.subnet.DefaultPrefixLength;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.siteattachmentipconnection.IpConnection;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.device.interfaces.yangautoprefixinterface.ipv4.AugmentedIpIpv4;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.device.interfaces.yangautoprefixinterface.ipv4.DefaultAugmentedIpIpv4;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.device.interfaces.yangautoprefixinterface.ipv6.AugmentedIpIpv6;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.device.interfaces.yangautoprefixinterface.ipv6.DefaultAugmentedIpIpv6;
-import org.onosproject.yang.model.InnerModelObject;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Representation of utility for interface creation and deletion.
- */
-public final class IntConstructionUtil {
-
- private static final String IP_ADD_NULL = "Vpn binding to an interface " +
- "requires ip address.";
-
- // No instantiation.
- private IntConstructionUtil() {
- }
-
- /**
- * Creates device model interface by building its parameters with port
- * name, VPN name and ip connection.
- *
- * @param pName port name
- * @param vpnName VPN name
- * @param connect ip connection
- * @return interface device model
- */
- public static Interfaces createInterface(String pName, String vpnName,
- IpConnection connect) {
- Interfaces interfaces = new DefaultInterfaces();
- List<YangAutoPrefixInterface> intList = new LinkedList<>();
- YangAutoPrefixInterface inter = buildInterface(vpnName, pName, connect);
- intList.add(inter);
- interfaces.yangAutoPrefixInterface(intList);
- return interfaces;
- }
-
- /**
- * Builds augmented info of ip address to the interface.
- *
- * @param vpnName VPN name
- * @param pName port name
- * @param connect ip connection
- * @return interface
- */
- private static YangAutoPrefixInterface buildInterface(String vpnName,
- String pName,
- IpConnection connect) {
- // Bind vpn name in the augmented info of interface.
- org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623
- .ietfnetworkinstance.devices.device.interfaces
- .yangautoprefixinterface.AugmentedIfInterface augIf = new org
- .onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623
- .ietfnetworkinstance.devices.device.interfaces
- .yangautoprefixinterface.DefaultAugmentedIfInterface();
- augIf.bindNetworkInstanceName(vpnName);
-
- // Bind ip address to the interface as augmented info.
- AugmentedIfInterface intAug = buildIpAddress(connect, vpnName);
- YangAutoPrefixInterface inter = new DefaultYangAutoPrefixInterface();
- inter.name(pName);
- ((DefaultYangAutoPrefixInterface) inter).addAugmentation(
- (InnerModelObject) augIf);
- ((DefaultYangAutoPrefixInterface) inter).addAugmentation(
- (InnerModelObject) intAug);
-
- return inter;
- }
-
- /**
- * Returns ipv6 address filled with attached VPN, ipv6 address and mask.
- *
- * @param vpnName VPN name
- * @param mask mask
- * @param ipv6Add ipv6 address
- * @return device ipv6 address
- */
- private static Ipv6 getIpv6Aug(String vpnName, short mask, String ipv6Add) {
- AugmentedIpIpv6 augIpv6 = new DefaultAugmentedIpIpv6();
- org.onosproject.yang.gen.v1.ietfip.rev20140616.ietfip.devices.device
- .interfaces.yangautoprefixinterface.augmentedifinterface.ipv6
- .Address add = new org.onosproject.yang.gen.v1.ietfip
- .rev20140616.ietfip.devices.device.interfaces
- .yangautoprefixinterface.augmentedifinterface.ipv6
- .DefaultAddress();
- Ipv6 ipv6 = new DefaultIpv6();
- List<org.onosproject.yang.gen.v1.ietfip
- .rev20140616.ietfip.devices.device.interfaces
- .yangautoprefixinterface.augmentedifinterface.ipv6
- .Address> addList = new LinkedList<>();
- add.ip(Ipv6AddressNoZone.of(Ipv6Address.of(ipv6Add)));
- augIpv6.bindNetworkInstanceName(vpnName);
- add.prefixLength(mask);
- addList.add(add);
- ipv6.address(addList);
- ((DefaultIpv6) ipv6).addAugmentation((DefaultAugmentedIpIpv6) augIpv6);
- return ipv6;
- }
-
- /**
- * Returns ipv4 address filled with attached VPN, ipv4 address and mask.
- *
- * @param vpnName VPN name
- * @param mask mask
- * @param ipv4Add ipv4 address
- * @return device ipv4 address
- */
- private static Ipv4 getIpv4Aug(String vpnName, short mask, String ipv4Add) {
- AugmentedIpIpv4 augIpv4 = new DefaultAugmentedIpIpv4();
- Subnet net = new DefaultPrefixLength();
- Address add = new DefaultAddress();
- Ipv4 ipv4 = new DefaultIpv4();
- List<Address> addList = new LinkedList<>();
-
- augIpv4.bindNetworkInstanceName(vpnName);
- ((DefaultPrefixLength) net).prefixLength(mask);
- add.ip(Ipv4AddressNoZone.of(Ipv4Address.of(ipv4Add)));
- add.subnet(net);
- addList.add(add);
- ipv4.address(addList);
- ((DefaultIpv4) ipv4).addAugmentation((DefaultAugmentedIpIpv4) augIpv4);
- return ipv4;
- }
-
- /**
- * Builds ip address according to the existence of ip address in ip
- * connection of device model.
- *
- * @param connect ip connection
- * @param vpnName VPN name
- * @return augmented interface
- */
- public static AugmentedIfInterface buildIpAddress(IpConnection connect,
- String vpnName) {
- if (connect == null || (connect.ipv4() == null
- && connect.ipv6() == null)) {
- throw new NetL3VpnException(IP_ADD_NULL);
- }
- AugmentedIfInterface intAug = new DefaultAugmentedIfInterface();
- short mask;
- if (connect.ipv4() != null) {
- mask = connect.ipv4().addresses().mask();
- Ipv4Address peIpv4 = connect.ipv4().addresses().providerAddress();
- Ipv4 v4 = getIpv4Aug(vpnName, mask, peIpv4.string());
- intAug.ipv4(v4);
- }
-
- if (connect.ipv6() != null) {
- mask = connect.ipv6().addresses().mask();
- Ipv6Address peIpv6 = connect.ipv6().addresses().providerAddress();
- Ipv6 v6 = getIpv6Aug(vpnName, mask, peIpv6.string());
- intAug.ipv6(v6);
- }
- return intAug;
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/NetL3VpnManager.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/NetL3VpnManager.java
deleted file mode 100644
index 7c1ccf8..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/NetL3VpnManager.java
+++ /dev/null
@@ -1,1103 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.l3vpn.netl3vpn.impl;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onlab.util.AbstractAccumulator;
-import org.onlab.util.Accumulator;
-import org.onosproject.cluster.ClusterService;
-import org.onosproject.cluster.LeadershipEvent;
-import org.onosproject.cluster.LeadershipEventListener;
-import org.onosproject.cluster.LeadershipService;
-import org.onosproject.cluster.NodeId;
-import org.onosproject.config.DynamicConfigEvent;
-import org.onosproject.config.DynamicConfigListener;
-import org.onosproject.config.DynamicConfigService;
-import org.onosproject.config.FailedException;
-import org.onosproject.config.Filter;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.core.IdGenerator;
-import org.onosproject.l3vpn.netl3vpn.AccessInfo;
-import org.onosproject.l3vpn.netl3vpn.BgpDriverInfo;
-import org.onosproject.l3vpn.netl3vpn.BgpInfo;
-import org.onosproject.l3vpn.netl3vpn.DeviceInfo;
-import org.onosproject.l3vpn.netl3vpn.FullMeshVpnConfig;
-import org.onosproject.l3vpn.netl3vpn.HubSpokeVpnConfig;
-import org.onosproject.l3vpn.netl3vpn.InterfaceInfo;
-import org.onosproject.l3vpn.netl3vpn.NetL3VpnException;
-import org.onosproject.l3vpn.netl3vpn.NetL3VpnStore;
-import org.onosproject.l3vpn.netl3vpn.VpnConfig;
-import org.onosproject.l3vpn.netl3vpn.VpnInstance;
-import org.onosproject.l3vpn.netl3vpn.VpnSiteRole;
-import org.onosproject.l3vpn.netl3vpn.VpnType;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Port;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.pce.pceservice.api.PceService;
-import org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.ietfinterfaces.devices.device.Interfaces;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.DefaultL3VpnSvc;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.L3VpnSvc;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.accessvpnpolicy.VpnAttachment;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.accessvpnpolicy.vpnattachment.AttachmentFlavor;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.accessvpnpolicy.vpnattachment.attachmentflavor.DefaultVpnId;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.l3vpnsvc.DefaultSites;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.l3vpnsvc.Sites;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.l3vpnsvc.VpnServices;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.l3vpnsvc.sites.Site;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.l3vpnsvc.sites.site.SiteNetworkAccesses;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.l3vpnsvc.sites.site.sitenetworkaccesses.SiteNetworkAccess;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.l3vpnsvc.vpnservices.VpnSvc;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.siteattachmentbearer.Bearer;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.siteattachmentbearer.bearer.RequestedType;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.siteattachmentipconnection.IpConnection;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.siterouting.RoutingProtocols;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.siterouting.routingprotocols.RoutingProtocol;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.device.NetworkInstances;
-import org.onosproject.yang.gen.v1.l3vpnsvcext.rev20160730.l3vpnsvcext.l3vpnsvc.sites.site.sitenetworkaccesses.sitenetworkaccess.bearer.DefaultAugmentedL3VpnBearer;
-import org.onosproject.yang.gen.v1.l3vpnsvcext.rev20160730.l3vpnsvcext.l3vpnsvc.sites.site.sitenetworkaccesses.sitenetworkaccess.bearer.requestedtype.DefaultAugmentedL3VpnRequestedType;
-import org.onosproject.yang.gen.v1.l3vpnsvcext.rev20160730.l3vpnsvcext.requestedtypegrouping.requestedtypeprofile.RequestedTypeChoice;
-import org.onosproject.yang.gen.v1.l3vpnsvcext.rev20160730.l3vpnsvcext.requestedtypegrouping.requestedtypeprofile.requestedtypechoice.DefaultDot1Qcase;
-import org.onosproject.yang.gen.v1.l3vpnsvcext.rev20160730.l3vpnsvcext.requestedtypegrouping.requestedtypeprofile.requestedtypechoice.DefaultPhysicalCase;
-import org.onosproject.yang.model.DataNode;
-import org.onosproject.yang.model.DefaultModelObjectData;
-import org.onosproject.yang.model.ModelConverter;
-import org.onosproject.yang.model.ModelObject;
-import org.onosproject.yang.model.ModelObjectData;
-import org.onosproject.yang.model.ModelObjectId;
-import org.onosproject.yang.model.NodeKey;
-import org.onosproject.yang.model.ResourceData;
-import org.onosproject.yang.model.ResourceId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Timer;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.config.DynamicConfigEvent.Type.NODE_ADDED;
-import static org.onosproject.config.DynamicConfigEvent.Type.NODE_DELETED;
-import static org.onosproject.l3vpn.netl3vpn.VpnType.HUB;
-import static org.onosproject.l3vpn.netl3vpn.impl.BgpConstructionUtil.createBgpInfo;
-import static org.onosproject.l3vpn.netl3vpn.impl.InsConstructionUtil.createInstance;
-import static org.onosproject.l3vpn.netl3vpn.impl.InsConstructionUtil.deleteInstance;
-import static org.onosproject.l3vpn.netl3vpn.impl.IntConstructionUtil.createInterface;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.BEARER_NULL;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.CONS_HUNDRED;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.DEVICE_INFO_NULL;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.EVENT_NULL;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.ID_LIMIT;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.ID_LIMIT_EXCEEDED;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.INT_INFO_NULL;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.IP_INT_INFO_NULL;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.MAX_BATCH_MS;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.MAX_EVENTS;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.MAX_IDLE_MS;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.PORT_NAME;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.SITE_ROLE_NULL;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.SITE_VPN_MISMATCH;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.TIMER;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.UNKNOWN_EVENT;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.VPN_ATTACHMENT_NULL;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.VPN_POLICY_NOT_SUPPORTED;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.VPN_TYPE_UNSUPPORTED;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.getBgpCreateConfigObj;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.getId;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.getIntCreateModObj;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.getIntNotAvailable;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.getModIdForL3VpnSvc;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.getModIdForSites;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.getResourceData;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.getRole;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.getVpnBgpDelModObj;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.getVpnCreateModObj;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.getVpnDelModObj;
-
-/**
- * The IETF net l3vpn manager implementation.
- */
-@Component(immediate = true)
-public class NetL3VpnManager {
-
- private static final String APP_ID = "org.onosproject.app.l3vpn";
- private static final String L3_VPN_ID_TOPIC = "l3vpn-id";
- private static final String TNL_ID_TOPIC = "l3vpn-tnl-id";
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private final DynamicConfigListener configListener =
- new InternalConfigListener();
-
- private final Accumulator<DynamicConfigEvent> accumulator =
- new InternalEventAccumulator();
-
- private final InternalLeadershipListener leadershipEventListener =
- new InternalLeadershipListener();
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DriverService driverService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceService deviceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected ModelConverter modelConverter;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DynamicConfigService configService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetL3VpnStore l3VpnStore;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LeadershipService leadershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected ClusterService clusterService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PceService pceService;
-
- protected IdGenerator l3VpnIdGen;
-
- protected IdGenerator tnlIdGen;
-
- private NodeId localNodeId;
-
- private ApplicationId appId;
-
- private ResourceId id;
-
- private ResourceId module;
-
- private ResourceId sites;
-
- private boolean isElectedLeader;
-
- private NetL3VpnTunnelHandler tnlHandler;
-
- @Activate
- protected void activate() {
- appId = coreService.registerApplication(APP_ID);
- l3VpnIdGen = coreService.getIdGenerator(L3_VPN_ID_TOPIC);
- tnlIdGen = coreService.getIdGenerator(TNL_ID_TOPIC);
- localNodeId = clusterService.getLocalNode().id();
- leadershipService.addListener(leadershipEventListener);
- leadershipService.runForLeadership(appId.name());
- getResourceId();
- configService.addListener(configListener);
- tnlHandler = new NetL3VpnTunnelHandler(
- pceService, driverService, configService, l3VpnStore,
- deviceService, tnlIdGen, modelConverter);
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- configService.removeListener(configListener);
- leadershipService.withdraw(appId.name());
- leadershipService.removeListener(leadershipEventListener);
- log.info("Stopped");
- }
-
- /**
- * Returns id as string. If the id is not in the freed list a new id is
- * generated else the id from the freed list is used.
- *
- * @return id
- */
- private String getIdFromGen() {
- Long value;
- Iterable<Long> freeIds = l3VpnStore.getFreedIdList();
- Iterator<Long> it = freeIds.iterator();
- if (it.hasNext()) {
- value = it.next();
- l3VpnStore.removeIdFromFreeList(value);
- } else {
- value = l3VpnIdGen.getNewId();
- }
- if (value > ID_LIMIT) {
- throw new IllegalStateException(ID_LIMIT_EXCEEDED);
- }
- return CONS_HUNDRED + String.valueOf(value);
- }
-
- /**
- * Returns the resource id, after constructing model object id and
- * converting it.
- */
- private void getResourceId() {
-
- ModelObjectId moduleId = ModelObjectId.builder().build();
- module = getResourceVal(moduleId);
-
- ModelObjectId svcId = getModIdForL3VpnSvc();
- id = getResourceVal(svcId);
-
- ModelObjectId sitesId = getModIdForSites();
- sites = getResourceVal(sitesId);
- }
-
- /**
- * Returns resource id from model converter.
- *
- * @param modelId model object id
- * @return resource id
- */
- private ResourceId getResourceVal(ModelObjectId modelId) {
- DefaultModelObjectData.Builder data = DefaultModelObjectData.builder()
- .identifier(modelId);
- ResourceData resData = modelConverter.createDataNode(data.build());
- return resData.resourceId();
- }
-
- /**
- * Processes create request from the store, by taking the root object.
- * The root object is then used for l3VPN processing.
- *
- * @param storeId store resource id
- * @param node data node
- */
- private void processCreateFromStore(ResourceId storeId, DataNode node) {
- if (isElectedLeader) {
- List<NodeKey> keys = storeId.nodeKeys();
- List<ModelObject> objects = null;
- if (keys.size() == 1) {
- objects = getModelObjects(node, module);
- } else if (keys.size() == 2) {
- objects = getModelObjects(node, id);
- }
- if (objects != null) {
- for (ModelObject obj : objects) {
- if (obj instanceof DefaultL3VpnSvc) {
- DefaultL3VpnSvc l3VpnSvc = (DefaultL3VpnSvc) obj;
- createGlobalConfig(l3VpnSvc);
- } else if (obj instanceof DefaultSites) {
- DefaultSites sites = (DefaultSites) obj;
- createInterfaceConfig(sites);
- }
- }
- }
- }
- }
-
- /**
- * Processes delete request from the store, by taking the root object.
- * The root object would have got deleted from store. So all the
- * configurations are removed.
- *
- * @param dataNode data node
- */
- private void processDeleteFromStore(DataNode dataNode) {
- if (isElectedLeader) {
- if (dataNode == null) {
- //TODO: Delete for inner nodes.
- deleteGlobalConfig(null);
- }
- }
- }
-
- /**
- * Returns model objects of the store. The data node read from store
- * gives the particular node. So the node's parent resource id is taken
- * and the data node is given to model converter.
- *
- * @param dataNode data node from store
- * @param appId parent resource id
- * @return model objects
- */
- public List<ModelObject> getModelObjects(DataNode dataNode,
- ResourceId appId) {
- ResourceData data = getResourceData(dataNode, appId);
- ModelObjectData modelData = modelConverter.createModel(data);
- return modelData.modelObjects();
- }
-
- /**
- * Returns true if the event resource id points to the root level node
- * only and event is for addition and deletion; false otherwise.
- *
- * @param event config event
- * @return true if event is supported; false otherwise
- */
- public boolean isSupported(DynamicConfigEvent event) {
- ResourceId rsId = event.subject();
- List<NodeKey> storeKeys = rsId.nodeKeys();
- List<NodeKey> regKeys = id.nodeKeys();
- List<NodeKey> sitesKeys = sites.nodeKeys();
- if (storeKeys != null) {
- int storeSize = storeKeys.size();
- if (storeSize == 1) {
- return storeKeys.get(0).equals(regKeys.get(1)) &&
- (event.type() == NODE_ADDED ||
- event.type() == NODE_DELETED);
- } else if (storeSize == 2) {
- return (storeKeys.get(0).equals(sitesKeys.get(1))) &&
- storeKeys.get(1).equals(sitesKeys.get(2)) &&
- (event.type() == NODE_ADDED ||
- event.type() == NODE_DELETED);
- }
- }
- return false;
- }
-
- /***
- * Creates all configuration in the standard device model.
- *
- * @param l3VpnSvc l3VPN service object
- */
- void createGlobalConfig(L3VpnSvc l3VpnSvc) {
- if (l3VpnSvc.vpnServices() != null) {
- createVpnServices(l3VpnSvc.vpnServices());
- }
- if (l3VpnSvc.sites() != null) {
- createInterfaceConfig(l3VpnSvc.sites());
- }
- }
-
- /**
- * Creates the VPN instances from the VPN services object, if only that
- * VPN instance is not already created.
- *
- * @param vpnSvcs VPN services object
- */
- private void createVpnServices(VpnServices vpnSvcs) {
- if (vpnSvcs != null && vpnSvcs.vpnSvc() != null) {
- List<VpnSvc> svcList = vpnSvcs.vpnSvc();
- for (VpnSvc svc : svcList) {
- String vpnName = svc.vpnId().string();
- l3VpnStore.addVpnInsIfAbsent(vpnName, new VpnInstance(vpnName));
- }
- }
- }
-
- /**
- * Creates interface configuration from the site network access if
- * available.
- *
- * @param sites sites object
- */
- private void createInterfaceConfig(Sites sites) {
- if (sites.site() != null) {
- List<Site> sitesList = sites.site();
- for (Site site : sitesList) {
- if (site.siteNetworkAccesses() != null) {
- SiteNetworkAccesses accesses = site.siteNetworkAccesses();
- List<SiteNetworkAccess> accessList =
- accesses.siteNetworkAccess();
- for (SiteNetworkAccess access : accessList) {
- createFromAccess(access, site.siteId().string());
- }
- }
- }
- }
- }
-
- /**
- * Creates the interface and VPN related configurations from the access
- * and site id value.
- *
- * @param access site network access
- * @param siteId site id
- */
- private void createFromAccess(SiteNetworkAccess access, String siteId) {
- Map<AccessInfo, InterfaceInfo> intMap = l3VpnStore.getInterfaceInfo();
- Map<String, VpnInstance> insMap = l3VpnStore.getVpnInstances();
- String accessId = access.siteNetworkAccessId().string();
- AccessInfo info = new AccessInfo(siteId, accessId);
-
- if (intMap.get(info) == null) {
- VpnSiteRole siteRole = getSiteRole(access.vpnAttachment());
- VpnInstance instance = insMap.get(siteRole.name());
- if (instance == null) {
- throw new NetL3VpnException(SITE_VPN_MISMATCH);
- }
- buildFromAccess(instance, info, access, siteRole);
- }
- }
-
- /**
- * Returns the VPN site role from the VPN attachment.
- *
- * @param attach VPN attachment
- * @return VPN site role
- */
- private VpnSiteRole getSiteRole(VpnAttachment attach) {
- if (attach == null || attach.attachmentFlavor() == null) {
- throw new NetL3VpnException(VPN_ATTACHMENT_NULL);
- }
- AttachmentFlavor flavor = attach.attachmentFlavor();
- if (!(flavor instanceof DefaultVpnId)) {
- throw new NetL3VpnException(VPN_POLICY_NOT_SUPPORTED);
- }
- DefaultVpnId vpnId = (DefaultVpnId) flavor;
- if (vpnId.siteRole() == null) {
- throw new NetL3VpnException(SITE_ROLE_NULL);
- }
- VpnType role = getRole(vpnId.siteRole());
- return new VpnSiteRole(String.valueOf(vpnId.vpnId()), role);
- }
-
- /**
- * Builds the required details for device standard model from the site
- * network access info available.
- *
- * @param instance VPN instance
- * @param info access info
- * @param access network access
- * @param role VPN site role
- */
- private void buildFromAccess(VpnInstance instance, AccessInfo info,
- SiteNetworkAccess access, VpnSiteRole role) {
- Bearer bearer = access.bearer();
- if (bearer == null) {
- throw new NetL3VpnException(BEARER_NULL);
- }
-
- RequestedType reqType = bearer.requestedType();
- IpConnection connect = access.ipConnection();
- RoutingProtocols pro = access.routingProtocols();
-
- if (reqType == null || connect == null) {
- throw new NetL3VpnException(IP_INT_INFO_NULL);
- }
- buildDeviceDetails(instance, info, role, bearer, connect,
- reqType, pro);
- }
-
- /**
- * Builds the device details such as, VPN instance value if it is for
- * the first time, interface values and BGP info if available in service.
- *
- * @param instance VPN instance
- * @param accInfo access info
- * @param role VPN site role
- * @param bearer bearer object
- * @param connect ip connect object
- * @param reqType requested type
- * @param pro routing protocol
- */
- private void buildDeviceDetails(VpnInstance instance, AccessInfo accInfo,
- VpnSiteRole role, Bearer bearer,
- IpConnection connect, RequestedType reqType,
- RoutingProtocols pro) {
- Map<AccessInfo, InterfaceInfo> interMap = l3VpnStore.getInterfaceInfo();
- InterfaceInfo intInfo = interMap.get(accInfo);
- if (intInfo != null) {
- return;
- }
-
- DeviceInfo info = buildDevVpnIns(bearer, instance, role, connect);
- String portName = getInterfaceName(info, reqType);
- buildDevVpnInt(info, instance, connect, portName, accInfo);
-
- if (pro != null && pro.routingProtocol() != null) {
- buildBgpInfo(pro.routingProtocol(), info,
- role.name(), connect, accInfo);
- }
- InterfaceInfo interInfo = new InterfaceInfo(info, portName,
- instance.vpnName());
- l3VpnStore.addInterfaceInfo(accInfo, interInfo);
- l3VpnStore.addVpnIns(instance.vpnName(), instance);
- }
-
- /**
- * Builds device VPN instance with the service objects. It returns
- *
- * @param bearer bearer object
- * @param ins VPN instance
- * @param role VPN site role
- * @param connect ip connection
- * @return return
- */
- private DeviceInfo buildDevVpnIns(Bearer bearer, VpnInstance ins,
- VpnSiteRole role, IpConnection connect) {
- DefaultAugmentedL3VpnBearer augBearer = bearer.augmentation(
- DefaultAugmentedL3VpnBearer.class);
- DeviceId id = getDeviceId(augBearer);
- Map<DeviceId, DeviceInfo> devices = ins.devInfo();
- DeviceInfo info = null;
- if (devices != null) {
- info = devices.get(id);
- }
- if (info == null) {
- info = createVpnInstance(id, role, ins, connect);
- }
- return info;
- }
-
- /**
- * Returns the device id from the bearer augment attachment of service.
- * If the attachment in augment is not available it throws error.
- *
- * @param attach augmented bearer
- * @return device id
- */
- private DeviceId getDeviceId(DefaultAugmentedL3VpnBearer attach) {
- if (attach == null || attach.bearerAttachment() == null ||
- attach.bearerAttachment().peMgmtIp() == null ||
- attach.bearerAttachment().peMgmtIp().string() == null) {
- throw new NetL3VpnException(DEVICE_INFO_NULL);
- }
- String ip = attach.bearerAttachment().peMgmtIp().string();
- return getId(ip, true, deviceService.getAvailableDevices());
- }
-
- /**
- * Creates the VPN instance by constructing standard device model of
- * instances. It adds the RD and RT values to the VPN instance.
- *
- * @param id device id
- * @param role VPN site role
- * @param inst VPN instance
- * @param ip ip connection
- * @return device info
- */
- private DeviceInfo createVpnInstance(DeviceId id, VpnSiteRole role,
- VpnInstance inst, IpConnection ip) {
- Map<AccessInfo, InterfaceInfo> intMap = l3VpnStore.getInterfaceInfo();
- generateRdRt(inst, role);
- DeviceInfo info = new DeviceInfo(id, role.role());
-
- NetworkInstances instances = createInstance(inst, role, ip);
- ModelObjectData devMod = getVpnCreateModObj(intMap, instances,
- id.toString());
- inst.addDevInfo(id, info);
- l3VpnStore.addVpnIns(inst.vpnName(), inst);
-
- ModelObjectData driMod = info.processCreateInstance(driverService,
- devMod);
- ResourceData resData = modelConverter.createDataNode(driMod);
- addToStore(resData);
- // TODO: Enable tunnel creation on-demand. Uncomment below after
- // complete validation
- //checkAndUpdateTunnel(inst, id);
- return info;
- }
-
- /**
- * Checks if the tunnel can be established and creates the tunnel from
- * source to destination.
- *
- * @param inst VPN instance
- * @param id device id
- */
- private void checkAndUpdateTunnel(VpnInstance inst, DeviceId id) {
- Map<DeviceId, DeviceInfo> devInfo = inst.devInfo();
- int devSize = devInfo.size();
- String vpnName = inst.vpnName();
- if (devSize != 1) {
- DeviceInfo info = devInfo.get(id);
- tnlHandler.createSrcInfo(vpnName, info);
- for (Map.Entry<DeviceId, DeviceInfo> device : devInfo.entrySet()) {
- DeviceInfo val = device.getValue();
- if (val != info) {
- tnlHandler.createSrcDesTunnel(val);
- }
- }
- }
- }
-
- /**
- * Adds the resource data that is received from the driver, after
- * converting from the model object data.
- *
- * @param resData resource data
- */
- private void addToStore(ResourceData resData) {
- if (resData != null && resData.dataNodes() != null) {
- List<DataNode> dataNodes = resData.dataNodes();
- for (DataNode node : dataNodes) {
- configService.createNode(resData.resourceId(), node);
- }
- }
- }
-
- /**
- * Generates RD and RT value for the VPN instance for the first time VPN
- * instance creation.
- *
- * @param ins VPN instance
- * @param role VPN site role
- */
- private void generateRdRt(VpnInstance ins, VpnSiteRole role) {
- ins.type(role.role());
- VpnConfig config = ins.vpnConfig();
- String rd = null;
- if (config == null) {
- rd = getIdFromGen();
- }
- switch (ins.type()) {
- case ANY_TO_ANY:
- if (config == null) {
- config = new FullMeshVpnConfig(rd);
- config.rd(rd);
- }
- break;
-
- case HUB:
- case SPOKE:
- if (config == null) {
- config = new HubSpokeVpnConfig();
- config.rd(rd);
- }
- createImpRtVal((HubSpokeVpnConfig) config, ins.type());
- createExpRtVal((HubSpokeVpnConfig) config, ins.type());
- break;
-
- default:
- throw new NetL3VpnException(VPN_TYPE_UNSUPPORTED);
- }
- ins.vpnConfig(config);
- }
-
- /**
- * Creates import RT value for HUB and SPOKE, according to the type, if
- * the values are not present.
- *
- * @param config VPN config
- * @param type VPN type
- */
- private void createImpRtVal(HubSpokeVpnConfig config, VpnType type) {
- if (type == HUB) {
- if (config.hubImpRt() != null) {
- return;
- }
- setHubImpRt(config);
- } else {
- if (config.spokeImpRt() != null) {
- return;
- }
- config.spokeImpRt(config.rd());
- }
- }
-
- /**
- * Sets the HUB import RT, from the spoke export RT. If it is not
- * available a new ID is generated.
- *
- * @param config VPN config
- */
- public void setHubImpRt(HubSpokeVpnConfig config) {
- String hubImp;
- if (config.spokeExpRt() != null) {
- hubImp = config.spokeExpRt();
- } else {
- hubImp = getIdFromGen();
- }
- config.hubImpRt(hubImp);
- }
-
- /**
- * Creates export RT value for HUB and SPOKE, according to the type, if
- * the values are not present.
- *
- * @param config VPN config
- * @param type VPN type
- */
- private void createExpRtVal(HubSpokeVpnConfig config, VpnType type) {
- if (type == HUB) {
- if (config.hubExpRt() != null) {
- return;
- }
- config.hubExpRt(config.rd());
- } else {
- if (config.spokeExpRt() != null) {
- return;
- }
- setSpokeExpRt(config);
- }
- }
-
- /**
- * Sets the SPOKE export RT, from the hub import RT. If it is not
- * available a new ID is generated.
- *
- * @param config VPN config
- */
- public void setSpokeExpRt(HubSpokeVpnConfig config) {
- String spokeExp;
- if (config.hubImpRt() != null) {
- spokeExp = config.hubImpRt();
- } else {
- spokeExp = getIdFromGen();
- }
- config.spokeExpRt(spokeExp);
- }
-
- /**
- * Returns the interface name from the requested type service object.
- *
- * @param info device info
- * @param reqType requested type
- * @return interface name
- */
- private String getInterfaceName(DeviceInfo info, RequestedType reqType) {
- DefaultAugmentedL3VpnRequestedType req = reqType.augmentation(
- DefaultAugmentedL3VpnRequestedType.class);
- if (req == null || req.requestedTypeProfile() == null ||
- req.requestedTypeProfile().requestedTypeChoice() == null) {
- throw new NetL3VpnException(INT_INFO_NULL);
- }
- RequestedTypeChoice reqChoice = req.requestedTypeProfile()
- .requestedTypeChoice();
- return getNameFromChoice(reqChoice, info.deviceId());
- }
-
- /**
- * Returns the interface name from the type choice provided.
- *
- * @param choice service choice
- * @param id device id
- * @return interface name
- */
- private String getNameFromChoice(RequestedTypeChoice choice, DeviceId id) {
- if (choice == null) {
- throw new NetL3VpnException(INT_INFO_NULL);
- }
- String intName;
- if (choice instanceof DefaultDot1Qcase) {
- if (((DefaultDot1Qcase) choice).dot1q() == null ||
- ((DefaultDot1Qcase) choice).dot1q()
- .physicalIf() == null) {
- throw new NetL3VpnException(INT_INFO_NULL);
- }
- intName = ((DefaultDot1Qcase) choice).dot1q().physicalIf();
- } else {
- if (((DefaultPhysicalCase) choice).physical() == null ||
- ((DefaultPhysicalCase) choice).physical()
- .physicalIf() == null) {
- throw new NetL3VpnException(INT_INFO_NULL);
- }
- intName = ((DefaultPhysicalCase) choice).physical().physicalIf();
- }
- return getPortName(intName, id);
- }
-
- /**
- * Returns the port name when it the port is available in the device.
- *
- * @param intName interface name
- * @param id device id
- * @return port name
- */
- private String getPortName(String intName, DeviceId id) {
- List<Port> ports = deviceService.getPorts(id);
- for (Port port : ports) {
- String pName = port.annotations().value(PORT_NAME);
- if (pName.equals(intName)) {
- return intName;
- }
- }
- throw new NetL3VpnException(getIntNotAvailable(intName));
- }
-
- /**
- * Builds the interface for the device binding with the VPN instance.
- *
- * @param info device info
- * @param ins VPN instance
- * @param connect IP connection
- * @param pName port name
- * @param access access info
- */
- private void buildDevVpnInt(DeviceInfo info, VpnInstance ins,
- IpConnection connect, String pName,
- AccessInfo access) {
- Map<AccessInfo, InterfaceInfo> intMap = l3VpnStore.getInterfaceInfo();
- info.addAccessInfo(access);
- info.addIfName(pName);
- Interfaces interfaces = createInterface(pName, ins.vpnName(),
- connect);
- ModelObjectData devMod = getIntCreateModObj(
- info.ifNames(), interfaces, info.deviceId().toString());
- ModelObjectData driMod = info.processCreateInterface(driverService,
- devMod);
- ResourceData resData = modelConverter.createDataNode(driMod);
- addToStore(resData);
- }
-
- /**
- * Builds the BGP information from the routes that are given from the
- * service.
- *
- * @param routes routing protocol
- * @param info device info
- * @param name VPN name
- * @param connect IP connection
- * @param access access info
- */
- private void buildBgpInfo(List<RoutingProtocol> routes, DeviceInfo info,
- String name, IpConnection connect,
- AccessInfo access) {
- Map<BgpInfo, DeviceId> bgpMap = l3VpnStore.getBgpInfo();
- BgpInfo intBgp = createBgpInfo(routes, info, name, connect, access);
- if (intBgp != null) {
- intBgp.vpnName(name);
- BgpDriverInfo config = getBgpCreateConfigObj(
- bgpMap, info.deviceId().toString(), info.bgpInfo(), intBgp);
- ModelObjectData driData = info.processCreateBgpInfo(
- driverService, intBgp, config);
- l3VpnStore.addBgpInfo(info.bgpInfo(), info.deviceId());
- ResourceData resData = modelConverter.createDataNode(driData);
- addToStore(resData);
- }
- }
-
- /**
- * Creates all configuration in the standard device model.
- *
- * @param l3VpnSvc l3 VPN service
- */
- void deleteGlobalConfig(L3VpnSvc l3VpnSvc) {
- deleteGlobalVpn(l3VpnSvc);
- //TODO: Site and access deletion needs to be added.
- }
-
- /**
- * Deletes the global VPN from the device model and delete from the device.
- *
- * @param l3VpnSvc L3 VPN service
- */
- private void deleteGlobalVpn(L3VpnSvc l3VpnSvc) {
- Map<String, VpnInstance> insMap = l3VpnStore.getVpnInstances();
- //TODO: check for VPN delete deleting interface from store.
- if (l3VpnSvc == null || l3VpnSvc.vpnServices() == null ||
- l3VpnSvc.vpnServices().vpnSvc() == null) {
- for (Map.Entry<String, VpnInstance> vpnMap : insMap.entrySet()) {
- deleteVpnInstance(vpnMap.getValue(), false);
- }
- return;
- }
- List<VpnSvc> vpnList = l3VpnSvc.vpnServices().vpnSvc();
- for (Map.Entry<String, VpnInstance> vpnMap : insMap.entrySet()) {
- boolean isPresent = isVpnPresent(vpnMap.getKey(), vpnList);
- if (!isPresent) {
- deleteVpnInstance(vpnMap.getValue(), false);
- }
- }
- }
-
- /**
- * Returns true if the VPN in the distributed map is also present in the
- * service; false otherwise.
- *
- * @param vpnName VPN name from store
- * @param vpnList VPN list from service
- * @return true if VPN available; false otherwise
- */
- private boolean isVpnPresent(String vpnName, List<VpnSvc> vpnList) {
- for (VpnSvc svc : vpnList) {
- if (svc.vpnId().string().equals(vpnName)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Deletes the VPN instance by constructing standard device model of
- * instances.
- *
- * @param instance VPN instance
- * @param isIntDeleted if interface already removed.
- */
- private void deleteVpnInstance(VpnInstance instance, boolean isIntDeleted) {
- Map<DeviceId, DeviceInfo> devices = instance.devInfo();
- if (devices != null) {
- for (Map.Entry<DeviceId, DeviceInfo> device : devices.entrySet()) {
- NetworkInstances ins = deleteInstance(instance.vpnName());
- DeviceInfo dev = device.getValue();
- if (!isIntDeleted) {
- remVpnBgp(dev);
- remInterfaceFromMap(dev);
- }
- Map<AccessInfo, InterfaceInfo> intMap =
- l3VpnStore.getInterfaceInfo();
- String id = dev.deviceId().toString();
- ModelObjectData devMod = getVpnDelModObj(intMap, ins, id);
- ModelObjectData driMod = dev.processDeleteInstance(
- driverService, devMod);
- ResourceData resData = modelConverter.createDataNode(driMod);
- deleteFromStore(resData);
- // TODO: Enable tunnel creation on-demand. Uncomment below after
- // complete validation
- // tnlHandler.deleteTunnel(dev, instance.vpnName());
- }
- l3VpnStore.removeVpnInstance(instance.vpnName());
- }
- }
-
- /**
- * Removes the BGP information for that complete VPN instance.
- *
- * @param dev device info
- */
- private void remVpnBgp(DeviceInfo dev) {
- BgpInfo devBgp = dev.bgpInfo();
- if (devBgp != null) {
- l3VpnStore.removeBgpInfo(devBgp);
- BgpInfo delInfo = new BgpInfo();
- delInfo.vpnName(devBgp.vpnName());
- String id = dev.deviceId().toString();
- Map<BgpInfo, DeviceId> bgpMap = l3VpnStore.getBgpInfo();
- BgpDriverInfo driConfig = getVpnBgpDelModObj(bgpMap, id);
- ModelObjectData driData = dev.processDeleteBgpInfo(
- driverService, delInfo, driConfig);
- ResourceData resData = modelConverter.createDataNode(driData);
- deleteFromStore(resData);
- l3VpnStore.removeBgpInfo(devBgp);
- }
- }
-
- /**
- * Deletes the resource data that is received from the driver, after
- * converting from the model object data.
- *
- * @param resData resource data
- */
- private void deleteFromStore(ResourceData resData) {
- if (resData != null) {
- configService.deleteNode(resData.resourceId());
- }
- }
-
- /**
- * Removes the interface from the app distributed map, if the driver
- * interfaces are already removed from the store.
- *
- * @param deviceInfo device info
- */
- private void remInterfaceFromMap(DeviceInfo deviceInfo) {
- List<AccessInfo> accesses = deviceInfo.accesses();
- if (accesses != null) {
- for (AccessInfo access : accesses) {
- l3VpnStore.removeInterfaceInfo(access);
- }
- }
- deviceInfo.ifNames(null);
- deviceInfo.accesses(null);
- }
-
- /**
- * Signals that the leadership has changed.
- *
- * @param isLeader true if this instance is now the leader, otherwise false
- */
- private void leaderChanged(boolean isLeader) {
- log.debug("Leader changed: {}", isLeader);
- isElectedLeader = isLeader;
- }
-
- /**
- * Representation of internal listener, listening for dynamic config event.
- */
- private class InternalConfigListener implements DynamicConfigListener {
-
- @Override
- public boolean isRelevant(DynamicConfigEvent event) {
- return isSupported(event);
- }
-
- @Override
- public void event(DynamicConfigEvent event) {
- accumulator.add(event);
- }
- }
-
- /**
- * Accumulates events to allow processing after a desired number of
- * events were accumulated.
- */
- private class InternalEventAccumulator extends
- AbstractAccumulator<DynamicConfigEvent> {
-
- /**
- * Constructs the event accumulator with timer and event limit.
- */
- protected InternalEventAccumulator() {
- super(new Timer(TIMER), MAX_EVENTS, MAX_BATCH_MS, MAX_IDLE_MS);
- }
-
- @Override
- public void processItems(List<DynamicConfigEvent> events) {
- for (DynamicConfigEvent event : events) {
- checkNotNull(event, EVENT_NULL);
- Filter filter = Filter.builder().build();
- DataNode node;
- try {
- node = configService.readNode(event.subject(), filter);
- } catch (FailedException e) {
- node = null;
- }
- switch (event.type()) {
- case NODE_ADDED:
- processCreateFromStore(event.subject(), node);
- break;
-
- case NODE_DELETED:
- processDeleteFromStore(node);
- break;
-
- default:
- log.warn(UNKNOWN_EVENT, event.type());
- break;
- }
- }
- }
- }
-
- /**
- * A listener for leadership events.
- */
- private class InternalLeadershipListener implements LeadershipEventListener {
-
- @Override
- public boolean isRelevant(LeadershipEvent event) {
- return event.subject().topic().equals(appId.name());
- }
-
- @Override
- public void event(LeadershipEvent event) {
- switch (event.type()) {
- case LEADER_CHANGED:
- case LEADER_AND_CANDIDATES_CHANGED:
- if (localNodeId.equals(event.subject().leaderNodeId())) {
- log.info("Net l3vpn manager gained leadership");
- leaderChanged(true);
- } else {
- log.info("Net l3vpn manager leader changed. New " +
- "leader is {}", event.subject()
- .leaderNodeId());
- leaderChanged(false);
- }
- break;
- default:
- break;
- }
- }
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/NetL3VpnTunnelHandler.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/NetL3VpnTunnelHandler.java
deleted file mode 100644
index edef00a..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/NetL3VpnTunnelHandler.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn.impl;
-
-import org.onosproject.config.DynamicConfigService;
-import org.onosproject.core.IdGenerator;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.l3vpn.netl3vpn.DeviceInfo;
-import org.onosproject.l3vpn.netl3vpn.ModelIdLevel;
-import org.onosproject.l3vpn.netl3vpn.NetL3VpnException;
-import org.onosproject.l3vpn.netl3vpn.NetL3VpnStore;
-import org.onosproject.l3vpn.netl3vpn.TunnelInfo;
-import org.onosproject.l3vpn.netl3vpn.VpnType;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.pce.pceservice.api.PceService;
-import org.onosproject.yang.model.DataNode;
-import org.onosproject.yang.model.ModelConverter;
-import org.onosproject.yang.model.ModelObjectData;
-import org.onosproject.yang.model.ResourceData;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.onosproject.l3vpn.netl3vpn.ModelIdLevel.DEVICE;
-import static org.onosproject.l3vpn.netl3vpn.ModelIdLevel.DEVICES;
-import static org.onosproject.l3vpn.netl3vpn.ModelIdLevel.TNL_M;
-import static org.onosproject.l3vpn.netl3vpn.ModelIdLevel.TNL_POL;
-import static org.onosproject.l3vpn.netl3vpn.ModelIdLevel.TP_HOP;
-import static org.onosproject.l3vpn.netl3vpn.VpnType.SPOKE;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.NEW_NAME;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.getId;
-import static org.onosproject.l3vpn.netl3vpn.impl.NetL3VpnUtil.getIpFromDevId;
-import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING;
-
-/**
- * Represents net l3VPN tunnel handler, which handles tunnel operations like
- * creation and deletion and updating it to the driver.
- */
-public class NetL3VpnTunnelHandler {
-
- private PceService pceSvc;
- private DriverService driSvc;
- private DynamicConfigService configSvc;
- private NetL3VpnStore store;
- private DeviceService devSvc;
- private IdGenerator tnlIdGen;
- private ModelConverter modelCon;
- private String sIp;
- private String vpnName;
- private DeviceInfo sInfo;
- private VpnType type;
-
- /**
- * Constructs net l3VPN tunnel handler with required services.
- *
- * @param p pce service
- * @param d driver service
- * @param c dynamic config service
- * @param s net l3VPN store
- * @param dev device service
- * @param id ID generator
- * @param m model converter
- */
- public NetL3VpnTunnelHandler(PceService p, DriverService d,
- DynamicConfigService c,
- NetL3VpnStore s, DeviceService dev,
- IdGenerator id, ModelConverter m) {
- pceSvc = p;
- driSvc = d;
- configSvc = c;
- store = s;
- devSvc = dev;
- tnlIdGen = id;
- modelCon = m;
- }
-
- /**
- * Creates the source information for tunnel creation. It creates from
- * source device info and VPN name.
- *
- * @param vName VPN name
- * @param devInfo device info
- */
- public void createSrcInfo(String vName, DeviceInfo devInfo) {
- vpnName = vName;
- sInfo = devInfo;
- type = devInfo.type();
- sIp = getIpFromDevId(sInfo.deviceId());
- }
-
- /**
- * Creates tunnel between source and destination devices.
- *
- * @param dInfo destination device
- */
- public void createSrcDesTunnel(DeviceInfo dInfo) {
- VpnType dType = dInfo.type();
- if (type == SPOKE && dType == SPOKE) {
- return;
- }
- String dIp = getIpFromDevId(dInfo.deviceId());
- createTunnelInfo(sIp, dIp, sInfo);
- createTunnelInfo(dIp, sIp, dInfo);
- }
-
- /**
- * Creates tunnel info and tunnel based on source and destination ip
- * address and configures it in the source device.
- *
- * @param sIp source ip address
- * @param dIp destination ip address
- * @param sInfo source device info
- */
- private void createTunnelInfo(String sIp, String dIp, DeviceInfo sInfo) {
- DeviceId id = sInfo.deviceId();
- Map<DeviceId, Integer> tnlMap = store.getTunnelInfo();
- int count = 0;
- if (tnlMap.containsKey(id)) {
- count = tnlMap.get(id);
- }
- String tnlName = createTunnel(sIp, dIp);
- sInfo.addTnlName(tnlName);
- store.addTunnelInfo(id, count + 1);
- TunnelInfo tnl = new TunnelInfo(dIp, tnlName, vpnName, id.toString());
- configureDevTnl(sInfo, tnl, tnlMap);
- }
-
- /**
- * Creates tunnel between source ip address and destination ip address
- * with pce service.
- *
- * @param srcIp source ip address
- * @param desIp destination ip address
- * @return tunnel name
- */
- private String createTunnel(String srcIp, String desIp) {
- Iterable<Device> devices = devSvc.getAvailableDevices();
- DeviceId srcDevId = getId(srcIp, false, devices);
- DeviceId desDevId = getId(desIp, false, devices);
- String name = getNewName();
- boolean isCreated = pceSvc.setupPath(srcDevId, desDevId, name,
- null, WITH_SIGNALLING);
- if (!isCreated) {
- throw new NetL3VpnException("Tunnel is not created between " +
- srcDevId.toString() + " and " +
- desDevId.toString());
- }
- return name;
- }
-
- /**
- * Returns a unique name for tunnel to be created.
- *
- * @return unique tunnel name
- */
- private String getNewName() {
- return NEW_NAME + String.valueOf(tnlIdGen.getNewId());
- }
-
- /**
- * Configures the created tunnel to the device by processing it at the
- * proper level and sending it to the driver.
- *
- * @param info source device info
- * @param tnlInfo tunnel info
- * @param tnlMap store tunnel map
- */
- private void configureDevTnl(DeviceInfo info, TunnelInfo tnlInfo,
- Map<DeviceId, Integer> tnlMap) {
- DeviceId id = info.deviceId();
- int count = 0;
- if (tnlMap.containsKey(id)) {
- count = tnlMap.get(id);
- }
- if (tnlMap.size() == 0) {
- tnlInfo.level(DEVICES);
- } else if (count == 0) {
- tnlInfo.level(DEVICE);
- }
-
- if (tnlInfo.level() != null) {
- ModelObjectData mod = info.processCreateTnlDev(driSvc, tnlInfo);
- addDataNodeToStore(mod);
- tnlInfo.level(TNL_M);
- tnlPolToStore(info, tnlInfo);
- }
- if (!info.isTnlPolCreated()) {
- tnlInfo.level(TNL_POL);
- tnlPolToStore(info, tnlInfo);
- }
- if (tnlInfo.level() == null) {
- tnlInfo.level(TP_HOP);
- }
-
- ModelObjectData tnlMod = info.processCreateTnl(driSvc, tnlInfo);
- addDataNodeToStore(tnlMod);
- if (tnlInfo.level() != TP_HOP) {
- ModelObjectData mod = info.processBindTnl(driSvc, tnlInfo);
- addDataNodeToStore(mod);
- }
- }
-
- /**
- * Adds data node to the store after converting it to the resource data.
- *
- * @param driMod driver model object data
- */
- private void addDataNodeToStore(ModelObjectData driMod) {
- ResourceData resData = modelCon.createDataNode(driMod);
- addToStore(resData);
- }
-
- /**
- * Adds resource data to the store.
- *
- * @param resData resource data
- */
- private void addToStore(ResourceData resData) {
- if (resData != null && resData.dataNodes() != null) {
- List<DataNode> dataNodes = resData.dataNodes();
- for (DataNode node : dataNodes) {
- configSvc.createNode(resData.resourceId(), node);
- }
- }
- }
-
- /**
- * Creates tunnel policy from driver and adds it to the store.
- *
- * @param info device info
- * @param tnlInfo tunnel info
- */
- private void tnlPolToStore(DeviceInfo info, TunnelInfo tnlInfo) {
- ModelObjectData mod = info.processCreateTnlPol(driSvc, tnlInfo);
- addDataNodeToStore(mod);
- info.setTnlPolCreated(true);
- }
-
- /**
- * Deletes the tunnel with the source tunnel info and VPN name.
- * //FIXME: PCE does'nt have api, which can give tunnel by providing the
- * tunnel name.
- *
- * @param info device info
- * @param vName VPN name
- */
- public void deleteTunnel(DeviceInfo info, String vName) {
- List<String> tnlNames = info.tnlNames();
- for (String tnlName : tnlNames) {
- Iterable<Tunnel> path = pceSvc.queryAllPath();
- for (Tunnel tnl : path) {
- if (tnl.tunnelName().toString().equals(tnlName)) {
- pceSvc.releasePath(tnl.tunnelId());
- break;
- }
- }
- }
- deleteFromDevice(info, vName);
- }
-
- /**
- * Deletes tunnel configuration from the device by updating various
- * levels in the store.
- *
- * @param info device info
- * @param vName VPN name
- */
- private void deleteFromDevice(DeviceInfo info, String vName) {
- Map<DeviceId, Integer> map = store.getTunnelInfo();
- DeviceId id = info.deviceId();
- Integer count = map.get(id);
- int tnlCount = info.tnlNames().size();
- int upCount = count - tnlCount;
- ModelIdLevel level;
- TunnelInfo tnlInfo = new TunnelInfo(null, null, vName, id.toString());
- if (upCount == 0) {
- if (map.size() == 1) {
- level = DEVICES;
- } else {
- level = DEVICE;
- }
- } else {
- if (map.size() > 1) {
- level = TNL_POL;
- } else {
- return;
- }
- }
- tnlInfo.level(level);
- ModelObjectData mod = info.processDeleteTnl(driSvc, tnlInfo);
- deleteFromStore(mod);
- info.tnlNames(null);
- info.setTnlPolCreated(false);
- if (upCount == 0) {
- store.removeTunnelInfo(id);
- } else {
- store.addTunnelInfo(id, upCount);
- }
- }
-
- /**
- * Deletes the data node from the store.
- *
- * @param mod driver model object data
- */
- private void deleteFromStore(ModelObjectData mod) {
- ResourceData resData = modelCon.createDataNode(mod);
- if (resData != null) {
- configSvc.deleteNode(resData.resourceId());
- }
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/NetL3VpnUtil.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/NetL3VpnUtil.java
deleted file mode 100644
index 1fd03bd..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/NetL3VpnUtil.java
+++ /dev/null
@@ -1,567 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.l3vpn.netl3vpn.impl;
-
-import org.onosproject.l3vpn.netl3vpn.AccessInfo;
-import org.onosproject.l3vpn.netl3vpn.BgpDriverInfo;
-import org.onosproject.l3vpn.netl3vpn.BgpInfo;
-import org.onosproject.l3vpn.netl3vpn.InterfaceInfo;
-import org.onosproject.l3vpn.netl3vpn.NetL3VpnException;
-import org.onosproject.l3vpn.netl3vpn.VpnType;
-import org.onosproject.net.DeviceId;
-import org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.ietfinterfaces.devices.device.Interfaces;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.DefaultL3VpnSvc;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.SiteRole;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.ietfl3vpnsvc.l3vpnsvc.DefaultSites;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.DefaultDevices;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.Devices;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.DefaultDevice;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.Device;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.DeviceKeys;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.device.NetworkInstances;
-import org.onosproject.yang.model.DataNode;
-import org.onosproject.yang.model.DefaultModelObjectData;
-import org.onosproject.yang.model.DefaultResourceData;
-import org.onosproject.yang.model.InnerModelObject;
-import org.onosproject.yang.model.ModelObjectData;
-import org.onosproject.yang.model.ModelObjectId;
-import org.onosproject.yang.model.ResourceData;
-import org.onosproject.yang.model.ResourceId;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import static org.onosproject.l3vpn.netl3vpn.ModelIdLevel.DEVICE;
-import static org.onosproject.l3vpn.netl3vpn.ModelIdLevel.DEVICES;
-import static org.onosproject.l3vpn.netl3vpn.ModelIdLevel.ROOT;
-import static org.onosproject.l3vpn.netl3vpn.ModelIdLevel.VPN;
-import static org.onosproject.l3vpn.netl3vpn.VpnType.ANY_TO_ANY;
-import static org.onosproject.l3vpn.netl3vpn.VpnType.HUB;
-import static org.onosproject.l3vpn.netl3vpn.VpnType.SPOKE;
-
-/**
- * Representation of utility for YANG tree builder.
- */
-public final class NetL3VpnUtil {
-
- /**
- * Error message for site VPN name being not present in global VPN.
- */
- static final String SITE_VPN_MISMATCH = "Site VPN instance name did not " +
- "match any of the global VPN names";
-
- /**
- * Error message for VPN attachment object being null.
- */
- static final String VPN_ATTACHMENT_NULL = "The VPN attachment information" +
- " cannot be null";
-
- /**
- * Error message for VPN policy being not supported.
- */
- static final String VPN_POLICY_NOT_SUPPORTED = "VPN policy implementation" +
- " is not supported.";
-
- /**
- * Static constant value for hundred.
- */
- static final String CONS_HUNDRED = "100:";
-
- /**
- * Error message for site role being not present in site network access.
- */
- static final String SITE_ROLE_NULL = "There must be a site role available" +
- " for the VPN in site network access.";
-
- /**
- * Error message for bearer object information being null.
- */
- static final String BEARER_NULL = "The bearer information of the access " +
- "is not available";
-
- /**
- * Error message for requested type or ip connect being null.
- */
- static final String IP_INT_INFO_NULL = "The required information of " +
- "request type or ip connection is not available";
-
- /**
- * Error message for device info being not available from augment.
- */
- static final String DEVICE_INFO_NULL = "Bearer of site does not have any " +
- "device information in the augment info.";
-
- /**
- * Static constant value for ip address.
- */
- static final String IP = "ipaddress";
-
- /**
- * Static constant value for lsr id.
- */
- static final String LSR_ID = "lsrId";
-
- /**
- * Error message for VPN type being not supported.
- */
- static final String VPN_TYPE_UNSUPPORTED = "The VPN type is not supported";
-
- /**
- * Error message when the generated ID has crossed the limit.
- */
- static final String ID_LIMIT_EXCEEDED = "The ID generation has got " +
- "exceeded";
-
- /**
- * Static constant value ID management limit.
- */
- static final Long ID_LIMIT = 4294967295L;
-
- /**
- * Error message for interface information being not available.
- */
- static final String INT_INFO_NULL = "Requested type does not have any " +
- "interface information in the augment info.";
-
- /**
- * Static constant value of port name.
- */
- static final String PORT_NAME = "portName";
-
- /**
- * Static constants to use with accumulator for maximum number of events.
- */
- static final int MAX_EVENTS = 1000;
-
- /**
- * Static constants to use with accumulator for maximum number of millis.
- */
- static final int MAX_BATCH_MS = 5000;
-
- /**
- * Static constants to use with accumulator for maximum number of idle
- * millis.
- */
- static final int MAX_IDLE_MS = 1000;
-
- /**
- * Static constants for timer name.
- */
- static final String TIMER = "dynamic-config-l3vpn-timer";
-
- /**
- * Error message for unknown event being occurred.
- */
- static final String UNKNOWN_EVENT = "NetL3VPN listener: unknown event: {}";
-
- /**
- * Error message for event being null.
- */
- static final String EVENT_NULL = "Event cannot be null";
-
- /**
- * Unique tunnel name for net-l3VPN.
- */
- static final String NEW_NAME = "onos-netl3vpn";
-
- private static final String SITE_ROLE_INVALID = "The given site role is " +
- "invalid";
- private static final String ANY_TO_ANY_ROLE = "AnyToAnyRole";
- private static final String HUB_ROLE = "HubRole";
- private static final String SPOKE_ROLE = "SpokeRole";
- private static final String COLON = ":";
-
- // No instantiation.
- private NetL3VpnUtil() {
- }
-
- /**
- * Returns the model object id for service L3VPN container.
- *
- * @return model object id
- */
- static ModelObjectId getModIdForL3VpnSvc() {
- return ModelObjectId.builder().addChild(DefaultL3VpnSvc.class).build();
- }
-
- /**
- * Returns the model object id for service sites container.
- *
- * @return model object id
- */
- static ModelObjectId getModIdForSites() {
- return ModelObjectId.builder().addChild(DefaultL3VpnSvc.class)
- .addChild(DefaultSites.class).build();
- }
-
- /**
- * Returns the resource data from the data node and the resource id.
- *
- * @param dataNode data node
- * @param resId resource id
- * @return resource data
- */
- static ResourceData getResourceData(DataNode dataNode, ResourceId resId) {
- return DefaultResourceData.builder().addDataNode(dataNode)
- .resourceId(resId).build();
- }
-
- /**
- * Returns the VPN role from the service site role.
- *
- * @param siteRole service site role
- * @return VPN type
- */
- static VpnType getRole(Class<? extends SiteRole> siteRole) {
- switch (siteRole.getSimpleName()) {
- case ANY_TO_ANY_ROLE:
- return ANY_TO_ANY;
-
- case HUB_ROLE:
- return HUB;
-
- case SPOKE_ROLE:
- return SPOKE;
-
- default:
- throw new NetL3VpnException(SITE_ROLE_INVALID);
- }
- }
-
- /**
- * Returns error message for management ip being unavailable in device.
- *
- * @param ip management ip
- * @return error message
- */
- static String getMgmtIpUnAvailErr(String ip) {
- return "The device with management ip " + ip + " is not available.";
- }
-
- /**
- * Returns true if device id present in the interface map; false otherwise.
- *
- * @param info interface map
- * @param id device id
- * @return true if device id available; false otherwise
- */
- private static boolean isDevIdPresent(Map<AccessInfo, InterfaceInfo> info,
- String id) {
- for (Map.Entry<AccessInfo, InterfaceInfo> inter : info.entrySet()) {
- InterfaceInfo interfaceInfo = inter.getValue();
- DeviceId devId = interfaceInfo.devInfo().deviceId();
- if (devId.toString().equals(id)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Builds the device model VPN instance model object data, with respect to
- * the device level.
- *
- * @param id device id
- * @param ins VPN instance
- * @return model object data, with device level
- */
- private static ModelObjectData buildInsModDataDevice(String id,
- NetworkInstances ins) {
- DeviceKeys devKeys = new DeviceKeys();
- devKeys.deviceid(id);
- ModelObjectId modelId = ModelObjectId.builder()
- .addChild(DefaultDevices.class)
- .addChild(DefaultDevice.class, devKeys)
- .build();
- return DefaultModelObjectData.builder().identifier(modelId)
- .addModelObject((InnerModelObject) ins).build();
- }
-
- /**
- * Builds the device model VPN instance model object data, with respect to
- * the devices level.
- *
- * @param id device id
- * @param ins VPN instance
- * @return model object data, with devices level
- */
- private static ModelObjectData buildInsModDataDevices(String id,
- NetworkInstances ins) {
- ModelObjectId modelId = ModelObjectId.builder()
- .addChild(DefaultDevices.class).build();
- Device device = new DefaultDevice();
- device.deviceid(id);
- device.networkInstances(ins);
- return DefaultModelObjectData.builder().identifier(modelId)
- .addModelObject((InnerModelObject) device).build();
- }
-
- /**
- * Builds the device model VPN instance model object data, with respect to
- * root level.
- *
- * @param id device id
- * @param ins VPN instance
- * @return model object data, with root level
- */
- private static ModelObjectData buildInsModDataRoot(String id,
- NetworkInstances ins) {
- Devices devices = new DefaultDevices();
- Device device = new DefaultDevice();
- List<Device> deviceList = new LinkedList<>();
- device.deviceid(id);
- device.networkInstances(ins);
- deviceList.add(device);
- devices.device(deviceList);
- return DefaultModelObjectData.builder()
- .addModelObject((InnerModelObject) devices).build();
- }
-
- /**
- * Builds the device model interface model object data, with respect to
- * device level.
- *
- * @param id device id
- * @param ifs interface object
- * @return model object data, with device level
- */
- private static ModelObjectData buildIntModDataDevice(String id,
- Interfaces ifs) {
- org.onosproject.yang.gen.v1.ietfinterfaces
- .rev20140508.ietfinterfaces.devices.DeviceKeys keys = new org.
- onosproject.yang.gen.v1.ietfinterfaces.rev20140508
- .ietfinterfaces.devices.DeviceKeys();
- keys.deviceid(id);
- ModelObjectId modelId = ModelObjectId.builder()
- .addChild(org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508
- .ietfinterfaces.DefaultDevices.class)
- .addChild(org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508
- .ietfinterfaces.devices.DefaultDevice.class,
- keys)
- .build();
- return DefaultModelObjectData.builder().identifier(modelId)
- .addModelObject((InnerModelObject) ifs).build();
- }
-
- /**
- * Returns the VPN instance create model object data.
- *
- * @param intMap interface map
- * @param instances VPN instances
- * @param id device id
- * @return VPN instance model object data
- */
- static ModelObjectData getVpnCreateModObj(Map<AccessInfo, InterfaceInfo> intMap,
- NetworkInstances instances,
- String id) {
- ModelObjectData modData;
- boolean devAdded = isDevIdPresent(intMap, id);
- if (devAdded) {
- modData = buildInsModDataDevice(id, instances);
- } else if (intMap.size() != 0) {
- modData = buildInsModDataDevices(id, instances);
- } else {
- modData = buildInsModDataRoot(id, instances);
- }
- return modData;
- }
-
- /**
- * Returns error message for interface being unavailable in device.
- *
- * @param intName interface name
- * @return error message
- */
- static String getIntNotAvailable(String intName) {
- return "The interface " + intName + " is not available.";
- }
-
- /**
- * Returns the interface create model object data.
- *
- * @param ifNames interfaces
- * @param ifs interface instance
- * @param id device id
- * @return interface model object data
- */
- static ModelObjectData getIntCreateModObj(List<String> ifNames,
- Interfaces ifs, String id) {
- ModelObjectData modData;
- if (ifNames.size() > 1) {
- modData = buildIntModDataDevice(id, ifs);
- } else {
- modData = buildIntModDataRoot(id, ifs);
- }
- return modData;
- }
-
- /**
- * Builds the device model interface model object data, with respect to
- * root level.
- *
- * @param id device id
- * @param ifs interface object
- * @return model object data, with root level
- */
- private static ModelObjectData buildIntModDataRoot(String id,
- Interfaces ifs) {
- org.onosproject.yang.gen.v1.ietfinterfaces
- .rev20140508.ietfinterfaces.Devices devices = new org
- .onosproject.yang.gen.v1.ietfinterfaces.rev20140508
- .ietfinterfaces.DefaultDevices();
- org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.ietfinterfaces.
- devices.Device device = new org.onosproject.yang.gen.v1.
- ietfinterfaces.rev20140508.ietfinterfaces.devices.DefaultDevice();
- List<org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508
- .ietfinterfaces.devices.Device> deviceList = new LinkedList<>();
-
- device.deviceid(id);
- device.interfaces(ifs);
- deviceList.add(device);
- devices.device(deviceList);
- return DefaultModelObjectData.builder()
- .addModelObject((InnerModelObject) devices).build();
- }
-
- /**
- * Returns the BGP create driver info.
- *
- * @param bgpMap BGP map
- * @param id device id
- * @param devBgp device BGP info
- * @param intBgp interface BGP info
- * @return BGP driver config
- */
- static BgpDriverInfo getBgpCreateConfigObj(Map<BgpInfo, DeviceId> bgpMap,
- String id, BgpInfo devBgp,
- BgpInfo intBgp) {
- boolean isDevIdPresent = isDevIdBgpPresent(bgpMap, id);
- BgpDriverInfo info;
- if (devBgp != intBgp) {
- //TODO: With ipv6 BGP it has to be changed
- info = new BgpDriverInfo(VPN, id);
- } else if (isDevIdPresent) {
- info = new BgpDriverInfo(DEVICE, id);
- } else if (bgpMap.size() != 0) {
- info = new BgpDriverInfo(DEVICES, id);
- } else {
- info = new BgpDriverInfo(ROOT, id);
- }
- return info;
- }
-
- /**
- * Returns true if the device is present in the BGP map; false otherwise.
- *
- * @param bgpMap BGP map
- * @param id device id
- * @return true if device is present; false otherwise
- */
- private static boolean isDevIdBgpPresent(Map<BgpInfo, DeviceId> bgpMap,
- String id) {
- for (Map.Entry<BgpInfo, DeviceId> info : bgpMap.entrySet()) {
- DeviceId devId = info.getValue();
- if (devId.toString().equals(id)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns the model object data for VPN instance deletion.
- *
- * @param intMap interface map
- * @param ins VPN instance
- * @param id device id
- * @return model object data
- */
- static ModelObjectData getVpnDelModObj(Map<AccessInfo, InterfaceInfo> intMap,
- NetworkInstances ins,
- String id) {
- boolean isDevIdPresent = isDevIdPresent(intMap, id);
- ModelObjectData modData;
- if (intMap.size() == 0) {
- modData = buildInsModDataRoot(id, ins);
- } else if (isDevIdPresent) {
- modData = buildInsModDataDevice(id, ins);
- } else {
- modData = buildInsModDataDevices(id, ins);
- }
- return modData;
- }
-
- /**
- * Returns the BGP driver info for VPN BGP instance deletion.
- *
- * @param bgpMap BGP map
- * @param id device id
- * @return BGP driver info
- */
- static BgpDriverInfo getVpnBgpDelModObj(Map<BgpInfo, DeviceId> bgpMap,
- String id) {
- boolean isDevIdPresent = isDevIdBgpPresent(bgpMap, id);
- BgpDriverInfo driInfo;
- if (bgpMap.size() == 0) {
- driInfo = new BgpDriverInfo(ROOT, id);
- } else if (isDevIdPresent) {
- driInfo = new BgpDriverInfo(DEVICE, id);
- } else {
- driInfo = new BgpDriverInfo(DEVICES, id);
- }
- return driInfo;
- }
-
- /**
- * Returns the device id whose management ip address or lsr ID matches with
- * the ip or lsr ID received respectively.
- *
- * @param ip value of ip or lsr id
- * @param isIp if ip or lsr id
- * @param devices available devices
- * @return device id
- */
- static DeviceId getId(String ip, boolean isIp,
- Iterable<org.onosproject.net.Device> devices) {
- for (org.onosproject.net.Device device : devices) {
- String val;
- if (isIp) {
- val = device.annotations().value(IP);
- } else {
- val = device.annotations().value(LSR_ID);
- }
- if (ip.equals(val)) {
- return device.id();
- }
- }
- throw new NetL3VpnException(getMgmtIpUnAvailErr(ip));
- }
-
- /**
- * Returns ip address from the device id by parsing.
- *
- * @param devId device id
- * @return ip address
- */
- static String getIpFromDevId(DeviceId devId) {
- String devKey = devId.toString();
- int firstInd = devKey.indexOf(COLON);
- int secInd = devKey.indexOf(COLON, firstInd + 1);
- return devKey.substring(firstInd + 1, secInd);
- }
-}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/package-info.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/package-info.java
deleted file mode 100644
index 68e99ec..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * The implementations of IETF NET l3VPN manager and store.
- */
-package org.onosproject.l3vpn.netl3vpn.impl;
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/package-info.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/package-info.java
deleted file mode 100644
index f270fcd..0000000
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * The IETF NET l3VPN YANG application.
- */
-package org.onosproject.l3vpn.netl3vpn;
diff --git a/apps/pce/app/BUILD b/apps/pce/app/BUILD
deleted file mode 100644
index 9c2d107..0000000
--- a/apps/pce/app/BUILD
+++ /dev/null
@@ -1,24 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + JACKSON + KRYO + CLI + REST + [
- "//core/store/serializers:onos-core-serializers",
- "//apps/tunnel/api:onos-apps-tunnel-api",
- "//apps/pcep-api:onos-apps-pcep-api",
- "//apps/pce/bandwidthmgmt:onos-apps-pce-bandwidthmgmt",
-]
-
-TEST_DEPS = TEST_REST + [
- "//apps/tunnel/api:onos-apps-tunnel-api-tests",
-]
-
-osgi_jar_with_tests(
- karaf_command_packages = ["org.onosproject.pce.cli"],
- test_deps = TEST_DEPS,
- deps = COMPILE_DEPS,
-)
-
-onos_app(
- app_name = "org.onosproject.pce.app",
- category = "default",
- description = "PCE as centeral controller App.",
- title = "PCE",
- url = "http://onosproject.org",
-)
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceDeleteLoadBalancingPathCommand.java b/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceDeleteLoadBalancingPathCommand.java
deleted file mode 100644
index fd8a3cb..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceDeleteLoadBalancingPathCommand.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.cli;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.pce.pceservice.api.PceService;
-
-import org.slf4j.Logger;
-
-/**
- * Supports deleting pce load balancing path.
- */
-@Service
-@Command(scope = "onos", name = "pce-delete-load-balancing-path",
- description = "Supports deleting pce load balancing path.")
-public class PceDeleteLoadBalancingPathCommand extends AbstractShellCommand {
- private final Logger log = getLogger(getClass());
-
- @Argument(index = 0, name = "name", description = "load balancing path name", required = true,
- multiValued = false)
- String name = null;
-
- @Override
- protected void doExecute() {
- log.info("executing pce-delete-load-balancing-path");
-
- PceService service = get(PceService.class);
-
- if (!service.releasePath(name)) {
- error("Path deletion failed.");
- return;
- }
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceDeletePathCommand.java b/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceDeletePathCommand.java
deleted file mode 100644
index e4a6ccc..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceDeletePathCommand.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.cli;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.pce.pceservice.api.PceService;
-
-import org.slf4j.Logger;
-
-/**
- * Supports deleting pce path.
- */
-@Service
-@Command(scope = "onos", name = "pce-delete-path", description = "Supports deleting pce path.")
-public class PceDeletePathCommand extends AbstractShellCommand {
- private final Logger log = getLogger(getClass());
-
- @Argument(index = 0, name = "id", description = "Path Id.", required = true, multiValued = false)
- String id = null;
-
- @Override
- protected void doExecute() {
- log.info("executing pce-delete-path");
-
- PceService service = get(PceService.class);
-
- if (!service.releasePath(TunnelId.valueOf(id))) {
- error("Path deletion failed.");
- return;
- }
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceQueryLoadBalancingPathCommand.java b/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceQueryLoadBalancingPathCommand.java
deleted file mode 100644
index 686ea45..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceQueryLoadBalancingPathCommand.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.cli;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.pce.pceservice.api.PceService;
-
-import org.slf4j.Logger;
-
-import java.util.List;
-
-/**
- * Supports quering PCE load balanced path.
- */
-@Service
-@Command(scope = "onos", name = "pce-query-load-balancing-path",
- description = "Supports querying PCE path.")
-public class PceQueryLoadBalancingPathCommand extends AbstractShellCommand {
- private final Logger log = getLogger(getClass());
- public static final String COST_TYPE = "costType";
-
- @Argument(index = 0, name = "pathName", description = "load balencing path name", required = true,
- multiValued = false)
- String name = null;
-
- @Override
- protected void doExecute() {
- log.info("executing pce-query-load-balancing-path");
-
- PceService service = get(PceService.class);
-
- if (name == null) {
- print("Path name is mandatory");
- return;
- }
-
- List<TunnelId> tunnelIds = service.queryLoadBalancingPath(name);
- if (tunnelIds == null || tunnelIds.isEmpty()) {
- print("Release path failed");
- return;
- }
-
- for (TunnelId id : tunnelIds) {
- Tunnel tunnel = service.queryPath(id);
- if (tunnel == null) {
- print("Path doesnot exists");
- return;
- }
- display(tunnel);
- }
- }
-
- /**
- * Display tunnel information on the terminal.
- *
- * @param tunnel pce tunnel
- */
- void display(Tunnel tunnel) {
-
- print("\npath-id : %s \n" +
- "source : %s \n" +
- "destination : %s \n" +
- "path-type : %s \n" +
- "symbolic-path-name : %s \n" +
- "constraints: \n" +
- " cost : %s \n" +
- " bandwidth : %s",
- tunnel.tunnelId().id(), tunnel.path().src().deviceId().toString(),
- tunnel.path().dst().deviceId().toString(),
- tunnel.type().name(), tunnel.tunnelName(), tunnel.annotations().value(COST_TYPE),
- tunnel.annotations().value(AnnotationKeys.BANDWIDTH));
- print("Path : %s", tunnel.path().toString());
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceQueryPathCommand.java b/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceQueryPathCommand.java
deleted file mode 100644
index 5edb675..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceQueryPathCommand.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.cli;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.pce.pceservice.ExplicitPathInfo;
-import org.onosproject.pce.pceservice.api.PceService;
-
-import org.slf4j.Logger;
-
-import java.util.List;
-
-/**
- * Supports quering PCE path.
- */
-@Service
-@Command(scope = "onos", name = "pce-query-path",
- description = "Supports querying PCE path.")
-public class PceQueryPathCommand extends AbstractShellCommand {
- private final Logger log = getLogger(getClass());
- public static final String COST_TYPE = "costType";
-
- @Option(name = "-i", aliases = "--id", description = "path-id", required = false,
- multiValued = false)
- String id = null;
-
- @Override
- protected void doExecute() {
- log.info("executing pce-query-path");
-
- PceService service = get(PceService.class);
- if (null == id) {
- Iterable<Tunnel> tunnels = service.queryAllPath();
- if (tunnels != null) {
- for (final Tunnel tunnel : tunnels) {
- display(tunnel);
- }
- } else {
- print("No path is found.");
- return;
- }
- } else {
- Tunnel tunnel = service.queryPath(TunnelId.valueOf(id));
- if (tunnel == null) {
- print("Path doesnot exists.");
- return;
- }
- display(tunnel);
- }
- }
-
- /**
- * Display tunnel information on the terminal.
- *
- * @param tunnel pce tunnel
- */
- void display(Tunnel tunnel) {
- List<ExplicitPathInfo> explicitPathInfoList = AbstractShellCommand.get(PceService.class)
- .explicitPathInfoList(tunnel.tunnelName().value());
-
- print("\npath-id : %s \n" +
- "source : %s \n" +
- "destination : %s \n" +
- "path-type : %s \n" +
- "symbolic-path-name : %s \n" +
- "constraints: \n" +
- " cost : %s \n" +
- " bandwidth : %s",
- tunnel.tunnelId().id(), tunnel.path().src().deviceId().toString(),
- tunnel.path().dst().deviceId().toString(),
- tunnel.type().name(), tunnel.tunnelName(), tunnel.annotations().value(COST_TYPE),
- tunnel.annotations().value(AnnotationKeys.BANDWIDTH));
- if (explicitPathInfoList != null) {
- for (ExplicitPathInfo e : explicitPathInfoList) {
- print("explicitPathObjects : \n" +
- " type : %s \n" +
- " value : %s ",
- String.valueOf(e.type().type()), e.value().toString());
- }
- }
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceSetupPathCommand.java b/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceSetupPathCommand.java
deleted file mode 100644
index 253a166..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceSetupPathCommand.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.cli;
-
-import static org.onosproject.net.Link.State.ACTIVE;
-import static org.onosproject.net.Link.Type.DIRECT;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.LinkedList;
-
-import com.google.common.collect.Lists;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onlab.util.DataRateUnit;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.NetworkResource;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pce.pceservice.ExplicitPathInfo;
-import org.onosproject.pce.pceservice.constraint.CostConstraint;
-import org.onosproject.pce.pceservice.LspType;
-import org.onosproject.pce.pceservice.api.PceService;
-import org.onosproject.pce.pceservice.constraint.PceBandwidthConstraint;
-import org.slf4j.Logger;
-
-/**
- * Supports creating the pce path.
- */
-@Service
-@Command(scope = "onos", name = "pce-setup-path", description = "Supports creating pce path.")
-public class PceSetupPathCommand extends AbstractShellCommand {
- private final Logger log = getLogger(getClass());
- public static final byte SUBTYPE_DEVICEID = 0;
- public static final byte SUBTYPE_LINK = 1;
- public static final byte SUBTYPE_INDEX = 1;
- public static final byte TYPE_INDEX = 0;
-
- public static final byte DEVICEID_INDEX = 2;
- public static final byte SOURCE_DEVICEID_INDEX = 2;
- public static final byte SOURCE_PORTNO_INDEX = 3;
- public static final byte DESTINATION_DEVICEID_INDEX = 4;
- public static final byte DESTINATION_PORTNO_INDEX = 5;
-
- @Argument(index = 0, name = "src", description = "source device.", required = true, multiValued = false)
- String src = null;
-
- @Argument(index = 1, name = "dst", description = "destination device.", required = true, multiValued = false)
- String dst = null;
-
- @Argument(index = 2, name = "type", description = "LSP type:" + " It includes "
- + "PCE tunnel with signalling in network (0), "
- + "PCE tunnel without signalling in network with segment routing (1), "
- + "PCE tunnel without signalling in network (2).",
- required = true, multiValued = false)
- int type = 0;
-
- @Argument(index = 3, name = "name", description = "symbolic-path-name.", required = true, multiValued = false)
- String name = null;
-
- @Option(name = "-c", aliases = "--cost", description = "The cost attribute IGP cost(1) or TE cost(2)",
- required = false, multiValued = false)
- int cost = 2;
-
- @Option(name = "-b", aliases = "--bandwidth", description = "The bandwidth attribute of path. "
- + "Data rate unit is in BPS.", required = false, multiValued = false)
- double bandwidth = 0.0;
-
- @Option(name = "-e", aliases = "--explicitPathObjects", description = "List of strict and loose hopes"
- + " explicitPathInfo format : Type/SubType/Value(DeviceId or Link info)\n" +
- " If Value is Device : Type/SubType/deviceId\n" +
- " If Value is Link : Type/SubType/SourceDeviceId/SourcePortNo/DestinationDeviceId/DestinationPortNo" +
- "Type 0 - strict, 1 - loose \n" + "SubType 0 - deviceId, 1 - link \n",
- required = false, multiValued = true)
- String[] explicitPathInfoStrings;
-
- @Option(name = "-l", aliases = "--loadBalancing", description = "The load balancing option for user. ",
- required = false, multiValued = false)
- boolean loadBalancing = false;
-
- //explicitPathInfo format : Type/SubType/Value(DeviceId or Link info)
- //If Value is Device : Type/SubType/deviceId
- //If Value is Link : Type/SubType/SourceDeviceId/SourcePortNo/DestinationDeviceId/DestinationPortNo
- List<ExplicitPathInfo> explicitPathInfo = Lists.newLinkedList();
-
- @Override
- protected void doExecute() {
- log.info("executing pce-setup-path");
-
- PceService service = get(PceService.class);
- TunnelService tunnelService = get(TunnelService.class);
-
- DeviceId srcDevice = DeviceId.deviceId(src);
- DeviceId dstDevice = DeviceId.deviceId(dst);
- List<Constraint> listConstrnt = new LinkedList<>();
-
- // LSP type validation
- if ((type < 0) || (type > 2)) {
- error("The LSP type value can be PCE tunnel with signalling in network (0), " +
- "PCE tunnel without signalling in network with segment routing (1), " +
- "PCE tunnel without signalling in network (2).");
- return;
- }
- LspType lspType = LspType.values()[type];
-
- //Validating tunnel name, duplicated tunnel names not allowed
- Collection<Tunnel> existingTunnels = tunnelService.queryTunnel(Tunnel.Type.MPLS);
- for (Tunnel t : existingTunnels) {
- if (t.tunnelName().toString().equals(name)) {
- error("Path creation failed, Tunnel name already exists");
- return;
- }
- }
-
- // Add bandwidth
- // bandwidth default data rate unit is in BPS
- if (bandwidth != 0.0) {
- listConstrnt.add(PceBandwidthConstraint.of(bandwidth, DataRateUnit.valueOf("BPS")));
- }
-
- // Add cost
- // Cost validation
- if ((cost < 1) || (cost > 2)) {
- error("The cost attribute value either IGP cost(1) or TE cost(2).");
- return;
- }
- // Here 'cost - 1' indicates the index of enum
- CostConstraint.Type costType = CostConstraint.Type.values()[cost - 1];
- listConstrnt.add(CostConstraint.of(costType));
-
- if (explicitPathInfoStrings != null) {
- for (String str : explicitPathInfoStrings) {
- String[] splitted = str.split("/");
- DeviceId deviceId;
- NetworkResource res = null;
- PortNumber portNo;
- int explicitPathType = Integer.parseInt(splitted[TYPE_INDEX]);
- if ((explicitPathType < 0) || (explicitPathType > 1)) {
- error("Explicit path validation failed");
- return;
- }
-
- //subtype 0 = deviceId, 1 = link
- //subtype is required to store either as deviceId or Link
- if (splitted[DEVICEID_INDEX] != null && Integer.parseInt(splitted[SUBTYPE_INDEX]) == SUBTYPE_DEVICEID) {
- res = DeviceId.deviceId(splitted[DEVICEID_INDEX]);
- } else if (Integer.parseInt(splitted[SUBTYPE_INDEX]) == SUBTYPE_LINK
- && splitted[SOURCE_DEVICEID_INDEX] != null
- && splitted[SOURCE_PORTNO_INDEX] != null
- && splitted[DESTINATION_DEVICEID_INDEX] != null
- && splitted[DESTINATION_PORTNO_INDEX] != null) {
-
- deviceId = DeviceId.deviceId(splitted[SOURCE_DEVICEID_INDEX]);
- portNo = PortNumber.portNumber(splitted[SOURCE_PORTNO_INDEX]);
- ConnectPoint cpSrc = new ConnectPoint(deviceId, portNo);
- deviceId = DeviceId.deviceId(splitted[DESTINATION_DEVICEID_INDEX]);
- portNo = PortNumber.portNumber(splitted[DESTINATION_PORTNO_INDEX]);
- ConnectPoint cpDst = new ConnectPoint(deviceId, portNo);
- res = DefaultLink.builder()
- .providerId(ProviderId.NONE)
- .src(cpSrc)
- .dst(cpDst)
- .type(DIRECT)
- .state(ACTIVE)
- .build();
- } else {
- error("Explicit path validation failed");
- return;
- }
- ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.values()[explicitPathType], res);
- explicitPathInfo.add(obj);
- }
- }
-
- //with load balancing option
- if (loadBalancing) {
- if (!service.setupPath(srcDevice, dstDevice, name, listConstrnt, lspType, loadBalancing)) {
- error("Path creation failed.");
- }
- return;
- }
-
- if (!service.setupPath(srcDevice, dstDevice, name, listConstrnt, lspType, explicitPathInfo)) {
- error("Path creation failed.");
- }
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceUpdatePathCommand.java b/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceUpdatePathCommand.java
deleted file mode 100644
index 96796b5..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/cli/PceUpdatePathCommand.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.cli;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.List;
-import java.util.LinkedList;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onlab.util.DataRateUnit;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.pce.pceservice.constraint.PceBandwidthConstraint;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.pce.pceservice.constraint.CostConstraint;
-import org.onosproject.pce.pceservice.api.PceService;
-
-import org.slf4j.Logger;
-
-/**
- * Supports updating the PCE path.
- */
-@Service
-@Command(scope = "onos", name = "pce-update-path",
- description = "Supports updating PCE path.")
-public class PceUpdatePathCommand extends AbstractShellCommand {
- private final Logger log = getLogger(getClass());
-
- @Argument(index = 0, name = "id", description = "Path Id.", required = true, multiValued = false)
- String id = null;
-
- @Option(name = "-c", aliases = "--cost", description = "The cost attribute IGP cost (1) or TE cost (2).",
- required = false, multiValued = false)
- Integer cost = null;
-
- @Option(name = "-b", aliases = "--bandwidth", description = "The bandwidth attribute of path. "
- + "Data rate unit is in Bps.", required = false, multiValued = false)
- Double bandwidth = null;
-
- @Override
- protected void doExecute() {
- log.info("executing pce-update-path");
-
- PceService service = get(PceService.class);
-
- List<Constraint> constrntList = new LinkedList<>();
- // Assign bandwidth. Data rate unit is in Bps.
- if (bandwidth != null) {
- constrntList.add(PceBandwidthConstraint.of(Double.valueOf(bandwidth), DataRateUnit.valueOf("BPS")));
- }
-
- // Cost validation
- if (cost != null) {
- if ((cost < 1) || (cost > 2)) {
- error("The cost attribute value is either IGP cost(1) or TE cost(2).");
- return;
- }
- CostConstraint.Type costType = CostConstraint.Type.values()[cost - 1];
- constrntList.add(CostConstraint.of(costType));
- }
-
- if (!service.updatePath(TunnelId.valueOf(id), constrntList)) {
- error("Path updation failed.");
- return;
- }
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/cli/package-info.java b/apps/pce/app/src/main/java/org/onosproject/pce/cli/package-info.java
deleted file mode 100644
index 7054cfa..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/cli/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCE path console command-line extensions.
- */
-package org.onosproject.pce.cli;
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/DefaultPcePath.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/DefaultPcePath.java
deleted file mode 100644
index 404db25..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/DefaultPcePath.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pce.pceservice;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Objects;
-
-import org.onlab.rest.BaseResource;
-import org.onlab.util.DataRateUnit;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.pce.pceservice.constraint.CostConstraint;
-import org.onosproject.pce.pceservice.constraint.PceBandwidthConstraint;
-
-/**
- * Implementation of an entity which provides functionalities of pce path.
- */
-public final class DefaultPcePath implements PcePath {
-
- private TunnelId id; // path id
- private String source; // Ingress
- private String destination; // Egress
- private LspType lspType; // LSP type
- private String name; // symbolic-path-name
- private Constraint costConstraint; // cost constraint
- private Constraint bandwidthConstraint; // bandwidth constraint
- private Collection<ExplicitPathInfo> explicitPathInfo; //list of explicit path info
-
- /**
- * Initializes PCE path attributes.
- *
- * @param id path id
- * @param src ingress
- * @param dst egress
- * @param lspType LSP type
- * @param name symbolic-path-name
- * @param costConstrnt cost constraint
- * @param bandwidthConstrnt bandwidth constraint
- * @param explicitPathInfo list of explicit path info
- */
- private DefaultPcePath(TunnelId id, String src, String dst, LspType lspType,
- String name, Constraint costConstrnt, Constraint bandwidthConstrnt,
- Collection<ExplicitPathInfo> explicitPathInfo) {
- this.id = id;
- this.source = src;
- this.destination = dst;
- this.lspType = lspType;
- this.name = name;
- this.costConstraint = costConstrnt;
- this.bandwidthConstraint = bandwidthConstrnt;
- this.explicitPathInfo = explicitPathInfo;
- }
-
- @Override
- public TunnelId id() {
- return id;
- }
-
- @Override
- public void id(TunnelId id) {
- this.id = id;
- }
-
- @Override
- public String source() {
- return source;
- }
-
- @Override
- public void source(String src) {
- this.source = src;
- }
-
- @Override
- public String destination() {
- return destination;
- }
-
- @Override
- public void destination(String dst) {
- this.destination = dst;
- }
-
- @Override
- public LspType lspType() {
- return lspType;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public Constraint costConstraint() {
- return costConstraint;
- }
-
- @Override
- public Constraint bandwidthConstraint() {
- return bandwidthConstraint;
- }
-
- @Override
- public Collection<ExplicitPathInfo> explicitPathInfo() {
- return explicitPathInfo;
- }
-
- @Override
- public PcePath copy(PcePath path) {
- if (null != path.source()) {
- this.source = path.source();
- }
- if (null != path.destination()) {
- this.destination = path.destination();
- }
-
- this.lspType = path.lspType();
-
- if (null != path.name()) {
- this.name = path.name();
- }
- if (null != path.costConstraint()) {
- this.costConstraint = path.costConstraint();
- }
- if (null != path.bandwidthConstraint()) {
- this.bandwidthConstraint = path.bandwidthConstraint();
- }
- return this;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, source, destination, lspType, name, costConstraint, bandwidthConstraint,
- explicitPathInfo);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultPcePath) {
- DefaultPcePath that = (DefaultPcePath) obj;
- return Objects.equals(id, that.id)
- && Objects.equals(source, that.source)
- && Objects.equals(destination, that.destination)
- && Objects.equals(lspType, that.lspType)
- && Objects.equals(name, that.name)
- && Objects.equals(costConstraint, that.costConstraint)
- && Objects.equals(bandwidthConstraint, that.bandwidthConstraint)
- && Objects.equals(explicitPathInfo, that.explicitPathInfo);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .omitNullValues()
- .add("id", id())
- .add("source", source)
- .add("destination", destination)
- .add("lsptype", lspType)
- .add("name", name)
- .add("costConstraint", costConstraint)
- .add("bandwidthConstraint", bandwidthConstraint)
- .add("explicitPathInfo", explicitPathInfo)
- .toString();
- }
-
- /**
- * Creates an instance of the pce path builder.
- *
- * @return instance of builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for pce path.
- */
- public static final class Builder extends BaseResource implements PcePath.Builder {
- private TunnelId id;
- private String source;
- private String destination;
- private LspType lspType;
- private String name;
- private Constraint costConstraint;
- private Constraint bandwidthConstraint;
- private Collection<ExplicitPathInfo> explicitPathInfo;
-
- @Override
- public Builder id(String id) {
- this.id = TunnelId.valueOf(id);
- return this;
- }
-
- @Override
- public Builder source(String source) {
- this.source = source;
- return this;
- }
-
- @Override
- public Builder destination(String destination) {
- this.destination = destination;
- return this;
- }
-
- @Override
- public Builder lspType(String type) {
- if (null != type) {
- this.lspType = LspType.values()[Integer.valueOf(type)];
- }
- return this;
- }
-
- @Override
- public Builder name(String name) {
- this.name = name;
- return this;
- }
-
- @Override
- public Builder costConstraint(String cost) {
- this.costConstraint = CostConstraint.of(CostConstraint.Type.values()[Integer.valueOf(cost) - 1]);
- return this;
- }
-
- @Override
- public Builder bandwidthConstraint(String bandwidth) {
- this.bandwidthConstraint = PceBandwidthConstraint.of(Double.valueOf(bandwidth), DataRateUnit
- .valueOf("BPS"));
- return this;
- }
-
- @Override
- public Builder explicitPathInfo(Collection<ExplicitPathInfo> explicitPathInfo) {
- this.explicitPathInfo = explicitPathInfo;
- return this;
- }
-
- @Override
- public Builder of(Tunnel tunnel, List<ExplicitPathInfo> explicitPathInfoList) {
- this.id = TunnelId.valueOf(tunnel.tunnelId().id());
- this.source = tunnel.path().src().deviceId().toString();
- this.destination = tunnel.path().dst().deviceId().toString();
- this.name = tunnel.tunnelName().toString();
- // LSP type
- String lspType = tunnel.annotations().value(PcepAnnotationKeys.LSP_SIG_TYPE);
- if (lspType != null) {
- this.lspType = LspType.values()[LspType.valueOf(lspType).type()];
- }
-
- // Cost type
- String costType = tunnel.annotations().value(PcepAnnotationKeys.COST_TYPE);
- if (costType != null) {
- this.costConstraint = CostConstraint.of(CostConstraint.Type.valueOf(costType));
- }
-
- // Bandwidth
- String bandwidth = tunnel.annotations().value(PcepAnnotationKeys.BANDWIDTH);
- if (bandwidth != null) {
- this.bandwidthConstraint = PceBandwidthConstraint.of(Double.parseDouble(bandwidth),
- DataRateUnit.valueOf("BPS"));
- }
-
- // Explicit Path
- if (explicitPathInfoList != null) {
- this.explicitPathInfo = explicitPathInfoList;
- }
-
- return this;
- }
-
- @Override
- public PcePath build() {
- return new DefaultPcePath(id, source, destination, lspType, name,
- costConstraint, bandwidthConstraint, explicitPathInfo);
- }
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/ExplicitPathInfo.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/ExplicitPathInfo.java
deleted file mode 100644
index fcf5006..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/ExplicitPathInfo.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pceservice;
-
-import org.onosproject.net.NetworkResource;
-
-import com.google.common.annotations.Beta;
-
-import java.util.Objects;
-
-/**
- * Representation of explicit path info consists of contraints (strict / loose) to compute path.
- */
-@Beta
-public final class ExplicitPathInfo {
-
- private final Type type;
-
- //Can be Link or DeviceId
- private final NetworkResource value;
-
- public enum Type {
- /**
- * Signifies that path includes strict node or link.
- */
- STRICT(0),
-
- /**
- * Signifies that path includes loose node or link.
- */
- LOOSE(1);
-
- int value;
-
- /**
- * Assign val with the value as the type.
- *
- * @param val type
- */
- Type(int val) {
- value = val;
- }
-
- /**
- * Returns value of type.
- *
- * @return type
- */
- public byte type() {
- return (byte) value;
- }
- }
-
- /**
- * Creates instance of explicit path object.
- *
- * @param type specifies whether strict or loose node/link
- * @param value specifies deviceId or link
- */
- public ExplicitPathInfo(Type type, NetworkResource value) {
- this.type = type;
- this.value = value;
- }
-
- /**
- * Returns explicit path type.
- *
- * @return explicit path type as strict/loose
- */
- public Type type() {
- return type;
- }
-
- /**
- * Returns deviceId or link.
- *
- * @return deviceId or link
- */
- public NetworkResource value() {
- return value;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type, value);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof ExplicitPathInfo) {
- final ExplicitPathInfo other = (ExplicitPathInfo) obj;
- return Objects.equals(this.type, other.type)
- && Objects.equals(this.value, other.value);
- }
- return false;
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/LspType.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/LspType.java
deleted file mode 100644
index 443e19e..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/LspType.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pce.pceservice;
-
-/**
- * Representation of LSP type.
- */
-public enum LspType {
- /**
- * Signifies that path is created via signaling mode.
- */
- WITH_SIGNALLING(0),
-
- /**
- * Signifies that path is created via SR mode.
- */
- SR_WITHOUT_SIGNALLING(1),
-
- /**
- * Signifies that path is created via without signaling and without SR mode.
- */
- WITHOUT_SIGNALLING_AND_WITHOUT_SR(2);
-
- int value;
-
- /**
- * Assign val with the value as the LSP type.
- *
- * @param val LSP type
- */
- LspType(int val) {
- value = val;
- }
-
- /**
- * Returns value of LSP type.
- *
- * @return LSP type
- */
- public byte type() {
- return (byte) value;
- }
-}
\ No newline at end of file
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
deleted file mode 100644
index d9a61f0..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
+++ /dev/null
@@ -1,1323 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pceservice;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
-import org.onlab.graph.ScalarWeight;
-import org.onlab.graph.Weight;
-import org.onlab.packet.IpAddress;
-import org.onlab.util.Bandwidth;
-import org.onosproject.bandwidthmgr.api.BandwidthMgmtService;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.core.IdGenerator;
-import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelEvent;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelListener;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultAnnotations.Builder;
-import org.onosproject.net.DefaultPath;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.DisjointPath;
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.NetworkResource;
-import org.onosproject.net.Path;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigRegistry;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.config.basics.SubjectFactories;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.link.LinkEvent;
-import org.onosproject.net.resource.Resource;
-import org.onosproject.net.resource.ResourceAllocation;
-import org.onosproject.net.topology.LinkWeigher;
-import org.onosproject.net.topology.PathService;
-import org.onosproject.net.topology.TopologyEdge;
-import org.onosproject.net.topology.TopologyEvent;
-import org.onosproject.net.topology.TopologyListener;
-import org.onosproject.net.topology.TopologyService;
-import org.onosproject.pce.pceservice.api.PceService;
-import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
-import org.onosproject.pce.pceservice.constraint.CapabilityConstraint.CapabilityType;
-import org.onosproject.pce.pceservice.constraint.CostConstraint;
-import org.onosproject.pce.pceservice.constraint.PceBandwidthConstraint;
-import org.onosproject.pce.pceservice.constraint.SharedBandwidthConstraint;
-import org.onosproject.pce.pcestore.PcePathInfo;
-import org.onosproject.pce.pcestore.api.PceStore;
-import org.onosproject.pcep.api.DeviceCapability;
-import org.onosproject.pcep.api.TeLinkConfig;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.DistributedSet;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT;
-import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE;
-import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS;
-import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING;
-import static org.onosproject.pce.pceservice.PcepAnnotationKeys.BANDWIDTH;
-import static org.onosproject.pce.pceservice.PcepAnnotationKeys.COST_TYPE;
-import static org.onosproject.pce.pceservice.PcepAnnotationKeys.DELEGATE;
-import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LOCAL_LSP_ID;
-import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LSP_SIG_TYPE;
-import static org.onosproject.pce.pceservice.PcepAnnotationKeys.PCC_TUNNEL_ID;
-import static org.onosproject.pce.pceservice.PcepAnnotationKeys.PCE_INIT;
-import static org.onosproject.pce.pceservice.PcepAnnotationKeys.PLSP_ID;
-
-/**
- * Implementation of PCE service.
- */
-@Component(immediate = true, service = PceManager.class)
-public class PceManager implements PceService {
- private static final Logger log = LoggerFactory.getLogger(PceManager.class);
-
- public static final long GLOBAL_LABEL_SPACE_MIN = 4097;
- public static final long GLOBAL_LABEL_SPACE_MAX = 5121;
- public static final String PCE_SERVICE_APP = "org.onosproject.pce";
- private static final String LOCAL_LSP_ID_GEN_TOPIC = "pcep-local-lsp-id";
- public static final String DEVICE_TYPE = "type";
- public static final String L3_DEVICE = "L3";
-
- private static final String LSRID = "lsrId";
- private static final String TRUE = "true";
- private static final String FALSE = "false";
- public static final int PCEP_PORT = 4189;
-
- private IdGenerator localLspIdIdGen;
- protected DistributedSet<Short> localLspIdFreeList;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PathService pathService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PceStore pceStore;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TunnelService tunnelService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceService deviceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigService netCfgService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected MastershipService mastershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TopologyService topologyService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected BandwidthMgmtService bandwidthMgmtService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigRegistry netConfigRegistry;
-
- private TunnelListener listener = new InnerTunnelListener();
- private ApplicationId appId;
-
- private final TopologyListener topologyListener = new InternalTopologyListener();
- public static final String LOAD_BALANCING_PATH_NAME = "loadBalancingPathName";
-
- private List<TunnelId> rsvpTunnelsWithLocalBw = new ArrayList<>();
-
- private final ConfigFactory<LinkKey, TeLinkConfig> configFactory =
- new ConfigFactory<LinkKey, TeLinkConfig>(SubjectFactories.LINK_SUBJECT_FACTORY,
- TeLinkConfig.class, "teLinkConfig") {
- @Override
- public TeLinkConfig createConfig() {
- return new TeLinkConfig();
- }
- };
-
- /**
- * Creates new instance of PceManager.
- */
- public PceManager() {
- }
-
- @Activate
- protected void activate() {
- appId = coreService.registerApplication(PCE_SERVICE_APP);
-
- tunnelService.addListener(listener);
-
- localLspIdIdGen = coreService.getIdGenerator(LOCAL_LSP_ID_GEN_TOPIC);
- localLspIdIdGen.getNewId(); // To prevent 0, the 1st value generated from being used in protocol.
- localLspIdFreeList = storageService.<Short>setBuilder()
- .withName("pcepLocalLspIdDeletedList")
- .withSerializer(Serializer.using(KryoNamespaces.API))
- .build()
- .asDistributedSet();
-
- topologyService.addListener(topologyListener);
- netConfigRegistry.registerConfigFactory(configFactory);
-
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- tunnelService.removeListener(listener);
- topologyService.removeListener(topologyListener);
- netConfigRegistry.unregisterConfigFactory(configFactory);
-
- log.info("Stopped");
- }
-
- /**
- * Returns an edge-weight capable of evaluating links on the basis of the
- * specified constraints.
- *
- * @param constraints path constraints
- * @return edge-weight function
- */
- private LinkWeigher weight(List<Constraint> constraints) {
- return new TeConstraintBasedLinkWeight(constraints);
- }
-
- /**
- * Computes a path between two devices.
- *
- * @param src ingress device
- * @param dst egress device
- * @param constraints path constraints
- * @return computed path based on constraints
- */
- protected Set<Path> computePath(DeviceId src, DeviceId dst, List<Constraint> constraints) {
- if (pathService == null) {
- return ImmutableSet.of();
- }
-
- Set<Path> paths = pathService.getPaths(src, dst, weight(constraints));
- log.info("paths in computePath ::" + paths);
- if (!paths.isEmpty()) {
- return paths;
- }
- return ImmutableSet.of();
- }
-
- //Computes the partial path from partial computed path to specified dst.
- private List<Path> computePartialPath(List<Path> computedPath, DeviceId src, DeviceId dst,
- List<Constraint> constraints) {
- int size = computedPath.size();
- Path path = null;
- DeviceId deviceId = size == 0 ? src :
- computedPath.get(size - 1).dst().deviceId();
-
- Set<Path> tempComputePath = computePath(deviceId, dst, constraints);
-
- if (tempComputePath.isEmpty()) {
- return null;
- }
-
- //if path validation fails return null
- //Validate computed path to avoid loop in the path
- for (Path p : tempComputePath) {
- if (pathValidation(computedPath, p)) {
- path = p;
- break;
- }
- }
- if (path == null) {
- return null;
- }
-
- //Store the partial path result in a list
- computedPath.add(path);
- return computedPath;
- }
-
- private List<DeviceId> createListOfDeviceIds(List<? extends NetworkResource> list) {
- List<Link> links = new LinkedList<>();
- if (!list.isEmpty() && list.iterator().next() instanceof Path) {
- for (Path path : (List<Path>) list) {
- links.addAll(path.links());
- }
- } else if (!list.isEmpty() && list.iterator().next() instanceof Link) {
- links.addAll((List<Link>) list);
- }
-
- //List of devices for new path computed
- DeviceId source = null;
- DeviceId destination = null;
- List<DeviceId> devList = new LinkedList<>();
-
- for (Link l : links) {
- if (!devList.contains(l.src().deviceId())) {
- devList.add(l.src().deviceId());
- }
- if (!devList.contains(l.dst().deviceId())) {
- devList.add(l.dst().deviceId());
- }
- }
-
- return devList;
- }
-
- //To detect loops in the path i.e if the partial paths has intersection node avoid it.
- private boolean pathValidation(List<Path> partialPath, Path path) {
-
- //List of devices in new path computed
- List<DeviceId> newPartialPathDevList;
- newPartialPathDevList = createListOfDeviceIds(path.links());
-
- //List of devices in partial computed path
- List<DeviceId> partialComputedPathDevList;
- partialComputedPathDevList = createListOfDeviceIds(partialPath);
-
- for (DeviceId deviceId : newPartialPathDevList) {
- for (DeviceId devId : partialComputedPathDevList) {
- if (!newPartialPathDevList.get(0).equals(deviceId) &&
- !partialComputedPathDevList.get(partialComputedPathDevList.size() - 1).equals(devId)
- && deviceId.equals(devId)) {
- return false;
- }
- }
- }
- return true;
- }
-
- //Returns final computed explicit path (list of partial computed paths).
- private List<Path> computeExplicitPath(List<ExplicitPathInfo> explicitPathInfo, DeviceId src, DeviceId dst,
- List<Constraint> constraints) {
- List<Path> finalComputedPath = new LinkedList<>();
- for (ExplicitPathInfo info : explicitPathInfo) {
- /*
- * If explicit path object is LOOSE,
- * 1) If specified as DeviceId (node) :
- * If it is source , compute from source to destination (partial computation not required),
- * otherwise compute from specified source to specified device
- * 2) If specified as Link :
- * Compute partial path from source to link's source , if path exists compute from link's source to dst
- */
- if (info.type().equals(ExplicitPathInfo.Type.LOOSE)) {
- if (info.value() instanceof DeviceId) {
- // If deviceId is source no need to compute
- if (!(info.value()).equals(src)) {
- log.debug("computeExplicitPath :: Loose , device");
- finalComputedPath = computePartialPath(finalComputedPath, src, (DeviceId) info.value(),
- constraints);
- log.debug("finalComputedPath in computeExplicitPath ::" + finalComputedPath);
- }
-
- } else if (info.value() instanceof Link) {
- if ((((Link) info.value()).src().deviceId().equals(src))
- || (!finalComputedPath.isEmpty()
- && finalComputedPath.get(finalComputedPath.size() - 1).dst().deviceId().equals(
- ((Link) info.value()).src().deviceId()))) {
-
- finalComputedPath = computePartialPath(finalComputedPath, src, ((Link) info.value()).dst()
- .deviceId(), constraints);
- } else {
-
- finalComputedPath = computePartialPath(finalComputedPath, src, ((Link) info.value()).src()
- .deviceId(), constraints) != null ? computePartialPath(finalComputedPath, src,
- ((Link) info.value()).dst().deviceId(), constraints) : null;
- }
- }
- /*
- * If explicit path object is STRICT,
- * 1) If specified as DeviceId (node) :
- * Check whether partial computed path has reachable to strict specified node orde
- * strict node is the source, if no set path as null else do nothing
- * 2) If specified as Link :
- * Check whether partial computed path has reachable to strict link's src, if yes compute
- * path from strict link's src to link's dst (to include specified link)
- */
- } else if (info.type().equals(ExplicitPathInfo.Type.STRICT)) {
- if (info.value() instanceof DeviceId) {
- log.debug("computeExplicitPath :: Strict , device");
- if (!(!finalComputedPath.isEmpty() && finalComputedPath.get(finalComputedPath.size() - 1).dst()
- .deviceId().equals(info.value()))
- && !info.value().equals(src)) {
- finalComputedPath = null;
- }
-
- } else if (info.value() instanceof Link) {
- log.info("computeExplicitPath :: Strict");
- finalComputedPath = ((Link) info.value()).src().deviceId().equals(src)
- || !finalComputedPath.isEmpty()
- && finalComputedPath.get(finalComputedPath.size() - 1).dst().deviceId()
- .equals(((Link) info.value()).src().deviceId()) ? computePartialPath(
- finalComputedPath, src, ((Link) info.value()).dst().deviceId(), constraints) : null;
-
- //Log.info("computeExplicitPath :: (Link) info.value() " + (Link) info.value());
- //Log.info("computeExplicitPath :: finalComputedPath " + finalComputedPath);
-
- if (finalComputedPath != null && !finalComputedPath.get(finalComputedPath.size() - 1).links()
- .contains(info.value())) {
- finalComputedPath = null;
- }
- }
- }
- if (finalComputedPath == null) {
- return null;
- }
- }
- // Destination is not reached in Partial computed path then compute till destination
- if (finalComputedPath.isEmpty() || !finalComputedPath.isEmpty()
- && !finalComputedPath.get(finalComputedPath.size() - 1).dst().deviceId().equals(dst)) {
-
- finalComputedPath = computePartialPath(finalComputedPath, src, dst, constraints);
- if (finalComputedPath == null) {
- return null;
- }
- }
-
- return finalComputedPath;
- }
-
- @Override
- public boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints,
- LspType lspType) {
- return setupPath(src, dst, tunnelName, constraints, lspType, null, false);
- }
-
- //[TODO:] handle requests in queue
- @Override
- public boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints,
- LspType lspType, List<ExplicitPathInfo> explicitPathInfo) {
- return setupPath(src, dst, tunnelName, constraints, lspType, explicitPathInfo, false);
-
- }
-
- @Override
- public boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints,
- LspType lspType, boolean loadBalancing) {
- return setupPath(src, dst, tunnelName, constraints, lspType, null, loadBalancing);
- }
-
- @Override
- public boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints,
- LspType lspType, List<ExplicitPathInfo> explicitPathInfo, boolean loadBalancing) {
- checkNotNull(src);
- checkNotNull(dst);
- checkNotNull(tunnelName);
- checkNotNull(lspType);
-
- // Convert from DeviceId to TunnelEndPoint
- Device srcDevice = deviceService.getDevice(src);
- Device dstDevice = deviceService.getDevice(dst);
-
- if (srcDevice == null || dstDevice == null) {
- // Device is not known.
- pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType, explicitPathInfo,
- loadBalancing));
- return false;
- }
-
- // In future projections instead of annotations will be used to fetch LSR ID.
- String srcLsrId = srcDevice.annotations().value(LSRID);
- String dstLsrId = dstDevice.annotations().value(LSRID);
-
- if (srcLsrId == null || dstLsrId == null) {
- // LSR id is not known.
- pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType, explicitPathInfo,
- loadBalancing));
- return false;
- }
-
- // Get device config from netconfig, to ascertain that session with ingress is present.
- DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(srcLsrId), DeviceCapability.class);
- if (cfg == null) {
- log.debug("No session to ingress.");
- pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType, explicitPathInfo,
- loadBalancing));
- return false;
- }
-
- TunnelEndPoint srcEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(srcLsrId));
- TunnelEndPoint dstEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dstLsrId));
-
- double bwConstraintValue = 0;
- CostConstraint costConstraint = null;
- if (constraints != null) {
- constraints.add(CapabilityConstraint.of(CapabilityType.valueOf(lspType.name())));
- Iterator<Constraint> iterator = constraints.iterator();
-
- while (iterator.hasNext()) {
- Constraint constraint = iterator.next();
- if (constraint instanceof PceBandwidthConstraint) {
- bwConstraintValue = ((PceBandwidthConstraint) constraint).bandwidth().bps();
- } else if (constraint instanceof CostConstraint) {
- costConstraint = (CostConstraint) constraint;
- }
- }
-
- /*
- * Add cost at the end of the list of constraints. The path computation algorithm also computes cumulative
- * cost. The function which checks the limiting/capability constraints also returns per link cost. This
- * function can either return the result of limiting/capability constraint validation or the value of link
- * cost, depending upon what is the last constraint in the loop.
- */
- if (costConstraint != null) {
- constraints.remove(costConstraint);
- constraints.add(costConstraint);
- }
- } else {
- constraints = new LinkedList<>();
- constraints.add(CapabilityConstraint.of(CapabilityType.valueOf(lspType.name())));
- }
- Set<Path> computedPathSet = Sets.newLinkedHashSet();
-
- if (loadBalancing) {
- return setupDisjointPaths(src, dst, constraints, tunnelName, bwConstraintValue, lspType, costConstraint,
- srcEndPoint, dstEndPoint);
- }
-
- if (explicitPathInfo != null && !explicitPathInfo.isEmpty()) {
- List<Path> finalComputedPath = computeExplicitPath(explicitPathInfo, src, dst, constraints);
- if (finalComputedPath == null) {
- return false;
- }
-
- pceStore.tunnelNameExplicitPathInfoMap(tunnelName, explicitPathInfo);
- List<Link> links = new LinkedList<>();
- double totalCost = 0;
- // Add all partial computed paths
- for (Path path : finalComputedPath) {
- links.addAll(path.links());
- totalCost = totalCost + path.cost();
- }
- computedPathSet.add(new DefaultPath(finalComputedPath.iterator().next().providerId(), links,
- ScalarWeight.toWeight(totalCost)));
- } else {
- computedPathSet = computePath(src, dst, constraints);
- }
-
- // NO-PATH
- if (computedPathSet.isEmpty()) {
- pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType, explicitPathInfo,
- loadBalancing));
- return false;
- }
-
- Builder annotationBuilder = DefaultAnnotations.builder();
- if (bwConstraintValue != 0) {
- annotationBuilder.set(BANDWIDTH, String.valueOf(bwConstraintValue));
- }
- if (costConstraint != null) {
- annotationBuilder.set(COST_TYPE, String.valueOf(costConstraint.type()));
- }
- annotationBuilder.set(LSP_SIG_TYPE, lspType.name());
- annotationBuilder.set(PCE_INIT, TRUE);
- annotationBuilder.set(DELEGATE, TRUE);
-
- Path computedPath = computedPathSet.iterator().next();
-
- if (lspType != WITH_SIGNALLING) {
- /*
- * Local LSP id which is assigned by RSVP for RSVP signalled LSPs, will be assigned by
- * PCE for non-RSVP signalled LSPs.
- */
- annotationBuilder.set(LOCAL_LSP_ID, String.valueOf(getNextLocalLspId()));
- }
-
- // For SR-TE tunnels, call SR manager for label stack and put it inside tunnel.
- Tunnel tunnel = new DefaultTunnel(null, srcEndPoint, dstEndPoint, MPLS, INIT, null, null,
- TunnelName.tunnelName(tunnelName), computedPath,
- annotationBuilder.build());
-
- // Allocate bandwidth for all tunnels.
- if (bwConstraintValue != 0) {
- if (!reserveBandwidth(computedPath, bwConstraintValue, null)) {
- pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints,
- lspType, explicitPathInfo, loadBalancing));
- return false;
- }
- }
-
- TunnelId tunnelId = tunnelService.setupTunnel(appId, src, tunnel, computedPath);
- if (tunnelId == null) {
- pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType, explicitPathInfo,
- loadBalancing));
-
- if (bwConstraintValue != 0) {
- computedPath.links().forEach(ln -> bandwidthMgmtService.releaseLocalReservedBw(LinkKey.linkKey(ln),
- Double.parseDouble(tunnel.annotations().value(BANDWIDTH))));
- }
-
- return false;
- }
-
- if (bwConstraintValue != 0 && lspType == WITH_SIGNALLING) {
- rsvpTunnelsWithLocalBw.add(tunnelId);
- }
-
- return true;
- }
-
- private boolean setupDisjointPaths(DeviceId src, DeviceId dst, List<Constraint> constraints, String tunnelName,
- double bwConstraintValue, LspType lspType, CostConstraint costConstraint,
- TunnelEndPoint srcEndPoint, TunnelEndPoint dstEndPoint) {
- Set<DisjointPath> paths = pathService.getDisjointPaths(src, dst, weight(constraints));
-
- // NO-PATH
- if (paths.isEmpty()) {
- pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType, null, true));
- return false;
- }
-
- DisjointPath path = paths.iterator().next();
-
- Builder annotationBuilder = DefaultAnnotations.builder();
- double bw = 0;
- if (bwConstraintValue != 0) {
- //TODO: BW needs to be divided by 2 :: bwConstraintValue/2
- bw = bwConstraintValue / 2;
- annotationBuilder.set(BANDWIDTH, String.valueOf(bw));
- }
- if (costConstraint != null) {
- annotationBuilder.set(COST_TYPE, String.valueOf(costConstraint.type()));
- }
- annotationBuilder.set(LSP_SIG_TYPE, lspType.name());
- annotationBuilder.set(PCE_INIT, TRUE);
- annotationBuilder.set(DELEGATE, TRUE);
- annotationBuilder.set(LOAD_BALANCING_PATH_NAME, tunnelName);
-
- //Path computedPath = computedPathSet.iterator().next();
-
- if (lspType != WITH_SIGNALLING) {
- /*
- * Local LSP id which is assigned by RSVP for RSVP signalled LSPs, will be assigned by
- * PCE for non-RSVP signalled LSPs.
- */
- annotationBuilder.set(LOCAL_LSP_ID, String.valueOf(getNextLocalLspId()));
- }
-
- //Generate different tunnel name for disjoint paths
- String tunnel1 = (new StringBuilder()).append(tunnelName).append("_1").toString();
- String tunnel2 = (new StringBuilder()).append(tunnelName).append("_2").toString();
-
- // For SR-TE tunnels, call SR manager for label stack and put it inside tunnel.
- Tunnel tunnelPrimary = new DefaultTunnel(null, srcEndPoint, dstEndPoint, MPLS, INIT, null, null,
- TunnelName.tunnelName(tunnel1), path.primary(),
- annotationBuilder.build());
-
- Tunnel tunnelBackup = new DefaultTunnel(null, srcEndPoint, dstEndPoint, MPLS, INIT, null, null,
- TunnelName.tunnelName(tunnel2), path.backup(),
- annotationBuilder.build());
-
- // Allocate bandwidth.
- if (bwConstraintValue != 0) {
- if (!reserveBandwidth(path.primary(), bw, null)) {
- pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnel1, constraints,
- lspType, null, true));
- return false;
- }
-
- if (!reserveBandwidth(path.backup(), bw, null)) {
- //Release bandwidth resource for tunnel1
- if (bwConstraintValue != 0) {
- path.primary().links().forEach(ln ->
- bandwidthMgmtService.releaseLocalReservedBw(LinkKey.linkKey(ln),
- Double.parseDouble(tunnelPrimary.annotations().value(BANDWIDTH))));
- }
-
- pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnel2, constraints,
- lspType, null, true));
- return false;
- }
- }
-
- TunnelId tunnelId1 = tunnelService.setupTunnel(appId, src, tunnelPrimary, path.primary());
- if (tunnelId1 == null) {
- pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType, null, true));
-
- if (bwConstraintValue != 0) {
- path.primary().links().forEach(ln -> bandwidthMgmtService.releaseLocalReservedBw(LinkKey.linkKey(ln),
- Double.parseDouble(tunnelPrimary.annotations().value(BANDWIDTH))));
- }
-
- return false;
- }
-
- TunnelId tunnelId2 = tunnelService.setupTunnel(appId, src, tunnelBackup, path.backup());
- if (tunnelId2 == null) {
- //Release 1st tunnel
- releasePath(tunnelId1);
-
- pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType, null, true));
-
- if (bwConstraintValue != 0) {
- path.backup().links().forEach(ln -> bandwidthMgmtService.releaseLocalReservedBw(LinkKey.linkKey(ln),
- Double.parseDouble(tunnelBackup.annotations().value(BANDWIDTH))));
- }
-
- return false;
- }
-
- pceStore.addLoadBalancingTunnelIdsInfo(tunnelName, tunnelId1, tunnelId2);
- //pceStore.addDisjointPathInfo(tunnelName, path);
- return true;
- }
-
- @Override
- public boolean updatePath(TunnelId tunnelId, List<Constraint> constraints) {
- checkNotNull(tunnelId);
- Set<Path> computedPathSet = Sets.newLinkedHashSet();
- Tunnel tunnel = tunnelService.queryTunnel(tunnelId);
-
- if (tunnel == null) {
- return false;
- }
-
- if (tunnel.type() != MPLS || FALSE.equalsIgnoreCase(tunnel.annotations().value(DELEGATE))) {
- // Only delegated LSPs can be updated.
- return false;
- }
-
- List<Link> links = tunnel.path().links();
- String lspSigType = tunnel.annotations().value(LSP_SIG_TYPE);
- double bwConstraintValue = 0;
- String costType = null;
- SharedBandwidthConstraint shBwConstraint = null;
- PceBandwidthConstraint bwConstraint = null;
- CostConstraint costConstraint = null;
-
- if (constraints != null) {
- // Call path computation in shared bandwidth mode.
- Iterator<Constraint> iterator = constraints.iterator();
- while (iterator.hasNext()) {
- Constraint constraint = iterator.next();
- if (constraint instanceof PceBandwidthConstraint) {
- bwConstraint = (PceBandwidthConstraint) constraint;
- bwConstraintValue = bwConstraint.bandwidth().bps();
- } else if (constraint instanceof CostConstraint) {
- costConstraint = (CostConstraint) constraint;
- costType = costConstraint.type().name();
- }
- }
-
- // Remove and keep the cost constraint at the end of the list of constraints.
- if (costConstraint != null) {
- constraints.remove(costConstraint);
- }
-
- Bandwidth existingBwValue = null;
- String existingBwAnnotation = tunnel.annotations().value(BANDWIDTH);
- if (existingBwAnnotation != null) {
- existingBwValue = Bandwidth.bps(Double.parseDouble(existingBwAnnotation));
-
- /*
- * The computation is a shared bandwidth constraint based, so need to remove bandwidth constraint which
- * has been utilized to create shared bandwidth constraint.
- */
- if (bwConstraint != null) {
- constraints.remove(bwConstraint);
- }
- }
-
- if (existingBwValue != null) {
- if (bwConstraint == null) {
- bwConstraintValue = existingBwValue.bps();
- }
- //If bandwidth constraints not specified , take existing bandwidth for shared bandwidth calculation
- shBwConstraint = bwConstraint != null ? new SharedBandwidthConstraint(links,
- existingBwValue, bwConstraint.bandwidth()) : new SharedBandwidthConstraint(links,
- existingBwValue, existingBwValue);
-
- constraints.add(shBwConstraint);
- }
- } else {
- constraints = new LinkedList<>();
- }
-
- constraints.add(CapabilityConstraint.of(CapabilityType.valueOf(lspSigType)));
- if (costConstraint != null) {
- constraints.add(costConstraint);
- } else {
- //Take cost constraint from old tunnel if it is not specified in update flow
- costType = tunnel.annotations().value(COST_TYPE);
- costConstraint = CostConstraint.of(CostConstraint.Type.valueOf(costType));
- constraints.add(costConstraint);
- }
-
- List<ExplicitPathInfo> explicitPathInfo = pceStore
- .getTunnelNameExplicitPathInfoMap(tunnel.tunnelName().value());
- if (explicitPathInfo != null) {
- List<Path> finalComputedPath = computeExplicitPath(explicitPathInfo,
- tunnel.path().src().deviceId(), tunnel.path().dst().deviceId(),
- constraints);
-
- if (finalComputedPath == null) {
- return false;
- }
-
- List<Link> totalLinks = new LinkedList<>();
- double totalCost = 0;
- //Add all partial computed paths
- for (Path path : finalComputedPath) {
- totalLinks.addAll(path.links());
- totalCost = totalCost + path.cost();
- }
- computedPathSet.add(new DefaultPath(finalComputedPath.iterator().next().providerId(),
- totalLinks, ScalarWeight.toWeight(totalCost)));
- } else {
- computedPathSet = computePath(tunnel.path().src().deviceId(), tunnel.path().dst().deviceId(),
- constraints);
- }
-
- // NO-PATH
- if (computedPathSet.isEmpty()) {
- return false;
- }
-
- Builder annotationBuilder = DefaultAnnotations.builder();
- annotationBuilder.set(BANDWIDTH, String.valueOf(bwConstraintValue));
- if (costType != null) {
- annotationBuilder.set(COST_TYPE, costType);
- }
- annotationBuilder.set(LSP_SIG_TYPE, lspSigType);
- annotationBuilder.set(PCE_INIT, TRUE);
- annotationBuilder.set(DELEGATE, TRUE);
- annotationBuilder.set(PLSP_ID, tunnel.annotations().value(PLSP_ID));
- annotationBuilder.set(PCC_TUNNEL_ID, tunnel.annotations().value(PCC_TUNNEL_ID));
-
- Path computedPath = computedPathSet.iterator().next();
- LspType lspType = LspType.valueOf(lspSigType);
- long localLspId = 0;
- if (lspType != WITH_SIGNALLING) {
- /*
- * Local LSP id which is assigned by RSVP for RSVP signalled LSPs, will be assigned by
- * PCE for non-RSVP signalled LSPs.
- */
- localLspId = getNextLocalLspId();
- annotationBuilder.set(LOCAL_LSP_ID, String.valueOf(localLspId));
- }
-
- Tunnel updatedTunnel = new DefaultTunnel(null, tunnel.src(), tunnel.dst(), MPLS, INIT, null, null,
- tunnel.tunnelName(), computedPath,
- annotationBuilder.build());
-
- // Allocate shared bandwidth for all tunnels.
- if (bwConstraintValue != 0) {
- if (!reserveBandwidth(computedPath, bwConstraintValue, shBwConstraint)) {
- return false;
- }
- }
-
- TunnelId updatedTunnelId = tunnelService.setupTunnel(appId, links.get(0).src().deviceId(), updatedTunnel,
- computedPath);
-
- if (updatedTunnelId == null) {
- if (bwConstraintValue != 0) {
- releaseSharedBwForNewTunnel(computedPath, bwConstraintValue, shBwConstraint);
- }
- return false;
- }
-
- if (bwConstraintValue != 0 && lspType == WITH_SIGNALLING) {
- rsvpTunnelsWithLocalBw.add(updatedTunnelId);
- }
-
- return true;
- }
-
- @Override
- public boolean releasePath(TunnelId tunnelId) {
- checkNotNull(tunnelId);
- // 1. Query Tunnel from Tunnel manager.
- Tunnel tunnel = tunnelService.queryTunnel(tunnelId);
-
- if (tunnel == null) {
- return false;
- }
-
- // 2. Call tunnel service.
- return tunnelService.downTunnel(appId, tunnel.tunnelId());
- }
-
- @Override
- public boolean releasePath(String loadBalancingPathName) {
- checkNotNull(loadBalancingPathName);
-
- List<TunnelId> tunnelIds = pceStore.getLoadBalancingTunnelIds(loadBalancingPathName);
- if (tunnelIds != null && !tunnelIds.isEmpty()) {
- for (TunnelId id : tunnelIds) {
- if (!tunnelService.downTunnel(appId, id)) {
- return false;
- }
- }
-
- //pceStore.removeDisjointPathInfo(loadBalancedPathName);
- pceStore.removeLoadBalancingTunnelIdsInfo(loadBalancingPathName);
- return true;
- }
-
- return false;
- }
-
- @Override
- public Iterable<Tunnel> queryAllPath() {
- return tunnelService.queryTunnel(MPLS);
- }
-
- @Override
- public Tunnel queryPath(TunnelId tunnelId) {
- return tunnelService.queryTunnel(tunnelId);
- }
-
- private boolean releaseSharedBwForNewTunnel(Path computedPath, double bandwidthConstraint,
- SharedBandwidthConstraint shBwConstraint) {
- checkNotNull(computedPath);
- double bwToAllocate;
-
- Double additionalBwValue = null;
- if (shBwConstraint != null) {
- additionalBwValue = ((bandwidthConstraint - shBwConstraint.sharedBwValue().bps()) <= 0) ? null
- : (bandwidthConstraint - shBwConstraint.sharedBwValue().bps());
- }
-
- for (Link link : computedPath.links()) {
- bwToAllocate = 0;
- if ((shBwConstraint != null) && (shBwConstraint.links().contains(link))) {
- if (additionalBwValue != null) {
- bwToAllocate = additionalBwValue;
- }
- } else {
- bwToAllocate = bandwidthConstraint;
- }
-
- if (bwToAllocate != 0) {
- bandwidthMgmtService.releaseLocalReservedBw(LinkKey.linkKey(link), bwToAllocate);
- }
- }
- return true;
- }
-
- /**
- * Returns the next local LSP identifier to be used either by getting from
- * freed list if available otherwise generating a new one.
- *
- * @return value of local LSP identifier
- */
- private synchronized short getNextLocalLspId() {
- // If there is any free id use it. Otherwise generate new id.
- if (localLspIdFreeList.isEmpty()) {
- return (short) localLspIdIdGen.getNewId();
- }
- Iterator<Short> it = localLspIdFreeList.iterator();
- Short value = it.next();
- localLspIdFreeList.remove(value);
- return value;
- }
-
- protected class TeConstraintBasedLinkWeight implements LinkWeigher {
-
- private final List<Constraint> constraints;
-
- /**
- * Creates a new edge-weight function capable of evaluating links
- * on the basis of the specified constraints.
- *
- * @param constraints path constraints
- */
- public TeConstraintBasedLinkWeight(List<Constraint> constraints) {
- if (constraints == null) {
- this.constraints = Collections.emptyList();
- } else {
- this.constraints = ImmutableList.copyOf(constraints);
- }
- }
-
- @Override
- public Weight getInitialWeight() {
- return ScalarWeight.toWeight(0.0);
- }
-
- @Override
- public Weight getNonViableWeight() {
- return ScalarWeight.toWeight(0.0);
- }
-
- @Override
- public Weight weight(TopologyEdge edge) {
- if (!constraints.iterator().hasNext()) {
- //Takes default cost/hopcount as 1 if no constraints specified
- return ScalarWeight.toWeight(1.0);
- }
-
- Iterator<Constraint> it = constraints.iterator();
- double cost = 1;
-
- //If any constraint fails return -1 also value of cost returned from cost constraint can't be negative
- while (it.hasNext() && cost > 0) {
- Constraint constraint = it.next();
- if (constraint instanceof CapabilityConstraint) {
- cost = ((CapabilityConstraint) constraint).isValidLink(edge.link(), deviceService,
- netCfgService) ? 1 : -1;
- } else if (constraint instanceof PceBandwidthConstraint) {
- cost = ((PceBandwidthConstraint) constraint).isValidLink(edge.link(),
- bandwidthMgmtService) ? 1 : -1;
- } else if (constraint instanceof SharedBandwidthConstraint) {
- cost = ((SharedBandwidthConstraint) constraint).isValidLink(edge.link(),
- bandwidthMgmtService) ? 1 : -1;
- } else if (constraint instanceof CostConstraint) {
- cost = ((CostConstraint) constraint).isValidLink(edge.link(), netCfgService);
- } else {
- cost = constraint.cost(edge.link(), null);
- }
- }
- return ScalarWeight.toWeight(cost);
- }
- }
-
- //TODO: annotations used for temporarily later projection/network config will be used
- private class InternalTopologyListener implements TopologyListener {
- @Override
- public void event(TopologyEvent event) {
- event.reasons().forEach(e -> {
- //If event type is link removed, get the impacted tunnel
- if (e instanceof LinkEvent) {
- LinkEvent linkEvent = (LinkEvent) e;
- if (linkEvent.type() == LinkEvent.Type.LINK_REMOVED) {
- tunnelService.queryTunnel(MPLS).forEach(t -> {
- if (t.path().links().contains((e.subject()))) {
- // Check whether this ONOS instance is master for ingress device if yes,
- // recompute and send update
- checkForMasterAndUpdateTunnel(t.path().src().deviceId(), t);
- }
- });
- }
- }
- });
- }
- }
-
- private boolean checkForMasterAndUpdateTunnel(DeviceId src, Tunnel tunnel) {
- /**
- * Master of ingress node will recompute and also delegation flag must be set.
- */
- if (mastershipService.isLocalMaster(src)
- && Boolean.valueOf(tunnel.annotations().value(DELEGATE)) != null) {
- LinkedList<Constraint> constraintList = new LinkedList<>();
-
- if (tunnel.annotations().value(BANDWIDTH) != null) {
- //Requested bandwidth will be same as previous allocated bandwidth for the tunnel
- PceBandwidthConstraint localConst = new PceBandwidthConstraint(Bandwidth.bps(Double.parseDouble(tunnel
- .annotations().value(BANDWIDTH))));
- constraintList.add(localConst);
- }
- if (tunnel.annotations().value(COST_TYPE) != null) {
- constraintList.add(CostConstraint.of(CostConstraint.Type.valueOf(tunnel.annotations().value(
- COST_TYPE))));
- }
-
- /*
- * If tunnel was UP after recomputation failed then store failed path in PCE store send PCIntiate(remove)
- * and If tunnel is failed and computation fails nothing to do because tunnel status will be same[Failed]
- */
- if (!updatePath(tunnel.tunnelId(), constraintList) && !tunnel.state().equals(Tunnel.State.FAILED)) {
- // If updation fails store in PCE store as failed path
- // then PCInitiate (Remove)
- pceStore.addFailedPathInfo(new PcePathInfo(tunnel.path().src().deviceId(), tunnel
- .path().dst().deviceId(), tunnel.tunnelName().value(), constraintList,
- LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)),
- pceStore.getTunnelNameExplicitPathInfoMap(tunnel.tunnelName().value()),
- tunnel.annotations().value(LOAD_BALANCING_PATH_NAME) != null ? true : false));
- //Release that tunnel calling PCInitiate
- releasePath(tunnel.tunnelId());
- }
- }
-
- return false;
- }
-
- // Allocates the bandwidth locally for PCECC tunnels.
- private boolean reserveBandwidth(Path computedPath, double bandwidthConstraint,
- SharedBandwidthConstraint shBwConstraint) {
- checkNotNull(computedPath);
- Resource resource = null;
- double bwToAllocate = 0;
- Map<Link, Double> linkMap = new HashMap<>();
-
- /**
- * Shared bandwidth sub-case : Lesser bandwidth required than original -
- * No reservation required.
- */
- Double additionalBwValue = null;
- if (shBwConstraint != null) {
- additionalBwValue = ((bandwidthConstraint - shBwConstraint.sharedBwValue().bps()) <= 0) ? null
- : (bandwidthConstraint - shBwConstraint.sharedBwValue().bps());
- }
-
- Optional<ResourceAllocation> resAlloc = null;
- for (Link link : computedPath.links()) {
- bwToAllocate = 0;
- if ((shBwConstraint != null) && (shBwConstraint.links().contains(link))) {
- if (additionalBwValue != null) {
- bwToAllocate = additionalBwValue;
- }
- } else {
- bwToAllocate = bandwidthConstraint;
- }
-
- /**
- * In shared bandwidth cases, where new BW is lesser than old BW, it
- * is not required to allocate anything.
- */
- if (bwToAllocate != 0) {
- if (!bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link.src(), link.dst()),
- bwToAllocate)) {
- // If allocation for any link fails, then release the partially allocated bandwidth
- // for all links allocated
- linkMap.forEach((ln, aDouble) -> bandwidthMgmtService
- .releaseLocalReservedBw(LinkKey.linkKey(ln), aDouble));
- return false;
- }
-
- linkMap.put(link, bwToAllocate);
- }
- }
-
- return true;
- }
-
- /*
- * Deallocates the bandwidth which is reserved locally for PCECC tunnels.
- */
- private void releaseBandwidth(Tunnel tunnel) {
- // Between same source and destination, search the tunnel with same symbolic path name.
- Collection<Tunnel> tunnelQueryResult = tunnelService.queryTunnel(tunnel.src(), tunnel.dst());
- Tunnel newTunnel = null;
- for (Tunnel tunnelObj : tunnelQueryResult) {
- if (tunnel.tunnelName().value().equals(tunnelObj.tunnelName().value())) {
- newTunnel = tunnelObj;
- break;
- }
- }
-
- // Even if one link is shared, the bandwidth release should happen based on shared mechanism.
- boolean isLinkShared = false;
- if (newTunnel != null) {
- for (Link link : tunnel.path().links()) {
- if (newTunnel.path().links().contains(link)) {
- isLinkShared = true;
- break;
- }
- }
- }
-
- if (isLinkShared) {
- releaseSharedBandwidth(newTunnel, tunnel);
- return;
- }
-
- tunnel.path().links().forEach(tn -> bandwidthMgmtService.releaseLocalReservedBw(LinkKey.linkKey(tn),
- Double.parseDouble(tunnel.annotations().value(BANDWIDTH))));
- }
-
- /**
- * Re-allocates the bandwidth for the tunnel for which the bandwidth was
- * allocated in shared mode initially.
- */
- private synchronized void releaseSharedBandwidth(Tunnel newTunnel, Tunnel oldTunnel) {
-
- boolean isAllocate = false;
- Double oldTunnelBw = Double.parseDouble(oldTunnel.annotations().value(BANDWIDTH));
- Double newTunnelBw = Double.parseDouble(newTunnel.annotations().value(BANDWIDTH));
-
- if (newTunnelBw > oldTunnelBw) {
- isAllocate = true;
- }
-
- for (Link link : newTunnel.path().links()) {
- if (oldTunnel.path().links().contains(link)) {
- if (!isAllocate) {
- bandwidthMgmtService.releaseLocalReservedBw(LinkKey.linkKey(link),
- oldTunnelBw - newTunnelBw);
- }
- } else {
- bandwidthMgmtService.releaseLocalReservedBw(LinkKey.linkKey(link), oldTunnelBw);
- }
- }
- }
-
- // Listens on tunnel events.
- private class InnerTunnelListener implements TunnelListener {
- @Override
- public void event(TunnelEvent event) {
- // Event gets generated with old tunnel object.
- Tunnel tunnel = event.subject();
- if (tunnel.type() != MPLS) {
- return;
- }
-
- LspType lspType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE));
- String tunnelBandwidth = tunnel.annotations().value(BANDWIDTH);
- double bwConstraintValue = 0;
- if (tunnelBandwidth != null) {
- bwConstraintValue = Double.parseDouble(tunnelBandwidth);
- }
-
- switch (event.type()) {
- case TUNNEL_UPDATED:
- if (rsvpTunnelsWithLocalBw.contains(tunnel.tunnelId())) {
- releaseBandwidth(event.subject());
- rsvpTunnelsWithLocalBw.remove(tunnel.tunnelId());
- }
-
- if (tunnel.state() == UNSTABLE) {
- /*
- * During LSP DB sync if PCC doesn't report LSP which was PCE initiated, it's state is turned into
- * unstable so that it can be setup again. Add into failed path store so that it can be recomputed
- * and setup while global reoptimization.
- */
-
- List<Constraint> constraints = new LinkedList<>();
- String bandwidth = tunnel.annotations().value(BANDWIDTH);
- if (bandwidth != null) {
- constraints.add(new PceBandwidthConstraint(Bandwidth
- .bps(Double.parseDouble(bandwidth))));
- }
-
- String costType = tunnel.annotations().value(COST_TYPE);
- if (costType != null) {
- CostConstraint costConstraint = new CostConstraint(CostConstraint.Type.valueOf(costType));
- constraints.add(costConstraint);
- }
-
- constraints.add(CapabilityConstraint
- .of(CapabilityType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE))));
-
- List<Link> links = tunnel.path().links();
- pceStore.addFailedPathInfo(new PcePathInfo(links.get(0).src().deviceId(),
- links.get(links.size() - 1).dst().deviceId(),
- tunnel.tunnelName().value(), constraints, lspType,
- pceStore.getTunnelNameExplicitPathInfoMap(tunnel
- .tunnelName().value()), tunnel.annotations()
- .value(LOAD_BALANCING_PATH_NAME) != null ? true : false));
- }
-
- break;
-
- case TUNNEL_REMOVED:
- if (lspType != WITH_SIGNALLING) {
- localLspIdFreeList.add(Short.valueOf(tunnel.annotations().value(LOCAL_LSP_ID)));
- }
- // If not zero bandwidth, and delegated (initiated LSPs will also be delegated).
- if (bwConstraintValue != 0 && mastershipService.getLocalRole(tunnel.path().src()
- .deviceId()) == MastershipRole.MASTER) {
- if (lspType != WITH_SIGNALLING) {
- releaseBandwidth(tunnel);
- }
- }
-
- /*if (pceStore.getTunnelInfo(tunnel.tunnelId()) != null) {
- pceStore.removeTunnelInfo(tunnel.tunnelId());
- }*/
-
- break;
-
- default:
- break;
-
- }
- return;
- }
- }
-
- @Override
- public List<ExplicitPathInfo> explicitPathInfoList(String tunnelName) {
- return pceStore.getTunnelNameExplicitPathInfoMap(tunnelName);
- }
-
- @Override
- public List<TunnelId> queryLoadBalancingPath(String pathName) {
- return pceStore.getLoadBalancingTunnelIds(pathName);
- }
-
- //Computes path from tunnel store and also path failed to setup.
- private void callForOptimization() {
- //Recompute the LSPs which it was delegated [LSPs stored in PCE store (failed paths)]
- for (PcePathInfo failedPathInfo : pceStore.getFailedPathInfos()) {
- checkForMasterAndSetupPath(failedPathInfo);
- }
-
- //Recompute the LSPs for which it was delegated [LSPs stored in tunnel store]
- tunnelService.queryTunnel(MPLS).forEach(t -> {
- checkForMasterAndUpdateTunnel(t.path().src().deviceId(), t);
- });
- }
-
- private boolean checkForMasterAndSetupPath(PcePathInfo failedPathInfo) {
- /**
- * Master of ingress node will setup the path failed stored in PCE store.
- */
- if (mastershipService.isLocalMaster(failedPathInfo.src())) {
- if (setupPath(failedPathInfo.src(), failedPathInfo.dst(), failedPathInfo.name(),
- failedPathInfo.constraints(), failedPathInfo.lspType(), failedPathInfo.explicitPathInfo())) {
- // If computation is success remove that path
- pceStore.removeFailedPathInfo(failedPathInfo);
- return true;
- }
- }
-
- return false;
- }
-
- //Timer to call global optimization
- private class GlobalOptimizationTimer implements Runnable {
-
- public GlobalOptimizationTimer() {
- }
-
- @Override
- public void run() {
- callForOptimization();
- }
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PcePath.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PcePath.java
deleted file mode 100644
index cfe7e87..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PcePath.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pce.pceservice;
-
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.net.intent.Constraint;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Abstraction of an entity which provides functionalities of pce path.
- */
-public interface PcePath {
-
- /**
- * Returns the attribute path id.
- *
- * @return path id
- */
- TunnelId id();
-
- /**
- * Sets the attribute path id.
- *
- * @param id path id
- */
- void id(TunnelId id);
-
- /**
- * Returns the attribute ingress.
- *
- * @return source
- */
- String source();
-
- /**
- * Sets the attribute ingress.
- *
- * @param src pce source
- */
- void source(String src);
-
- /**
- * Returns the attribute egress.
- *
- * @return destination
- */
- String destination();
-
- /**
- * Sets the attribute egress.
- *
- * @param dst pce destination.
- */
- void destination(String dst);
-
- /**
- * Returns the attribute lspType.
- *
- * @return lspType
- */
- LspType lspType();
-
- /**
- * Returns the attribute symbolic-path-name.
- *
- * @return symbolic-path-name
- */
- String name();
-
- /**
- * Returns the attribute cost constraint.
- *
- * @return cost constraint
- */
- Constraint costConstraint();
-
- /**
- * Returns the attribute bandwidth constraint.
- *
- * @return bandwidth constraint
- */
- Constraint bandwidthConstraint();
-
- /**
- * Returns the list of explicit path objects.
- *
- * @return list of explicit path objects
- */
- Collection<ExplicitPathInfo> explicitPathInfo();
-
- /**
- * Copies only non-null or non-zero member variables.
- *
- * @param id path-id
- * @return pce-path
- */
- PcePath copy(PcePath id);
-
- /**
- * Builder for pce path.
- */
- interface Builder {
-
- /**
- * Returns the builder object of path id.
- *
- * @param id path id
- * @return builder object of path id
- */
- Builder id(String id);
-
- /**
- * Returns the builder object of ingress.
- *
- * @param source ingress
- * @return builder object of ingress
- */
- Builder source(String source);
-
- /**
- * Returns the builder object of egress.
- *
- * @param destination egress
- * @return builder object of egress
- */
- Builder destination(String destination);
-
- /**
- * Returns the builder object of lspType.
- *
- * @param lspType lsp type
- * @return builder object of lsp type
- */
- Builder lspType(String lspType);
-
- /**
- * Returns the builder object of symbolic-path-name.
- *
- * @param n symbolic-path-name
- * @return builder object of symbolic-path-name
- */
- Builder name(String n);
-
- /**
- * Returns the builder object of cost constraint.
- *
- * @param cost constraint
- * @return builder object of cost constraint
- */
- Builder costConstraint(String cost);
-
- /**
- * Returns the builder object of bandwidth constraint.
- *
- * @param bandwidth constraint
- * @return builder object of bandwidth constraint
- */
- Builder bandwidthConstraint(String bandwidth);
-
- /**
- * Copies tunnel information to local.
- *
- * @param tunnel pcc tunnel
- * @param explicitPathInfoList list of explicit path objects info
- * @return object of pce-path
- */
- Builder of(Tunnel tunnel, List<ExplicitPathInfo> explicitPathInfoList);
-
- /**
- * Returns the builder object of ExplicitPathInfo.
- *
- * @param explicitPathInfo list of explicit path obj
- * @return builder object of ExplicitPathInfo
- */
- Builder explicitPathInfo(Collection<ExplicitPathInfo> explicitPathInfo);
-
- /**
- * Builds object of pce path.
- *
- * @return object of pce path.
- */
- PcePath build();
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PcepAnnotationKeys.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PcepAnnotationKeys.java
deleted file mode 100644
index 91dca03..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PcepAnnotationKeys.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pceservice;
-
-/**
- * Collection of keys for annotation for PCEP tunnels.
- */
-public final class PcepAnnotationKeys {
-
- /**
- * Prohibits instantiation.
- */
- private PcepAnnotationKeys() {
- }
-
- /**
- * Annotation key for bandwidth.
- * The value for this key is interpreted as Mbps.
- */
- public static final String BANDWIDTH = "bandwidth";
-
- /**
- * Annotation key for the LSP signaling type.
- */
- public static final String LSP_SIG_TYPE = "lspSigType";
-
- /**
- * Annotation key for the PCC tunnel id.
- */
- public static final String PCC_TUNNEL_ID = "PccTunnelId";
-
- /**
- * Annotation key for the LSP id assigned per tunnel per session.
- */
- public static final String PLSP_ID = "PLspId";
-
- /**
- * Annotation key for the LSP id assigned per tunnel.
- */
- public static final String LOCAL_LSP_ID = "localLspId";
-
- /**
- * Annotation key for the identification of initiated LSP.
- */
- public static final String PCE_INIT = "pceInit";
-
- /**
- * Annotation key for the cost type.
- */
- public static final String COST_TYPE = "costType";
-
- /**
- * Annotation key for the Delegation.
- * Whether LSPs are delegated or not.
- */
- public static final String DELEGATE = "delegate";
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/TunnelConsumerId.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/TunnelConsumerId.java
deleted file mode 100644
index 4474b4c..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/TunnelConsumerId.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pceservice;
-
-import org.onlab.util.Identifier;
-import org.onosproject.net.resource.ResourceConsumer;
-
-import com.google.common.annotations.Beta;
-import org.onosproject.net.resource.ResourceConsumerId;
-
-/**
- * Tunnel resource consumer identifier suitable to be used as a consumer id for
- * resource allocations.
- */
-@Beta
-public final class TunnelConsumerId extends Identifier<Long> implements ResourceConsumer {
-
- /**
- * Creates a tunnel resource consumer identifier from the specified long value.
- *
- * @param value long value to be used as tunnel resource consumer id
- * @return tunnel resource consumer identifier
- */
- public static TunnelConsumerId valueOf(long value) {
- return new TunnelConsumerId(value);
- }
-
- /**
- * Initializes object for serializer.
- */
- public TunnelConsumerId() {
- super(0L);
- }
-
- /**
- * Constructs the tunnel resource consumer id corresponding to a given long
- * value.
- *
- * @param value the underlying value in long representation of this tunnel
- * resource consumer id
- */
- public TunnelConsumerId(long value) {
- super(value);
- }
-
- /**
- * Returns the backing identifier value.
- *
- * @return value backing identifier value
- */
- public long value() {
- return identifier;
- }
-
- @Override
- public String toString() {
- return "0x" + Long.toHexString(identifier);
- }
-
- @Override
- public ResourceConsumerId consumerId() {
- return ResourceConsumerId.of(this);
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/api/PceService.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/api/PceService.java
deleted file mode 100644
index ac0a66c..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/api/PceService.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pceservice.api;
-
-import java.util.List;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.pce.pceservice.ExplicitPathInfo;
-import org.onosproject.pce.pceservice.LspType;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-
-/**
- * Service to compute path based on constraints, release path,
- * update path with new constraints and query existing tunnels.
- */
-public interface PceService {
-
- /**
- * Creates new path based on constraints and LSP type.
- *
- * @param src source device
- * @param dst destination device
- * @param tunnelName name of the tunnel
- * @param constraints list of constraints to be applied on path
- * @param lspType type of path to be setup
- * @return false on failure and true on successful path creation
- */
- boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints, LspType lspType);
-
- /**
- * Creates new path based on constraints and LSP type.
- *
- * @param src source device
- * @param dst destination device
- * @param tunnelName name of the tunnel
- * @param constraints list of constraints to be applied on path
- * @param lspType type of path to be setup
- * @param explicitPathInfo list of explicit path info
- * @return false on failure and true on successful path creation
- */
- boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints, LspType lspType,
- List<ExplicitPathInfo> explicitPathInfo);
-
- /**
- * Creates new path based on constraints and LSP type with load balancing option.
- *
- * @param src source device
- * @param dst destination device
- * @param tunnelName name of the tunnel
- * @param constraints list of constraints to be applied on path
- * @param lspType type of path to be setup
- * @param loadBalancing load balancing option enable or not
- * @return false on failure and true on successful path creation
- */
- boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints, LspType lspType,
- boolean loadBalancing);
-
- /**
- * Creates new path based on constraints and LSP type with load balancing and explicit path options.
- *
- * @param src source device
- * @param dst destination device
- * @param tunnelName name of the tunnel
- * @param constraints list of constraints to be applied on path
- * @param lspType type of path to be setup
- * @param explicitPathInfo list of explicit path info
- * @param loadBalancing load balancing option enable or not
- * @return false on failure and true on successful path creation
- */
- boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints, LspType lspType,
- List<ExplicitPathInfo> explicitPathInfo, boolean loadBalancing);
-
- /**
- * Updates an existing path.
- *
- * @param tunnelId tunnel identifier
- * @param constraints list of constraints to be applied on path
- * @return false on failure and true on successful path update
- */
- boolean updatePath(TunnelId tunnelId, List<Constraint> constraints);
-
- /**
- * Releases an existing path.
- *
- * @param tunnelId tunnel identifier
- * @return false on failure and true on successful path removal
- */
- boolean releasePath(TunnelId tunnelId);
-
- /**
- * Releases load balancing paths.
- *
- * @param loadBalancingPathName load balance path name
- * @return false on failure and true on successful paths removal
- */
- boolean releasePath(String loadBalancingPathName);
-
- /**
- * Queries all paths.
- *
- * @return iterable of existing tunnels
- */
- Iterable<Tunnel> queryAllPath();
-
- /**
- * Queries particular path based on tunnel identifier.
- *
- * @param tunnelId tunnel identifier
- * @return tunnel if path exists, otherwise null
- */
- Tunnel queryPath(TunnelId tunnelId);
-
- /**
- * Returns list of explicit path info.
- *
- * @param tunnelName tunnel name
- * @return list of explicit path info
- */
- List<ExplicitPathInfo> explicitPathInfoList(String tunnelName);
-
- /**
- * Queries load balancing paths on load balance path name.
- *
- * @param pathName load balance path name
- * @return list of load balancing tunnels
- */
- List<TunnelId> queryLoadBalancingPath(String pathName);
-}
\ No newline at end of file
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/api/package-info.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/api/package-info.java
deleted file mode 100644
index bf2225d..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/api/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCE service API.
- */
-package org.onosproject.pce.pceservice.api;
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/CapabilityConstraint.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/CapabilityConstraint.java
deleted file mode 100644
index c4630b8..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/CapabilityConstraint.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pceservice.constraint;
-
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.intent.ResourceContext;
-import org.onosproject.net.intent.constraint.BooleanConstraint;
-import org.onosproject.pcep.api.DeviceCapability;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Constraint that evaluates whether devices satisfies capability.
- */
-public final class CapabilityConstraint extends BooleanConstraint {
-
- private final CapabilityType capabilityType;
- public static final String LSRID = "lsrId";
- public static final String TRUE = "true";
-
- /**
- * Represents about capability type.
- */
- public enum CapabilityType {
- /**
- * Signifies that path is created via signaling mode.
- */
- WITH_SIGNALLING(0),
-
- /**
- * Signifies that path is created via SR mode.
- */
- SR_WITHOUT_SIGNALLING(1),
-
- /**
- * Signifies that path is created via without signaling and without SR mode.
- */
- WITHOUT_SIGNALLING_AND_WITHOUT_SR(2);
-
- int value;
-
- /**
- * Assign val with the value as the capability type.
- *
- * @param val capability type
- */
- CapabilityType(int val) {
- value = val;
- }
-
- /**
- * Returns value of capability type.
- *
- * @return capability type
- */
- public byte type() {
- return (byte) value;
- }
- }
-
- // Constructor for serialization
- private CapabilityConstraint() {
- capabilityType = null;
- }
-
- /**
- * Creates a new capability constraint.
- *
- * @param capabilityType type of capability device supports
- */
- public CapabilityConstraint(CapabilityType capabilityType) {
- this.capabilityType = capabilityType;
- }
-
- /**
- * Creates a new capability constraint.
- *
- * @param capabilityType type of capability device supports
- * @return instance of CapabilityConstraint for specified capability type
- */
- public static CapabilityConstraint of(CapabilityType capabilityType) {
- return new CapabilityConstraint(capabilityType);
- }
-
- /**
- * Obtains type of capability.
- *
- * @return type of capability
- */
- public CapabilityType capabilityType() {
- return capabilityType;
- }
-
- /**
- * Validates the link based on capability constraint.
- *
- * @param link to validate source and destination based on capability constraint
- * @param deviceService instance of DeviceService
- * @param netCfgService instance of NetworkConfigService
- * @return true if link satisfies capability constraint otherwise false
- */
- public boolean isValidLink(Link link, DeviceService deviceService, NetworkConfigService netCfgService) {
- if (deviceService == null || netCfgService == null) {
- return false;
- }
-
- Device srcDevice = deviceService.getDevice(link.src().deviceId());
- Device dstDevice = deviceService.getDevice(link.dst().deviceId());
-
- //TODO: Usage of annotations are for transient solution. In future will be replaced with the
- // network config service / Projection model.
- // L3 device
- if (srcDevice == null || dstDevice == null) {
- return false;
- }
-
- String srcLsrId = srcDevice.annotations().value(LSRID);
- String dstLsrId = dstDevice.annotations().value(LSRID);
-
- DeviceCapability srcDeviceConfig = netCfgService.getConfig(DeviceId.deviceId(srcLsrId),
- DeviceCapability.class);
- DeviceCapability dstDeviceConfig = netCfgService.getConfig(DeviceId.deviceId(dstLsrId),
- DeviceCapability.class);
-
- switch (capabilityType) {
- case WITH_SIGNALLING:
- return true;
- case WITHOUT_SIGNALLING_AND_WITHOUT_SR:
- return srcDeviceConfig != null && dstDeviceConfig != null
- && srcDeviceConfig.localLabelCap() && dstDeviceConfig.localLabelCap();
- case SR_WITHOUT_SIGNALLING:
- return srcDeviceConfig != null && dstDeviceConfig != null && srcDeviceConfig.srCap()
- && dstDeviceConfig.srCap() && srcDeviceConfig.labelStackCap() && dstDeviceConfig.labelStackCap();
- default:
- return false;
- }
- }
-
- @Override
- public boolean isValid(Link link, ResourceContext context) {
- return false;
- //Do nothing instead using isValidLink needs device service to validate link
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(capabilityType);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof CapabilityConstraint) {
- CapabilityConstraint other = (CapabilityConstraint) obj;
- return Objects.equals(this.capabilityType, other.capabilityType);
- }
-
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("capabilityType", capabilityType)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/CostConstraint.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/CostConstraint.java
deleted file mode 100644
index ce00308..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/CostConstraint.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pceservice.constraint;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-import org.onosproject.net.Path;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.intent.ResourceContext;
-import org.onosproject.pcep.api.TeLinkConfig;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Constraint that evaluates whether cost for a link is available, if yes return cost for that link.
- */
-public final class CostConstraint implements Constraint {
-
- /**
- * Represents about cost types.
- */
- public enum Type {
- /**
- * Signifies that cost is IGP cost.
- */
- COST(1),
-
- /**
- * Signifies that cost is TE cost.
- */
- TE_COST(2);
-
- int value;
-
- /**
- * Assign val with the value as the Cost type.
- *
- * @param val Cost type
- */
- Type(int val) {
- value = val;
- }
-
- /**
- * Returns value of Cost type.
- *
- * @return Cost type
- */
- public byte type() {
- return (byte) value;
- }
- }
-
- private final Type type;
- public static final String TE_COST = "teCost";
- public static final String COST = "cost";
-
- // Constructor for serialization
- private CostConstraint() {
- this.type = null;
- }
-
- /**
- * Creates a new cost constraint.
- *
- * @param type of a link
- */
- public CostConstraint(Type type) {
- this.type = checkNotNull(type, "Type cannot be null");
- }
-
- /**
- * Creates new CostConstraint with specified cost type.
- *
- * @param type of cost
- * @return instance of CostConstraint
- */
- public static CostConstraint of(Type type) {
- return new CostConstraint(type);
- }
-
- /**
- * Returns the type of a cost specified in a constraint.
- *
- * @return required cost type
- */
- public Type type() {
- return type;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof CostConstraint) {
- CostConstraint other = (CostConstraint) obj;
- return Objects.equals(this.type, other.type);
- }
-
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("type", type)
- .toString();
- }
-
- @Override
- public double cost(Link link, ResourceContext context) {
- return 0;
- }
-
- /**
- * Validates the link based on cost type specified.
- *
- * @param link to validate cost type constraint
- * @param netCfgService instance of netCfgService
- * @return true if link satisfies cost constraint otherwise false
- */
- public double isValidLink(Link link, NetworkConfigService netCfgService) {
- if (netCfgService == null) {
- return -1;
- }
-
- TeLinkConfig cfg = netCfgService.getConfig(LinkKey.linkKey(link.src(), link.dst()), TeLinkConfig.class);
- if (cfg == null) {
- //If cost configuration absent return -1[It is not L3 device]
- return -1;
- }
-
- switch (type) {
- case COST:
- //If IGP cost is zero then IGP cost is not assigned for that link
- return cfg.igpCost() == 0 ? -1 : cfg.igpCost();
-
- case TE_COST:
- //If TE cost is zero then TE cost is not assigned for that link
- return cfg.teCost() == 0 ? -1 : cfg.teCost();
-
- default:
- return -1;
- }
- }
-
- @Override
- public boolean validate(Path path, ResourceContext context) {
- // TODO Auto-generated method stub
- return false;
- }
-}
\ No newline at end of file
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/PceBandwidthConstraint.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/PceBandwidthConstraint.java
deleted file mode 100644
index cff0973..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/PceBandwidthConstraint.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pceservice.constraint;
-
-import org.onlab.util.Bandwidth;
-import org.onlab.util.DataRateUnit;
-import org.onosproject.net.Link;
-import org.onosproject.net.intent.ResourceContext;
-import org.onosproject.net.intent.constraint.BooleanConstraint;
-import org.onosproject.bandwidthmgr.api.BandwidthMgmtService;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Constraint that evaluates links based on available pce bandwidths.
- */
-public final class PceBandwidthConstraint extends BooleanConstraint {
-
- private final Bandwidth bandwidth;
-
- /**
- * Creates a new pce bandwidth constraint.
- *
- * @param bandwidth required bandwidth
- */
- public PceBandwidthConstraint(Bandwidth bandwidth) {
- this.bandwidth = checkNotNull(bandwidth, "Bandwidth cannot be null");
- }
-
- /**
- * Creates a new pce bandwidth constraint.
- *
- * @param v required amount of bandwidth
- * @param unit {@link DataRateUnit} of {@code v}
- * @return {@link PceBandwidthConstraint} instance with given bandwidth requirement
- */
- public static PceBandwidthConstraint of(double v, DataRateUnit unit) {
- return new PceBandwidthConstraint(Bandwidth.of(v, unit));
- }
-
- // Constructor for serialization
- private PceBandwidthConstraint() {
- this.bandwidth = null;
- }
-
- @Override
- public boolean isValid(Link link, ResourceContext context) {
- return false;
- //Do nothing instead using isValidLink needs bandwidthMgmtService to validate link
- }
-
- /**
- * Validates the link based on pce bandwidth constraint.
- *
- * @param link to validate pce bandwidth constraint
- * @param bandwidthMgmtService instance of BandwidthMgmtService
- * @return true if link satisfies pce bandwidth constraint otherwise false
- */
- public boolean isValidLink(Link link, BandwidthMgmtService bandwidthMgmtService) {
- if (bandwidthMgmtService == null) {
- return false;
- }
-
- return bandwidthMgmtService.isBandwidthAvailable(link, bandwidth.bps());
-
- }
-
- /**
- * Returns the bandwidth required by this constraint.
- *
- * @return required bandwidth
- */
- public Bandwidth bandwidth() {
- return bandwidth;
- }
-
- @Override
- public int hashCode() {
- return bandwidth.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
- final PceBandwidthConstraint other = (PceBandwidthConstraint) obj;
- return Objects.equals(this.bandwidth, other.bandwidth);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("bandwidth", bandwidth).toString();
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/SharedBandwidthConstraint.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/SharedBandwidthConstraint.java
deleted file mode 100644
index dcd8285..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/SharedBandwidthConstraint.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pceservice.constraint;
-
-import org.onlab.util.Bandwidth;
-import org.onosproject.net.Link;
-import org.onosproject.net.intent.ResourceContext;
-import org.onosproject.net.intent.constraint.BooleanConstraint;
-import org.onosproject.bandwidthmgr.api.BandwidthMgmtService;
-
-import java.util.List;
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Constraint that evaluates whether links satisfies sharedbandwidth request.
- */
-public final class SharedBandwidthConstraint extends BooleanConstraint {
-
- private final List<Link> links;
- private final Bandwidth sharedBwValue;
- private final Bandwidth requestBwValue;
- //temporary variable declared to hold changed bandwidth value
- private Bandwidth changedBwValue;
-
- // Constructor for serialization
- private SharedBandwidthConstraint() {
- links = null;
- sharedBwValue = null;
- requestBwValue = null;
- }
-
- /**
- * Creates a new SharedBandwidth constraint.
- *
- * @param links shared links
- * @param sharedBwValue shared bandwidth of the links
- * @param requestBwValue requested bandwidth value
- */
- public SharedBandwidthConstraint(List<Link> links, Bandwidth sharedBwValue, Bandwidth requestBwValue) {
- this.links = links;
- this.sharedBwValue = sharedBwValue;
- this.requestBwValue = requestBwValue;
- }
-
- /**
- * Creates a new SharedBandwidth constraint.
- *
- * @param links shared links
- * @param sharedBwValue shared bandwidth of the links
- * @param requestBwValue requested bandwidth value
- * @return SharedBandwidth instance
- */
- public static SharedBandwidthConstraint of(List<Link> links, Bandwidth sharedBwValue, Bandwidth requestBwValue) {
- return new SharedBandwidthConstraint(links, sharedBwValue, requestBwValue);
- }
-
- /**
- * Obtains shared links.
- *
- * @return shared links
- */
- public List<Link> links() {
- return links;
- }
-
- /**
- * Obtains shared bandwidth of the links.
- *
- * @return shared bandwidth
- */
- public Bandwidth sharedBwValue() {
- return sharedBwValue;
- }
-
- /**
- * Obtains requested bandwidth value.
- *
- * @return requested bandwidth value
- */
- public Bandwidth requestBwValue() {
- return requestBwValue;
- }
-
- @Override
- public boolean isValid(Link link, ResourceContext context) {
- return false;
- //Do nothing instead using isValidLink needs pce service to validate link
- }
-
- /**
- * Validates the link based on shared bandwidth constraint.
- *
- * @param link to validate shared bandwidth constraint
- * @param bandwidthMgmtService instance of BandwidthMgmtService
- * @return true if link satisfies shared bandwidth constraint otherwise false
- */
- public boolean isValidLink(Link link, BandwidthMgmtService bandwidthMgmtService) {
- if (bandwidthMgmtService == null) {
- return false;
- }
- changedBwValue = requestBwValue;
- if (links.contains(link)) {
- changedBwValue = requestBwValue.isGreaterThan(sharedBwValue) ? requestBwValue.subtract(sharedBwValue)
- : Bandwidth.bps(0);
- }
-
- return bandwidthMgmtService.isBandwidthAvailable(link, changedBwValue.bps());
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(requestBwValue, sharedBwValue, links);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof SharedBandwidthConstraint) {
- SharedBandwidthConstraint other = (SharedBandwidthConstraint) obj;
- return Objects.equals(this.requestBwValue, other.requestBwValue)
- && Objects.equals(this.sharedBwValue, other.sharedBwValue)
- && Objects.equals(this.links, other.links);
- }
-
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("requestBwValue", requestBwValue)
- .add("sharedBwValue", sharedBwValue)
- .add("links", links)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/package-info.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/package-info.java
deleted file mode 100644
index 8e1d934..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/constraint/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Constraints for path computation for PCE service.
- */
-package org.onosproject.pce.pceservice.constraint;
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/package-info.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/package-info.java
deleted file mode 100644
index 07e0269..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCE service application.
- */
-package org.onosproject.pce.pceservice;
\ No newline at end of file
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java
deleted file mode 100644
index 998f87e..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pcestore;
-
-import com.google.common.collect.ImmutableSet;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.pce.pceservice.ExplicitPathInfo;
-import org.onosproject.pce.pceservice.LspType;
-import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
-import org.onosproject.pce.pceservice.constraint.CostConstraint;
-import org.onosproject.pce.pceservice.constraint.PceBandwidthConstraint;
-import org.onosproject.pce.pceservice.constraint.SharedBandwidthConstraint;
-import org.onosproject.pce.pcestore.api.PceStore;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.DistributedSet;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-import java.util.List;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Manages the pool of available labels to devices, links and tunnels.
- */
-@Component(immediate = true, service = PceStore.class)
-public class DistributedPceStore implements PceStore {
- private static final String PATH_INFO_NULL = "Path Info cannot be null";
- private static final String PCECC_TUNNEL_INFO_NULL = "PCECC Tunnel Info cannot be null";
- private static final String TUNNEL_ID_NULL = "Tunnel Id cannot be null";
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- //Mapping tunnel name with Disjoint paths
- private ConsistentMap<String, List<TunnelId>> tunnelNameDisjoinTunnelIdInfo;
-
- // List of Failed path info
- private DistributedSet<PcePathInfo> failedPathSet;
-
- // Maintains tunnel name mapped to explicit path info
- private ConsistentMap<String, List<ExplicitPathInfo>> tunnelNameExplicitPathInfoMap;
-
- private static final Serializer SERIALIZER = Serializer
- .using(new KryoNamespace.Builder().register(KryoNamespaces.API)
- .register(PcePathInfo.class)
- .register(ExplicitPathInfo.class)
- .register(ExplicitPathInfo.Type.class)
- .register(CostConstraint.class)
- .register(CostConstraint.Type.class)
- .register(PceBandwidthConstraint.class)
- .register(SharedBandwidthConstraint.class)
- .register(CapabilityConstraint.class)
- .register(CapabilityConstraint.CapabilityType.class)
- .register(LspType.class)
- .build());
-
- @Activate
- protected void activate() {
-
- failedPathSet = storageService.<PcePathInfo>setBuilder()
- .withName("failed-path-info")
- .withSerializer(SERIALIZER)
- .build()
- .asDistributedSet();
-
- tunnelNameExplicitPathInfoMap = storageService.<String, List<ExplicitPathInfo>>consistentMapBuilder()
- .withName("onos-pce-explicitpathinfo")
- .withSerializer(Serializer.using(
- new KryoNamespace.Builder()
- .register(KryoNamespaces.API)
- .register(ExplicitPathInfo.class)
- .register(ExplicitPathInfo.Type.class)
- .build()))
- .build();
-
- tunnelNameDisjoinTunnelIdInfo = storageService.<String, List<TunnelId>>consistentMapBuilder()
- .withName("onos-pce-disjointTunnelIds")
- .withSerializer(Serializer.using(
- new KryoNamespace.Builder()
- .register(KryoNamespaces.API)
- .register(TunnelId.class)
- .build()))
- .build();
-
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public boolean existsFailedPathInfo(PcePathInfo failedPathInfo) {
- checkNotNull(failedPathInfo, PATH_INFO_NULL);
- return failedPathSet.contains(failedPathInfo);
- }
-
-
- @Override
- public int getFailedPathInfoCount() {
- return failedPathSet.size();
- }
-
- @Override
- public Iterable<PcePathInfo> getFailedPathInfos() {
- return ImmutableSet.copyOf(failedPathSet);
- }
-
-
-
- @Override
- public void addFailedPathInfo(PcePathInfo failedPathInfo) {
- checkNotNull(failedPathInfo, PATH_INFO_NULL);
- failedPathSet.add(failedPathInfo);
- }
-
-
- @Override
- public boolean removeFailedPathInfo(PcePathInfo failedPathInfo) {
- checkNotNull(failedPathInfo, PATH_INFO_NULL);
-
- if (!failedPathSet.remove(failedPathInfo)) {
- log.error("Failed path info {} deletion has failed.", failedPathInfo.toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean tunnelNameExplicitPathInfoMap(String tunnelName, List<ExplicitPathInfo> explicitPathInfo) {
- checkNotNull(tunnelName);
- checkNotNull(explicitPathInfo);
- return tunnelNameExplicitPathInfoMap.put(tunnelName, explicitPathInfo) != null ? true : false;
- }
-
- @Override
- public List<ExplicitPathInfo> getTunnelNameExplicitPathInfoMap(String tunnelName) {
- checkNotNull(tunnelName);
- if (tunnelNameExplicitPathInfoMap.get(tunnelName) != null) {
- return tunnelNameExplicitPathInfoMap.get(tunnelName).value();
- }
- return null;
- }
-
-/* @Override
- public DisjointPath getDisjointPaths(String tunnelName) {
- if (tunnelNameDisjointPathInfo.get(tunnelName) != null) {
- return tunnelNameDisjointPathInfo.get(tunnelName).value();
- }
- return null;
- }
-
- @Override
- public boolean addDisjointPathInfo(String tunnelName, DisjointPath path) {
- checkNotNull(tunnelName);
- checkNotNull(path);
- return tunnelNameDisjointPathInfo.put(tunnelName, path) != null ? true : false;
- }*/
-
- @Override
- public boolean addLoadBalancingTunnelIdsInfo(String tunnelName, TunnelId... tunnelIds) {
- checkNotNull(tunnelName);
- checkNotNull(tunnelIds);
- return tunnelNameDisjoinTunnelIdInfo.put(tunnelName, Arrays.asList(tunnelIds)) != null ? true : false;
- }
-
- @Override
- public List<TunnelId> getLoadBalancingTunnelIds(String tunnelName) {
- if (tunnelNameDisjoinTunnelIdInfo.get(tunnelName) != null) {
- return tunnelNameDisjoinTunnelIdInfo.get(tunnelName).value();
- }
- return null;
- }
-
- @Override
- public boolean removeLoadBalancingTunnelIdsInfo(String tunnelName) {
- if (tunnelNameDisjoinTunnelIdInfo.remove(tunnelName) == null) {
- log.error("Failed to remove entry {} for this tunnelName in DisjointTunnelIdsInfoMap" + tunnelName);
- return false;
- }
- return true;
- }
-
- /* @Override
- public boolean removeDisjointPathInfo(String tunnelName) {
- if (tunnelNameDisjointPathInfo.remove(tunnelName) == null) {
- log.error("Failed to remove entry {} for this tunnelName in DisjointPathInfoMap", tunnelName);
- return false;
- }
- return true;
- }*/
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/PcePathInfo.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/PcePathInfo.java
deleted file mode 100644
index 5772969..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/PcePathInfo.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pcestore;
-
-import com.google.common.base.MoreObjects;
-
-import java.util.List;
-import java.util.Objects;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.pce.pceservice.ExplicitPathInfo;
-import org.onosproject.pce.pceservice.LspType;
-
-/**
- * Input path information to compute CSPF path.
- * This path information will be stored in pce store and will be used later to recalculate the path.
- */
-public final class PcePathInfo {
-
- private DeviceId src; // source path
-
- private DeviceId dst; // destination path
-
- private String name; // tunnel name
-
- private List<Constraint> constraints; // list of constraints (cost, bandwidth, etc.)
-
- private LspType lspType; // lsp type
-
- private List<ExplicitPathInfo> explicitPathInfo; //Explicit path info to compute explicit path
-
- private boolean loadBalancing; //load balancing option
-
- /**
- * Initialization of member variables.
- *
- * @param src source device id
- * @param dst destination device id
- * @param name tunnel name
- * @param constraints list of constraints
- * @param lspType lsp type
- * @param explicitPathInfo explicit path info
- * @param loadBalancing load balancing option
- */
- public PcePathInfo(DeviceId src,
- DeviceId dst,
- String name,
- List<Constraint> constraints,
- LspType lspType,
- List<ExplicitPathInfo> explicitPathInfo,
- boolean loadBalancing) {
- this.src = src;
- this.dst = dst;
- this.name = name;
- this.constraints = constraints;
- this.lspType = lspType;
- this.explicitPathInfo = explicitPathInfo;
- this.loadBalancing = loadBalancing;
- }
-
- /**
- * Initialization for serialization.
- */
- public PcePathInfo() {
- this.src = null;
- this.dst = null;
- this.name = null;
- this.constraints = null;
- this.lspType = null;
- this.explicitPathInfo = null;
- this.loadBalancing = false;
- }
-
- /**
- * Returns source device id.
- *
- * @return source device id
- */
- public DeviceId src() {
- return src;
- }
-
- /**
- * Sets source device id.
- *
- * @param id source device id
- */
- public void src(DeviceId id) {
- this.src = id;
- }
-
- /**
- * Returns destination device id.
- *
- * @return destination device id
- */
- public DeviceId dst() {
- return dst;
- }
-
- /**
- * Sets destination device id.
- *
- * @param id destination device id
- */
- public void dst(DeviceId id) {
- this.dst = id;
- }
-
-
- /**
- * Returns tunnel name.
- *
- * @return name
- */
- public String name() {
- return name;
- }
-
- /**
- * Sets tunnel name.
- *
- * @param name tunnel name
- */
- public void name(String name) {
- this.name = name;
- }
-
- /**
- * Returns list of constraints including cost, bandwidth, etc.
- *
- * @return list of constraints
- */
- public List<Constraint> constraints() {
- return constraints;
- }
-
- /**
- * Sets list of constraints.
- * @param constraints list of constraints
- */
- public void constraints(List<Constraint> constraints) {
- this.constraints = constraints;
- }
-
- /**
- * Returns lsp type.
- *
- * @return lsp type
- */
- public LspType lspType() {
- return lspType;
- }
-
- /**
- * Sets lsp type.
- *
- * @param lspType lsp type
- */
- public void lspType(LspType lspType) {
- this.lspType = lspType;
- }
-
- /**
- * Returns list of explicit path info.
- *
- * @return list of explicit path info
- */
- public List<ExplicitPathInfo> explicitPathInfo() {
- return explicitPathInfo;
- }
-
- /**
- * Sets list of explicit path info.
- *
- * @param explicitPathInfo list of explicit path info
- */
- public void explicitPathInfo(List<ExplicitPathInfo> explicitPathInfo) {
- this.explicitPathInfo = explicitPathInfo;
- }
-
- /**
- * Returns whether stored path has enabled load balancing.
- *
- * @return load balancing option is enable
- */
- public boolean isLoadBalancing() {
- return loadBalancing;
- }
-
- /**
- * Sets load balancing option is enable.
- *
- * @param loadBalancing load balancing option is enable
- */
- public void loadBalancing(boolean loadBalancing) {
- this.loadBalancing = loadBalancing;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(src, dst, name, constraints, lspType, explicitPathInfo, loadBalancing);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof PcePathInfo) {
- final PcePathInfo other = (PcePathInfo) obj;
- return Objects.equals(this.src, other.src) &&
- Objects.equals(this.dst, other.dst) &&
- Objects.equals(this.name, other.name) &&
- Objects.equals(this.constraints, other.constraints) &&
- Objects.equals(this.lspType, other.lspType) &&
- Objects.equals(this.explicitPathInfo, other.explicitPathInfo) &&
- Objects.equals(this.loadBalancing, other.loadBalancing);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("Source", src)
- .add("Destination", dst)
- .add("Name", name)
- .add("Constraints", constraints)
- .add("explicitPathInfo", explicitPathInfo)
- .add("LspType", lspType)
- .add("loadBalancing", loadBalancing)
- .toString();
- }
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java
deleted file mode 100644
index 5ad49999..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/PceStore.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pcestore.api;
-
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.pce.pceservice.ExplicitPathInfo;
-import org.onosproject.pce.pcestore.PcePathInfo;
-
-import java.util.List;
-
-/**
- * Abstraction of an entity providing pool of available labels to devices, links and tunnels.
- */
-public interface PceStore {
-
- /**
- * Checks whether path info is present in failed path info list.
- *
- * @param failedPathInfo failed path information
- * @return success or failure
- */
- boolean existsFailedPathInfo(PcePathInfo failedPathInfo);
-
- /**
- * Retrieves the failed path info count.
- *
- * @return failed path info count
- */
- int getFailedPathInfoCount();
-
- /**
- * Retrieves path info collection from failed path info store.
- *
- * @return collection of failed path info
- */
- Iterable<PcePathInfo> getFailedPathInfos();
-
- /**
- * Stores path information into failed path info store.
- *
- * @param failedPathInfo failed path information
- */
- void addFailedPathInfo(PcePathInfo failedPathInfo);
-
-
- /**
- * Removes path info from failed path info store.
- *
- * @param failedPathInfo failed path information
- * @return success or failure
- */
- boolean removeFailedPathInfo(PcePathInfo failedPathInfo);
-
- /**
- * Adds explicit path info to the map with corresponding tunnel name.
- *
- * @param tunnelName tunnel name as key
- * @param explicitPathInfo list of explicit path objects
- * @return whether it is added to map
- */
- boolean tunnelNameExplicitPathInfoMap(String tunnelName, List<ExplicitPathInfo> explicitPathInfo);
-
- /**
- * Gets explicit path info based on tunnel name.
- *
- * @param tunnelName tunnel name as key
- * @return list of explicit path info
- */
- List<ExplicitPathInfo> getTunnelNameExplicitPathInfoMap(String tunnelName);
-
- //DisjointPath getDisjointPaths(String tunnelName);
-
- //boolean addDisjointPathInfo(String tunnelName, DisjointPath path);
-
- /**
- * Stores load balancing tunnels by load balance path name.
- *
- * @param loadBalancingPathName load balancing path name
- * @param tunnelIds list load balancing tunnels
- * @return success or failure
- */
- boolean addLoadBalancingTunnelIdsInfo(String loadBalancingPathName, TunnelId... tunnelIds);
-
- /**
- * Query load balancing tunnels by load balance path name.
- *
- * @param loadBalancingPathName load balancing path name
- * @return list of load balancing tunnels
- */
- List<TunnelId> getLoadBalancingTunnelIds(String loadBalancingPathName);
-
- /**
- * Removes load balancing tunnel info.
- *
- * @param loadBalancingPathName load balancing path name
- * @return success or failure
- */
- boolean removeLoadBalancingTunnelIdsInfo(String loadBalancingPathName);
-
- //boolean removeDisjointPathInfo(String tunnelName);
-}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/package-info.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/package-info.java
deleted file mode 100644
index 1acea25..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/api/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCE store service API.
- */
-package org.onosproject.pce.pcestore.api;
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/package-info.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/package-info.java
deleted file mode 100644
index f7ad0c0..0000000
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCE store application.
- */
-package org.onosproject.pce.pcestore;
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/BandwidthMgmtServiceAdapter.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/BandwidthMgmtServiceAdapter.java
deleted file mode 100644
index 891bb18..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/BandwidthMgmtServiceAdapter.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pceservice;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-import org.onosproject.bandwidthmgr.api.BandwidthMgmtService;
-
-import java.util.Set;
-
-/**
- * Adapter for Bandwidth Management service.
- */
-public class BandwidthMgmtServiceAdapter implements BandwidthMgmtService {
- @Override
- public boolean allocLocalReservedBw(LinkKey linkkey, Double bandwidth) {
- return false;
- }
-
- @Override
- public boolean releaseLocalReservedBw(LinkKey linkkey, Double bandwidth) {
- return false;
- }
-
- @Override
- public Double getAllocatedLocalReservedBw(LinkKey linkkey) {
- return null;
- }
-
- @Override
- public boolean addUnreservedBw(LinkKey linkkey, Set<Double> bandwidth) {
- return false;
- }
-
- @Override
- public boolean removeUnreservedBw(LinkKey linkkey) {
- return false;
- }
-
- @Override
- public Set<Double> getUnreservedBw(LinkKey linkkey) {
- return null;
- }
-
- @Override
- public boolean isBandwidthAvailable(Link link, Double bandwidth) {
- return false;
- }
-
- @Override
- public Double getTeCost(LinkKey linkKey) {
- return null;
- }
-
- @Override
- public Double getAvailableBandwidth(LinkKey linkKey) {
- return null;
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/DefaultPcePathTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/DefaultPcePathTest.java
deleted file mode 100644
index 9d95e44..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/DefaultPcePathTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pce.pceservice;
-
-import com.google.common.collect.Lists;
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.pce.pceservice.constraint.CostConstraint;
-import org.onosproject.pce.pceservice.constraint.PceBandwidthConstraint;
-import org.onosproject.pce.pcestore.api.PceStore;
-
-import java.util.List;
-
-import static org.easymock.EasyMock.createMock;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onosproject.pce.pceservice.PathComputationTest.D2;
-
-/**
- * Unit tests for DefaultPcePath class.
- */
-public class DefaultPcePathTest {
- private PceStore pceStore = createMock(PceStore.class);
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- // create same two pce-path objects.
- final String cost1 = "1";
- final String bandwidth1 = "200";
- final String src1 = "foo";
- final String dst1 = "bee";
- final String type1 = "1";
- final String name1 = "pcc";
- final List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
- ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D2.deviceId());
- explicitPathInfoList.add(obj);
- PcePath path1 = DefaultPcePath.builder()
- .source(src1)
- .destination(dst1)
- .lspType(type1)
- .name(name1)
- .costConstraint(cost1)
- .bandwidthConstraint(bandwidth1)
- .explicitPathInfo(explicitPathInfoList)
- .build();
- path1.id(TunnelId.valueOf("1"));
-
- // create same as above object
- PcePath samePath1 = DefaultPcePath.builder()
- .source(src1)
- .destination(dst1)
- .lspType(type1)
- .name(name1)
- .costConstraint(cost1)
- .bandwidthConstraint(bandwidth1)
- .explicitPathInfo(explicitPathInfoList)
- .build();
- samePath1.id(TunnelId.valueOf("1"));
-
- // Create different pce-path object.
- final String cost2 = "1";
- final String bandwidth2 = "200";
- final String src2 = "google";
- final String dst2 = "yahoo";
- final String type2 = "2";
- final String name2 = "pcc2";
-
- PcePath path2 = DefaultPcePath.builder()
- .source(src2)
- .destination(dst2)
- .lspType(type2)
- .name(name2)
- .costConstraint(cost2)
- .bandwidthConstraint(bandwidth2)
- .explicitPathInfo(explicitPathInfoList)
- .build();
- path2.id(TunnelId.valueOf("2"));
-
- new EqualsTester().addEqualityGroup(path1, samePath1).addEqualityGroup(path2).testEquals();
- }
-
- /**
- * Checks the construction of a DefaultPcePath object.
- */
- @Test
- public void testConstruction() {
- final String cost = "1";
- final String bandwidth = "600";
- final String src = "indiatimes";
- final String dst = "deccan";
- final String type = "2";
- final String name = "pcc4";
- final List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
- ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D2.deviceId());
- explicitPathInfoList.add(obj);
- PcePath path = DefaultPcePath.builder()
- .source(src)
- .destination(dst)
- .lspType(type)
- .name(name)
- .costConstraint(cost)
- .bandwidthConstraint(bandwidth)
- .explicitPathInfo(explicitPathInfoList)
- .build();
-
- assertThat(path.source(), is(src));
- assertThat(path.destination(), is(dst));
- assertThat(path.lspType(), is(LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR));
- assertThat(path.name(), is(name));
- CostConstraint costConstExpected = CostConstraint.of(CostConstraint.Type.values()[Integer.valueOf(cost) - 1]);
- CostConstraint costConstActual = (CostConstraint) path.costConstraint();
- assertThat(costConstActual.type(), is(costConstExpected.type()));
- PceBandwidthConstraint bandwidthActual = (PceBandwidthConstraint) path.bandwidthConstraint();
- assertThat(bandwidthActual.bandwidth().bps(), is(Double.valueOf(bandwidth)));
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java
deleted file mode 100644
index 2241d6d..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PathComputationTest.java
+++ /dev/null
@@ -1,1436 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pceservice;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.graph.AbstractGraphPathSearch;
-import org.onlab.graph.AdjacencyListsGraph;
-import org.onlab.graph.DijkstraGraphSearch;
-import org.onlab.graph.Graph;
-import org.onlab.graph.GraphPathSearch;
-import org.onlab.graph.ScalarWeight;
-import org.onlab.graph.Weight;
-import org.onlab.packet.ChassisId;
-import org.onlab.util.Bandwidth;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultDevice;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.DefaultPath;
-import org.onosproject.net.Device;
-import org.onosproject.net.Device.Type;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-import org.onosproject.net.Path;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.config.Config;
-import org.onosproject.net.config.ConfigApplyDelegate;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigRegistryAdapter;
-import org.onosproject.net.device.DeviceServiceAdapter;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.topology.DefaultTopologyEdge;
-import org.onosproject.net.topology.DefaultTopologyVertex;
-import org.onosproject.net.topology.LinkWeigher;
-import org.onosproject.net.topology.TopologyEdge;
-import org.onosproject.net.topology.TopologyVertex;
-import org.onosproject.pce.pceservice.constraint.CapabilityConstraint;
-import org.onosproject.pce.pceservice.constraint.CostConstraint;
-import org.onosproject.pce.pceservice.constraint.PceBandwidthConstraint;
-import org.onosproject.pce.pceservice.constraint.SharedBandwidthConstraint;
-import org.onosproject.pcep.api.DeviceCapability;
-import org.onosproject.pcep.api.TeLinkConfig;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.ImmutableSet.of;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.onlab.graph.GraphPathSearch.ALL_PATHS;
-import static org.onosproject.core.CoreService.CORE_PROVIDER_ID;
-import static org.onosproject.net.DeviceId.deviceId;
-import static org.onosproject.net.Link.State.ACTIVE;
-import static org.onosproject.net.Link.Type.DIRECT;
-import static org.onosproject.pce.pceservice.constraint.CostConstraint.Type.COST;
-import static org.onosproject.pce.pceservice.constraint.CostConstraint.Type.TE_COST;
-
-/**
- * Test for CSPF path computation.
- */
-public class PathComputationTest {
-
- private final MockDeviceService deviceService = new MockDeviceService();
- private final MockNetConfigRegistryAdapter netConfigRegistry = new MockNetConfigRegistryAdapter();
- private PceManager pceManager = new PceManager();
- private final MockBandwidthMgmtService bandwidthMgmtService = new MockBandwidthMgmtService();
- public static ProviderId providerId = new ProviderId("pce", "foo");
- public static final String DEVICE1 = "D001";
- public static final String DEVICE2 = "D002";
- public static final String DEVICE3 = "D003";
- public static final String DEVICE4 = "D004";
- public static final String DEVICE5 = "D005";
- public static final String PCEPDEVICE1 = "PD001";
- public static final String PCEPDEVICE2 = "PD002";
- public static final String PCEPDEVICE3 = "PD003";
- public static final String PCEPDEVICE4 = "PD004";
- public static final TopologyVertex D1 = new DefaultTopologyVertex(DeviceId.deviceId("D001"));
- public static final TopologyVertex D2 = new DefaultTopologyVertex(DeviceId.deviceId("D002"));
- public static final TopologyVertex D3 = new DefaultTopologyVertex(DeviceId.deviceId("D003"));
- public static final TopologyVertex D4 = new DefaultTopologyVertex(DeviceId.deviceId("D004"));
- public static final TopologyVertex D5 = new DefaultTopologyVertex(DeviceId.deviceId("D005"));
- private static final String ANNOTATION_COST = "cost";
- private static final String ANNOTATION_TE_COST = "teCost";
- private static final String UNKNOWN = "unknown";
- public static final String LSRID = "lsrId";
- public static final String L3 = "L3";
- public static final String PCECC_CAPABILITY = "pceccCapability";
- public static final String SR_CAPABILITY = "srCapability";
- public static final String LABEL_STACK_CAPABILITY = "labelStackCapability";
-
- @Before
- public void startUp() {
- pceManager.deviceService = deviceService;
- pceManager.netCfgService = netConfigRegistry;
- }
-
- /**
- * Selects path computation algorithm.
- *
- * @return graph path search algorithm
- */
- public static AbstractGraphPathSearch<TopologyVertex, TopologyEdge> graphSearch() {
- return new DijkstraGraphSearch<>();
- }
-
- /**
- * Returns link for two devices.
- *
- * @param device source device
- * @param port source port
- * @param device2 destination device
- * @param port2 destination port
- * @return link
- */
- public static Link addLink(String device, long port, String device2, long port2, boolean setCost, int value) {
- ConnectPoint src = new ConnectPoint(DeviceId.deviceId(device), PortNumber.portNumber(port));
- ConnectPoint dst = new ConnectPoint(DeviceId.deviceId(device2), PortNumber.portNumber(port2));
- Link curLink;
- DefaultAnnotations.Builder annotationBuilder = DefaultAnnotations.builder();
-
- //TODO:If cost not set cost : default value case
- curLink = DefaultLink.builder().src(src).dst(dst).state(ACTIVE).type(DIRECT)
- .providerId(PathComputationTest.providerId).annotations(annotationBuilder.build()).build();
- return curLink;
- }
-
- @After
- public void tearDown() {
- pceManager.deviceService = null;
- pceManager.netCfgService = null;
- }
-
- /**
- * Returns an edge-weight capable of evaluating links on the basis of the
- * specified constraints.
- *
- * @param constraints path constraints
- * @return edge-weight function
- */
- private LinkWeigher weight(List<Constraint> constraints) {
- return new MockTeConstraintBasedLinkWeight(constraints);
- }
-
- private Set<Path> computePath(Link link1, Link link2, Link link3, Link link4, List<Constraint> constraints) {
- Graph<TopologyVertex, TopologyEdge> graph = new AdjacencyListsGraph<>(of(D1, D2, D3, D4),
- of(new DefaultTopologyEdge(D1, D2, link1),
- new DefaultTopologyEdge(D2, D4, link2),
- new DefaultTopologyEdge(D1, D3, link3),
- new DefaultTopologyEdge(D3, D4, link4)));
-
- GraphPathSearch.Result<TopologyVertex, TopologyEdge> result =
- graphSearch().search(graph, D1, D4, weight(constraints), ALL_PATHS);
- ImmutableSet.Builder<Path> builder = ImmutableSet.builder();
- for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
- builder.add(networkPath(path));
- }
- return builder.build();
- }
-
- private class MockDeviceService extends DeviceServiceAdapter {
- List<Device> devices = new LinkedList<>();
-
- private void addDevice(Device dev) {
- devices.add(dev);
- }
-
- @Override
- public Device getDevice(DeviceId deviceId) {
- for (Device dev : devices) {
- if (dev.id().equals(deviceId)) {
- return dev;
- }
- }
- return null;
- }
-
- @Override
- public Iterable<Device> getAvailableDevices() {
- return devices;
- }
- }
-
- private class MockTeConstraintBasedLinkWeight implements LinkWeigher {
-
- private final List<Constraint> constraints;
-
- /**
- * Creates a new edge-weight function capable of evaluating links
- * on the basis of the specified constraints.
- *
- * @param constraints path constraints
- */
- MockTeConstraintBasedLinkWeight(List<Constraint> constraints) {
- if (constraints == null) {
- this.constraints = Collections.emptyList();
- } else {
- this.constraints = ImmutableList.copyOf(constraints);
- }
- }
-
- @Override
- public Weight getInitialWeight() {
- return ScalarWeight.toWeight(0.0);
- }
-
- @Override
- public Weight getNonViableWeight() {
- return ScalarWeight.NON_VIABLE_WEIGHT;
- }
-
- @Override
- public Weight weight(TopologyEdge edge) {
- if (!constraints.iterator().hasNext()) {
- //Takes default cost/hopcount as 1 if no constraints specified
- return ScalarWeight.toWeight(1.0);
- }
-
- Iterator<Constraint> it = constraints.iterator();
- double cost = 1;
-
- //If any constraint fails return -1 also value of cost returned from cost constraint can't be negative
- while (it.hasNext() && cost > 0) {
- Constraint constraint = it.next();
- if (constraint instanceof CapabilityConstraint) {
- cost = ((CapabilityConstraint) constraint).isValidLink(edge.link(), deviceService,
- netConfigRegistry) ? 1 : -1;
- } else if (constraint instanceof PceBandwidthConstraint) {
- cost = ((PceBandwidthConstraint) constraint).isValidLink(edge.link(),
- bandwidthMgmtService) ? 1 : -1;
-
- } else if (constraint instanceof SharedBandwidthConstraint) {
- cost = ((SharedBandwidthConstraint) constraint).isValidLink(edge.link(),
- bandwidthMgmtService) ? 1 : -1;
-
- } else if (constraint instanceof CostConstraint) {
- cost = ((CostConstraint) constraint).isValidLink(edge.link(), netConfigRegistry);
- } else {
- cost = constraint.cost(edge.link(), null);
- }
- }
- return ScalarWeight.toWeight(cost);
- }
- }
-
- /**
- * Returns the path in Path object format.
- */
- public static Path networkPath(org.onlab.graph.Path<TopologyVertex, TopologyEdge> path) {
- List<Link> links = path.edges().stream().map(TopologyEdge::link).collect(Collectors.toList());
- return new DefaultPath(CORE_PROVIDER_ID, links, path.cost());
- }
-
- public static class MockBandwidthMgmtService extends BandwidthMgmtServiceAdapter {
- private Map<LinkKey, Double> teCost = new HashMap<>();
- // Locally maintain unreserved bandwidth of each link.
- private Map<LinkKey, Set<Double>> unResvBw = new HashMap<>();
-
- // Mapping tunnel with link key with local reserved bandwidth
- private Map<LinkKey, Double> localReservedBw = new HashMap<>();
-
- @Override
- public boolean allocLocalReservedBw(LinkKey linkkey, Double bandwidth) {
- Double allocatedBw = localReservedBw.get(linkkey);
- if (allocatedBw != null) {
- localReservedBw.put(linkkey, (allocatedBw + bandwidth));
- } else {
- localReservedBw.put(linkkey, bandwidth);
- }
-
- return true;
- }
-
- @Override
- public boolean releaseLocalReservedBw(LinkKey linkkey, Double bandwidth) {
- Double allocatedBw = localReservedBw.get(linkkey);
- if (allocatedBw == null || allocatedBw < bandwidth) {
- return false;
- }
-
- Double releasedBw = allocatedBw - bandwidth;
- if (releasedBw == 0.0) {
- localReservedBw.remove(linkkey);
- } else {
- localReservedBw.put(linkkey, releasedBw);
- }
- return true;
- }
-
- @Override
- public Double getAllocatedLocalReservedBw(LinkKey linkkey) {
- return localReservedBw.get(linkkey);
- }
-
- @Override
- public boolean addUnreservedBw(LinkKey linkkey, Set<Double> bandwidth) {
- unResvBw.put(linkkey, bandwidth);
- return true;
- }
-
- @Override
- public boolean removeUnreservedBw(LinkKey linkkey) {
- unResvBw.remove(linkkey);
- return true;
- }
-
- @Override
- public Set<Double> getUnreservedBw(LinkKey linkkey) {
- checkNotNull(linkkey);
- return unResvBw.get(linkkey);
- }
-
- @Override
- public boolean isBandwidthAvailable(Link link, Double bandwidth) {
- LinkKey linkKey = LinkKey.linkKey(link);
- Double localAllocBw = getAllocatedLocalReservedBw(linkKey);
-
- Set<Double> unResvBw = getUnreservedBw(linkKey);
-
- Double prirZeroBw = unResvBw.iterator().next();
- return (bandwidth <= prirZeroBw - (localAllocBw != null ? localAllocBw : 0));
- }
-
- @Override
- public Double getTeCost(LinkKey linkKey) {
- if (teCost.get(linkKey) != null) {
- return teCost.get(linkKey);
- }
- return null;
- }
-
- @Override
- public Double getAvailableBandwidth(LinkKey linkKey) {
- if (unResvBw.get(linkKey) != null && localReservedBw.get(linkKey) != null) {
-
- return unResvBw.get(linkKey).iterator().next().doubleValue()
- - localReservedBw.get(linkKey).doubleValue();
- }
- return unResvBw.get(linkKey).iterator().next().doubleValue();
- }
- }
-
- /* Mock test for network config registry. */
- public static class MockNetConfigRegistryAdapter extends NetworkConfigRegistryAdapter {
- private ConfigFactory cfgFactory;
- private Map<DeviceId, DeviceCapability> classConfig = new HashMap<>();
- private Map<LinkKey, TeLinkConfig> teLinkConfig = new HashMap<>();
-
- @Override
- public void registerConfigFactory(ConfigFactory configFactory) {
- cfgFactory = configFactory;
- }
-
- @Override
- public void unregisterConfigFactory(ConfigFactory configFactory) {
- cfgFactory = null;
- }
-
- @Override
- public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) {
- if (configClass == DeviceCapability.class) {
- DeviceCapability devCap = new DeviceCapability();
- classConfig.put((DeviceId) subject, devCap);
-
- JsonNode node = new ObjectNode(new MockJsonNode());
- ObjectMapper mapper = new ObjectMapper();
- ConfigApplyDelegate delegate = new InternalApplyDelegate();
- devCap.init((DeviceId) subject, null, node, mapper, delegate);
- return (C) devCap;
- } else if (configClass == TeLinkConfig.class) {
- TeLinkConfig teConfig = new TeLinkConfig();
- teLinkConfig.put((LinkKey) subject, teConfig);
-
- JsonNode node = new ObjectNode(new MockJsonNode());
- ObjectMapper mapper = new ObjectMapper();
- ConfigApplyDelegate delegate = new InternalApplyDelegate();
- teConfig.init((LinkKey) subject, null, node, mapper, delegate);
- return (C) teConfig;
- }
-
- return null;
- }
-
- @Override
- public <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass) {
- if (configClass == DeviceCapability.class) {
- classConfig.remove(subject);
- } else if (configClass == TeLinkConfig.class) {
- teLinkConfig.remove(subject);
- }
- }
-
- @Override
- public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) {
- if (configClass == DeviceCapability.class) {
- return (C) classConfig.get(subject);
- } else if (configClass == TeLinkConfig.class) {
- return (C) teLinkConfig.get(subject);
- }
- return null;
- }
-
- private class MockJsonNode extends JsonNodeFactory {
- }
-
- // Auxiliary delegate to receive notifications about changes applied to
- // the network configuration - by the apps.
- private class InternalApplyDelegate implements ConfigApplyDelegate {
- @Override
- public void onApply(Config config) {
- //configs.put(config.subject(), config.node());
- }
- }
- }
-
- /**
- * All links with different costs with L1-L2 as least cost path.
- */
- @Test
- public void testpathComputationCase1() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 50);
-
- CostConstraint costConst = CostConstraint.of(COST);
- List<Constraint> constraints = new LinkedList<>();
- constraints.add(costConst);
-
- TeLinkConfig teLinkConfig = netConfigRegistry.addConfig(LinkKey.linkKey(link1), TeLinkConfig.class);
- teLinkConfig.igpCost(50)
- .apply();
-
-
- TeLinkConfig teLinkConfig2 = netConfigRegistry.addConfig(LinkKey.linkKey(link2), TeLinkConfig.class);
- teLinkConfig2.igpCost(20)
- .apply();
-
- TeLinkConfig teLinkConfig3 = netConfigRegistry.addConfig(LinkKey.linkKey(link3), TeLinkConfig.class);
- teLinkConfig3.igpCost(100)
- .apply();
-
- TeLinkConfig teLinkConfig4 = netConfigRegistry.addConfig(LinkKey.linkKey(link4), TeLinkConfig.class);
- teLinkConfig4.igpCost(50)
- .apply();
-
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- List<Link> links = new LinkedList<>();
-
- links.add(link1);
- links.add(link2);
-
- assertThat(paths.iterator().next().links(), is(links));
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
- }
-
- /**
- * Links with same cost 100 except link3.
- */
- @Test
- public void testpathComputationCase2() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 100);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 100);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 1000);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 100);
-
- CostConstraint costConst = CostConstraint.of(COST);
- List<Constraint> constraints = new LinkedList<>();
- constraints.add(costConst);
-
- TeLinkConfig teLinkConfig = netConfigRegistry.addConfig(LinkKey.linkKey(link1), TeLinkConfig.class);
- teLinkConfig.igpCost(100)
- .apply();
-
-
- TeLinkConfig teLinkConfig2 = netConfigRegistry.addConfig(LinkKey.linkKey(link2), TeLinkConfig.class);
- teLinkConfig2.igpCost(100)
- .apply();
-
- TeLinkConfig teLinkConfig3 = netConfigRegistry.addConfig(LinkKey.linkKey(link3), TeLinkConfig.class);
- teLinkConfig3.igpCost(1000)
- .apply();
-
- TeLinkConfig teLinkConfig4 = netConfigRegistry.addConfig(LinkKey.linkKey(link4), TeLinkConfig.class);
- teLinkConfig4.igpCost(100)
- .apply();
-
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- List<Link> links = new LinkedList<>();
- links.add(link1);
- links.add(link2);
-
- assertThat(paths.iterator().next().links(), is(links));
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(200.0)));
- }
-
- /**
- * Path which satisfy bandwidth as a constraint with 10bps.
- */
- @Test
- public void testpathComputationCase3() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 50);
-
- Set<Double> unreserved = new HashSet<>();
- unreserved.add(new Double(50));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link1), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link1), new Double(0));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link2), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link2), new Double(0));
-
- unreserved.remove(new Double(50));
- unreserved.add(new Double(100));
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link3), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link3), new Double(0));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link4), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link4), new Double(0));
-
- PceBandwidthConstraint bandwidthConst = new PceBandwidthConstraint(Bandwidth.bps(10.0));
-
- List<Constraint> constraints = new LinkedList<>();
- constraints.add(bandwidthConst);
-
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(2.0)));
- }
-
- /**
- * Path which satisfy bandwidth as a constraint with 60bps.
- */
- @Test
- public void testpathComputationCase4() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 50);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 100);
-
- Set<Double> unreserved = new HashSet<>();
- unreserved.add(new Double(50));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link1), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link1), new Double(0));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link2), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link2), new Double(0));
-
- unreserved.remove(new Double(50));
- unreserved.add(new Double(100));
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link3), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link3), new Double(0));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link4), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link4), new Double(0));
-
- PceBandwidthConstraint bandwidthConst = new PceBandwidthConstraint(Bandwidth.bps(60.0));
-
- List<Constraint> constraints = new LinkedList<>();
- constraints.add(bandwidthConst);
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(2.0)));
- }
-
- /**
- * Shared bandwidth as L1, L2 with its value 10 bps and bandwidth constraint as 20 bps.
- */
- @Test
- public void testpathComputationCase5() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 80);
-
- Set<Double> unreserved = new HashSet<>();
- unreserved.add(new Double(50));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link1), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link1), new Double(0));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link2), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link2), new Double(0));
-
- unreserved.remove(new Double(50));
- unreserved.add(new Double(100));
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link3), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link3), new Double(0));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link4), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link4), new Double(0));
-
- List<Constraint> constraints = new LinkedList<>();
-
- List<Link> sharedLinks = new LinkedList<>();
-
- List<Link> links = new LinkedList<>();
- links.add(link1);
- links.add(link2);
-
- CostConstraint costConst = CostConstraint.of(COST);
-
-
- TeLinkConfig teLinkConfig = netConfigRegistry.addConfig(LinkKey.linkKey(link1), TeLinkConfig.class);
- teLinkConfig.igpCost(50)
- .apply();
-
-
- TeLinkConfig teLinkConfig2 = netConfigRegistry.addConfig(LinkKey.linkKey(link2), TeLinkConfig.class);
- teLinkConfig2.igpCost(20)
- .apply();
-
- TeLinkConfig teLinkConfig3 = netConfigRegistry.addConfig(LinkKey.linkKey(link3), TeLinkConfig.class);
- teLinkConfig3.igpCost(100)
- .apply();
-
- TeLinkConfig teLinkConfig4 = netConfigRegistry.addConfig(LinkKey.linkKey(link4), TeLinkConfig.class);
- teLinkConfig4.igpCost(50)
- .apply();
-
- sharedLinks.addAll(links);
- SharedBandwidthConstraint sharedBw = new SharedBandwidthConstraint(sharedLinks, Bandwidth.bps(10),
- Bandwidth.bps(20.0));
- constraints.add(sharedBw);
- constraints.add(costConst);
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
- assertThat(paths.iterator().next().links(), is(links));
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
- }
-
- /**
- * Shared bandwidth as L1, L2 with its value 20 bps and bandwidth constraint as 10 bps.
- */
- @Test
- public void testpathComputationCase6() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 80);
-
- Set<Double> unreserved = new HashSet<>();
- unreserved.add(new Double(50));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link1), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link1), new Double(0));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link2), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link2), new Double(0));
-
- unreserved.remove(new Double(50));
- unreserved.add(new Double(100));
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link3), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link3), new Double(0));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link4), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link4), new Double(0));
-
- List<Constraint> constraints = new LinkedList<>();
-
- List<Link> sharedLinks = new LinkedList<>();
-
- List<Link> links = new LinkedList<>();
- links.add(link1);
- links.add(link2);
- CostConstraint costConst = CostConstraint.of(COST);
-
-
- TeLinkConfig teLinkConfig = netConfigRegistry.addConfig(LinkKey.linkKey(link1), TeLinkConfig.class);
- teLinkConfig.igpCost(50)
- .apply();
-
-
- TeLinkConfig teLinkConfig2 = netConfigRegistry.addConfig(LinkKey.linkKey(link2), TeLinkConfig.class);
- teLinkConfig2.igpCost(20)
- .apply();
-
- TeLinkConfig teLinkConfig3 = netConfigRegistry.addConfig(LinkKey.linkKey(link3), TeLinkConfig.class);
- teLinkConfig3.igpCost(100)
- .apply();
-
- TeLinkConfig teLinkConfig4 = netConfigRegistry.addConfig(LinkKey.linkKey(link4), TeLinkConfig.class);
- teLinkConfig4.igpCost(80)
- .apply();
-
- sharedLinks.addAll(links);
- SharedBandwidthConstraint sharedBwConst = new SharedBandwidthConstraint(sharedLinks, Bandwidth.bps(20),
- Bandwidth.bps(10.0));
- constraints.add(sharedBwConst);
- constraints.add(costConst);
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- assertThat(paths.iterator().next().links(), is(links));
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
- }
-
- /**
- * Path without constraints.
- */
- @Test
- public void testpathComputationCase7() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 80);
- List<Constraint> constraints = new LinkedList<>();
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(2.0)));
- }
-
- /**
- * With TeCost as a constraints.
- */
- @Test
- public void testpathComputationCase8() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, false, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, false, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, false, 80);
-
- CostConstraint tecostConst = CostConstraint.of(TE_COST);
-
- List<Constraint> constraints = new LinkedList<>();
- constraints.add(tecostConst);
-
-
- TeLinkConfig teLinkConfig = netConfigRegistry.addConfig(LinkKey.linkKey(link1), TeLinkConfig.class);
- teLinkConfig.teCost(50)
- .apply();
-
-
- TeLinkConfig teLinkConfig2 = netConfigRegistry.addConfig(LinkKey.linkKey(link2), TeLinkConfig.class);
- teLinkConfig2.teCost(20)
- .apply();
-
- TeLinkConfig teLinkConfig3 = netConfigRegistry.addConfig(LinkKey.linkKey(link3), TeLinkConfig.class);
- teLinkConfig3.teCost(100)
- .apply();
-
- TeLinkConfig teLinkConfig4 = netConfigRegistry.addConfig(LinkKey.linkKey(link4), TeLinkConfig.class);
- teLinkConfig4.teCost(80)
- .apply();
-
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- List<Link> links = new LinkedList<>();
- links.add(link1);
- links.add(link2);
- assertThat(paths.iterator().next().links(), is(links));
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
- }
-
- /**
- * With device supporting RSVP capability as a constraints.
- */
- @Test
- public void testpathComputationCase9() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, false, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, false, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, false, 80);
-
- CostConstraint tecostConst = CostConstraint.of(TE_COST);
-
- TeLinkConfig teLinkConfig = netConfigRegistry.addConfig(LinkKey.linkKey(link1), TeLinkConfig.class);
- teLinkConfig.teCost(50)
- .apply();
-
-
- TeLinkConfig teLinkConfig2 = netConfigRegistry.addConfig(LinkKey.linkKey(link2), TeLinkConfig.class);
- teLinkConfig2.teCost(20)
- .apply();
-
- TeLinkConfig teLinkConfig3 = netConfigRegistry.addConfig(LinkKey.linkKey(link3), TeLinkConfig.class);
- teLinkConfig3.teCost(100)
- .apply();
-
- TeLinkConfig teLinkConfig4 = netConfigRegistry.addConfig(LinkKey.linkKey(link4), TeLinkConfig.class);
- teLinkConfig4.teCost(80)
- .apply();
-
-
- CapabilityConstraint capabilityConst = CapabilityConstraint
- .of(CapabilityConstraint.CapabilityType.WITH_SIGNALLING);
-
- List<Constraint> constraints = new LinkedList<>();
- constraints.add(capabilityConst);
- constraints.add(tecostConst);
- //Device1
- DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "1.1.1.1");
- addDevice(DEVICE1, builder);
-
- DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class);
- device1Cap.setLabelStackCap(false)
- .setLocalLabelCap(false)
- .setSrCap(false)
- .apply();
-
- //Device2
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "2.2.2.2");
- addDevice(DEVICE2, builder);
-
- DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class);
- device2Cap.setLabelStackCap(false)
- .setLocalLabelCap(false)
- .setSrCap(false)
- .apply();
-
- //Device3
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "3.3.3.3");
- addDevice(DEVICE3, builder);
-
- DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class);
- device3Cap.setLabelStackCap(false)
- .setLocalLabelCap(false)
- .setSrCap(false)
- .apply();
-
- //Device4
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "4.4.4.4");
- addDevice(DEVICE4, builder);
-
- DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class);
- device4Cap.setLabelStackCap(false)
- .setLocalLabelCap(false)
- .setSrCap(false)
- .apply();
-
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- List<Link> links = new LinkedList<>();
- links.add(link1);
- links.add(link2);
- assertThat(paths.iterator().next().links(), is(links));
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
- }
-
- /**
- * Devices supporting CR capability.
- */
- @Test
- public void testpathComputationCase10() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 80);
-
- CapabilityConstraint capabilityConst = CapabilityConstraint
- .of(CapabilityConstraint.CapabilityType.WITHOUT_SIGNALLING_AND_WITHOUT_SR);
-
- List<Constraint> constraints = new LinkedList<>();
- constraints.add(capabilityConst);
- CostConstraint costConst = CostConstraint.of(COST);
- constraints.add(costConst);
- TeLinkConfig teLinkConfig = netConfigRegistry.addConfig(LinkKey.linkKey(link1), TeLinkConfig.class);
- teLinkConfig.igpCost(50)
- .apply();
-
-
- TeLinkConfig teLinkConfig2 = netConfigRegistry.addConfig(LinkKey.linkKey(link2), TeLinkConfig.class);
- teLinkConfig2.igpCost(20)
- .apply();
-
- TeLinkConfig teLinkConfig3 = netConfigRegistry.addConfig(LinkKey.linkKey(link3), TeLinkConfig.class);
- teLinkConfig3.igpCost(100)
- .apply();
-
- TeLinkConfig teLinkConfig4 = netConfigRegistry.addConfig(LinkKey.linkKey(link4), TeLinkConfig.class);
- teLinkConfig4.igpCost(80)
- .apply();
-
- //Device1
- DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "1.1.1.1");
- addDevice(DEVICE1, builder);
- DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class);
- device1Cap.setLabelStackCap(false)
- .setLocalLabelCap(true)
- .setSrCap(false)
- .apply();
-
- //Device2
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "2.2.2.2");
- addDevice(DEVICE2, builder);
- DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class);
- device2Cap.setLabelStackCap(false)
- .setLocalLabelCap(true)
- .setSrCap(false)
- .apply();
-
- //Device3
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "3.3.3.3");
- addDevice(DEVICE3, builder);
- DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class);
- device3Cap.setLabelStackCap(false)
- .setLocalLabelCap(true)
- .setSrCap(false)
- .apply();
-
- //Device4
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "4.4.4.4");
- addDevice(DEVICE4, builder);
- DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class);
- device4Cap.setLabelStackCap(false)
- .setLocalLabelCap(true)
- .setSrCap(false)
- .apply();
-
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- List<Link> links = new LinkedList<>();
- links.add(link1);
- links.add(link2);
- assertThat(paths.iterator().next().links(), is(links));
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
- }
-
- /**
- * Device supporting SR capability.
- */
- @Test
- public void testpathComputationCase11() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 80);
-
- CapabilityConstraint capabilityConst = CapabilityConstraint
- .of(CapabilityConstraint.CapabilityType.SR_WITHOUT_SIGNALLING);
-
- List<Constraint> constraints = new LinkedList<>();
- constraints.add(capabilityConst);
- CostConstraint costConst = CostConstraint.of(COST);
- constraints.add(costConst);
-
- TeLinkConfig teLinkConfig = netConfigRegistry.addConfig(LinkKey.linkKey(link1), TeLinkConfig.class);
- teLinkConfig.igpCost(50)
- .apply();
-
-
- TeLinkConfig teLinkConfig2 = netConfigRegistry.addConfig(LinkKey.linkKey(link2), TeLinkConfig.class);
- teLinkConfig2.igpCost(20)
- .apply();
-
- TeLinkConfig teLinkConfig3 = netConfigRegistry.addConfig(LinkKey.linkKey(link3), TeLinkConfig.class);
- teLinkConfig3.igpCost(100)
- .apply();
-
- TeLinkConfig teLinkConfig4 = netConfigRegistry.addConfig(LinkKey.linkKey(link4), TeLinkConfig.class);
- teLinkConfig4.igpCost(80)
- .apply();
- //Device1
- DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "1.1.1.1");
- addDevice(DEVICE1, builder);
- DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class);
- device1Cap.setLabelStackCap(true)
- .setLocalLabelCap(false)
- .setSrCap(true)
- .apply();
-
- //Device2
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "2.2.2.2");
- addDevice(DEVICE2, builder);
- DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class);
- device2Cap.setLabelStackCap(true)
- .setLocalLabelCap(false)
- .setSrCap(true)
- .apply();
-
- //Device3
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "3.3.3.3");
- addDevice(DEVICE3, builder);
- DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class);
- device3Cap.setLabelStackCap(true)
- .setLocalLabelCap(false)
- .setSrCap(true)
- .apply();
-
- //Device4
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "4.4.4.4");
- addDevice(DEVICE4, builder);
- DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class);
- device4Cap.setLabelStackCap(true)
- .setLocalLabelCap(false)
- .setSrCap(true)
- .apply();
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- List<Link> links = new LinkedList<>();
- links.add(link1);
- links.add(link2);
- assertThat(paths.iterator().next().links(), is(links));
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
- }
-
- /**
- * Path with TE and SR capability constraint.
- */
- @Test
- public void testpathComputationCase12() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, false, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, false, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, false, 80);
-
- CostConstraint tecostConst = CostConstraint.of(TE_COST);
- CapabilityConstraint capabilityConst = CapabilityConstraint
- .of(CapabilityConstraint.CapabilityType.SR_WITHOUT_SIGNALLING);
-
- List<Constraint> constraints = new LinkedList<>();
-
- constraints.add(capabilityConst);
- constraints.add(tecostConst);
-
- TeLinkConfig teLinkConfig = netConfigRegistry.addConfig(LinkKey.linkKey(link1), TeLinkConfig.class);
- teLinkConfig.teCost(50)
- .apply();
-
-
- TeLinkConfig teLinkConfig2 = netConfigRegistry.addConfig(LinkKey.linkKey(link2), TeLinkConfig.class);
- teLinkConfig2.teCost(20)
- .apply();
-
- TeLinkConfig teLinkConfig3 = netConfigRegistry.addConfig(LinkKey.linkKey(link3), TeLinkConfig.class);
- teLinkConfig3.teCost(100)
- .apply();
-
- TeLinkConfig teLinkConfig4 = netConfigRegistry.addConfig(LinkKey.linkKey(link4), TeLinkConfig.class);
- teLinkConfig4.teCost(80)
- .apply();
- //Device1
- DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "1.1.1.1");
- addDevice(DEVICE1, builder);
- DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class);
- device1Cap.setLabelStackCap(true)
- .setLocalLabelCap(false)
- .setSrCap(true)
- .apply();
-
- //Device2
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "2.2.2.2");
- addDevice(DEVICE2, builder);
- DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class);
- device2Cap.setLabelStackCap(true)
- .setLocalLabelCap(false)
- .setSrCap(true)
- .apply();
-
- //Device3
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "3.3.3.3");
- addDevice(DEVICE3, builder);
- DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class);
- device3Cap.setLabelStackCap(true)
- .setLocalLabelCap(false)
- .setSrCap(true)
- .apply();
-
- //Device4
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "4.4.4.4");
- addDevice(DEVICE4, builder);
- DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class);
- device4Cap.setLabelStackCap(true)
- .setLocalLabelCap(false)
- .setSrCap(true)
- .apply();
-
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- List<Link> links = new LinkedList<>();
- links.add(link1);
- links.add(link2);
- assertThat(paths.iterator().next().links(), is(links));
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(70.0)));
- }
-
- /**
- * Path with capability constraint and with default cost.
- */
- @Test
- public void testpathComputationCase13() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, false, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, false, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, false, 80);
-
- CapabilityConstraint capabilityConst = CapabilityConstraint
- .of(CapabilityConstraint.CapabilityType.SR_WITHOUT_SIGNALLING);
-
- List<Constraint> constraints = new LinkedList<>();
- constraints.add(capabilityConst);
- //Device1
- DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "1.1.1.1");
- addDevice(DEVICE1, builder);
- DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class);
- device1Cap.setLabelStackCap(true)
- .setLocalLabelCap(false)
- .setSrCap(true)
- .apply();
-
- //Device2
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "2.2.2.2");
- addDevice(DEVICE2, builder);
- DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class);
- device2Cap.setLabelStackCap(true)
- .setLocalLabelCap(false)
- .setSrCap(true)
- .apply();
-
- //Device3
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "3.3.3.3");
- addDevice(DEVICE3, builder);
- DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class);
- device3Cap.setLabelStackCap(true)
- .setLocalLabelCap(false)
- .setSrCap(true)
- .apply();
-
- //Device4
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "4.4.4.4");
- addDevice(DEVICE4, builder);
- DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class);
- device4Cap.setLabelStackCap(true)
- .setLocalLabelCap(false)
- .setSrCap(true)
- .apply();
-
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- List<Link> links = new LinkedList<>();
- links.add(link1);
- links.add(link2);
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(2.0)));
- }
-
- /**
- * Test case with empty constraints.
- */
- @Test
- public void testpathComputationCase14() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, false, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, false, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, false, 80);
-
- List<Constraint> constraints = new LinkedList<>();
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(2.0)));
- }
-
- /**
- * Test case with constraints as null.
- */
- @Test
- public void testpathComputationCase15() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, false, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, false, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, false, 80);
-
- List<Constraint> constraints = null;
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(2.0)));
- }
-
- /**
- * Path with cost constraint.
- */
- @Test
- public void testpathComputationCase16() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 100);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 10);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 10);
- Link link5 = addLink(DEVICE4, 90, DEVICE5, 100, true, 20);
-
- CostConstraint costConst = CostConstraint.of(COST);
-
- List<Constraint> constraints = new LinkedList<>();
- constraints.add(costConst);
-
- TeLinkConfig teLinkConfig = netConfigRegistry.addConfig(LinkKey.linkKey(link1), TeLinkConfig.class);
- teLinkConfig.igpCost(50)
- .apply();
-
-
- TeLinkConfig teLinkConfig2 = netConfigRegistry.addConfig(LinkKey.linkKey(link2), TeLinkConfig.class);
- teLinkConfig2.igpCost(100)
- .apply();
-
- TeLinkConfig teLinkConfig3 = netConfigRegistry.addConfig(LinkKey.linkKey(link3), TeLinkConfig.class);
- teLinkConfig3.igpCost(10)
- .apply();
-
- TeLinkConfig teLinkConfig4 = netConfigRegistry.addConfig(LinkKey.linkKey(link4), TeLinkConfig.class);
- teLinkConfig4.igpCost(10)
- .apply();
-
- TeLinkConfig teLinkConfig5 = netConfigRegistry.addConfig(LinkKey.linkKey(link5), TeLinkConfig.class);
- teLinkConfig5.igpCost(20)
- .apply();
-
- Graph<TopologyVertex, TopologyEdge> graph = new AdjacencyListsGraph<>(of(D1, D2, D3, D4, D5),
- of(new DefaultTopologyEdge(D1, D2, link1),
- new DefaultTopologyEdge(D2, D4, link2),
- new DefaultTopologyEdge(D1, D3, link3),
- new DefaultTopologyEdge(D3, D4, link4),
- new DefaultTopologyEdge(D4, D5, link5)));
-
- GraphPathSearch.Result<TopologyVertex, TopologyEdge> result =
- graphSearch().search(graph, D1, D5, weight(constraints), ALL_PATHS);
- ImmutableSet.Builder<Path> builder = ImmutableSet.builder();
- for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
- builder.add(networkPath(path));
- }
-
- List<Link> links = new LinkedList<>();
- links.add(link3);
- links.add(link4);
- links.add(link5);
- assertThat(builder.build().iterator().next().links(), is(links));
- assertThat(builder.build().iterator().next().weight(), is(ScalarWeight.toWeight(40.0)));
- }
-
- /**
- * D3 doesn't support capability constraint, so path is L1-L2.
- */
- @Test
- public void testpathComputationCase17() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, false, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, false, 100);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, false, 80);
-
- CapabilityConstraint capabilityConst = CapabilityConstraint
- .of(CapabilityConstraint.CapabilityType.WITHOUT_SIGNALLING_AND_WITHOUT_SR);
-
- List<Constraint> constraints = new LinkedList<>();
- constraints.add(capabilityConst);
- //Device1
- DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "1.1.1.1");
- addDevice(DEVICE1, builder);
- DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class);
- device1Cap.setLabelStackCap(false)
- .setLocalLabelCap(true)
- .setSrCap(false)
- .apply();
-
- //Device2
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "2.2.2.2");
- addDevice(DEVICE2, builder);
- DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class);
- device2Cap.setLabelStackCap(false)
- .setLocalLabelCap(true)
- .setSrCap(false)
- .apply();
-
- //Device4
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "4.4.4.4");
- addDevice(DEVICE4, builder);
- DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class);
- device4Cap.setLabelStackCap(false)
- .setLocalLabelCap(true)
- .setSrCap(false)
- .apply();
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- List<Link> links = new LinkedList<>();
- links.add(link1);
- links.add(link2);
-
- assertThat(paths.iterator().next().links(), is(links));
- assertThat(paths.iterator().next().weight(), is(ScalarWeight.toWeight(2.0)));
- }
-
- /**
- * L2 doesn't support cost constraint and D3 doesn't support capability constraint, both constraint fails hence no
- * path.
- */
- @Test
- public void testpathComputationCase18() {
- Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50);
- Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, false, 20);
- Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 10);
- Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 10);
-
- CapabilityConstraint capabilityConst = CapabilityConstraint
- .of(CapabilityConstraint.CapabilityType.WITHOUT_SIGNALLING_AND_WITHOUT_SR);
- CostConstraint costConst = CostConstraint.of(COST);
-
- TeLinkConfig teLinkConfig = netConfigRegistry.addConfig(LinkKey.linkKey(link1), TeLinkConfig.class);
- teLinkConfig.igpCost(50)
- .apply();
-
-
- TeLinkConfig teLinkConfig2 = netConfigRegistry.addConfig(LinkKey.linkKey(link2), TeLinkConfig.class);
- teLinkConfig2.igpCost(20)
- .apply();
-
- TeLinkConfig teLinkConfig3 = netConfigRegistry.addConfig(LinkKey.linkKey(link3), TeLinkConfig.class);
- teLinkConfig3.igpCost(10)
- .apply();
-
- TeLinkConfig teLinkConfig4 = netConfigRegistry.addConfig(LinkKey.linkKey(link4), TeLinkConfig.class);
- teLinkConfig4.igpCost(10)
- .apply();
-
- List<Constraint> constraints = new LinkedList<>();
- constraints.add(capabilityConst);
- constraints.add(costConst);
- //Device1
- DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "1.1.1.1");
- addDevice(DEVICE2, builder);
- DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class);
- device1Cap.setLabelStackCap(false)
- .setLocalLabelCap(true)
- .setSrCap(false)
- .apply();
-
- //Device2
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "2.2.2.2");
- addDevice(DEVICE2, builder);
- DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class);
- device2Cap.setLabelStackCap(false)
- .setLocalLabelCap(true)
- .setSrCap(false)
- .apply();
-
- //Device4
- builder = DefaultAnnotations.builder();
- builder.set(AnnotationKeys.TYPE, L3);
- builder.set(LSRID, "4.4.4.4");
- addDevice(DEVICE4, builder);
- DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class);
- device4Cap.setLabelStackCap(false)
- .setLocalLabelCap(true)
- .setSrCap(false)
- .apply();
- Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
-
- assertThat(paths, is(new HashSet<>()));
- }
-
- private void addDevice(String device, DefaultAnnotations.Builder builder) {
- deviceService.addDevice(new DefaultDevice(ProviderId.NONE, deviceId(device), Type.ROUTER,
- UNKNOWN, UNKNOWN, UNKNOWN,
- UNKNOWN, new ChassisId(), builder.build()));
- }
-}
\ No newline at end of file
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
deleted file mode 100644
index 1449eb0..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/PceManagerTest.java
+++ /dev/null
@@ -1,1688 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pceservice;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.graph.GraphPathSearch;
-import org.onlab.graph.ScalarWeight;
-import org.onlab.junit.TestUtils;
-import org.onlab.junit.TestUtils.TestUtilsException;
-import org.onlab.util.Bandwidth;
-import org.onosproject.common.DefaultTopologyGraph;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreServiceAdapter;
-import org.onosproject.core.DefaultApplicationId;
-import org.onosproject.core.IdGenerator;
-import org.onosproject.event.Event;
-import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.Tunnel.State;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelEvent;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelListener;
-import org.onosproject.incubator.net.tunnel.TunnelServiceAdapter;
-import org.onosproject.mastership.MastershipServiceAdapter;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultAnnotations.Builder;
-import org.onosproject.net.DefaultDevice;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.ElementId;
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.Path;
-import org.onosproject.net.SparseAnnotations;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.link.LinkEvent;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.topology.DefaultTopologyEdge;
-import org.onosproject.net.topology.DefaultTopologyVertex;
-import org.onosproject.net.topology.LinkWeigher;
-import org.onosproject.net.topology.PathServiceAdapter;
-import org.onosproject.net.topology.Topology;
-import org.onosproject.net.topology.TopologyEdge;
-import org.onosproject.net.topology.TopologyEvent;
-import org.onosproject.net.topology.TopologyGraph;
-import org.onosproject.net.topology.TopologyListener;
-import org.onosproject.net.topology.TopologyServiceAdapter;
-import org.onosproject.net.topology.TopologyVertex;
-import org.onosproject.pce.pceservice.PathComputationTest.MockNetConfigRegistryAdapter;
-import org.onosproject.pce.pceservice.constraint.CostConstraint;
-import org.onosproject.pce.pceservice.constraint.PceBandwidthConstraint;
-import org.onosproject.pce.pcestore.api.PceStore;
-import org.onosproject.pce.util.MockDeviceService;
-import org.onosproject.pce.util.PceStoreAdapter;
-import org.onosproject.pcep.api.DeviceCapability;
-import org.onosproject.pcep.api.TeLinkConfig;
-import org.onosproject.store.service.TestStorageService;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.function.Consumer;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.onlab.graph.GraphPathSearch.ALL_PATHS;
-import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED;
-import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE;
-import static org.onosproject.net.MastershipRole.MASTER;
-import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING;
-import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
-import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING;
-import static org.onosproject.pce.pceservice.PathComputationTest.D1;
-import static org.onosproject.pce.pceservice.PathComputationTest.D2;
-import static org.onosproject.pce.pceservice.PathComputationTest.D3;
-import static org.onosproject.pce.pceservice.PathComputationTest.D4;
-import static org.onosproject.pce.pceservice.PathComputationTest.D5;
-import static org.onosproject.pce.pceservice.PathComputationTest.DEVICE1;
-import static org.onosproject.pce.pceservice.PathComputationTest.DEVICE2;
-import static org.onosproject.pce.pceservice.PathComputationTest.DEVICE3;
-import static org.onosproject.pce.pceservice.PathComputationTest.DEVICE4;
-import static org.onosproject.pce.pceservice.PathComputationTest.DEVICE5;
-import static org.onosproject.pce.pceservice.PcepAnnotationKeys.LOCAL_LSP_ID;
-import static org.onosproject.pce.pceservice.PcepAnnotationKeys.PLSP_ID;
-import static org.onosproject.pce.pceservice.constraint.CostConstraint.Type.COST;
-import static org.onosproject.pce.pceservice.constraint.CostConstraint.Type.TE_COST;
-
-/**
- * Tests the functions of PceManager.
- */
-public class PceManagerTest {
-
- private PathComputationTest pathCompTest = new PathComputationTest();
- private MockTopologyService topologyService = new MockTopologyService();
- private MockMastershipService mastershipService = new MockMastershipService();
- private MockPathService pathService = new MockPathService();
- private PceManager pceManager = new PceManager();
- private MockCoreService coreService = new MockCoreService();
- private MockTunnelServiceAdapter tunnelService = new MockTunnelServiceAdapter();
- private TestStorageService storageService = new TestStorageService();
- private MockDeviceService deviceService = new MockDeviceService();
- private MockNetConfigRegistryAdapter netConfigRegistry = new PathComputationTest.MockNetConfigRegistryAdapter();
- private PceStore pceStore = new PceStoreAdapter();
- private PathComputationTest.MockBandwidthMgmtService bandwidthMgmtService = new PathComputationTest
- .MockBandwidthMgmtService();
-
- public static ProviderId providerId = new ProviderId("pce", "foo");
- private static final String L3 = "L3";
- private static final String LSRID = "lsrId";
- private static final String PCECC_CAPABILITY = "pceccCapability";
- private static final String SR_CAPABILITY = "srCapability";
- private static final String LABEL_STACK_CAPABILITY = "labelStackCapability";
-
- private TopologyGraph graph = null;
- private Device deviceD1, deviceD2, deviceD3, deviceD4, deviceD5;
- private Device pcepDeviceD1, pcepDeviceD2, pcepDeviceD3, pcepDeviceD4;
- private Link link1, link2, link3, link4, link5, link6;
- protected static int flowsDownloaded;
- private TunnelListener tunnelListener;
- private TopologyListener listener;
- private Topology topology;
- private Set<TopologyEdge> edges;
- private Set<TopologyVertex> vertexes;
-
- @Before
- public void startUp() throws TestUtilsException {
- listener = TestUtils.getField(pceManager, "topologyListener");
- pceManager.pathService = pathService;
- pceManager.topologyService = topologyService;
- pceManager.tunnelService = tunnelService;
- pceManager.coreService = coreService;
- pceManager.storageService = storageService;
- pceManager.deviceService = deviceService;
- pceManager.netCfgService = netConfigRegistry;
- pceManager.netConfigRegistry = netConfigRegistry;
- pceManager.pceStore = pceStore;
- pceManager.mastershipService = mastershipService;
- pceManager.bandwidthMgmtService = bandwidthMgmtService;
- pceManager.activate();
- }
-
- private class MockMastershipService extends MastershipServiceAdapter {
- @Override
- public MastershipRole getLocalRole(DeviceId deviceId) {
- return MASTER;
- }
-
- @Override
- public boolean isLocalMaster(DeviceId deviceId) {
- return getLocalRole(deviceId) == MASTER;
- }
- }
-
- private void build4RouterTopo(boolean setCost, boolean setPceccCap, boolean setSrCap,
- boolean setLabelStackCap, int bandwidth) {
- link1 = PathComputationTest.addLink(DEVICE1, 10, DEVICE2, 20, setCost, 50);
- link2 = PathComputationTest.addLink(DEVICE2, 30, DEVICE4, 40, setCost, 20);
- link3 = PathComputationTest.addLink(DEVICE1, 80, DEVICE3, 70, setCost, 100);
- link4 = PathComputationTest.addLink(DEVICE3, 60, DEVICE4, 50, setCost, 80);
- link5 = PathComputationTest.addLink(DEVICE2, 60, DEVICE5, 50, setCost, 80);
- link6 = PathComputationTest.addLink(DEVICE4, 60, DEVICE5, 50, setCost, 80);
-
- if (setCost) {
- TeLinkConfig teLinkConfig = netConfigRegistry.addConfig(LinkKey.linkKey(link1), TeLinkConfig.class);
- teLinkConfig.igpCost(50)
- .apply();
-
- TeLinkConfig teLinkConfig2 = netConfigRegistry.addConfig(LinkKey.linkKey(link2), TeLinkConfig.class);
- teLinkConfig2.igpCost(20)
- .apply();
-
- TeLinkConfig teLinkConfig3 = netConfigRegistry.addConfig(LinkKey.linkKey(link3), TeLinkConfig.class);
- teLinkConfig3.igpCost(100)
- .apply();
-
- TeLinkConfig teLinkConfig4 = netConfigRegistry.addConfig(LinkKey.linkKey(link4), TeLinkConfig.class);
- teLinkConfig4.igpCost(80)
- .apply();
-
- TeLinkConfig teLinkConfig5 = netConfigRegistry.addConfig(LinkKey.linkKey(link5), TeLinkConfig.class);
- teLinkConfig5.igpCost(80)
- .apply();
-
- TeLinkConfig teLinkConfig6 = netConfigRegistry.addConfig(LinkKey.linkKey(link6), TeLinkConfig.class);
- teLinkConfig6.igpCost(80)
- .apply();
- } else {
- TeLinkConfig teLinkConfig = netConfigRegistry.addConfig(LinkKey.linkKey(link1), TeLinkConfig.class);
- teLinkConfig.teCost(50)
- .apply();
-
-
- TeLinkConfig teLinkConfig2 = netConfigRegistry.addConfig(LinkKey.linkKey(link2), TeLinkConfig.class);
- teLinkConfig2.teCost(20)
- .apply();
-
- TeLinkConfig teLinkConfig3 = netConfigRegistry.addConfig(LinkKey.linkKey(link3), TeLinkConfig.class);
- teLinkConfig3.teCost(100)
- .apply();
-
- TeLinkConfig teLinkConfig4 = netConfigRegistry.addConfig(LinkKey.linkKey(link4), TeLinkConfig.class);
- teLinkConfig4.teCost(80)
- .apply();
-
- TeLinkConfig teLinkConfig5 = netConfigRegistry.addConfig(LinkKey.linkKey(link5), TeLinkConfig.class);
- teLinkConfig5.teCost(80)
- .apply();
-
- TeLinkConfig teLinkConfig6 = netConfigRegistry.addConfig(LinkKey.linkKey(link6), TeLinkConfig.class);
- teLinkConfig6.teCost(80)
- .apply();
- }
-
-
- Set<TopologyVertex> vertexes = new HashSet<TopologyVertex>();
- vertexes.add(D1);
- vertexes.add(D2);
- vertexes.add(D3);
- vertexes.add(D4);
- vertexes.add(D5);
-
- this.vertexes = vertexes;
-
- Set<TopologyEdge> edges = new HashSet<TopologyEdge>();
- TopologyEdge edge1 = new DefaultTopologyEdge(D1, D2, link1);
- edges.add(edge1);
-
- TopologyEdge edge2 = new DefaultTopologyEdge(D2, D4, link2);
- edges.add(edge2);
-
- TopologyEdge edge3 = new DefaultTopologyEdge(D1, D3, link3);
- edges.add(edge3);
-
- TopologyEdge edge4 = new DefaultTopologyEdge(D3, D4, link4);
- edges.add(edge4);
-
- TopologyEdge edge5 = new DefaultTopologyEdge(D2, D5, link5);
- edges.add(edge5);
-
- TopologyEdge edge6 = new DefaultTopologyEdge(D4, D5, link6);
- edges.add(edge6);
-
- this.edges = edges;
-
- graph = new DefaultTopologyGraph(vertexes, edges);
-
- DefaultAnnotations.Builder builderDev1 = DefaultAnnotations.builder();
- DefaultAnnotations.Builder builderDev2 = DefaultAnnotations.builder();
- DefaultAnnotations.Builder builderDev3 = DefaultAnnotations.builder();
- DefaultAnnotations.Builder builderDev4 = DefaultAnnotations.builder();
- DefaultAnnotations.Builder builderDev5 = DefaultAnnotations.builder();
-
- // Making L3 devices
- builderDev1.set(AnnotationKeys.TYPE, L3);
- builderDev1.set(LSRID, "1.1.1.1");
-
- builderDev2.set(AnnotationKeys.TYPE, L3);
- builderDev2.set(LSRID, "2.2.2.2");
-
- builderDev3.set(AnnotationKeys.TYPE, L3);
- builderDev3.set(LSRID, "3.3.3.3");
-
- builderDev4.set(AnnotationKeys.TYPE, L3);
- builderDev4.set(LSRID, "4.4.4.4");
-
- builderDev5.set(AnnotationKeys.TYPE, L3);
- builderDev5.set(LSRID, "5.5.5.5");
-
- deviceD1 = new MockDevice(D1.deviceId(), builderDev1.build());
- deviceD2 = new MockDevice(D2.deviceId(), builderDev2.build());
- deviceD3 = new MockDevice(D3.deviceId(), builderDev3.build());
- deviceD4 = new MockDevice(D4.deviceId(), builderDev4.build());
- deviceD5 = new MockDevice(D5.deviceId(), builderDev5.build());
-
- deviceService.addDevice(deviceD1);
- deviceService.addDevice(deviceD2);
- deviceService.addDevice(deviceD3);
- deviceService.addDevice(deviceD4);
- deviceService.addDevice(deviceD5);
-
- DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class);
- device1Cap.setLabelStackCap(setLabelStackCap)
- .setLocalLabelCap(setPceccCap)
- .setSrCap(setSrCap)
- .apply();
-
- DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class);
- device2Cap.setLabelStackCap(setLabelStackCap)
- .setLocalLabelCap(setPceccCap)
- .setSrCap(setSrCap)
- .apply();
-
- DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class);
- device3Cap.setLabelStackCap(setLabelStackCap)
- .setLocalLabelCap(setPceccCap)
- .setSrCap(setSrCap)
- .apply();
-
- DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class);
- device4Cap.setLabelStackCap(setLabelStackCap)
- .setLocalLabelCap(setPceccCap)
- .setSrCap(setSrCap)
- .apply();
-
- DeviceCapability device5Cap = netConfigRegistry.addConfig(DeviceId.deviceId("5.5.5.5"), DeviceCapability.class);
- device4Cap.setLabelStackCap(setLabelStackCap)
- .setLocalLabelCap(setPceccCap)
- .setSrCap(setSrCap)
- .apply();
-
- if (bandwidth != 0) {
- Set<Double> unreserved = new HashSet<>();
- unreserved.add(new Double(bandwidth));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link1), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link1), new Double(0));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link2), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link2), new Double(0));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link3), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link3), new Double(0));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link4), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link4), new Double(0));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link5), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link5), new Double(0));
-
- bandwidthMgmtService.addUnreservedBw(LinkKey.linkKey(link6), unreserved);
- bandwidthMgmtService.allocLocalReservedBw(LinkKey.linkKey(link6), new Double(0));
- }
- }
-
- /**
- * Tests path success with (IGP) cost constraint for signalled LSP.
- */
- @Test
- public void setupPathTest1() {
- build4RouterTopo(true, false, false, false, 0); // IGP cost is set here.
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(COST);
- constraints.add(costConstraint);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING, null);
- assertThat(result, is(true));
- }
-
- /**
- * Tests path failure with (IGP) cost constraint for signalled LSP.
- */
- @Test
- public void setupPathTest2() {
- build4RouterTopo(false, false, false, false, 0); // TE cost is set here, not IGP.
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(COST);
- constraints.add(costConstraint);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING, null);
- assertThat(result, is(false));
- }
-
- /**
- * Tests path success with TE-cost constraint for signalled LSP.
- */
- @Test
- public void setupPathTest3() {
- build4RouterTopo(false, false, false, false, 0); // TE cost is set here.
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(TE_COST);
- constraints.add(costConstraint);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING, null);
- assertThat(result, is(true));
- }
-
- /**
- * Tests path failure with TE-cost constraint for signalled LSP.
- */
- @Test
- public void setupPathTest4() {
- build4RouterTopo(true, false, false, false, 0); // IGP cost is set here, not TE.
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(TE_COST);
- constraints.add(costConstraint);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING, null);
- assertThat(result, is(false));
- }
-
- /**
- * Tests path success with (IGP) cost constraint for non-SR non-signalled LSP.
- */
- @Test
- public void setupPathTest5() {
- build4RouterTopo(true, true, false, false, 0);
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(COST);
- constraints.add(costConstraint);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints,
- WITHOUT_SIGNALLING_AND_WITHOUT_SR, null);
- assertThat(result, is(true));
- }
-
- /**
- * Tests path success with TE-cost constraint for non-SR non-sgnalled LSP.
- */
- @Test
- public void setupPathTest6() {
- build4RouterTopo(false, true, false, false, 0);
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(TE_COST);
- constraints.add(costConstraint);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints,
- WITHOUT_SIGNALLING_AND_WITHOUT_SR, null);
- assertThat(result, is(true));
- }
-
- /**
- * Tests path failure with TE-cost constraint for non-SR non-signalled LSP(CR). Label capability not registered.
- */
- @Test
- public void setupPathTest7() {
- build4RouterTopo(true, false, false, false, 0);
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(TE_COST);
- constraints.add(costConstraint);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints,
- WITHOUT_SIGNALLING_AND_WITHOUT_SR, null);
- assertThat(result, is(false));
- }
-
- /**
- * Tests path failure as bandwidth is requested but is not registered.
- */
- @Test
- public void setupPathTest8() {
- build4RouterTopo(true, false, false, false, 2);
-
- List<Constraint> constraints = new LinkedList<>();
- PceBandwidthConstraint bwConstraint = new PceBandwidthConstraint(Bandwidth.bps(10.0));
- CostConstraint costConstraint = new CostConstraint(TE_COST);
-
- constraints.add(costConstraint);
- constraints.add(bwConstraint);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints,
- WITH_SIGNALLING, null);
- assertThat(result, is(false));
- }
-
- /**
- * Tests path failure as bandwidth requested is more than registered.
- */
- @Test
- public void setupPathTest9() {
- build4RouterTopo(false, false, false, false, 5);
- List<Constraint> constraints = new LinkedList<Constraint>();
- PceBandwidthConstraint bwConstraint = new PceBandwidthConstraint(Bandwidth.bps(10.0));
- CostConstraint costConstraint = new CostConstraint(TE_COST);
-
- constraints.add(costConstraint);
- constraints.add(bwConstraint);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123",
- constraints, WITH_SIGNALLING, null);
- assertThat(result, is(false));
- }
-
- /**
- * Tests path setup failure(without signalling). Label capability is not present.
- */
- @Test
- public void setupPathTest10() {
- build4RouterTopo(false, false, false, false, 0);
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(TE_COST);
- constraints.add(costConstraint);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints,
- SR_WITHOUT_SIGNALLING, null);
- assertThat(result, is(false));
- }
-
- /**
- * Tests path setup without signalling and with bandwidth reservation.
- */
- @Test
- public void setupPathTest12() {
- build4RouterTopo(false, true, true, true, 15);
- List<Constraint> constraints = new LinkedList<Constraint>();
- PceBandwidthConstraint bwConstraint = new PceBandwidthConstraint(Bandwidth.bps(10.0));
- CostConstraint costConstraint = new CostConstraint(TE_COST);
-
- constraints.add(costConstraint);
- constraints.add(bwConstraint);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123",
- constraints, SR_WITHOUT_SIGNALLING, null);
- assertThat(result, is(true));
- }
-
- /**
- * Tests path setup without cost/bandwidth constraints.
- */
- @Test
- public void setupPathTest13() {
- build4RouterTopo(false, false, false, false, 0);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", null, WITH_SIGNALLING, null);
- assertThat(result, is(true));
- }
-
- /**
- * Tests path setup with explicit path with loose node D2.
- */
- @Test
- public void setupPathTest14() {
- build4RouterTopo(false, false, false, false, 0);
-
- List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
- ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D2.deviceId());
- explicitPathInfoList.add(obj);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123", null, WITH_SIGNALLING,
- explicitPathInfoList);
-
- Tunnel tunnel = pceManager.queryAllPath().iterator().next();
- List<Link> links = new LinkedList<>();
- links.add(link1);
- links.add(link2);
-
- assertThat(result, is(true));
- assertThat(tunnel.path().links().equals(links), is(true));
- }
-
- /**
- * Tests path setup with explicit path with loose node D3.
- */
- @Test
- public void setupPathTest15() {
- build4RouterTopo(false, false, false, false, 0);
-
- List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
- ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D3.deviceId());
- explicitPathInfoList.add(obj);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(), "T123", null, WITH_SIGNALLING,
- explicitPathInfoList);
-
- Tunnel tunnel = pceManager.queryAllPath().iterator().next();
- List<Link> links = new LinkedList<>();
- links.add(link3);
- links.add(link4);
- links.add(link6);
-
- assertThat(result, is(true));
- assertThat(tunnel.path().links().equals(links), is(true));
- }
-
- /**
- * Tests path setup with explicit path with loose node D4 , D3 - path fails.
- */
- @Test
- public void setupPathTest16() {
- build4RouterTopo(false, false, false, false, 0);
-
- List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
- ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D4.deviceId());
- explicitPathInfoList.add(obj);
- obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D3.deviceId());
- explicitPathInfoList.add(obj);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(), "T123", null, WITH_SIGNALLING,
- explicitPathInfoList);
-
- assertThat(result, is(false));
- }
-
- /**
- * Tests path setup with explicit path with strict node D2 - without reacble to src - path fails.
- */
- @Test
- public void setupPathTest17() {
- build4RouterTopo(false, false, false, false, 0);
-
- List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
- ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT, D2.deviceId());
- explicitPathInfoList.add(obj);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(), "T123", null, WITH_SIGNALLING,
- explicitPathInfoList);
-
- assertThat(result, is(false));
- }
-
- /**
- * Tests path setup with explicit path with loose node D2, strict D2.
- */
- @Test
- public void setupPathTest18() {
- build4RouterTopo(false, false, false, false, 0);
-
- List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
- ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D2.deviceId());
- explicitPathInfoList.add(obj);
- obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT, D2.deviceId());
- explicitPathInfoList.add(obj);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(), "T123", null, WITH_SIGNALLING,
- explicitPathInfoList);
-
- Tunnel tunnel = pceManager.queryAllPath().iterator().next();
- List<Link> links = new LinkedList<>();
- links.add(link1);
- links.add(link5);
-
- assertThat(result, is(true));
- assertThat(tunnel.path().links().equals(links), is(true));
- }
-
- /**
- * Tests path setup with explicit path with loose D1-D2, strict D2.
- */
- @Test
- public void setupPathTest19() {
- build4RouterTopo(false, false, false, false, 0);
-
- List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
- ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, link1);
- explicitPathInfoList.add(obj);
- obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT, D2.deviceId());
- explicitPathInfoList.add(obj);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D5.deviceId(), "T123", null, WITH_SIGNALLING,
- explicitPathInfoList);
-
- Tunnel tunnel = pceManager.queryAllPath().iterator().next();
- List<Link> links = new LinkedList<>();
- links.add(link1);
- links.add(link5);
-
- assertThat(result, is(true));
- assertThat(tunnel.path().links().equals(links), is(true));
- }
-
- /**
- * Tests path update with increase in bandwidth.
- */
- @Test
- public void updatePathTest1() {
- build4RouterTopo(false, true, true, true, 100);
-
- // Setup tunnel.
- List<Constraint> constraints = new LinkedList<>();
- PceBandwidthConstraint bwConstraint = new PceBandwidthConstraint(Bandwidth.bps(60.0));
- constraints.add(bwConstraint);
- CostConstraint costConstraint = new CostConstraint(TE_COST);
- constraints.add(costConstraint);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
- constraints, WITH_SIGNALLING, null);
- assertThat(result, is(true));
-
- // Change constraint and update it.
- constraints = new LinkedList<>();
- bwConstraint = new PceBandwidthConstraint(Bandwidth.bps(50.0));
- constraints.add(bwConstraint);
- constraints.add(costConstraint);
-
- Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- assertThat(tunnels.size(), is(1));
-
- Tunnel tunnel = tunnels.iterator().next();
-
- // Stimulate the effect of LSP ids from protocol msg.
- tunnelService.updateTunnelWithLspIds(tunnel, "123", "1", State.ACTIVE);
-
- result = pceManager.updatePath(tunnel.tunnelId(), constraints);
- assertThat(result, is(true));
-
- tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- assertThat(tunnels.size(), is(2));
- }
-
- /**
- * Tests path update with decrease in bandwidth.
- */
- @Test
- public void updatePathTest2() {
- build4RouterTopo(false, true, true, true, 100);
-
- // Setup tunnel.
- List<Constraint> constraints = new LinkedList<Constraint>();
- PceBandwidthConstraint bwConstraint = new PceBandwidthConstraint(Bandwidth.bps(60.0));
- constraints.add(bwConstraint);
- CostConstraint costConstraint = new CostConstraint(TE_COST);
- constraints.add(costConstraint);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123",
- constraints, SR_WITHOUT_SIGNALLING, null);
- assertThat(result, is(true));
-
- // Change constraint and update it.
- constraints.remove(bwConstraint);
- bwConstraint = new PceBandwidthConstraint(Bandwidth.bps(70.0));
- constraints.add(bwConstraint);
-
- Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- assertThat(tunnels.size(), is(1));
-
- for (Tunnel tunnel : tunnels) {
- result = pceManager.updatePath(tunnel.tunnelId(), constraints);
- assertThat(result, is(true));
- }
-
- tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- assertThat(tunnels.size(), is(2));
- }
-
- /**
- * Tests path update without cost/bandwidth constraints.
- */
- @Test
- public void updatePathTest3() {
- build4RouterTopo(false, true, true, true, 100);
-
- // Setup tunnel.
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(TE_COST);
- constraints.add(costConstraint);
- boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123",
- constraints, WITH_SIGNALLING, null);
- assertThat(result, is(true));
-
- Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- assertThat(tunnels.size(), is(1));
-
- for (Tunnel tunnel : tunnels) {
- result = pceManager.updatePath(tunnel.tunnelId(), null);
- assertThat(result, is(true));
- }
-
- Iterable<Tunnel> queryTunnelResult = pceManager.queryAllPath();
- assertThat((int) queryTunnelResult.spliterator().getExactSizeIfKnown(), is(2));
- }
-
- /**
- * Tests path update without cost/bandwidth constraints and with explicit path object.
- */
- @Test
- public void updatePathTest4() {
- build4RouterTopo(false, true, true, true, 100);
-
- // Setup tunnel.
- List<Constraint> constraints = new LinkedList<>();
- PceBandwidthConstraint bwConstraint = new PceBandwidthConstraint(Bandwidth.bps(60.0));
- constraints.add(bwConstraint);
- CostConstraint costConstraint = new CostConstraint(TE_COST);
- constraints.add(costConstraint);
-
- List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
- ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, link1);
- explicitPathInfoList.add(obj);
- obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT, D2.deviceId());
- explicitPathInfoList.add(obj);
-
- boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
- constraints, WITH_SIGNALLING, explicitPathInfoList);
- assertThat(result, is(true));
-
- // Change constraint and update it.
- constraints = new LinkedList<>();
- bwConstraint = new PceBandwidthConstraint(Bandwidth.bps(50.0));
- constraints.add(bwConstraint);
- constraints.add(costConstraint);
-
- Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- assertThat(tunnels.size(), is(1));
-
- Tunnel tunnel = tunnels.iterator().next();
-
- // Stimulate the effect of LSP ids from protocol msg.
- tunnelService.updateTunnelWithLspIds(tunnel, "123", "1", State.ACTIVE);
-
- result = pceManager.updatePath(tunnel.tunnelId(), constraints);
- assertThat(result, is(true));
-
- tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- assertThat(tunnels.size(), is(2));
- }
-
- /**
- * Tests path release.
- */
- @Test
- public void releasePathTest1() {
- build4RouterTopo(false, false, false, false, 5);
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(TE_COST);
- PceBandwidthConstraint bwConst = new PceBandwidthConstraint(Bandwidth.bps(3));
- constraints.add(bwConst);
- constraints.add(costConstraint);
-
- List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
- ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, link1);
- explicitPathInfoList.add(obj);
- obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT, D2.deviceId());
- explicitPathInfoList.add(obj);
-
- pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING, explicitPathInfoList);
-
- Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- assertThat(tunnels.size(), is(1));
- boolean result;
- for (Tunnel tunnel : tunnels) {
- result = pceManager.releasePath(tunnel.tunnelId());
- assertThat(result, is(true));
- }
- tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- assertThat(tunnels.size(), is(0));
- }
-
- /**
- * Tests path release failure.
- */
- @Test
- public void releasePathTest2() {
- build4RouterTopo(false, false, false, false, 5);
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(TE_COST);
- constraints.add(costConstraint);
-
- pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING, null);
-
- Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- assertThat(tunnels.size(), is(1));
-
- // Random tunnel id.
- boolean result = pceManager.releasePath(TunnelId.valueOf("111"));
- assertThat(result, is(false));
-
- tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- assertThat(tunnels.size(), is(1));
- }
-
- /**
- * Tests path release failure.
- */
- @Test
- public void releasePathTest3() {
- build4RouterTopo(false, false, false, false, 5);
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(TE_COST);
- PceBandwidthConstraint bwConst = new PceBandwidthConstraint(Bandwidth.bps(3));
- constraints.add(bwConst);
- constraints.add(costConstraint);
-
- pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING, null);
-
- Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- assertThat(tunnels.size(), is(1));
- boolean result;
- for (Tunnel tunnel : tunnels) {
- result = pceManager.releasePath(tunnel.tunnelId());
- assertThat(result, is(true));
- }
- tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- assertThat(tunnels.size(), is(0));
- }
-
- /**
- * Tests tunnel events added and removed.
- */
- @Test
- public void tunnelEventTest1() {
- build4RouterTopo(false, true, true, true, 15);
- List<Constraint> constraints = new LinkedList<Constraint>();
- PceBandwidthConstraint bwConstraint = new PceBandwidthConstraint(Bandwidth.bps(10.0));
- CostConstraint costConstraint = new CostConstraint(TE_COST);
-
- constraints.add(costConstraint);
- constraints.add(bwConstraint);
-
- boolean isSuccess = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T1", constraints,
- SR_WITHOUT_SIGNALLING, null);
- assertThat(isSuccess, is(true));
-
- Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
-
- for (Tunnel tunnel : tunnels) {
- TunnelEvent event = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, tunnel);
- tunnelListener.event(event);
-
- isSuccess = pceManager.releasePath(tunnel.tunnelId());
- assertThat(isSuccess, is(true));
-
- event = new TunnelEvent(TunnelEvent.Type.TUNNEL_REMOVED, tunnel);
- tunnelListener.event(event);
- }
- }
-
- /**
- * Tests label allocation/removal in CR case based on tunnel event.
- */
- @Test
- public void tunnelEventTest2() {
- build4RouterTopo(false, true, true, true, 15);
- List<Constraint> constraints = new LinkedList<Constraint>();
- PceBandwidthConstraint bwConstraint = new PceBandwidthConstraint(Bandwidth.bps(10.0));
- CostConstraint costConstraint = new CostConstraint(TE_COST);
-
- constraints.add(costConstraint);
- constraints.add(bwConstraint);
-
- boolean isSuccess = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T2", constraints,
- WITHOUT_SIGNALLING_AND_WITHOUT_SR, null);
- assertThat(isSuccess, is(true));
-
- TunnelEvent event;
- Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- for (Tunnel tunnel : tunnels) {
- event = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, tunnel);
- tunnelListener.event(event);
-
- // Stimulate the effect of LSP ids from protocol msg.
- tunnelService.updateTunnelWithLspIds(tunnel, "123", "1", ESTABLISHED);
- }
-
- tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- for (Tunnel tunnel : tunnels) {
- event = new TunnelEvent(TunnelEvent.Type.TUNNEL_UPDATED, tunnel);
- tunnelListener.event(event);
-
- isSuccess = pceManager.releasePath(tunnel.tunnelId());
- assertThat(isSuccess, is(true));
-
- event = new TunnelEvent(TunnelEvent.Type.TUNNEL_REMOVED, tunnel);
- tunnelListener.event(event);
- }
- }
-
- /**
- * Tests handling UNSTABLE state based on tunnel event.
- */
- @Test
- public void tunnelEventTest3() {
- build4RouterTopo(false, true, true, true, 15);
- List<Constraint> constraints = new LinkedList<Constraint>();
- PceBandwidthConstraint bwConstraint = new PceBandwidthConstraint(Bandwidth.bps(10.0));
- CostConstraint costConstraint = new CostConstraint(TE_COST);
-
- constraints.add(costConstraint);
- constraints.add(bwConstraint);
-
- boolean isSuccess = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T2", constraints,
- WITHOUT_SIGNALLING_AND_WITHOUT_SR, null);
- assertThat(isSuccess, is(true));
- assertThat(pceStore.getFailedPathInfoCount(), is(0));
-
- TunnelEvent event;
- Collection<Tunnel> tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- for (Tunnel tunnel : tunnels) {
- event = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, tunnel);
- tunnelListener.event(event);
-
- // Stimulate the effect of LSP ids from protocol msg.
- tunnelService.updateTunnelWithLspIds(tunnel, "123", "1", UNSTABLE);
- }
-
- tunnels = (Collection<Tunnel>) pceManager.queryAllPath();
- for (Tunnel tunnel : tunnels) {
- event = new TunnelEvent(TunnelEvent.Type.TUNNEL_UPDATED, tunnel);
- tunnelListener.event(event);
- }
-
- assertThat(pceStore.getFailedPathInfoCount(), is(1));
- }
-
- /**
- * Tests resiliency when L2 link is down.
- */
- @Test
- public void resiliencyTest1() {
- build4RouterTopo(true, false, false, false, 10);
-
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(COST);
- constraints.add(costConstraint);
- PceBandwidthConstraint localBwConst = new PceBandwidthConstraint(Bandwidth.bps(10));
- constraints.add(localBwConst);
-
- //Setup the path , tunnel created
- boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
- constraints, WITH_SIGNALLING, null);
- assertThat(result, is(true));
- assertThat(pceStore.getFailedPathInfoCount(), is(0));
-
- List<Event> reasons = new LinkedList<>();
- final LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
- reasons.add(linkEvent);
- final TopologyEvent event = new TopologyEvent(
- TopologyEvent.Type.TOPOLOGY_CHANGED,
- topology,
- reasons);
-
- //Change Topology : remove link2
- Set<TopologyEdge> tempEdges = new HashSet<>();
- tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
- topologyService.changeInTopology(getGraph(null, tempEdges));
- listener.event(event);
-
- List<Link> links = new LinkedList<>();
- links.add(link3);
- links.add(link4);
-
- //Path is D1-D3-D4
- assertThat(pathService.paths().iterator().next().links(), is(links));
- assertThat(pathService.paths().iterator().next().weight(), is(ScalarWeight.toWeight(180.0)));
- }
-
- /**
- * Tests resiliency when L2 and L4 link is down.
- */
- @Test
- public void resiliencyTest2() {
- build4RouterTopo(true, false, false, false, 10);
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(COST);
- constraints.add(costConstraint);
- PceBandwidthConstraint localBwConst = new PceBandwidthConstraint(Bandwidth.bps(10));
- constraints.add(localBwConst);
-
- //Setup the path , tunnel created
- boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
- constraints, WITH_SIGNALLING, null);
- assertThat(result, is(true));
-
- List<Event> reasons = new LinkedList<>();
- LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
- reasons.add(linkEvent);
- linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link4);
- reasons.add(linkEvent);
- final TopologyEvent event = new TopologyEvent(
- TopologyEvent.Type.TOPOLOGY_CHANGED,
- topology,
- reasons);
-
- //Change Topology : remove link2 and link4
- Set<TopologyEdge> tempEdges = new HashSet<>();
- tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
- tempEdges.add(new DefaultTopologyEdge(D3, D4, link4));
- topologyService.changeInTopology(getGraph(null, tempEdges));
- listener.event(event);
-
- //No Path
- assertThat(pathService.paths().size(), is(0));
- }
-
- /**
- * Tests resiliency when D2 device is down.
- */
- @Test
- public void resiliencyTest3() {
- build4RouterTopo(true, false, false, false, 10);
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(COST);
- constraints.add(costConstraint);
- PceBandwidthConstraint localBwConst = new PceBandwidthConstraint(Bandwidth.bps(10));
- constraints.add(localBwConst);
-
- //Setup the path , tunnel created
- boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
- constraints, WITH_SIGNALLING, null);
- assertThat(result, is(true));
-
- List<Event> reasons = new LinkedList<>();
- LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
- reasons.add(linkEvent);
- linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link1);
- reasons.add(linkEvent);
- final TopologyEvent event = new TopologyEvent(
- TopologyEvent.Type.TOPOLOGY_CHANGED,
- topology,
- reasons);
-
- //Change Topology : remove link2 and link1
- Set<TopologyEdge> tempEdges = new HashSet<>();
- tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
- tempEdges.add(new DefaultTopologyEdge(D1, D2, link1));
- topologyService.changeInTopology(getGraph(null, tempEdges));
- listener.event(event);
-
- List<Link> links = new LinkedList<>();
- links.add(link3);
- links.add(link4);
-
- Path path = tunnelService.queryAllTunnels().iterator().next().path();
- //Path is D1-D3-D4
- assertThat(path.links(), is(links));
- assertThat(path.weight(), is(ScalarWeight.toWeight(180.0)));
- }
-
- /**
- * Tests resiliency when ingress device is down.
- */
- @Test
- public void resiliencyTest4() {
- build4RouterTopo(true, false, false, false, 10);
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(COST);
- constraints.add(costConstraint);
- PceBandwidthConstraint localBwConst = new PceBandwidthConstraint(Bandwidth.bps(10));
- constraints.add(localBwConst);
-
- //Setup the path , tunnel created
- boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
- constraints, WITH_SIGNALLING, null);
- assertThat(result, is(true));
-
- List<Event> reasons = new LinkedList<>();
- LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link3);
- reasons.add(linkEvent);
- linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link1);
- reasons.add(linkEvent);
- final TopologyEvent event = new TopologyEvent(
- TopologyEvent.Type.TOPOLOGY_CHANGED,
- topology,
- reasons);
-
- //Change Topology : remove link2 and link1
- Set<TopologyEdge> tempEdges = new HashSet<>();
- tempEdges.add(new DefaultTopologyEdge(D1, D3, link3));
- tempEdges.add(new DefaultTopologyEdge(D1, D2, link1));
- topologyService.changeInTopology(getGraph(null, tempEdges));
- listener.event(event);
-
- //No path
- assertThat(pathService.paths().size(), is(0));
- }
-
- /**
- * Tests resiliency when D2 and D3 devices are down.
- */
- @Test
- public void resiliencyTest5() {
- build4RouterTopo(true, false, false, false, 10);
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(COST);
- constraints.add(costConstraint);
- PceBandwidthConstraint localBwConst = new PceBandwidthConstraint(Bandwidth.bps(10));
- constraints.add(localBwConst);
-
- //Setup the path , tunnel created
- boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
- constraints, WITH_SIGNALLING, null);
- assertThat(result, is(true));
-
- List<Event> reasons = new LinkedList<>();
- LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
- reasons.add(linkEvent);
- linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link1);
- reasons.add(linkEvent);
- linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link3);
- reasons.add(linkEvent);
- linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link4);
- reasons.add(linkEvent);
-
- final TopologyEvent event = new TopologyEvent(
- TopologyEvent.Type.TOPOLOGY_CHANGED,
- topology,
- reasons);
-
- //Change Topology : remove device2, device3 and all links
- Set<TopologyEdge> tempEdges = new HashSet<>();
- tempEdges.add(new DefaultTopologyEdge(D1, D2, link1));
- tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
- tempEdges.add(new DefaultTopologyEdge(D1, D3, link3));
- tempEdges.add(new DefaultTopologyEdge(D3, D4, link4));
- Set<TopologyVertex> tempVertexes = new HashSet<>();
- tempVertexes.add(D2);
- tempVertexes.add(D3);
- topologyService.changeInTopology(getGraph(tempVertexes, tempEdges));
- listener.event(event);
-
- //No path
- assertThat(pathService.paths().size(), is(0));
- }
-
- /**
- * Tests resiliency when egress device is down.
- */
- @Test
- public void resiliencyTest6() {
- build4RouterTopo(true, false, false, false, 10);
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(COST);
- constraints.add(costConstraint);
- PceBandwidthConstraint localBwConst = new PceBandwidthConstraint(Bandwidth.bps(10));
- constraints.add(localBwConst);
-
- //Setup the path , tunnel created
- boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
- constraints, WITH_SIGNALLING, null);
- assertThat(result, is(true));
-
- List<Event> reasons = new LinkedList<>();
- LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
- reasons.add(linkEvent);
- linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link4);
- reasons.add(linkEvent);
-
- final TopologyEvent event = new TopologyEvent(
- TopologyEvent.Type.TOPOLOGY_CHANGED,
- topology,
- reasons);
-
- //Change Topology : remove device4 , link2 and link4
- Set<TopologyEdge> tempEdges = new HashSet<>();
- tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
- tempEdges.add(new DefaultTopologyEdge(D3, D4, link4));
- Set<TopologyVertex> tempVertexes = new HashSet<>();
- tempVertexes.add(D4);
- topologyService.changeInTopology(getGraph(tempVertexes, tempEdges));
- listener.event(event);
-
- //No path
- assertThat(pathService.paths().size(), is(0));
- }
-
- /**
- * Tests resiliency when egress device is down.
- */
- @Test
- public void resiliencyTest7() {
- build4RouterTopo(true, false, false, false, 10);
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(COST);
- constraints.add(costConstraint);
- PceBandwidthConstraint localBwConst = new PceBandwidthConstraint(Bandwidth.bps(10));
- constraints.add(localBwConst);
-
- //Setup the path , tunnel created
- boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
- constraints, WITH_SIGNALLING, null);
- assertThat(result, is(true));
-
- List<Event> reasons = new LinkedList<>();
- LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
- reasons.add(linkEvent);
- linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link4);
- reasons.add(linkEvent);
-
- final TopologyEvent event = new TopologyEvent(
- TopologyEvent.Type.TOPOLOGY_CHANGED,
- topology,
- reasons);
-
- //Change Topology : remove device4 , link2 and link4
- Set<TopologyEdge> tempEdges = new HashSet<>();
- tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
- tempEdges.add(new DefaultTopologyEdge(D3, D4, link4));
- Set<TopologyVertex> tempVertexes = new HashSet<>();
- tempVertexes.add(D4);
- topologyService.changeInTopology(getGraph(tempVertexes, tempEdges));
- listener.event(event);
-
- //No path
- assertThat(pathService.paths().size(), is(0));
- }
-
- /**
- * Tests resiliency when D2 device is suspended.
- */
- @Test
- public void resiliencyTest8() {
- build4RouterTopo(true, false, false, false, 10);
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(COST);
- constraints.add(costConstraint);
- PceBandwidthConstraint localBwConst = new PceBandwidthConstraint(Bandwidth.bps(10));
- constraints.add(localBwConst);
-
- //Setup the path , tunnel created
- boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
- constraints, WITH_SIGNALLING, null);
- assertThat(result, is(true));
-
- List<Event> reasons = new LinkedList<>();
- LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link1);
- reasons.add(linkEvent);
- linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
- reasons.add(linkEvent);
-
- final TopologyEvent event = new TopologyEvent(
- TopologyEvent.Type.TOPOLOGY_CHANGED,
- topology,
- reasons);
-
- //Change Topology : remove device2 , link1 and link2
- Set<TopologyEdge> tempEdges = new HashSet<>();
- tempEdges.add(new DefaultTopologyEdge(D1, D2, link1));
- tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
- Set<TopologyVertex> tempVertexes = new HashSet<>();
- tempVertexes.add(D2);
- topologyService.changeInTopology(getGraph(tempVertexes, tempEdges));
- listener.event(event);
-
- List<Link> links = new LinkedList<>();
- links.add(link3);
- links.add(link4);
-
- Path path = tunnelService.queryAllTunnels().iterator().next().path();
-
- //Path is D1-D3-D4
- assertThat(path.links(), is(links));
- assertThat(path.weight(), is(ScalarWeight.toWeight(180.0)));
- }
-
- /**
- * Tests resiliency when D2 device availability is changed.
- */
- @Test
- public void resiliencyTest11() {
- build4RouterTopo(true, false, false, false, 10);
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(COST);
- constraints.add(costConstraint);
- PceBandwidthConstraint localBwConst = new PceBandwidthConstraint(Bandwidth.bps(10));
- constraints.add(localBwConst);
-
- //Setup the path , tunnel created
- boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
- constraints, WITH_SIGNALLING, null);
- assertThat(result, is(true));
-
- List<Event> reasons = new LinkedList<>();
- LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link1);
- reasons.add(linkEvent);
- linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
- reasons.add(linkEvent);
-
- final TopologyEvent event = new TopologyEvent(
- TopologyEvent.Type.TOPOLOGY_CHANGED,
- topology,
- reasons);
-
- //Change Topology : remove device2 , link1 and link2
- Set<TopologyEdge> tempEdges = new HashSet<>();
- tempEdges.add(new DefaultTopologyEdge(D1, D2, link1));
- tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
- Set<TopologyVertex> tempVertexes = new HashSet<>();
- tempVertexes.add(D2);
- topologyService.changeInTopology(getGraph(tempVertexes, tempEdges));
- listener.event(event);
-
- List<Link> links = new LinkedList<>();
- links.add(link3);
- links.add(link4);
-
- Path path = tunnelService.queryAllTunnels().iterator().next().path();
-
- //Path is D1-D3-D4
- assertThat(path.links(), is(links));
- assertThat(path.weight(), is(ScalarWeight.toWeight(180.0)));
- }
-
- /**
- * Tests resiliency when link2 availability is changed.
- */
- @Test
- public void resiliencyTest12() {
- build4RouterTopo(true, false, false, false, 10);
-
- List<Constraint> constraints = new LinkedList<Constraint>();
- CostConstraint costConstraint = new CostConstraint(COST);
- constraints.add(costConstraint);
- PceBandwidthConstraint localBwConst = new PceBandwidthConstraint(Bandwidth.bps(10));
- constraints.add(localBwConst);
-
- List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList();
- ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, link1);
- explicitPathInfoList.add(obj);
- obj = new ExplicitPathInfo(ExplicitPathInfo.Type.STRICT, D2.deviceId());
- explicitPathInfoList.add(obj);
-
- //Setup the path , tunnel created
- boolean result = pceManager.setupPath(D1.deviceId(), D4.deviceId(), "T123",
- constraints, WITH_SIGNALLING, explicitPathInfoList);
- assertThat(result, is(true));
- assertThat(pceStore.getFailedPathInfoCount(), is(0));
-
- List<Event> reasons = new LinkedList<>();
- final LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2);
- reasons.add(linkEvent);
- final TopologyEvent event = new TopologyEvent(
- TopologyEvent.Type.TOPOLOGY_CHANGED,
- topology,
- reasons);
-
- //Change Topology : remove link2
- Set<TopologyEdge> tempEdges = new HashSet<>();
- tempEdges.add(new DefaultTopologyEdge(D2, D4, link2));
- topologyService.changeInTopology(getGraph(null, tempEdges));
- listener.event(event);
-
- List<Link> links = new LinkedList<>();
- links.add(link3);
- links.add(link4);
-
- //Path fails - no alternate path
- assertThat(pathService.paths().iterator().hasNext(), is(false));
- }
-
- @After
- public void tearDown() {
- pceManager.deactivate();
- pceManager.pathService = null;
- pceManager.tunnelService = null;
- pceManager.coreService = null;
- pceManager.storageService = null;
- pceManager.deviceService = null;
- pceManager.netCfgService = null;
- pceManager.pceStore = null;
- pceManager.topologyService = null;
- pceManager.mastershipService = null;
- flowsDownloaded = 0;
- }
-
- private class MockTopologyService extends TopologyServiceAdapter {
- private void changeInTopology(TopologyGraph graphModified) {
- graph = graphModified;
- }
-
- @Override
- public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeigher weight) {
- DefaultTopologyVertex srcV = new DefaultTopologyVertex(src);
- DefaultTopologyVertex dstV = new DefaultTopologyVertex(dst);
- Set<TopologyVertex> vertices = graph.getVertexes();
- if (!vertices.contains(srcV) || !vertices.contains(dstV)) {
- // src or dst not part of the current graph
- return ImmutableSet.of();
- }
-
- GraphPathSearch.Result<TopologyVertex, TopologyEdge> result = PathComputationTest.graphSearch()
- .search(graph, srcV, dstV, weight, ALL_PATHS);
- ImmutableSet.Builder<Path> builder = ImmutableSet.builder();
- for (org.onlab.graph.Path<TopologyVertex, TopologyEdge> path : result.paths()) {
- builder.add(PathComputationTest.networkPath(path));
- }
- return builder.build();
- }
- }
-
- private TopologyGraph getGraph(Set<TopologyVertex> removedVertex, Set<TopologyEdge> removedEdges) {
- if (removedVertex != null) {
- vertexes.remove(removedVertex);
- removedVertex.forEach(new Consumer<TopologyVertex>() {
- @Override
- public void accept(TopologyVertex v) {
- vertexes.remove(v);
- }
- });
- }
-
- if (removedEdges != null) {
- removedEdges.forEach(new Consumer<TopologyEdge>() {
- @Override
- public void accept(TopologyEdge e) {
- edges.remove(e);
- }
- });
- }
-
- return new DefaultTopologyGraph(vertexes, edges);
- }
-
- private class MockPathService extends PathServiceAdapter {
- Set<Path> computedPaths;
- @Override
- public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weight) {
- // If either edge is null, bail with no paths.
- if (src == null || dst == null) {
- return ImmutableSet.of();
- }
-
- // Otherwise get all paths between the source and destination edge
- // devices.
- computedPaths = topologyService.getPaths(null, (DeviceId) src, (DeviceId) dst, weight);
- return computedPaths;
- }
-
- private Set<Path> paths() {
- return computedPaths;
- }
- }
-
- private class MockTunnelServiceAdapter extends TunnelServiceAdapter {
- private HashMap<TunnelId, Tunnel> tunnelIdAsKeyStore = new HashMap<TunnelId, Tunnel>();
- private int tunnelIdCounter = 0;
-
- @Override
- public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) {
- TunnelId tunnelId = TunnelId.valueOf(String.valueOf(++tunnelIdCounter));
- Tunnel tunnelToInsert = new DefaultTunnel(tunnel.providerId(), tunnel.src(), tunnel.dst(), tunnel.type(),
- tunnel.state(), tunnel.groupId(), tunnelId, tunnel.tunnelName(),
- path, tunnel.annotations());
- tunnelIdAsKeyStore.put(tunnelId, tunnelToInsert);
- return tunnelId;
- }
-
- @Override
- public void addListener(TunnelListener listener) {
- tunnelListener = listener;
- }
-
- /**
- * Stimulates the effect of receiving PLSP id and LSP id from protocol PCRpt msg.
- */
- public TunnelId updateTunnelWithLspIds(Tunnel tunnel, String pLspId, String localLspId, State state) {
- TunnelId tunnelId = tunnel.tunnelId();
- Builder annotationBuilder = DefaultAnnotations.builder();
- annotationBuilder.putAll(tunnel.annotations());
-
- // PCRpt in response to PCInitate msg will carry PLSP id allocated by PCC.
- if (tunnel.annotations().value(PLSP_ID) == null) {
- annotationBuilder.set(PLSP_ID, pLspId);
- }
-
- // Signalled LSPs will carry local LSP id allocated by signalling protocol(PCC).
- if (tunnel.annotations().value(LOCAL_LSP_ID) == null) {
- annotationBuilder.set(LOCAL_LSP_ID, localLspId);
- }
- SparseAnnotations annotations = annotationBuilder.build();
- tunnelIdAsKeyStore.remove(tunnelId, tunnel);
-
- Tunnel tunnelToInsert = new DefaultTunnel(tunnel.providerId(), tunnel.src(), tunnel.dst(), tunnel.type(),
- state, tunnel.groupId(), tunnelId, tunnel.tunnelName(),
- tunnel.path(), annotations);
-
- tunnelIdAsKeyStore.put(tunnelId, tunnelToInsert);
-
- return tunnelId;
- }
-
- @Override
- public boolean downTunnel(ApplicationId producerId, TunnelId tunnelId) {
- for (TunnelId tunnelIdKey : tunnelIdAsKeyStore.keySet()) {
- if (tunnelIdKey.equals(tunnelId)) {
- tunnelIdAsKeyStore.remove(tunnelId);
- return true;
- }
- }
- return false;
- }
-
- @Override
- public Tunnel queryTunnel(TunnelId tunnelId) {
- for (TunnelId tunnelIdKey : tunnelIdAsKeyStore.keySet()) {
- if (tunnelIdKey.equals(tunnelId)) {
- return tunnelIdAsKeyStore.get(tunnelId);
- }
- }
- return null;
- }
-
- @Override
- public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) {
- Collection<Tunnel> result = new HashSet<Tunnel>();
- Tunnel tunnel = null;
- for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
- tunnel = tunnelIdAsKeyStore.get(tunnelId);
-
- if ((null != tunnel) && (src.equals(tunnel.src())) && (dst.equals(tunnel.dst()))) {
- result.add(tunnel);
- }
- }
-
- return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result);
- }
-
- @Override
- public Collection<Tunnel> queryTunnel(Tunnel.Type type) {
- Collection<Tunnel> result = new HashSet<Tunnel>();
-
- for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
- result.add(tunnelIdAsKeyStore.get(tunnelId));
- }
-
- return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result);
- }
-
- @Override
- public Collection<Tunnel> queryAllTunnels() {
- Collection<Tunnel> result = new HashSet<Tunnel>();
-
- for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
- result.add(tunnelIdAsKeyStore.get(tunnelId));
- }
-
- return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result);
- }
-
- @Override
- public Iterable<Tunnel> getTunnels(DeviceId deviceId) {
- List<Tunnel> tunnelList = new LinkedList<>();
-
- for (Tunnel t : tunnelIdAsKeyStore.values()) {
- for (Link l : t.path().links()) {
- if (l.src().deviceId().equals(deviceId) || l.dst().deviceId().equals(deviceId)) {
- tunnelList.add(t);
- break;
- }
- }
- }
- return tunnelList;
- }
- }
-
- public static class MockCoreService extends CoreServiceAdapter {
-
- @Override
- public ApplicationId registerApplication(String name) {
- return new DefaultApplicationId(1, name);
- }
-
- @Override
- public IdGenerator getIdGenerator(String topic) {
- return new IdGenerator() {
- private AtomicLong counter = new AtomicLong(0);
-
- @Override
- public long getNewId() {
- return counter.getAndIncrement();
- }
- };
- }
- }
-
- private class MockDevice extends DefaultDevice {
- MockDevice(DeviceId id, Annotations annotations) {
- super(null, id, null, null, null, null, null, null, annotations);
- }
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/ResourceServiceAdapter.java b/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/ResourceServiceAdapter.java
deleted file mode 100644
index fb579c9..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pceservice/ResourceServiceAdapter.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pceservice;
-
-import org.onosproject.net.resource.DiscreteResourceId;
-import org.onosproject.net.resource.ResourceAllocation;
-import org.onosproject.net.resource.ResourceConsumer;
-import org.onosproject.net.resource.ResourceId;
-import org.onosproject.net.resource.ResourceListener;
-import org.onosproject.net.resource.Resource;
-import org.onosproject.net.resource.ResourceService;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Adapter for resource service for path computation.
- */
-public class ResourceServiceAdapter implements ResourceService {
-
- @Override
- public void addListener(ResourceListener listener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeListener(ResourceListener listener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<? extends Resource> resources) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean release(List<ResourceAllocation> allocations) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean release(ResourceConsumer consumer) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public List<ResourceAllocation> getResourceAllocations(ResourceId id) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public <T> Collection<ResourceAllocation> getResourceAllocations(DiscreteResourceId parent, Class<T> cls) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<ResourceAllocation> getResourceAllocations(ResourceConsumer consumer) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Set<Resource> getAvailableResources(DiscreteResourceId parent) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public <T> Set<Resource> getAvailableResources(DiscreteResourceId parent, Class<T> cls) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public <T> Set<T> getAvailableResourceValues(DiscreteResourceId parent, Class<T> cls) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Set<Resource> getRegisteredResources(DiscreteResourceId parent) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean isAvailable(Resource resource) {
- // TODO Auto-generated method stub
- return false;
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/DistributedPceStoreTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/DistributedPceStoreTest.java
deleted file mode 100644
index ec378c4..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/DistributedPceStoreTest.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pcestore;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onlab.util.DataRateUnit;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.intent.constraint.BandwidthConstraint;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.ResourceConsumer;
-import org.onosproject.pce.pceservice.ExplicitPathInfo;
-import org.onosproject.pce.pceservice.LspType;
-import org.onosproject.pce.pceservice.TunnelConsumerId;
-import org.onosproject.store.service.TestStorageService;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit tests for DistributedPceStore class.
- */
-public class DistributedPceStoreTest {
-
- private DistributedPceStore distrPceStore;
- private DeviceId deviceId1 = DeviceId.deviceId("foo");
- private DeviceId deviceId2 = DeviceId.deviceId("goo");
- private DeviceId deviceId3 = DeviceId.deviceId("yaa");
- private DeviceId deviceId4 = DeviceId.deviceId("zoo");
- private LabelResourceId labelId1 = LabelResourceId.labelResourceId(1);
- private LabelResourceId labelId2 = LabelResourceId.labelResourceId(2);
- private LabelResourceId labelId3 = LabelResourceId.labelResourceId(3);
- private LabelResourceId labelId4 = LabelResourceId.labelResourceId(4);
- private PortNumber portNumber1 = PortNumber.portNumber(1);
- private PortNumber portNumber2 = PortNumber.portNumber(2);
- private PortNumber portNumber3 = PortNumber.portNumber(3);
- private PortNumber portNumber4 = PortNumber.portNumber(4);
- private ConnectPoint srcConnectionPoint1 = new ConnectPoint(deviceId1, portNumber1);
- private ConnectPoint dstConnectionPoint2 = new ConnectPoint(deviceId2, portNumber2);
- private ConnectPoint srcConnectionPoint3 = new ConnectPoint(deviceId3, portNumber3);
- private ConnectPoint dstConnectionPoint4 = new ConnectPoint(deviceId4, portNumber4);
- private Link link1;
- private Link link2;
- private TunnelId tunnelId1 = TunnelId.valueOf("1");
- private TunnelId tunnelId2 = TunnelId.valueOf("2");
- private TunnelId tunnelId3 = TunnelId.valueOf("3");
- private TunnelId tunnelId4 = TunnelId.valueOf("4");
- private ResourceConsumer tunnelConsumerId1 = TunnelConsumerId.valueOf(10);
- private ResourceConsumer tunnelConsumerId2 = TunnelConsumerId.valueOf(20);
- private PcePathInfo failedPathInfo1;
- private PcePathInfo failedPathInfo2;
- private PcePathInfo failedPathInfo3;
- private PcePathInfo failedPathInfo4;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- distrPceStore = new DistributedPceStore();
-
- // Initialization of member variables
- link1 = DefaultLink.builder()
- .providerId(new ProviderId("eth", "1"))
- .annotations(DefaultAnnotations.builder().set("key1", "yahoo").build())
- .src(srcConnectionPoint1)
- .dst(dstConnectionPoint2)
- .type(Link.Type.DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- link2 = DefaultLink.builder()
- .providerId(new ProviderId("mac", "2"))
- .annotations(DefaultAnnotations.builder().set("key2", "google").build())
- .src(srcConnectionPoint3)
- .dst(dstConnectionPoint4)
- .type(Link.Type.DIRECT)
- .state(Link.State.ACTIVE)
- .build();
-
- // Creates failedPathInfo1
- DeviceId src1 = DeviceId.deviceId("foo1");
- DeviceId dst1 = DeviceId.deviceId("goo1");
- String name1 = "pcc1";
- LspType lspType1 = LspType.SR_WITHOUT_SIGNALLING;
- List<Constraint> constraints1 = new LinkedList<>();
- Constraint bandwidth1 = BandwidthConstraint.of(200, DataRateUnit.BPS);
- constraints1.add(bandwidth1);
-
- failedPathInfo1 = new PcePathInfo(src1, dst1, name1, constraints1, lspType1, null, false);
-
- // Creates failedPathInfo2
- DeviceId src2 = DeviceId.deviceId("foo2");
- DeviceId dst2 = DeviceId.deviceId("goo2");
- String name2 = "pcc2";
- LspType lspType2 = LspType.SR_WITHOUT_SIGNALLING;
- List<Constraint> constraints2 = new LinkedList<>();
- Constraint bandwidth2 = BandwidthConstraint.of(400, DataRateUnit.BPS);
- constraints2.add(bandwidth2);
-
- failedPathInfo2 = new PcePathInfo(src2, dst2, name2, constraints2, lspType2, null, false);
-
- // Creates failedPathInfo3
- DeviceId src3 = DeviceId.deviceId("foo3");
- DeviceId dst3 = DeviceId.deviceId("goo3");
- String name3 = "pcc3";
- LspType lspType3 = LspType.SR_WITHOUT_SIGNALLING;
- List<Constraint> constraints3 = new LinkedList<>();
- Constraint bandwidth3 = BandwidthConstraint.of(500, DataRateUnit.BPS);
- constraints3.add(bandwidth3);
-
- failedPathInfo3 = new PcePathInfo(src3, dst3, name3, constraints3, lspType3, null, false);
-
- // Creates failedPathInfo4
- DeviceId src4 = DeviceId.deviceId("foo4");
- DeviceId dst4 = DeviceId.deviceId("goo4");
- String name4 = "pcc4";
- LspType lspType4 = LspType.SR_WITHOUT_SIGNALLING;
- List<Constraint> constraints4 = new LinkedList<>();
- Constraint bandwidth4 = BandwidthConstraint.of(600, DataRateUnit.BPS);
- constraints4.add(bandwidth4);
-
- failedPathInfo4 = new PcePathInfo(src4, dst4, name4, constraints4, lspType4, null, false);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- /**
- * Checks the operation of addTunnelInfo() method.
- */
- @Test
- public void testAddExplicitPathInfo() {
- // initialization
- distrPceStore.storageService = new TestStorageService();
- distrPceStore.activate();
-
- List<ExplicitPathInfo> infoList = new LinkedList<>();
- ExplicitPathInfo info1 = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, DeviceId.deviceId("D1"));
- infoList.add(info1);
- distrPceStore.tunnelNameExplicitPathInfoMap("Sample1", infoList);
- assertThat(distrPceStore.getTunnelNameExplicitPathInfoMap("Sample1"), is(infoList));
- }
-
- /**
- * Checks the operation of addFailedPathInfo() method.
- */
- @Test
- public void testAddFailedPathInfo() {
- // initialization
- distrPceStore.storageService = new TestStorageService();
- distrPceStore.activate();
-
- // PcePathInfo with pce path input information
- distrPceStore.addFailedPathInfo(failedPathInfo1);
- assertThat(distrPceStore.existsFailedPathInfo(failedPathInfo1), is(true));
- distrPceStore.addFailedPathInfo(failedPathInfo2);
- assertThat(distrPceStore.existsFailedPathInfo(failedPathInfo2), is(true));
- }
-
- /**
- * Checks the operation of existsFailedPathInfo() method.
- */
- @Test
- public void testExistsFailedPathInfo() {
- testAddFailedPathInfo();
-
- assertThat(distrPceStore.existsFailedPathInfo(failedPathInfo1), is(true));
- assertThat(distrPceStore.existsFailedPathInfo(failedPathInfo2), is(true));
- assertThat(distrPceStore.existsFailedPathInfo(failedPathInfo3), is(false));
- assertThat(distrPceStore.existsFailedPathInfo(failedPathInfo4), is(false));
- }
-
- /**
- * Checks the operation of getFailedPathInfoCount() method.
- */
- @Test
- public void testGetFailedPathInfoCount() {
- testAddFailedPathInfo();
-
- assertThat(distrPceStore.getFailedPathInfoCount(), is(2));
- }
-
- /**
- * Checks the operation of getFailedPathInfos() method.
- */
- @Test
- public void testGetFailedPathInfos() {
- testAddFailedPathInfo();
-
- Iterable<PcePathInfo> failedPathInfoSet = distrPceStore.getFailedPathInfos();
- assertThat(failedPathInfoSet, is(notNullValue()));
- assertThat(failedPathInfoSet.iterator().hasNext(), is(true));
- }
-
- /**
- * Checks the operation of removeFailedPathInfo() method.
- */
- @Test
- public void testRemoveFailedPathInfo() {
- testAddFailedPathInfo();
-
- assertThat(distrPceStore.removeFailedPathInfo(failedPathInfo1), is(true));
- assertThat(distrPceStore.removeFailedPathInfo(failedPathInfo2), is(true));
- assertThat(distrPceStore.removeFailedPathInfo(failedPathInfo3), is(false));
- assertThat(distrPceStore.removeFailedPathInfo(failedPathInfo4), is(false));
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/PcePathInfoTest.java b/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/PcePathInfoTest.java
deleted file mode 100644
index 4d31d68..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/pcestore/PcePathInfoTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.pcestore;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-
-import com.google.common.testing.EqualsTester;
-
-import java.util.List;
-import java.util.LinkedList;
-
-import org.junit.Test;
-import org.onlab.util.DataRateUnit;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.intent.constraint.BandwidthConstraint;
-import org.onosproject.pce.pceservice.LspType;
-
-/**
- * Unit tests for PcePathInfo class.
- */
-public class PcePathInfoTest {
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- // create same two objects.
- DeviceId src1 = DeviceId.deviceId("foo1");
- DeviceId dst1 = DeviceId.deviceId("goo1");
- String name1 = "pcc1";
- LspType lspType1 = LspType.WITH_SIGNALLING;
- List<Constraint> constraints1 = new LinkedList<>();
- Constraint bandwidth11 = BandwidthConstraint.of(100, DataRateUnit.BPS);
- constraints1.add(bandwidth11);
- Constraint bandwidth12 = BandwidthConstraint.of(200, DataRateUnit.BPS);
- constraints1.add(bandwidth12);
- Constraint bandwidth13 = BandwidthConstraint.of(300, DataRateUnit.BPS);
- constraints1.add(bandwidth13);
-
- PcePathInfo pathInfo1 = new PcePathInfo(src1, dst1, name1, constraints1, lspType1, null, false);
-
- // create same object as above object
- PcePathInfo samePathInfo1 = new PcePathInfo(src1, dst1, name1, constraints1, lspType1, null, false);
-
- // Create different object.
- DeviceId src2 = DeviceId.deviceId("foo2");
- DeviceId dst2 = DeviceId.deviceId("goo2");
- String name2 = "pcc2";
- LspType lspType2 = LspType.SR_WITHOUT_SIGNALLING;
- List<Constraint> constraints2 = new LinkedList<>();
- Constraint bandwidth21 = BandwidthConstraint.of(400, DataRateUnit.BPS);
- constraints2.add(bandwidth21);
- Constraint bandwidth22 = BandwidthConstraint.of(800, DataRateUnit.BPS);
- constraints2.add(bandwidth22);
-
- PcePathInfo pathInfo2 = new PcePathInfo(src2, dst2, name2, constraints2, lspType2, null, false);
-
- new EqualsTester().addEqualityGroup(pathInfo1, samePathInfo1)
- .addEqualityGroup(pathInfo2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a PcePathInfo object.
- */
- @Test
- public void testConstruction() {
- DeviceId src = DeviceId.deviceId("foo2");
- DeviceId dst = DeviceId.deviceId("goo2");
- String name = "pcc2";
- LspType lspType = LspType.SR_WITHOUT_SIGNALLING;
- List<Constraint> constraints = new LinkedList<>();
- Constraint bandwidth1 = BandwidthConstraint.of(100, DataRateUnit.BPS);
- constraints.add(bandwidth1);
- Constraint bandwidth2 = BandwidthConstraint.of(200, DataRateUnit.BPS);
- constraints.add(bandwidth2);
- Constraint bandwidth3 = BandwidthConstraint.of(300, DataRateUnit.BPS);
- constraints.add(bandwidth3);
-
- PcePathInfo pathInfo = new PcePathInfo(src, dst, name, constraints, lspType, null, false);
-
- assertThat(src, is(pathInfo.src()));
- assertThat(dst, is(pathInfo.dst()));
- assertThat(name, is(pathInfo.name()));
- assertThat(constraints, is(pathInfo.constraints()));
- assertThat(lspType, is(pathInfo.lspType()));
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/util/LabelResourceAdapter.java b/apps/pce/app/src/test/java/org/onosproject/pce/util/LabelResourceAdapter.java
deleted file mode 100644
index 3b7195a..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/util/LabelResourceAdapter.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.util;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Random;
-import java.util.Set;
-
-import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-import org.onosproject.incubator.net.resource.label.LabelResourceDelegate;
-import org.onosproject.incubator.net.resource.label.LabelResourceEvent;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceListener;
-import org.onosproject.incubator.net.resource.label.LabelResourcePool;
-import org.onosproject.incubator.net.resource.label.LabelResourceProvider;
-import org.onosproject.incubator.net.resource.label.LabelResourceProviderRegistry;
-import org.onosproject.incubator.net.resource.label.LabelResourceProviderService;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceEvent.Type;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.provider.AbstractListenerProviderRegistry;
-import org.onosproject.net.provider.AbstractProviderService;
-
-import com.google.common.collect.Multimap;
-
-/**
- * Provides test implementation of class LabelResourceService.
- */
-public class LabelResourceAdapter
- extends AbstractListenerProviderRegistry<LabelResourceEvent, LabelResourceListener,
- LabelResourceProvider, LabelResourceProviderService>
- implements LabelResourceService, LabelResourceAdminService, LabelResourceProviderRegistry {
- public static final long GLOBAL_LABEL_SPACE_MIN = 4097;
- public static final long GLOBAL_LABEL_SPACE_MAX = 5121;
- public static final long LOCAL_LABEL_SPACE_MIN = 5122;
- public static final long LOCAL_LABEL_SPACE_MAX = 9217;
-
- private Random random = new Random();
-
- @Override
- public boolean createDevicePool(DeviceId deviceId,
- LabelResourceId beginLabel,
- LabelResourceId endLabel) {
- return true;
- }
-
- @Override
- public boolean createGlobalPool(LabelResourceId beginLabel,
- LabelResourceId endLabel) {
- return true;
- }
-
- @Override
- public boolean destroyDevicePool(DeviceId deviceId) {
- return true;
- }
-
- @Override
- public boolean destroyGlobalPool() {
- return true;
- }
-
- public long getLabelId(long min, long max) {
- return random.nextInt((int) max - (int) min + 1) + (int) min;
- }
-
- public Collection<LabelResource> applyFromDevicePool(DeviceId deviceId,
- long applyNum) {
- Collection<LabelResource> labelList = new LinkedList<>();
- LabelResource label = new DefaultLabelResource(deviceId,
- LabelResourceId.labelResourceId(
- getLabelId(LOCAL_LABEL_SPACE_MIN, LOCAL_LABEL_SPACE_MAX)));
- labelList.add(label);
- return labelList;
- }
-
- public Collection<LabelResource> applyFromGlobalPool(long applyNum) {
- Collection<LabelResource> labelList = new LinkedList<>();
- LabelResource label = new DefaultLabelResource(DeviceId.deviceId("foo"),
- LabelResourceId.labelResourceId(
- getLabelId(GLOBAL_LABEL_SPACE_MIN, GLOBAL_LABEL_SPACE_MAX)));
- labelList.add(label);
- return labelList;
- }
-
- public boolean releaseToDevicePool(Multimap<DeviceId, LabelResource> release) {
- return true;
- }
-
- public boolean releaseToGlobalPool(Set<LabelResourceId> release) {
- return true;
- }
-
- public boolean isDevicePoolFull(DeviceId deviceId) {
- return false;
- }
-
- public boolean isGlobalPoolFull() {
- return false;
- }
-
- public long getFreeNumOfDevicePool(DeviceId deviceId) {
- return 4;
- }
-
- public long getFreeNumOfGlobalPool() {
- return 4;
- }
-
- @Override
- public LabelResourcePool getDeviceLabelResourcePool(DeviceId deviceId) {
- return null;
- }
-
- @Override
- public LabelResourcePool getGlobalLabelResourcePool() {
- return null;
- }
-
- private class InternalLabelResourceDelegate implements LabelResourceDelegate {
- @Override
- public void notify(LabelResourceEvent event) {
- post(event);
- }
-
- }
-
- private class InternalDeviceListener implements DeviceListener {
- @Override
- public void event(DeviceEvent event) {
- Device device = event.subject();
- if (Type.DEVICE_REMOVED.equals(event.type())) {
- destroyDevicePool(device.id());
- }
- }
- }
-
- private class InternalLabelResourceProviderService
- extends AbstractProviderService<LabelResourceProvider>
- implements LabelResourceProviderService {
-
- protected InternalLabelResourceProviderService(LabelResourceProvider provider) {
- super(provider);
- }
-
- @Override
- public void deviceLabelResourcePoolDetected(DeviceId deviceId,
- LabelResourceId beginLabel,
- LabelResourceId endLabel) {
- checkNotNull(deviceId, "deviceId is not null");
- checkNotNull(beginLabel, "beginLabel is not null");
- checkNotNull(endLabel, "endLabel is not null");
- createDevicePool(deviceId, beginLabel, endLabel);
- }
-
- @Override
- public void deviceLabelResourcePoolDestroyed(DeviceId deviceId) {
- checkNotNull(deviceId, "deviceId is not null");
- destroyDevicePool(deviceId);
- }
-
- }
-
- @Override
- protected LabelResourceProviderService createProviderService(LabelResourceProvider provider) {
- return null;
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/util/LinkServiceAdapter.java b/apps/pce/app/src/test/java/org/onosproject/pce/util/LinkServiceAdapter.java
deleted file mode 100644
index a239819..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/util/LinkServiceAdapter.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.util;
-
-import java.util.Set;
-
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.link.LinkListener;
-import org.onosproject.net.link.LinkService;
-import org.onosproject.net.Link.State;
-
-import com.google.common.collect.FluentIterable;
-
-/**
- * Test adapter for link service.
- */
-public class LinkServiceAdapter implements LinkService {
- @Override
- public int getLinkCount() {
- return 0;
- }
-
- @Override
- public Iterable<Link> getLinks() {
- return null;
- }
-
- @Override
- public Iterable<Link> getActiveLinks() {
- return FluentIterable.from(getLinks())
- .filter(input -> input.state() == State.ACTIVE);
- }
-
- @Override
- public Set<Link> getDeviceLinks(DeviceId deviceId) {
- return null;
- }
-
- @Override
- public Set<Link> getDeviceEgressLinks(DeviceId deviceId) {
- return null;
- }
-
- @Override
- public Set<Link> getDeviceIngressLinks(DeviceId deviceId) {
- return null;
- }
-
- @Override
- public Set<Link> getLinks(ConnectPoint connectPoint) {
- return null;
- }
-
- @Override
- public Set<Link> getEgressLinks(ConnectPoint connectPoint) {
- return null;
- }
-
- @Override
- public Set<Link> getIngressLinks(ConnectPoint connectPoint) {
- return null;
- }
-
- @Override
- public Link getLink(ConnectPoint src, ConnectPoint dst) {
- return null;
- }
-
- @Override
- public void addListener(LinkListener listener) {
- }
-
- @Override
- public void removeListener(LinkListener listener) {
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/util/MockDeviceService.java b/apps/pce/app/src/test/java/org/onosproject/pce/util/MockDeviceService.java
deleted file mode 100644
index 937c0fa..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/util/MockDeviceService.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.util;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceServiceAdapter;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-
-/**
- * Test fixture for the device service.
- */
-public class MockDeviceService extends DeviceServiceAdapter {
- private List<Device> devices = new LinkedList<>();
- private DeviceListener listener;
-
- public void addDevice(Device dev) {
- devices.add(dev);
- }
-
- public void removeDevice(Device dev) {
- devices.remove(dev);
- }
-
- @Override
- public Device getDevice(DeviceId deviceId) {
- for (Device dev : devices) {
- if (dev.id().equals(deviceId)) {
- return dev;
- }
- }
- return null;
- }
-
- @Override
- public Iterable<Device> getAvailableDevices() {
- return devices;
- }
-
- @Override
- public void addListener(DeviceListener listener) {
- this.listener = listener;
- }
-
- /**
- * Get the listener.
- */
- public DeviceListener getListener() {
- return listener;
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/util/MockLinkService.java b/apps/pce/app/src/test/java/org/onosproject/pce/util/MockLinkService.java
deleted file mode 100644
index bfca2c4..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/util/MockLinkService.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.util;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.link.LinkServiceAdapter;
-import org.onosproject.net.link.LinkListener;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Test fixture for the link service.
- */
-public class MockLinkService extends LinkServiceAdapter {
- List<Link> links = new ArrayList<>();
- LinkListener listener;
-
- @Override
- public int getLinkCount() {
- return links.size();
- }
-
- @Override
- public Iterable<Link> getLinks() {
- return links;
- }
-
- @Override
- public void addListener(LinkListener listener) {
- this.listener = listener;
- }
-
- /**
- * Get listener.
- */
- public LinkListener getListener() {
- return listener;
- }
-
- /**
- * Add link.
- *
- * @param link needs to be added to list
- */
- public void addLink(Link link) {
- links.add(link);
- }
-
- /**
- * Delete link.
- *
- * @param link needs to be deleted from list
- */
- public void removeLink(Link link) {
- links.remove(link);
- }
-}
diff --git a/apps/pce/app/src/test/java/org/onosproject/pce/util/PceStoreAdapter.java b/apps/pce/app/src/test/java/org/onosproject/pce/util/PceStoreAdapter.java
deleted file mode 100644
index 79bb214..0000000
--- a/apps/pce/app/src/test/java/org/onosproject/pce/util/PceStoreAdapter.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pce.util;
-
-import com.google.common.collect.ImmutableSet;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.pce.pceservice.ExplicitPathInfo;
-import org.onosproject.pce.pcestore.PcePathInfo;
-import org.onosproject.pce.pcestore.api.PceStore;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Arrays;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Provides test implementation of PceStore.
- */
-public class PceStoreAdapter implements PceStore {
-
- // Mapping tunnel with device local info with tunnel consumer id
-
- // Set of Path info
- private Set<PcePathInfo> failedPathInfoSet = new HashSet<>();
-
- // Locally maintain with tunnel name as key and corresponding list of explicit path object
- private Map<String, List<ExplicitPathInfo>> tunnelNameExplicitPathInfoMap = new HashMap<>();
-
- //Mapping tunnel name with Disjoint paths
- private Map<String, List<TunnelId>> loadBalancingPathNameTunnelIdInfo = new HashMap<>();
-
- @Override
- public boolean existsFailedPathInfo(PcePathInfo pathInfo) {
- return failedPathInfoSet.contains(pathInfo);
- }
-
- @Override
- public int getFailedPathInfoCount() {
- return failedPathInfoSet.size();
- }
-
- @Override
- public Iterable<PcePathInfo> getFailedPathInfos() {
- return ImmutableSet.copyOf(failedPathInfoSet);
- }
-
- @Override
- public void addFailedPathInfo(PcePathInfo pathInfo) {
- failedPathInfoSet.add(pathInfo);
- }
-
- @Override
- public boolean removeFailedPathInfo(PcePathInfo pathInfo) {
- if (failedPathInfoSet.remove(pathInfo)) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean tunnelNameExplicitPathInfoMap(String tunnelName, List<ExplicitPathInfo> explicitPathInfo) {
- tunnelNameExplicitPathInfoMap.put(tunnelName, explicitPathInfo);
- return false;
- }
-
- @Override
- public List<ExplicitPathInfo> getTunnelNameExplicitPathInfoMap(String tunnelName) {
- return tunnelNameExplicitPathInfoMap.get(tunnelName);
- }
-
-/* @Override
- public DisjointPath getDisjointPaths(String tunnelName) {
- if (tunnelNameDisjointPathInfo.get(tunnelName) != null) {
- return tunnelNameDisjointPathInfo.get(tunnelName);
- }
- return null;
- }
-
- @Override
- public boolean addDisjointPathInfo(String tunnelName, DisjointPath path) {
- return tunnelNameDisjointPathInfo.put(tunnelName, path) != null ? true : false;
- }*/
-
- @Override
- public boolean addLoadBalancingTunnelIdsInfo(String loadBalancingPathName, TunnelId... tunnelIds) {
- return loadBalancingPathNameTunnelIdInfo.put(loadBalancingPathName,
- Arrays.asList(tunnelIds)) != null ? true : false;
- }
-
- @Override
- public List<TunnelId> getLoadBalancingTunnelIds(String loadBalancingPathName) {
- if (loadBalancingPathNameTunnelIdInfo.get(loadBalancingPathName) != null) {
- return loadBalancingPathNameTunnelIdInfo.get(loadBalancingPathName);
- }
- return null;
- }
-
- @Override
- public boolean removeLoadBalancingTunnelIdsInfo(String loadBalancingPathName) {
- if (loadBalancingPathNameTunnelIdInfo.remove(loadBalancingPathName) == null) {
- return false;
- }
- return true;
- }
-
-/* @Override
- public boolean removeDisjointPathInfo(String tunnelName) {
- if (tunnelNameDisjointPathInfo.remove(tunnelName) == null) {
- return false;
- }
- return true;
- }*/
-}
diff --git a/apps/pce/bandwidthmgmt/BUILD b/apps/pce/bandwidthmgmt/BUILD
deleted file mode 100644
index 755f9b2..0000000
--- a/apps/pce/bandwidthmgmt/BUILD
+++ /dev/null
@@ -1,16 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + KRYO + [
- "//core/store/serializers:onos-core-serializers",
- "//apps/pcep-api:onos-apps-pcep-api",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
-
-onos_app(
- app_name = "org.onosproject.bandwidthmgmt",
- category = "default",
- description = "PCE Bandwidth Management.",
- title = "PCE Bandwidth Management",
- url = "http://onosproject.org",
-)
diff --git a/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/BandwidthManager.java b/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/BandwidthManager.java
deleted file mode 100644
index a23c16e..0000000
--- a/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/BandwidthManager.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bandwidthmgr;
-
-import org.onosproject.bandwidthmgr.api.BandwidthMgmtService;
-import org.onosproject.bandwidthmgr.api.BandwidthMgmtStore;
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Implementation of PCE service.
- */
-@Component(immediate = true, service = BandwidthMgmtService.class)
-public class BandwidthManager implements BandwidthMgmtService {
- private static final Logger log = LoggerFactory.getLogger(BandwidthManager.class);
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected BandwidthMgmtStore store;
-
- @Activate
- protected void activate() {
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public Double getTeCost(LinkKey linkKey) {
- checkNotNull(linkKey);
- return store.getTeCost(linkKey);
- }
-
- @Override
- public Double getAvailableBandwidth(LinkKey linkKey) {
- checkNotNull(linkKey);
- Set<Double> unResvBw = getUnreservedBw(linkKey);
- Double localReservedBw = getAllocatedLocalReservedBw(linkKey);
- if (unResvBw != null && localReservedBw != null) {
-
- return unResvBw.iterator().next().doubleValue()
- - localReservedBw.doubleValue();
- }
- if (unResvBw != null) {
- return unResvBw.iterator().next().doubleValue();
- } else {
- return null;
- }
- }
-
- @Override
- public boolean allocLocalReservedBw(LinkKey linkKey, Double bandwidth) {
- checkNotNull(linkKey);
- checkNotNull(bandwidth);
- return store.allocLocalReservedBw(linkKey, bandwidth);
- }
-
- @Override
- public boolean releaseLocalReservedBw(LinkKey linkkey, Double bandwidth) {
- checkNotNull(linkkey);
- checkNotNull(bandwidth);
- return store.releaseLocalReservedBw(linkkey, bandwidth);
- }
-
- @Override
- public Double getAllocatedLocalReservedBw(LinkKey linkkey) {
- checkNotNull(linkkey);
- return store.getAllocatedLocalReservedBw(linkkey);
- }
-
- @Override
- public boolean addUnreservedBw(LinkKey linkKey, Set<Double> bandwidth) {
- checkNotNull(linkKey);
- checkNotNull(bandwidth);
- return store.addUnreservedBw(linkKey, bandwidth);
- }
-
- @Override
- public boolean removeUnreservedBw(LinkKey linkkey) {
- checkNotNull(linkkey);
- return store.removeUnreservedBw(linkkey);
- }
-
- @Override
- public Set<Double> getUnreservedBw(LinkKey linkkey) {
- checkNotNull(linkkey);
- return store.getUnreservedBw(linkkey);
- }
-
- @Override
- public boolean isBandwidthAvailable(Link link, Double bandwidth) {
- checkNotNull(link);
- checkNotNull(bandwidth);
-
- LinkKey linkKey = LinkKey.linkKey(link);
- Double localAllocBw = getAllocatedLocalReservedBw(linkKey);
-
- Set<Double> unResvBw = getUnreservedBw(linkKey);
- Double prirZeroBw = unResvBw.iterator().next();
-
- return (bandwidth <= prirZeroBw - (localAllocBw != null ? localAllocBw : 0));
- }
-}
diff --git a/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/DistributedBandwidthMgmtStore.java b/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/DistributedBandwidthMgmtStore.java
deleted file mode 100644
index 50bad95..0000000
--- a/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/DistributedBandwidthMgmtStore.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bandwidthmgr;
-
-import org.onlab.util.KryoNamespace;
-import org.onosproject.bandwidthmgr.api.BandwidthMgmtStore;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.LinkKey;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.pcep.api.TeLinkConfig;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_ADDED;
-import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_REMOVED;
-import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_UPDATED;
-
-/**
- * Manages the pool of available labels to devices, links and tunnels.
- */
-@Component(immediate = true, service = BandwidthMgmtStore.class)
-public class DistributedBandwidthMgmtStore implements BandwidthMgmtStore {
- private static final Logger log = LoggerFactory.getLogger(BandwidthManager.class);
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigService netCfgService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- private InternalConfigListener cfgListener = new InternalConfigListener();
-
- private ConsistentMap<LinkKey, Double> teCost;
- // Locally maintain unreserved bandwidth of each link.
- private ConsistentMap<LinkKey, Set<Double>> unResvBw;
-
- // Mapping tunnel with link key with local reserved bandwidth
- private ConsistentMap<LinkKey, Double> localReservedBw;
-
- private static final Serializer SERIALIZER = Serializer
- .using(new KryoNamespace.Builder().register(KryoNamespaces.API)
- .register(KryoNamespaces.API)
- .register(LinkKey.class)
- .register(ConnectPoint.class)
- .build());
-
- @Activate
- protected void activate() {
- netCfgService.addListener(cfgListener);
-
- localReservedBw = storageService.<LinkKey, Double>consistentMapBuilder()
- .withName("local-reserved-bandwith")
- .withSerializer(SERIALIZER)
- .build();
-
- unResvBw = storageService.<LinkKey, Set<Double>>consistentMapBuilder()
- .withName("onos-unreserved-bandwidth")
- .withSerializer(SERIALIZER)
- .build();
-
- teCost = storageService.<LinkKey, Double>consistentMapBuilder()
- .withName("onos-tecost")
- .withSerializer(SERIALIZER)
- .build();
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- netCfgService.removeListener(cfgListener);
- log.info("Stopped");
- }
-
- @Override
- public Double getTeCost(LinkKey linkKey) {
- if (teCost.get(linkKey) != null) {
- return teCost.get(linkKey).value();
- }
- return null;
- }
-
- @Override
- public boolean allocLocalReservedBw(LinkKey linkkey, Double bandwidth) {
- Double allocatedBw = null;
-
- if (localReservedBw.get(linkkey) != null) {
- allocatedBw = localReservedBw.get(linkkey).value();
- }
- if (allocatedBw != null) {
- localReservedBw.put(linkkey, (allocatedBw + bandwidth));
- } else {
- localReservedBw.put(linkkey, bandwidth);
- }
-
- return true;
- }
-
- @Override
- public boolean releaseLocalReservedBw(LinkKey linkkey, Double bandwidth) {
-
- Double allocatedBw = null;
- if (localReservedBw.get(linkkey) != null) {
- allocatedBw = localReservedBw.get(linkkey).value();
- }
-
- if (allocatedBw == null || allocatedBw < bandwidth) {
- return false;
- }
-
- Double releasedBw = allocatedBw - bandwidth;
- if (releasedBw == 0.0) {
- localReservedBw.remove(linkkey);
- } else {
- localReservedBw.put(linkkey, releasedBw);
- }
- return true;
- }
-
- @Override
- public Double getAllocatedLocalReservedBw(LinkKey linkkey) {
- return localReservedBw.get(linkkey) != null ? localReservedBw.get(linkkey).value() : null;
- }
-
- @Override
- public boolean addUnreservedBw(LinkKey linkkey, Set<Double> bandwidth) {
- unResvBw.put(linkkey, bandwidth);
- return true;
- }
-
- @Override
- public boolean removeUnreservedBw(LinkKey linkkey) {
- unResvBw.remove(linkkey);
- return true;
- }
-
- @Override
- public Set<Double> getUnreservedBw(LinkKey linkkey) {
- checkNotNull(linkkey);
- return unResvBw.get(linkkey) != null ? unResvBw.get(linkkey).value() : null;
- }
-
- private class InternalConfigListener implements NetworkConfigListener {
-
- @Override
- public void event(NetworkConfigEvent event) {
-
- if (event.configClass().equals(TeLinkConfig.class)) {
- if ((event.type() != CONFIG_ADDED) && (event.type() != CONFIG_UPDATED)
- && (event.type() != CONFIG_REMOVED)) {
- return;
- }
- LinkKey linkKey = (LinkKey) event.subject();
- switch (event.type()) {
- case CONFIG_ADDED:
- case CONFIG_UPDATED:
-
- TeLinkConfig cfg = netCfgService.getConfig(linkKey, TeLinkConfig.class);
- if (cfg == null) {
- log.error("Unable to get the configuration of the link.");
- return;
- }
- Set<Double> unresvBw = new LinkedHashSet<>();
- unresvBw.add(cfg.unResvBandwidth());
- addUnreservedBw(linkKey, unresvBw);
-
- if (cfg.teCost() != 0) {
- teCost.put(linkKey, (double) cfg.teCost());
- }
-
- break;
- case CONFIG_REMOVED:
- removeUnreservedBw(linkKey);
- localReservedBw.remove(linkKey);
- teCost.remove(linkKey);
-
- break;
- default:
- break;
- }
- }
- }
- }
-
-}
diff --git a/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/api/BandwidthMgmtService.java b/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/api/BandwidthMgmtService.java
deleted file mode 100644
index b16287c..0000000
--- a/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/api/BandwidthMgmtService.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bandwidthmgr.api;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-
-import java.util.Set;
-
-public interface BandwidthMgmtService {
-
-
- /**
- * Allocate local bandwidth(non rsvp-te) to linkKey mapping.
- *
- * @param linkkey link key of the link
- * @param bandwidth requested local bandwidth
- * @return success or failure
- */
- boolean allocLocalReservedBw(LinkKey linkkey, Double bandwidth);
-
-
- /**
- * Release local bandwidth(non rsvp-te) to linkKey mapping.
- *
- * @param linkkey link key of the link
- * @param bandwidth releasing local bandwidth
- * @return success or failure
- */
- boolean releaseLocalReservedBw(LinkKey linkkey, Double bandwidth);
-
- /**
- * Get local allocated bandwidth of the link.
- *
- * @param linkkey link key of the link
- * @return allocated bandwidth
- */
- Double getAllocatedLocalReservedBw(LinkKey linkkey);
-
- /**
- * Add unreserved bandwidth to linkKey mapping.
- *
- * @param linkkey link key of the link
- * @param bandwidth set of unreserved bandwidth
- * @return success or failure
- */
- boolean addUnreservedBw(LinkKey linkkey, Set<Double> bandwidth);
-
- /**
- * Remove unreserved bandwidth to linkKey mapping.
- *
- * @param linkkey link key of the link
- * @return success or failure
- */
- boolean removeUnreservedBw(LinkKey linkkey);
-
- /**
- * Get list of unreserved Bandwidth of the link.
- *
- * @param linkkey link key of the link
- * @return Set of unreserved bandwidth
- */
- Set<Double> getUnreservedBw(LinkKey linkkey);
-
- /**
- * Returns if the link has the available bandwidth or not.
- *
- * @param link link
- * @param bandwidth required bandwidth
- * @return true if bandwidth is available else false
- */
- boolean isBandwidthAvailable(Link link, Double bandwidth);
-
- /**
- * Returns Te cost for the specified link key.
- *
- * @param linkKey connect point of source and destination of the link
- * @return Te cost for the linkKey
- */
- Double getTeCost(LinkKey linkKey);
-
- /**
- * Returns available bandwidth for the linkKey.
- *
- * @param linkKey connect point of source and destination of the link
- * @return available bandwidth for the linkKey
- */
- Double getAvailableBandwidth(LinkKey linkKey);
-}
diff --git a/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/api/BandwidthMgmtStore.java b/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/api/BandwidthMgmtStore.java
deleted file mode 100644
index 43589c9..0000000
--- a/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/api/BandwidthMgmtStore.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bandwidthmgr.api;
-
-import org.onosproject.net.LinkKey;
-
-import java.util.Set;
-
-/**
- * Abstraction of an entity providing pool of available labels to devices, links and tunnels.
- */
-public interface BandwidthMgmtStore {
-
- /**
- * Allocate local bandwidth(non rsvp-te) to linkKey mapping.
- *
- * @param linkkey link key of the link
- * @param bandwidth requested local bandwidth
- * @return success or failure
- */
- boolean allocLocalReservedBw(LinkKey linkkey, Double bandwidth);
-
-
- /**
- * Release local bandwidth(non rsvp-te) to linkKey mapping.
- *
- * @param linkkey link key of the link
- * @param bandwidth releasing local bandwidth
- * @return success or failure
- */
- boolean releaseLocalReservedBw(LinkKey linkkey, Double bandwidth);
-
- /**
- * Get local allocated bandwidth of the link.
- *
- * @param linkkey link key of the link
- * @return allocated bandwidth
- */
- Double getAllocatedLocalReservedBw(LinkKey linkkey);
-
- /**
- * Add unreserved bandwidth to linkKey mapping.
- *
- * @param linkkey link key of the link
- * @param bandwidth set of unreserved bandwidth
- * @return success or failure
- */
- boolean addUnreservedBw(LinkKey linkkey, Set<Double> bandwidth);
-
- /**
- * Remove unreserved bandwidth to linkKey mapping.
- *
- * @param linkkey link key of the link
- * @return success or failure
- */
- boolean removeUnreservedBw(LinkKey linkkey);
-
- /**
- * Get list of unreserved Bandwidth of the link.
- *
- * @param linkkey link key of the link
- * @return Set of unreserved bandwidth
- */
- Set<Double> getUnreservedBw(LinkKey linkkey);
-
- /**
- * Returns Te cost for the specified link key.
- *
- * @param linkKey connect point of source and destination of the link
- * @return Te cost for the linkKey
- */
- Double getTeCost(LinkKey linkKey);
-}
diff --git a/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/api/package-info.java b/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/api/package-info.java
deleted file mode 100644
index 54b323f..0000000
--- a/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/api/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Bandwidth management service.
- */
-package org.onosproject.bandwidthmgr.api;
diff --git a/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/package-info.java b/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/package-info.java
deleted file mode 100644
index 14fd443..0000000
--- a/apps/pce/bandwidthmgmt/src/main/java/org/onosproject/bandwidthmgr/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCE Bandwidth management service implementation.
- */
-package org.onosproject.bandwidthmgr;
\ No newline at end of file
diff --git a/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/PceCodecRegistrator.java b/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/PceCodecRegistrator.java
deleted file mode 100644
index be8686a..0000000
--- a/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/PceCodecRegistrator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcerest;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onosproject.codec.CodecService;
-import org.onosproject.pce.pceservice.PcePath;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of the json codec brokering service for pce app.
- */
-@Component(immediate = true)
-public class PceCodecRegistrator {
-
- private static Logger log = LoggerFactory.getLogger(PceCodecRegistrator.class);
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CodecService codecService;
-
- @Activate
- public void activate() {
- codecService.registerCodec(PcePath.class, new PcePathCodec());
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-}
diff --git a/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/PcePathCodec.java b/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/PcePathCodec.java
deleted file mode 100644
index 20671f7..0000000
--- a/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/PcePathCodec.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcerest;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.net.Link.State.ACTIVE;
-import static org.onosproject.net.Link.Type.DIRECT;
-
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.NetworkResource;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pce.pceservice.ExplicitPathInfo;
-import org.onosproject.pce.pceservice.PcePath;
-import org.onosproject.pce.pceservice.DefaultPcePath;
-import org.onosproject.pce.pceservice.constraint.CostConstraint;
-import org.onosproject.pce.pceservice.constraint.PceBandwidthConstraint;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.fasterxml.jackson.databind.JsonNode;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * PCE path json codec.
- */
-public final class PcePathCodec extends JsonCodec<PcePath> {
- private final Logger log = LoggerFactory.getLogger(PcePathCodec.class);
- private static final String SOURCE = "source";
- private static final String DESTINATION = "destination";
- private static final String LSP_TYPE = "pathType";
- private static final String SYMBOLIC_PATH_NAME = "name";
- private static final String CONSTRAINT = "constraint";
- private static final String COST = "cost";
- private static final String BANDWIDTH = "bandwidth";
- private static final String PATH_ID = "pathId";
- private static final String EXPLICIT_PATH_INFO = "explicitPathInfo";
- private static final String MISSING_MEMBER_MESSAGE = " member is required in pce-path";
- public static final String JSON_NOT_NULL = "JsonNode can not be null";
- public static final byte SOURCE_DEVICEID_INDEX = 0;
- public static final byte SOURCE_PORTNO_INDEX = 1;
- public static final byte DESTINATION_DEVICEID_INDEX = 2;
- public static final byte DESTINATION_PORTNO_INDEX = 3;
-
- @Override
- public PcePath decode(ObjectNode json, CodecContext context) {
- if (json == null || !json.isObject()) {
- log.error("Empty json input");
- return null;
- }
-
- // build pce-path
- PcePath.Builder resultBuilder = new DefaultPcePath.Builder();
-
- // retrieve source
- JsonNode jNode = json.get(SOURCE);
- if (jNode != null) {
- String src = jNode.asText();
- resultBuilder.source(src);
- }
-
- // retrieve destination
- jNode = json.get(DESTINATION);
- if (jNode != null) {
- String dst = jNode.asText();
- resultBuilder.destination(dst);
- }
-
- // retrieve lsp-type
- jNode = json.get(LSP_TYPE);
- if (jNode != null) {
- String lspType = jNode.asText();
- //Validating LSP type
- int type = Integer.parseInt(lspType);
- if ((type < 0) || (type > 2)) {
- return null;
- }
- resultBuilder.lspType(lspType);
- }
-
- // retrieve symbolic-path-name
- jNode = json.get(SYMBOLIC_PATH_NAME);
- if (jNode != null) {
- String name = jNode.asText();
- resultBuilder.name(name);
- }
-
- // retrieve constraint
- JsonNode constraintJNode = (JsonNode) json.path(CONSTRAINT);
- if ((constraintJNode != null) && (!constraintJNode.isMissingNode())) {
- // retrieve cost
- jNode = constraintJNode.get(COST);
- if (jNode != null) {
- String cost = jNode.asText();
- //Validating Cost type
- int costType = Integer.parseInt(cost);
- if ((costType < 1) || (costType > 2)) {
- return null;
- }
- resultBuilder.costConstraint(cost);
- }
-
- // retrieve bandwidth
- jNode = constraintJNode.get(BANDWIDTH);
- if (jNode != null) {
- String bandwidth = jNode.asText();
- double bw = Double.parseDouble(bandwidth);
- if (bw < 0) {
- return null;
- }
- resultBuilder.bandwidthConstraint(bandwidth);
- }
- }
-
- // Retrieve explicit path info
- JsonNode explicitPathInfo = json.get(EXPLICIT_PATH_INFO);
- if (explicitPathInfo != null) {
- List<ExplicitPathInfo> explicitPathInfoList =
- ImmutableList.copyOf(jsonNodeToExplicitPathInfo(explicitPathInfo));
- if (explicitPathInfoList != null) {
- resultBuilder.explicitPathInfo(explicitPathInfoList);
- }
- }
-
- return resultBuilder.build();
- }
-
- private ExplicitPathInfo createListOfExplicitPathObj(JsonNode node) {
- int explicitPathType = Integer.parseInt(node.get("type").asText());
- DeviceId deviceId;
- PortNumber portNo;
- NetworkResource res;
- LinkedList<ExplicitPathInfo> list = Lists.newLinkedList();
- if ((explicitPathType < 0) || (explicitPathType > 1)) {
- return null;
- }
- ExplicitPathInfo.Type type = ExplicitPathInfo.Type.values()[explicitPathType];
- String subType = node.get("subtype").asText();
- if (Integer.parseInt(subType) == 0) {
- res = DeviceId.deviceId(node.get("value").asText());
- } else if (Integer.parseInt(subType) == 1) {
-
- String[] splitted = node.get("value").asText().split("/");
-
- if (splitted[SOURCE_DEVICEID_INDEX] != null
- && splitted[SOURCE_PORTNO_INDEX] != null
- && splitted[DESTINATION_DEVICEID_INDEX] != null
- && splitted[DESTINATION_PORTNO_INDEX] != null) {
- return null;
- }
- deviceId = DeviceId.deviceId(splitted[SOURCE_DEVICEID_INDEX]);
- portNo = PortNumber.portNumber(splitted[SOURCE_PORTNO_INDEX]);
- ConnectPoint cpSrc = new ConnectPoint(deviceId, portNo);
- deviceId = DeviceId.deviceId(splitted[DESTINATION_DEVICEID_INDEX]);
- portNo = PortNumber.portNumber(splitted[DESTINATION_PORTNO_INDEX]);
- ConnectPoint cpDst = new ConnectPoint(deviceId, portNo);
- res = DefaultLink.builder()
- .providerId(ProviderId.NONE)
- .src(cpSrc)
- .dst(cpDst)
- .type(DIRECT)
- .state(ACTIVE)
- .build();
- } else {
- return null;
- }
-
- return new ExplicitPathInfo(type, res);
- }
-
- private Collection<ExplicitPathInfo> jsonNodeToExplicitPathInfo(JsonNode explicitPathInfo) {
- checkNotNull(explicitPathInfo, JSON_NOT_NULL);
-
- Integer i = 0;
- NetworkResource res;
- LinkedList<ExplicitPathInfo> list = Lists.newLinkedList();
- if (explicitPathInfo.isArray()) {
- for (JsonNode node : explicitPathInfo) {
- ExplicitPathInfo obj = createListOfExplicitPathObj(node);
- if (obj == null) {
- return null;
- }
- list.add(obj);
- }
- } else {
- ExplicitPathInfo obj = createListOfExplicitPathObj(explicitPathInfo);
- if (obj == null) {
- return null;
- }
- list.add(obj);
- }
-
- return Collections.unmodifiableCollection(list);
- }
-
- @Override
- public ObjectNode encode(PcePath path, CodecContext context) {
- checkNotNull(path, "path output cannot be null");
- ObjectNode result = context.mapper()
- .createObjectNode()
- .put(PATH_ID, path.id().id())
- .put(SOURCE, path.source())
- .put(DESTINATION, path.destination())
- .put(LSP_TYPE, path.lspType().type())
- .put(SYMBOLIC_PATH_NAME, path.name());
-
- ObjectNode constraintNode = context.mapper()
- .createObjectNode()
- .put(COST, ((CostConstraint) path.costConstraint()).type().type())
- .put(BANDWIDTH, ((PceBandwidthConstraint) path.bandwidthConstraint()).bandwidth().bps());
-
- if (path.explicitPathInfo() != null && !path.explicitPathInfo().isEmpty()) {
- ArrayNode arrayNode = context.mapper().createArrayNode();
- for (ExplicitPathInfo e : path.explicitPathInfo()) {
- ObjectNode node = context.mapper()
- .createObjectNode()
- .put("type", e.type().toString())
- .put("value", e.value().toString());
- arrayNode.add(node);
- }
- result.set(EXPLICIT_PATH_INFO, arrayNode);
- }
-
- result.set(CONSTRAINT, constraintNode);
- return result;
- }
-}
diff --git a/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/PcePathWebResource.java b/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/PcePathWebResource.java
deleted file mode 100644
index de2e84a..0000000
--- a/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/PcePathWebResource.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcerest;
-
-import static javax.ws.rs.core.Response.Status.OK;
-import static org.onlab.util.Tools.nullIsNotFound;
-import static org.onlab.util.Tools.readTreeFromStream;
-
-import java.util.Collection;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-import java.util.LinkedList;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import com.google.common.collect.ImmutableList;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.pce.pceservice.ExplicitPathInfo;
-import org.onosproject.pce.pceservice.api.PceService;
-import org.onosproject.pce.pceservice.PcePath;
-import org.onosproject.pce.pceservice.DefaultPcePath;
-import org.onosproject.pce.pceservice.LspType;
-import org.onosproject.rest.AbstractWebResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Query and program pce path.
- */
-@Path("path")
-public class PcePathWebResource extends AbstractWebResource {
-
- private final Logger log = LoggerFactory.getLogger(PcePathWebResource.class);
- public static final String PCE_PATH_NOT_FOUND = "Path not found";
- public static final String PCE_PATH_ID_EXIST = "Path exists";
- public static final String PCE_PATH_ID_NOT_EXIST = "Path does not exist for the identifier";
- public static final String PCE_SETUP_PATH_FAILED = "PCE Setup path has failed.";
-
- /**
- * Retrieve details of all paths created.
- *
- * @return 200 OK
- */
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response queryAllPath() {
- log.debug("Query all paths.");
- PceService pceService = get(PceService.class);
- Iterable<Tunnel> tunnels = pceService.queryAllPath();
-
- ObjectNode result = mapper().createObjectNode();
- ArrayNode pathEntry = result.putArray("paths");
- if (tunnels != null) {
- for (final Tunnel tunnel : tunnels) {
- PcePath path = DefaultPcePath.builder().of(tunnel, pceService.explicitPathInfoList(tunnel
- .tunnelName().value()))
- .build();
- pathEntry.add(codec(PcePath.class).encode(path, this));
- }
- }
- return ok(result.toString()).build();
- }
-
- /**
- * Retrieve details of a specified path id.
- *
- * @param id path id
- * @return 200 OK, 404 if given identifier does not exist
- */
- @GET
- @Path("{path_id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response queryPath(@PathParam("path_id") String id) {
- log.debug("Query path by identifier {}.", id);
- PceService pceService = get(PceService.class);
-
- Tunnel tunnel = nullIsNotFound(pceService.queryPath(TunnelId.valueOf(id)),
- PCE_PATH_NOT_FOUND);
- PcePath path = DefaultPcePath.builder().of(tunnel, pceService.explicitPathInfoList(tunnel
- .tunnelName().value())).build();
- if (path == null) {
- return Response.status(OK).entity(PCE_SETUP_PATH_FAILED).build();
- }
- ObjectNode result = mapper().createObjectNode();
- result.set("path", codec(PcePath.class).encode(path, this));
- return ok(result.toString()).build();
- }
-
- /**
- * Creates a new path.
- *
- * @param stream pce path from json
- * @return status of the request
- */
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response setupPath(InputStream stream) {
- log.debug("Setup path.");
- try {
- ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
- JsonNode port = jsonTree.get("path");
- TunnelService tunnelService = get(TunnelService.class);
- PcePath path = codec(PcePath.class).decode((ObjectNode) port, this);
- if (path == null) {
- return Response.status(OK).entity(PCE_SETUP_PATH_FAILED).build();
- }
-
- //Validating tunnel name, duplicated tunnel names not allowed
- Collection<Tunnel> existingTunnels = tunnelService.queryTunnel(Tunnel.Type.MPLS);
- if (existingTunnels != null) {
- for (Tunnel t : existingTunnels) {
- if (t.tunnelName().toString().equals(path.name())) {
- return Response.status(OK).entity(PCE_SETUP_PATH_FAILED).build();
- }
- }
- }
-
- DeviceId srcDevice = DeviceId.deviceId(path.source());
- DeviceId dstDevice = DeviceId.deviceId(path.destination());
- LspType lspType = path.lspType();
- List<Constraint> listConstrnt = new LinkedList<Constraint>();
-
- // Add bandwidth
- listConstrnt.add(path.bandwidthConstraint());
-
- // Add cost
- listConstrnt.add(path.costConstraint());
-
- List<ExplicitPathInfo> explicitPathInfoList = null;
- if (path.explicitPathInfo() != null) {
- explicitPathInfoList = ImmutableList.copyOf(path.explicitPathInfo());
- }
-
- Boolean issuccess = nullIsNotFound(get(PceService.class)
- .setupPath(srcDevice, dstDevice, path.name(), listConstrnt,
- lspType, explicitPathInfoList),
- PCE_SETUP_PATH_FAILED);
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (IOException e) {
- log.error("Exception while creating path {}.", e.toString());
- throw new IllegalArgumentException(e);
- }
- }
-
- /**
- * Update details of a specified path id.
- *
- * @param id path id
- * @param stream pce path from json
- * @return 200 OK, 404 if given identifier does not exist
- */
- @PUT
- @Path("{path_id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updatePath(@PathParam("path_id") String id,
- final InputStream stream) {
- log.debug("Update path by identifier {}.", id);
- try {
- ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
- JsonNode pathNode = jsonTree.get("path");
- PcePath path = codec(PcePath.class).decode((ObjectNode) pathNode, this);
- if (path == null) {
- return Response.status(OK).entity(PCE_SETUP_PATH_FAILED).build();
- }
- List<Constraint> constrntList = new LinkedList<Constraint>();
- // Assign bandwidth
- if (path.bandwidthConstraint() != null) {
- constrntList.add(path.bandwidthConstraint());
- }
-
- // Assign cost
- if (path.costConstraint() != null) {
- constrntList.add(path.costConstraint());
- }
-
- Boolean result = nullIsNotFound(get(PceService.class).updatePath(TunnelId.valueOf(id), constrntList),
- PCE_PATH_NOT_FOUND);
- return Response.status(OK).entity(result.toString()).build();
- } catch (IOException e) {
- log.error("Update path failed because of exception {}.", e.toString());
- throw new IllegalArgumentException(e);
- }
- }
-
- /**
- * Release a specified path.
- *
- * @param id path id
- * @return 200 OK, 404 if given identifier does not exist
- */
- @DELETE
- @Path("{path_id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response releasePath(@PathParam("path_id") String id) {
- log.debug("Deletes path by identifier {}.", id);
-
- Boolean isSuccess = nullIsNotFound(get(PceService.class).releasePath(TunnelId.valueOf(id)),
- PCE_PATH_NOT_FOUND);
- if (!isSuccess) {
- log.debug("Path identifier {} does not exist", id);
- }
-
- return Response.status(OK).entity(isSuccess.toString()).build();
- }
-}
diff --git a/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/PceWebApplication.java b/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/PceWebApplication.java
deleted file mode 100644
index 3413880..0000000
--- a/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/PceWebApplication.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcerest;
-
-import org.onlab.rest.AbstractWebApplication;
-
-import java.util.Set;
-
-/**
- * PCE rest api web application.
- */
-public class PceWebApplication extends AbstractWebApplication {
- @Override
- public Set<Class<?>> getClasses() {
- return getClasses(PcePathWebResource.class);
- }
-}
-
diff --git a/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/package-info.java b/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/package-info.java
deleted file mode 100644
index 95c5198..0000000
--- a/apps/pce/pcerest/src/main/java/org/onosproject/pcerest/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCE rest application.
- */
-
-package org.onosproject.pcerest;
diff --git a/apps/pce/pcerest/src/main/resources/WEB-INF/web.xml b/apps/pce/pcerest/src/main/resources/WEB-INF/web.xml
deleted file mode 100644
index 388044a..0000000
--- a/apps/pce/pcerest/src/main/resources/WEB-INF/web.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright 2016-present Open Networking Foundation
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- id="ONOS" version="2.5">
- <display-name>PCE REST API v1.0</display-name>
-
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>Secured</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>admin</role-name>
- <role-name>viewer</role-name>
- </auth-constraint>
- </security-constraint>
-
- <security-role>
- <role-name>admin</role-name>
- <role-name>viewer</role-name>
- </security-role>
-
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>karaf</realm-name>
- </login-config>
-
- <servlet>
- <servlet-name>JAX-RS Service</servlet-name>
- <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
- <init-param>
- <param-name>javax.ws.rs.Application</param-name>
- <param-value>org.onosproject.pcerest.PceWebApplication</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>JAX-RS Service</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-</web-app>
diff --git a/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/MockPceCodecContext.java b/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/MockPceCodecContext.java
deleted file mode 100644
index 3c2ae24..0000000
--- a/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/MockPceCodecContext.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcerest;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.CodecService;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.codec.impl.CodecManager;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * Mock codec context for use in codec unit tests.
- */
-public class MockPceCodecContext implements CodecContext {
-
- private final ObjectMapper mapper = new ObjectMapper();
- private final CodecManager codecManager = new CodecManager();
- private final PceCodecRegistrator manager = new PceCodecRegistrator();
-
- /**
- * Constructs a new mock codec context.
- */
- public MockPceCodecContext() {
- codecManager.activate();
- manager.codecService = codecManager;
- manager.activate();
- }
-
- @Override
- public ObjectMapper mapper() {
- return mapper;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getService(Class<T> serviceClass) {
- return null;
- }
-
- @Override
- public <T> JsonCodec<T> codec(Class<T> entityClass) {
- return codecManager.getCodec(entityClass);
- }
-
- /**
- * Get the codec manager.
- *
- * @return instance of codec manager
- */
- public CodecService codecManager() {
- return codecManager;
- }
-}
diff --git a/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/PcePathCodecTest.java b/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/PcePathCodecTest.java
deleted file mode 100644
index 3826172..0000000
--- a/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/PcePathCodecTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcerest;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import org.onlab.util.DataRateUnit;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.pce.pceservice.PcePath;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.pce.pceservice.constraint.CostConstraint;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onosproject.pce.pceservice.constraint.PceBandwidthConstraint;
-
-/**
- * PCE path codec unit tests.
- */
-public class PcePathCodecTest {
-
- MockPceCodecContext context;
- JsonCodec<PcePath> pcePathCodec;
- /**
- * Sets up for each test. Creates a context and fetches the PCE path codec.
- */
- @Before
- public void setUp() {
- context = new MockPceCodecContext();
- pcePathCodec = context.codec(PcePath.class);
- assertThat(pcePathCodec, notNullValue());
- }
-
- /**
- * Reads in a pce-path from the given resource and decodes it.
- *
- * @param resourceName resource to use to read the json for the pce-path
- * @return decoded pce-path
- * @throws IOException if processing the resource fails
- */
- private PcePath getPcePath(String resourceName) throws IOException {
- InputStream jsonStream = PcePathCodecTest.class
- .getResourceAsStream(resourceName);
- ObjectMapper mapper = new ObjectMapper();
- JsonNode json = mapper.readTree(jsonStream);
- assertThat(json, notNullValue());
- PcePath pcePath = pcePathCodec.decode((ObjectNode) json, context);
- assertThat(pcePath, notNullValue());
- return pcePath;
- }
-
- /**
- * Checks that a simple pce-path is decoded properly.
- *
- * @throws IOException if the resource cannot be processed
- */
- @Test
- public void codecPcePathTest() throws IOException {
-
- PcePath pcePath = getPcePath("pcePath.json");
-
- assertThat(pcePath, notNullValue());
-
- assertThat(pcePath.source().toString(), is("11.0.0.1"));
- assertThat(pcePath.destination(), is("11.0.0.2"));
- assertThat(pcePath.lspType().toString(), is("WITHOUT_SIGNALLING_AND_WITHOUT_SR"));
- // testing cost type
- String cost = "2";
- Constraint costConstraint = CostConstraint.of(CostConstraint.Type.values()[Integer.valueOf(cost) - 1]);
- assertThat(pcePath.costConstraint(), is(costConstraint));
- // testing bandwidth
- String bandwidth = "200";
- Constraint bandwidthConstraint = PceBandwidthConstraint.of(Double.valueOf(bandwidth), DataRateUnit
- .valueOf("BPS"));
- assertThat(pcePath.bandwidthConstraint(), is(bandwidthConstraint));
- }
-}
diff --git a/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/PcePathResourceTest.java b/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/PcePathResourceTest.java
deleted file mode 100644
index 1e35395..0000000
--- a/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/PcePathResourceTest.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcerest;
-
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-import static org.onosproject.net.Link.Type.DIRECT;
-
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonObject;
-
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.NotFoundException;
-
-import com.google.common.collect.Lists;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.graph.ScalarWeight;
-import org.onlab.junit.TestUtils;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.packet.IpAddress;
-import org.onlab.rest.BaseResource;
-import org.onosproject.codec.CodecService;
-// import org.onosproject.core.DefaultGroupId;
-import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.DefaultPath;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.pce.pceservice.ExplicitPathInfo;
-import org.onosproject.pce.pceservice.api.PceService;
-import org.onosproject.pce.pceservice.PcepAnnotationKeys;
-import org.onosproject.pce.pcestore.api.PceStore;
-import org.onosproject.net.Path;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.provider.ProviderId;
-
-/**
- * Unit tests for pce path REST APIs.
- */
-public class PcePathResourceTest extends PceResourceTest {
- private final PceService pceService = createMock(PceService.class);
- private final PceStore pceStore = createMock(PceStore.class);
- private final TunnelService tunnelService = createMock(TunnelService.class);
- private final TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423));
- private final TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421));
- // private final DefaultGroupId groupId = new DefaultGroupId(92034);
- private final TunnelName tunnelName = TunnelName.tunnelName("TunnelName");
- private final TunnelId tunnelId = TunnelId.valueOf("41654654");
- private final ProviderId producerName = new ProviderId("producer1", "13");
- private Path path;
- private Tunnel tunnel;
- private List<ExplicitPathInfo> explicitPathInfoList;
- private DeviceId deviceId1;
- private DeviceId deviceId2;
- private DeviceId deviceId3;
- private DeviceId deviceId4;
- private DeviceId deviceId5;
- private PortNumber port1;
- private PortNumber port2;
- private PortNumber port3;
- private PortNumber port4;
- private PortNumber port5;
-
- /**
- * Sets up the global values for all the tests.
- */
- @Before
- public void setUpTest() {
- // Mock environment setup
- MockPceCodecContext context = new MockPceCodecContext();
- ServiceDirectory testDirectory = new TestServiceDirectory().add(PceService.class, pceService)
- .add(TunnelService.class, tunnelService)
- .add(PceStore.class, pceStore)
- .add(CodecService.class, context.codecManager());
- TestUtils.setField(BaseResource.class, "services", testDirectory);
-
- // Tunnel creation
- // Links
- ProviderId providerId = new ProviderId("of", "foo");
- deviceId1 = DeviceId.deviceId("of:A");
- deviceId2 = DeviceId.deviceId("of:B");
- deviceId3 = DeviceId.deviceId("of:C");
- deviceId4 = DeviceId.deviceId("of:D");
- deviceId5 = DeviceId.deviceId("of:E");
- port1 = PortNumber.portNumber(1);
- port2 = PortNumber.portNumber(2);
- port3 = PortNumber.portNumber(3);
- port4 = PortNumber.portNumber(4);
- port5 = PortNumber.portNumber(5);
- List<Link> linkList = new LinkedList<>();
-
- Link l1 = DefaultLink.builder()
- .providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key1", "yahoo").build())
- .src(new ConnectPoint(deviceId1, port1))
- .dst(new ConnectPoint(deviceId2, port2))
- .type(DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- linkList.add(l1);
- Link l2 = DefaultLink.builder()
- .providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key2", "yahoo").build())
- .src(new ConnectPoint(deviceId2, port2))
- .dst(new ConnectPoint(deviceId3, port3))
- .type(DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- linkList.add(l2);
- Link l3 = DefaultLink.builder()
- .providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key3", "yahoo").build())
- .src(new ConnectPoint(deviceId3, port3))
- .dst(new ConnectPoint(deviceId4, port4))
- .type(DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- linkList.add(l3);
- Link l4 = DefaultLink.builder()
- .providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key4", "yahoo").build())
- .src(new ConnectPoint(deviceId4, port4))
- .dst(new ConnectPoint(deviceId5, port5))
- .type(DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- linkList.add(l4);
-
- // Path
- path = new DefaultPath(providerId, linkList, ScalarWeight.toWeight(10));
-
- // Annotations
- DefaultAnnotations.Builder builderAnn = DefaultAnnotations.builder();
- builderAnn.set(PcepAnnotationKeys.LSP_SIG_TYPE, "WITH_SIGNALLING");
- builderAnn.set(PcepAnnotationKeys.COST_TYPE, "COST");
- builderAnn.set(PcepAnnotationKeys.BANDWIDTH, "200");
-
- // Tunnel
- tunnel = new DefaultTunnel(producerName, src, dst, Tunnel.Type.VXLAN,
- Tunnel.State.ACTIVE, null, tunnelId,
- tunnelName, path, builderAnn.build());
-
- explicitPathInfoList = Lists.newLinkedList();
- ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, deviceId2);
- explicitPathInfoList.add(obj);
-
- }
-
- /**
- * Cleans up.
- */
- @After
- public void tearDownTest() {
- }
-
- /**
- * Tests the result of the rest api GET when there are no pce paths.
- */
- @Test
- public void testPcePathsEmpty() {
- expect(pceService.queryAllPath())
- .andReturn(null)
- .anyTimes();
- replay(pceService);
- WebTarget wt = target();
- String response = wt.path("path").request().get(String.class);
- assertThat(response, is("{\"paths\":[]}"));
- }
-
- /**
- * Tests the result of a rest api GET for pce path id.
- */
- @Test
- public void testGetTunnelId() {
- expect(pceService.queryPath(anyObject()))
- .andReturn(tunnel)
- .anyTimes();
-
- expect(pceService.explicitPathInfoList(tunnel.tunnelName().value()))
- .andReturn(explicitPathInfoList)
- .anyTimes();
- replay(pceService);
-
- WebTarget wt = target();
- String response = wt.path("path/1").request().get(String.class);
- JsonObject result = Json.parse(response).asObject();
- assertThat(result, notNullValue());
- }
-
- /**
- * Tests that a fetch of a non-existent pce path object throws an exception.
- */
- @Test
- public void testBadGet() {
- expect(pceService.queryPath(anyObject()))
- .andReturn(null)
- .anyTimes();
- replay(pceService);
-
- WebTarget wt = target();
- try {
- wt.path("path/1").request().get(String.class);
- fail("Fetch of non-existent pce path did not throw an exception");
- } catch (NotFoundException ex) {
- assertThat(ex.getMessage(), containsString("HTTP 404 Not Found"));
- }
- }
-
- /**
- * Tests creating a pce path with POST.
- */
- @Test
- public void testPost() {
- expect(pceService.setupPath(anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject()))
- .andReturn(true)
- .anyTimes();
- replay(pceService);
-
- WebTarget wt = target();
- InputStream jsonStream = PcePathResourceTest.class.getResourceAsStream("post-PcePath.json");
-
- Response response = wt.path("path")
- .request(MediaType.APPLICATION_JSON_TYPE)
- .post(Entity.json(jsonStream));
- assertThat(response.getStatus(), is(HttpURLConnection.HTTP_OK));
- }
-
- /**
- * Tests creating a pce path with PUT.
- */
- @Test
- public void testPut() {
- expect(pceService.updatePath(anyObject(), anyObject()))
- .andReturn(true)
- .anyTimes();
- replay(pceService);
-
- WebTarget wt = target();
- InputStream jsonStream = PcePathResourceTest.class.getResourceAsStream("post-PcePath.json");
-
- Response response = wt.path("path/1")
- .request(MediaType.APPLICATION_JSON_TYPE)
- .put(Entity.json(jsonStream));
- assertThat(response.getStatus(), is(HttpURLConnection.HTTP_OK));
- }
-
- /**
- * Tests deleting a pce path.
- */
- @Test
- public void testDelete() {
- expect(pceService.releasePath(TunnelId.valueOf("1")))
- .andReturn(true)
- .anyTimes();
- replay(pceService);
-
- WebTarget wt = target();
-
- String location = "path/1";
-
- Response deleteResponse = wt.path(location)
- .request(MediaType.APPLICATION_JSON_TYPE)
- .delete();
- assertThat(deleteResponse.getStatus(), is(HttpURLConnection.HTTP_OK));
- }
-}
diff --git a/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/PceResourceTest.java b/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/PceResourceTest.java
deleted file mode 100644
index a24c874..0000000
--- a/apps/pce/pcerest/src/test/java/org/onosproject/pcerest/PceResourceTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcerest;
-
-import org.glassfish.jersey.server.ResourceConfig;
-import org.glassfish.jersey.test.JerseyTest;
-import org.glassfish.jersey.test.TestProperties;
-import org.onlab.rest.AuthorizationFilter;
-
-/**
- * Base class for pce rest api tests. Performs common configuration operations.
- */
-public class PceResourceTest extends JerseyTest {
-
- /**
- * Creates a new web-resource test.
- */
- public PceResourceTest() {
- super(ResourceConfig.forApplicationClass(PceWebApplication.class));
- AuthorizationFilter.disableForTests();
- set(TestProperties.CONTAINER_PORT, 0);
- }
-}
diff --git a/apps/pce/pcerest/src/test/resources/org/onosproject/pcerest/pcePath.json b/apps/pce/pcerest/src/test/resources/org/onosproject/pcerest/pcePath.json
deleted file mode 100644
index a68c4d7..0000000
--- a/apps/pce/pcerest/src/test/resources/org/onosproject/pcerest/pcePath.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "source":"11.0.0.1",
- "destination":"11.0.0.2",
- "pathType":"2",
- "name":"pcc2",
- "description":"path-create",
- "constraint":
- { "cost":2,
- "bandwidth":200.0
- },
- "explicitPathInfo" :
- {"type":1,
- "subtype":0,
- "value":"11.0.0.2"
- }
-}
diff --git a/apps/pce/pcerest/src/test/resources/org/onosproject/pcerest/post-PcePath.json b/apps/pce/pcerest/src/test/resources/org/onosproject/pcerest/post-PcePath.json
deleted file mode 100644
index 479e4f1..0000000
--- a/apps/pce/pcerest/src/test/resources/org/onosproject/pcerest/post-PcePath.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{"path": {"source":"11.0.0.1",
- "destination":"11.0.0.2",
- "pathType":"0",
- "name":"rsvp11",
- "constraint":
- {"cost":1,
- "bandwidth":300
- },
- "explicitPathInfo" :
- {"type":1,
- "subtype":0,
- "value":"11.0.0.2"
- }
- }
-}
diff --git a/apps/pce/pceweb/BUILD b/apps/pce/pceweb/BUILD
deleted file mode 100644
index 30f067c..0000000
--- a/apps/pce/pceweb/BUILD
+++ /dev/null
@@ -1,15 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + JACKSON + CLI + [
- "//apps/pce/app:onos-apps-pce-app",
- "//apps/tunnel/api:onos-apps-tunnel-api",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
-
-onos_app(
- category = "Utility",
- description = "Allows the user to visualize different types of paths between network entities",
- title = "PCE REST API",
- url = "http://onosproject.org",
-)
diff --git a/apps/pce/pceweb/app.png b/apps/pce/pceweb/app.png
deleted file mode 100644
index abe34eb..0000000
--- a/apps/pce/pceweb/app.png
+++ /dev/null
Binary files differ
diff --git a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebLink.java b/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebLink.java
deleted file mode 100644
index 16a1212..0000000
--- a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebLink.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pceweb;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-import org.onosproject.ui.topo.BiLink;
-import org.onosproject.ui.topo.LinkHighlight;
-import org.onosproject.ui.topo.LinkHighlight.Flavor;
-
-import java.util.Set;
-
-/**
- * Provides the link color highlight mechanism for given links.
- */
-public class PceWebLink extends BiLink {
-
- private boolean primary;
- private boolean secondary;
-
- /**
- * Initialize the Link and key attributes.
- * @param key the link key identifier
- * @param link the link to be highlighted.
- */
- public PceWebLink(LinkKey key, Link link) {
- super(key, link);
- }
-
- /**
- * Highlight the color of given selected links.
- * @param selectedLinks the primary links
- * @param allLinks the secondary links
- */
- public void computeHilight(Set<Link> selectedLinks, Set<Link> allLinks) {
- primary = selectedLinks.contains(this.one()) ||
- (two() != null && selectedLinks.contains(two()));
- secondary = allLinks.contains(this.one()) ||
- (two() != null && allLinks.contains(two()));
- }
-
- @Override
- public LinkHighlight highlight(Enum<?> anEnum) {
- Flavor flavor = primary ? Flavor.PRIMARY_HIGHLIGHT :
- (secondary ? Flavor.SECONDARY_HIGHLIGHT : Flavor.NO_HIGHLIGHT);
- return new LinkHighlight(this.linkId(), flavor);
- }
-}
diff --git a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebLinkMap.java b/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebLinkMap.java
deleted file mode 100644
index a78de1b..0000000
--- a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebLinkMap.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pceweb;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-import org.onosproject.ui.topo.BiLinkMap;
-
-/**
- * Our concrete link map.
- */
-public class PceWebLinkMap extends BiLinkMap<PceWebLink> {
-
- @Override
- protected PceWebLink create(LinkKey linkKey, Link link) {
- return new PceWebLink(linkKey, link);
- }
-}
diff --git a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovComponent.java b/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovComponent.java
deleted file mode 100644
index a98e8b0..0000000
--- a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovComponent.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pceweb;
-
-import com.google.common.collect.ImmutableList;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onosproject.ui.UiExtension;
-import org.onosproject.ui.UiExtensionService;
-import org.onosproject.ui.UiMessageHandlerFactory;
-import org.onosproject.ui.UiTopoOverlayFactory;
-import org.onosproject.ui.UiView;
-import org.onosproject.ui.UiViewHidden;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-/**
- * Skeletal ONOS UI Topology-Overlay application component.
- */
-@Component(immediate = true)
-public class PceWebTopovComponent {
-
- private static final ClassLoader CL = PceWebTopovComponent.class.getClassLoader();
- private static final String VIEW_ID = "pcewebTopov";
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected UiExtensionService uiExtensionService;
-
- // List of application views
- private final List<UiView> uiViews = ImmutableList.of(
- new UiViewHidden(VIEW_ID)
- );
-
- // Factory for UI message handlers
- private final UiMessageHandlerFactory messageHandlerFactory =
- () -> ImmutableList.of(
- new PceWebTopovMessageHandler()
- );
-
- // Factory for UI topology overlays
- private final UiTopoOverlayFactory topoOverlayFactory =
- () -> ImmutableList.of(
- new PceWebTopovOverlay()
- );
-
- // Application UI extension
- protected UiExtension extension =
- new UiExtension.Builder(CL, uiViews)
- .resourcePath(VIEW_ID)
- .messageHandlerFactory(messageHandlerFactory)
- .topoOverlayFactory(topoOverlayFactory)
- .build();
-
- @Activate
- protected void activate() {
- uiExtensionService.register(extension);
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- uiExtensionService.unregister(extension);
- log.info("Stopped");
- }
-
-}
diff --git a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovMessageHandler.java b/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovMessageHandler.java
deleted file mode 100644
index 4306f61..0000000
--- a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovMessageHandler.java
+++ /dev/null
@@ -1,860 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pceweb;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.packet.IpAddress;
-import org.onlab.util.DataRateUnit;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelEvent;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelListener;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.ElementId;
-import org.onosproject.net.HostId;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.topology.TopologyService;
-import org.onosproject.pce.pceservice.LspType;
-import org.onosproject.pce.pceservice.api.PceService;
-import org.onosproject.pce.pceservice.constraint.CostConstraint;
-import org.onosproject.pce.pceservice.constraint.PceBandwidthConstraint;
-import org.onosproject.ui.RequestHandler;
-import org.onosproject.ui.UiConnection;
-import org.onosproject.ui.UiMessageHandler;
-import org.onosproject.ui.topo.DeviceHighlight;
-import org.onosproject.ui.topo.Highlights;
-import org.onosproject.ui.topo.LinkHighlight;
-import org.onosproject.ui.topo.Mod;
-import org.onosproject.ui.topo.NodeBadge;
-import org.onosproject.ui.topo.TopoJson;
-import org.onosproject.ui.topo.TopoUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import static org.onosproject.incubator.net.tunnel.Tunnel.State.ACTIVE;
-import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS;
-import static org.onosproject.ui.topo.LinkHighlight.Flavor.PRIMARY_HIGHLIGHT;
-import static org.onosproject.ui.topo.TopoJson.highlightsMessage;
-
-/**
- * ONOS UI PCE WEB Topology-Overlay message handler.
- */
-public class PceWebTopovMessageHandler extends UiMessageHandler {
-
- private static final String PCEWEB_CLEAR = "pceTopovClear";
- private static final String PCEWEB_SET_PATH = "pceTopovSetMode";
- private static final String PCEWEB_UPDATE_PATH_QUERY = "pceTopovUpdateQuery";
- private static final String PCEWEB_UPDATE_PATH = "pceTopovUpdate";
- private static final String PCEWEB_REMOVE_PATH_QUERY = "pceTopovRemQuery";
- private static final String PCEWEB_REMOVE_PATH = "pceTopovRem";
- private static final String PCEWEB_QUERY_TUNNELS = "pceTopovTunnelDisplay";
- private static final String PCEWEB_SHOW_TUNNEL = "pceTopovShowTunnels";
- private static final String PCEWEB_SHOW_TUNNEL_REMOVE = "pceTopovShowTunnelsRem";
- private static final String PCEWEB_TUNNEL_UPDATE_INFO = "updatePathmsgInfo";
- private static final String PCEWEB_TUNNEL_UPDATE_INFO_REPLY = "pceTopovShowTunnelsUpdate";
- private static final String PCEWEB_TUNNEL_QUERY_INFO = "pceTopovShowTunnelsQuery";
- private static final String PCEWEB_TUNNEL_QUERY_INFO_SHOW = "pceTopovshowTunnelHighlightMsg";
- private static final String DST = "DST";
- private static final String SRC = "SRC";
- private static final String BANDWIDTH = "bw";
- private static final String LOADBALANCING = "lb";
- private static final String BANDWIDTHTYPE = "bwtype";
- private static final String COSTTYPE = "ctype";
- private static final String LSPTYPE = "lsptype";
- private static final String SRCID = "srid";
- private static final String DSTID = "dsid";
- private static final String TUNNEL_ID = "tunnelid";
- private static final String TUNNEL_NAME = "tunnelname";
- private static final String COST_TYPE_IGP = "igp";
- private static final String COST_TYPE_TE = "te";
- private static final String BANDWIDTH_TYPE_KBPS = "kbps";
- private static final String BANDWIDTH_TYPE_MBPS = "mbps";
- private static final String BUFFER_ARRAY = "a";
- private static final String BANDWIDTH_BPS = "BPS";
- private static final String LSP_TYPE_CR = "cr";
- private static final String LSP_TYPE_SRBE = "srbe";
- private static final String LSP_TYPE_SRTE = "srte";
- private static final String STRING_NULL = "null";
- // Delay for showHighlights event processing on GUI client side to
- // account for addLink animation.
- private static final int DELAY_MS = 1_100;
- private static final double BANDWIDTH_KBPS = 1_000;
- private static final double BANDWIDTH_MBPS = 1_000_000;
- private static final String[] LINK_COLOR = {
- "pCol1", "pCol2", "pCol3", "pCol4", "pCol5",
- "pCol6", "pCol7", "pCol8", "pCol9", "pCol10",
- "pCol11", "pCol12", "pCol13", "pCol14", "pCol15"
- };
-
- private static final int LINK_COLOR_MAX = LINK_COLOR.length;
-
- private Set<Link> allPathLinks;
- private ElementId src, dst;
- private List<Path> paths = new LinkedList<>();
- private int pathIndex;
-
- private final Logger log = LoggerFactory.getLogger(getClass());
- private final TunnelListener tunnelListener = new InnerPceWebTunnelListener();
-
- protected TopologyService topologyService;
- protected TunnelService tunnelService;
- protected PceService pceService;
- protected DeviceService deviceService;
-
- @Override
- public void init(UiConnection connection, ServiceDirectory directory) {
- super.init(connection, directory);
- tunnelService = directory.get(TunnelService.class);
- pceService = directory.get(PceService.class);
- deviceService = directory.get(DeviceService.class);
- tunnelService.addListener(tunnelListener);
- }
-
- @Override
- protected Collection<RequestHandler> createRequestHandlers() {
- return ImmutableSet.of(
- new ClearHandler(),
- new SetPathHandler(),
- new UpdatePathQueryHandler(),
- new UpdatePathHandler(),
- new RemovePathQueryHandler(),
- new RemovePathHandler(),
- new UpdatePathInfoHandler(),
- new ShowTunnelHandler(),
- new ShowTunnelHighlight());
- }
-
- @Override
- public void destroy() {
- tunnelService.removeListener(tunnelListener);
- super.destroy();
- }
-
- // Handler classes
-
- /**
- * Handles the 'clear' event received from the client.
- */
- private final class ClearHandler extends RequestHandler {
-
- public ClearHandler() {
- super(PCEWEB_CLEAR);
- }
-
- @Override
- public void process(ObjectNode payload) {
- src = null;
- dst = null;
- sendMessage(highlightsMessage(new Highlights()));
- }
- }
-
- /**
- * Handles the 'path calculation' event received from the client.
- */
- private final class SetPathHandler extends RequestHandler {
-
- public SetPathHandler() {
- super(PCEWEB_SET_PATH);
- }
-
- @Override
- public void process(ObjectNode payload) {
- String srcId = string(payload, SRCID);
- src = elementId(srcId);
- String dstId = string(payload, DSTID);
- dst = elementId(dstId);
- if (src.equals(dst)) {
- src = null;
- }
-
- String bandWidth = string(payload, BANDWIDTH);
- String bandWidthType = string(payload, BANDWIDTHTYPE);
- String costType = string(payload, COSTTYPE);
- String loadBalancing = string(payload, LOADBALANCING);
- String lspType = string(payload, LSPTYPE);
- String tunnelName = string(payload, TUNNEL_NAME);
-
- if (tunnelName == null || tunnelName.equals(STRING_NULL)) {
- log.error("tunnel name should not be empty");
- return;
- }
- //Validating tunnel name, duplicated tunnel names not allowed
- Collection<Tunnel> existingTunnels = tunnelService.queryTunnel(Tunnel.Type.MPLS);
- if (existingTunnels != null) {
- for (Tunnel t : existingTunnels) {
- if (t.tunnelName().toString().equals(tunnelName)) {
- log.error("Path creation failed, Tunnel name already exists");
- return;
- }
- }
- }
-
- if (pceService == null) {
- log.error("PCE service is not active");
- return;
- }
-
- if (lspType == null || lspType.equals(STRING_NULL)) {
- log.error("PCE setup path is failed as LSP type is mandatory");
- }
-
- if ((src != null) && (dst != null)) {
- findAndSendPaths(src, dst, bandWidth, bandWidthType, costType, lspType, tunnelName, loadBalancing);
- }
- }
- }
-
- /**
- * Handles the 'update path query' event received from the client.
- */
- private final class UpdatePathQueryHandler extends RequestHandler {
-
- public UpdatePathQueryHandler() {
- super(PCEWEB_UPDATE_PATH_QUERY);
- }
-
- @Override
- public void process(ObjectNode payload) {
- String srcId = string(payload, SRCID);
- ElementId src = elementId(srcId);
- String dstId = string(payload, DSTID);
- ElementId dst = elementId(dstId);
- Device srcDevice = deviceService.getDevice((DeviceId) src);
- Device dstDevice = deviceService.getDevice((DeviceId) dst);
-
- TunnelEndPoint tunSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(srcDevice.annotations().value("lsrId")));
- TunnelEndPoint tunDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(dstDevice.annotations().value("lsrId")));
-
- Collection<Tunnel> tunnelSet = tunnelService.queryTunnel(tunSrc, tunDst);
- ObjectNode result = objectNode();
- ArrayNode arrayNode = arrayNode();
- for (Tunnel tunnel : tunnelSet) {
- if (tunnel.type() == MPLS) {
- if (tunnel.state().equals(ACTIVE)) {
- arrayNode.add(tunnel.tunnelId().toString());
- arrayNode.add(tunnel.tunnelName().toString());
- }
- }
- }
-
- result.putArray(BUFFER_ARRAY).addAll(arrayNode);
- sendMessage(PCEWEB_SHOW_TUNNEL, result);
- }
- }
-
- /**
- * Handles the 'update path' event received from the client.
- */
- private final class UpdatePathHandler extends RequestHandler {
-
- public UpdatePathHandler() {
- super(PCEWEB_UPDATE_PATH);
- }
-
- @Override
- public void process(ObjectNode payload) {
- String bandWidth = string(payload, BANDWIDTH);
- String bandWidthType = string(payload, BANDWIDTHTYPE);
- String costType = string(payload, COSTTYPE);
- String tunnelId = string(payload, TUNNEL_ID);
-
- if (tunnelId == null) {
- log.error("PCE update path is failed.");
- }
-
- findAndSendPathsUpdate(bandWidth, bandWidthType, costType, tunnelId);
- }
- }
-
- /**
- * Handles the 'update path' event received from the client.
- */
- private final class UpdatePathInfoHandler extends RequestHandler {
-
- public UpdatePathInfoHandler() {
- super(PCEWEB_TUNNEL_UPDATE_INFO);
- }
-
- @Override
- public void process(ObjectNode payload) {
- String tunnelIdStr = string(payload, TUNNEL_ID);
-
- if (tunnelIdStr == null) {
- log.error("PCE update path is failed.");
- return;
- }
-
- if (tunnelIdStr.equals(STRING_NULL)) {
- log.error("PCE update path is failed.");
- return;
- }
-
- if (pceService == null) {
- log.error("PCE service is not active");
- return;
- }
-
- TunnelId tunnelId = TunnelId.valueOf(tunnelIdStr);
- Tunnel tunnel = tunnelService.queryTunnel(tunnelId);
- ObjectNode result = objectNode();
- ArrayNode arrayNode = arrayNode();
-
- arrayNode.add("Tunnel");
- arrayNode.add(tunnelIdStr);
- arrayNode.add("BandWidth");
- arrayNode.add(tunnel.annotations().value("bandwidth"));
- arrayNode.add("CostType");
- arrayNode.add(tunnel.annotations().value("costType"));
-
- result.putArray(BUFFER_ARRAY).addAll(arrayNode);
- sendMessage(PCEWEB_TUNNEL_UPDATE_INFO_REPLY, result);
- }
- }
-
- /**
- * Handles the 'remove path query' event received from the client.
- */
- private final class RemovePathQueryHandler extends RequestHandler {
-
- public RemovePathQueryHandler() {
- super(PCEWEB_REMOVE_PATH_QUERY);
- }
-
- @Override
- public void process(ObjectNode payload) {
- String srcId = string(payload, SRCID);
- ElementId src = elementId(srcId);
- String dstId = string(payload, DSTID);
- ElementId dst = elementId(dstId);
-
- Device srcDevice = deviceService.getDevice((DeviceId) src);
- Device dstDevice = deviceService.getDevice((DeviceId) dst);
-
- TunnelEndPoint tunSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(srcDevice.annotations().value("lsrId")));
- TunnelEndPoint tunDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(dstDevice.annotations().value("lsrId")));
-
- Collection<Tunnel> tunnelSet = tunnelService.queryTunnel(tunSrc, tunDst);
- ObjectNode result = objectNode();
- ArrayNode arrayNode = arrayNode();
-
- for (Tunnel tunnel : tunnelSet) {
- if (tunnel.type() == MPLS) {
- if (tunnel.state().equals(ACTIVE)) {
-
- if (tunnel.annotations().value("loadBalancingPathName") != null) {
- boolean present = false;
- if (!arrayNode.isNull()) {
- for (JsonNode node : arrayNode) {
- if (node.asText().equals(tunnel.annotations().value("loadBalancingPathName"))) {
- present = true;
- break;
- }
- }
- if (!present) {
- arrayNode.add("");
- arrayNode.add(tunnel.annotations().value("loadBalancingPathName"));
- }
- }
-
- } else {
- arrayNode.add(tunnel.tunnelId().toString());
- arrayNode.add(tunnel.tunnelName().toString());
- }
- }
- }
- }
-
- result.putArray(BUFFER_ARRAY).addAll(arrayNode);
- sendMessage(PCEWEB_SHOW_TUNNEL_REMOVE, result);
- }
- }
-
- /**
- * Handles the 'remove path' event received from the client.
- */
- private final class RemovePathHandler extends RequestHandler {
-
- public RemovePathHandler() {
- super(PCEWEB_REMOVE_PATH);
- }
-
- @Override
- public void process(ObjectNode payload) {
- String tunnelId = string(payload, TUNNEL_ID);
- String pathName = string(payload, "tunnelname");
-
- //TODO: if tunnel id null it is load banlanced path
- if (tunnelId.equals("") && pathName != null) {
- findAndSendPathsRemove(STRING_NULL, pathName);
- /* List<TunnelId> tunnelIds = pceService.getLoadBalancedPath(pathName);
- for (TunnelId id : tunnelIds) {
- Tunnel tunnel = tunnelService.queryTunnel(id);
- if (tunnel != null) {
-
- }
- }*/
- } else {
- findAndSendPathsRemove(tunnelId, null);
- }
-
- }
- }
-
- /**
- * Handles the 'show the existed tunnels' event received from the client.
- */
- private final class ShowTunnelHandler extends RequestHandler {
-
- public ShowTunnelHandler() {
- super(PCEWEB_QUERY_TUNNELS);
- }
-
- @Override
- public void process(ObjectNode payload) {
- ObjectNode result = objectNode();
- ArrayNode arrayNode = arrayNode();
- Collection<Tunnel> tunnelSet = null;
-
- tunnelSet = tunnelService.queryTunnel(MPLS);
- for (Tunnel tunnel : tunnelSet) {
- if (tunnel.state().equals(ACTIVE)) {
- //TODO: if it is load balancing need to check whether to send tunnel ID as null or some negative
- //TODO;value
- if (tunnel.annotations().value("loadBalancingPathName") != null) {
- boolean present = false;
- if (!arrayNode.isNull()) {
- for (JsonNode node : arrayNode) {
- if (node.asText().equals(tunnel.annotations().value("loadBalancingPathName"))) {
- present = true;
- break;
- }
- }
- if (!present) {
- arrayNode.add("");
- arrayNode.add(tunnel.annotations().value("loadBalancingPathName"));
- }
- }
-
- } else {
- arrayNode.add(tunnel.tunnelId().toString());
- arrayNode.add(tunnel.tunnelName().toString());
- }
- }
- }
-
- result.putArray(BUFFER_ARRAY).addAll(arrayNode);
- sendMessage(PCEWEB_TUNNEL_QUERY_INFO, result);
- }
- }
-
- /**
- * Handles the 'show the existed tunnels' event received from the client.
- */
- private final class ShowTunnelHighlight extends RequestHandler {
-
- public ShowTunnelHighlight() {
- super(PCEWEB_TUNNEL_QUERY_INFO_SHOW);
- }
-
- @Override
- public void process(ObjectNode payload) {
- String tunnelIdStr = string(payload, TUNNEL_ID);
- String pathName = string(payload, "tunnelname");
-
- if (tunnelIdStr.equals("")) {
- List<Tunnel> tunnels = Lists.newLinkedList();
- List<TunnelId> tunnelIds = pceService.queryLoadBalancingPath(pathName);
- for (TunnelId id : tunnelIds) {
- Tunnel t = tunnelService.queryTunnel(id);
- tunnels.add(t);
- }
- if (!tunnels.isEmpty()) {
- highlightsForTunnel(tunnels);
- }
- } else {
- TunnelId tunnelId = TunnelId.valueOf(tunnelIdStr);
- Tunnel t = tunnelService.queryTunnel(tunnelId);
- if (t != null) {
- highlightsForTunnel(t);
- }
- }
- }
- }
-
- /**
- * provides the element id.
- */
- private ElementId elementId(String id) {
- try {
- return DeviceId.deviceId(id);
- } catch (IllegalArgumentException e) {
- return HostId.hostId(id);
- }
- }
-
- /**
- * Handles the setup path and highlights the path.
- *
- * @param src ID of source
- * @param dst ID of destination
- * @param bandWidth bandwidth
- * @param bandWidthType is the kbps or mbps
- * @param costType is igp or te
- * @param lspType is WITH_SIGNALLING, WITHOUT_SIGNALLING_AND_WITHOUT_SR
- * or SR_WITHOUT_SIGNALLING
- * @param tunnelName tunnel id
- */
- private void findAndSendPaths(ElementId src, ElementId dst, String bandWidth,
- String bandWidthType, String costType,
- String lspType, String tunnelName, String loadBalancing) {
- log.debug("src={}; dst={};", src, dst);
- boolean path;
- List<Constraint> listConstrnt;
-
- listConstrnt = addBandwidthCostTypeConstraints(bandWidth, bandWidthType, costType);
-
- //LSP type
- LspType lspTypeVal = null;
- switch (lspType) {
- case LSP_TYPE_CR:
- lspTypeVal = LspType.WITH_SIGNALLING;
- break;
- case LSP_TYPE_SRBE:
- lspTypeVal = LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
- break;
- case LSP_TYPE_SRTE:
- lspTypeVal = LspType.SR_WITHOUT_SIGNALLING;
- break;
- default:
- break;
- }
-
- boolean loadBalancingOpt = Boolean.parseBoolean(loadBalancing);
-
- //TODO: need to get explicit paths [temporarily using null as the value]
-
- if (loadBalancingOpt) {
- path = pceService.setupPath((DeviceId) src, (DeviceId) dst, tunnelName, listConstrnt, lspTypeVal,
- loadBalancingOpt);
- } else {
- path = pceService.setupPath((DeviceId) src, (DeviceId) dst, tunnelName, listConstrnt, lspTypeVal,
- null);
- }
-
- if (!path) {
- log.error("setup path is failed");
- }
- }
-
- /**
- * Handles the update path and highlights the path.
- *
- * @param bandWidth bandWidth
- * @param bandWidthType is the kbps or mbps
- * @param costType is igp or te
- * @param tunnelIdStr tunnel id
- */
- private void findAndSendPathsUpdate(String bandWidth, String bandWidthType,
- String costType, String tunnelIdStr) {
- if (tunnelIdStr != null) {
- List<Constraint> listConstrnt;
-
- if (tunnelIdStr.equals(STRING_NULL)) {
- log.error("update path is failed");
- return;
- }
-
- if (pceService == null) {
- log.error("PCE service is not active");
- return;
- }
-
- listConstrnt = addBandwidthCostTypeConstraints(bandWidth, bandWidthType, costType);
- TunnelId tunnelId = TunnelId.valueOf(tunnelIdStr);
- boolean path = pceService.updatePath(tunnelId, listConstrnt);
-
- if (!path) {
- log.error("update path is failed");
- }
- }
- }
-
- /**
- * Handles the remove path and highlights the paths if existed.
- *
- * @param tunnelIdStr tunnelId
- */
- private void findAndSendPathsRemove(String tunnelIdStr, String pathName) {
- if (pceService == null) {
- log.error("PCE service is not active");
- return;
- }
- boolean path;
-
- if (tunnelIdStr.equals(STRING_NULL) && !pathName.equals(STRING_NULL)) {
- path = pceService.releasePath(pathName);
- } else {
- TunnelId tunnelId = TunnelId.valueOf(tunnelIdStr);
- path = pceService.releasePath(tunnelId);
- }
-
- if (!path) {
- log.error("remove path is failed");
- }
-
- }
-
- private ImmutableSet.Builder<Link> buildPaths(ImmutableSet.Builder<Link> pathBuilder) {
- paths.forEach(path -> path.links().forEach(pathBuilder::add));
- return pathBuilder;
- }
-
- /**
- * Handles the preparation of constraints list with given bandwidth and cost-type.
- *
- * @param bandWidth bandWidth
- * @param bandWidthType is the kbps or mbps
- * @param costType is igp or te
- * @return
- */
- private List<Constraint> addBandwidthCostTypeConstraints(String bandWidth,
- String bandWidthType,
- String costType) {
- List<Constraint> listConstrnt = new LinkedList<>();
- //bandwidth
- double bwValue = 0.0;
- if (!bandWidth.equals(STRING_NULL)) {
- bwValue = Double.parseDouble(bandWidth);
- }
- if (bandWidthType.equals(BANDWIDTH_TYPE_KBPS)) {
- bwValue = bwValue * BANDWIDTH_KBPS;
- } else if (bandWidthType.equals(BANDWIDTH_TYPE_MBPS)) {
- bwValue = bwValue * BANDWIDTH_MBPS;
- }
-
- //Cost type
- CostConstraint.Type costTypeVal = null;
- switch (costType) {
- case COST_TYPE_IGP:
- costTypeVal = CostConstraint.Type.COST;
- break;
- case COST_TYPE_TE:
- costTypeVal = CostConstraint.Type.TE_COST;
- break;
- default:
- break;
- }
-
- if (bwValue != 0.0) {
- listConstrnt.add(PceBandwidthConstraint.of(bwValue, DataRateUnit.valueOf(BANDWIDTH_BPS)));
- }
-
- if (costTypeVal != null) {
- listConstrnt.add(CostConstraint.of(costTypeVal));
- }
-
- return listConstrnt;
- }
-
- /**
- * Handles the highlights of selected path.
- */
- private void hilightAndSendPaths(Highlights highlights) {
- LinkHighlight lh;
- int linkclr = 0;
- for (Path path : paths) {
- for (Link link : path.links()) {
- lh = new LinkHighlight(TopoUtils.compactLinkString(link), PRIMARY_HIGHLIGHT)
- .addMod(new Mod(LINK_COLOR[linkclr]));
- highlights.add(lh);
- }
- linkclr = linkclr + 1;
- if (linkclr == LINK_COLOR_MAX) {
- linkclr = 0;
- }
- }
-
- sendMessage(highlightsMessage(highlights));
- }
-
- /**
- * Handles the addition of badge and highlights.
- *
- * @param highlights highlights
- * @param elemId device to be add badge
- * @param src device to be add badge
- * @return
- */
- private Highlights addBadge(Highlights highlights,
- String elemId, String src) {
- highlights = addDeviceBadge(highlights, elemId, src);
- return highlights;
- }
-
- /**
- * Handles the badge add and highlights.
- *
- * @param h highlights
- * @param elemId device to be add badge
- * @param type device badge value
- * @return highlights
- */
- private Highlights addDeviceBadge(Highlights h, String elemId, String type) {
- DeviceHighlight dh = new DeviceHighlight(elemId);
- dh.setBadge(createBadge(type));
- h.add(dh);
- return h;
- }
-
- /**
- * Handles the node badge add and highlights.
- *
- * @param type device badge value
- * @return badge of given node
- */
- private NodeBadge createBadge(String type) {
- return NodeBadge.text(type);
- }
-
- /**
- * Handles the event of tunnel listeners.
- */
- private class InnerPceWebTunnelListener implements TunnelListener {
- @Override
- public void event(TunnelEvent event) {
- Tunnel tunnel = event.subject();
- if (tunnel.type() == MPLS) {
- highlightsForTunnel(tunnel);
- }
- }
- }
-
- /**
- * Handles the event of topology listeners.
- */
- private void findTunnelAndHighlights() {
- Collection<Tunnel> tunnelSet = null;
- Highlights highlights = new Highlights();
- paths.clear();
- tunnelSet = tunnelService.queryTunnel(MPLS);
- if (tunnelSet.size() == 0) {
- log.warn("Tunnel does not exist");
- sendMessage(highlightsMessage(highlights));
- return;
- }
-
- for (Tunnel tunnel : tunnelSet) {
- if (tunnel.path() == null) {
- log.error("path does not exist");
- sendMessage(highlightsMessage(highlights));
- return;
- }
- if (!tunnel.state().equals(ACTIVE)) {
- log.debug("Tunnel state is not active");
- sendMessage(highlightsMessage(highlights));
- return;
- }
- Link firstLink = tunnel.path().links().get(0);
- if (firstLink != null) {
- if (firstLink.src() != null) {
- highlights = addBadge(highlights, firstLink.src().deviceId().toString(), SRC);
- }
- }
- Link lastLink = tunnel.path().links().get(tunnel.path().links().size() - 1);
- if (lastLink != null) {
- if (lastLink.dst() != null) {
- highlights = addBadge(highlights, lastLink.dst().deviceId().toString(), DST);
- }
- }
- paths.add(tunnel.path());
- }
-
- ImmutableSet.Builder<Link> builder = ImmutableSet.builder();
- allPathLinks = buildPaths(builder).build();
- hilightAndSendPaths(highlights);
- }
-
- private void highlightsForTunnel(Tunnel... tunnels) {
- highlightsForTunnel(Arrays.asList(tunnels));
- }
- /**
- * Handles the event of topology listeners.
- */
- private void highlightsForTunnel(List<Tunnel> tunnels) {
- Highlights highlights = new Highlights();
- paths.clear();
-
- if (tunnels.isEmpty()) {
- log.error("path does not exist");
- sendMessage(TopoJson.highlightsMessage(highlights));
- return;
- }
- for (Tunnel tunnel : tunnels) {
- if (tunnel.path() == null) {
- log.error("path does not exist");
- sendMessage(highlightsMessage(highlights));
- return;
- }
- if (!tunnel.state().equals(ACTIVE)) {
- log.debug("Tunnel state is not active");
- sendMessage(highlightsMessage(highlights));
- return;
- }
-
- Link firstLink = tunnel.path().links().get(0);
- if (firstLink != null) {
- if (firstLink.src() != null) {
- highlights = addBadge(highlights, firstLink.src().deviceId().toString(), SRC);
- }
- }
- Link lastLink = tunnel.path().links().get(tunnel.path().links().size() - 1);
- if (lastLink != null) {
- if (lastLink.dst() != null) {
- highlights = addBadge(highlights, lastLink.dst().deviceId().toString(), DST);
- }
- }
- paths.add(tunnel.path());
- }
-
- ImmutableSet.Builder<Link> builder = ImmutableSet.builder();
- allPathLinks = buildPaths(builder).build();
- hilightAndSendPaths(highlights);
- }
-}
diff --git a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovOverlay.java b/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovOverlay.java
deleted file mode 100644
index 1a32815..0000000
--- a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/PceWebTopovOverlay.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pceweb;
-
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.resource.ContinuousResource;
-import org.onosproject.net.resource.ResourceService;
-import org.onosproject.net.resource.Resource;
-import org.onosproject.net.resource.DiscreteResource;
-import org.onosproject.net.resource.Resources;
-import org.onosproject.ui.UiTopoOverlay;
-import org.onosproject.ui.topo.PropertyPanel;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.link.LinkEvent;
-import org.onosproject.ui.topo.TopoConstants.CoreButtons;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpAddress;
-/**
- * PCE WEB topology overlay.
- */
-public class PceWebTopovOverlay extends UiTopoOverlay {
-
- // NOTE: this must match the ID defined in pcewebTopovOverlay.js
- private static final String OVERLAY_ID = "PCE-web-overlay";
- private static final String MY_TITLE = "Device details";
-
- public static final String AS_NUMBER = "asNumber";
- public static final String LSR_ID = "lsrId";
- public static final String ABR_BIT = "abrBit";
- public static final String ASBR_BIT = "externalBit";
- public static final String TE_METRIC = "teCost";
- public static final String ABR = "ABR";
- public static final String ASBR = "ASBR";
- public static final String ABR_ASBR = "ABR/ASBR";
- public static final String INNER = "Inner";
- public static final long IDENTIFIER_SET = 0x100000000L;
- public static final long SET = 0xFFFFFFFFL;
- public static final String TYPE_LABEL = "Type";
- public static final String AS_NUMBER_LABEL = "AS Number";
- public static final String LSR_ID_LABEL = "LSR ID";
- public static final String POSITION_LABEL = "Position";
-
- /**
- * Initialize the overlay ID.
- */
- public PceWebTopovOverlay() {
- super(OVERLAY_ID);
- }
-
- @Override
- public void deactivate() {
- super.deactivate();
- log.debug("Deactivated");
- }
-
- @Override
- public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
-
- pp.title(MY_TITLE);
- DeviceService deviceService = AbstractShellCommand.get(DeviceService.class);
- pp.removeAllProps();
- pp.removeButtons(CoreButtons.SHOW_PORT_VIEW)
- .removeButtons(CoreButtons.SHOW_GROUP_VIEW)
- .removeButtons(CoreButtons.SHOW_METER_VIEW);
-
- if (deviceService != null) {
-
- Device device = deviceService.getDevice(deviceId);
- Annotations annots = device.annotations();
-
- String type = annots.value(AnnotationKeys.TYPE);
- String asNumber = annots.value(AS_NUMBER);
- String lsrId = annots.value(LSR_ID);
- String abrStatus = annots.value(ABR_BIT);
- String asbrStatus = annots.value(ASBR_BIT);
-
- if (type != null) {
- pp.addProp(TYPE_LABEL, TYPE_LABEL, type);
- }
-
- if (asNumber != null) {
- pp.addProp(AS_NUMBER_LABEL, AS_NUMBER_LABEL, asNumber);
- }
-
- if (lsrId != null) {
- pp.addProp(LSR_ID_LABEL, LSR_ID_LABEL, lsrId);
- }
-
- if (Boolean.valueOf(abrStatus).equals(true) && Boolean.valueOf(asbrStatus).equals(true)) {
- pp.addProp(POSITION_LABEL, POSITION_LABEL, ABR_ASBR);
- } else if (Boolean.valueOf(abrStatus).equals(true)) {
- pp.addProp(POSITION_LABEL, POSITION_LABEL, ABR);
- } else if (Boolean.valueOf(asbrStatus).equals(true)) {
- pp.addProp(POSITION_LABEL, POSITION_LABEL, ASBR);
- } else {
- pp.addProp(POSITION_LABEL, POSITION_LABEL, INNER);
- }
- }
- }
-
- @Override
- public Map<String, String> additionalLinkData(LinkEvent event) {
- Map<String, String> map = new HashMap<>();
- Link link = event.subject();
- long srcPortNo;
- long dstPortNo;
- IpAddress ipDstAddress = null;
- IpAddress ipSrcAddress = null;
- String srcPort;
- String dstPort;
- String bandWidth;
-
- srcPortNo = link.src().port().toLong();
- if (((srcPortNo & IDENTIFIER_SET) == IDENTIFIER_SET)) {
- srcPort = String.valueOf(srcPortNo);
- } else {
- ipSrcAddress = Ip4Address.valueOf((int) srcPortNo);
- srcPort = ipSrcAddress.toString();
- }
-
- dstPortNo = link.dst().port().toLong();
- if (((dstPortNo & IDENTIFIER_SET) == IDENTIFIER_SET)) {
- dstPort = String.valueOf(dstPortNo);
- } else {
- ipDstAddress = Ip4Address.valueOf((int) dstPortNo);
- dstPort = ipDstAddress.toString();
- }
-
- map.put("Src Address", srcPort);
- map.put("Dst Address", dstPort);
- map.put("Te metric", link.annotations().value(TE_METRIC));
-
- ResourceService resService = AbstractShellCommand.get(ResourceService.class);
- DiscreteResource devResource = Resources.discrete(link.src().deviceId(), link.src().port()).resource();
- if (resService == null) {
- log.warn("resource service does not exist");
- return map;
- }
-
- if (devResource == null) {
- log.warn("Device resources does not exist");
- return map;
- }
- double regBandwidth = 0;
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- log.error("Exception occurred while getting the bandwidth.");
- Thread.currentThread().interrupt();
- }
- Set<Resource> resources = resService.getRegisteredResources(devResource.id());
- for (Resource res : resources) {
- if (res instanceof ContinuousResource) {
- regBandwidth = ((ContinuousResource) res).value();
- break;
- }
- }
-
- if (regBandwidth != 0) {
- bandWidth = String.valueOf(regBandwidth);
- map.put("Bandwidth", bandWidth);
- }
-
- return map;
- }
-}
diff --git a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/package-info.java b/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/package-info.java
deleted file mode 100644
index f0c3ed6..0000000
--- a/apps/pce/pceweb/src/main/java/org/onosproject/pceweb/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCE visualization GUI topology view overlay.
- */
-package org.onosproject.pceweb;
diff --git a/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopov.css b/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopov.css
deleted file mode 100644
index 8e414c0..0000000
--- a/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopov.css
+++ /dev/null
@@ -1,154 +0,0 @@
-/* css for PCE web app topology overlay */
-.radioButtonSpace {
- margin-left:20px;
-}
-/* color:1 */
-#ov-topo svg .link.primary.pCol1 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol1 {
- stroke: #FF00CE;
-}
-.dark #ov-topo svg .link.primary.pCol1 {
- stroke: #FF00CE;
-}
-/* color:2 */
-#ov-topo svg .link.primary.pCol2 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol2 {
- stroke: #ff4000;
-}
-.dark #ov-topo svg .link.primary.pCol2 {
- stroke: #ff4000;
-}
-/* color:3 */
-#ov-topo svg .link.primary.pCol3 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol3 {
- stroke: #ffb400;
-}
-.dark #ov-topo svg .link.primary.pCol3 {
- stroke: #ffb400;
-}
-/* color:4 */
-#ov-topo svg .link.primary.pCol4 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol4 {
- stroke: #89ff00;
-}
-.dark #ov-topo svg .link.primary.pCol4 {
- stroke: #89ff00;
-}
-/* color:5 */
-#ov-topo svg .link.primary.pCol5 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol5 {
- stroke: #00FF2B;
-}
-.dark #ov-topo svg .link.primary.pCol5 {
- stroke: #00FF2B;
-}
-/* color:6 */
-#ov-topo svg .link.primary.pCol6 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol6 {
- stroke: #00ffec;
-}
-.dark #ov-topo svg .link.primary.pCol6 {
- stroke: #00ffec;
-}
-/* color:7 */
-#ov-topo svg .link.primary.pCol7 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol7 {
- stroke: #00abff;
-}
-.dark #ov-topo svg .link.primary.pCol7 {
- stroke: #00abff;
-}
-/* color:8 */
-#ov-topo svg .link.primary.pCol8 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol8 {
- stroke: #005eff;
-}
-.dark #ov-topo svg .link.primary.pCol8 {
- stroke: #005eff;
-}
-/* color:9 */
-#ov-topo svg .link.primary.pCol9 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol9 {
- stroke: #0011ff;
-}
-.dark #ov-topo svg .link.primary.pCol9 {
- stroke: #0011ff;
-}
-/* color:10 */
-#ov-topo svg .link.primary.pCol10 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol10 {
- stroke: #7c00ff;
-}
-.dark #ov-topo svg .link.primary.pCol10 {
- stroke: #7c00ff;
-}
-/* color:11 */
-#ov-topo svg .link.primary.pCol11 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol11 {
- stroke: #ffe700;
-}
-.dark #ov-topo svg .link.primary.pCol11 {
- stroke: #ffe700;
-}
-/* color:12 */
-#ov-topo svg .link.primary.pCol12 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol12 {
- stroke: #00ffec;
-}
-.dark #ov-topo svg .link.primary.pCol12 {
- stroke: #00ffec;
-}
-/* color:13 */
-#ov-topo svg .link.primary.pCol13 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol13 {
- stroke: #c900ff;
-}
-.dark #ov-topo svg .link.primary.pCol13 {
- stroke: #c900ff;
-}
-/* color:14 */
-#ov-topo svg .link.primary.pCol14 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol14 {
- stroke: #ff00e7;
-}
-.dark #ov-topo svg .link.primary.pCol14 {
- stroke: #ff00e7;
-}
-/* color:15 */
-#ov-topo svg .link.primary.pCol15 {
- stroke-width: 6px;
-}
-.light #ov-topo svg .link.primary.pCol15 {
- stroke: #3c00ff;
-}
-.dark #ov-topo svg .link.primary.pCol15 {
- stroke: #3c00ff;
-}
diff --git a/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopov.html b/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopov.html
deleted file mode 100644
index 7d02ca9..0000000
--- a/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopov.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<!-- partial HTML -->
-<div id="ov-pceweb-topov">
- <p>This is a hidden view .. just a placeholder to house the javascript</p>
-</div>
diff --git a/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopovDemo.js b/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopovDemo.js
deleted file mode 100644
index 0523f33..0000000
--- a/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopovDemo.js
+++ /dev/null
@@ -1,600 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*PCE topology overlay web application implementation.*/
-
-(function () {
- 'use strict';
-
- // injected refs
- var $log, fs, flash, wss, tps, ns, tds, ds;
- var tunnelNameData, tunnelNameDataRemove, tunnelDataUpdateInfo, tunnelIdUpd, tunnelNameDataQuery;
- // constants
- var srcMessage = 'pceTopovSetSrc',
- dstMessage = 'pceTopovSetDst',
- clearMessage = 'pceTopovClear',
- setPathmsg = 'pceTopovSetMode',
- updatePathmsgQuery = 'pceTopovUpdateQuery',
- remPathmsgQuery = 'pceTopovRemQuery',
- updatePathmsg = 'pceTopovUpdate',
- updatePathmsgInfo = 'updatePathmsgInfo',
- remPathmsg = 'pceTopovRem',
- showTunnelInfoMsg = 'pceTopovShowTunnels',
- queryDisplayTunnelMsg = 'pceTopovTunnelDisplay',
- showTunnelInfoRemoveMsg = 'pceTopovShowTunnelsRem',
- showTunnelInfoUpdateMsg = 'pceTopovShowTunnelsUpdate',
- showTunnelInfoQuery = 'pceTopovShowTunnelsQuery',
- showTunnelHighlightMsg = 'pceTopovshowTunnelHighlightMsg';
-
- // internal state
- var currentMode = null;
- var handlerMap = {},
- handlerMapRem = {},
- handlerMapshowQuery = {},
- handlerMapShowUpdate = {};
- // === ---------------------------
- // === Helper functions
-
- // === ---------------------------
- // === Main API functions
-
- function setSrc(node) {
- wss.sendEvent(srcMessage, {
- id: node.id,
- type: node.type
- });
- flash.flash('Source node: ' + node.id);
- }
-
- function setDst(node) {
- wss.sendEvent(dstMessage, {
- id: node.id,
- type: node.type
- });
- flash.flash('Destination node: ' + node.id);
- }
-
- function clear() {
- wss.sendEvent(clearMessage);
- flash.flash('Cleared source and destination');
- }
-
- function dClose() {
- $log.debug('Dialog Close button clicked (or Esc pressed)');
- }
-
- function createUserText() {
- var content = ds.createDiv('constraints-input'),
- form = content.append('form'),
- p = form.append('p');
-
- function addAttribute(name, id, nameField, type) {
- if (type == 'radio') {
- if (id == 'pce-lsp-type-cr') {
- p.append('input').attr({
- type: type,
- name: name,
- id: id,
- checked: 'checked',
- class: 'radioButtonSpace'
- });
- } else {
- p.append('input').attr({
- type: type,
- name: name,
- id: id,
- class: 'radioButtonSpace'
- });
- }
- } else {
- p.append('input').attr({
- type: type,
- name: name,
- id: id
- });
- }
-
- p.append('span').text(nameField);
- p.append('br');
- }
-
- //Add the bandwidth related inputs.
- addAttribute('band-width-name', 'band-width-box', 'Band Width', 'checkbox');
- addAttribute('band-width-value-name', 'band-width-value', null, 'number');
- addAttribute('pce-band-type', 'band-kpbs-val', 'kbps', 'radio');
- addAttribute('pce-band-type', 'band-mpbs-val', 'mbps', 'radio');
- addAttribute('pce-band-type', 'band-bps-val', 'bps', 'radio');
- //Add the cost type related inputs.
- addAttribute('pce-cost-type-name', 'pce-cost-type', 'Cost Type', 'checkbox');
- addAttribute('pce-cost-type-valname', 'pce-cost-type-igp', 'IGP', 'radio');
- addAttribute('pce-cost-type-valname', 'pce-cost-type-te', 'TE', 'radio');
-
- //Add the load balancing related inputs.
- addAttribute('pce-load-balancing-option-name', 'pce-load-balance', 'Load balancing', 'checkbox');
-
- //Add the LSP type related inputs.
- p.append('span').text("Lsp Type *");
- p.append('br');
- addAttribute('pce-lsp-type-valname', 'pce-lsp-type-cr', 'With signalling', 'radio');
- addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srbe', 'Without SR without signalling', 'radio');
- addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srte', 'With SR without signalling', 'radio');
- //Add the tunnel name
- p.append('span').text("Tunnel Name *");
- p.append('br');
- addAttribute('pce-tunnel-name', 'pce-tunnel-name-id', null, 'text');
- p.append('span').text("* indicates mandatory fields");
- return content;
- }
-
- function createUserTextUpdate(data) {
- var content = ds.createDiv(),
- form = content.append('form'),
- p = form.append('p');
-
- p.append('span').text('Tunnel IDs');
- p.append('br');
-
- for (var idx = 0; idx < data.a.length; idx++) {
- p.append('input').attr({
- id: 'tunnel-id-'+idx,
- type: 'radio',
- name: 'tunnel-id-name',
- value: data.a[idx]
- });
- idx++;
- p.append('span').text(data.a[idx]);
- p.append('br');
- }
- return content;
- }
-
- function createUserTextUpdatePathEvent(data) {
- var content = ds.createDiv(),
- form = content.append('form'),
- p = form.append('p');
- var constType;
-
- function addAttribute(name, id, nameField, type) {
- if (type == 'radio') {
- p.append('input').attr({
- type: type,
- name: name,
- id: id,
- class: 'radioButtonSpace'
- });
- }
- else {
- p.append('input').attr({
- type: type,
- name: name,
- id: id
- });
- }
-
- p.append('span').text(nameField);
- p.append('br');
- }
-
- data.a.forEach( function (val, idx) {
- if (val == 'Tunnel') {
- constType = 'TUNNEL';
- return;
- }
-
- if (val == 'BandWidth') {
- constType = 'BW';
- return;
- }
-
- if (val == 'CostType') {
- constType = 'CT';
- return;
- }
-
- if (val == 'LoadBalancing') {
- constType = 'LB';
- return;
- }
-
- if (constType == 'TUNNEL') {
- p.append('span').text('Tunnel Id: ');
- p.append('span').text(val);
- p.append('br');
- tunnelIdUpd = val;
- }
-
- if (constType == 'BW') {
- //addAttribute('band-width-name', 'update-band-width-box', 'Band Width', 'checkbox');
- p.append('span').text('Band Width');
- p.append('br');
- p.append('input').attr({
- id: 'update-band-width-value',
- type: 'number',
- name: 'band-width-value-name',
- value: val
- });
- p.append('br');
- p.append('input').attr({
- id: 'update-band-bps-val',
- type: 'radio',
- name: 'pce-band-type',
- checked: 'checked',
- class: 'radioButtonSpace'
- });
- p.append('span').text('bps');
- p.append('br');
- addAttribute('pce-band-type', 'update-band-kbps-val', 'kbps', 'radio');
- addAttribute('pce-band-type', 'update-band-mbps-val', 'mbps', 'radio');
- addAttribute('pce-band-type', 'update-band-none-val', 'none', 'radio');
- }
-
- if (constType == 'CT') {
- //addAttribute('pce-cost-type', 'update-pce-cost-type', 'Cost Type', 'checkbox');
- p.append('span').text('Cost Type');
- p.append('br');
- if (val == 'COST') {
- p.append('input').attr({
- id: 'update-pce-cost-type-igp',
- type: 'radio',
- name: 'pce-cost-type-value',
- checked: 'checked',
- class: 'radioButtonSpace'
- });
- p.append('span').text('IGP');
- p.append('br');
- addAttribute('pce-cost-type-value', 'update-pce-cost-type-te', 'TE', 'radio');
- addAttribute('pce-cost-type-value', 'update-pce-cost-type-none', 'none', 'radio');
-
- } else {
- addAttribute('pce-cost-type-value', 'update-pce-cost-type-igp', 'IGP', 'radio');
- p.append('input').attr({
- id: 'update-pce-cost-type-te',
- type: 'radio',
- name: 'pce-cost-type-value',
- checked: 'checked',
- class: 'radioButtonSpace'
- });
- p.append('span').text('TE');
- p.append('br');
- addAttribute('pce-cost-type-value', 'update-pce-cost-type-none', 'none', 'radio');
- }
- }
- } );
-
- return content;
- }
-
- function createUserTextRemove(data) {
-
- var content = ds.createDiv(),
- form = content.append('form'),
- p = form.append('p');
-
- p.append('span').text('Tunnels');
- p.append('br');
-
- for (var idx = 0; idx < data.a.length; idx++) {
- p.append('input').attr({
- id: 'tunnel-id-remove-'+idx,
- type: 'checkbox',
- name: 'tunnel-id-name-remove',
- value: data.a[idx]
- });
- idx++;
- p.append('span').text(data.a[idx]);
- p.append('br');
- }
-
- return content;
- }
-
- function createUserTextQuery(data) {
-
- var content = ds.createDiv(),
- form = content.append('form'),
- p = form.append('p');
-
- p.append('span').text('Tunnels');
- p.append('br');
-
- for (var idx =0; idx < data.a.length; idx++) {
- p.append('input').attr({
- id: 'tunnel-id-query-'+idx,
- type: 'radio',
- name: 'tunnel-id-name-query',
- value: data.a[idx]
- });
- idx++;
- p.append('span').text(data.a[idx]);
- p.append('br');
- }
- return content;
- }
-
- function isChecked(cboxId) {
- return d3.select('#' + cboxId).property('checked');
- }
-
- function getCheckedValue(cboxId) {
- return d3.select('#' + cboxId).property('value');
- }
-
- function showTunnelInformation(data) {
- wss.unbindHandlers(handlerMap);
- tunnelNameData = data;
-
- function dOkUpdate() {
- var tdString = '' ;
- for (var idx = 0; idx < tunnelNameData.a.length; idx++) {
- var tunnelName = isChecked('tunnel-id-'+idx);
- if (tunnelName) {
- tdString = tunnelNameData.a[idx];
- }
- idx++;
- }
- //send event to server for getting the tunnel information.
- if (tdString != null) {
- handlerMapShowUpdate[showTunnelInfoUpdateMsg] = showTunnelInfoUpdateMsgHandle;
- wss.bindHandlers(handlerMapShowUpdate);
-
- wss.sendEvent(updatePathmsgInfo, {
- tunnelid: tdString
- });
- }
- //constraintsUpdateDialog(tdString);
- $log.debug('Dialog OK button clicked');
- }
-
- tds.openDialog()
- .setTitle('Available LSPs with selected device')
- .addContent(createUserTextUpdate(data))
- .addOk(dOkUpdate, 'OK')
- .addCancel(dClose, 'Close')
- .bindKeys();
- }
-
- function dOkUpdateEvent() {
- $log.debug('Select constraints for update path Dialog OK button pressed');
-
- var bandValue = null,
- bandType = null;
-
- bandValue = getCheckedValue('update-band-width-value');
-
- if (isChecked('update-band-kbps-val')) {
- bandType = 'kbps';
- } else if (isChecked('update-band-mbps-val')) {
- bandType = 'mbps';
- } else if (isChecked('update-band-bps-val')) {
- bandType = 'bps';
- } else if (isChecked('update-band-none-val')) {
- bandType = null;
- bandValue = null;
- }
-
- var costTypeVal = null;
-
- if (isChecked('update-pce-cost-type-igp')) {
- costTypeVal = 'igp';
- } else if (isChecked('update-pce-cost-type-te')) {
- costTypeVal = 'te';
- } else if (isChecked('update-pce-cost-type-none')) {
- costTypeVal = null;
- }
-
- wss.sendEvent(updatePathmsg, {
- bw: bandValue,
- bwtype: bandType,
- ctype: costTypeVal,
- tunnelid: tunnelIdUpd
- });
-
- flash.flash('update path message');
-
- }
-
- function showTunnelInformationRemove(data) {
-
- wss.unbindHandlers(handlerMapRem);
- tunnelNameDataRemove = data;
- tds.openDialog()
- .setTitle('Available Tunnels for remove')
- .addContent(createUserTextRemove(data))
- .addOk(dOkRemove, 'OK')
- .addCancel(dClose, 'Close')
- .bindKeys();
- }
-
- function showTunnelInformationQuery(data) {
-
- wss.unbindHandlers(handlerMapshowQuery);
- tunnelNameDataQuery = data;
- tds.openDialog()
- .setTitle('Available Tunnels for highlight')
- .addContent(createUserTextQuery(data))
- .addOk(dOkQuery, 'OK')
- .addCancel(dClose, 'Close')
- .bindKeys();
- }
-
- function showTunnelInfoUpdateMsgHandle(data) {
-
- wss.unbindHandlers(handlerMapShowUpdate);
- tunnelDataUpdateInfo = data;
- tds.openDialog()
- .setTitle('Constrainst selection for update')
- .addContent(createUserTextUpdatePathEvent(data))
- .addOk(dOkUpdateEvent, 'OK')
- .addCancel(dClose, 'Close')
- .bindKeys();
- }
-
- //setup path
- function setMode(node) {
-
- function dOk() {
- var bandWidth = isChecked('band-width-box'),
- bandValue = null,
- bandType = null;
-
- if (bandWidth) {
- bandValue = getCheckedValue('band-width-value');
-
- if (isChecked('band-kpbs-val')) {
- bandType = 'kbps';
- } else if (isChecked('band-mpbs-val')) {
- bandType = 'mbps';
- } else if (isChecked('band-bps-val')) {
- bandType = 'bps';
- }
- }
-
- var costType = isChecked('pce-cost-type'),
- costTypeVal = null;
-
- if (costType) {
- if (isChecked('pce-cost-type-igp')) {
- costTypeVal = 'igp';
- } else if (isChecked('pce-cost-type-te')) {
- costTypeVal = 'te';
- }
- }
-
- var loadBalancedOption = isChecked('pce-load-balance');
-
- var lspTypeVal = null;
-
- if (isChecked('pce-lsp-type-cr')) {
- lspTypeVal = 'cr';
- } else if (isChecked('pce-lsp-type-srbe')) {
- lspTypeVal = 'srbe';
- } else if (isChecked('pce-lsp-type-srte')) {
- lspTypeVal = 'srte';
- }
-
- wss.sendEvent(setPathmsg, {
- srid: node[0],
- dsid: node[1],
- bw: bandValue,
- bwtype: bandType,
- ctype: costTypeVal,
- lb: loadBalancedOption,
- lsptype: lspTypeVal,
- tunnelname: getCheckedValue('pce-tunnel-name-id')
- });
-
- flash.flash('create path message');
- $log.debug('Dialog OK button clicked');
- }
-
- tds.openDialog()
- .setTitle('constraints selection')
- .addContent(createUserText())
- .addOk(dOk, 'OK')
- .addCancel(dClose, 'Close')
- .bindKeys();
- }
-
- function updatePath(node) {
-
- wss.sendEvent(updatePathmsgQuery, {
- srid: node[0],
- dsid: node[1]
- });
-
- handlerMap[showTunnelInfoMsg] = showTunnelInformation;
- wss.bindHandlers(handlerMap);
-
- flash.flash('update path message');
- }
-
- function dOkRemove() {
-
- for (var idx = 0; idx < tunnelNameDataRemove.a.length; idx++) {
- var tunnelNameVal = isChecked('tunnel-id-remove-'+idx);
- if (tunnelNameVal) {
- wss.sendEvent(remPathmsg, {
- tunnelid: tunnelNameDataRemove.a[idx],
- tunnelname: tunnelNameDataRemove.a[++idx]
- });
- }
- idx++;
- }
-
- flash.flash('remove path message');
- }
-
- function dOkQuery() {
-
- for (var idx = 0; idx < tunnelNameDataQuery.a.length; idx++) {
- var tunnelNameVal = isChecked('tunnel-id-query-'+idx);
- if (tunnelNameVal) {
- wss.sendEvent(showTunnelHighlightMsg, {
- tunnelid: tunnelNameDataQuery.a[idx],
- tunnelname: tunnelNameDataQuery.a[++idx]
- });
- }
- idx++;
- }
-
- flash.flash('query path message');
- }
-
- function remPath(node) {
- wss.sendEvent(remPathmsgQuery, {
- srid: node[0],
- dsid: node[1]
- });
-
- handlerMapRem[showTunnelInfoRemoveMsg] = showTunnelInformationRemove;
- wss.bindHandlers(handlerMapRem);
- }
-
- function queryTunnelDisplay() {
- handlerMapshowQuery[showTunnelInfoQuery] = showTunnelInformationQuery;
- wss.bindHandlers(handlerMapshowQuery);
-
- wss.sendEvent(queryDisplayTunnelMsg);
- }
- // === ---------------------------
- // === Module Factory Definition
-
- angular.module('ovPcewebTopov', [])
- .factory('PcewebTopovDemoService',
- ['$log', 'FnService', 'FlashService', 'WebSocketService',
- 'TopoPanelService', 'NavService', 'TopoDialogService', 'DialogService',
-
- function (_$log_, _fs_, _flash_, _wss_, _tps_, _ns_,_tds_, _ds_) {
- $log = _$log_;
- fs = _fs_;
- flash = _flash_;
- wss = _wss_;
- tps = _tps_;
- ns = _ns_;
- tds = _tds_;
- ds = _ds_;
-
- return {
- setSrc: setSrc,
- setDst: setDst,
- clear: clear,
- setMode: setMode,
- updatePath: updatePath,
- remPath: remPath,
- queryTunnelDisplay: queryTunnelDisplay
- };
- }]);
-}());
diff --git a/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopovOverlay.js b/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopovOverlay.js
deleted file mode 100644
index 02320b0..0000000
--- a/apps/pce/pceweb/src/main/resources/app/view/pcewebTopov/pcewebTopovOverlay.js
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// PCE web topology overlay - client side
-//
-// This is the glue that binds our business logic (in pcewebTopovDemo.js)
-// to the overlay framework.
-
-(function () {
- 'use strict';
-
- // injected refs
- var $log, tov, pps;
-
- // internal state should be kept in the service module (not here)
- var selection;
- // our overlay definition
- var overlay = {
- // NOTE: this must match the ID defined in AppUiTopovOverlay
- overlayId: 'PCE-web-overlay',
- glyphId: 'topo',
- tooltip: 'PCE web Topo Overlay',
-
- activate: function () {
- $log.debug("PCE web topology overlay ACTIVATED");
- },
- deactivate: function () {
- pps.clear();
- $log.debug("PCE web topology overlay DEACTIVATED");
- },
-
- // These glyphs get installed using the overlayId as a prefix.
- // e.g. 'src' is installed as 'PCE-web-overlay-src'
- // They can be referenced (from this overlay) as '*src'
- // That is, the '*' prefix stands in for 'PCE-web-overlay-'
- glyphs: {
- jp: {
- vb: '0 0 110 110',
- d: 'M84.3,89.3L58.9,64.2l-1.4,1.4L83,90.7L84.3,89.3z M27,7.6H7.4v19.2H27V7.6z' +
- 'M59.3,47.1H39.8v19.2h19.5V47.1z M102.1,79.5H82.6v19.2h19.5V79.5z M41.7,47.6L19,25.1l-1.2,1.2l22.7,22.5L41.7,47.6z'
- },
- },
-
- // Key bindings for PCE web overlay buttons
- // NOTE: fully qual. button ID is derived from overlay-id and key-name
- keyBindings: {
- 1: {
- cb: function () {
- pps.setMode(selection);
- },
- tt: 'Setup path',
- gid: 'plus'
- },
- 2: {
- cb: function () {
- pps.updatePath(selection);
- },
- tt: 'Update path',
- gid: '*jp'
- },
- 3: {
- cb: function () {
- pps.remPath(selection);
- },
- tt: 'Remove path',
- gid: 'minus'
- },
- 4: {
- cb: function () {
- pps.queryTunnelDisplay();
- },
- tt: 'Show Tunnels',
- gid: 'checkMark'
- },
-
- _keyOrder: [
- '1', '2', '3', '4'
- ]
- },
- hooks: {
- // hook for handling escape key
- // Must return true to consume ESC, false otherwise.
- escape: function () {
- selectionCallback();
- pps.setSrc();
- pps.setDst();
- return true;
- },
-
- // hooks for when the selection changes...
- empty: function () {
- selectionCallback();
- },
- single: function (data) {
- selectionCallback(data);
- },
- multi: function (selectOrder) {
- selectionCallback(selectOrder);
- },
- modifylinkdata: function (data, extra) {
- $log.debug("Modify link data", data, extra);
-
- function sep() {
- data.propOrder.push('-');
- }
-
- function add(key) {
- var val = extra[key];
- if (val !== undefined) {
- data.propOrder.push(key);
- data.props[key] = val;
- }
- }
-
- sep();
- add('Src Address');
- add('Dst Address');
- add('Te metric');
- add('Bandwidth');
-
- return data;
- }
- }
- };
-
- function selectionCallback(d) {
- $log.debug('Selection callback', d);
- selection = d;
- }
-
- // invoke code to register with the overlay service
- angular.module('ovPcewebTopov')
- .run(['$log', 'TopoOverlayService', 'PcewebTopovDemoService',
-
- function (_$log_, _tov_, _pps_) {
- $log = _$log_;
- tov = _tov_;
- pps = _pps_;
- tov.register(overlay);
- }]);
-
-}());
diff --git a/apps/pce/pceweb/src/main/resources/pcewebTopov/css.html b/apps/pce/pceweb/src/main/resources/pcewebTopov/css.html
deleted file mode 100644
index ea1b11d..0000000
--- a/apps/pce/pceweb/src/main/resources/pcewebTopov/css.html
+++ /dev/null
@@ -1 +0,0 @@
-<link rel="stylesheet" href="app/view/pcewebTopov/pcewebTopov.css">
\ No newline at end of file
diff --git a/apps/pce/pceweb/src/main/resources/pcewebTopov/js.html b/apps/pce/pceweb/src/main/resources/pcewebTopov/js.html
deleted file mode 100644
index 300dd7e..0000000
--- a/apps/pce/pceweb/src/main/resources/pcewebTopov/js.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<script src="app/view/pcewebTopov/pcewebTopovDemo.js"></script>
-<script src="app/view/pcewebTopov/pcewebTopovOverlay.js"></script>
diff --git a/apps/pcep-api/BUILD b/apps/pcep-api/BUILD
deleted file mode 100644
index b759412..0000000
--- a/apps/pcep-api/BUILD
+++ /dev/null
@@ -1,16 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + JACKSON + [
- "//protocols/ovsdb/api:onos-protocols-ovsdb-api",
- "//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc",
- "@jaxb_api//jar",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
-
-onos_app(
- category = "Protocol",
- description = "PCEP protocol API.",
- title = "PCEP Protocol API",
- url = "http://onosproject.org",
-)
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/DeviceCapability.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/api/DeviceCapability.java
deleted file mode 100644
index 6acee76..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/DeviceCapability.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.api;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.config.Config;
-
-/**
- * Configuration to specify device capabilities.
- */
-public class DeviceCapability extends Config<DeviceId> {
- public static final String SRCAP = "srCapabaility";
- public static final String LABELSTACKCAP = "labelStackCapability";
- public static final String LOCALLABELCAP = "localLabelCapability";
-
- @Override
- public boolean isValid() {
- return true;
- }
-
- /**
- * Gets the SR capability of the router.
- *
- * @return SR capability
- */
- public boolean srCap() {
- String srCap = get(SRCAP, null);
- return srCap != null ?
- Boolean.valueOf(srCap) :
- false;
- }
-
- /**
- * Gets the label stack capability of the router.
- *
- * @return label stack capability
- */
- public boolean labelStackCap() {
- String labelStackCap = get(LABELSTACKCAP, null);
- return labelStackCap != null ?
- Boolean.valueOf(labelStackCap) :
- false;
- }
-
- /**
- * Gets the local label capability of the router.
- *
- * @return local label capability
- */
- public boolean localLabelCap() {
- String localLabelCap = get(LOCALLABELCAP, null);
- return localLabelCap != null ?
- Boolean.valueOf(localLabelCap) :
- false;
- }
-
- /**
- * Sets the SR capability of the router.
- *
- * @param srCap SR capability of the router.
- * @return the capability configuration of the device.
- */
- public DeviceCapability setSrCap(boolean srCap) {
- return (DeviceCapability) setOrClear(SRCAP, srCap);
- }
-
- /**
- * Sets the label stack capability of the router.
- *
- * @param labelStackCap label stack capability of the router.
- * @return the capability configuration of the device.
- */
- public DeviceCapability setLabelStackCap(boolean labelStackCap) {
- return (DeviceCapability) setOrClear(LABELSTACKCAP, labelStackCap);
- }
-
- /**
- * Sets the local label capability of the router.
- *
- * @param localLabelCap local label capability of the router.
- * @return the capability configuration of the device.
- */
- public DeviceCapability setLocalLabelCap(boolean localLabelCap) {
- return (DeviceCapability) setOrClear(LOCALLABELCAP, localLabelCap);
- }
-}
-
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepController.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepController.java
deleted file mode 100644
index 74a2367..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepController.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.api;
-
-import org.onosproject.net.DeviceId;
-
-/**
- * Abstraction of an PCEP controller. Serves as a one stop shop for obtaining
- * PCEP devices and (un)register listeners on PCEP events
- */
-public interface PcepController {
-
- /**
- * Returns all switches known to this PCEP controller.
- *
- * @return Iterable of did elements
- */
- Iterable<PcepSwitch> getSwitches();
-
- /**
- * Return a switch with a specified did.
- *
- * @param did of a device
- * @return a pcep device
- */
- PcepSwitch getSwitch(PcepDpid did);
-
- /**
- * Register a listener for meta events that occur to PCEP devices.
- *
- * @param listener the listener to notify
- */
- void addListener(PcepSwitchListener listener);
-
- /**
- * Unregister a listener.
- *
- * @param listener the listener to unregister
- */
- void removeListener(PcepSwitchListener listener);
-
- /**
- * Register a listener for meta events that occur to PCEP links.
- *
- * @param listener the listener to notify
- */
- void addLinkListener(PcepLinkListener listener);
-
- /**
- * Unregister a link listener.
- *
- * @param listener the listener to unregister
- */
- void removeLinkListener(PcepLinkListener listener);
-
- /**
- * Register a listener for meta events that occur to PCEP tunnel.
- *
- * @param listener the listener to notify
- */
- void addTunnelListener(PcepTunnelListener listener);
-
- /**
- * Unregister a tunnel listener.
- *
- * @param listener the listener to unregister
- */
- void removeTunnelListener(PcepTunnelListener listener);
-
- /**
- * Setup a tunnel through pcep controller.
- *
- * @param srcDid src deviceId of tunnel
- * @param dstDid dst deviceId of tunnel
- * @param srcPort src port
- * @param dstPort dst port
- * @param bandwidth andwidth of tunnel
- * @param name tunnel name
- * @return pcep tunnel
- */
- PcepTunnel applyTunnel(DeviceId srcDid, DeviceId dstDid,
- long srcPort, long dstPort, long bandwidth,
- String name);
-
- /**
- * Delete tunnel by id.
- *
- * @param id pcep tunnel id.
- * @return true or false
- */
- Boolean deleteTunnel(String id);
-
- /**
- * Update tunnel bandwidth by tunnel id.
- *
- * @param id tunnel id
- * @param bandwidth bandwidth of a tunnel
- * @return true or false
- */
- Boolean updateTunnelBandwidth(String id, long bandwidth);
-
- /**
- * Send statistic request by tunnel id.
- *
- * @param pcepTunnelId PCEP tunnel id
- */
- void getTunnelStatistics(String pcepTunnelId);
-
-}
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepDpid.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepDpid.java
deleted file mode 100644
index 3ac5269..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepDpid.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.api;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.onosproject.pcep.tools.PcepTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The class representing a network switch PCEPDid. This class is immutable.
- */
-public final class PcepDpid {
- private static final Logger log = LoggerFactory.getLogger(PcepDpid.class);
- private static final String SCHEME = "l3";
- private static final long UNKNOWN = 0;
- private long nodeId;
-
- /**
- * Default constructor.
- */
- public PcepDpid() {
- this.nodeId = PcepDpid.UNKNOWN;
- }
-
- /**
- * Constructor from a long value.
- *
- * @param value long value for construct
- */
- public PcepDpid(long value) {
- this.nodeId = value;
- }
-
- /**
- * Constructor from a String.
- *
- * @param value string value for construct
- */
- public PcepDpid(String value) {
- this.nodeId = Long.parseLong(value, 16);
- }
-
- /**
- * Produces device URI from the given DPID.
- *
- * @param dpid device dpid
- * @return device URI
- */
- public static URI uri(PcepDpid dpid) {
- return uri(dpid.nodeId);
- }
-
- /**
- * Produces pcep URI.
- *
- * @param value string to get URI
- * @return pcep URI, otherwise null
- */
- public static URI uri(String value) {
- try {
- return new URI(SCHEME, value, null);
- } catch (URISyntaxException e) {
- log.debug("Exception PcepId URI: " + e.toString());
- }
- return null;
- }
-
- /**
- * Produces device long from the given string which comes from the uri
- * method.
- *
- * @param value string value which produced by uri method.
- * @return a long value.
- */
- public static long toLong(String value) {
- return PcepTools.ipToLong(value.replace(SCHEME, ""));
- }
-
- /**
- * Produces device URI from the given DPID long.
- *
- * @param value device dpid as long
- * @return device URI
- */
- public static URI uri(long value) {
- try {
- return new URI(SCHEME, PcepTools.longToIp(value), null);
- } catch (URISyntaxException e) {
- return null;
- }
- }
-
- /**
- * Return a device id with the form of long.
- *
- * @return long value
- */
- public long value() {
- return this.nodeId;
- }
-
-}
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepHopNodeDescription.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepHopNodeDescription.java
deleted file mode 100644
index 5b58cf2..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepHopNodeDescription.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.api;
-
-/**
- * Description of a pcep tunnel hop node.a hop list consists of a number of hop
- * node.
- */
-public class PcepHopNodeDescription {
- private PcepDpid deviceId;
- private long portNum;
-
- /**
- * Get the pcepdpid of a node.
- *
- * @return device pcepdpid.
- */
- public PcepDpid getDeviceId() {
- return deviceId;
- }
-
- /**
- * Set the pcepdpid of a node.
- *
- * @param deviceId pcep dpid of a node.
- */
- public void setDeviceId(PcepDpid deviceId) {
- this.deviceId = deviceId;
- }
-
- /**
- * Get the port number of a node.
- *
- * @return port number.
- */
- public long getPortNum() {
- return portNum;
- }
-
- /**
- * Set the port number of a node.
- *
- * @param portNum port number of a node.
- */
- public void setPortNum(long portNum) {
- this.portNum = portNum;
- }
-
-}
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepLink.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepLink.java
deleted file mode 100644
index a1e683f..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepLink.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.api;
-
-import org.onosproject.net.Port;
-
-/**
- * Abstraction of a network infrastructure link.
- */
-public interface PcepLink extends PcepOperator {
-
- enum SubType {
- /**
- * Optical Transmission Section Link.
- */
- OTS,
-
- /**
- * Optical Physical Section Link.
- */
- OPS,
-
- /**
- * User-to-Network Interface Link.
- */
- UNI,
-
- /**
- * Optical channel Data Unit-k link.
- */
- ODUk,
-
- /**
- * Optical Transport Network link.
- */
- OTU,
- }
-
-
- enum PortType {
- ODU_PORT, OCH_PORT, OMS_PORT
- }
-
- /**
- * Returns the link endpoint port type.
- *
- * @return endpoint port type
- */
- PortType portType();
-
- /**
- * Returns the link sub type,OTS,OPS,PKT_OPTICAL or ODUK.
- *
- * @return link subType
- */
-
- SubType linkSubType();
-
- /**
- * Returns the link state, up or down.
- *
- * @return link state
- */
- String linkState();
-
- /**
- * Returns the distance of a link.
- *
- * @return distance
- */
- int linkDistance();
-
- /**
- * Returns the capacity type of a link,1: WAVELENGTHNUM, 2:SLOTNUM, 3,
- * BANDWIDTH.
- *
- * @return capacity type
- */
- String linkCapacityType();
-
- /**
- * Returns the available capacity value ,such as available bandwidth.
- *
- * @return availValue
- */
- int linkAvailValue();
-
- /**
- * Returns the max capacity value ,such as max bandwidth.
- *
- * @return maxValue
- */
- int linkMaxValue();
-
- /**
- * Returns the source device did of a link.
- *
- * @return source did
- */
- PcepDpid linkSrcDeviceID();
-
- /**
- * Returns the destination device did of a link.
- *
- * @return destination did
- */
- PcepDpid linkDstDeviceId();
-
- /**
- * Returns the source port of a link.
- *
- * @return port number
- */
- Port linkSrcPort();
-
- /**
- * Returns the destination port of a link.
- *
- * @return port number
- */
- Port linkDstPort();
-
-}
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepLinkListener.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepLinkListener.java
deleted file mode 100644
index 6d1c268..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepLinkListener.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.api;
-
-/**
- * Allows for providers interested in Link events to be notified.
- */
-public interface PcepLinkListener {
-
- /**
- * Notify that get a packet of link from network and need do some
- * processing.
- *
- * @param link pcep link
- */
- void handlePceplink(PcepLink link);
-}
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepOperator.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepOperator.java
deleted file mode 100644
index ef8d7c3..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepOperator.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.api;
-
-/**
- * A interface defined operator type, and provide a method to get the operator
- * type.
- */
-public interface PcepOperator {
-
- enum OperationType {
-
- ADD, UPDATE, DELETE,
- }
-
- /**
- * Get operate type of a event,such as device add ,device update.
- *
- * @return operation type.
- */
- OperationType getOperationType();
-}
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepSwitch.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepSwitch.java
deleted file mode 100644
index 19aeff7..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepSwitch.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.api;
-
-/*
- * Represent to provider facing side of a switch
- */
-public interface PcepSwitch extends PcepOperator {
-
- enum DeviceType {
- /* optical device */
- ROADM,
-
- /* electronic device */
- OTN,
-
- /* router */
- ROUTER,
-
- /* unknown type */
- UNKNOW,
- }
-
- /**
- * Gets a string version of the ID for this switch.
- * @return string version of the ID
- */
- String getStringId();
-
- /**
- * Gets the datapathId of the switch.
- * @return the switch dpid in long format
- */
- long getId();
-
- long getNeId();
-
- /**
- * Gets the sub type of the device.
- * @return the sub type
- */
- DeviceType getDeviceType();
-
- /**
- * fetch the manufacturer description.
- * @return the description
- */
- String manufacturerDescription();
-
- /**
- * fetch the datapath description.
- * @return the description
- */
- String datapathDescription();
-
- /**
- * fetch the hardware description.
- * @return the description
- */
- String hardwareDescription();
-
- /**
- * fetch the software description.
- * @return the description
- */
- String softwareDescription();
-
- /**
- * fetch the serial number.
- * @return the serial
- */
- String serialNumber();
-
- /**
- * Indicates if this switch is optical.
- * @return true if optical
- */
- boolean isOptical();
-}
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepSwitchListener.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepSwitchListener.java
deleted file mode 100644
index ebe95dc..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepSwitchListener.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.api;
-
-/**
- * Notifies providers about switch in events.
- */
-public interface PcepSwitchListener {
-
- /**
- * Notify that the switch was added.
- *
- * @param dpid the switch where the event occurred
- */
- void switchAdded(PcepDpid dpid);
-
- /**
- * Notify that the switch was removed.
- *
- * @param dpid the switch where the event occurred.
- */
- void switchRemoved(PcepDpid dpid);
-
- /**
- * Notify that the switch has changed in some way.
- *
- * @param dpid the switch that changed
- */
- void switchChanged(PcepDpid dpid);
-
-}
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnel.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnel.java
deleted file mode 100644
index 4fc7a4c..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnel.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcep.api;
-
-import java.util.List;
-
-/**
- * Abstraction of a generalized PCEP Tunnel entity (bandwidth pipe) for L2
- * networks or L1/L0 networks, representation of e.g., VLAN, L1 ODUk connection,
- * WDM OCH, etc..
- */
-public interface PcepTunnel extends PcepOperator {
-
- /**
- * Describe the type of a tunnel.
- */
- enum Type {
-
- /**
- * Signifies that this is a L0 OCH tunnel.
- */
- OCH,
-
- /**
- * Signifies that this is a L1 OTN tunnel.
- */
- OTN,
-
- /**
- * Signifies that this is a L2 tunnel.
- */
- UNI,
- }
-
- /**
- * The ability of a tunnel.
- */
- enum Ability {
- /**
- * no protected tunnel,if the tunnel is broken ,then the user is out of
- * service.
- */
- NOPROTECTED,
-
- /**
- * tunnel with rerouter ability.if a tunnel is broken, the tunnel will
- * try to find another path to provider service.
- */
- SILVER,
-
- /**
- * tunnel with 1 + 1 rerouter ability.if a tunnel is broken, there'll be
- * another tunnel providing service at once.
- */
- DIAMOND
- }
-
- enum PathType {
-
- /**
- * Indicates path is the preferred path.
- */
- FIRST,
-
- /**
- * Indicates path is the alternate path.
- */
- SECOND
- }
-
- /**
- * Represents state of the path, work normally or broken down.
- */
- enum PathState {
- NORMAL, BROKEN
- }
-
- /**
- * Returns the type of a tunnel.
- *
- * @return tunnel type
- */
- Type type();
-
- /**
- * Returns the name of a tunnel.
- *
- * @return tunnel name
- */
- String name();
-
- /**
- * Returns the device id of destination endpoint of a tunnel.
- *
- * @return device id
- */
- PcepDpid srcDeviceID();
-
- /**
- * Returns the device id of source endpoint of a tunnel.
- *
- * @return device id
- */
- PcepDpid dstDeviceId();
-
- /**
- * Returns source port of a tunnel.
- *
- * @return port number
- */
- long srcPort();
-
- /**
- * Returns destination port of a tunnel.
- *
- * @return port number
- */
- long dstPort();
-
- /**
- * Returns the bandwidth of a tunnel.
- *
- * @return bandwidth
- */
- long bandWidth();
-
- /**
- * Returns the tunnel id.
- *
- * @return id of the PCEP tunnel
- */
- long id();
-
- /**
- * Returns the detail hop list of a tunnel.
- *
- * @return hop list
- */
- List<PcepHopNodeDescription> getHopList();
-
- /**
- * Returns the instance of a pcep tunnel,a instance is used to mark the times of
- * a tunnel created. instance and id identify a tunnel together.
- *
- * @return the instance of a tunnel.
- */
- int getInstance();
-
- /**
- * Returns the state of a path.
- *
- * @return normal or broken
- */
- PathState getPathState();
-
- /**
- * Returns the ability of a tunnel.
- *
- * @return ability of the tunenl
- */
- Ability getSla();
-
- /**
- * Returns the path type of a path if the tunnel's ability is diamond .
- *
- * @return the type of a path, the preferred or alternate.
- */
- PathType getPathType();
-
- /**
- * Get the under lay tunnel id of VLAN tunnel.
- *
- * @return the tunnel id of a OCH tunnel under lay of a VLAN tunnel.
- */
- long underlayTunnelId();
-
-}
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnelListener.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnelListener.java
deleted file mode 100644
index e522c4a..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnelListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.api;
-
-/**
- * Allows for providers interested in tunnel events to be notified.
- */
-public interface PcepTunnelListener {
-
- /**
- * Notify that get a packet of tunnel from network and need do some
- * processing.
- *
- * @param tunnel a pceptunnel.
- */
- void handlePcepTunnel(PcepTunnel tunnel);
-
- /**
- * Notify that get a tunnel statistic data from the network.
- *
- * @param tunnelStatistics tunnel statistic information.
- */
- void handlePcepTunnelStatistics(PcepTunnelStatistics tunnelStatistics);
-
-
-
-}
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnelStatistics.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnelStatistics.java
deleted file mode 100644
index e02bf03..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/PcepTunnelStatistics.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcep.api;
-
-import java.time.Duration;
-import java.util.List;
-
-/**
- * Statistics of a PCEP tunnel.
- */
-public interface PcepTunnelStatistics {
-
-
- /**
- * Returns the id of PCEP tunnel.
- *
- * @return PCEP tunnel id
- */
- long id();
-
-
- /**
- * Returns the bandwidth utilization of a PCEP tunnel.
- *
- * @return PCEP bandwidth utilization
- */
- double bandwidthUtilization();
-
- /**
- * Returns the flow loss rate of a tunnel.
- *
- * @return tunnel flow loss rate
- */
- double packetLossRate();
-
- /**
- * Returns the end-to-end traffic flow delay of a tunnel.
- *
- * @return tunnel traffic flow delay
- */
- Duration flowDelay();
-
- /**
- * Returns the alarms on a tunnel.
- *
- * @return tunnel alarms
- */
- List<String> alarms();
-}
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/TeLinkConfig.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/api/TeLinkConfig.java
deleted file mode 100644
index d446de1..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/TeLinkConfig.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.api;
-
-import org.onosproject.net.LinkKey;
-import org.onosproject.net.config.Config;
-
-/**
- * Configuration to specify traffic engineering parameters of the link.
- */
-public class TeLinkConfig extends Config<LinkKey> {
- public static final String MAX_RESV_BW = "maxRervableBandwidth";
- public static final String UNRESV_BWS = "unReservedBandwidths";
- public static final String IGP_COST = "igpCost";
- public static final String TE_COST = "teCost";
-
- @Override
- public boolean isValid() {
- return hasOnlyFields(MAX_RESV_BW, UNRESV_BWS, IGP_COST, TE_COST);
- }
-
- /**
- * Gets the maximum reservable bandwidth of the link.
- *
- * @return maximum reservable bandwidth
- */
- public Double maxResvBandwidth() {
-
- String resvBw = get(MAX_RESV_BW, null);
- return resvBw != null ?
- Double.valueOf(resvBw) :
- 0.0;
- }
-
- /**
- * Gets the set of unreserved bandwidth of the link.
- *
- * @return set of unreserved bandwidth
- */
- public Double unResvBandwidth() {
- String unResvBw = get(UNRESV_BWS, null);
- return unResvBw != null ? Double.valueOf(unResvBw) : 0.0;
- }
-
- /**
- * Gets the igp cost of the link.
- *
- * @return igp cost of the link
- */
- public int igpCost() {
- return get(IGP_COST, 0);
- }
-
- /**
- * Gets the te cost of the link.
- *
- * @return te cost of the link
- */
- public int teCost() {
- return get(TE_COST, 0);
- }
-
- /**
- * Sets the maximum reservable bandwidth of the link.
- *
- * @param maxResvBw maximum reservable bandwidth of link
- * @return te link configuration
- */
- public TeLinkConfig maxResvBandwidth(Double maxResvBw) {
- return (TeLinkConfig) setOrClear(MAX_RESV_BW, maxResvBw);
- }
-
- /**
- * Sets unreserved bandwidths of the link in priority order.
- *
- * @param unResvBw unreserved bandwidths of the link in priority order
- * @return te link configuration
- */
- public TeLinkConfig unResvBandwidth(Double unResvBw) {
- return (TeLinkConfig) setOrClear(UNRESV_BWS, unResvBw);
- }
-
- /**
- * Sets the igp cost of the link.
- *
- * @param igpCost igp cost of link
- * @return te link configuration
- */
- public TeLinkConfig igpCost(int igpCost) {
- return (TeLinkConfig) setOrClear(IGP_COST, igpCost);
- }
-
- /**
- * Sets the te cost of the link.
- *
- * @param teCost te cost of link
- * @return te link configuration
- */
- public TeLinkConfig teCost(int teCost) {
- return (TeLinkConfig) setOrClear(TE_COST, teCost);
- }
-
-
-}
-
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/package-info.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/api/package-info.java
deleted file mode 100644
index 2917bc9..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/api/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCEP controller API.
- */
-package org.onosproject.pcep.api;
\ No newline at end of file
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/tools/PcepTools.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/tools/PcepTools.java
deleted file mode 100644
index e123b5c..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/tools/PcepTools.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.tools;
-
-import javax.xml.bind.DatatypeConverter;
-
-/**
- * tools fo pcep app.
- */
-public abstract class PcepTools {
-
- private PcepTools() {
-
- }
-
- /**
- * Converts decimal byte array to a hex string.
- *
- * @param byteArray byte array
- * @return a hex string
- */
- public static String toHexString(byte[] byteArray) {
- return DatatypeConverter.printHexBinary(byteArray);
- }
-
- /**
- * Converts a hex string to a decimal byte array.
- *
- * @param hexString a hex string
- * @return byte array
- */
- public static byte[] toByteArray(String hexString) {
- return DatatypeConverter.parseHexBinary(hexString);
- }
-
- /**
- * Converts a byte array to a decimal string.
- *
- * @param bytes a byte array
- * @return a decimal string
- */
- public static String toDecimalString(byte[] bytes) {
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < bytes.length; i++) {
- buf.append(bytes[i]);
- }
- return buf.toString();
- }
-
- /**
- * convert a string to the form of ip address.
- *
- * @param str a string
- * @return a string with ip format
- */
- public static String stringToIp(String str) {
- long ipInt = Long.parseLong(str, 16);
- return longToIp(ipInt);
- }
-
- /**
- * convert a long to ip format.
- *
- * @param ipLong a decimal number.
- * @return a ip format string
- */
- public static String longToIp(long ipLong) {
- StringBuilder sb = new StringBuilder();
- sb.append((ipLong >> 24) & 0xFF).append(".");
- sb.append((ipLong >> 16) & 0xFF).append(".");
- sb.append((ipLong >> 8) & 0xFF).append(".");
- sb.append(ipLong & 0xFF);
- return sb.toString();
- }
-
- /**
- * convert a string with ip format to a long.
- *
- * @param strIp a string with ip format
- * @return a long number
- */
- public static long ipToLong(String strIp) {
- long[] ip = new long[4];
- int position1 = strIp.indexOf(".");
- int position2 = strIp.indexOf(".", position1 + 1);
- int position3 = strIp.indexOf(".", position2 + 1);
- ip[0] = Long.parseLong(strIp.substring(0, position1));
- ip[1] = Long.parseLong(strIp.substring(position1 + 1, position2));
- ip[2] = Long.parseLong(strIp.substring(position2 + 1, position3));
- ip[3] = Long.parseLong(strIp.substring(position3 + 1));
- return (ip[0] << 24) + (ip[1] << 16) + (ip[2] << 8) + ip[3];
- }
-
- /**
- * get a integer value from a cut string.
- *
- * @param str a whole string
- * @param base cut the string from this index
- * @param offset the offset when execute the cut
- * @return a integer value
- */
- public static int tranferHexStringToInt(String str, int base, int offset) {
- return Integer.parseInt(str.substring(base, offset), 16);
-
- }
-}
diff --git a/apps/pcep-api/src/main/java/org/onosproject/pcep/tools/package-info.java b/apps/pcep-api/src/main/java/org/onosproject/pcep/tools/package-info.java
deleted file mode 100644
index c3a52fb..0000000
--- a/apps/pcep-api/src/main/java/org/onosproject/pcep/tools/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * tools for pcep app.
- */
-package org.onosproject.pcep.tools;
\ No newline at end of file
diff --git a/apps/pcep-api/src/test/java/org/onosproject/pcep/api/PcepControllerAdapter.java b/apps/pcep-api/src/test/java/org/onosproject/pcep/api/PcepControllerAdapter.java
deleted file mode 100644
index 8163634..0000000
--- a/apps/pcep-api/src/test/java/org/onosproject/pcep/api/PcepControllerAdapter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcep.api;
-
-import org.onosproject.net.DeviceId;
-
-/**
- * Implementation of PCEP controller.
- */
-public class PcepControllerAdapter implements PcepController {
-
- @Override
- public Iterable<PcepSwitch> getSwitches() {
- return null;
- }
-
- @Override
- public PcepSwitch getSwitch(PcepDpid did) {
- return null;
- }
-
- @Override
- public void addListener(PcepSwitchListener listener) {
-
- }
-
- @Override
- public void removeListener(PcepSwitchListener listener) {
- }
-
- @Override
- public void addLinkListener(PcepLinkListener listener) {
- }
-
- @Override
- public void removeLinkListener(PcepLinkListener listener) {
- }
-
- @Override
- public void addTunnelListener(PcepTunnelListener listener) {
- }
-
- @Override
- public void removeTunnelListener(PcepTunnelListener listener) {
- }
-
- @Override
- public PcepTunnel applyTunnel(DeviceId srcDid, DeviceId dstDid, long srcPort, long dstPort, long bandwidth,
- String name) {
- return null;
- }
-
- @Override
- public Boolean deleteTunnel(String id) {
- return null;
- }
-
- @Override
- public Boolean updateTunnelBandwidth(String id, long bandwidth) {
- return null;
- }
-
- @Override
- public void getTunnelStatistics(String pcepTunnelId) {
-
- }
-}
diff --git a/apps/tenbi/topology/src/main/java/org/onosproject/tenbi/topology/impl/TeTopologyNbiManager.java b/apps/tenbi/topology/src/main/java/org/onosproject/tenbi/topology/impl/TeTopologyNbiManager.java
deleted file mode 100644
index 4c4d532..0000000
--- a/apps/tenbi/topology/src/main/java/org/onosproject/tenbi/topology/impl/TeTopologyNbiManager.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tenbi.topology.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onosproject.event.AbstractListenerManager;
-import org.onosproject.tetopology.management.api.TeTopologyEvent;
-import org.onosproject.tetopology.management.api.TeTopologyListener;
-import org.onosproject.tetopology.management.api.TeTopologyService;
-import org.onosproject.teyang.api.OperationType;
-import org.onosproject.teyang.utils.topology.NetworkConverter;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.IetfNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.IetfNetwork.OnosYangOpType;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.IetfNetworkOpParam;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.IetfNetworkService;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.Networks;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NetworksState;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.IetfNetworkTopology;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology
- .rev20151208.IetfNetworkTopologyOpParam;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology
- .rev20151208.IetfNetworkTopologyService;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.IetfTeTopology;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.IetfTeTopologyOpParam;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.IetfTeTopologyService;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology
- .IetfTeTopologyEvent;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology
- .IetfTeTopologyEventListener;
-import org.onosproject.yms.ymsm.YmsService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The IETF TE Topology NBI Manager implementation.
- */
-@Component(immediate = true, service = { IetfNetworkService.class, IetfNetworkTopologyService.class, IetfTeTopologyService.class })
-public class TeTopologyNbiManager
- extends AbstractListenerManager<IetfTeTopologyEvent, IetfTeTopologyEventListener>
- implements IetfNetworkService, IetfNetworkTopologyService, IetfTeTopologyService {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TeTopologyService teTopologyService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected YmsService ymsService;
-
-
- /**
- * Activation helper function.
- */
- private void activateBasics() {
- eventDispatcher.addSink(IetfTeTopologyEvent.class, listenerRegistry);
- }
-
- /**
- * Deactivation helper function.
- */
- private void deactivateBasics() {
- eventDispatcher.removeSink(IetfTeTopologyEvent.class);
- }
-
- @Activate
- protected void activate() {
- activateBasics();
-
- // Register 3 services with YMS.
- ymsService.registerService(this, IetfNetworkService.class, null);
- ymsService.registerService(this, IetfNetworkTopologyService.class, null);
- ymsService.registerService(this, IetfTeTopologyService.class, null);
-
- // Listens to TE Topology events
- teTopologyService.addListener(new InternalTeTopologyListener());
-
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- deactivateBasics();
-
- // Unregister 3 services.
- ymsService.unRegisterService(this, IetfNetworkService.class);
- ymsService.unRegisterService(this, IetfNetworkTopologyService.class);
- ymsService.unRegisterService(this, IetfTeTopologyService.class);
-
- teTopologyService.removeListener(new InternalTeTopologyListener());
- log.info("Stopped");
- }
-
- @Override
- public IetfNetwork getIetfNetwork(IetfNetworkOpParam ietfNetwork) {
- checkNotNull(ietfNetwork, "getIetfNetwork: ietfNetwork cannot be null");
-
- // Get the entire data tree from TE Subsystem core.
- org.onosproject.tetopology.management.api.Networks teNetworks = teTopologyService.networks();
-
- // Build the sample networks for RESTCONF/YMS integration test
-// org.onosproject.tetopology.management.api.Networks teNetworks = new DefaultNetworks(DefaultBuilder
-// .sampleDomain1Networks());
-
- // Convert the TE Subsystem core data into YANG Objects.
- Networks networks = NetworkConverter
- .teSubsystem2YangNetworks(teNetworks, OperationType.QUERY,
- teTopologyService);
- NetworksState networkStates = NetworkConverter.teSubsystem2YangNetworkStates(teNetworks, OperationType.QUERY);
-
- IetfNetworkOpParam.IetfNetworkBuilder builder = new IetfNetworkOpParam.IetfNetworkBuilder();
- IetfNetwork newNetwork = builder.networks(networks)
- .networksState(networkStates)
- .yangIetfNetworkOpType(OnosYangOpType.NONE)
- .build();
-
- // processSubtreeFiltering() filters the entire data tree based on the
- // user's query and returns the filtered data.
- IetfNetwork result = ietfNetwork.processSubtreeFiltering(
- newNetwork,
- false);
- log.debug("result is: {}", result);
- return result;
- }
-
- @Override
- public void setIetfNetwork(IetfNetworkOpParam ietfNetwork) {
- // In H release, topology is discovered from south, no NBI Set is supported.
- }
-
- @Override
- public IetfTeTopology getIetfTeTopology(IetfTeTopologyOpParam ietfTeTopology) {
- // unused method.
- return ietfTeTopology;
- }
-
- @Override
- public void setIetfTeTopology(IetfTeTopologyOpParam ietfTeTopology) {
- // unused methods.
- }
-
- @Override
- public IetfTeTopology getAugmentedIetfTeTopologyTeLinkEvent(IetfTeTopologyOpParam ietfTeTopology) {
- // unused methods.
- return ietfTeTopology;
- }
-
- @Override
- public void setAugmentedIetfTeTopologyTeLinkEvent(IetfTeTopologyOpParam augmentedIetfTeTopologyTeLinkEvent) {
- // unused methods.
- }
-
- @Override
- public IetfNetworkTopology getIetfNetworkTopology(IetfNetworkTopologyOpParam ietfNetworkTopology) {
- // unused methods.
- return ietfNetworkTopology;
- }
-
- @Override
- public void setIetfNetworkTopology(IetfNetworkTopologyOpParam ietfNetworkTopology) {
- // unused methods.
- }
-
- @Override
- public IetfNetwork getAugmentedIetfNetworkNetworks(IetfNetworkOpParam ietfNetwork) {
- // unused methods.
- return ietfNetwork;
- }
-
- @Override
- public void setAugmentedIetfNetworkNetworks(IetfNetworkOpParam augmentedIetfNetworkNetworks) {
- // unused methods.
- }
-
- private class InternalTeTopologyListener implements TeTopologyListener {
- @Override
- public void event(TeTopologyEvent event) {
- IetfTeTopologyEvent yangEvent = NetworkConverter
- .teTopoEvent2YangIetfTeTopoEvent(event, teTopologyService);
- post(yangEvent);
- }
- }
-}
diff --git a/apps/tenbi/topology/src/main/java/org/onosproject/tenbi/topology/impl/package-info.java b/apps/tenbi/topology/src/main/java/org/onosproject/tenbi/topology/impl/package-info.java
deleted file mode 100644
index 87c5e70..0000000
--- a/apps/tenbi/topology/src/main/java/org/onosproject/tenbi/topology/impl/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * The implementations of IETF TE Topology YANG NBI.
- */
-package org.onosproject.tenbi.topology.impl;
diff --git a/apps/tenbi/tunnel/src/main/java/org/onosproject/tenbi/tunnel/TeTunnelNbiManager.java b/apps/tenbi/tunnel/src/main/java/org/onosproject/tenbi/tunnel/TeTunnelNbiManager.java
deleted file mode 100644
index 4783d4a..0000000
--- a/apps/tenbi/tunnel/src/main/java/org/onosproject/tenbi/tunnel/TeTunnelNbiManager.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tenbi.tunnel;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onosproject.event.AbstractListenerManager;
-import org.onosproject.tetopology.management.api.TeTopology;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.TeTopologyService;
-import org.onosproject.tetunnel.api.TeTunnelAdminService;
-import org.onosproject.tetunnel.api.TeTunnelService;
-import org.onosproject.tetunnel.api.tunnel.DefaultTeTunnel;
-import org.onosproject.tetunnel.api.tunnel.TeTunnel;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.IetfTe;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.IetfTeOpParam;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.IetfTeService;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.IetfTeEvent;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.IetfTeEventListener;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelsgrouping.tunnels.Tunnel;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.IetfTeTypes;
-import org.onosproject.yms.ymsm.YmsService;
-import org.slf4j.Logger;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Optional;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.tetopology.management.api.TeTopology.BIT_MERGED;
-import static org.onosproject.teyang.utils.tunnel.TunnelConverter.buildIetfTeWithTunnels;
-import static org.onosproject.teyang.utils.tunnel.TunnelConverter.te2YangTunnelConverter;
-import static org.onosproject.teyang.utils.tunnel.TunnelConverter.yang2TeTunnel;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * The IETF TE Tunnel NBI Manager implementation.
- */
-@Component(immediate = true, service = IetfTeService.class)
-public class TeTunnelNbiManager
- extends AbstractListenerManager<IetfTeEvent, IetfTeEventListener>
- implements IetfTeService {
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected YmsService ymsService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TeTunnelService tunnelService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TeTopologyService toplogyService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TeTunnelAdminService tunnelAdminService;
-
- @Activate
- protected void activate() {
- ymsService.registerService(this, IetfTeService.class, null);
- ymsService.registerService(null, IetfTeTypes.class, null);
- log.info("started");
- }
-
- @Deactivate
- protected void deactivate() {
- ymsService.unRegisterService(this, IetfTeService.class);
- ymsService.unRegisterService(null, IetfTeTypes.class);
- log.info("stopped");
- }
-
- @Override
- public IetfTe getIetfTe(IetfTeOpParam ietfTe) {
- List<Tunnel> tunnels = new ArrayList<>();
- Collection<TeTunnel> teTunnels = tunnelService.getTeTunnels();
- teTunnels.forEach(teTunnel -> {
- Tunnel tunnel = te2YangTunnelConverter(teTunnel, false);
- tunnels.add(tunnel);
- });
- IetfTe newIetfTe = buildIetfTeWithTunnels(tunnels);
- return ietfTe.processSubtreeFiltering(newIetfTe, false);
- }
-
- @Override
- public void setIetfTe(IetfTeOpParam ietfTe) {
- checkNotNull(ietfTe, "Ietf te params should not be null");
- //FIXME use topology id configured by user
- // for there is no topology id param in the definition of te tunnel
- // we use the merged topology id as the default topology where we create
- // the tunnel, need to talk with the ietf-te draft writer.
- TeTopologyKey topologyKey = getTopologyKey();
- if (topologyKey == null) {
- log.error("No usable topology now!");
- return;
- }
-
- ietfTe.te().tunnels().tunnel().forEach(tunnel -> {
- DefaultTeTunnel teTunnel = yang2TeTunnel(tunnel, topologyKey);
- tunnelAdminService.createTeTunnel(teTunnel);
- });
- }
-
- @Override
- public void globalsRpc() {
-
- }
-
- @Override
- public void interfacesRpc() {
-
- }
-
- @Override
- public void tunnelsRpc() {
- //TODO add implement for the te tunnel rpc
- }
-
- private TeTopologyKey getTopologyKey() {
- TeTopologyKey key = null;
- Optional<TeTopology> teTopology = toplogyService
- .teTopologies()
- .teTopologies()
- .values()
- .stream()
- .filter(topology -> topology.flags().get(BIT_MERGED))
- .findFirst();
- if (teTopology.isPresent()) {
- TeTopology topology = teTopology.get();
- key = topology.teTopologyId();
- }
- return key;
- }
-}
diff --git a/apps/tenbi/tunnel/src/main/java/org/onosproject/tenbi/tunnel/package-info.java b/apps/tenbi/tunnel/src/main/java/org/onosproject/tenbi/tunnel/package-info.java
deleted file mode 100644
index ab2e599..0000000
--- a/apps/tenbi/tunnel/src/main/java/org/onosproject/tenbi/tunnel/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * The implementations of IETF TE Tunnel YANG NBI.
- */
-package org.onosproject.tenbi.tunnel;
\ No newline at end of file
diff --git a/apps/tenbi/tunnel/src/test/org/onosproject/tenbi/tunnel/TeTunnelNbiManagerTest.java b/apps/tenbi/tunnel/src/test/org/onosproject/tenbi/tunnel/TeTunnelNbiManagerTest.java
deleted file mode 100644
index 8ad125a..0000000
--- a/apps/tenbi/tunnel/src/test/org/onosproject/tenbi/tunnel/TeTunnelNbiManagerTest.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tenbi.tunnel;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.tetunnel.api.TeTunnelAdminService;
-import org.onosproject.tetunnel.api.TeTunnelService;
-import org.onosproject.tetunnel.api.lsp.TeLsp;
-import org.onosproject.tetunnel.api.lsp.TeLspKey;
-import org.onosproject.tetunnel.api.tunnel.DefaultTeTunnel;
-import org.onosproject.tetunnel.api.tunnel.TeTunnel;
-import org.onosproject.tetunnel.api.tunnel.TeTunnelKey;
-import org.onosproject.tetunnel.api.tunnel.path.DefaultTePath;
-import org.onosproject.tetunnel.api.tunnel.path.DefaultTeRouteUnnumberedLink;
-import org.onosproject.tetunnel.api.tunnel.path.TePath;
-import org.onosproject.tetunnel.api.tunnel.path.TeRouteSubobject;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev20130715.ietfinettypes.IpAddress;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.IetfTe;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.IetfTeOpParam;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.DefaultTe;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.Te;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.pathparamsconfig.Type;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.pathparamsconfig.type.DefaultExplicit;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.pathparamsconfig.type.explicit.DefaultExplicitRouteObjects;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.pathparamsconfig.type.explicit.ExplicitRouteObjects;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelproperties.Config;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelproperties.DefaultConfig;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelproperties.DefaultPrimaryPaths;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelproperties.PrimaryPaths;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelproperties.State;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelsgrouping.DefaultTunnels;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelsgrouping.Tunnels;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelsgrouping.tunnels.DefaultTunnel;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelsgrouping.tunnels.Tunnel;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.LspProtUnprotected;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.RouteIncludeEro;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.StateUp;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TunnelP2p;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.explicitroutesubobject.type.DefaultUnnumberedLink;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.onosproject.tetunnel.api.tunnel.TeTunnel.LspProtectionType.LSP_PROT_REROUTE;
-import static org.onosproject.tetunnel.api.tunnel.TeTunnel.Type.P2P;
-import static org.onosproject.tetunnel.api.tunnel.path.TeRouteSubobject.Type.UNNUMBERED_LINK;
-
-/**
- * Unit tests for TeTunnelNbiManager.
- */
-public class TeTunnelNbiManagerTest {
- private static final String TE_REQ_FAILED = "IETF TE reqeust failed: ";
- private static final String NAME = "testTunnel";
- private IpAddress srcIp = IpAddress.fromString("1.1.1.1");
- private IpAddress dstIp = IpAddress.fromString("2.2.2.2");
- private byte[] bytes1 = new byte[]{1, 1, 1, 1, 0, 0, 0, 0};
- private byte[] bytes2 = new byte[]{2, 2, 2, 2, 0, 0, 0, 0};
- private long id1 = 16843009;
- private long id2 = 33686018;
-
-
- private TeTunnelNbiManager manager;
- private TeTunnel testTeTunnel;
-
-
- @Before
- public void setUp() throws Exception {
- manager = new TeTunnelNbiManager();
- }
-
- @Test
- public void getIetfTe() throws Exception {
- TeTunnelService tunnelService = createMock(TeTunnelService.class);
- expect(tunnelService.getTeTunnels())
- .andReturn(ImmutableList.of(buildTunnel()))
- .once();
- replay(tunnelService);
-
- manager.tunnelService = tunnelService;
-
- IetfTe ietfTe = manager.getIetfTe((IetfTeOpParam) buildGetIetfTeParams());
-
- assertNotNull(TE_REQ_FAILED + "te null", ietfTe.te());
- assertNotNull(TE_REQ_FAILED + "tunnel null", ietfTe.te().tunnels());
-
- List<Tunnel> tunnelList = ietfTe.te().tunnels().tunnel();
- assertEquals(TE_REQ_FAILED + "wrong tunnel size", 1, tunnelList.size());
-
- Tunnel tunnel = tunnelList.get(0);
- List<PrimaryPaths> pathsList = tunnel.primaryPaths();
- assertNotNull(TE_REQ_FAILED + "path null", pathsList);
- assertEquals(TE_REQ_FAILED + "wrong path size", 1, pathsList.size());
-
- Type type = pathsList.get(0).state().type();
- assertTrue(TE_REQ_FAILED + "wrong path type",
- type instanceof DefaultExplicit);
- DefaultExplicit explicitPath = (DefaultExplicit) type;
- List<ExplicitRouteObjects> routeObjectses =
- explicitPath.explicitRouteObjects();
- assertEquals(TE_REQ_FAILED + "wrong route size", 2, routeObjectses.size());
-
- ExplicitRouteObjects routeObjects = routeObjectses.get(1);
- assertTrue(TE_REQ_FAILED + "wrong route object type",
- routeObjects.type() instanceof DefaultUnnumberedLink);
-
- DefaultUnnumberedLink link = (DefaultUnnumberedLink) routeObjects.type();
- assertEquals(TE_REQ_FAILED + "wrong route id",
- IpAddress.fromString("0.0.0.2"), link.routerId());
- assertEquals(TE_REQ_FAILED + "wrong interface id", 2, link.interfaceId());
-
- State state = tunnel.state();
- assertEquals(TE_REQ_FAILED + "wrong state",
- StateUp.class, state.adminStatus());
- assertEquals(TE_REQ_FAILED + "wrong source",
- IpAddress.fromString("0.0.0.1"), state.source());
- }
-
- @Test
- public void setIetfTe() throws Exception {
- manager.tunnelAdminService = new TestTunnelAdmin();
- manager.setIetfTe((IetfTeOpParam) buildPostIetfTeParams());
- assertEquals(NAME, testTeTunnel.name());
- List<TePath> tePaths = testTeTunnel.primaryPaths();
- assertEquals(1, tePaths.size());
- TePath tePath = tePaths.get(0);
- List<TeRouteSubobject> teRouteSubobjects = tePath.explicitRoute();
- assertEquals(2, teRouteSubobjects.size());
- TeRouteSubobject routeSubobject = teRouteSubobjects.get(1);
- assertEquals(UNNUMBERED_LINK, routeSubobject.type());
- DefaultTeRouteUnnumberedLink link =
- (DefaultTeRouteUnnumberedLink) routeSubobject;
- assertEquals(id2, link.node().teNodeId());
- assertEquals(id2, link.ttp().ttpId());
-
- }
-
- private IetfTe buildGetIetfTeParams() {
- Te te = new DefaultTe
- .TeBuilder()
- .yangTeOpType(IetfTe.OnosYangOpType.NONE)
- .build();
- return new IetfTeOpParam
- .IetfTeBuilder()
- .te(te)
- .yangIetfTeOpType(IetfTe.OnosYangOpType.NONE)
- .build();
- }
-
- private IetfTe buildPostIetfTeParams() {
- Tunnel tunnel = buildYangTunnel();
- Tunnels teTunnels = new DefaultTunnels
- .TunnelsBuilder()
- .tunnel(Lists.newArrayList(tunnel))
- .build();
- Te te = new DefaultTe
- .TeBuilder()
- .tunnels(teTunnels)
- .yangTeOpType(IetfTe.OnosYangOpType.NONE)
- .build();
- return new IetfTeOpParam
- .IetfTeBuilder()
- .te(te)
- .yangIetfTeOpType(IetfTe.OnosYangOpType.NONE)
- .build();
- }
-
- private Tunnel buildYangTunnel() {
- TeTunnel teTunnel = buildTunnel();
- checkNotNull(teTunnel);
- Config config = new DefaultConfig.ConfigBuilder()
- .name(NAME)
- .adminStatus(StateUp.class)
- .source(srcIp)
- .destination(dstIp)
- .srcTpId(bytes1)
- .dstTpId(bytes2)
- .type(TunnelP2p.class)
- .lspProtectionType(LspProtUnprotected.class)
- .build();
-
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.
- rev20160705.ietftetypes.explicitroutesubobject.type.
- UnnumberedLink yangLink1 = DefaultUnnumberedLink.builder()
- .routerId(srcIp)
- .interfaceId(id1)
- .build();
-
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.
- rev20160705.ietftetypes.explicitroutesubobject.type.
- UnnumberedLink yangLink2 = DefaultUnnumberedLink.builder()
- .routerId(dstIp)
- .interfaceId(id2)
- .build();
-
- ExplicitRouteObjects routeObject1 = DefaultExplicitRouteObjects.builder()
- .type(yangLink1)
- .explicitRouteUsage(RouteIncludeEro.class)
- .build();
-
- ExplicitRouteObjects routeObject2 = DefaultExplicitRouteObjects.builder()
- .type(yangLink2)
- .explicitRouteUsage(RouteIncludeEro.class)
- .build();
-
-
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.
- rev20160705.ietfte.pathparamsconfig.type.Explicit explicit
- = DefaultExplicit.builder()
- .explicitRouteObjects(ImmutableList.of(routeObject1, routeObject2))
- .build();
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.
- rev20160705.ietfte.p2pprimarypathparams.Config pathConfig
- = org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.
- te.rev20160705.ietfte.p2pprimarypathparams.DefaultConfig.builder()
- .pathNamedConstraint("onlyPath")
- .lockdown(true)
- .noCspf(true)
- .type(explicit)
- .build();
-
- PrimaryPaths primaryPaths = DefaultPrimaryPaths.builder()
- .config(pathConfig).build();
-
- return DefaultTunnel.builder()
- .name(config.name())
- .type(config.type())
- .config(config)
- .primaryPaths(Lists.newArrayList(primaryPaths))
- .build();
- }
-
- private TeTunnel buildTunnel() {
- TeTopologyKey topologyKey = new TeTopologyKey(1, 2, 3);
- TeTunnelKey teTunnelKey = new TeTunnelKey(topologyKey, 1);
-
- TeNodeKey srcNodeKey = new TeNodeKey(topologyKey, 1);
- TeNodeKey dstNodeKey = new TeNodeKey(topologyKey, 2);
-
- TtpKey srcTtpKey = new TtpKey(srcNodeKey, 1);
- TtpKey dstTtpKey = new TtpKey(srcNodeKey, 2);
-
- TeLspKey lspKey = new TeLspKey(teTunnelKey, 1);
-
- DefaultTeRouteUnnumberedLink unnumberedLink1 =
- new DefaultTeRouteUnnumberedLink(srcNodeKey, srcTtpKey);
- DefaultTeRouteUnnumberedLink unnumberedLink2 =
- new DefaultTeRouteUnnumberedLink(dstNodeKey, dstTtpKey);
- List<TeRouteSubobject> explicitRouteList = new ArrayList<>();
-
- explicitRouteList.add(unnumberedLink1);
- explicitRouteList.add(unnumberedLink2);
- TePath tePath = new DefaultTePath(TePath.Type.EXPLICIT,
- Lists.newArrayList(lspKey),
- explicitRouteList,
- Lists.newArrayList());
-
- return DefaultTeTunnel.builder()
- .teTunnelKey(teTunnelKey)
- .name(NAME)
- .type(P2P)
- .adminState(TeTunnel.State.UP)
- .srcNode(srcNodeKey)
- .dstNode(dstNodeKey)
- .srcTp(srcTtpKey)
- .dstTp(dstTtpKey)
- .lspProtectionType(LSP_PROT_REROUTE)
- .primaryPaths(Lists.newArrayList(tePath))
- .build();
- }
-
- private class TestTunnelAdmin implements TeTunnelAdminService {
-
- @Override
- public TunnelId createTeTunnel(TeTunnel teTunnel) {
- TunnelId tunnelId = TunnelId.valueOf(teTunnel.teTunnelKey().toString());
- testTeTunnel = teTunnel;
- return tunnelId;
- }
-
- @Override
- public void setTunnelId(TeTunnelKey teTunnelKey, TunnelId tunnelId) {
-
- }
-
- @Override
- public void updateTeTunnel(TeTunnel teTunnel) {
-
- }
-
- @Override
- public void updateTunnelState(TeTunnelKey key, org.onosproject.incubator.net.tunnel.Tunnel.State state) {
-
- }
-
- @Override
- public void removeTeTunnel(TeTunnelKey teTunnelKey) {
-
- }
-
- @Override
- public void removeTeTunnels() {
-
- }
-
- @Override
- public void setSegmentTunnel(TeTunnelKey e2eTunnelKey, List<TeTunnelKey> segmentTunnels) {
-
- }
-
- @Override
- public TeTunnel getTeTunnel(TeTunnelKey teTunnelKey) {
- return null;
- }
-
- @Override
- public TeTunnel getTeTunnel(TunnelId tunnelId) {
- return null;
- }
-
- @Override
- public TunnelId getTunnelId(TeTunnelKey teTunnelKey) {
- return null;
- }
-
- @Override
- public Collection<TeTunnel> getTeTunnels() {
- return null;
- }
-
- @Override
- public Collection<TeTunnel> getTeTunnels(TeTunnel.Type type) {
- return null;
- }
-
- @Override
- public Collection<TeTunnel> getTeTunnels(TeTopologyKey teTopologyKey) {
- return null;
- }
-
- @Override
- public TeLsp getTeLsp(TeLspKey key) {
- return null;
- }
-
- @Override
- public Collection<TeLsp> getTeLsps() {
- return null;
- }
- }
-
-}
\ No newline at end of file
diff --git a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/api/OperationType.java b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/api/OperationType.java
deleted file mode 100644
index 01f938f..0000000
--- a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/api/OperationType.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.teyang.api;
-
-/**
- * The operation type.
- */
-public enum OperationType {
-
- /**
- * The configuration data identified by the element
- * containing this attribute is merged with the configuration
- * at the corresponding level in the configuration datastore.
- */
- MERGE,
-
- /**
- * The configuration data identified by the element
- * containing this attribute replaces any related configuration
- * in the configuration datastore. If no such configuration
- * data exists in the configuration datastore, it is created.
- */
- REPLACE,
-
- /**
- * The configuration data identified by the element
- * containing this attribute is added to the configuration if
- * and only if the configuration data does not already exist in
- * the configuration datastore. If the configuration data
- * exists, an error is returned.
- */
- CREATE,
-
- /**
- * The configuration data identified by the element
- * containing this attribute is deleted from the configuration
- * if and only if the configuration data currently exists in
- * the configuration datastore. If the configuration data does
- * not exist, an error is returned".
- */
- DELETE,
-
- /**
- * The configuration data identified by the element
- * containing this attribute is deleted from the configuration
- * if the configuration data currently exists in the
- * configuration datastore. If the configuration data does not
- * exist, the "remove" operation is silently ignored by the
- * server.
- */
- REMOVE,
-
- /**
- * The node is used as a containment node to reach the child node,
- * There is no change in the data store for the values of this node in the
- * edit request.
- */
- NONE,
-
-// /**
-// * The YANG based request is to edit a config node / subtree in the data
-// * store.
-// */
-// EDIT_CONFIG,
-//
-// /**
-// * The YANG based request is to query a config node / subtree in the data
-// * store.
-// */
-// QUERY_CONFIG,
-//
- /**
- * The YANG based request is to query a node / subtree in the data store.
- */
- QUERY,
-
-// /**
-// * The YANG based request is to execute an RPC defined in YANG.
-// */
-// RPC,
-//
-// /**
-// * The YANG based request is to execute an RPC defined in YANG.
-// */
-// NOTIFICATION
-}
diff --git a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/api/package-info.java b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/api/package-info.java
deleted file mode 100644
index 9b1161a..0000000
--- a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/api/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * The utility APIs.
- */
-package org.onosproject.teyang.api;
diff --git a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/EnumConverter.java b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/EnumConverter.java
deleted file mode 100644
index d98cade..0000000
--- a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/EnumConverter.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.teyang.utils.topology;
-
-import org.onosproject.tetopology.management.api.TeStatus;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeAdminStatus;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeOperStatus;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.teadminstatus.TeAdminStatusEnum;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.teoperstatus.TeOperStatusEnum;
-
-/**
- * The Enum conversion functions.
- */
-public final class EnumConverter {
-
- // no instantiation
- private EnumConverter() {
- }
-
- /**
- * Converts YANG Operation Status Enum to TE Topology TeStatus Enum.
- *
- * @param opStatus YANG Operation Status
- * @return the equivalent Enum from TE Topology TeStatus or null if not
- * found
- */
- public static TeStatus yang2TeSubsystemOpStatus(TeOperStatus opStatus) {
- if (opStatus == null) {
- return null;
- }
-
- switch (opStatus.enumeration()) {
- case DOWN:
- return TeStatus.DOWN;
- case UP:
- return TeStatus.UP;
- case MAINTENANCE:
- return TeStatus.MAINTENANCE;
- case PREPARING_MAINTENANCE:
- return TeStatus.PREPARING_MAINTENANCE;
- case TESTING:
- return TeStatus.TESTING;
- case UNKNOWN:
- return TeStatus.UNKNOWN;
- default:
- return null;
- }
- }
-
- /**
- * Converts YANG TeAdminStatus Enum to TE Topology TeStatus Enum.
- *
- * @param adminStatus YANG Admin Status
- * @return the equivalent Enum from TE Topology TeStatus or null if not
- * found
- */
- public static TeStatus yang2TeSubsystemAdminStatus(TeAdminStatus adminStatus) {
- if (adminStatus == null) {
- return TeStatus.UNKNOWN;
- }
-
- switch (adminStatus.enumeration()) {
- case DOWN:
- return TeStatus.DOWN;
- case UP:
- return TeStatus.UP;
- case TESTING:
- return TeStatus.TESTING;
- case MAINTENANCE:
- return TeStatus.MAINTENANCE;
- case PREPARING_MAINTENANCE:
- return TeStatus.PREPARING_MAINTENANCE;
- default:
- return TeStatus.UNKNOWN;
- }
- }
-
- /**
- * Converts TE Topology TeStatus Enum to YANG TeAdminStatus Enum.
- *
- * @param adminStatus TE Topology admin status
- * @return the equivalent Enum from YANG TeAdminStatus or null if not found
- */
- public static TeAdminStatus teSubsystem2YangAdminStatus(TeStatus adminStatus) {
- if (adminStatus == null) {
- return null;
- }
-
- switch (adminStatus) {
- case DOWN:
- return TeAdminStatus.of(TeAdminStatusEnum.DOWN);
- case UP:
- return TeAdminStatus.of(TeAdminStatusEnum.UP);
- case TESTING:
- return TeAdminStatus.of(TeAdminStatusEnum.TESTING);
- case MAINTENANCE:
- return TeAdminStatus.of(TeAdminStatusEnum.MAINTENANCE);
- case PREPARING_MAINTENANCE:
- return TeAdminStatus.of(TeAdminStatusEnum.PREPARING_MAINTENANCE);
- case UNKNOWN:
- return null;
- default:
- return null;
- }
- }
-
- /**
- * Converts TE Topology TeStatus Enum to YANG TeOperStatus Enum.
- *
- * @param opStatus TE Topology operation status
- * @return the equivalent Enum from YANG TeOperStatus or null if not found
- */
- public static TeOperStatus teSubsystem2YangOperStatus(TeStatus opStatus) {
- if (opStatus == null) {
- return null;
- }
-
- switch (opStatus) {
- case DOWN:
- return TeOperStatus.of(TeOperStatusEnum.DOWN);
- case UP:
- return TeOperStatus.of(TeOperStatusEnum.UP);
- case TESTING:
- return TeOperStatus.of(TeOperStatusEnum.TESTING);
- case MAINTENANCE:
- return TeOperStatus.of(TeOperStatusEnum.MAINTENANCE);
- case PREPARING_MAINTENANCE:
- return TeOperStatus.of(TeOperStatusEnum.PREPARING_MAINTENANCE);
- case UNKNOWN:
- return TeOperStatus.of(TeOperStatusEnum.UNKNOWN);
- default:
- return null;
- }
- }
-
-}
\ No newline at end of file
diff --git a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/LinkConverter.java b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/LinkConverter.java
deleted file mode 100644
index 31ebaa3..0000000
--- a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/LinkConverter.java
+++ /dev/null
@@ -1,1147 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.teyang.utils.topology;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.tetopology.management.api.TeConstants.MAX_PRIORITY;
-
-import java.math.BigInteger;
-import java.util.BitSet;
-import java.util.List;
-
-import org.onlab.packet.Ip4Address;
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.TeStatus;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.TeTopologyService;
-import org.onosproject.tetopology.management.api.link.CommonLinkData;
-import org.onosproject.tetopology.management.api.link.DefaultNetworkLink;
-import org.onosproject.tetopology.management.api.link.DefaultTeLink;
-import org.onosproject.tetopology.management.api.link.ElementType;
-import org.onosproject.tetopology.management.api.link.ExternalLink;
-import org.onosproject.tetopology.management.api.link.LinkBandwidth;
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.link.NetworkLinkEventSubject;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.link.PathElement;
-import org.onosproject.tetopology.management.api.link.TeLink;
-import org.onosproject.tetopology.management.api.link.TeLinkId;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.link.TeLinkTpKey;
-import org.onosproject.tetopology.management.api.link.TePathAttributes;
-import org.onosproject.tetopology.management.api.link.TeTunnelId;
-import org.onosproject.tetopology.management.api.link.TunnelProtectionType;
-import org.onosproject.tetopology.management.api.link.UnderlayBackupPath;
-import org.onosproject.tetopology.management.api.link.UnderlayPath;
-import org.onosproject.tetopology.management.api.node.NodeTpKey;
-import org.onosproject.tetopology.management.api.node.TeNode;
-import org.onosproject.tetopology.management.api.node.TerminationPointKey;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev20130715.ietfinettypes.IpAddress;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NetworkId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.Networks;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NodeId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks.Network;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks.network.Node;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.LinkId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.TpId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.ietfnetworktopology.networks.network.AugmentedNdNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.augmentedndnetwork.DefaultLink;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.augmentedndnetwork.DefaultLink.LinkBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.augmentedndnetwork.Link;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.augmentedndnetwork.link.DefaultDestination;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.augmentedndnetwork.link.DefaultSource;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.augmentedndnetwork.link.DefaultSupportingLink;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.augmentedndnetwork.link.Destination
- .DestinationBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.augmentedndnetwork.link.Source.SourceBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.augmentedndnetwork.link.SupportingLink;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.augmentedndnetwork.link.SupportingLink
- .SupportingLinkBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.ietfnetworktopology.networks.network.node.AugmentedNdNode;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.DefaultTeLinkEvent;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.TeBandwidth;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.TeLinkEvent;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.informationsourceperlinkattributes.DefaultInformationSourceState;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.informationsourceperlinkattributes.InformationSourceState;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.informationsourceperlinkattributes.informationsourcestate.DefaultTopology;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.informationsourceperlinkattributes.informationsourcestate.Topology;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.networks.network.AugmentedNwNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.networks.network.link.AugmentedNtLink;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.networks.network.link.DefaultAugmentedNtLink;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.networks.network.link.DefaultAugmentedNtLink.AugmentedNtLinkBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.networks.network.node.AugmentedNwNode;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.networks.network.node.terminationpoint.AugmentedNtTerminationPoint;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkaugment.DefaultTe;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkaugment.DefaultTe.TeBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkaugment.te.Config;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkaugment.te.DefaultConfig;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkaugment.te.DefaultConfig.ConfigBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkaugment.te.DefaultState;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkaugment.te.DefaultState.StateBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkaugment.te.State;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconfigattributes.DefaultTeLinkAttributes;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconfigattributes.DefaultTeLinkAttributes.TeLinkAttributesBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconfigattributes.TeLinkAttributes;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconfigattributes.telinkattributes.DefaultExternalDomain;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconfigattributes.telinkattributes.DefaultExternalDomain.ExternalDomainBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconfigattributes.telinkattributes.DefaultUnderlay;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconfigattributes.telinkattributes.DefaultUnderlay.UnderlayBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconfigattributes.telinkattributes.ExternalDomain;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconnectivityattributes.DefaultTeSrlgs;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconnectivityattributes.DefaultTeSrlgs.TeSrlgsBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconnectivityattributes.DefaultUnreservedBandwidth;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconnectivityattributes.DefaultUnreservedBandwidth.UnreservedBandwidthBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconnectivityattributes.TeSrlgs;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconnectivityattributes.UnreservedBandwidth;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkinfoattributes.LinkProtectionTypeEnum;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkunderlayattributes.DefaultBackupPath;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkunderlayattributes.DefaultBackupPath.BackupPathBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkunderlayattributes.DefaultPrimaryPath;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkunderlayattributes.DefaultPrimaryPath.PrimaryPathBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkunderlayattributes.PrimaryPath;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkunderlayattributes.primarypath.DefaultPathElement;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.Srlg;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeNodeId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeOperStatus;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeTopologyEventType;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeTpId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.explicitroutesubobject.type.DefaultUnnumberedLink;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.explicitroutesubobject.type.DefaultUnnumberedLink.UnnumberedLinkBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.explicitroutesubobject.type.UnnumberedLink;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.tetopologyeventtype.TeTopologyEventTypeEnum;
-
-import com.google.common.collect.Lists;
-
-/**
- * The conversion functions.
- */
-public final class LinkConverter {
- private static final String E_NULL_TELINK_UNDERLAY_PATH =
- "TeSubsystem link underlayPath object cannot be null";
- private static final String E_NULL_TELINK_DATA =
- "TeSubsystem teLinkAttrBuilder data cannot be null";
- private static final String E_NULL_TELINK =
- "TeSubsystem teLink object cannot be null";
- private static final String E_NULL_YANG_TELINK_CONFIG =
- "YANG telink config object cannot be null";
- private static final String E_NULL_YANG_TELINK =
- "YANG Link object cannot be null";
-
- // no instantiation
- private LinkConverter() {
- }
-
- private static LinkProtectionTypeEnum teSubsystem2YangLinkProtectionType(TunnelProtectionType linkProtectionType) {
- switch (linkProtectionType) {
- case ENHANCED:
- return LinkProtectionTypeEnum.ENHANCED;
- case EXTRA_TRAFFIC:
- return LinkProtectionTypeEnum.EXTRA_TRAFFIC;
- case SHARED:
- return LinkProtectionTypeEnum.SHARED;
- case UNPROTECTED:
- return LinkProtectionTypeEnum.UNPROTECTED;
- case ONE_FOR_ONE:
- return LinkProtectionTypeEnum.YANGAUTOPREFIX1_FOR_1;
- case ONE_PLUS_ONE:
- return LinkProtectionTypeEnum.YANGAUTOPREFIX1_PLUS_1;
- default:
- return null;
- }
- }
- /**
- * TE Link Config object conversion from TE Topology subsystem to YANG.
- *
- * @param teLink TE link object
- * @return TE Link Config YANG object
- */
- private static Config teLink2YangConfig(TeLink teLink, TeTopologyService teTopologyService) {
- checkNotNull(teLink, E_NULL_TELINK_DATA);
-
- TeLinkAttributesBuilder attrBuilder = DefaultTeLinkAttributes.builder();
-
- if (teLink.teLinkKey() != null) {
- // what is link index? for now I used teLinkTpId
- attrBuilder = attrBuilder.linkIndex(BigInteger.valueOf(teLink.teLinkKey().teLinkTpId()));
- }
-
- if (teLink.adminStatus() != null) {
- attrBuilder = attrBuilder.adminStatus(EnumConverter.teSubsystem2YangAdminStatus(teLink.adminStatus()));
- }
-
- if (teLink.tunnelProtectionType() != null) {
- attrBuilder = attrBuilder
- .linkProtectionType(teSubsystem2YangLinkProtectionType(teLink
- .tunnelProtectionType()));
- }
-
- attrBuilder = attrBuilder.teDefaultMetric(teLink.cost());
-
- if (teLink.srlgs() != null) {
- TeSrlgsBuilder teSrlgsBuilder = DefaultTeSrlgs.builder();
- for (Long srlgLongVal : teLink.srlgs()) {
- teSrlgsBuilder = teSrlgsBuilder.addToValue(new Srlg(srlgLongVal));
- }
- attrBuilder = attrBuilder.teSrlgs(teSrlgsBuilder.build());
- }
- attrBuilder = attrBuilder.isAbstract(teLink.flags().get(TeNode.BIT_ABSTRACT));
-
- if (teLink.externalLink() != null) {
- ExternalDomainBuilder edBuilder =
- DefaultExternalDomain.builder();
- if (teLink.externalLink().plugId() != null) {
- edBuilder.plugId(teLink.externalLink().plugId());
- }
- if (teLink.externalLink().externalLinkKey() != null) {
- edBuilder = edBuilder
- .remoteTeLinkTpId(TeTpId.fromString(String.valueOf(teLink
- .externalLink()
- .externalLinkKey()
- .teLinkTpId())))
- .remoteTeNodeId(TeNodeId.fromString(String.valueOf(teLink
- .externalLink()
- .externalLinkKey()
- .teNodeId())));
- }
- attrBuilder = attrBuilder.externalDomain(edBuilder.build());
- }
-
- if (teLink.availBandwidth() != null) {
- for (short i = 0; i < teLink.availBandwidth().length; i++) {
- UnreservedBandwidthBuilder urBuilder =
- DefaultUnreservedBandwidth.builder()
- .bandwidth(TeBandwidth.fromString(String
- .valueOf(teLink.availBandwidth()[i])))
- .priority(i);
- attrBuilder = attrBuilder.addToUnreservedBandwidth(urBuilder.build());
- }
- }
-
- if (teLink.maxBandwidth() != null) {
- // maxBandwidth is an array of float[], but in yang is just a big decimal
- attrBuilder = attrBuilder.maxLinkBandwidth(TeBandwidth
- .fromString(String.valueOf(teLink.maxBandwidth()[0])));
- }
- // FIXME: how to retrieve maxResvLinkBandwidth from teLink
-// if (teLink.maxResvLinkBandwidth() != null) {
-// attrBuilder = attrBuilder.maxResvLinkBandwidth(teLink.maxResvLinkBandwidth());
-// }
-
- if (teLink.primaryPath() != null || teLink.backupPaths() != null) {
- UnderlayBuilder builder = DefaultUnderlay.builder();
- if (teLink.primaryPath() != null) {
- // TODO: what is underlayProtectionType in tePath?
- // builder =
- // builder.underlayProtectionType(tePath.protectionType());
- builder = te2YangConfigUnderlayPrimaryPath(builder, teLink,
- teTopologyService);
- }
-
- if (teLink.backupPaths() != null) {
- builder = te2YangConfigUnderlayBackupPaths(builder, teLink,
- teTopologyService);
- }
-
- attrBuilder = attrBuilder.underlay(builder.build());
- }
-
-
- ConfigBuilder yangConfigBuilder = DefaultConfig.builder()
- .teLinkAttributes(attrBuilder.build());
- return yangConfigBuilder.build();
- }
-
- /**
- * TE Link State object conversion from TE Topology subsystem to YANG.
- *
- * @param teLink TE link object
- * @param teTopologyService TE Topology Service object
- * @return TE Link State YANG object
- */
- private static State teLink2YangState(TeLink teLink, TeTopologyService teTopologyService) {
- TeLinkAttributes
- .TeLinkAttributesBuilder attrBuilder =
- DefaultTeLinkAttributes
- .builder()
- .teDefaultMetric(teLink.cost())
- .isAbstract(teLink.flags().get(TeLink.BIT_ABSTRACT));
- if (teLink.teLinkKey() != null) {
- // what is link index? for now I used teLinkTpId
- attrBuilder = attrBuilder.linkIndex(BigInteger.valueOf(teLink.teLinkKey().teLinkTpId()));
- }
-
- if (teLink.adminStatus() != null) {
- attrBuilder = attrBuilder.adminStatus(EnumConverter.teSubsystem2YangAdminStatus(teLink.adminStatus()));
- }
- if (teLink.tunnelProtectionType() != null) {
- attrBuilder = attrBuilder
- .linkProtectionType(teSubsystem2YangLinkProtectionType(teLink
- .tunnelProtectionType()));
- }
- if (teLink.maxBandwidth() != null) {
- // maxBandwidth is an array of float[], but in yang is just a big decimal
- attrBuilder = attrBuilder.maxLinkBandwidth(TeBandwidth
- .fromString(String.valueOf(teLink.maxBandwidth()[0])));
- }
-// if (teLink.maxResvLinkBandwidth() != null) {
-// attrBuilder = attrBuilder.maxResvLinkBandwidth(teLink.maxResvLinkBandwidth());
-// }
- if (teLink.srlgs() != null) {
- TeSrlgs.TeSrlgsBuilder srlgsBuilder = DefaultTeSrlgs.builder();
- for (Long srlgLongVal : teLink.srlgs()) {
- srlgsBuilder = srlgsBuilder.addToValue(new Srlg(srlgLongVal));
- }
- attrBuilder = attrBuilder.teSrlgs(srlgsBuilder.build());
- }
-
- if (teLink.externalLink() != null) {
- ExternalDomain.ExternalDomainBuilder edBuilder = DefaultExternalDomain
- .builder();
- if (teLink.externalLink().plugId() != null) {
- edBuilder = edBuilder.plugId(teLink.externalLink().plugId());
- }
- if (teLink.externalLink().externalLinkKey() != null) {
- edBuilder = edBuilder
- .remoteTeLinkTpId(TeTpId.fromString(String.valueOf(teLink
- .externalLink()
- .externalLinkKey()
- .teLinkTpId())))
- .remoteTeNodeId(TeNodeId.fromString(String.valueOf(teLink
- .externalLink()
- .externalLinkKey()
- .teNodeId())));
- }
- attrBuilder = attrBuilder.externalDomain(edBuilder.build());
-
- }
-
- if (teLink.availBandwidth() != null) {
- short i = 0;
- for (float f : teLink.availBandwidth()) {
- UnreservedBandwidth.UnreservedBandwidthBuilder urBuilder = DefaultUnreservedBandwidth
- .builder()
- .bandwidth(TeBandwidth.fromString(String.valueOf(f)))
- .priority(i);
- i++;
- attrBuilder = attrBuilder.addToUnreservedBandwidth(urBuilder.build());
- }
- }
-
- StateBuilder yangStateBuilder = DefaultState.builder()
- .teLinkAttributes(attrBuilder.build());
- if (teLink.opStatus() != null) {
- yangStateBuilder = yangStateBuilder.operStatus(EnumConverter
- .teSubsystem2YangOperStatus(teLink.opStatus()));
- }
-
- if (teLink.sourceTeLinkId() != null) {
- InformationSourceState.InformationSourceStateBuilder issBuilder = DefaultInformationSourceState.builder();
-
- Topology.TopologyBuilder topologyBuilder = DefaultTopology.builder();
- topologyBuilder = topologyBuilder
- .linkRef(teTopologyService.linkKey(teLink.sourceTeLinkId())
- .linkId())
- .networkRef(teTopologyService
- .linkKey(teLink.sourceTeLinkId()).networkId());
-
- issBuilder = issBuilder.topology(topologyBuilder.build());
- yangStateBuilder.informationSourceState(issBuilder.build());
- }
-
- // Once stateDerived underlay is available in yang and core TE Topology
- // object model, set the value properly
- // stateDerivedUnderlay = org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology
- // .rev20170110.ietftetopology.telinkstatederived.Underlay
- //yangStateBuilder = yangStateBuilder.underlay(stateDerivedUnderlay);
-
- return yangStateBuilder.build();
- }
-
- /**
- * Link object conversion from TE Topology subsystem to YANG.
- *
- * @param teSubsNetworkLink TE subsystem link object
- * @param teTopologyService TE Topology Service object
- * @return YANG link object
- */
- public static Link teSubsystem2YangLink(
- org.onosproject.tetopology.management.api.link.NetworkLink teSubsNetworkLink,
- TeTopologyService teTopologyService) {
- checkNotNull(teSubsNetworkLink, E_NULL_TELINK);
-
- LinkId linkId = LinkId.fromString(teSubsNetworkLink.linkId().toString());
- LinkBuilder builder = DefaultLink.builder().linkId(linkId);
- if (teSubsNetworkLink.supportingLinkIds() != null) {
- List<SupportingLink> slinks = Lists.newArrayList();
- SupportingLinkBuilder spLinkBuilder = DefaultSupportingLink.builder();
- for (NetworkLinkKey linkKey : teSubsNetworkLink.supportingLinkIds()) {
- slinks.add(spLinkBuilder.networkRef(NetworkId.fromString(
- linkKey.networkId().toString()))
- .linkRef(LinkId.fromString(
- linkKey.linkId().toString()))
- .build());
- }
- builder = builder.supportingLink(slinks);
- }
- if (teSubsNetworkLink.source() != null) {
- SourceBuilder sourceBuilder = DefaultSource
- .builder()
- .sourceNode(NodeId.fromString(
- teSubsNetworkLink.source().nodeId().toString()))
- .sourceTp(TpId.fromString(
- teSubsNetworkLink.source().tpId().toString()));
- builder = builder.source(sourceBuilder.build());
- }
- if (teSubsNetworkLink.destination() != null) {
- DestinationBuilder destBuilder = DefaultDestination
- .builder()
- .destNode(NodeId.fromString(
- teSubsNetworkLink.destination().nodeId().toString()))
- .destTp(TpId.fromString(
- teSubsNetworkLink.destination().tpId().toString()));
- builder = builder.destination(destBuilder.build());
- }
-
- if (teSubsNetworkLink.teLink() != null) {
- TeLink teData = teSubsNetworkLink.teLink();
- TeBuilder yangTeBuilder = DefaultTe.builder()
- .config(teLink2YangConfig(teData, teTopologyService))
- .state(teLink2YangState(teData, teTopologyService));
-
- AugmentedNtLinkBuilder linkAugmentBuilder =
- DefaultAugmentedNtLink.builder()
- .te(yangTeBuilder.build());
- builder.addYangAugmentedInfo(linkAugmentBuilder.build(), AugmentedNtLink.class);
- }
-
- return builder.build();
- }
-
- private static UnderlayBuilder te2YangConfigUnderlayPrimaryPath(
- UnderlayBuilder yangBuilder,
- TeLink teLink, TeTopologyService teTopologyService) {
-
- org.onosproject.tetopology.management.api.link.UnderlayPrimaryPath tePath = teLink.primaryPath();
-
- PrimaryPathBuilder pathBuilder = DefaultPrimaryPath.builder();
- if (tePath.pathElements() != null) {
- for (PathElement pathElementTe : tePath.pathElements()) {
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.telinkunderlayattributes.primarypath.PathElement
- .PathElementBuilder pathElementYangBuilder = DefaultPathElement.builder();
-
- pathElementYangBuilder = pathElementYangBuilder.pathElementId(pathElementTe.pathElementId());
- //TODO: check more types here
- if (pathElementTe.type() instanceof TeLinkId) {
- UnnumberedLinkBuilder unmBuilder = DefaultUnnumberedLink.builder()
- .routerId(IpAddress.fromString(
- Ip4Address.valueOf((int) pathElementTe.teNodeId()).toString()))
- .interfaceId(((TeLinkId) pathElementTe.type()).value());
- pathElementYangBuilder = pathElementYangBuilder.type(unmBuilder.build());
- }
-
- pathBuilder = pathBuilder.addToPathElement(pathElementYangBuilder.build());
- }
- }
-
- pathBuilder = pathBuilder.networkRef(teTopologyService
- .networkId(teLink.underlayTeTopologyId()));
-
- return yangBuilder.primaryPath(pathBuilder.build());
- }
-
- private static UnderlayBuilder te2YangConfigUnderlayBackupPaths(UnderlayBuilder yangBuilder,
- TeLink teLink,
- TeTopologyService teTopologyService) {
- List<UnderlayBackupPath> tePaths = teLink.backupPaths();
-
- for (UnderlayBackupPath tePath : tePaths) {
- BackupPathBuilder pathBuilder = DefaultBackupPath
- .builder();
- pathBuilder = pathBuilder.index(tePath.index());
-
- pathBuilder = pathBuilder.networkRef(teTopologyService
- .networkId(teLink.underlayTeTopologyId()));
-
- for (PathElement backupPathElementTe : tePath.pathElements()) {
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.telinkunderlayattributes.backuppath.PathElement
- .PathElementBuilder elementBuilder =
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.telinkunderlayattributes.backuppath.DefaultPathElement
- .builder();
-
- elementBuilder = elementBuilder.pathElementId(backupPathElementTe.pathElementId());
- //TODO: check more types here
- if (backupPathElementTe.type() instanceof TeLinkId) {
- UnnumberedLinkBuilder unmBuilder = DefaultUnnumberedLink.builder()
- .routerId(IpAddress.fromString(
- Ip4Address.valueOf((int) backupPathElementTe.teNodeId()).toString()))
- .interfaceId(((TeLinkId) backupPathElementTe.type()).value());
- elementBuilder = elementBuilder.type(unmBuilder.build());
- }
-
- pathBuilder = pathBuilder.addToPathElement(elementBuilder.build());
- }
- yangBuilder = yangBuilder.addToBackupPath(pathBuilder.build());
- }
-
- return yangBuilder;
- }
-
- private static TeLink yang2TeLinkAttributes(TeLinkAttributes yangLinkAttr,
- State opState, Link yangLink,
- Network yangNetwork,
- Networks yangNetworks) {
- TeNodeId teNodeId = findTeNodeId(yangNetwork,
- yangLink.source().sourceNode());
- long teNodeIdLong = -1;
- if (teNodeId != null && teNodeId.dottedQuad() != null) {
- teNodeIdLong = Ip4Address.valueOf(teNodeId.dottedQuad().string())
- .toInt();
- }
-
- TeLinkTpKey teLinkKey = new TeLinkTpKey(teNodeIdLong,
- findTeTpId(yangNetwork,
- yangLink.source().sourceNode(),
- yangLink.source().sourceTp()));
-
- TeNodeId teNodeIdDest = null;
- if (yangLink.destination() != null) {
- teNodeIdDest = findTeNodeId(yangNetwork,
- yangLink.destination().destNode());
- }
- long teNodeIdDestLong = -1;
- if (teNodeIdDest != null && teNodeIdDest.dottedQuad() != null) {
- teNodeIdDestLong = Ip4Address.valueOf(teNodeIdDest.dottedQuad().string()).toInt();
- }
-
- TeLinkTpKey peerTeLinkKey = null;
- if (yangLink.destination() != null) {
- peerTeLinkKey = new TeLinkTpKey(teNodeIdDestLong,
- findTeTpId(yangNetwork,
- yangLink.destination().destNode(),
- yangLink.destination().destTp()));
- }
-
- TeLinkTpGlobalKey supportTeLinkId = findSupportTeLinkId(yangNetworks, yangLink);
-
- org.onosproject.tetopology.management.api.TeStatus opStatus = null;
- if (opState != null && opState.operStatus() != null) {
- opStatus = EnumConverter.yang2TeSubsystemOpStatus(opState.operStatus());
- }
-
- TeTopologyKey underlayTopologyId = null;
- if (yangLinkAttr != null && yangLinkAttr.underlay() != null && yangLinkAttr.underlay().primaryPath() != null) {
- underlayTopologyId = findTopologyId(yangNetworks, yangLinkAttr.underlay().primaryPath().networkRef());
- }
-
- TeLink teLink = yangLinkAttr2TeLinkAttributes(yangLinkAttr, opStatus,
- teNodeIdLong,
- teNodeIdDestLong,
- teLinkKey,
- peerTeLinkKey,
- supportTeLinkId,
- underlayTopologyId);
-
- return teLink;
- }
-
- /**
- * Finds the TE TopologyKey from yangNetworks and a networkRef.
- *
- * @param yangNetworks YANG networks object
- * @param networkRef YANG network reference
- * @return TeTopologyKey the TE TopologyKey
- */
- public static TeTopologyKey findTopologyId(Networks yangNetworks, Object networkRef) {
- if (networkRef == null) {
- return null;
- }
- NetworkId networkId = NetworkId.fromString((String) networkRef);
-
- TeTopologyKey topologyId = null;
- Network targetTeNetwork = null;
- if (yangNetworks.network() != null
- && !yangNetworks.network().isEmpty() && networkId != null) {
- for (Network ynetItem : yangNetworks.network()) {
- if (ynetItem.networkId() != null) {
- if (ynetItem.networkId().equals(networkId)) {
- targetTeNetwork = ynetItem;
- break;
- }
- }
- }
- }
- if (targetTeNetwork != null && targetTeNetwork
- .yangAugmentedInfo(AugmentedNwNetwork.class) != null) {
- AugmentedNwNetwork augmentTeIds = (AugmentedNwNetwork) targetTeNetwork
- .yangAugmentedInfo(AugmentedNwNetwork.class);
- topologyId = new TeTopologyKey(augmentTeIds.providerId().uint32(),
- augmentTeIds.clientId().uint32(),
- Long.valueOf(augmentTeIds.teTopologyId().string()));
- }
- return topologyId;
- }
-
- private static TeLink yangLinkAttr2TeLinkAttributes(TeLinkAttributes yangLinkAtrr,
- org.onosproject.tetopology.management.api.TeStatus opStatus,
- long teNodeIdLong,
- long teNodeIdDestLong,
- TeLinkTpKey teLinkKey,
- TeLinkTpKey peerTeLinkKey,
- TeLinkTpGlobalKey supportTeLinkId,
- TeTopologyKey underlayTopologyId) {
- org.onosproject.tetopology.management.api.TeStatus adminStatus = null;
-
- TeLinkTpGlobalKey sourceTeLinkId = null; // from yang to core, we can ignore sourceTeLinkId
-
- CommonLinkData teData = null;
-
- if (yangLinkAtrr.adminStatus() != null) {
- adminStatus = EnumConverter.yang2TeSubsystemAdminStatus(yangLinkAtrr.adminStatus());
- }
-
- BitSet flags = new BitSet();
- if (yangLinkAtrr.isAbstract()) {
- flags.set(TeLink.BIT_ABSTRACT);
- }
-
- ExternalLink externalLink = null;
- if (yangLinkAtrr != null && yangLinkAtrr.externalDomain() != null) {
- externalLink = new ExternalLink(null, yangLinkAtrr.externalDomain().plugId());
- }
-
- UnderlayPath underlayPath = null;
- underlayPath = yang2TeSubsystemUnderlayPath(yangLinkAtrr, teNodeIdLong,
- teNodeIdDestLong);
- Long adminGroup = null;
- if (yangLinkAtrr != null && yangLinkAtrr.administrativeGroup() != null) {
- adminGroup = Long.valueOf(yangLinkAtrr.administrativeGroup().toString());
- }
- List<Long> interLayerLocks = null; // FIXME: how to find interLayerLocks?
-
- List<UnreservedBandwidth> listOfUnreservedBandwidth = yangLinkAtrr.unreservedBandwidth();
- float[] availBandwidth = new float[MAX_PRIORITY + 1];
- for (UnreservedBandwidth urbw : listOfUnreservedBandwidth) {
- availBandwidth[urbw.priority()] = Float.valueOf(urbw.bandwidth().string());
- }
-
- float[] maxBandwidth = new float[MAX_PRIORITY + 1];
- if (yangLinkAtrr.maxLinkBandwidth() != null) {
- // Core TE has an array, but YANG is an integer
- for (short p = 0; p <= MAX_PRIORITY; p++) {
- maxBandwidth[p] = Float.valueOf(yangLinkAtrr.maxLinkBandwidth().string());
- }
- }
-
- float[] maxAvailLspBandwidth = availBandwidth; // FIXME: how to find this?
- float[] minAvailLspBandwidth = availBandwidth; // FIXME: how to find this?
- LinkBandwidth bandwidth = new LinkBandwidth(
- maxBandwidth,
- availBandwidth,
- maxAvailLspBandwidth,
- minAvailLspBandwidth,
- null); // FIXME: how to find odu resource?
- List<Long> srlgs = Lists.newArrayList();
- if (yangLinkAtrr.teSrlgs() != null
- && yangLinkAtrr.teSrlgs().value() != null
- && !yangLinkAtrr.teSrlgs().value().isEmpty()) {
- for (Srlg srlg : yangLinkAtrr.teSrlgs().value()) {
- srlgs.add(srlg.uint32());
- }
- }
- TePathAttributes teAttributes =
- new TePathAttributes(yangLinkAtrr.teDefaultMetric(), yangLinkAtrr.teDelayMetric(),
- srlgs);
- teData = new CommonLinkData(adminStatus,
- opStatus,
- flags,
- null, // switchingLayer
- null, // encodingLayer
- externalLink,
- underlayPath,
- teAttributes,
- adminGroup,
- interLayerLocks,
- bandwidth);
-
- TeLink te = new DefaultTeLink(teLinkKey, peerTeLinkKey,
- underlayTopologyId, supportTeLinkId,
- sourceTeLinkId, teData);
- return te;
- }
-
- private static TeLinkTpGlobalKey findSupportTeLinkId(Networks yangNetworks,
- Link yangLink) {
- Network teNetworkFound = null;
- LinkId teLinkIdFound = null;
- TeLinkTpGlobalKey supportTeLinkId = null;
-
- if (yangLink != null && yangLink.supportingLink() != null && !yangLink.supportingLink().isEmpty()) {
- if (yangNetworks.network() != null && !yangNetworks.network().isEmpty()) {
- for (Network ynetItem : yangNetworks.network()) {
- if (ynetItem.networkId() != null) {
- if (ynetItem.networkId().equals(yangLink.supportingLink().get(0).networkRef())) {
- teNetworkFound = ynetItem;
- teLinkIdFound = yangLink.supportingLink().get(0).linkRef();
- break;
- }
- }
- }
- }
- Link teLinkFound = null;
- if (teNetworkFound.yangAugmentedInfo(AugmentedNdNetwork.class) != null) {
- AugmentedNdNetwork augmentLink =
- (AugmentedNdNetwork) teNetworkFound.yangAugmentedInfo(AugmentedNdNetwork.class);
- for (Link link : augmentLink.link()) {
- if (link.linkId().equals(teLinkIdFound)) {
- teLinkFound = link;
- break;
- }
- }
- }
-
- if (teLinkFound != null) {
- TeNodeId teSupportNodeId = findTeNodeId(teNetworkFound,
- teLinkFound.source().sourceNode());
- long tenIdLong = -1;
- if (teSupportNodeId != null) {
- tenIdLong = Ip4Address.valueOf(teSupportNodeId.dottedQuad().string()).toInt();
- }
- long teSupportLinkTpId = findTeTpId(teNetworkFound,
- teLinkFound.source().sourceNode(),
- teLinkFound.source().sourceTp());
-
- org.onosproject.tetopology.management.api.TeTopologyId teTopologyId = null;
- if (teNetworkFound.yangAugmentedInfo(AugmentedNwNetwork.class) != null) {
- AugmentedNwNetwork augmentTeIds =
- (AugmentedNwNetwork) teNetworkFound.yangAugmentedInfo(AugmentedNwNetwork.class);
- teTopologyId =
- new org.onosproject.tetopology.management.api.TeTopologyId(
- augmentTeIds.clientId().uint32(),
- augmentTeIds.providerId().uint32(),
- augmentTeIds.teTopologyId().string());
- }
-
- supportTeLinkId = new TeLinkTpGlobalKey(teTopologyId.providerId(),
- teTopologyId.clientId(),
- Long.valueOf(teTopologyId
- .topologyId()),
- tenIdLong, teSupportLinkTpId);
- }
- }
-
- return supportTeLinkId;
- }
-
- /**
- * Finds TeNodeId from a yangNetwork and yangNodeId.
- *
- * @param yangNetwork YANG network object
- * @param yangNodeId YANG node Id
- * @return teNodeId teNodeId
- */
- public static TeNodeId findTeNodeId(Network yangNetwork, NodeId yangNodeId) {
- TeNodeId teNodeId = null;
- for (Node node : yangNetwork.node()) {
- if (node.nodeId().equals(yangNodeId)) {
- if (node.yangAugmentedInfoMap() != null
- && !node.yangAugmentedInfoMap().isEmpty()) {
- AugmentedNwNode yangNodeAugment = (AugmentedNwNode) node
- .yangAugmentedInfo(AugmentedNwNode.class);
- if (yangNodeAugment != null
- && yangNodeAugment.teNodeId() != null) {
- teNodeId = yangNodeAugment.teNodeId();
- }
- }
- }
- }
- return teNodeId;
- }
-
- private static long findTeTpId(Network yangNetwork, NodeId yangNodeId, TpId yangTpId) {
- long teTpId = 0;
- for (Node node : yangNetwork.node()) {
- if (node.nodeId().equals(yangNodeId)) {
- if (node.yangAugmentedInfoMap() != null
- && !node.yangAugmentedInfoMap().isEmpty()) {
-
- AugmentedNdNode yangTpNodeAugment = (AugmentedNdNode) node
- .yangAugmentedInfo(AugmentedNdNode.class);
- if (yangTpNodeAugment.terminationPoint() != null) {
- for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology
- .rev20151208.ietfnetworktopology.networks.network.node.augmentedndnode.TerminationPoint
- yangTpnode : yangTpNodeAugment.terminationPoint()) {
- if (yangTpnode.tpId().equals(yangTpId)) {
- if (yangTpnode.yangAugmentedInfoMap() != null
- && !yangTpnode.yangAugmentedInfoMap()
- .isEmpty()) {
- AugmentedNtTerminationPoint yangTpAugment =
- (AugmentedNtTerminationPoint) yangTpnode
- .yangAugmentedInfo(AugmentedNtTerminationPoint.class);
- if (yangTpAugment.teTpId() != null) {
- teTpId = Long.valueOf(yangTpAugment.teTpId().toString());
- }
- }
- }
- }
- }
- }
- }
- }
- return teTpId;
- }
- /**
- * Link object conversion from YANG to TE Topology subsystem.
- *
- * @param yangLink YANG link
- * @param yangNetwork YANG network
- * @param yangNetworks YANG networks
- * @return TE subsystem link
- */
- public static org.onosproject.tetopology.management.api.link.NetworkLink
- yang2TeSubsystemLink(Link yangLink, Network yangNetwork,
- Networks yangNetworks) {
- NetworkId networkId = yangNetwork.networkId();
- checkNotNull(yangLink, E_NULL_YANG_TELINK);
-
- KeyId linkId = KeyId.keyId(yangLink.linkId().uri().toString());
- NodeTpKey sourceNodeTpKey = null;
- NodeTpKey destinationNodeTpKey = null;
- List<NetworkLinkKey> spLinkIds = null;
- TeLink te = null;
-
- if (yangLink.supportingLink() != null) {
- spLinkIds = Lists.newArrayList();
- for (SupportingLink yangSpLink : yangLink.supportingLink()) {
- NetworkLinkKey linkKey = new NetworkLinkKey(KeyId.keyId(yangSpLink.networkRef().uri().toString()),
- KeyId.keyId(yangSpLink.linkRef().uri().toString()));
- spLinkIds.add(linkKey);
- }
- }
-
- if (yangLink.source() != null) {
- TerminationPointKey source = new TerminationPointKey(
- KeyId.keyId(networkId.uri().toString()),
- KeyId.keyId(yangLink.source().sourceNode().uri().toString()),
- KeyId.keyId(yangLink.source().sourceTp().uri().toString()));
- sourceNodeTpKey = new NodeTpKey(source.nodeId(), source.tpId());
- }
-
- if (yangLink.destination() != null) {
- TerminationPointKey destination = new TerminationPointKey(
- KeyId.keyId(networkId.uri().toString()),
- KeyId.keyId(yangLink.destination().destNode().uri().toString()),
- KeyId.keyId(yangLink.destination().destTp().uri().toString()));
- destinationNodeTpKey = new NodeTpKey(destination.nodeId(), destination.tpId());
- }
-
- if (yangLink.yangAugmentedInfoMap() != null && !yangLink.yangAugmentedInfoMap().isEmpty()) {
-
- AugmentedNtLink yangLinkAugment =
- (AugmentedNtLink) yangLink.yangAugmentedInfo(AugmentedNtLink.class);
- if (yangLinkAugment != null &&
- yangLinkAugment.te() != null &&
- yangLinkAugment.te().config() != null) {
- TeLinkAttributes yangLinkAtrr =
- yangLinkAugment.te().config().teLinkAttributes();
- if (yangLinkAtrr != null && yangLinkAtrr.linkIndex() != null) {
- te = yang2TeLinkAttributes(yangLinkAtrr,
- yangLinkAugment.te().state(),
- yangLink, yangNetwork,
- yangNetworks);
- }
- }
- }
-
- org.onosproject.tetopology.management.api.link.DefaultNetworkLink link =
- new DefaultNetworkLink(linkId,
- sourceNodeTpKey,
- destinationNodeTpKey,
- spLinkIds,
- te);
- return link;
- }
-
- private static org.onosproject.tetopology.management.api.link.UnderlayPrimaryPath
- yang2TeSubsystemUnderlayPrimaryPath(PrimaryPath yangpath,
- long teNodeId) {
- org.onosproject.tetopology.management.api.link.UnderlayPrimaryPath teUnderlayPrimaryPath = null;
-
- List<PathElement> pathElementList = Lists.newArrayList();
- for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology
- .telinkunderlayattributes.primarypath.
- PathElement pathElementYang : yangpath.pathElement()) {
-
- long nodeId = 0;
- ElementType type = null;
- // TODO: check more types
- if (pathElementYang.type() instanceof UnnumberedLink) {
- nodeId = Long.valueOf(((UnnumberedLink) pathElementYang.type()).routerId().toString());
- type = new TeLinkId(((UnnumberedLink) pathElementYang.type()).interfaceId());
- }
- PathElement tePathElement = new PathElement(pathElementYang.pathElementId(),
- nodeId,
- type,
- false); // FIXME: how to find the proper value for loose?
- pathElementList.add(tePathElement);
- }
-
- teUnderlayPrimaryPath = new org.onosproject.tetopology.management.api.link.
- UnderlayPrimaryPath(pathElementList, false); // FIXME: how to find the proper value for loose?
-
- return teUnderlayPrimaryPath;
- }
-
- private static List<UnderlayBackupPath>
- yang2TeSubsystemUnderlayBackupPaths(
- List<org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
- rev20170110.ietftetopology.telinkunderlayattributes.
- BackupPath> yangpaths,
- long teNodeId) {
-
- List<UnderlayBackupPath> underlayBackupPathsList = Lists.newArrayList();
- for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.telinkunderlayattributes.
- BackupPath yangConfig : yangpaths) {
- UnderlayBackupPath ubp = null;
- List<PathElement> backupPathElementList = Lists.newArrayList();
- long nodeId = 0;
- ElementType type = null;
- for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology
- .telinkunderlayattributes.backuppath.
- PathElement backupYang : yangConfig.pathElement()) {
- // TODO: check more types
- if (backupYang.type() instanceof UnnumberedLink) {
- nodeId = Long.valueOf(((UnnumberedLink) backupYang.type()).routerId().toString());
- type = new TeLinkId(((UnnumberedLink) backupYang.type()).interfaceId());
- }
- PathElement tePathElementBackup = new PathElement(backupYang.pathElementId(),
- nodeId,
- type,
- false);
- backupPathElementList.add(tePathElementBackup);
- }
- ubp = new UnderlayBackupPath(yangConfig.index(),
- backupPathElementList,
- null); // FIXME: find the proper value for loose
- underlayBackupPathsList.add(ubp);
- }
-
- return underlayBackupPathsList;
- }
-
- /**
- * TE Link underlay path Config object conversion from YANG to TE Topology subsystem.
- *
- * @param yangLinkAtrr YANG link Config YANG object
- * @return teSubsystem TE underlay path object
- */
- private static org.onosproject.tetopology.management.api.link.UnderlayPath
- yang2TeSubsystemUnderlayPath(TeLinkAttributes yangLinkAtrr, long srcTeNodeId, long dstTeNodeId) {
-
- checkNotNull(yangLinkAtrr, E_NULL_YANG_TELINK_CONFIG);
-
- org.onosproject.tetopology.management.api.link.UnderlayPrimaryPath underlayPrimaryPath = null;
- List<UnderlayBackupPath> underlayBackupPathsList = null;
- TeTunnelId teTunnelId = new TeTunnelId(srcTeNodeId, dstTeNodeId, 0); // FIXME: how to find teTunnelId?
-
- if (yangLinkAtrr.underlay() != null && yangLinkAtrr.underlay().primaryPath() != null) {
- underlayPrimaryPath =
- yang2TeSubsystemUnderlayPrimaryPath(yangLinkAtrr.underlay().primaryPath(), srcTeNodeId);
- }
-
- if (yangLinkAtrr.underlay() != null && yangLinkAtrr.underlay().backupPath() != null) {
- underlayBackupPathsList =
- yang2TeSubsystemUnderlayBackupPaths(yangLinkAtrr.underlay().backupPath(), srcTeNodeId);
- }
-
- org.onosproject.tetopology.management.api.link.UnderlayPath teUnderlay = null;
- if (yangLinkAtrr.underlay() != null) {
- teUnderlay = new org.onosproject.tetopology.management.api.link.
- UnderlayPath(underlayPrimaryPath,
- underlayBackupPathsList,
- TunnelProtectionType.of(yangLinkAtrr.underlay().protectionType()),
- (Long) yangLinkAtrr.underlay().tunnelSrc().tunnelTpRef(), // null safe?
- (Long) yangLinkAtrr.underlay().tunnelDes().tunnelTpRef(), // null safe?
- teTunnelId);
- }
-
- return teUnderlay;
- }
-
- /**
- * Converts a TE Topology link event from the data format used in
- * the core to its corresponding YANG Object (YO) format.
- *
- * @param eventType Link event type
- * @param linkData TE Topology link event data
- * @param teTopologyService TE Topology Service object
- * @return YANG Object converted from linkData
- */
- public static TeLinkEvent teNetworkLink2yangTeLinkEvent(TeTopologyEventTypeEnum eventType,
- NetworkLinkEventSubject linkData,
- TeTopologyService teTopologyService) {
- checkNotNull(linkData);
- TeLinkEvent.TeLinkEventBuilder teLinkEventBuilder = new DefaultTeLinkEvent.TeLinkEventBuilder();
-
- TeTopologyEventType yangEventType = new TeTopologyEventType(eventType);
- teLinkEventBuilder.eventType(yangEventType);
- NetworkId networkId = NetworkId.fromString(linkData.key().networkId().toString());
- teLinkEventBuilder.networkRef(networkId);
- LinkId linkId = LinkId.fromString(linkData.key().linkId().toString());
- teLinkEventBuilder.linkRef(linkId);
-
- if (linkData != null && linkData.networkLink() != null) {
- NetworkLink link = linkData.networkLink();
- State yangTeLinkState = teLink2YangState(link.teLink(), teTopologyService);
-
- teLinkEventBuilder.operStatus(yangTeLinkState.operStatus());
- teLinkEventBuilder.informationSource(yangTeLinkState.informationSource());
- teLinkEventBuilder.informationSourceEntry(yangTeLinkState.informationSourceEntry());
- teLinkEventBuilder.informationSourceState(yangTeLinkState.informationSourceState());
- teLinkEventBuilder.isTransitional(yangTeLinkState.isTransitional());
- teLinkEventBuilder.recovery(yangTeLinkState.recovery());
- teLinkEventBuilder.teLinkAttributes(yangTeLinkState.teLinkAttributes());
- teLinkEventBuilder.underlay(yangTeLinkState.underlay());
- }
-
- return teLinkEventBuilder.build();
- }
-
- /**
- * Retrieves the TE network link key from a given YANG network link
- * notification event.
- *
- * @param yangLinkEvent YANG network link notification
- * @return TE network link key
- */
- public static NetworkLinkKey yangLinkEvent2NetworkLinkKey(TeLinkEvent yangLinkEvent) {
- NetworkId networkRef = NetworkId.fromString(yangLinkEvent.networkRef().toString());
- LinkId linkRef = LinkId.fromString(yangLinkEvent.linkRef().toString());
- KeyId networkId = KeyId.keyId(networkRef.uri().toString());
- KeyId linkId = KeyId.keyId(linkRef.uri().toString());
-
- NetworkLinkKey networkLinkKey = new NetworkLinkKey(networkId, linkId);
-
- return networkLinkKey;
-
- }
-
- /**
- * Converts a YANG network link notification event into a TE network link.
- *
- * @param yangLinkEvent YANG network link notification
- * @param teTopologyService TE Topology service used to help the conversion
- * @return TE network link
- */
- public static NetworkLink yangLinkEvent2NetworkLink(TeLinkEvent yangLinkEvent,
- TeTopologyService teTopologyService) {
-
- KeyId linkId = yangLinkEvent2NetworkLinkKey(yangLinkEvent).linkId();
-
- org.onosproject.tetopology.management.api.
- Network network = teTopologyService.network(
- yangLinkEvent2NetworkLinkKey(yangLinkEvent).networkId());
- if (network == null) {
- return null;
- }
-
- NetworkLink networkLink = network.link(linkId);
- if (networkLink == null) {
- return null;
- }
-
- NodeTpKey sourceTp = networkLink.source();
- if (sourceTp == null) {
- return null;
- }
- NodeTpKey destTp = networkLink.destination();
-
- List<NetworkLinkKey> supportingLinkIds = networkLink.supportingLinkIds();
- TeLink teLink = networkLink.teLink();
- if (teLink == null) {
- return null;
- }
-
- TeOperStatus opState = yangLinkEvent.operStatus();
- org.onosproject.tetopology.management.api.
- TeStatus opStatus = EnumConverter.yang2TeSubsystemOpStatus(opState);
-
- TeLink updatedTeLink = yangLinkEvent2TeLinkAttributes(yangLinkEvent,
- teLink, opStatus, teTopologyService);
-
-
- NetworkLink updatedNetworkLink = new DefaultNetworkLink(linkId, sourceTp, destTp, supportingLinkIds,
- updatedTeLink);
-
- return updatedNetworkLink;
- }
-
- private static TeLink yangLinkEvent2TeLinkAttributes(TeLinkEvent yangLinkEvent, TeLink oldTeLink, TeStatus
- opStatus, TeTopologyService teTopologyService) {
-
- TeLinkAttributes yangTeLinkAttrs = yangLinkEvent.teLinkAttributes();
-
- TeLinkTpKey teLinkKey = oldTeLink.teLinkKey();
-
- long teNodeIdDest = 0;
- long teNodeIdSrc = 0;
-
- TeLinkTpGlobalKey supportTeLinkId = oldTeLink.supportingTeLinkId();
- TeLinkTpKey peerTeLinkKey = oldTeLink.peerTeLinkKey();
-
- TeTopologyKey underlayTopologyId = null;
- KeyId networkRef = null;
- if (yangTeLinkAttrs.underlay() != null &&
- yangTeLinkAttrs.underlay().primaryPath() != null &&
- yangTeLinkAttrs.underlay().primaryPath().networkRef() != null) {
- networkRef = (KeyId) yangTeLinkAttrs.underlay().primaryPath().networkRef();
- }
-
- if (networkRef != null && teTopologyService.network(networkRef) != null
- && teTopologyService.network(networkRef).teTopologyId() != null) {
- long clientId = teTopologyService.network(networkRef).teTopologyId().clientId();
- long providerId = teTopologyService.network(networkRef).teTopologyId().providerId();
- long topologyId = Long.valueOf(teTopologyService.network(networkRef).teTopologyId().topologyId());
- underlayTopologyId = new TeTopologyKey(providerId, clientId, topologyId);
- }
-
- TeLink updatedTeLink = yangLinkAttr2TeLinkAttributes(yangTeLinkAttrs, opStatus, teNodeIdSrc, teNodeIdDest,
- teLinkKey,
- peerTeLinkKey,
- supportTeLinkId,
- underlayTopologyId);
-
- return updatedTeLink;
- }
-}
diff --git a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/NetworkConverter.java b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/NetworkConverter.java
deleted file mode 100644
index 86df3ce..0000000
--- a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/NetworkConverter.java
+++ /dev/null
@@ -1,645 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.teyang.utils.topology;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static org.onosproject.tetopology.management.api.OptimizationType.NOT_OPTIMIZED;
-
-import java.util.List;
-import java.util.Map;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.TeTopologyEvent;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.TeTopologyService;
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.link.NetworkLinkEventSubject;
-import org.onosproject.tetopology.management.api.node.NetworkNode;
-import org.onosproject.tetopology.management.api.node.NetworkNodeEventSubject;
-import org.onosproject.teyang.api.OperationType;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.IetfNetwork.OnosYangOpType;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.DefaultNetworks;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork
- .DefaultNetworksState;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NetworkId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.Networks;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NetworksState;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks
- .DefaultNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks.Network;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks.Network
- .NetworkBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks.network
- .DefaultNetworkTypes;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks.network
- .DefaultSupportingNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks.network
- .DefaultSupportingNetwork.SupportingNetworkBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks.network
- .NetworkTypes;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks.network
- .Node;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks.network
- .SupportingNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.ietfnetworktopology
- .networks.network.AugmentedNdNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.ietfnetworktopology
- .networks.network.DefaultAugmentedNdNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.ietfnetworktopology
- .networks.network.DefaultAugmentedNdNetwork.AugmentedNdNetworkBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.ietfnetworktopology
- .networks.network.augmentedndnetwork.Link;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology
- .IetfTeTopologyEvent;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.IetfTeTopologyEventSubject;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.TeLinkEvent;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.TeNodeEvent;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.networks
- .network.AugmentedNwNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.networks
- .network.DefaultAugmentedNwNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.networks
- .network.networktypes.AugmentedNwNetworkTypes;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.networks
- .network.networktypes.DefaultAugmentedNwNetworkTypes;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology
- .tetopologyaugment.DefaultTe;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology
- .tetopologyaugment.Te;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tetopologyaugment.te.Config;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tetopologyaugment.te.DefaultConfig;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology
- .tetopologytype.DefaultTeTopology;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology
- .tetopologytype.TeTopology;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.Cost;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.Delay;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.NotOptimized;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeGlobalId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeOptimizationCriterion;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeTopologyId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.tetopologyeventtype.TeTopologyEventTypeEnum;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-
-/**
- * Networks, Networks State conversion functions.
- */
-public final class NetworkConverter {
- private static final String
- E_NULL_TE_NETWORKS = "TeSubsystem networks cannot be null";
- private static final String
- E_NULL_TE_NETWORK_LIST = "TeSubsystem network list cannot be null";
- private static final String
- E_NULL_TE_NETWORK = "TeSubsystem network cannot be null";
- private static final String
- E_NULL_TE_NETWORKID = "TeSubsystem networkId cannot be null";
- private static final String
- E_NULL_YANG_NETWORKS = "YANG networks cannot be null";
- private static final String
- E_NULL_YANG_NETWORK_LIST = "YANG network list cannot be null";
- private static final String
- E_NULL_YANG_NETWORK = "YANG network cannot be null";
- private static final String
- E_NULL_YANG_NETWORKID = "YANG networkId cannot be null";
- private static final String
- E_NULL_YANG_NETWORKSSTATE = "YANG networksState cannot be null";
- private static final String
- E_DIFF_YANG_NETWORKID = "YANG networkId must be same in Network and NetworkState";
- private static final String
- E_NULL_YANG_NETWORKSSTATE_NETWORK = "YANG networksState network cannot be null";
- private static final String
- E_NULL_YANG_NETWORKSSTATE_NETWORKREF = "YANG networksState networkRef cannot be null";
-
- private static final Logger log = LoggerFactory.getLogger(NetworkConverter.class);
-
- // no instantiation
- private NetworkConverter() {
- }
-
- private static OnosYangOpType toNetworksOperationType(OperationType operation) {
- switch (operation) {
- case CREATE:
- return OnosYangOpType.CREATE;
-
- case DELETE:
- return OnosYangOpType.DELETE;
-
- case REMOVE:
- return OnosYangOpType.REMOVE;
-
- case MERGE:
- return OnosYangOpType.MERGE;
-
- case REPLACE:
- return OnosYangOpType.REPLACE;
-
- default:
- return OnosYangOpType.NONE;
- }
- }
-
- /**
- * Networks object conversion from TE Topology subsystem to YANG.
- *
- * @param teSubsystem TE Topology subsystem networks object
- * @param operation operation type
- * @param teTopologyService teTopology core service
- * @return Networks YANG object
- */
- public static Networks teSubsystem2YangNetworks(
- org.onosproject.tetopology.management.api.Networks teSubsystem,
- OperationType operation,
- TeTopologyService teTopologyService) {
- checkNotNull(teSubsystem, E_NULL_TE_NETWORKS);
- checkNotNull(teSubsystem.networks(), E_NULL_TE_NETWORK_LIST);
- Networks.NetworksBuilder builder =
- DefaultNetworks.builder()
- .yangNetworksOpType(toNetworksOperationType(operation));
- List<Network> networks = Lists.newArrayList();
- for (org.onosproject.tetopology.management.api.Network teNetwork : teSubsystem.networks()) {
- networks.add(teSubsystem2YangNetwork(teNetwork, operation,
- teTopologyService));
- }
- builder.network(networks);
- return builder.build();
- }
-
- /**
- * Network States object conversion from TE Topology subsystem to YANG.
- *
- * @param teSubsystem TE Topology subsystem networks object
- * @param operation operation type
- * @return NetworkStates YANG object
- */
- public static NetworksState teSubsystem2YangNetworkStates(
- org.onosproject.tetopology.management.api.Networks teSubsystem,
- OperationType operation) {
- checkNotNull(teSubsystem, "teSubsystem object cannot be null");
- checkNotNull(teSubsystem.networks(), "TeSubsystem Networks object cannot be null");
- NetworksState.NetworksStateBuilder builder =
- DefaultNetworksState.builder()
- .yangNetworksStateOpType(toNetworksOperationType(operation));
- List<org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
- .ietfnetwork.networksstate.Network> networks = Lists.newArrayList();
- for (org.onosproject.tetopology.management.api.Network teNetwork : teSubsystem.networks()) {
- networks.add(teSubsystem2YangNetworkState(teNetwork, operation));
- }
- builder.network(networks);
- return builder.build();
- }
-
- private static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
- .ietfnetwork.networksstate.Network networkStateNetwork(Network network,
- NetworksState yangNetworkStates) {
- checkNotNull(network, "YANG Network object cannot be null");
- checkNotNull(yangNetworkStates, "YANG NetworksState object cannot be null");
- if (yangNetworkStates.network() == null) {
- return null;
- }
-
- for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
- .ietfnetwork.networksstate.Network stateNetwork : yangNetworkStates.network()) {
- if (stateNetwork.networkRef().equals(network.networkId())) {
- return stateNetwork;
- }
- }
- return null;
- }
-
- /**
- * Networks object conversion from YANG to TE Topology subsystem.
- *
- * @param yangNetworks Networks YANG object
- * @param yangNetworkStates NetworkStates YANG object
- * @param deviceId the device Id
- * @return teSubsystem TE Topology subsystem networks object
- */
- public static org.onosproject.tetopology.management.api.Networks yang2TeSubsystemNetworks(
- Networks yangNetworks, NetworksState yangNetworkStates, DeviceId deviceId) {
- checkNotNull(yangNetworks, E_NULL_YANG_NETWORKS);
- checkNotNull(yangNetworks.network(), E_NULL_YANG_NETWORK_LIST);
- checkNotNull(yangNetworkStates, E_NULL_YANG_NETWORKSSTATE);
-
- List<org.onosproject.tetopology.management.api.Network> networks = Lists.newArrayList();
- for (Network network : yangNetworks.network()) {
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
- .ietfnetwork.networksstate.Network stateNetwork =
- networkStateNetwork(network, yangNetworkStates);
- org.onosproject.tetopology.management.api.Network teNetwork;
- if (stateNetwork == null) {
- log.info("networkId {} can't be found in yangNetworkStates",
- network.networkId());
- teNetwork = yang2TeSubsystemNetwork(network, yangNetworks, deviceId);
- } else {
- teNetwork = yang2TeSubsystemNetwork(network, stateNetwork, yangNetworks, deviceId);
- }
- networks.add(teNetwork);
- }
-
- org.onosproject.tetopology.management.api.DefaultNetworks defaultNetworks =
- new org.onosproject.tetopology.management.api.DefaultNetworks(networks);
- return defaultNetworks;
- }
-
- private static NetworkBuilder te2YangSupportingNetwork(NetworkBuilder builder,
- List<KeyId> teSpptNetworkIds) {
- List<SupportingNetwork> snws = Lists.newArrayList();
- SupportingNetworkBuilder spNetworkBuilder = DefaultSupportingNetwork.builder();
- for (KeyId teSpNwKey : teSpptNetworkIds) {
- snws.add(spNetworkBuilder
- .networkRef(NetworkId.fromString(teSpNwKey.toString()))
- .build());
- }
- return builder.supportingNetwork(snws);
- }
-
- private static NetworkBuilder te2YangNodes(NetworkBuilder builder,
- Map<KeyId, NetworkNode> teNodes,
- TeTopologyService teTopologyService,
- TeTopologyKey teTopologyKey) {
- List<Node> nodeList = Lists.newArrayList();
-
- for (org.onosproject.tetopology.management.api.node.NetworkNode node : teNodes.values()) {
- nodeList.add(NodeConverter.teSubsystem2YangNode(node,
- teTopologyService,
- teTopologyKey));
- }
- return builder.node(nodeList);
- }
-
- private static NetworkBuilder te2YangLinks(NetworkBuilder builder,
- Map<KeyId, NetworkLink> teLinks,
- TeTopologyService teTopologyService) {
- List<Link> linkList = Lists.newArrayList();
-
- for (org.onosproject.tetopology.management.api.link.NetworkLink link : teLinks.values()) {
- linkList.add(LinkConverter.teSubsystem2YangLink(link, teTopologyService));
- }
- AugmentedNdNetworkBuilder ndAugment = DefaultAugmentedNdNetwork.builder();
- ndAugment.link(linkList);
- builder.addYangAugmentedInfo(ndAugment.build(), AugmentedNdNetwork.class);
- return builder;
- }
-
- private static NetworkBuilder te2YangNetworkType(NetworkBuilder builder,
- org.onosproject.tetopology.management.api.TeTopologyId
- teTopologyId) {
- NetworkTypes.NetworkTypesBuilder nwType = DefaultNetworkTypes.builder();
- if (teTopologyId != null) {
- // Set "te-topology" network type.
- TeTopology.TeTopologyBuilder teTopology = DefaultTeTopology.builder();
- AugmentedNwNetworkTypes.AugmentedNwNetworkTypesBuilder teNwType =
- DefaultAugmentedNwNetworkTypes.builder();
- teNwType.teTopology(teTopology.build());
- nwType.addYangAugmentedInfo(teNwType.build(), AugmentedNwNetworkTypes.class);
- }
- return builder.networkTypes(nwType.build());
- }
-
- private static NetworkBuilder te2YangTopologyIds(NetworkBuilder builder,
- org.onosproject.tetopology.management.api
- .TeTopologyId teTopologyId,
- TeTopologyService teTopologyService,
- KeyId networkKeyId) {
-
- //teBuilder. //OPTIMIZATIONCRITERION for Config/State
- Te.TeBuilder teBuilder = DefaultTe.builder();
- Config.ConfigBuilder configBuilder = DefaultConfig.builder();
- org.onosproject.tetopology.management.api.Network nt = teTopologyService.network(networkKeyId);
- TeTopologyKey teTopoKey = new TeTopologyKey(nt.teTopologyId().providerId(),
- nt.teTopologyId().clientId(),
- Long.valueOf(nt.teTopologyId().topologyId()));
- switch (teTopologyService.teTopology(teTopoKey).optimization()) {
- case LEAST_COST:
- configBuilder = configBuilder.optimizationCriterion(Cost.class);
- break;
- case SHORTEST_DELAY:
- configBuilder = configBuilder.optimizationCriterion(Delay.class);
- break;
- case NOT_OPTIMIZED:
- configBuilder = configBuilder.optimizationCriterion(NotOptimized.class);
- break;
- default:
- configBuilder = configBuilder.optimizationCriterion(TeOptimizationCriterion.class);
- break;
- }
-
- teBuilder = teBuilder.config(configBuilder.build());
-
- AugmentedNwNetwork.AugmentedNwNetworkBuilder nwAugment = DefaultAugmentedNwNetwork
- .builder();
- nwAugment.clientId(new TeGlobalId(teTopologyId.clientId()));
- nwAugment.providerId(new TeGlobalId(teTopologyId.providerId()));
- if (teTopologyId.topologyId() != null) {
- nwAugment.teTopologyId(new TeTopologyId(teTopologyId.topologyId()));
- }
- nwAugment.te(teBuilder.build());
- builder.addYangAugmentedInfo(nwAugment.build(),
- AugmentedNwNetwork.class);
- return builder;
- }
-
- /**
- * Network object conversion from TE Topology subsystem to YANG.
- *
- * @param teSubsystem TE Topology subsystem network object
- * @param operation operation type
- * @param teTopologyService teTopology core service
- * @return Network YANG object
- */
- public static Network teSubsystem2YangNetwork(
- org.onosproject.tetopology.management.api.Network teSubsystem,
- OperationType operation,
- TeTopologyService teTopologyService) {
- checkNotNull(teSubsystem, E_NULL_TE_NETWORK);
- checkNotNull(teSubsystem.networkId(), E_NULL_TE_NETWORKID);
-
- // Generate a network builder with the specific networkId.
- NetworkId networkId = NetworkId.fromString(teSubsystem.networkId().toString());
- NetworkBuilder builder = DefaultNetwork.builder()
- .yangNetworkOpType(
- toNetworksOperationType(operation))
- .networkId(networkId);
-
- // Supporting networks
- if (teSubsystem.supportingNetworkIds() != null) {
- builder = te2YangSupportingNetwork(builder, teSubsystem.supportingNetworkIds());
- }
-
- // Nodes
- if (teSubsystem.nodes() != null) {
- org.onosproject.tetopology.management.api.Network nt = teTopologyService.network(teSubsystem.networkId());
- TeTopologyKey teTopoKey = new TeTopologyKey(nt.teTopologyId().providerId(),
- nt.teTopologyId().clientId(),
- Long.valueOf(nt.teTopologyId().topologyId()));
- builder = te2YangNodes(builder, teSubsystem.nodes(),
- teTopologyService,
- teTopoKey);
- }
-
- // Network types
- builder = te2YangNetworkType(builder, teSubsystem.teTopologyId());
-
- // Add links - link is the augmentation
- if (teSubsystem.links() != null) {
- builder = te2YangLinks(builder, teSubsystem.links(), teTopologyService);
- }
-
- // TE Topology IDs
- if (teSubsystem.teTopologyId() != null) {
- builder = te2YangTopologyIds(builder, teSubsystem.teTopologyId(),
- teTopologyService,
- teSubsystem.networkId());
- }
-
- return builder.build();
- }
-
- /**
- * Network State object conversion from TE Topology subsystem to YANG.
- *
- * @param teSubsystem TE Topology subsystem network object
- * @param operation operation type
- * @return Network YANG object
- */
- public static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network
- .rev20151208.ietfnetwork.networksstate.Network
- teSubsystem2YangNetworkState(
- org.onosproject.tetopology.management.api.Network teSubsystem,
- OperationType operation) {
- checkNotNull(teSubsystem, E_NULL_TE_NETWORK);
- checkNotNull(teSubsystem.networkId(), E_NULL_TE_NETWORKID);
-
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
- .ietfnetwork.networksstate.Network.NetworkBuilder stateBuilder =
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
- .ietfnetwork.networksstate.DefaultNetwork.builder();
-
- if (teSubsystem.networkId() != null) {
- stateBuilder.networkRef(NetworkId.fromString(teSubsystem.networkId().toString()));
- }
- stateBuilder.serverProvided(teSubsystem.isServerProvided());
-
- // Operation type may be required.
- return stateBuilder.build();
- }
-
-
- /**
- * Network conversion from YANG to TE Topology subsystem.
- *
- * @param yangNetwork Network YANG object
- * @param yangNetworkState NetworkState YANG object
- * @param yangNetworks Networks YANG object
- * @return TE Topology subsystem defaultNetwork object
- */
- private static org.onosproject.tetopology.management.api.DefaultNetwork yang2TeDefaultNetwork(
- Network yangNetwork,
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.
- yang.ietf.network.rev20151208.ietfnetwork.networksstate.
- Network yangNetworkState,
- Networks yangNetworks, DeviceId deviceId) {
- checkNotNull(yangNetwork, E_NULL_YANG_NETWORK);
- checkNotNull(yangNetwork.networkId(), E_NULL_YANG_NETWORKID);
- String networkId = yangNetwork.networkId().uri().string();
-
- KeyId networkKeyId = KeyId.keyId(networkId);
- List<KeyId> supportingNetworkIds = null;
- Map<KeyId, NetworkNode> teNodes = null;
- Map<KeyId, NetworkLink> teLinks = null;
- org.onosproject.tetopology.management.api.TeTopologyId teTopologyId = null;
- boolean serverProvided = false;
-
- // Supporting networks
- if (yangNetwork.supportingNetwork() != null) {
- supportingNetworkIds = Lists.newArrayList();
- for (SupportingNetwork supportNw : yangNetwork.supportingNetwork()) {
- supportingNetworkIds.add(
- KeyId.keyId(supportNw.networkRef().uri().string()));
- }
- }
-
- // Nodes
- if (yangNetwork.node() != null) {
- teNodes = Maps.newHashMap();
- for (Node node : yangNetwork.node()) {
- // Convert the Yang Node to a TE node.
- teNodes.put(KeyId.keyId(node.nodeId().uri().string()),
- NodeConverter.yang2TeSubsystemNode(node, yangNetwork, yangNetworks));
- }
- }
-
- // Links
- if (yangNetwork.yangAugmentedInfo(AugmentedNdNetwork.class) != null) {
- AugmentedNdNetwork augmentLink =
- (AugmentedNdNetwork) yangNetwork.yangAugmentedInfo(AugmentedNdNetwork.class);
- teLinks = Maps.newHashMap();
- for (Link link : augmentLink.link()) {
- // Convert the Yang Link to a TE link.
- teLinks.put(KeyId.keyId(link.linkId().uri().string()),
- LinkConverter.yang2TeSubsystemLink(link, yangNetwork, yangNetworks));
- }
- }
-
- // TE Topology Ids
- if (yangNetwork.yangAugmentedInfo(AugmentedNwNetwork.class) != null) {
- AugmentedNwNetwork augmentTeIds =
- (AugmentedNwNetwork) yangNetwork.yangAugmentedInfo(AugmentedNwNetwork.class);
- teTopologyId =
- new org.onosproject.tetopology.management.api.TeTopologyId(
- augmentTeIds.providerId().uint32(),
- augmentTeIds.clientId().uint32(),
- augmentTeIds.teTopologyId().string());
- }
-
- if (yangNetworkState != null) {
- serverProvided = yangNetworkState.serverProvided();
- }
-
- org.onosproject.tetopology.management.api.DefaultNetwork network =
- new org.onosproject.tetopology.management.api.DefaultNetwork(networkKeyId, supportingNetworkIds,
- teNodes, teLinks, teTopologyId,
- serverProvided,
- deviceId,
- NOT_OPTIMIZED);
- return network;
- }
-
- /**
- * Network object conversion from YANG to TE Topology subsystem.
- *
- * @param yangNetwork Network YANG object
- * @param yangNetworks Networks YANG object
- * @param deviceId The identifier of RESTCONF server device
- * @return network TE Topology subsystem networks object
- */
- public static org.onosproject.tetopology.management.api.Network yang2TeSubsystemNetwork(Network yangNetwork,
- Networks yangNetworks,
- DeviceId deviceId) {
- return yang2TeDefaultNetwork(yangNetwork, null, yangNetworks, deviceId);
- }
-
- /**
- * Network and State object conversion from YANG to TE Topology subsystem.
- *
- * @param yangNetwork Network YANG object
- * @param yangNetworkState NetworkState YANG object
- * @param yangNetworks Networks YANG object
- * @param deviceId The identifier of RESTCONF server device
- * @return teSubsystem TE Topology subsystem networks object
- */
- public static org.onosproject.tetopology.management.api.Network yang2TeSubsystemNetwork(Network yangNetwork,
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork
- .networksstate.Network yangNetworkState, Networks yangNetworks, DeviceId deviceId) {
- checkNotNull(yangNetworkState, E_NULL_YANG_NETWORKSSTATE_NETWORK);
- checkNotNull(yangNetworkState.networkRef(), E_NULL_YANG_NETWORKSSTATE_NETWORKREF);
-
- org.onosproject.tetopology.management.api.DefaultNetwork teNetwork =
- yang2TeDefaultNetwork(yangNetwork, yangNetworkState, yangNetworks, deviceId);
-
- String networkref = yangNetworkState.networkRef().toString();
- checkState(teNetwork.networkId().toString().equals(networkref),
- E_DIFF_YANG_NETWORKID);
-
- return teNetwork;
- }
-
- /**
- * Converts a TE Topology event from the data format used in core to its
- * corresponding YANG Object (YO) format.
- *
- * @param event TE Topology event from the core
- * @param teTopologyService TE Topology Service object
- * @return YANG Object converted from event
- */
- public static IetfTeTopologyEvent teTopoEvent2YangIetfTeTopoEvent(TeTopologyEvent event,
- TeTopologyService teTopologyService) {
- IetfTeTopologyEvent yangEvent = null;
- IetfTeTopologyEventSubject eventSubject = new IetfTeTopologyEventSubject();
-
- IetfTeTopologyEvent.Type yangEventType = teTopoEventType2YangIetfTopoEventType(event.type());
- if (yangEventType == IetfTeTopologyEvent.Type.TE_LINK_EVENT) {
- NetworkLinkEventSubject eventData = (NetworkLinkEventSubject) event.subject();
- TeTopologyEventTypeEnum linkEventType = teTopoEventType2YangTeTopoEventType(event.type());
- TeLinkEvent yangLinkEvent = LinkConverter
- .teNetworkLink2yangTeLinkEvent(linkEventType, eventData, teTopologyService);
- eventSubject.teLinkEvent(yangLinkEvent);
- yangEvent = new IetfTeTopologyEvent(IetfTeTopologyEvent.Type.TE_LINK_EVENT, eventSubject);
- } else if (yangEventType == IetfTeTopologyEvent.Type.TE_NODE_EVENT) {
- NetworkNodeEventSubject eventData = (NetworkNodeEventSubject) event.subject();
- TeTopologyEventTypeEnum nodeEventType = teTopoEventType2YangTeTopoEventType(event.type());
- TeNodeEvent yangNodeEvent = NodeConverter.teNetworkNode2yangTeNodeEvent(nodeEventType, eventData);
- eventSubject.teNodeEvent(yangNodeEvent);
- yangEvent = new IetfTeTopologyEvent(IetfTeTopologyEvent.Type.TE_NODE_EVENT, eventSubject);
- }
-
- return yangEvent;
- }
-
- private static IetfTeTopologyEvent.Type teTopoEventType2YangIetfTopoEventType(TeTopologyEvent.Type type) {
- IetfTeTopologyEvent.Type returnType = null;
-
- switch (type) {
- case LINK_ADDED:
- case LINK_REMOVED:
- case LINK_UPDATED:
- returnType = IetfTeTopologyEvent.Type.TE_LINK_EVENT;
- break;
- case NODE_ADDED:
- case NODE_REMOVED:
- case NODE_UPDATED:
- returnType = IetfTeTopologyEvent.Type.TE_NODE_EVENT;
- break;
- default:
- log.warn("teTopoEventType2YangIetfTopoEventType: unknown type: {}", type);
- }
-
- return returnType;
- }
-
- private static TeTopologyEventTypeEnum teTopoEventType2YangTeTopoEventType(TeTopologyEvent.Type type) {
- TeTopologyEventTypeEnum returnType = null;
-
- switch (type) {
- case LINK_ADDED:
- case NODE_ADDED:
- returnType = TeTopologyEventTypeEnum.ADD;
- break;
- case LINK_REMOVED:
- case NODE_REMOVED:
- returnType = TeTopologyEventTypeEnum.REMOVE;
- break;
- case LINK_UPDATED:
- case NODE_UPDATED:
- returnType = TeTopologyEventTypeEnum.UPDATE;
- break;
- default:
- log.warn("teTopoEventType2YangteTopoEventType: unsupported type: {}", type);
- break;
- }
-
- return returnType;
- }
-}
-
-
diff --git a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/NodeConverter.java b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/NodeConverter.java
deleted file mode 100644
index 4a2e87f..0000000
--- a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/NodeConverter.java
+++ /dev/null
@@ -1,1173 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.teyang.utils.topology;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.BitSet;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.tetopology.management.api.EncodingType;
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.SwitchingType;
-import org.onosproject.tetopology.management.api.TeConstants;
-import org.onosproject.tetopology.management.api.TeStatus;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.TeTopologyService;
-import org.onosproject.tetopology.management.api.link.ElementType;
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.link.TeIpv4;
-import org.onosproject.tetopology.management.api.link.TeLinkId;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.link.TePathAttributes;
-import org.onosproject.tetopology.management.api.link.UnderlayAbstractPath;
-import org.onosproject.tetopology.management.api.node.CommonNodeData;
-import org.onosproject.tetopology.management.api.node.ConnectivityMatrix;
-import org.onosproject.tetopology.management.api.node.DefaultNetworkNode;
-import org.onosproject.tetopology.management.api.node.DefaultTeNode;
-import org.onosproject.tetopology.management.api.node.LocalLinkConnectivity;
-import org.onosproject.tetopology.management.api.node.NetworkNode;
-import org.onosproject.tetopology.management.api.node.NetworkNodeEventSubject;
-import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
-import org.onosproject.tetopology.management.api.node.TeNode;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TerminationPoint;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev20130715.ietfinettypes.DomainName;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev20130715.ietfinettypes.IpAddress;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NetworkId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.Networks;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NodeId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks.Network;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
- .ietfnetwork.networks.network.DefaultNode;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
- .ietfnetwork.networks.network.Node;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
- .ietfnetwork.networks.network.node.DefaultSupportingNode;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208
- .ietfnetwork.networks.network.node.SupportingNode;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.node.AugmentedNdNode;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.node.DefaultAugmentedNdNode;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.DefaultTeNodeEvent;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.TeNodeEvent;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.connectivitymatrixentryattributes.DefaultUnderlay;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.connectivitymatrixentryattributes.Underlay;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.informationsourcepernodeattributes.DefaultInformationSourceState;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.informationsourcepernodeattributes.InformationSourceState;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.informationsourcepernodeattributes.informationsourcestate.DefaultTopology;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.informationsourcepernodeattributes.informationsourcestate.Topology;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.networks.network.node.AugmentedNwNode;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.networks.network.node.DefaultAugmentedNwNode;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.networks.network.node.terminationpoint.AugmentedNtTerminationPoint;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconnectivityattributes.DefaultTeSrlgs;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkconnectivityattributes.TeSrlgs;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkunderlayattributes.DefaultPrimaryPath;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkunderlayattributes.PrimaryPath;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkunderlayattributes.primarypath.DefaultPathElement;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkunderlayattributes.primarypath.PathElement;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeaugment.DefaultTe;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeaugment.DefaultTe.TeBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeaugment.Te;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeaugment.te.Config;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeaugment.te.DefaultConfig;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeaugment.te.DefaultState;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeaugment.te.DefaultTunnelTerminationPoint;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeaugment.te.State;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeaugment.te.TunnelTerminationPoint;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeaugment.te.tunnelterminationpoint.DefaultSupportingTunnelTerminationPoint;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeaugment.te.tunnelterminationpoint.SupportingTunnelTerminationPoint;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeconfigattributes.DefaultTeNodeAttributes;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeconfigattributes.TeNodeAttributes;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeconfigattributes.TeNodeAttributes.TeNodeAttributesBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeconnectivitymatrix.ConnectivityMatrices;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeconnectivitymatrix.DefaultConnectivityMatrices;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeconnectivitymatrix.DefaultConnectivityMatrices.ConnectivityMatricesBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeconnectivitymatrix.connectivitymatrices.DefaultConnectivityMatrix;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeconnectivitymatrix.connectivitymatrices.DefaultConnectivityMatrix.ConnectivityMatrixBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeconnectivitymatrix.connectivitymatrices.connectivitymatrix.DefaultFrom;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeconnectivitymatrix.connectivitymatrices.connectivitymatrix.DefaultTo;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeinfoattributes.DefaultUnderlayTopology;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeinfoattributes.UnderlayTopology;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodetunnelterminationattributes.DefaultLocalLinkConnectivities;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodetunnelterminationattributes.LocalLinkConnectivities;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodetunnelterminationattributes.locallinkconnectivities.DefaultLocalLinkConnectivity;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodetunnelterminationattributes.locallinkconnectivities.DefaultLocalLinkConnectivity.LocalLinkConnectivityBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.Srlg;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeAdminStatus;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeNodeId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeTopologyEventType;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.explicitroutesubobject.type.AsNumber;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.explicitroutesubobject.type.DefaultAsNumber;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.explicitroutesubobject.type.DefaultUnnumberedLink;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.explicitroutesubobject.type.Ipv4Address;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.explicitroutesubobject.type.UnnumberedLink;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.tetopologyeventtype.TeTopologyEventTypeEnum;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev20130715.ietfyangtypes.DottedQuad;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-/**
- * Node conversion functions.
- */
-public final class NodeConverter {
-
- private static final String E_NULL_TE_SUBSYSTEM_TE_NODE =
- "TeSubsystem teNode object cannot be null";
- private static final String E_NULL_TE_SUBSYSTEM_TE_TUNNEL_TP =
- "TeSubsystem teTunnelTp object cannot be null";
- private static final String E_NULL_TE_SUBSYSTEM_NODE =
- "TeSubsystem ndoe object cannot be null";
- private static final String E_NULL_YANG_NODE =
- "Yang node object cannot be null";
-
- // no instantiation
- private NodeConverter() {
- }
-
- /**
- * TE Node Config object conversion from TE Topology subsystem to YANG.
- *
- * @param teSubsystemTeNode TE node object
- * @param teTopologyService teTopolog core service
- * @return TE Node Config YANG object
- */
- private static Config teNode2YangConfig(TeNode teSubsystemTeNode, TeTopologyService teTopologyService) {
- checkNotNull(teSubsystemTeNode, E_NULL_TE_SUBSYSTEM_TE_NODE);
-
- TeNodeAttributes.TeNodeAttributesBuilder teNodeAttributesConfigBuilder = DefaultTeNodeAttributes
- .builder();
- teNodeAttributesConfigBuilder = teNodeAttributesConfigBuilder
- .isAbstract(teSubsystemTeNode.flags()
- .get(TeNode.BIT_ABSTRACT));
-
- if (teSubsystemTeNode.adminStatus() != null) {
- teNodeAttributesConfigBuilder = teNodeAttributesConfigBuilder
- .adminStatus(EnumConverter.teSubsystem2YangAdminStatus(teSubsystemTeNode.adminStatus()));
- }
-
- if (teSubsystemTeNode.name() != null) {
- teNodeAttributesConfigBuilder = teNodeAttributesConfigBuilder
- .name(DomainName.fromString(teSubsystemTeNode.name()));
- }
-
- if (teSubsystemTeNode.underlayTeTopologyId() != null) {
- teNodeAttributesConfigBuilder = teNodeAttributesConfigBuilder
- .underlayTopology(teNode2YangUnderlay(teSubsystemTeNode
- .underlayTeTopologyId(), teTopologyService));
- }
-
- // TODO: should we ignore this from te to yang? as we've already set yang supportingNode
- //if (teSubsystemTeNode.supportingTeNodeId() != null) {
- //}
-
- if (teSubsystemTeNode.connectivityMatrices() != null) {
- teNodeAttributesConfigBuilder = te2YangConnectivityMatrix(teNodeAttributesConfigBuilder,
- teSubsystemTeNode.connectivityMatrices());
- }
-
-
- Config.ConfigBuilder yangConfigBuilder = DefaultConfig.builder();
- yangConfigBuilder = yangConfigBuilder.teNodeAttributes(teNodeAttributesConfigBuilder.build());
-
- return yangConfigBuilder.build();
- }
-
- private static TeNodeAttributesBuilder
- te2YangConnectivityMatrix(TeNodeAttributesBuilder teNodeAttributesConfigBuilder,
- Map<Long, ConnectivityMatrix> connectivityMatrices) {
- ConnectivityMatrixBuilder connectivityMatrixConfigBuilder = DefaultConnectivityMatrix.builder();
- ConnectivityMatricesBuilder yangConnectivityMatricesBuilder = DefaultConnectivityMatrices.builder();
- for (Map.Entry<Long, ConnectivityMatrix> teCmEntry :
- connectivityMatrices.entrySet()) {
- connectivityMatrixConfigBuilder = connectivityMatrixConfigBuilder
- .id(teCmEntry.getKey())
- .isAllowed(!teCmEntry.getValue().flags()
- .get(ConnectivityMatrix.BIT_DISALLOWED))
- .from(new DefaultFrom.FromBuilder() // TODO: for now, assuming that there is
- // only one 'from', and mergingList is empty
- .tpRef(((TeLinkId) teCmEntry.getValue().from()).value())
- .build())
- .to(new DefaultTo.ToBuilder() // TODO: for now, assuming that there is only
- // one item in constrainingElements list
- .tpRef(((TeLinkId) teCmEntry.getValue().constrainingElements().get(0)).value())
- .build());
- if (teCmEntry.getValue().teAttributes() != null) {
- connectivityMatrixConfigBuilder = connectivityMatrixConfigBuilder
- .teDefaultMetric(teCmEntry.getValue().teAttributes().cost())
- .teDelayMetric(teCmEntry.getValue().teAttributes().delay());
- }
-
- TeSrlgs.TeSrlgsBuilder teSrlgsBuilder = DefaultTeSrlgs.builder();
- if (teCmEntry.getValue().teAttributes().srlgs() != null) {
- for (Long val : teCmEntry.getValue().teAttributes().srlgs()) {
- Srlg srlg = new Srlg(val);
- teSrlgsBuilder = teSrlgsBuilder.addToValue(srlg);
- }
- connectivityMatrixConfigBuilder = connectivityMatrixConfigBuilder
- .teSrlgs(teSrlgsBuilder.build());
- }
-
- Underlay.UnderlayBuilder underlayBuilder = DefaultUnderlay.builder();
- PrimaryPath.PrimaryPathBuilder primaryPathBuilder = DefaultPrimaryPath.builder();
-
- PathElement.PathElementBuilder pathElementBuilder = DefaultPathElement.builder();
- if (teCmEntry.getValue().underlayPath() != null &&
- teCmEntry.getValue().underlayPath().pathElements() != null &&
- !teCmEntry.getValue().underlayPath().pathElements().isEmpty()) {
- for (org.onosproject.tetopology.management.api.link.PathElement patel : teCmEntry.getValue()
- .underlayPath().pathElements()) {
- pathElementBuilder = pathElementBuilder.pathElementId(patel.pathElementId());
- if (patel.type() instanceof AsNumber) {
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes
- .explicitroutesubobject.type.AsNumber
- .AsNumberBuilder asNumberBuilder = new DefaultAsNumber.AsNumberBuilder();
- asNumberBuilder = asNumberBuilder.asNumber(((AsNumber) patel.type()).asNumber());
- pathElementBuilder = pathElementBuilder.type(asNumberBuilder.build());
- } else if (patel.type() instanceof UnnumberedLink) {
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes
- .explicitroutesubobject.type.UnnumberedLink
- .UnnumberedLinkBuilder unNumberBuilder = DefaultUnnumberedLink.builder();
- unNumberBuilder = unNumberBuilder.interfaceId(((UnnumberedLink) patel.type()).interfaceId());
- unNumberBuilder = unNumberBuilder.routerId(IpAddress.fromString(((UnnumberedLink) patel.type())
- .routerId().toString()));
- pathElementBuilder = pathElementBuilder.type(unNumberBuilder.build());
- }
- primaryPathBuilder = primaryPathBuilder
- .addToPathElement(pathElementBuilder.build());
- }
- }
-
- underlayBuilder = underlayBuilder.primaryPath(primaryPathBuilder.build());
- connectivityMatrixConfigBuilder = connectivityMatrixConfigBuilder
- .underlay(underlayBuilder.build());
-
- yangConnectivityMatricesBuilder = yangConnectivityMatricesBuilder
- .addToConnectivityMatrix(connectivityMatrixConfigBuilder.build());
- }
- teNodeAttributesConfigBuilder = teNodeAttributesConfigBuilder
- .connectivityMatrices(yangConnectivityMatricesBuilder.build());
- return teNodeAttributesConfigBuilder;
- }
-
- private static UnderlayTopology teNode2YangUnderlay(TeTopologyKey underlayTopology,
- TeTopologyService teTopologyService) {
- UnderlayTopology.UnderlayTopologyBuilder underlayBuilder = DefaultUnderlayTopology.builder();
-
- underlayBuilder = underlayBuilder.networkRef(teTopologyService.networkId(underlayTopology));
-
- return underlayBuilder.build();
- }
-
- /**
- * TE Node State object conversion from TE Topology subsystem to YANG.
- *
- * @param teSubsystemTeNode TE node object
- * @param teTopologyService teTopology core service
- * @return TE Node State YANG object
- */
- private static State teNode2YangState(TeNode teSubsystemTeNode, TeTopologyService teTopologyService) {
- checkNotNull(teSubsystemTeNode, E_NULL_TE_SUBSYSTEM_TE_NODE);
-
- TeNodeAttributes
- .TeNodeAttributesBuilder teNodeAttributesStateBuilder =
- DefaultTeNodeAttributes.builder()
- .isAbstract(teSubsystemTeNode.flags()
- .get(TeNode.BIT_ABSTRACT));
-
- if (teSubsystemTeNode.adminStatus() != null) {
- teNodeAttributesStateBuilder = teNodeAttributesStateBuilder
- .adminStatus(EnumConverter.teSubsystem2YangAdminStatus(teSubsystemTeNode.adminStatus()));
- }
-
- if (teSubsystemTeNode.name() != null) {
- teNodeAttributesStateBuilder = teNodeAttributesStateBuilder
- .name(DomainName.fromString(teSubsystemTeNode.name()));
- }
-
- if (teSubsystemTeNode.underlayTeTopologyId() != null) {
- teNodeAttributesStateBuilder = teNodeAttributesStateBuilder
- .underlayTopology(teNode2YangUnderlay(teSubsystemTeNode
- .underlayTeTopologyId(), teTopologyService));
- }
-
- if (teSubsystemTeNode.connectivityMatrices() != null) {
- teNodeAttributesStateBuilder = te2YangConnectivityMatrix(teNodeAttributesStateBuilder,
- teSubsystemTeNode.connectivityMatrices());
- }
-
- // TODO: should we ignore this from te to yang? as we've already set yang supportingNode
- //if (teSubsystemTeNode.supportingTeNodeId() != null) {
- //}
-
- State.StateBuilder yangStateBuilder = DefaultState.builder();
- yangStateBuilder = yangStateBuilder.teNodeAttributes(teNodeAttributesStateBuilder.build());
-
- if (teSubsystemTeNode.opStatus() != null) {
- yangStateBuilder = yangStateBuilder.operStatus(EnumConverter
- .teSubsystem2YangOperStatus(teSubsystemTeNode.opStatus()));
- }
-
- if (teSubsystemTeNode.sourceTeNodeId() != null) {
- InformationSourceState.InformationSourceStateBuilder issBuilder = DefaultInformationSourceState.builder();
-
- Topology.TopologyBuilder topologyBuilder = DefaultTopology.builder();
- topologyBuilder = topologyBuilder.nodeRef(teTopologyService
- .nodeKey(teSubsystemTeNode.sourceTeNodeId()).nodeId())
- .networkRef(teTopologyService
- .nodeKey(teSubsystemTeNode.sourceTeNodeId())
- .networkId());
-
- issBuilder = issBuilder.topology(topologyBuilder.build());
- yangStateBuilder.informationSourceState(issBuilder.build());
- }
-
- return yangStateBuilder.build();
- }
-
- private static class ByteUtils {
-
- public static byte[] longToBytes(long x) {
- long temp = x;
- byte[] b = new byte[8];
- for (int i = 0; i < b.length; i++) {
- b[i] = new Long(temp & 0xff).byteValue();
- temp = temp >> 8;
- }
- return b;
- }
-
- public static long bytesToLong(byte[] bytes) {
- return (bytes[7] & 255L) << 56
- | (bytes[6] & 255L) << 48
- | (bytes[5] & 255L) << 40
- | (bytes[4] & 255L) << 32
- | (bytes[3] & 255L) << 24
- | (bytes[2] & 255L) << 16
- | (bytes[1] & 255L) << 8 | bytes[0] & 255L;
- }
- }
-
- /**
- * TE Node TunnelTerminationPoint object conversion from TE Topology subsystem to YANG.
- *
- * @param teTunnelTp TE TunnelTerminationPoint object
- * @param teTpId
- * @param teTopologyService
- * @param teNodeKey
- * @return TunnelTerminationPoint YANG object
- */
- private static TunnelTerminationPoint teSubsystem2YangTtp(
- org.onosproject.tetopology.management.api.node
- .TunnelTerminationPoint teTunnelTp, Long teTpId,
- TeTopologyService teTopologyService,
- TeNodeKey teNodeKey) {
- checkNotNull(teTunnelTp, E_NULL_TE_SUBSYSTEM_TE_TUNNEL_TP);
-
- TunnelTerminationPoint.TunnelTerminationPointBuilder tunnelTpBuilder =
- DefaultTunnelTerminationPoint.builder().tunnelTpId(ByteUtils.longToBytes(teTpId.longValue()));
-
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.tenodeaugment.te.tunnelterminationpoint.Config.ConfigBuilder ttpConfigBuilder =
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.tenodeaugment.te.tunnelterminationpoint.DefaultConfig.builder();
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.tenodeaugment.te.tunnelterminationpoint.State.StateBuilder ttpStateBuilder =
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.tenodeaugment.te.tunnelterminationpoint.DefaultState.builder();
-
- // Assuming teTunnelTp only has one interLayerLock
- if (teTunnelTp.interLayerLockList() != null && !teTunnelTp.interLayerLockList().isEmpty()) {
- ttpConfigBuilder = ttpConfigBuilder.interLayerLockId(teTunnelTp.interLayerLockList().get(0));
- ttpStateBuilder = ttpStateBuilder.interLayerLockId(teTunnelTp.interLayerLockList().get(0));
- }
-
- // TODO: retrieve teTunnelTp.switchingLayer() and set it to ttpConfigBuilder and ttpStateBuilder
- // TODO: retrieve more attributes from teTunnelTp and assign to ttpConfigBuilder and ttpStateBuilder
- // For which ones we can do the conversion?
-
- LocalLinkConnectivities.LocalLinkConnectivitiesBuilder
- localLinkConnectivitiesBuilder = DefaultLocalLinkConnectivities.builder();
- if (teTunnelTp.localLinkConnectivityList() != null && !teTunnelTp.localLinkConnectivityList().isEmpty()) {
- for (LocalLinkConnectivity llcn : teTunnelTp.localLinkConnectivityList()) {
- // convert teLinkId to networkLinkKey
- if (llcn != null && llcn.constrainingElements() != null
- && !llcn.constrainingElements().isEmpty()) {
- TeLinkId telinkId = (TeLinkId) llcn.constrainingElements().get(0);
- TeLinkTpGlobalKey globalKey = new TeLinkTpGlobalKey(teNodeKey, telinkId.value());
- NetworkLinkKey netLinkKey = teTopologyService.linkKey(globalKey);
- NetworkLink networkLink = teTopologyService
- .network(netLinkKey.networkId()).links().get(netLinkKey.linkId());
- LocalLinkConnectivityBuilder llcBuilder = DefaultLocalLinkConnectivity.builder();
- llcBuilder = llcBuilder.linkTpRef(networkLink.source().tpId());
- localLinkConnectivitiesBuilder.addToLocalLinkConnectivity(llcBuilder.build());
- }
- }
-
-
- ttpConfigBuilder = ttpConfigBuilder.localLinkConnectivities(localLinkConnectivitiesBuilder.build());
- ttpStateBuilder = ttpStateBuilder.localLinkConnectivities(localLinkConnectivitiesBuilder.build());
- }
-
- tunnelTpBuilder = tunnelTpBuilder.config(ttpConfigBuilder.build())
- .state(ttpStateBuilder.build());
- SupportingTunnelTerminationPoint.SupportingTunnelTerminationPointBuilder
- supportTtpBuilder = DefaultSupportingTunnelTerminationPoint.builder();
- if (teTunnelTp.supportingTtpId() != null) {
- TeTopologyKey teTopologyKey = new TeTopologyKey(teTunnelTp.supportingTtpId().providerId(),
- teTunnelTp.supportingTtpId().clientId(),
- teTunnelTp.supportingTtpId().topologyId());
-
- TeNodeKey teNodeKeySup = new TeNodeKey(teTopologyKey, teTunnelTp.supportingTtpId().teNodeId());
- NetworkNodeKey networkNodeKey = teTopologyService.nodeKey(teNodeKeySup);
- NetworkId netId = NetworkId.fromString(networkNodeKey.networkId().toString());
-
- supportTtpBuilder = supportTtpBuilder
- .nodeRef(NodeId.fromString(networkNodeKey.nodeId().toString()))
- .networkRef(netId)
- .tunnelTpRef(ByteUtils.longToBytes(teTunnelTp.supportingTtpId().ttpId()));
-
- tunnelTpBuilder = tunnelTpBuilder.addToSupportingTunnelTerminationPoint(supportTtpBuilder.build());
- }
-
-
- return tunnelTpBuilder.build();
- }
-
- /**
- * Node object conversion from TE Topology subsystem to YANG.
- *
- * @param teSubsystem TE subsystem node
- * @param teTopologyService teTopology core service
- * @param teTopologyKey teTopologyKey
- * @return YANG node
- */
- public static Node teSubsystem2YangNode(org.onosproject.tetopology.management.api.node.NetworkNode teSubsystem,
- TeTopologyService teTopologyService,
- TeTopologyKey teTopologyKey) {
- checkNotNull(teSubsystem, E_NULL_TE_SUBSYSTEM_NODE);
-
- NodeId nodeId = NodeId.fromString(teSubsystem.nodeId().toString());
-
- Node.NodeBuilder builder = DefaultNode.builder().nodeId(nodeId);
-
- if (teSubsystem.supportingNodeIds() != null) {
- List<SupportingNode> sNodes = Lists.newArrayList();
- SupportingNode.SupportingNodeBuilder spNodeBuilder = DefaultSupportingNode
- .builder();
- for (NetworkNodeKey nodeKey : teSubsystem.supportingNodeIds()) {
- sNodes.add(spNodeBuilder
- .networkRef(NetworkId
- .fromString(nodeKey.networkId().toString()))
- .nodeRef(NodeId.fromString(nodeKey.nodeId().toString()))
- .build());
- }
- builder = builder.supportingNode(sNodes);
- }
-
- if (teSubsystem.terminationPoints() != null) {
- AugmentedNdNode.AugmentedNdNodeBuilder tpAugmentBuilder = DefaultAugmentedNdNode
- .builder();
- Map<KeyId, TerminationPoint> teSubsystemTeTp = teSubsystem
- .terminationPoints();
-
- for (TerminationPoint teTp : teSubsystemTeTp.values()) {
- tpAugmentBuilder.addToTerminationPoint(TerminationPointConverter
- .teSubsystem2YangTerminationPoint(teTp));
- }
- builder.addYangAugmentedInfo(tpAugmentBuilder.build(),
- AugmentedNdNode.class);
- }
-
- if (teSubsystem.teNode() != null) {
- AugmentedNwNode.AugmentedNwNodeBuilder nodeAugmentBuilder = DefaultAugmentedNwNode
- .builder();
-
- TeNode teSubsystemTeNode = teSubsystem.teNode();
-
- TeBuilder yangTeBuilder = DefaultTe.builder();
-
- nodeAugmentBuilder = nodeAugmentBuilder
- .teNodeId(TeNodeId.of(DottedQuad.of(Ip4Address
- .valueOf((int) teSubsystemTeNode.teNodeId())
- .toString())));
-
- // Set configuration data
- // Set state data
- yangTeBuilder = yangTeBuilder.config(teNode2YangConfig(teSubsystemTeNode, teTopologyService))
- .state(teNode2YangState(teSubsystemTeNode, teTopologyService));
-
- if (teSubsystemTeNode.tunnelTerminationPoints() != null) {
- for (Map.Entry<Long, org.onosproject.tetopology.management.api.node.TunnelTerminationPoint> entry :
- teSubsystemTeNode.tunnelTerminationPoints().entrySet()) {
- yangTeBuilder = yangTeBuilder
- .addToTunnelTerminationPoint(teSubsystem2YangTtp(entry
- .getValue(), entry.getKey(), teTopologyService,
- new TeNodeKey(teTopologyKey, teSubsystemTeNode.teNodeId())));
- }
- }
-
- nodeAugmentBuilder = nodeAugmentBuilder.te(yangTeBuilder.build());
- builder.addYangAugmentedInfo(nodeAugmentBuilder.build(),
- AugmentedNwNode.class);
- }
- return builder.build();
- }
-
- /**
- * Node object conversion from YANG to TE Topology subsystem.
- *
- * @param yangNode Node in YANG model
- * @param yangNetwork YANG network
- * @param yangNetworks YANG networks
- * @return TE subsystem node
- */
- public static org.onosproject.tetopology.management.api.node.NetworkNode
- yang2TeSubsystemNode(Node yangNode, Network yangNetwork,
- Networks yangNetworks) {
- checkNotNull(yangNode, E_NULL_YANG_NODE);
-
- org.onosproject.tetopology.management.api.node.DefaultNetworkNode node;
- List<NetworkNodeKey> spNodes = null;
- TeNode teNode = null;
- Map<KeyId, TerminationPoint> tps = null;
-
- if (yangNode.supportingNode() != null) {
- spNodes = Lists.newArrayList();
- for (SupportingNode yangSpNode : yangNode.supportingNode()) {
- NetworkNodeKey nodeKey = new NetworkNodeKey(KeyId.keyId(yangSpNode.nodeRef().uri().toString()),
- KeyId.keyId(yangSpNode.networkRef().uri().toString()));
- spNodes.add(nodeKey);
- }
- }
-
- if (yangNode.yangAugmentedInfoMap() != null
- && !yangNode.yangAugmentedInfoMap().isEmpty()) {
-
- AugmentedNdNode yangTpNodeAugment = (AugmentedNdNode) yangNode
- .yangAugmentedInfo(AugmentedNdNode.class);
- if (yang2TeSubsystemTpNodeAugment(yangTpNodeAugment) != null) {
- tps = yang2TeSubsystemTpNodeAugment(yangTpNodeAugment);
- }
-
- AugmentedNwNode yangNodeAugment = (AugmentedNwNode) yangNode
- .yangAugmentedInfo(AugmentedNwNode.class);
- if (yangNodeAugment != null && yangNodeAugment.te() != null && yangNodeAugment.teNodeId() != null) {
- TeNodeId teNodeId = yangNodeAugment.teNodeId();
- Te yangNodeAugTe = yangNodeAugment.te();
- teNode = yang2TeSubsystemNodeAugment(yangNodeAugTe, teNodeId,
- yangNetwork,
- yangNetworks,
- yangNode,
- tps);
- }
- }
-
- node = new org.onosproject.tetopology.management.api.node
- .DefaultNetworkNode(KeyId.keyId(yangNode.nodeId().uri().string()), spNodes, teNode, tps);
- return node;
- }
-
- // TODO: convert connectivity matrix from yang to te
- private static Map<Long, ConnectivityMatrix>
- yang2TeSubsystemNodeConnectivityMatrix(String networkId,
- String nodeId,
- ConnectivityMatrices yangMatrices) {
-
- Map<Long, ConnectivityMatrix> teCmList = Maps.newHashMap();
-
- List<org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology
- .tenodeconnectivitymatrix.connectivitymatrices.ConnectivityMatrix>
- yangMatrix = yangMatrices.connectivityMatrix();
- for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te
- .topology.rev20170110.ietftetopology.tenodeconnectivitymatrix.connectivitymatrices.
- ConnectivityMatrix cmYang : yangMatrix) {
-
- ElementType from = new TeLinkId(Long.valueOf(((String) cmYang.from().tpRef()))); // is this correct?
-
- UnderlayAbstractPath underlayPath = null; // ignore
- List<org.onosproject.tetopology.management.api.link.PathElement> pathElements = Lists.newArrayList();
- Boolean loose = false;
- long longTeNodeId = TeConstants.NIL_LONG_VALUE;
- if (cmYang != null && cmYang.underlay() != null && cmYang.underlay().primaryPath() != null
- && cmYang.underlay().primaryPath().pathElement() != null
- && !cmYang.underlay().primaryPath().pathElement().isEmpty()) {
- for (PathElement yangPathEl : cmYang.underlay().primaryPath().pathElement()) {
- ElementType type = null;
- if (yangPathEl.type() instanceof UnnumberedLink) {
- String rS = ((UnnumberedLink) (yangPathEl.type())).routerId().toString();
- org.onlab.packet.IpAddress routerId = org.onlab.packet.IpAddress.valueOf(rS);
- long interfaceId = ((UnnumberedLink) yangPathEl.type()).interfaceId();
- type = new org.onosproject.tetopology.management.api.link.UnnumberedLink(routerId, interfaceId);
- longTeNodeId = Long.valueOf(((UnnumberedLink) yangPathEl.type()).routerId().toString());
- } else if (yangPathEl.type() instanceof Ipv4Address) {
- short v4PrefixLength = ((Ipv4Address) yangPathEl.type())
- .v4PrefixLength();
-
- Ip4Address v4Address = Ip4Address
- .valueOf(((Ipv4Address) yangPathEl.type())
- .v4Address().string());
-
- loose = ((Ipv4Address) yangPathEl.type()).v4Loose();
- type = new TeIpv4(v4Address, v4PrefixLength);
- }
- org.onosproject.tetopology.management.api.link.PathElement
- patel = new org.onosproject.tetopology.management.api.link
- .PathElement(yangPathEl.pathElementId(),
- longTeNodeId,
- type,
- loose);
- pathElements.add(patel);
- }
- }
- underlayPath = new UnderlayAbstractPath(pathElements, loose);
-
- List<ElementType> mergingList = Lists.newArrayList(); // empty merging list for now
-
- List<ElementType> constrainingElements = Lists.newArrayList();
- ElementType to = new TeLinkId(Long.valueOf(((String) cmYang.to().tpRef()))); // is this correct?
- constrainingElements.add(to);
-
- BitSet flags = new BitSet(); // what are the flags in cmYang?
-
- List<Long> srlgs = Lists.newArrayList();
- if (cmYang.teSrlgs() != null) {
- for (Srlg srlg : cmYang.teSrlgs().value()) {
- srlgs.add(srlg.uint32());
- }
- }
- TePathAttributes teAttributes = new
- TePathAttributes(cmYang.teDefaultMetric(),
- cmYang.teDelayMetric(),
- srlgs);
- ConnectivityMatrix coreCm = new ConnectivityMatrix(cmYang.id(),
- from,
- mergingList,
- constrainingElements,
- flags,
- teAttributes,
- underlayPath);
-
- teCmList.put(cmYang.id(), coreCm);
- }
-
- return teCmList;
- }
-
- private static TeTopologyKey yang2TeSubsystemNodeUnderlayTopology(UnderlayTopology ut, Networks yangNetworks) {
- TeTopologyKey tetopokey = LinkConverter.findTopologyId(yangNetworks,
- ut.networkRef());
- return tetopokey;
- }
-
- // TODO: retrieve the details of tunnel termiantion points from yang to te
- private static Map<Long, org.onosproject.tetopology.management.api.node.
- TunnelTerminationPoint> yang2TeSubsystemTtp(List<TunnelTerminationPoint> ttps, Node yangNode,
- Networks yangNetworks) {
- Map<Long, org.onosproject.tetopology.management.api.node.TunnelTerminationPoint> ttpsMap = Maps
- .newHashMap();
- for (TunnelTerminationPoint ttpYang : ttps) {
-
- SwitchingType switchingLayer = null; // how to find switching type?
- EncodingType encodingLayer = null; // TODO: find proper encoding type from ttpYang.config().encoding();
- BitSet flags = new BitSet(); // how to set flags?
- List<Long> interLayerLockList = Lists.newArrayList();
-
- if (ttpYang.config() != null) {
- interLayerLockList.add(ttpYang.config().interLayerLockId()); // interLayerLock in yang is not a list
- }
-
- List<LocalLinkConnectivity> localLinkConnectivityList = Lists.newArrayList();
- // FIXME: once new yang model is used, we can make llc
- ElementType elt = null;
- List<ElementType> eltList = Lists.newArrayList();
- if (ttpYang.config() != null &&
- ttpYang.config().localLinkConnectivities() != null &&
- CollectionUtils.isNotEmpty(ttpYang.config().localLinkConnectivities().localLinkConnectivity())) {
- for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.tenodetunnelterminationattributes.locallinkconnectivities
- .LocalLinkConnectivity yangLlc : ttpYang.config()
- .localLinkConnectivities().localLinkConnectivity()) {
- if (MapUtils.isNotEmpty(yangNode.yangAugmentedInfoMap())) {
- AugmentedNdNode yangTpNodeAugment = (AugmentedNdNode) yangNode
- .yangAugmentedInfo(AugmentedNdNode.class);
- for (org.onosproject.yang.gen.v1.urn.ietf.params.xml
- .ns.yang.ietf.network.topology.rev20151208.ietfnetworktopology
- .networks.network.node.augmentedndnode
- .TerminationPoint tpItem : yangTpNodeAugment.terminationPoint()) {
- if (tpItem.tpId().uri().string().equals(yangLlc.linkTpRef().toString())) {
- if (tpItem.yangAugmentedInfoMap() != null
- && !tpItem.yangAugmentedInfoMap().isEmpty()) {
- AugmentedNtTerminationPoint yangTpAugment =
- (AugmentedNtTerminationPoint) tpItem
- .yangAugmentedInfo(AugmentedNtTerminationPoint.class);
- if (yangTpAugment.teTpId() != null) {
- elt = new TeLinkId(Long.valueOf(yangTpAugment.teTpId().toString()));
- break;
- }
- }
- }
- }
- }
- eltList.add(elt);
-// tercap.linkTp().toString() //tpId -> tp -> te-tp-id (long)
- }
- }
-
- TePathAttributes teAttributes = null; // how to find these
- // attributes from ttpYang?
- UnderlayAbstractPath underlayPath = null; // how to find underlayAbstractPath from ttpYang?
- LocalLinkConnectivity llc = new LocalLinkConnectivity(eltList,
- flags,
- teAttributes,
- underlayPath);
- localLinkConnectivityList.add(llc);
-
- float[] availAdaptBandwidth = null; // how to find availableBandwidth?
-
- TeTopologyKey teTopologyKey = null;
-
- Object networkRefObj = null;
- NetworkId networkId = null;
- if (ttpYang != null && ttpYang.supportingTunnelTerminationPoint() != null
- && !ttpYang.supportingTunnelTerminationPoint().isEmpty()
- && ttpYang.supportingTunnelTerminationPoint().get(0) != null) {
- networkRefObj = ttpYang.supportingTunnelTerminationPoint()
- .get(0).networkRef();
- }
- if (networkRefObj != null) {
- teTopologyKey = LinkConverter.findTopologyId(yangNetworks,
- networkRefObj);
- networkId = NetworkId.fromString((String) networkRefObj);
- }
-
- Network teNetworkFound = null;
- if (yangNetworks.network() != null
- && !yangNetworks.network().isEmpty()
- && networkId != null) {
- for (Network ynetItem : yangNetworks.network()) {
- if (ynetItem.networkId() != null) {
- if (ynetItem.networkId().equals(networkId)) {
- teNetworkFound = ynetItem;
- break;
- }
- }
- }
- }
- TeNodeId teNodeIdSupport = null;
- if (teNetworkFound != null
- && ttpYang != null
- && ttpYang.supportingTunnelTerminationPoint() != null
- && ttpYang.supportingTunnelTerminationPoint().get(0) != null) {
-
- String s = ((String) ttpYang.supportingTunnelTerminationPoint().get(0).nodeRef());
- int integ = Integer.valueOf(s);
- NodeId nodeId = NodeId.fromString(DottedQuad.of(Ip4Address.valueOf(integ).toString()).toString());
- teNodeIdSupport = LinkConverter
- .findTeNodeId(teNetworkFound,
- nodeId);
- }
-
- long tenIdLong = -1;
- if (teNodeIdSupport != null) {
- tenIdLong = Ip4Address
- .valueOf(teNodeIdSupport.dottedQuad().string()).toInt();
- }
-
- TeNodeKey teNodeKey = null;
- if (teTopologyKey != null && tenIdLong != -1) {
- teNodeKey = new TeNodeKey(teTopologyKey, tenIdLong);
- }
- TtpKey supportTtpKey = null;
- if (teNodeKey != null && ttpYang != null
- && ttpYang.supportingTunnelTerminationPoint() != null
- && !ttpYang.supportingTunnelTerminationPoint().isEmpty()
- && ttpYang.supportingTunnelTerminationPoint().get(0) != null) {
- supportTtpKey = new TtpKey(teNodeKey,
- ByteUtils.bytesToLong((byte[]) ttpYang
- .supportingTunnelTerminationPoint().get(0)
- .tunnelTpRef()));
- }
-
- org.onosproject.tetopology.management.api.node.
- TunnelTerminationPoint ttpTe = new
- org.onosproject.tetopology.management.api.node.
- DefaultTunnelTerminationPoint(ByteUtils.bytesToLong(ttpYang.tunnelTpId()),
- switchingLayer,
- encodingLayer,
- flags,
- interLayerLockList,
- localLinkConnectivityList,
- availAdaptBandwidth,
- supportTtpKey);
-
- ttpsMap.put(ByteUtils.bytesToLong(ttpYang.tunnelTpId()), ttpTe);
- }
-
- return ttpsMap;
- }
-
- private static TeNode yang2TeSubsystemNodeAugment(Te yangNodeAugTe,
- TeNodeId teNodeId,
- Network yangNetwork,
- Networks yangNetworks,
- Node yangNode,
- Map<KeyId, TerminationPoint> teTps) {
-
-
- NodeId yangNodeId = yangNode.nodeId();
-
- NetworkId yangNetworkId = yangNetwork.networkId();
-
- long teNodeIdLong = Ip4Address.valueOf(teNodeId.dottedQuad().string()).toInt();
-
- TeTopologyKey underlayTopologyIdId = null;
-
- // FIXME: yang has a list of supporting nodes, but TeNode only has one
- // supportTeNodeId. How ro retrieve providerId, clientId, topologyId, teNodeId?
- TeNodeKey supportTeNodeId = null;
-// supportTeNodeId = new TeNodeKey(providerId, clientId, topologyId, teNodeId)
-// yangSupportNodes.get(0).
-
- TeNodeKey sourceTeNodeId = null; //ignore
- CommonNodeData teData = null;
- Map<Long, ConnectivityMatrix> connMatrices = null;
- Map<Long, org.onosproject.tetopology.management.api.node.TunnelTerminationPoint> ttps = null;
- List<Long> teLinkIds = Lists.newArrayList();
- List<Long> teTpIds = Lists.newArrayList();
-
- // ********************************************** to find teLinkIds
- // teLinkIds should be supposed to get from YANG Link and TP data.
- // For now, assuming each teTp is sourcing a TE link .
- if (MapUtils.isNotEmpty(teTps)) {
- for (Map.Entry<KeyId, TerminationPoint> entry : teTps.entrySet()) {
- if (entry.getValue().teTpId() != null) {
- teTpIds.add(entry.getValue().teTpId());
- teLinkIds.add(entry.getValue().teTpId());
- }
- }
- }
- // ********************************************** to find teTpIds
-// if (yangNode.yangAugmentedInfoMap() != null
-// && !yangNode.yangAugmentedInfoMap().isEmpty()) {
-//
-// AugmentedNdNode yangTpNodeAugment = (AugmentedNdNode) yangNode
-// .yangAugmentedInfo(AugmentedNdNode.class);
-//
-// if (yangTpNodeAugment.terminationPoint() != null) {
-// for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology
-// .rev20151208.ietfnetworktopology.networks.network.node.augmentedndnode.TerminationPoint
-// yangTpnode : yangTpNodeAugment.terminationPoint()) {
-// teTpIds.add(Long.valueOf(yangTpnode.tpId().uri().string()));
-// }
-// }
-// }
- // **********************************************
-
- Config ynodeAugCfg = yangNodeAugTe.config();
-
- if (ynodeAugCfg != null) {
- TeNodeAttributes teNodeAttr = ynodeAugCfg.teNodeAttributes();
- if (teNodeAttr != null) {
-
- if (teNodeAttr.underlayTopology() != null) {
-
- underlayTopologyIdId = yang2TeSubsystemNodeUnderlayTopology(teNodeAttr
- .underlayTopology(), yangNetworks);
- }
- BitSet flags = new BitSet();
- if (teNodeAttr.isAbstract()) {
- flags.set(TeNode.BIT_ABSTRACT);
- }
- teData = new CommonNodeData(
- null, // teNodeAttr.name().string(),
- EnumConverter.yang2TeSubsystemAdminStatus(teNodeAttr.adminStatus()),
- EnumConverter.yang2TeSubsystemOpStatus(yangNodeAugTe.state().operStatus()),
- flags);
-
-// if (teNodeAttr.connectivityMatrix() != null) {
- if (teNodeAttr.connectivityMatrices() != null) {
- connMatrices = yang2TeSubsystemNodeConnectivityMatrix(yangNetworkId.uri().toString(),
- yangNodeId.uri().toString(),
- teNodeAttr.connectivityMatrices());
- }
-
- }
- }
-
- if (yangNodeAugTe.tunnelTerminationPoint() != null) {
- ttps = yang2TeSubsystemTtp(yangNodeAugTe.tunnelTerminationPoint(),
- yangNode,
- yangNetworks);
- }
-
- TeNode teNode = new DefaultTeNode(teNodeIdLong,
- underlayTopologyIdId,
- supportTeNodeId,
- sourceTeNodeId,
- teData,
- connMatrices,
- teLinkIds,
- ttps,
- teTpIds);
- return teNode;
- }
-
- private static Map<KeyId, TerminationPoint> yang2TeSubsystemTpNodeAugment(AugmentedNdNode yangTpNodeAugment) {
- Map<KeyId, TerminationPoint> tps;
- if (yangTpNodeAugment.terminationPoint() != null) {
- tps = Maps.newHashMap();
- for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology
- .rev20151208.ietfnetworktopology.networks.network.node.augmentedndnode.TerminationPoint
- yangTpnode : yangTpNodeAugment.terminationPoint()) {
- tps.put(KeyId.keyId(yangTpnode.tpId().uri().toString()),
- TerminationPointConverter.yang2teSubsystemTerminationPoint(yangTpnode));
- }
- return tps;
- }
- return null;
- }
-
- /**
- * Converts a TE Topology node event from the data format used in the core
- * to its corresponding YANG Object (YO) format.
- *
- * @param eventType Node event type
- * @param eventData TE Topology node event data
- * @return YANG Object converted from nodeData
- */
- public static TeNodeEvent teNetworkNode2yangTeNodeEvent(TeTopologyEventTypeEnum eventType,
- NetworkNodeEventSubject eventData) {
- TeNodeEvent.TeNodeEventBuilder builder = new DefaultTeNodeEvent.TeNodeEventBuilder();
-
- TeTopologyEventType yangEventType = new TeTopologyEventType(eventType);
- builder.eventType(yangEventType);
-
- NetworkId newtorkId = NetworkId.fromString(eventData.key().networkId().toString());
- builder.networkRef(newtorkId);
- NodeId nodeId = NodeId.fromString(eventData.key().nodeId().toString());
- builder.nodeRef(nodeId);
-
- NetworkNode node = eventData.neworkNode();
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
- rev20170110.ietftetopology.tenodeconfigattributesnotification.
- TeNodeAttributes teNodeAttributes = node == null ? null
- : teNode2YangTeNodeAttributes(node.teNode());
- builder.teNodeAttributes(teNodeAttributes);
-
- return builder.build();
- }
-
- private static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.
- ietf.te.topology.rev20170110.ietftetopology.
- tenodeconfigattributesnotification.
- TeNodeAttributes teNode2YangTeNodeAttributes(TeNode teNode) {
-
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
- rev20170110.ietftetopology.tenodeconfigattributesnotification.
- TeNodeAttributes.TeNodeAttributesBuilder attrBuilder =
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
- rev20170110.ietftetopology.tenodeconfigattributesnotification.
- DefaultTeNodeAttributes.builder();
-
- if (teNode.connectivityMatrices() != null) {
-
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology
- .tenodeconnectivitymatrixabs.DefaultConnectivityMatrix
- .ConnectivityMatrixBuilder connectivityMatrixConfigBuilder = org.onosproject.yang.gen.v1.urn.ietf.
- params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.tenodeconnectivitymatrixabs.
- DefaultConnectivityMatrix.builder();
- for (Map.Entry<Long, ConnectivityMatrix> teCmEntry :
- teNode.connectivityMatrices().entrySet()) {
- connectivityMatrixConfigBuilder = connectivityMatrixConfigBuilder
- .id(teCmEntry.getKey())
- .isAllowed(!teCmEntry.getValue().flags()
- .get(ConnectivityMatrix.BIT_DISALLOWED))
- .from(new org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.tenodeconnectivitymatrixabs.connectivitymatrix.DefaultFrom
- .FromBuilder() // TODO: for now, assuming that there is
- // only one 'from', and mergingList is empty
- .tpRef(teCmEntry.getValue().from())
- .build())
- .to(new org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.tenodeconnectivitymatrixabs.connectivitymatrix
- .DefaultTo.ToBuilder() // TODO: for now, assuming that there is only
- // one item in constrainingElements list
- .tpRef(teCmEntry.getValue().constrainingElements().get(0))
- .build());
- attrBuilder = attrBuilder
- .addToConnectivityMatrix(connectivityMatrixConfigBuilder
- .build());
- }
- }
-
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.
- rev20170110.ietftetopology.tenodeconfigattributesnotification.
- TeNodeAttributes teNodeAttributes = attrBuilder.build();
-
- return teNodeAttributes;
- }
-
- public static NetworkNodeKey yangNodeEvent2NetworkNodeKey(TeNodeEvent yangNodeEvent) {
- NetworkId networkRef = NetworkId.fromString(yangNodeEvent.networkRef().toString());
- NodeId nodeRef = NodeId.fromString(yangNodeEvent.nodeRef().toString());
- KeyId networkId = KeyId.keyId(networkRef.uri().toString());
- KeyId nodeId = KeyId.keyId(nodeRef.uri().toString());
-
- NetworkNodeKey networkNodeKey = new NetworkNodeKey(networkId, nodeId);
-
- return networkNodeKey;
- }
-
- /**
- * Converts YangNode event to NetworkNode.
- *
- * @param yangNodeEvent yangNodeEvent
- * @param teTopologyService teTopologyService
- * @return NetworkNode
- */
- public static NetworkNode yangNodeEvent2NetworkNode(TeNodeEvent yangNodeEvent,
- TeTopologyService teTopologyService) {
- KeyId networkNodeId = yangNodeEvent2NetworkNodeKey(yangNodeEvent).nodeId();
-
- org.onosproject.tetopology.management.api.Network network = teTopologyService.network(
- yangNodeEvent2NetworkNodeKey(yangNodeEvent).networkId());
- if (network == null) {
- return null;
- }
-
- NetworkNode networkNode = network.node(networkNodeId);
- if (networkNode == null) {
- return null;
- }
-
- List<NetworkNodeKey> supportingNodeIds = networkNode.supportingNodeIds();
- Map<KeyId, TerminationPoint> tps = networkNode.terminationPoints();
-
- TeNode teNode = networkNode.teNode();
- if (teNode == null) {
- return null;
- }
-
- TeNode updatedTeNode = yangNodeEvent2TeNode(yangNodeEvent, teNode);
-
- NetworkNode updatedNetworkNode = new DefaultNetworkNode(networkNodeId, supportingNodeIds, updatedTeNode, tps);
-
- return updatedNetworkNode;
- }
-
- private static TeNode yangNodeEvent2TeNode(TeNodeEvent yangNodeEvent, TeNode oldTeNode) {
-
- long teNodeId = oldTeNode.teNodeId();
- TeTopologyKey underlayTopoId = oldTeNode.underlayTeTopologyId();
- TeNodeKey supportTeNodeId = oldTeNode.sourceTeNodeId();
- TeNodeKey sourceTeNodeId = oldTeNode.sourceTeNodeId();
- Map<Long, ConnectivityMatrix> connMatrices = oldTeNode.connectivityMatrices();
- List<Long> teLinkIds = oldTeNode.teLinkIds();
- Map<Long, org.onosproject.tetopology.management.
- api.node.TunnelTerminationPoint> ttps = oldTeNode.tunnelTerminationPoints();
- List<Long> teTpIds = oldTeNode.teLinkIds();
- String name = oldTeNode.name();
- TeStatus adminStatus = oldTeNode.adminStatus();
- TeStatus opStatus = oldTeNode.opStatus();
- BitSet flags = oldTeNode.flags();
-
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology
- .tenodeconfigattributesnotification
- .TeNodeAttributes yangTeNodeAttrs = yangNodeEvent.teNodeAttributes();
-
- if (yangTeNodeAttrs != null) {
- TeAdminStatus yangAdminStatus = yangTeNodeAttrs.adminStatus();
- if (yangAdminStatus != null) {
- adminStatus = EnumConverter.yang2TeSubsystemAdminStatus(yangAdminStatus);
- }
-
- BitSet yangFlags = yangTeNodeAttrs.selectLeafFlags();
- if (yangFlags != null) {
- flags = yangFlags;
- }
-
- List<org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.
- ietf.te.topology.rev20170110.ietftetopology
- .tenodeconnectivitymatrixabs.ConnectivityMatrix> yangConnMatrices = yangTeNodeAttrs
- .connectivityMatrix();
- if (yangConnMatrices != null) {
- for (org.onosproject.yang.gen.v1.
- urn.ietf.params.xml.ns.yang.
- ietf.te.topology
- .rev20170110.ietftetopology
- .tenodeconnectivitymatrixabs
- .ConnectivityMatrix yangConnMatrix : yangConnMatrices) {
- Long cmId = new Long(yangConnMatrix.id());
- ConnectivityMatrix oldConnMatrix = connMatrices.get(new Long(yangConnMatrix.id()));
- if (oldConnMatrix != null) {
- ConnectivityMatrix newConnMatrix = yangNodeEvent2TeConnectivityMatrix(yangConnMatrix,
- oldConnMatrix);
- connMatrices.remove(cmId);
- connMatrices.put(cmId, newConnMatrix);
- }
- }
- }
- }
-
- CommonNodeData teData = new CommonNodeData(name, adminStatus, opStatus, flags);
- TeNode updatedTeNode = new DefaultTeNode(teNodeId, underlayTopoId, supportTeNodeId, sourceTeNodeId, teData,
- connMatrices, teLinkIds, ttps, teTpIds);
-
- return updatedTeNode;
- }
-
- private static ConnectivityMatrix yangNodeEvent2TeConnectivityMatrix(org.onosproject.yang.gen.v1.
- urn.ietf.params.xml.ns.yang.
- ietf.te.topology
- .rev20170110.ietftetopology
- .tenodeconnectivitymatrixabs
- .ConnectivityMatrix yangConnMatrix,
- ConnectivityMatrix oldTeConnMatrix) {
-
- long id = yangConnMatrix.id();
- ElementType from = new TeLinkId((long) (yangConnMatrix.from().tpRef()));
- UnderlayAbstractPath underlayPath = null;
- List<ElementType> mergingList = Lists.newArrayList();
-
- List<ElementType> constrainingElements = Lists.newArrayList();
- ElementType to = new TeLinkId((long) (yangConnMatrix.to().tpRef()));
- constrainingElements.add(to);
-
- BitSet flags = oldTeConnMatrix.flags();
-
- TePathAttributes teAttributes = oldTeConnMatrix.teAttributes();
-
- ConnectivityMatrix updatedConnMatrix = new ConnectivityMatrix(id,
- from,
- mergingList,
- constrainingElements,
- flags,
- teAttributes,
- underlayPath);
- return updatedConnMatrix;
- }
-}
diff --git a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/TerminationPointConverter.java b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/TerminationPointConverter.java
deleted file mode 100644
index 1b4c099..0000000
--- a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/TerminationPointConverter.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.teyang.utils.topology;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.List;
-
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.node.TerminationPointKey;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NetworkId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.NodeId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.TpId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.node.augmentedndnode.DefaultTerminationPoint;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.node.augmentedndnode.TerminationPoint;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.node.augmentedndnode.terminationpoint
- .DefaultSupportingTerminationPoint;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208
- .ietfnetworktopology.networks.network.node.augmentedndnode.terminationpoint
- .SupportingTerminationPoint;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.interfaceswitchingcapabilitylist.DefaultInterfaceSwitchingCapability;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.interfaceswitchingcapabilitylist.InterfaceSwitchingCapability;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.networks.network.node.terminationpoint.AugmentedNtTerminationPoint;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110
- .ietftetopology.networks.network.node.terminationpoint.DefaultAugmentedNtTerminationPoint;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkiscdattributes.DefaultMaxLspBandwidth;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.telinkiscdattributes.MaxLspBandwidth;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.teterminationpointaugment.DefaultTe;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.teterminationpointaugment.DefaultTe.TeBuilder;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.teterminationpointaugment.te.Config;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.teterminationpointaugment.te.DefaultConfig;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.teterminationpointaugment.te.DefaultState;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.teterminationpointaugment.te.State;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TeTpId;
-
-import com.google.common.collect.Lists;
-
-/**
- * The termination point translations.
- */
-public final class TerminationPointConverter {
-
- private static final String E_NULL_TE_SUBSYSTEM_TP =
- "TeSubsystem terminationPoint object cannot be null";
- private static final String E_NULL_YANG_TP =
- "YANG terminationPoint object cannot be null";
-
- // no instantiation
- private TerminationPointConverter() {
- }
-
- /**
- * TerminationPoint object translation from TE Topology subsystem to YANG.
- *
- * @param teSubsystem TE Topology subsystem termination point
- * @return Termination point in YANG Java data structure
- */
- public static TerminationPoint teSubsystem2YangTerminationPoint(org.onosproject.tetopology.management.api.node.
- TerminationPoint teSubsystem) {
- checkNotNull(teSubsystem, E_NULL_TE_SUBSYSTEM_TP);
-
- TpId tpId = TpId.fromString(teSubsystem.tpId().toString());
-// TpId tpId = TpId.fromString("0");
- TerminationPoint.TerminationPointBuilder builder =
- new DefaultTerminationPoint.TerminationPointBuilder().tpId(tpId);
-
- if (teSubsystem.supportingTpIds() != null) {
- List<SupportingTerminationPoint> tps = Lists.newArrayList();
- SupportingTerminationPoint.SupportingTerminationPointBuilder
- spTpBuilder = DefaultSupportingTerminationPoint.builder();
- for (TerminationPointKey tpKey : teSubsystem.supportingTpIds()) {
- tps.add(spTpBuilder.networkRef(NetworkId.fromString(tpKey.networkId().toString()))
- .nodeRef(NodeId.fromString(tpKey.nodeId().toString()))
- .tpRef(TpId.fromString(tpKey.tpId().toString()))
- .build());
- }
- builder = builder.supportingTerminationPoint(tps);
- }
-
- if (teSubsystem.teTpId() != null) {
- AugmentedNtTerminationPoint.AugmentedNtTerminationPointBuilder
- tpAugmentBuilder = DefaultAugmentedNtTerminationPoint.builder();
- tpAugmentBuilder.teTpId(TeTpId.fromString((String.valueOf(teSubsystem.teTpId()))));
- TeBuilder yangTeBuilder = DefaultTe.builder();
-
-// Config yConfig = teSubsystem2YangTeAugConfig(teSubsystem);
-// yangTeBuilder = yangTeBuilder.config(yConfig);
-//
-// State yState = teSubsystem2YangTeAugState(teSubsystem);
-// yangTeBuilder = yangTeBuilder.state(yState);
-
- tpAugmentBuilder = tpAugmentBuilder.te(yangTeBuilder.build());
- builder.addYangAugmentedInfo(tpAugmentBuilder.build(), AugmentedNtTerminationPoint.class);
- }
-
- return builder.build();
- }
-
- private static State teSubsystem2YangTeAugState(org.onosproject.tetopology.management.api.node.
- TerminationPoint teSubsystemTe) {
- State.StateBuilder yangStateBuilder = DefaultState.builder();
- // FIXME: interLayerLocks is a list in core but not in yang
-// yangStateBuilder = yangStateBuilder.interLayerLockId(teLink.interLayerLocks().get(0));
-
- return yangStateBuilder.build();
- }
-
- private static Config teSubsystem2YangTeAugConfig(org.onosproject.tetopology.management.api.node.
- TerminationPoint teSubsystemTe) {
- Config.ConfigBuilder yangConfigBuilder = DefaultConfig.builder();
- //FIXME: interLayerLocks is a list in core but not in yang
- // yangConfigBuilder =
- // yangConfigBuilder.interLayerLockId(teLink.interLayerLocks().get(0));
-
- InterfaceSwitchingCapability.InterfaceSwitchingCapabilityBuilder isc =
- DefaultInterfaceSwitchingCapability.builder();
-
- MaxLspBandwidth.MaxLspBandwidthBuilder maxlspBW = DefaultMaxLspBandwidth
- .builder();
-// for (float f : teLink.maxAvialLspBandwidth()) {
-// // is converting from float to long ok?
-// maxlspBW = maxlspBW.bandwidth(BigDecimal.valueOf((long) f));
-// isc = isc.addToMaxLspBandwidth(maxlspBW.build());
-// }
-
- yangConfigBuilder = yangConfigBuilder.addToInterfaceSwitchingCapability(isc.build());
-
- return yangConfigBuilder.build();
- }
-
- /**
- * TerminationPoint object translation from YANG to TE Topology subsystem.
- *
- * @param yangTp Termination point in YANG Java data structure
- * @return TerminationPoint TE Topology subsystem termination point
- */
- public static org.onosproject.tetopology.management.api.node.TerminationPoint
- yang2teSubsystemTerminationPoint(TerminationPoint yangTp) {
- checkNotNull(yangTp, E_NULL_YANG_TP);
-
- org.onosproject.tetopology.management.api.node.DefaultTerminationPoint tp = null;
- List<org.onosproject.tetopology.management.api.node.TerminationPointKey> spTps = null;
- KeyId teTpId = null;
-
- if (yangTp.supportingTerminationPoint() != null) {
- spTps = Lists.newArrayList();
- for (SupportingTerminationPoint yangSptp : yangTp.supportingTerminationPoint()) {
- org.onosproject.tetopology.management.api.node.TerminationPointKey tpKey =
- new org.onosproject.tetopology.management.api.node.TerminationPointKey(
- KeyId.keyId(yangSptp.networkRef().uri().string()),
- KeyId.keyId(yangSptp.nodeRef().uri().string()),
- KeyId.keyId(yangSptp.tpRef().uri().string()));
- spTps.add(tpKey);
- }
- }
-
- if (yangTp.yangAugmentedInfoMap() != null && !yangTp.yangAugmentedInfoMap().isEmpty()) {
- AugmentedNtTerminationPoint yangTpAugment =
- (AugmentedNtTerminationPoint) yangTp.yangAugmentedInfo(AugmentedNtTerminationPoint.class);
- if (yangTpAugment.teTpId() != null) {
- teTpId = KeyId.keyId(yangTpAugment.teTpId().toString());
- }
- }
-
- tp = new org.onosproject.tetopology.management.api.node
- .DefaultTerminationPoint(KeyId.keyId(yangTp.tpId().uri().string()),
- spTps,
- teTpId == null ? null : Long.valueOf(teTpId.toString()));
- return tp;
- }
-
-}
diff --git a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/package-info.java b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/package-info.java
deleted file mode 100644
index 69a994d..0000000
--- a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/topology/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * The utilities for conversions between TE Topology core subsystem and
- * IETF TE Topology Yang generated Java code.
- */
-package org.onosproject.teyang.utils.topology;
diff --git a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/tunnel/BasicConverter.java b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/tunnel/BasicConverter.java
deleted file mode 100644
index f946460..0000000
--- a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/tunnel/BasicConverter.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.teyang.utils.tunnel;
-
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev20130715.ietfinettypes.IpAddress;
-
-/**
- * Basic converter tools for ietf NBI & SBI.
- */
-public abstract class BasicConverter {
-
- //no instantiation
- private BasicConverter() {
-
- }
-
- /**
- * Converts a long value to IpAddress.
- *
- * @param value long value
- * @return ip address
- */
- static IpAddress longToIp(long value) {
- StringBuilder sb = new StringBuilder();
- sb.append((value >> 24) & 0xFF).append(".");
- sb.append((value >> 16) & 0xFF).append(".");
- sb.append((value >> 8) & 0xFF).append(".");
- sb.append(value & 0xFF);
- return IpAddress.fromString(sb.toString());
- }
-
- /**
- * Converts a long value to byte array.
- *
- * @param value long value
- * @return byte array
- */
- static byte[] longToByte(long value) {
- long temp = value;
- byte[] b = new byte[8];
- for (int i = 0; i < b.length; i++) {
- b[i] = new Long(temp & 0xff).byteValue();
- temp = temp >> 8;
- }
- return b;
- }
-
- /**
- * Converts a IP address to long value.
- *
- * @param ipAddress IP address
- * @return long value
- */
- static long ipToLong(IpAddress ipAddress) {
- long[] ip = new long[4];
- String strIp = ipAddress.toString();
- int position1 = strIp.indexOf(".");
- int position2 = strIp.indexOf(".", position1 + 1);
- int position3 = strIp.indexOf(".", position2 + 1);
- ip[0] = Long.parseLong(strIp.substring(0, position1));
- ip[1] = Long.parseLong(strIp.substring(position1 + 1, position2));
- ip[2] = Long.parseLong(strIp.substring(position2 + 1, position3));
- ip[3] = Long.parseLong(strIp.substring(position3 + 1));
- return (ip[0] << 24) + (ip[1] << 16) + (ip[2] << 8) + ip[3];
- }
-
- /**
- * Converts byte array to long value.
- *
- * @param bytes byte array
- * @return long value
- */
- static long bytesToLong(byte[] bytes) {
- return ((long) bytes[7] & 255L) << 56 |
- ((long) bytes[6] & 255L) << 48 |
- ((long) bytes[5] & 255L) << 40 |
- ((long) bytes[4] & 255L) << 32 |
- ((long) bytes[3] & 255L) << 24 |
- ((long) bytes[2] & 255L) << 16 |
- ((long) bytes[1] & 255L) << 8 |
- (long) bytes[0] & 255L;
- }
-}
diff --git a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/tunnel/TunnelConverter.java b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/tunnel/TunnelConverter.java
deleted file mode 100644
index 9113e3f..0000000
--- a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/tunnel/TunnelConverter.java
+++ /dev/null
@@ -1,479 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.teyang.utils.tunnel;
-
-import com.google.common.collect.Lists;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.tetunnel.api.tunnel.DefaultTeTunnel;
-import org.onosproject.tetunnel.api.tunnel.TeTunnel;
-import org.onosproject.tetunnel.api.tunnel.TeTunnelKey;
-import org.onosproject.tetunnel.api.tunnel.path.DefaultTePath;
-import org.onosproject.tetunnel.api.tunnel.path.DefaultTeRouteUnnumberedLink;
-import org.onosproject.tetunnel.api.tunnel.path.TePath;
-import org.onosproject.tetunnel.api.tunnel.path.TeRouteSubobject;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.IetfTe;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.IetfTeOpParam;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.DefaultTe;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.Te;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.pathparamsconfig.Type;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.pathparamsconfig.type.DefaultDynamic;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.pathparamsconfig.type.DefaultExplicit;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.pathparamsconfig.type.explicit.DefaultExplicitRouteObjects;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.pathparamsconfig.type.explicit.ExplicitRouteObjects;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelproperties.Config;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelproperties.DefaultPrimaryPaths;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelproperties.DefaultState;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelproperties.PrimaryPaths;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelproperties.State;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelsgrouping.DefaultTunnels;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelsgrouping.Tunnels;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelsgrouping.tunnels.DefaultTunnel;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelsgrouping.tunnels.Tunnel;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.LspProt1Forn;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.LspProtBidir1To1;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.LspProtReroute;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.LspProtRerouteExtra;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.LspProtType;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.LspProtUnidir1To1;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.LspProtUnprotected;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.PathSignalingRsvpte;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.PathSignalingSr;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.RouteIncludeEro;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.StateDown;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.StateUp;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TunnelP2Mp;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TunnelP2p;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.TunnelType;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.explicitroutesubobject.type.DefaultUnnumberedLink;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.explicitroutesubobject.type.UnnumberedLink;
-import org.slf4j.Logger;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static org.onlab.packet.ONOSLLDP.DEFAULT_NAME;
-import static org.onosproject.tetunnel.api.tunnel.TeTunnel.LspProtectionType;
-import static org.onosproject.tetunnel.api.tunnel.path.TeRouteSubobject.Type.UNNUMBERED_LINK;
-import static org.onosproject.teyang.utils.tunnel.BasicConverter.bytesToLong;
-import static org.onosproject.teyang.utils.tunnel.BasicConverter.ipToLong;
-import static org.onosproject.teyang.utils.tunnel.BasicConverter.longToByte;
-import static org.onosproject.teyang.utils.tunnel.BasicConverter.longToIp;
-import static org.slf4j.LoggerFactory.getLogger;
-
-
-/**
- * Tunnel convert utils.
- */
-public final class TunnelConverter {
-
- private static final Logger log = getLogger(TunnelConverter.class);
- private static final String DEFAULT_PATH_NAME = "ietfPath";
- private static final String DEFAULT_PATH_CONSTRAINT = "ietfPath";
- private static final int DEFAULT_PATH_PREFERENCE = 1;
- private static final boolean DEFAULT_CSPF_STATE = true;
- private static final boolean DEFAULT_LOCKDOWN_STATE = true;
-
- // no instantiation
- private TunnelConverter() {
- }
-
- /**
- * Build a general IETF TE object with a giving tunnel list. for there are
- * many kind of attributes in IETF TE, now we only care about the tunnel
- * attributes.
- *
- * @param tunnels tunnels in the TE network
- * @return IETF te info in the TE network
- */
- public static IetfTe buildIetfTeWithTunnels(List<Tunnel> tunnels) {
- Tunnels teTunnels = new DefaultTunnels
- .TunnelsBuilder()
- .tunnel(tunnels)
- .build();
- Te te = new DefaultTe
- .TeBuilder()
- .tunnels(teTunnels)
- .build();
- return new IetfTeOpParam
- .IetfTeBuilder()
- .te(te)
- .yangIetfTeOpType(IetfTe.OnosYangOpType.NONE)
- .build();
- }
-
- public static IetfTe buildIetfTe(TeTunnel teTunnel, boolean isConfig) {
- Tunnel tunnel = te2YangTunnelConverter(teTunnel, isConfig);
- return buildIetfTeWithTunnels(Lists.newArrayList(tunnel));
- }
-
- /**
- * Converts a specific te tunnel defined in the APP to the general te tunnel
- * defined in YANG model.
- *
- * @param tunnel te tunnel defined in APP
- * @param isConfig true if tunnel is to be built with config attributes;
- * false if built with state attributes
- * @return tunnel defined in YANG model
- */
- public static Tunnel te2YangTunnelConverter(TeTunnel tunnel, boolean isConfig) {
- List<PrimaryPaths> pathsList = new ArrayList<>();
-
- if (tunnel.primaryPaths() != null) {
- tunnel.primaryPaths()
- .forEach(tePath -> pathsList.add(te2YangPrimaryPath(tePath)));
- }
-
- tunnel.primaryPaths()
- .forEach(tePath -> pathsList.add(te2YangPrimaryPath(tePath)));
-
- Tunnel.TunnelBuilder builder = new DefaultTunnel
- .TunnelBuilder()
- .type(te2YangTunnelType(tunnel.type()))
- .name(validName(tunnel.name()))
- .identifier(tunnel.teTunnelKey().teTunnelId())
- .state(te2YangTunnelState(tunnel))
- .primaryPaths(pathsList);
- Tunnel.TunnelBuilder tunnelBuilder = isConfig ?
- builder.config(te2YangTunnelConfig(tunnel)) :
- builder.state(te2YangTunnelState(tunnel));
-
- return tunnelBuilder.build();
- }
-
- private static State te2YangTunnelState(TeTunnel tunnel) {
- State.StateBuilder stateBuilder = new DefaultState.StateBuilder();
- stateBuilder.name(validName(tunnel.name()))
- .identifier((int) tunnel.teTunnelKey().teTunnelId())
- .source((longToIp(tunnel.srcNode().teNodeId())))
- .destination((longToIp(tunnel.dstNode().teNodeId())))
- .srcTpId(longToByte(tunnel.srcTp().ttpId()))
- .dstTpId(longToByte(tunnel.dstTp().ttpId()))
- .adminStatus(te2YangStateType(tunnel.adminStatus()))
- .lspProtectionType(
- te2YangProtectionType(tunnel.lspProtectionType()))
- .type(te2YangTunnelType(tunnel.type()))
- .build();
- return stateBuilder.build();
- }
-
- private static Config te2YangTunnelConfig(TeTunnel tunnel) {
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.
- rev20160705.ietfte.tunnelproperties.DefaultConfig.ConfigBuilder
- configBuilder = new org.onosproject.yang.gen.v1.urn.ietf.params.
- xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelproperties.
- DefaultConfig.ConfigBuilder();
-
- configBuilder.name(validName(tunnel.name()))
- .identifier((int) tunnel.teTunnelKey().teTunnelId())
- .source((longToIp(tunnel.srcNode().teNodeId())))
- .destination((longToIp(tunnel.dstNode().teNodeId())))
- .srcTpId(longToByte(tunnel.srcTp().ttpId()))
- .dstTpId(longToByte(tunnel.dstTp().ttpId()))
- .adminStatus(te2YangStateType(tunnel.adminStatus()))
- .lspProtectionType(
- te2YangProtectionType(tunnel.lspProtectionType()))
- .type(te2YangTunnelType(tunnel.type()))
- .build();
- return configBuilder.build();
- }
-
- private static String validName(String name) {
- //for name is a required attribute, here we give a default name if not
- //configured
- return isNullOrEmpty(name) ? DEFAULT_NAME : name;
- }
-
- private static PrimaryPaths te2YangPrimaryPath(TePath tePath) {
- DefaultPrimaryPaths.PrimaryPathsBuilder builder = new DefaultPrimaryPaths
- .PrimaryPathsBuilder()
- .name(DEFAULT_PATH_NAME)
- .preference(DEFAULT_PATH_PREFERENCE)
- .state(te2YangPrimaryPathState(tePath))
- .yangPrimaryPathsOpType(IetfTe.OnosYangOpType.NONE);
- return builder.build();
- }
-
- private static org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
- .te.rev20160705.ietfte.p2pprimarypathparams.State
- te2YangPrimaryPathState(TePath tePath) {
-
- List<TeRouteSubobject> teRouteSubobjects = tePath.explicitRoute();
-
- List<ExplicitRouteObjects> routeObjects = new ArrayList<>();
- teRouteSubobjects.forEach(teRouteSubobject -> {
- routeObjects.add(te2YangRouteSubobject(teRouteSubobject));
- });
- DefaultExplicit.ExplicitBuilder explicitBuilder =
- DefaultExplicit.builder().explicitRouteObjects(routeObjects);
-
- return new org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.
- te.rev20160705.ietfte.p2pprimarypathparams.DefaultState
- .StateBuilder()
- .type(explicitBuilder.build())
- .pathNamedConstraint(DEFAULT_PATH_CONSTRAINT)
- .noCspf(DEFAULT_CSPF_STATE)
- .lockdown(DEFAULT_LOCKDOWN_STATE)
- .build();
- }
-
- private static ExplicitRouteObjects
- te2YangRouteSubobject(TeRouteSubobject routeSubobject) {
-
- TeRouteSubobject.Type type = routeSubobject.type();
- UnnumberedLink yanglink = null;
- //TODO implement other kind of TeRouteSubobject type
- if (type == UNNUMBERED_LINK) {
- DefaultTeRouteUnnumberedLink unnumberedLink =
- (DefaultTeRouteUnnumberedLink) routeSubobject;
- TeNodeKey nodeKey = unnumberedLink.node();
- TtpKey ttpKey = unnumberedLink.ttp();
-
- yanglink = DefaultUnnumberedLink.builder()
- .routerId(longToIp(nodeKey.teNodeId()))
- .interfaceId(ttpKey.ttpId())
- .build();
-
- }
-
- //TODO implement other kind of explicitRoute usage type
- return DefaultExplicitRouteObjects.builder()
- .type(yanglink)
- .explicitRouteUsage(RouteIncludeEro.class)
- .build();
- }
-
- /**
- * Converts a YANG TE tunnel defined in the YANG model to a specific TE
- * tunnel defined in the TE tunnel APP.
- *
- * @param tunnel yang tunnel object
- * @param topologyKey key of the TE topology to which this tunnel belongs
- * @return default Te tunnel defined in TE tunnel APP
- */
- public static DefaultTeTunnel yang2TeTunnel(org.onosproject.yang.gen.v1.
- urn.ietf.params.xml.
- ns.yang.ietf.te.
- rev20160705.ietfte.
- tunnelsgrouping.
- tunnels.Tunnel
- tunnel,
- TeTopologyKey topologyKey) {
- //get config info
- Config config = tunnel.config();
-
- //build basic attribute, node and ttp
- TeNodeKey srcNodeKey = new TeNodeKey(topologyKey, ipToLong(config.source()));
- TeNodeKey dstNodeKey = new TeNodeKey(topologyKey, ipToLong(config.destination()));
-
- TtpKey srcTtpKey = new TtpKey(srcNodeKey, bytesToLong(config.srcTpId()));
- TtpKey dstTtpKey = new TtpKey(srcNodeKey, bytesToLong(config.dstTpId()));
-
- //check if paths have been set
- List<PrimaryPaths> primaryPaths = tunnel.primaryPaths();
- List<TePath> paths = new ArrayList<>();
- primaryPaths.forEach(primaryPath -> paths.add(
- yang2TePrimaryPaths(primaryPath, topologyKey)));
-
- //build the te tunnel
- DefaultTeTunnel.Builder builder = new DefaultTeTunnel.Builder();
-
- return builder.teTunnelKey(new TeTunnelKey(topologyKey, config.identifier()))
- .name(config.name())
- .type(yang2TeTunnelType(config.type()))
- .lspProtectionType(yang2TeProtectionType(config.lspProtectionType()))
- .adminState(yang2TeStateType(config.adminStatus()))
- .srcNode(srcNodeKey)
- .dstNode(dstNodeKey)
- .srcTp(srcTtpKey)
- .dstTp(dstTtpKey)
- .primaryPaths(paths).build();
- }
-
- private static TePath yang2TePrimaryPaths(PrimaryPaths primaryPath,
- TeTopologyKey topologyKey) {
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.
- rev20160705.ietfte.p2pprimarypathparams.Config
- pathConfig = primaryPath.config();
-
- TePath tePath;
- TePath.Type tePathType = null;
- Type type = pathConfig.type();
-
- if (type == null) {
- return new DefaultTePath(TePath.Type.DYNAMIC,
- Lists.newArrayList(),
- Lists.newArrayList(),
- Lists.newArrayList());
- }
-
- Class<? extends Type> typeClass = type.getClass();
-
- List<TeRouteSubobject> routeSubobjects = new ArrayList<>();
-
- if (typeClass.isAssignableFrom(DefaultExplicit.class)) {
- DefaultExplicit explicitPath = (DefaultExplicit) type;
- explicitPath
- .explicitRouteObjects()
- .forEach(o -> routeSubobjects.add(
- yang2TeRouteSubobject(o, topologyKey)));
- tePathType = TePath.Type.EXPLICIT;
-
- } else if (typeClass.isAssignableFrom(DefaultDynamic.class)) {
- tePathType = TePath.Type.DYNAMIC;
- }
-
- tePath = new DefaultTePath(tePathType,
- Lists.newArrayList(),
- routeSubobjects,
- Lists.newArrayList());
- return tePath;
- }
-
- private static TeRouteSubobject
- yang2TeRouteSubobject(ExplicitRouteObjects routeObject,
- TeTopologyKey topologyKey) {
-
- //TODO implement other types of route type
- DefaultUnnumberedLink type = (DefaultUnnumberedLink) routeObject.type();
- TeNodeKey nodeKey = new TeNodeKey(topologyKey, ipToLong(type.routerId()));
- TtpKey tpId = new TtpKey(nodeKey, type.interfaceId());
- return new DefaultTeRouteUnnumberedLink(nodeKey, tpId);
- }
-
- private static TeTunnel.Type yang2TeTunnelType(Class type) {
- TeTunnel.Type tunnelType = null;
- if (type.isAssignableFrom(TunnelP2Mp.class)) {
- tunnelType = TeTunnel.Type.P2MP;
- } else if (type.isAssignableFrom(TunnelP2p.class)) {
- tunnelType = TeTunnel.Type.P2P;
- } else if (type.isAssignableFrom(PathSignalingRsvpte.class)) {
- tunnelType = TeTunnel.Type.PATH_SIGNALING_RSVPTE;
- } else if (type.isAssignableFrom(PathSignalingSr.class)) {
- tunnelType = TeTunnel.Type.PATH_SIGNALING_SR;
- }
- return tunnelType;
- }
-
-
- private static Class<? extends TunnelType> te2YangTunnelType(TeTunnel.Type type) {
- Class<? extends TunnelType> tunnelType = null;
- switch (type) {
-
- case P2P:
- tunnelType = TunnelP2p.class;
- break;
- case P2MP:
- tunnelType = TunnelP2Mp.class;
- break;
- case PATH_SIGNALING_RSVPTE:
- tunnelType = PathSignalingRsvpte.class;
-
- break;
- case PATH_SIGNALING_SR:
- tunnelType = PathSignalingSr.class;
- break;
- default:
- log.error("Unknown te tunnel type {}", type.toString());
- }
- return tunnelType;
- }
-
- private static LspProtectionType
- yang2TeProtectionType(Class<? extends LspProtType> protType) {
- LspProtectionType type = null;
- if (protType.isAssignableFrom(LspProt1Forn.class)) {
- type = LspProtectionType.LSP_PROT_1_FOR_N;
- } else if (protType.isAssignableFrom(LspProtBidir1To1.class)) {
- type = LspProtectionType.LSP_PROT_BIDIR_1_TO_1;
- } else if (protType.isAssignableFrom(LspProtReroute.class)) {
- type = LspProtectionType.LSP_PROT_REROUTE;
- } else if (protType.isAssignableFrom(LspProtRerouteExtra.class)) {
- type = LspProtectionType.LSP_PROT_REROUTE_EXTRA;
- } else if (protType.isAssignableFrom(LspProtUnidir1To1.class)) {
- type = LspProtectionType.LSP_PROT_UNIDIR_1_TO_1;
- } else if (protType.isAssignableFrom(LspProtUnprotected.class)) {
- type = LspProtectionType.LSP_PROT_UNPROTECTED;
- }
- return type;
- }
-
- private static Class<? extends LspProtType>
- te2YangProtectionType(LspProtectionType protType) {
- Class<? extends LspProtType> type = null;
- switch (protType) {
-
- case LSP_PROT_UNPROTECTED:
- type = LspProtUnprotected.class;
- break;
- case LSP_PROT_REROUTE:
- type = LspProtReroute.class;
- break;
- case LSP_PROT_REROUTE_EXTRA:
- type = LspProtRerouteExtra.class;
- break;
- case LSP_PROT_UNIDIR_1_TO_1:
- type = LspProtUnidir1To1.class;
- break;
- case LSP_PROT_BIDIR_1_TO_1:
- type = LspProtBidir1To1.class;
- break;
- case LSP_PROT_1_FOR_N:
- type = LspProt1Forn.class;
- break;
- default:
- log.error("Unknown te tunnel type {}", protType.toString());
- }
- return type;
- }
-
- private static TeTunnel.State
- yang2TeStateType(Class<? extends org.onosproject.yang.gen.v1.urn.ietf.
- params.xml.ns.yang.ietf.te.types.
- rev20160705.ietftetypes.StateType> stateType) {
- TeTunnel.State teStateType = null;
- if (stateType.isAssignableFrom(StateUp.class)) {
- teStateType = TeTunnel.State.UP;
- } else if (stateType.isAssignableFrom(StateDown.class)) {
- teStateType = TeTunnel.State.DOWN;
- }
- return teStateType;
- }
-
- private static Class<? extends org.onosproject.yang.gen.v1.urn.ietf.params.
- xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.StateType>
- te2YangStateType(TeTunnel.State stateType) {
- Class<? extends org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.
- ietf.te.types.rev20160705.ietftetypes.StateType> state = null;
-
- switch (stateType) {
-
- case DOWN:
- state = StateDown.class;
- break;
- case UP:
- state = StateUp.class;
- break;
- default:
- log.error("Unknown te tunnel type {}", stateType.toString());
-
- }
- return state;
- }
-}
diff --git a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/tunnel/package-info.java b/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/tunnel/package-info.java
deleted file mode 100644
index f724c86..0000000
--- a/apps/tenbi/utils/src/main/java/org/onosproject/teyang/utils/tunnel/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * The utilities for conversions between TE tunnel APP and IETF TE tunnel Yang
- * generated Java code.
- */
-package org.onosproject.teyang.utils.tunnel;
\ No newline at end of file
diff --git a/apps/tenbi/utils/src/test/java/org/onosproject/teyang/utils/topology/ConverterTest.java b/apps/tenbi/utils/src/test/java/org/onosproject/teyang/utils/topology/ConverterTest.java
deleted file mode 100644
index e65d4c8..0000000
--- a/apps/tenbi/utils/src/test/java/org/onosproject/teyang/utils/topology/ConverterTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.teyang.utils.topology;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks.Network;
-
-
-/**
- * Unit tests for converter functions.
- */
-public class ConverterTest {
-
- Network output;
-
- @Before
- public void setUp() {
- /*
- output = NetworkConverter.teSubsystem2YangNetwork(
- DefaultBuilder.sampleTeSubsystemNetworkBuilder(),
- OperationType.NONE);
- */
- }
-
- @Test
- public void basics() {
- //TODO: re-enable UT in the fallowing submission
- /*
- assertEquals("Wrong networkId",
- output.networkId().uri().string(),
- "HUAWEI_NETWORK_NEW");
- assertEquals("Wrong 1st nodeId",
- output.node().get(0).nodeId().uri().string(),
- "HUAWEI_ROADM_1");
- assertEquals("Wrong 2dn nodeId",
- output.node().get(1).nodeId().uri().string(),
- "HUAWEI_ROADM_2");
- AugmentedNwNode augmentedNode = (AugmentedNwNode) output.node().get(0)
- .yangAugmentedInfo(AugmentedNwNode.class);
-
- assertEquals("Wrong adminStatus",
- augmentedNode.te().config().teNodeAttributes().adminStatus(),
- TeAdminStatus.of(TeAdminStatusEnum.UP));
- */
- }
-
-}
diff --git a/apps/tenbi/utils/src/test/java/org/onosproject/teyang/utils/topology/DefaultBuilder.java b/apps/tenbi/utils/src/test/java/org/onosproject/teyang/utils/topology/DefaultBuilder.java
deleted file mode 100644
index 5693133..0000000
--- a/apps/tenbi/utils/src/test/java/org/onosproject/teyang/utils/topology/DefaultBuilder.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.teyang.utils.topology;
-
-import org.onosproject.tetopology.management.api.Network;
-import org.onosproject.tetopology.management.api.Networks;
-
-/**
- * Builds a sample Topology, which consists of two Nodes, one link,
- * and each node has two termination points.
- */
-public final class DefaultBuilder {
-
- private static final String HUAWEI_NETWORK_NEW = "HUAWEI_NETWORK_NEW";
- private static final String HUAWEI_ROADM_1 = "HUAWEI_ROADM_1";
- private static final String CLIENT1_NODE1 = "CLIENT1_NODE1";
- private static final String LINE1_NODE1 = "LINE1_NODE1";
- private static final String NODE1_IP = "10.11.12.33";
- private static final String HUAWEI_ROADM_2 = "HUAWEI_ROADM_2";
- private static final String CLIENT1_NODE2 = "CLIENT1_NODE2";
- private static final String LINE1_NODE2 = "LINE1_NODE2";
- private static final String NODE2_IP = "10.11.12.34";
- private static final String LINK1FORNETWORK1 = "LINK1FORNETWORK1";
- private static final String HUAWEI_TE_TOPOLOGY_NEW = "HUAWEI_TE_TOPOLOGY_NEW";
-
- // no instantiation
- private DefaultBuilder() {
- }
-
- /**
- * Returns a sample TeSubsystem Networks object.
- *
- * @return the Networks object
- */
- public static Networks sampleTeSubsystemNetworksBuilder() {
- //TODO: implementation will be submitted as a separate review.
- return null;
- }
-
- /**
- * Returns a sample TeSubsystem Network object.
- *
- * @return the Network object
- */
- public static Network sampleTeSubsystemNetworkBuilder() {
- //TODO: implementation will be submitted as a separate review.
- return null;
- }
-}
diff --git a/apps/tenbi/utils/src/test/java/org/onosproject/teyang/utils/topology/package-info.java b/apps/tenbi/utils/src/test/java/org/onosproject/teyang/utils/topology/package-info.java
deleted file mode 100644
index 596419a..0000000
--- a/apps/tenbi/utils/src/test/java/org/onosproject/teyang/utils/topology/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * The topology utilities test functions.
- *
- */
-package org.onosproject.teyang.utils.topology;
diff --git a/apps/tenbi/utils/src/test/java/org/onosproject/teyang/utils/tunnel/BasicConverterTest.java b/apps/tenbi/utils/src/test/java/org/onosproject/teyang/utils/tunnel/BasicConverterTest.java
deleted file mode 100644
index a927649..0000000
--- a/apps/tenbi/utils/src/test/java/org/onosproject/teyang/utils/tunnel/BasicConverterTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.teyang.utils.tunnel;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev20130715.ietfinettypes.IpAddress;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Test of the basic converter tools.
- */
-public class BasicConverterTest {
- private byte[] bytes1 = new byte[]{1, 1, 1, 1, 0, 0, 0, 0};
- private byte[] bytes2 = new byte[]{2, 2, 2, 2, 0, 0, 0, 0};
- private byte[] bytes3 = new byte[]{2, 0, 0, 0, 0, 0, 0, 0};
- private IpAddress ip1 = IpAddress.fromString("1.1.1.1");
- private IpAddress ip2 = IpAddress.fromString("2.2.2.2");
- private long longNum1 = 16843009;
- private long longNum2 = 33686018;
- private static final String CVT_F = "Convert failed: ";
-
-
- @Test
- public void longToIp() throws Exception {
- assertEquals(CVT_F + "longToIp", ip1, BasicConverter.longToIp(longNum1));
- assertEquals(CVT_F + "longToIp", ip2, BasicConverter.longToIp(longNum2));
- }
-
- @Test
- public void longToByte() throws Exception {
- assertArrayEquals(CVT_F + "longToByte", bytes1,
- BasicConverter.longToByte(longNum1));
- assertArrayEquals(CVT_F + "longToByte", bytes2,
- BasicConverter.longToByte(longNum2));
- }
-
- @Test
- public void ipToLong() throws Exception {
- assertEquals(CVT_F + "ipToLong", longNum1, BasicConverter.ipToLong(ip1));
- assertEquals(CVT_F + "ipToLong", longNum2, BasicConverter.ipToLong(ip2));
- }
-
- @Test
- public void bytesToLong() throws Exception {
- assertEquals(CVT_F + "bytesToLong", longNum1,
- BasicConverter.bytesToLong(bytes1));
- assertEquals(CVT_F + "bytesToLong", longNum2,
- BasicConverter.bytesToLong(bytes2));
-
- assertEquals(CVT_F + "bytesToLong", 2,
- BasicConverter.bytesToLong(bytes3));
- }
-}
\ No newline at end of file
diff --git a/apps/tenbi/yangmodel/src/main/yang/ietf-inet-types.yang b/apps/tenbi/yangmodel/src/main/yang/ietf-inet-types.yang
deleted file mode 100644
index 5388b03..0000000
--- a/apps/tenbi/yangmodel/src/main/yang/ietf-inet-types.yang
+++ /dev/null
@@ -1,461 +0,0 @@
-module ietf-inet-types {
-
- namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types";
- prefix "inet";
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/netmod/>
- WG List: <mailto:netmod@ietf.org>
-
- WG Chair: David Kessens
- <mailto:david.kessens@nsn.com>
-
- WG Chair: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>
-
- Editor: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>";
-
- description
- "This module contains a collection of generally useful derived
- YANG data types for Internet addresses and related things.
-
- Copyright (c) 2013 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC 6991; see
- the RFC itself for full legal notices.";
-
- revision 2013-07-15 {
- description
- "This revision adds the following new data types:
- - ip-address-no-zone
- - ipv4-address-no-zone
- - ipv6-address-no-zone";
- reference
- "RFC 6991: Common YANG Data Types";
- }
-
- revision 2010-09-24 {
- description
- "Initial revision.";
- reference
- "RFC 6021: Common YANG Data Types";
- }
-
- /*** collection of types related to protocol fields ***/
-
- typedef ip-version {
- type enumeration {
- enum unknown {
- value "0";
- description
- "An unknown or unspecified version of the Internet
- protocol.";
- }
- enum ipv4 {
- value "1";
- description
- "The IPv4 protocol as defined in RFC 791.";
- }
- enum ipv6 {
- value "2";
- description
- "The IPv6 protocol as defined in RFC 2460.";
- }
- }
- description
- "This value represents the version of the IP protocol.
-
- In the value set and its semantics, this type is equivalent
- to the InetVersion textual convention of the SMIv2.";
- reference
- "RFC 791: Internet Protocol
- RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
- RFC 4001: Textual Conventions for Internet Network Addresses";
- }
-
- typedef dscp {
- type uint8 {
- range "0..63";
- }
- description
- "The dscp type represents a Differentiated Services Code Point
- that may be used for marking packets in a traffic stream.
- In the value set and its semantics, this type is equivalent
- to the Dscp textual convention of the SMIv2.";
- reference
- "RFC 3289: Management Information Base for the Differentiated
- Services Architecture
- RFC 2474: Definition of the Differentiated Services Field
- (DS Field) in the IPv4 and IPv6 Headers
- RFC 2780: IANA Allocation Guidelines For Values In
- the Internet Protocol and Related Headers";
- }
-
- typedef ipv6-flow-label {
- type uint32 {
- range "0..1048575";
- }
- description
- "The ipv6-flow-label type represents the flow identifier or Flow
- Label in an IPv6 packet header that may be used to
- discriminate traffic flows.
-
- In the value set and its semantics, this type is equivalent
- to the IPv6FlowLabel textual convention of the SMIv2.";
- reference
- "RFC 3595: Textual Conventions for IPv6 Flow Label
- RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
- }
-
- typedef port-number {
- type uint16 {
- range "0..65535";
- }
- description
- "The port-number type represents a 16-bit port number of an
- Internet transport-layer protocol such as UDP, TCP, DCCP, or
- SCTP. Port numbers are assigned by IANA. A current list of
- all assignments is available from <http://www.iana.org/>.
-
- Note that the port number value zero is reserved by IANA. In
- situations where the value zero does not make sense, it can
- be excluded by subtyping the port-number type.
- In the value set and its semantics, this type is equivalent
- to the InetPortNumber textual convention of the SMIv2.";
- reference
- "RFC 768: User Datagram Protocol
- RFC 793: Transmission Control Protocol
- RFC 4960: Stream Control Transmission Protocol
- RFC 4340: Datagram Congestion Control Protocol (DCCP)
- RFC 4001: Textual Conventions for Internet Network Addresses";
- }
-
- /*** collection of types related to autonomous systems ***/
-
- typedef as-number {
- type uint32;
- description
- "The as-number type represents autonomous system numbers
- which identify an Autonomous System (AS). An AS is a set
- of routers under a single technical administration, using
- an interior gateway protocol and common metrics to route
- packets within the AS, and using an exterior gateway
- protocol to route packets to other ASes. IANA maintains
- the AS number space and has delegated large parts to the
- regional registries.
-
- Autonomous system numbers were originally limited to 16
- bits. BGP extensions have enlarged the autonomous system
- number space to 32 bits. This type therefore uses an uint32
- base type without a range restriction in order to support
- a larger autonomous system number space.
-
- In the value set and its semantics, this type is equivalent
- to the InetAutonomousSystemNumber textual convention of
- the SMIv2.";
- reference
- "RFC 1930: Guidelines for creation, selection, and registration
- of an Autonomous System (AS)
- RFC 4271: A Border Gateway Protocol 4 (BGP-4)
- RFC 4001: Textual Conventions for Internet Network Addresses
- RFC 6793: BGP Support for Four-Octet Autonomous System (AS)
- Number Space";
- }
-
- /*** collection of types related to IP addresses and hostnames ***/
-
- typedef ip-address {
- type union {
- type inet:ipv4-address;
- type inet:ipv6-address;
- }
- description
- "The ip-address type represents an IP address and is IP
- version neutral. The format of the textual representation
- implies the IP version. This type supports scoped addresses
- by allowing zone identifiers in the address format.";
- reference
- "RFC 4007: IPv6 Scoped Address Architecture";
- }
-
- typedef ipv4-address {
- type string {
- pattern
- '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
- + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
- + '(%[\p{N}\p{L}]+)?';
- }
- description
- "The ipv4-address type represents an IPv4 address in
- dotted-quad notation. The IPv4 address may include a zone
- index, separated by a % sign.
-
- The zone index is used to disambiguate identical address
- values. For link-local addresses, the zone index will
- typically be the interface index number or the name of an
- interface. If the zone index is not present, the default
- zone of the device will be used.
-
- The canonical format for the zone index is the numerical
- format";
- }
-
- typedef ipv6-address {
- type string {
- pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
- + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
- + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
- + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
- + '(%[\p{N}\p{L}]+)?';
- pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
- + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
- + '(%.+)?';
- }
- description
- "The ipv6-address type represents an IPv6 address in full,
- mixed, shortened, and shortened-mixed notation. The IPv6
- address may include a zone index, separated by a % sign.
-
- The zone index is used to disambiguate identical address
- values. For link-local addresses, the zone index will
- typically be the interface index number or the name of an
- interface. If the zone index is not present, the default
- zone of the device will be used.
-
-
-
- The canonical format of IPv6 addresses uses the textual
- representation defined in Section 4 of RFC 5952. The
- canonical format for the zone index is the numerical
- format as described in Section 11.2 of RFC 4007.";
- reference
- "RFC 4291: IP Version 6 Addressing Architecture
- RFC 4007: IPv6 Scoped Address Architecture
- RFC 5952: A Recommendation for IPv6 Address Text
- Representation";
- }
-
- typedef ip-address-no-zone {
- type union {
- type inet:ipv4-address-no-zone;
- type inet:ipv6-address-no-zone;
- }
- description
- "The ip-address-no-zone type represents an IP address and is
- IP version neutral. The format of the textual representation
- implies the IP version. This type does not support scoped
- addresses since it does not allow zone identifiers in the
- address format.";
- reference
- "RFC 4007: IPv6 Scoped Address Architecture";
- }
-
- typedef ipv4-address-no-zone {
- type inet:ipv4-address {
- pattern '[0-9\.]*';
- }
- description
- "An IPv4 address without a zone index. This type, derived from
- ipv4-address, may be used in situations where the zone is
- known from the context and hence no zone index is needed.";
- }
-
- typedef ipv6-address-no-zone {
- type inet:ipv6-address {
- pattern '[0-9a-fA-F:\.]*';
- }
- description
- "An IPv6 address without a zone index. This type, derived from
- ipv6-address, may be used in situations where the zone is
- known from the context and hence no zone index is needed.";
- reference
- "RFC 4291: IP Version 6 Addressing Architecture
- RFC 4007: IPv6 Scoped Address Architecture
- RFC 5952: A Recommendation for IPv6 Address Text
- Representation";
- }
-
- typedef ip-prefix {
- type union {
- type inet:ipv4-prefix;
- type inet:ipv6-prefix;
- }
- description
- "The ip-prefix type represents an IP prefix and is IP
- version neutral. The format of the textual representations
- implies the IP version.";
- }
-
- typedef ipv4-prefix {
- type string {
- pattern
- '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
- + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
- + '/(([0-9])|([1-2][0-9])|(3[0-2]))';
- }
- description
- "The ipv4-prefix type represents an IPv4 address prefix.
- The prefix length is given by the number following the
- slash character and must be less than or equal to 32.
-
- A prefix length value of n corresponds to an IP address
- mask that has n contiguous 1-bits from the most
- significant bit (MSB) and all other bits set to 0.
-
- The canonical format of an IPv4 prefix has all bits of
- the IPv4 address set to zero that are not part of the
- IPv4 prefix.";
- }
-
- typedef ipv6-prefix {
- type string {
- pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
- + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
- + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
- + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
- + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
- pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
- + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
- + '(/.+)';
- }
-
-
- description
- "The ipv6-prefix type represents an IPv6 address prefix.
- The prefix length is given by the number following the
- slash character and must be less than or equal to 128.
-
- A prefix length value of n corresponds to an IP address
- mask that has n contiguous 1-bits from the most
- significant bit (MSB) and all other bits set to 0.
-
- The IPv6 address should have all bits that do not belong
- to the prefix set to zero.
-
- The canonical format of an IPv6 prefix has all bits of
- the IPv6 address set to zero that are not part of the
- IPv6 prefix. Furthermore, the IPv6 address is represented
- as defined in Section 4 of RFC 5952.";
- reference
- "RFC 5952: A Recommendation for IPv6 Address Text
- Representation";
- }
-
- /*** collection of domain name and URI types ***/
-
- typedef domain-name {
- type string {
- pattern
- '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*'
- + '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)'
- + '|\.';
- length "1..253";
- }
- description
- "The domain-name type represents a DNS domain name. The
- name SHOULD be fully qualified whenever possible.
-
- Internet domain names are only loosely specified. Section
- 3.5 of RFC 1034 recommends a syntax (modified in Section
- 2.1 of RFC 1123). The pattern above is intended to allow
- for current practice in domain name use, and some possible
- future expansion. It is designed to hold various types of
- domain names, including names used for A or AAAA records
- (host names) and other records, such as SRV records. Note
- that Internet host names have a stricter syntax (described
- in RFC 952) than the DNS recommendations in RFCs 1034 and
- 1123, and that systems that want to store host names in
- schema nodes using the domain-name type are recommended to
- adhere to this stricter standard to ensure interoperability.
-
- The encoding of DNS names in the DNS protocol is limited
- to 255 characters. Since the encoding consists of labels
- prefixed by a length bytes and there is a trailing NULL
- byte, only 253 characters can appear in the textual dotted
- notation.
-
- The description clause of schema nodes using the domain-name
- type MUST describe when and how these names are resolved to
- IP addresses. Note that the resolution of a domain-name value
- may require to query multiple DNS records (e.g., A for IPv4
- and AAAA for IPv6). The order of the resolution process and
- which DNS record takes precedence can either be defined
- explicitly or may depend on the configuration of the
- resolver.
-
- Domain-name values use the US-ASCII encoding. Their canonical
- format uses lowercase US-ASCII characters. Internationalized
- domain names MUST be A-labels as per RFC 5890.";
- reference
- "RFC 952: DoD Internet Host Table Specification
- RFC 1034: Domain Names - Concepts and Facilities
- RFC 1123: Requirements for Internet Hosts -- Application
- and Support
- RFC 2782: A DNS RR for specifying the location of services
- (DNS SRV)
- RFC 5890: Internationalized Domain Names in Applications
- (IDNA): Definitions and Document Framework";
- }
-
- typedef host {
- type union {
- type inet:ip-address;
- type inet:domain-name;
- }
- description
- "The host type represents either an IP address or a DNS
- domain name.";
- }
-
- typedef uri {
- type string;
- description
- "The uri type represents a Uniform Resource Identifier
- (URI) as defined by STD 66.
-
- Objects using the uri type MUST be in US-ASCII encoding,
- and MUST be normalized as described by RFC 3986 Sections
- 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary
- percent-encoding is removed, and all case-insensitive
- characters are set to lowercase except for hexadecimal
- digits, which are normalized to uppercase as described in
- Section 6.2.2.1.
-
- The purpose of this normalization is to help provide
- unique URIs. Note that this normalization is not
- sufficient to provide uniqueness. Two URIs that are
- textually distinct after this normalization may still be
- equivalent.
-
- Objects using the uri type may restrict the schemes that
- they permit. For example, 'data:' and 'urn:' schemes
- might not be appropriate.
-
- A zero-length URI is not a valid URI. This can be used to
- express 'URI absent' where required.
-
- In the value set and its semantics, this type is equivalent
- to the Uri SMIv2 textual convention defined in RFC 5017.";
- reference
- "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
- RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
- Group: Uniform Resource Identifiers (URIs), URLs,
- and Uniform Resource Names (URNs): Clarifications
- and Recommendations
- RFC 5017: MIB Textual Conventions for Uniform Resource
- Identifiers (URIs)";
- }
-
-}
diff --git a/apps/tenbi/yangmodel/src/main/yang/ietf-network-topology@2015-12-08.yang b/apps/tenbi/yangmodel/src/main/yang/ietf-network-topology@2015-12-08.yang
deleted file mode 100644
index bba3916..0000000
--- a/apps/tenbi/yangmodel/src/main/yang/ietf-network-topology@2015-12-08.yang
+++ /dev/null
@@ -1,277 +0,0 @@
-module ietf-network-topology {
- // yang-version 1.1;
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology";
- prefix lnk;
- import ietf-inet-types {
- prefix inet;
- }
- import ietf-network {
- prefix nd;
- }
- organization
- "IETF I2RS (Interface to the Routing System) Working Group";
- contact
- "WG Web: <http: tools.ietf.org/wg/i2rs/>
- WG List: <mailto:i2rs@ietf.org>
- WG Chair: Susan Hares
- <mailto:shares@ndzh.com>
- WG Chair: Jeffrey Haas
- <mailto:jhaas@pfrc.org>
- Editor: Alexander Clemm
- <mailto:alex@cisco.com>
- Editor: Jan Medved
- <mailto:jmedved@cisco.com>
- Editor: Robert Varga
- <mailto:rovarga@cisco.com>
- Editor: Tony Tkacik
- <mailto:ttkacik@cisco.com>
- Editor: Nitin Bahadur
- <mailto:nitin_bahadur@yahoo.com>
- Editor: Hariharan Ananthakrishnan
- <mailto:hari@packetdesign.com>";
- description
- "This module defines a common base model for network topology,
- augmenting the base network model with links to connect nodes,
- as well as termination points to terminate links on nodes.
- Copyright (c) 2015 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http: trustee.ietf.org/license-info).
- This version of this YANG module is part of
- draft-ietf-i2rs-yang-network-topo-02;
- see the RFC itself for full legal notices.
- NOTE TO RFC EDITOR: Please replace above reference to
- draft-ietf-i2rs-yang-network-topo-02 with RFC
- number when published (i.e. RFC xxxx).";
- revision 2015-12-08 {
- description
- "Initial revision.
- NOTE TO RFC EDITOR: Please replace the following reference
- to draft-ietf-i2rs-yang-network-topo-02 with
- RFC number when published (i.e. RFC xxxx).";
- reference
- "draft-ietf-i2rs-yang-network-topo-02.";
- }
- typedef link-id {
- type inet:uri;
- description
- "An identifier for a link in a topology.
- The identifier SHOULD be chosen such that the same link in a
- real network topology will always be identified through the
- same identifier, even if the model is instantiated in
- separate datastores. An implementation MAY choose to capture
- semantics in the identifier, for example to indicate the type
- of link and/or the type of topology that the link is a part
- of.";
- }
- typedef tp-id {
- type inet:uri;
- description
- "An identifier for termination points on a node.
- The identifier SHOULD be chosen such that the same TP in a
- real network topology will always be identified through the
- same identifier, even if the model is instantiated in
- separate datastores. An implementation MAY choose to capture
- semantics in the identifier, for example to indicate the type
- of TP and/or the type of node and topology that the TP is a
- part of.";
- }
- grouping link-ref {
- description
- "References a link in a specific network.";
- leaf link-ref {
- type leafref {
- path "/nd:networks/nd:network[nd:network-id=current()/../"+
- "network-ref]/lnk:link/lnk:link-id";
- require-instance false;
- }
- description
- "A type for an absolute reference a link instance.
- (This type should not be used for relative references.
- In such a case, a relative path should be used instead.)";
- }
- uses nd:network-ref;
- }
- grouping tp-ref {
- description
- "References a termination point in a specific node.";
- leaf tp-ref {
- type leafref {
- path "/nd:networks/nd:network[nd:network-id=current()/../"+
- "network-ref]/nd:node[nd:node-id=current()/../"+
- "node-ref]/lnk:termination-point/lnk:tp-id";
- require-instance false;
- }
- description
- "A type for an absolute reference to a termination point.
- (This type should not be used for relative references.
- In such a case, a relative path should be used instead.)";
- }
- uses nd:node-ref;
- }
- augment "/nd:networks/nd:network" {
- description
- "Add links to the network model.";
- list link {
- key "link-id";
- description
- "A Network Link connects a by Local (Source) node and
- a Remote (Destination) Network Nodes via a set of the
- nodes' termination points.
- As it is possible to have several links between the same
- source and destination nodes, and as a link could
- potentially be re-homed between termination points, to
- ensure that we would always know to distinguish between
- links, every link is identified by a dedicated link
- identifier.
- Note that a link models a point-to-point link, not a
- multipoint link.
- Layering dependencies on links in underlay topologies are
- not represented as the layering information of nodes and of
- termination points is sufficient.";
- container source {
- description
- "This container holds the logical source of a particular
- link.";
- leaf source-node {
- type leafref {
- path "../../../nd:node/nd:node-id";
- }
- mandatory true;
- description
- "Source node identifier, must be in same topology.";
- }
- leaf source-tp {
- type leafref {
- path "../../../nd:node[nd:node-id=current()/../"+
- "source-node]/termination-point/tp-id";
- }
- description
- "Termination point within source node that terminates
- the link.";
- }
- }
- container destination {
- description
- "This container holds the logical destination of a
- particular link.";
- leaf dest-node {
- type leafref {
- path "../../../nd:node/nd:node-id";
- }
- mandatory true;
- description
- "Destination node identifier, must be in the same
- network.";
- }
- leaf dest-tp {
- type leafref {
- path "../../../nd:node[nd:node-id=current()/../"+
- "dest-node]/termination-point/tp-id";
- }
- description
- "Termination point within destination node that
- terminates the link.";
- }
- }
- leaf link-id {
- type link-id;
- description
- "The identifier of a link in the topology.
- A link is specific to a topology to which it belongs.";
- }
- list supporting-link {
- key "network-ref link-ref";
- description
- "Identifies the link, or links, that this link
- is dependent on.";
- leaf network-ref {
- type leafref {
- path "../../../nd:supporting-network/nd:network-ref";
- require-instance false;
- }
- description
- "This leaf identifies in which underlay topology
- supporting link is present.";
- }
- leaf link-ref {
- type leafref {
- path "/nd:networks/nd:network[nd:network-id=current()/"+
- "../network-ref]/link/link-id";
- require-instance false;
- }
- description
- "This leaf identifies a link which is a part
- of this link's underlay. Reference loops, in which
- a link identifies itself as its underlay, either
- directly or transitively, are not allowed.";
- }
- }
- }
- }
- augment "/nd:networks/nd:network/nd:node" {
- description
- "Augment termination points which terminate links.
- Termination points can ultimately be mapped to interfaces.";
- list termination-point {
- key "tp-id";
- description
- "A termination point can terminate a link.
- Depending on the type of topology, a termination point
- could, for example, refer to a port or an interface.";
- leaf tp-id {
- type tp-id;
- description
- "Termination point identifier.";
- }
- list supporting-termination-point {
- key "network-ref node-ref tp-ref";
- description
- "The leaf list identifies any termination points that
- the termination point is dependent on, or maps onto.
- Those termination points will themselves be contained
- in a supporting node.
- This dependency information can be inferred from
- the dependencies between links. For this reason,
- this item is not separately configurable. Hence no
- corresponding constraint needs to be articulated.
- The corresponding information is simply provided by the
- implementing system.";
- leaf network-ref {
- type leafref {
- path "../../../nd:supporting-node/nd:network-ref";
- require-instance false;
- }
- description
- "This leaf identifies in which topology the
- supporting termination point is present.";
- }
- leaf node-ref {
- type leafref {
- path "../../../nd:supporting-node/nd:node-ref";
- require-instance false;
- }
- description
- "This leaf identifies in which node the supporting
- termination point is present.";
- }
- leaf tp-ref {
- type leafref {
- path "/nd:networks/nd:network[nd:network-id=current()/"+
- "../network-ref]/nd:node[nd:node-id=current()/../"+
- "node-ref]/termination-point/tp-id";
- require-instance false;
- }
- description
- "Reference to the underlay node, must be in a
- different topology";
- }
- }
- }
- }
-}
diff --git a/apps/tenbi/yangmodel/src/main/yang/ietf-network@2015-12-08.yang b/apps/tenbi/yangmodel/src/main/yang/ietf-network@2015-12-08.yang
deleted file mode 100644
index f5e0dcc..0000000
--- a/apps/tenbi/yangmodel/src/main/yang/ietf-network@2015-12-08.yang
+++ /dev/null
@@ -1,196 +0,0 @@
-module ietf-network {
- // yang-version 1.1;
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network";
- prefix nd;
- import ietf-inet-types {
- prefix inet;
- }
- organization
- "IETF I2RS (Interface to the Routing System) Working Group";
- contact
- "WG Web: <http: tools.ietf.org/wg/i2rs/>
- WG List: <mailto:i2rs@ietf.org>
- WG Chair: Susan Hares
- <mailto:shares@ndzh.com>
- WG Chair: Jeffrey Haas
- <mailto:jhaas@pfrc.org>
- Editor: Alexander Clemm
- <mailto:alex@cisco.com>
- Editor: Jan Medved
- <mailto:jmedved@cisco.com>
- Editor: Robert Varga
- <mailto:rovarga@cisco.com>
- Editor: Tony Tkacik
- <mailto:ttkacik@cisco.com>
- Editor: Nitin Bahadur
- <mailto:nitin_bahadur@yahoo.com>
- Editor: Hariharan Ananthakrishnan
- <mailto:hari@packetdesign.com>";
- description
- "This module defines a common base model for a collection
- of nodes in a network. Node definitions are further used
- in network topologies and inventories.
- Copyright (c) 2015 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http: trustee.ietf.org/license-info).
- This version of this YANG module is part of
- draft-ietf-i2rs-yang-network-topo-02;
- see the RFC itself for full legal notices.
- NOTE TO RFC EDITOR: Please replace above reference to
- draft-ietf-i2rs-yang-network-topo-02 with RFC
- number when published (i.e. RFC xxxx).";
- revision 2015-12-08 {
- description
- "Initial revision.
- NOTE TO RFC EDITOR: Please replace the following reference
- to draft-ietf-i2rs-yang-network-topo-02 with
- RFC number when published (i.e. RFC xxxx).";
- reference
- "draft-ietf-i2rs-yang-network-topo-02";
- }
- typedef node-id {
- type inet:uri;
- description
- "Identifier for a node.";
- }
- typedef network-id {
- type inet:uri;
- description
- "Identifier for a network.";
- }
- grouping network-ref {
- description
- "Contains the information necessary to reference a network,
- for example an underlay network.";
- leaf network-ref {
- type leafref {
- path "/nd:networks/nd:network/nd:network-id";
- require-instance false;
- }
- description
- "Used to reference a network, for example an underlay
- network.";
- }
- }
- grouping node-ref {
- description
- "Contains the information necessary to reference a node.";
- leaf node-ref {
- type leafref {
- path "/nd:networks/nd:network[nd:network-id=current()/../"+
- "network-ref]/nd:node/nd:node-id";
- require-instance false;
- }
- description
- "Used to reference a node.
- Nodes are identified relative to the network they are
- contained in.";
- }
- uses network-ref;
- }
- container networks {
- description
- "Serves as top-level container for a list of networks.";
- list network {
- key "network-id";
- description
- "Describes a network.
- A network typically contains an inventory of nodes,
- topological information (augmented through
- network-topology model), as well as layering
- information.";
- container network-types {
- description
- "Serves as an augmentation target.
- The network type is indicated through corresponding
- presence containers augmented into this container.";
- }
- leaf network-id {
- type network-id;
- description
- "Identifies a network.";
- }
- list supporting-network {
- key "network-ref";
- description
- "An underlay network, used to represent layered network
- topologies.";
- leaf network-ref {
- type leafref {
- path "/networks/network/network-id";
- require-instance false;
- }
- description
- "References the underlay network.";
- }
- }
- list node {
- key "node-id";
- description
- "The inventory of nodes of this network.";
- leaf node-id {
- type node-id;
- description
- "Identifies a node uniquely within the containing
- network.";
- }
- list supporting-node {
- key "network-ref node-ref";
- description
- "Represents another node, in an underlay network, that
- this node is supported by. Used to represent layering
- structure.";
- leaf network-ref {
- type leafref {
- path "../../../supporting-network/network-ref";
- require-instance false;
- }
- description
- "References the underlay network that the
- underlay node is part of.";
- }
- leaf node-ref {
- type leafref {
- path "/networks/network/node/node-id";
- require-instance false;
- }
- description
- "References the underlay node itself.";
- }
- }
- }
- }
- }
- container networks-state {
- config false;
- description
- "Serves as top-level container for a list of state information
- for networks";
- list network {
- key "network-ref";
- description
- "Data nodes representing operational data and state of
- networks.
- An instance is automatically created for every network
- in the corresponding list under the networks container.";
- uses network-ref;
- leaf server-provided {
- type boolean;
- description
- "Indicates whether the information concerning this
- particular network is populated by the server
- (server-provided true, the general case for network
- information discovered from the server),
- or whether it is configured by a client
- (server-provided true, possible e.g. for
- service overlays managed through a controller).";
- }
- }
- }
-}
diff --git a/apps/tenbi/yangmodel/src/main/yang/ietf-schedule.yang b/apps/tenbi/yangmodel/src/main/yang/ietf-schedule.yang
deleted file mode 100644
index 55ce942..0000000
--- a/apps/tenbi/yangmodel/src/main/yang/ietf-schedule.yang
+++ /dev/null
@@ -1,61 +0,0 @@
-module ietf-schedule {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-schedule";
- // replace with IANA namespace when assigned
-
- prefix "sch";
-
- import ietf-yang-types {
- prefix "yang";
- }
-
- organization "TBD";
- contact "TBD";
- description
- "The model allows time scheduling parameters to be specified.";
-
- revision "2015-10-08" {
- description "Initial revision";
- reference "TBD";
- }
-
- /*
- * Groupings
- */
-
- grouping schedules {
- description
- "A list of schedules defining when a particular
- configuration takes effect.";
- container schedules {
- list schedule {
- key "schedule-id";
- description "A list of schedule elements.";
-
- leaf schedule-id {
- type uint32;
- description "Identifies the schedule element.";
- }
- leaf start {
- type yang:date-and-time;
- description "Start time.";
- }
- leaf schedule-duration {
- type string {
- pattern
- 'P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?(\d+S)?';
- }
- description "Schedule duration in ISO 8601 format.";
- }
- leaf repeat-interval {
- type string {
- pattern
- 'R\d*/P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?'
- + '(\d+S)?';
- }
- description "Repeat interval in ISO 8601 format.";
- }
- }
- }
- } // schedules
-}
diff --git a/apps/tenbi/yangmodel/src/main/yang/ietf-te-topology.yang b/apps/tenbi/yangmodel/src/main/yang/ietf-te-topology.yang
deleted file mode 100644
index 5c3efb1..0000000
--- a/apps/tenbi/yangmodel/src/main/yang/ietf-te-topology.yang
+++ /dev/null
@@ -1,2035 +0,0 @@
-module ietf-te-topology {
- //yang-version 1.1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
-
- prefix "tet";
-
- import ietf-yang-types {
- prefix "yang";
- }
-
- import ietf-inet-types {
- prefix "inet";
- }
-
- import ietf-te-types {
- prefix "te-types";
- }
-
- import ietf-network {
- prefix "nw";
- }
-
- import ietf-network-topology {
- prefix "nt";
- }
-
- organization
- "Traffic Engineering Architecture and Signaling (TEAS)
- Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/teas/>
- WG List: <mailto:teas@ietf.org>
-
- WG Chair: Lou Berger
- <mailto:lberger@labn.net>
-
- WG Chair: Vishnu Pavan Beeram
- <mailto:vbeeram@juniper.net>
-
- Editor: Xufeng Liu
- <mailto:xliu@kuatrotech.com>
-
- Editor: Igor Bryskin
- <mailto:Igor.Bryskin@huawei.com>
-
- Editor: Vishnu Pavan Beeram
- <mailto:vbeeram@juniper.net>
-
- Editor: Tarek Saad
- <mailto:tsaad@cisco.com>
-
- Editor: Himanshu Shah
- <mailto:hshah@ciena.com>
-
- Editor: Oscar Gonzalez De Dios
- <mailto:oscar.gonzalezdedios@telefonica.com>";
-
- description "TE topology model";
-
- revision "2017-01-10" {
- description "Initial revision";
- reference "TBD";
- }
-
- /*
- * Features
- */
- feature nsrlg {
- description
- "This feature indicates that the system supports NSRLG
- (Not Sharing Risk Link Group).";
- }
-
- feature te-topology-hierarchy {
- description
- "This feature indicates that the system allows underlay
- and/or overlay TE topology hierarchy.";
- }
-
- feature template {
- description
- "This feature indicates that the system supports
- template configuration.";
- }
-
- /*
- * Typedefs
- */
- typedef geographic-coordinate-degree {
- type decimal64 {
- fraction-digits 8;
- }
- description
- "Decimal degree (DD) used to express latitude and longitude
- geographic coordinates.";
- } // geographic-coordinate-degree
-
- typedef te-bandwidth {
- type string {
- pattern
- '0[xX](0((\.0?)?[pP](\+)?0?|(\.0?))|'
- + '1(\.([\da-fA-F]{0,5}[02468aAcCeE]?)?)?[pP](\+)?(12[0-7]|'
- + '1[01]\d|0?\d?\d)?)|0[xX][\da-fA-F]{1,8}|\d+'
- + '(,(0[xX](0((\.0?)?[pP](\+)?0?|(\.0?))|'
- + '1(\.([\da-fA-F]{0,5}[02468aAcCeE]?)?)?[pP](\+)?(12[0-7]|'
- + '1[01]\d|0?\d?\d)?)|0[xX][\da-fA-F]{1,8}|\d+))*';
- }
- description
- "This is the generic bandwidth type that is a string containing
- a list of numbers separated by commas, with each of these
- number can be non-negative decimal, hex integer, or hex float:
- (dec | hex | float)[*(','(dec | hex | float))]
- For packet switching type, a float number is used, such as
- 0x1p10.
- For OTN switching type, a list of integers can be used, such
- as '0,2,3,1', indicating 2 odu0's and 1 odu3.
- For DWDM, a list of pairs of slot number and width can be
- used, such as '0, 2, 3, 3', indicating a frequency slot 0 with
- slot width 2 and a frequency slot 3 with slot width 3.";
- } // te-bandwidth
-
- typedef te-info-source {
- type enumeration {
- enum "unknown" {
- description "The source is unknown.";
- }
- enum "locally-configured" {
- description "Configured entity.";
- }
- enum "ospfv2" {
- description "OSPFv2.";
- }
- enum "ospfv3" {
- description "OSPFv3.";
- }
- enum "isis" {
- description "ISIS.";
- }
- enum "bgp-ls" {
- description "BGP-LS.";
- reference
- "RFC7752: North-Bound Distribution of Link-State and
- Traffic Engineering (TE) Information Using BGP";
- }
- enum "system-processed" {
- description "System processed entity.";
- }
- enum "other" {
- description "Other source.";
- }
- }
- description
- "Describining the type of source that has provided the
- related information, and the source credibility.";
- } // te-info-source
-
- typedef te-path-disjointness {
- type bits {
- bit node {
- position 0;
- description "Node disjoint.";
- }
- bit link {
- position 1;
- description "Link disjoint.";
- }
- bit srlg {
- position 2;
- description "SRLG (Shared Risk Link Group) disjoint.";
- }
- }
- description
- "Type of the resource disjointness for a TE tunnel path.";
- reference
- "RFC4872: RSVP-TE Extensions in Support of End-to-End
- Generalized Multi-Protocol Label Switching (GMPLS)
- Recovery";
- } // te-path-disjointness
-
- /*
- * Groupings
- */
- grouping connectivity-label-restriction-list {
- description
- "List of abel restrictions specifying what labels may or may
- not be used on a link connectivity.";
- list label-restriction {
- key "inclusive-exclusive label-start";
- description
- "List of abel restrictions specifying what labels may or may
- not be used on a link connectivity.";
- reference
- "RFC7579: General Network Element Constraint Encoding
- for GMPLS-Controlled Networks";
- leaf inclusive-exclusive {
- type enumeration {
- enum inclusive {
- description "The label or label range is inclusive.";
- }
- enum exclusive {
- description "The label or label range is exclusive.";
- }
- }
- description
- "Whether the list item is inclusive or exclusive.";
- }
- leaf label-start {
- type te-types:generalized-label;
- description
- "This is the starting lable if a lable range is specified.
- This is the lable value if a single lable is specified,
- in which case, attribute 'label-end' is not set.";
- }
- leaf label-end {
- type te-types:generalized-label;
- description
- "The ending lable if a lable range is specified;
- This attribute is not set, If a single lable is
- specified.";
- }
- leaf range-bitmap {
- type binary;
- description
- "When there are gaps between label-start and label-end,
- this attribute is used to specified the possitions
- of the used labels.";
- }
- }
- } // connectivity-label-restrictions
-
- grouping connectivity-matrix-entry-attributes {
- description
- "Attributes of connectivity matrix entry.";
- leaf is-allowed {
- type boolean;
- description
- "true - switching is allowed,
- false - switching is disallowed.";
- }
- uses connectivity-label-restriction-list;
- container underlay {
- if-feature te-topology-hierarchy;
- presence
- "Indicates the underlay exists for this link.";
- description "Attributes of the te-link underlay.";
- reference
- "RFC4206: Label Switched Paths (LSP) Hierarchy with
- Generalized Multi-Protocol Label Switching (GMPLS)
- Traffic Engineering (TE)";
-
- uses te-link-underlay-attributes;
- } // underlay
- uses te-link-iscd-attributes;
- uses te-link-connectivity-attributes;
- } // connectivity-matrix-entry-attributes
-
- grouping geolocation-container {
- description
- "A container containing a GPS location.";
- container geolocation{
- description
- "A container containing a GPS location.";
- leaf altitude {
- type int64;
- units millimeter;
- description
- "Distance above the sea level.";
- }
- leaf latitude {
- type geographic-coordinate-degree {
- range "-90..90";
- }
- description
- "Relative position north or south on the Earth's surface.";
- }
- leaf longitude {
- type geographic-coordinate-degree {
- range "-180..180";
- }
- description
- "Angular distance east or west on the Earth's surface.";
- }
- } // gps-location
- } // geolocation-container
-
- grouping information-source-state-attributes {
- description
- "The attributes identifying source that has provided the
- related information, and the source credibility.";
- leaf credibility-preference {
- type uint16;
- description
- "The preference value to calculate the traffic
- engineering database credibility value used for
- tie-break selection between different
- information-source values.
- Higher value is more preferable.";
- }
- leaf logical-network-element {
- type string;
- description
- "When applicable, this is the name of a logical network
- element from which the information is learned.";
- } // logical-network-element
- leaf network-instance {
- type string;
- description
- "When applicable, this is the name of a network-instance
- from which the information is learned.";
- } // network-instance
- } // information-source-state-attributes
-
- grouping information-source-per-link-attributes {
- description
- "Per node container of the attributes identifying source that
- has provided the related information, and the source
- credibility.";
- leaf information-source {
- type te-info-source;
- description
- "Indicates the source of the information.";
- }
- container information-source-state {
- description
- "The container contains state attributes related to
- the information source.";
- uses information-source-state-attributes;
- container topology {
- description
- "When the information is processed by the system,
- the attributes in this container indicate which topology
- is used to process to generate the result information.";
- uses te-topology-ref;
- leaf link-ref {
- type leafref {
- path "/nw:networks/nw:network[nw:network-id = "
- + "current()/../network-ref]/nt:link/nt:link-id";
- require-instance false;
- }
- description
- "A reference to a link-id.";
- }
- } // topology
- } // information-source-state
- } // information-source-per-link-attributes
-
- grouping information-source-per-node-attributes {
- description
- "Per node container of the attributes identifying source that
- has provided the related information, and the source
- credibility.";
- leaf information-source {
- type te-info-source;
- description
- "Indicates the source of the information.";
- }
- container information-source-state {
- description
- "The container contains state attributes related to
- the information source.";
- uses information-source-state-attributes;
- container topology {
- description
- "When the information is processed by the system,
- the attributes in this container indicate which topology
- is used to process to generate the result information.";
- uses te-topology-ref;
- leaf node-ref {
- type leafref {
- path "/nw:networks/nw:network[nw:network-id = "
- + "current()/../network-ref]/nw:node/nw:node-id";
- require-instance false;
- }
- description
- "A reference to a node-id.";
- }
- } // topology
- } // information-source-state
- } // information-source-per-node-attributes
-
- grouping interface-switching-capability-list {
- description
- "List of Interface Switching Capabilities Descriptors (ISCD)";
-
- list interface-switching-capability {
- key "switching-capability";
- description
- "List of Interface Switching Capabilities Descriptors (ISCD)
- for this link.";
- reference
- "RFC3471: Generalized Multi-Protocol Label Switching (GMPLS)
- Signaling Functional Description.
- RFC4203: OSPF Extensions in Support of Generalized
- Multi-Protocol Label Switching (GMPLS).";
- leaf switching-capability {
- type identityref {
- base te-types:switching-capabilities;
- }
- description
- "Switching Capability for this interface.";
- }
- leaf encoding {
- type identityref {
- base te-types:lsp-encoding-types;
- }
- description
- "Encoding supported by this interface.";
- }
- uses te-link-iscd-attributes;
- } // interface-switching-capability
- } // interface-switching-capability-list
-
- grouping statistics-per-link {
- description
- "Statistics attributes per TE link.";
- leaf discontinuity-time {
- type yang:date-and-time;
- mandatory true;
- description
- "The time on the most recent occasion at which any one or
- more of this interface's counters suffered a
- discontinuity. If no such discontinuities have occurred
- since the last re-initialization of the local management
- subsystem, then this node contains the time the local
- management subsystem re-initialized itself.";
- }
- /* Administrative attributes */
- leaf disables {
- type yang:counter32;
- description
- "Number of times that link was disabled.";
- }
- leaf enables {
- type yang:counter32;
- description
- "Number of times that link was enabled.";
- }
- leaf maintenance-clears {
- type yang:counter32;
- description
- "Number of times that link was put out of maintenance.";
- }
- leaf maintenance-sets {
- type yang:counter32;
- description
- "Number of times that link was put in maintenance.";
- }
- leaf modifies {
- type yang:counter32;
- description
- "Number of times that link was modified.";
- }
- /* Operational attributes */
- leaf downs {
- type yang:counter32;
- description
- "Number of times that link was set to operational down.";
- }
- leaf ups {
- type yang:counter32;
- description
- "Number of times that link was set to operational up.";
- }
- /* Recovery attributes */
- leaf fault-clears {
- type yang:counter32;
- description
- "Number of times that link experienced fault clear event.";
- }
- leaf fault-detects {
- type yang:counter32;
- description
- "Number of times that link experienced fault detection.";
- }
- leaf protection-switches {
- type yang:counter32;
- description
- "Number of times that link experienced protection
- switchover.";
- }
- leaf protection-reverts {
- type yang:counter32;
- description
- "Number of times that link experienced protection
- reversion.";
- }
- leaf restoration-failures {
- type yang:counter32;
- description
- "Number of times that link experienced restoration
- failure.";
- }
- leaf restoration-starts {
- type yang:counter32;
- description
- "Number of times that link experienced restoration
- start.";
- }
- leaf restoration-successes {
- type yang:counter32;
- description
- "Number of times that link experienced restoration
- success.";
- }
- leaf restoration-reversion-failures {
- type yang:counter32;
- description
- "Number of times that link experienced restoration reversion
- failure.";
- }
- leaf restoration-reversion-starts {
- type yang:counter32;
- description
- "Number of times that link experienced restoration reversion
- start.";
- }
- leaf restoration-reversion-successes {
- type yang:counter32;
- description
- "Number of times that link experienced restoration reversion
- success.";
- }
- } // statistics-per-link
-
- grouping statistics-per-node {
- description
- "Statistics attributes per TE node.";
- leaf discontinuity-time {
- type yang:date-and-time;
- mandatory true;
- description
- "The time on the most recent occasion at which any one or
- more of this interface's counters suffered a
- discontinuity. If no such discontinuities have occurred
- since the last re-initialization of the local management
- subsystem, then this node contains the time the local
- management subsystem re-initialized itself.";
- }
- container node {
- description
- "Containing TE node level statistics attributes.";
- leaf disables {
- type yang:counter32;
- description
- "Number of times that node was disabled.";
- }
- leaf enables {
- type yang:counter32;
- description
- "Number of times that node was enabled.";
- }
- leaf maintenance-sets {
- type yang:counter32;
- description
- "Number of times that node was put in maintenance.";
- }
- leaf maintenance-clears {
- type yang:counter32;
- description
- "Number of times that node was put out of maintenance.";
- }
- leaf modifies {
- type yang:counter32;
- description
- "Number of times that node was modified.";
- }
- } // node
- container connectivity-matrix-entry {
- description
- "Containing connectivity matrix entry level statistics
- attributes.";
- leaf creates {
- type yang:counter32;
- description
- "Number of times that a connectivity matrix entry was
- created.";
- reference
- "RFC6241. Section 7.2 for 'create' operation. ";
- }
- leaf deletes {
- type yang:counter32;
- description
- "Number of times that a connectivity matrix entry was
- deleted.";
- reference
- "RFC6241. Section 7.2 for 'delete' operation. ";
- }
- leaf disables {
- type yang:counter32;
- description
- "Number of times that a connectivity matrix entry was
- disabled.";
- }
- leaf enables {
- type yang:counter32;
- description
- "Number of times that a connectivity matrix entry was
- enabled.";
- }
- leaf modifies {
- type yang:counter32;
- description
- "Number of times that a connectivity matrix entry was
- modified.";
- }
- } // connectivity-matrix-entry
- } // statistics-per-node
-
- grouping statistics-per-ttp {
- description
- "Statistics attributes per TE TTP (Tunnel Termination Point).";
- leaf discontinuity-time {
- type yang:date-and-time;
- mandatory true;
- description
- "The time on the most recent occasion at which any one or
- more of this interface's counters suffered a
- discontinuity. If no such discontinuities have occurred
- since the last re-initialization of the local management
- subsystem, then this node contains the time the local
- management subsystem re-initialized itself.";
- }
- container tunnel-termination-point {
- description
- "Containing TE TTP (Tunnel Termination Point) level
- statistics attributes.";
- /* Administrative attributes */
- leaf disables {
- type yang:counter32;
- description
- "Number of times that TTP was disabled.";
- }
- leaf enables {
- type yang:counter32;
- description
- "Number of times that TTP was enabled.";
- }
- leaf maintenance-clears {
- type yang:counter32;
- description
- "Number of times that TTP was put out of maintenance.";
- }
- leaf maintenance-sets {
- type yang:counter32;
- description
- "Number of times that TTP was put in maintenance.";
- }
- leaf modifies {
- type yang:counter32;
- description
- "Number of times that TTP was modified.";
- }
- /* Operational attributes */
- leaf downs {
- type yang:counter32;
- description
- "Number of times that TTP was set to operational down.";
- }
- leaf ups {
- type yang:counter32;
- description
- "Number of times that TTP was set to operational up.";
- }
- leaf in-service-clears {
- type yang:counter32;
- description
- "Number of times that TTP was taken out of service
- (TE tunnel was released).";
- }
- leaf in-service-sets {
- type yang:counter32;
- description
- "Number of times that TTP was put in service by a TE
- tunnel (TE tunnel was set up).";
- }
- } // tunnel-termination-point
-
- container local-link-connectivity {
- description
- "Containing TE LLCL (Local Link Connectivity List) level
- statistics attributes.";
- leaf creates {
- type yang:counter32;
- description
- "Number of times that an LLCL entry was created.";
- reference
- "RFC6241. Section 7.2 for 'create' operation. ";
- }
- leaf deletes {
- type yang:counter32;
- description
- "Number of times that an LLCL entry was deleted.";
- reference
- "RFC6241. Section 7.2 for 'delete' operation.";
- }
- leaf disables {
- type yang:counter32;
- description
- "Number of times that an LLCL entry was disabled.";
- }
- leaf enables {
- type yang:counter32;
- description
- "Number of times that an LLCL entry was enabled.";
- }
- leaf modifies {
- type yang:counter32;
- description
- "Number of times that an LLCL entry was modified.";
- }
- } // local-link-connectivity
- } // statistics-per-ttp
-
- grouping te-link-augment {
- description
- "Augmentation for TE link.";
-
- container te {
- must "count(../nt:supporting-link)<=1" {
- description
- "For a link in a TE topology, there cannot be more
- than 1 supporting link. If one or more link paths are
- abstracted, the underlay is used.";
- }
- presence "TE support.";
- description
- "Indicates TE support.";
-
- container config {
- description
- "Configuration data.";
- uses te-link-config;
- } // config
- container state {
- config false;
- description
- "Operational state data.";
- uses te-link-config;
- uses te-link-state-derived;
- } // state
- container statistics {
- config false;
- description
- "Statistics data.";
- uses statistics-per-link;
- } // statistics
- } // te
- } // te-link-augment
-
- grouping te-link-config {
- description
- "TE link configuration grouping.";
- choice bundle-stack-level {
- description
- "The TE link can be partitioned into bundled
- links, or component links.";
- case bundle {
- container bundled-links {
- description
- "A set of bundled links.";
- reference
- "RFC4201: Link Bundling in MPLS Traffic Engineering
- (TE).";
- list bundled-link {
- key "sequence";
- description
- "Specify a bundled interface that is
- further partitioned.";
- leaf sequence {
- type uint32;
- description
- "Identify the sequence in the bundle.";
- }
- leaf src-tp-ref {
- type leafref {
- path "../../../../../../nw:node[nw:node-id = "
- + "current()/../../../../../nt:source/"
- + "nt:source-node]/"
- + "nt:termination-point/nt:tp-id";
- require-instance true;
- }
- description
- "Reference to another TE termination point on the
- same souruce node.";
- }
- leaf des-tp-ref {
- type leafref {
- path "../../../../../../nw:node[nw:node-id = "
- + "current()/../../../../../nt:destination/"
- + "nt:dest-node]/"
- + "nt:termination-point/nt:tp-id";
- require-instance true;
- }
- description
- "Reference to another TE termination point on the
- same destination node.";
- }
- } // list bundled-link
- }
- }
- case component {
- container component-links {
- description
- "A set of component links";
- list component-link {
- key "sequence";
- description
- "Specify a component interface that is
- sufficient to unambiguously identify the
- appropriate resources";
-
- leaf sequence {
- type uint32;
- description
- "Identify the sequence in the bundle.";
- }
- leaf src-interface-ref {
- type string;
- description
- "Reference to component link interface on the
- source node.";
- }
- leaf des-interface-ref {
- type string;
- description
- "Reference to component link interface on the
- destinatioin node.";
- }
- }
- }
- }
- } // bundle-stack-level
-
- leaf-list te-link-template {
- if-feature template;
- type leafref {
- path "../../../../../te/templates/link-template/name";
- }
- description
- "The reference to a TE link template.";
- }
- uses te-link-config-attributes;
- } // te-link-config
-
- grouping te-link-config-attributes {
- description
- "Link configuration attributes in a TE topology.";
- container te-link-attributes {
- description "Link attributes in a TE topology.";
- leaf access-type {
- type te-types:te-link-access-type;
- description
- "Link access type, which can be point-to-point or
- multi-access.";
- }
- container external-domain {
- description
- "For an inter-domain link, specify the attributes of
- the remote end of link, to facilitate the signalling at
- local end.";
- uses te-topology-ref;
- leaf remote-te-node-id {
- type te-types:te-node-id;
- description
- "Remote TE node identifier, used together with
- remote-te-link-id to identify the remote link
- termination point in a different domain.";
- }
- leaf remote-te-link-tp-id {
- type te-types:te-tp-id;
- description
- "Remote TE link termination point identifier, used
- together with remote-te-node-id to identify the remote
- link termination point in a different domain.";
- }
- leaf plug-id {
- type uint32;
- description
- "A topology-wide unique number that identifies on the
- network a connectivity supporting a given inter-domain
- TE link. This is more flexible alternative to specifying
- remote-te-node-id and remote-te-link-tp-id, when the
- provider does not know remote-te-node-id and
- remote-te-link-tp-id or need to give client the
- flexibility to mix-n-match multiple topologies.";
- }
- }
- leaf is-abstract {
- type empty;
- description "Present if the link is abstract.";
- }
- leaf name {
- type string;
- description "Link Name.";
- }
- container underlay {
- if-feature te-topology-hierarchy;
- presence
- "Indicates the underlay exists for this link.";
- description "Attributes of the te-link underlay.";
- reference
- "RFC4206: Label Switched Paths (LSP) Hierarchy with
- Generalized Multi-Protocol Label Switching (GMPLS)
- Traffic Engineering (TE)";
-
- uses te-link-underlay-attributes;
- } // underlay
- leaf admin-status {
- type te-types:te-admin-status;
- description
- "The administrative state of the link.";
- }
-
- uses te-link-info-attributes;
- } // te-link-attributes
- } // te-link-config-attributes
-
- grouping te-link-connectivity-attributes {
- description
- "Advertised TE connectivity attributes.";
- leaf max-link-bandwidth {
- type te-bandwidth;
- description
- "Maximum bandwidth that can be seen on this link in this
- direction. Units in bytes per second.";
- reference
- "RFC3630: Traffic Engineering (TE) Extensions to OSPF
- Version 2.
- RFC5305: IS-IS Extensions for Traffic Engineering.";
- }
- leaf max-resv-link-bandwidth {
- type te-bandwidth;
- description
- "Maximum amount of bandwidth that can be reserved in this
- direction in this link. Units in bytes per second.";
- reference
- "RFC3630: Traffic Engineering (TE) Extensions to OSPF
- Version 2.
- RFC5305: IS-IS Extensions for Traffic Engineering.";
- }
- list unreserved-bandwidth {
- key "priority";
- max-elements "8";
- description
- "Unreserved bandwidth for 0-7 priority levels. Units in
- bytes per second.";
- reference
- "RFC3630: Traffic Engineering (TE) Extensions to OSPF
- Version 2.
- RFC5305: IS-IS Extensions for Traffic Engineering.";
- leaf priority {
- type uint8 {
- range "0..7";
- }
- description "Priority.";
- }
- leaf bandwidth {
- type te-bandwidth;
- description
- "Unreserved bandwidth for this level.";
- }
- }
- leaf te-default-metric {
- type uint32;
- description
- "Traffic engineering metric.";
- }
- leaf te-delay-metric {
- type uint32;
- description
- "Traffic engineering delay metric.";
- }
- container te-srlgs {
- description
- "Containing a list of SLRGs.";
- leaf-list value {
- type te-types:srlg;
- description "SRLG value.";
- reference
- "RFC4202: Routing Extensions in Support of
- Generalized Multi-Protocol Label Switching (GMPLS).";
- }
- }
- container te-nsrlgs {
- if-feature nsrlg;
- description
- "Containing a list of NSRLGs (Not Sharing Risk Link
- Groups).
- When an abstract TE link is configured, this list specifies
- the request that underlay TE paths need to be mutually
- disjoint with other TE links in the same groups.";
- leaf-list id {
- type uint32;
- description
- "NSRLG ID, uniquely configured within a topology.";
- reference
- "RFC4872: RSVP-TE Extensions in Support of End-to-End
- Generalized Multi-Protocol Label Switching (GMPLS)
- Recovery";
- }
- }
- } // te-link-connectivity-attributes
-
- grouping te-link-info-attributes {
- description
- "Advertised TE information attributes.";
- leaf link-index {
- type uint64;
- description
- "The link identifier. If OSPF is used, this represents an
- ospfLsdbID. If IS-IS is used, this represents an isisLSPID.
- If a locally configured link is used, this object represents
- a unique value, which is locally defined in a router.";
- }
- leaf administrative-group {
- type te-types:admin-groups;
- description
- "Administrative group or color of the link.
- This attribute covers both administrative group (defined in
- RFC3630, RFC5329, and RFC5305), and extended administrative
- group (defined in RFC7308).";
- }
- uses interface-switching-capability-list;
- leaf link-protection-type {
- type enumeration {
- enum "unprotected" {
- description "Unprotected.";
- }
- enum "extra-traffic" {
- description "Extra traffic.";
- }
- enum "shared" {
- description "Shared.";
- }
- enum "1-for-1" {
- description "One for one protection.";
- }
- enum "1-plus-1" {
- description "One plus one protection.";
- }
- enum "enhanced" {
- description "Enhanced protection.";
- }
- }
- description
- "Link Protection Type desired for this link.";
- reference
- "RFC4202: Routing Extensions in Support of
- Generalized Multi-Protocol Label Switching (GMPLS).";
- }
- uses te-link-connectivity-attributes;
- } // te-link-info-attributes
-
- grouping te-link-iscd-attributes {
- description
- "TE link ISCD (Interface Switching Capability Descriptor)
- attributes.";
- reference
- "Sec 1.4, RFC4203: OSPF Extensions in Support of Generalized
- Multi-Protocol Label Switching (GMPLS). Section 1.4.";
- list max-lsp-bandwidth {
- key "priority";
- max-elements "8";
- description
- "Maximum LSP Bandwidth at priorities 0-7.";
- leaf priority {
- type uint8 {
- range "0..7";
- }
- description "Priority.";
- }
- leaf bandwidth {
- type te-bandwidth;
- description
- "Max LSP Bandwidth for this level";
- }
- }
- } // te-link-iscd-attributes
-
- grouping te-link-state-derived {
- description
- "Link state attributes in a TE topology.";
- leaf oper-status {
- type te-types:te-oper-status;
- description
- "The current operational state of the link.";
- }
- leaf is-transitional {
- type empty;
- description
- "Present if the link is transitional, used as an
- alternative approach in lieu of inter-layer-lock-id
- for path computation in a TE topology covering multiple
- layers or multiple regions.";
- reference
- "RFC5212: Requirements for GMPLS-Based Multi-Region and
- Multi-Layer Networks (MRN/MLN).
- RFC6001: Generalized MPLS (GMPLS) Protocol Extensions
- for Multi-Layer and Multi-Region Networks (MLN/MRN).";
- }
- uses information-source-per-link-attributes;
- list information-source-entry {
- key "information-source";
- description
- "A list of information sources learned, including the one
- used.";
- uses information-source-per-link-attributes;
- uses te-link-info-attributes;
- }
- container recovery {
- description
- "Status of the recovery process.";
- leaf restoration-status {
- type te-types:te-recovery-status;
- description
- "Restoration status.";
- }
- leaf protection-status {
- type te-types:te-recovery-status;
- description
- "Protection status.";
- }
- }
- container underlay {
- if-feature te-topology-hierarchy;
- description "State attributes for te-link underlay.";
- uses te-link-state-underlay-attributes;
- }
- } // te-link-state-derived
-
- grouping te-link-state-underlay-attributes {
- description "State attributes for te-link underlay.";
- leaf dynamic {
- type boolean;
- description
- "true if the underlay is dynamically created.";
- }
- leaf committed {
- type boolean;
- description
- "true if the underlay is committed.";
- }
- } // te-link-state-underlay-attributes
-
- grouping te-link-underlay-attributes {
- description "Attributes for te-link underlay.";
- reference
- "RFC4206: Label Switched Paths (LSP) Hierarchy with
- Generalized Multi-Protocol Label Switching (GMPLS)
- Traffic Engineering (TE)";
- container primary-path {
- description
- "The service path on the underlay topology that
- supports this link.";
- uses te-topology-ref;
- list path-element {
- key "path-element-id";
- description
- "A list of path elements describing the service path.";
- leaf path-element-id {
- type uint32;
- description "To identify the element in a path.";
- }
- uses te-path-element;
- }
- } // primary-path
- list backup-path {
- key "index";
- description
- "A list of backup service paths on the underlay topology that
- protect the underlay primary path. If the primary path is
- not protected, the list contains zero elements. If the
- primary path is protected, the list contains one or more
- elements.";
- leaf index {
- type uint32;
- description
- "A sequence number to identify a backup path.";
- }
- uses te-topology-ref;
- list path-element {
- key "path-element-id";
- description
- "A list of path elements describing the backup service
- path";
- leaf path-element-id {
- type uint32;
- description "To identify the element in a path.";
- }
- uses te-path-element;
- }
- } // underlay-backup-path
- leaf protection-type {
- type uint16;
- description
- "Underlay protection type desired for this link";
- }
- container tunnel-src {
- uses te-tunnel-tp-ref;
- description
- "Source tunnel termination point of the underlay
- tunnel.";
- }
- container tunnel-des {
- uses te-tunnel-tp-ref;
- description
- "Destination tunnel termination point of the underlay
- tunnel.";
- }
- leaf tunnel-id {
- type uint16;
- description
- "Tunnel identifier used in the SESSION that remains constant
- over the life of the tunnel.
- This attribute is used together with underlay tunnel-src
- and underlay tunnel-src.
- The detailed information of this tunnel can be retrieved
- from the ietf-te model.";
- reference "RFC3209";
- }
- leaf tunnel-sharing {
- type boolean;
- description
- "'true' if the underlay tunnel can be shared with other
- TE links;
- 'false' if the underlay tunnel is dedicated to this
- TE link.";
- }
- } // te-link-underlay-attributes
-
- grouping te-node-augment {
- description
- "Augmentation for TE node.";
-
- leaf te-node-id {
- type te-types:te-node-id;
- description
- "The identifier of a node in the TE topology.
- A node is specific to a topology to which it belongs.";
- }
-
- container te {
- must "../te-node-id" {
- description
- "te-node-id is mandatory.";
- }
- must "count(../nw:supporting-node)<=1" {
- description
- "For a node in a TE topology, there cannot be more
- than 1 supporting node. If multiple nodes are abstracted,
- the underlay-topology is used.";
- }
- presence "TE support.";
- description
- "Indicates TE support.";
-
- container config {
- description
- "Configuration data.";
- uses te-node-config;
- } // config
- container state {
- config false;
- description
- "Operational state data.";
-
- uses te-node-config;
- uses te-node-state-derived;
- } // state
- container statistics {
- config false;
- description
- "Statistics data.";
- uses statistics-per-node;
- } // statistics
-
- list tunnel-termination-point {
- key "tunnel-tp-id";
- description
- "A termination point can terminate a tunnel.";
- leaf tunnel-tp-id {
- type binary;
- description
- "Tunnel termination point identifier.";
- }
-
- container config {
- description
- "Configuration data.";
- uses te-node-tunnel-termination-attributes;
- }
- container state {
- config false;
- description
- "Operational state data.";
-
- uses te-node-tunnel-termination-attributes;
- uses geolocation-container;
- } // state
- container statistics {
- config false;
- description
- "Statistics data.";
- uses statistics-per-ttp;
- } // statistics
-
- // Relations to other tunnel termination points
- list supporting-tunnel-termination-point {
-// key "node-ref tunnel-tp-ref";
- key "network-ref node-ref tunnel-tp-ref";
- description
- "Identifies the tunnel termination points, that this
- tunnel termination point is depending on.";
-// leaf node-ref {
-// type leafref {
-// path "../../../../nw:supporting-node/nw:node-ref";
-// require-instance false;
-// }
-// description
-// "This leaf identifies in which node the supporting
-// tunnel termination point is present.";
-// }
- uses nw:node-ref;
- leaf tunnel-tp-ref {
- type leafref {
- path "/nw:networks/nw:network"+
- "[nw:network-id="+
- "current()/../../../../nw:supporting-node/"+
- "nw:network-ref]/"+
- "nw:node[nw:node-id=current()/../node-ref]/te/"+
- "tunnel-termination-point/tunnel-tp-id";
- require-instance false;
- }
- description
- "Reference to the underlay node, must be in a
- different topology";
- }
- } // supporting-tunnel-termination-point
- } // tunnel-termination-point
- } // te
- } // te-node-augment
-
- grouping te-node-config {
- description "TE node configuration grouping.";
-
- leaf-list te-node-template {
- if-feature template;
- type leafref {
- path "../../../../../te/templates/node-template/name";
- }
- description
- "The reference to a TE node template.";
- }
- uses te-node-config-attributes;
- } // te-node-config
-
- grouping te-node-config-attributes {
- description "Configuration node attributes in a TE topology.";
- container te-node-attributes {
- description "Containing node attributes in a TE topology.";
- leaf admin-status {
- type te-types:te-admin-status;
- description
- "The administrative state of the link.";
- }
- uses te-node-connectivity-matrix;
- uses te-node-info-attributes;
- } // te-node-attributes
- } // te-node-config-attributes
-
- grouping te-node-config-attributes-template {
- description
- "Configuration node attributes for template in a TE topology.";
- container te-node-attributes {
- description "Containing node attributes in a TE topology.";
- leaf admin-status {
- type te-types:te-admin-status;
- description
- "The administrative state of the link.";
- }
- uses te-node-info-attributes;
- } // te-node-attributes
- } // te-node-config-attributes-template
-
- grouping te-node-connectivity-matrix {
- description "Connectivity matrix on a TE node.";
- container connectivity-matrices {
- description
- "Containing connectivity matrix on a TE node.";
- leaf number-of-entries {
- type uint16;
- description
- "The number of connectivity matrix entries.
- If this number is speficied in the configuration request,
- the number is requested number of entries, which may not
- all be listed in the list;
- if this number is reported in the state data,
- the number is the current number of operational entries.";
- }
- uses connectivity-matrix-entry-attributes;
- list connectivity-matrix {
- key "id";
- description
- "Represents node's switching limitations, i.e. limitations
- in interconnecting network TE links across the node.";
- reference
- "RFC7579: General Network Element Constraint Encoding
- for GMPLS-Controlled Networks.";
- leaf id {
- type uint32;
- description "Identifies the connectivity-matrix entry.";
- }
- container from {
- leaf tp-ref {
- type leafref {
- path "../../../../../../../nt:termination-point/"+
- "nt:tp-id";
- }
- description
- "Relative reference to source termination point.";
- }
- description
- "Reference to source NTP.";
- }
- container to {
- leaf tp-ref {
- type leafref {
- path "../../../../../../../nt:termination-point/"+
- "nt:tp-id";
- }
- description
- "Relative reference to destination termination point.";
- }
- description
- "Reference to destination NTP.";
- }
- uses connectivity-matrix-entry-attributes;
- } // connectivity-matrix
- } // connectivity-matrices
- } // te-node-connectivity-matrix
-
- grouping te-node-connectivity-matrix-abs {
- description
- "Connectivity matrix on a TE node, using absolute
- paths to reference termination points.";
- list connectivity-matrix {
- key "id";
- description
- "Represents node's switching limitations, i.e. limitations
- in interconnecting network TE links across the node.";
- reference
- "RFC7579: General Network Element Constraint Encoding
- for GMPLS-Controlled Networks.";
- leaf id {
- type uint32;
- description "Identifies the connectivity-matrix entry.";
- }
- container from {
- uses nt:tp-ref;
- description
- "Reference to source NTP.";
- }
- container to {
- uses nt:tp-ref;
- description
- "Reference to destination NTP.";
- }
- leaf is-allowed {
- type boolean;
- description
- "true - switching is allowed,
- false - switching is disallowed.";
- }
- }
- } // te-node-connectivity-matrix-abs
-
- grouping te-node-info-attributes {
- description
- "Advertised TE information attributes.";
- leaf domain-id {
- type uint32;
- description
- "Identifies the domain that this node belongs.
- This attribute is used to support inter-domain links.";
- reference
- "RFC5152: A Per-Domain Path Computation Method for
- Establishing Inter-Domain Traffic Engineering (TE)
- Label Switched Paths (LSPs).
- RFC5392: OSPF Extensions in Support of Inter-Autonomous
- System (AS) MPLS and GMPLS Traffic Engineering.
- RFC5316: ISIS Extensions in Support of Inter-Autonomous
- System (AS) MPLS and GMPLS Traffic Engineering.";
- }
- leaf is-abstract {
- type empty;
- description
- "Present if the node is abstract, not present if the node
- is actual.";
- }
- leaf name {
- type inet:domain-name;
- description "Node name.";
- }
- leaf-list signaling-address {
- type inet:ip-address;
- description "Node signaling address.";
- }
- container underlay-topology {
- if-feature te-topology-hierarchy;
- description
- "When an abstract node encapsulates a topology,
- the attributes in this container point to said topology.";
- uses te-topology-ref;
- }
- } // te-node-info-attributes
-
- grouping te-node-state-derived {
- description "Node state attributes in a TE topology.";
- leaf oper-status {
- type te-types:te-oper-status;
- description
- "The current operational state of the node.";
- }
- uses geolocation-container;
- leaf is-multi-access-dr {
- type empty;
- description
- "The presence of this attribute indicates that this TE node
- is a pseudonode elected as a designated router.";
- reference
- "RFC3630: Traffic Engineering (TE) Extensions to OSPF
- Version 2.
- RFC1195: Use of OSI IS-IS for Routing in TCP/IP and Dual
- Environments.";
- }
- uses information-source-per-node-attributes;
- list information-source-entry {
- key "information-source";
- description
- "A list of information sources learned, including the one
- used.";
- uses information-source-per-node-attributes;
- uses te-node-connectivity-matrix;
- uses te-node-info-attributes;
- }
- } // te-node-state-derived
-
- grouping te-node-state-derived-notification {
- description "Node state attributes in a TE topology.";
- leaf oper-status {
- type te-types:te-oper-status;
- description
- "The current operational state of the node.";
- }
- leaf is-multi-access-dr {
- type empty;
- description
- "The presence of this attribute indicates that this TE node
- is a pseudonode elected as a designated router.";
- reference
- "RFC3630: Traffic Engineering (TE) Extensions to OSPF
- Version 2.
- RFC1195: Use of OSI IS-IS for Routing in TCP/IP and Dual
- Environments.";
- }
- uses information-source-per-node-attributes;
- list information-source-entry {
- key "information-source";
- description
- "A list of information sources learned, including the one
- used.";
- uses information-source-per-node-attributes;
- uses te-node-connectivity-matrix-abs;
- uses te-node-info-attributes;
- }
- } // te-node-state-derived-notification
-
- grouping te-node-tunnel-termination-attributes {
- description
- "Termination capability of a tunnel termination point on a
- TE node.";
-
- leaf switching-capability {
- type identityref {
- base te-types:switching-capabilities;
- }
- description
- "Switching Capability for this interface.";
- }
- leaf encoding {
- type identityref {
- base te-types:lsp-encoding-types;
- }
- description
- "Encoding supported by this interface.";
- }
- leaf inter-layer-lock-id {
- type uint32;
- description
- "Inter layer lock ID, used for path computation in a TE
- topology covering multiple layers or multiple regions.";
- reference
- "RFC5212: Requirements for GMPLS-Based Multi-Region and
- Multi-Layer Networks (MRN/MLN).
- RFC6001: Generalized MPLS (GMPLS) Protocol Extensions
- for Multi-Layer and Multi-Region Networks (MLN/MRN).";
- }
- leaf protection-type {
- type identityref {
- base te-types:lsp-prot-type;
- }
- description
- "The protection type that this tunnel termination point
- is capable of.";
- }
-
- container local-link-connectivities {
- description
- "Containing local link connectivity list for
- a tunnel termination point on a TE node.";
- leaf number-of-entries {
- type uint16;
- description
- "The number of local link connectivity list entries.
- If this number is speficied in the configuration request,
- the number is requested number of entries, which may not
- all be listed in the list;
- if this number is reported in the state data,
- the number is the current number of operational entries.";
- }
- uses connectivity-matrix-entry-attributes;
- list local-link-connectivity {
- key "link-tp-ref";
- description
- "The termination capabilities between
- tunnel-termination-point and link termination-point.
- The capability information can be used to compute
- the tunnel path.
- The Interface Adjustment Capability Descriptors (IACD)
- [RFC6001] on each link-tp can be derived from this
- local-link-connectivity list.";
- reference
- "RFC6001: Generalized MPLS (GMPLS) Protocol Extensions
- for Multi-Layer and Multi-Region Networks (MLN/MRN).";
- leaf link-tp-ref {
- type leafref {
- path "../../../../../../nt:termination-point/nt:tp-id";
- }
- description
- "Link termination point.";
- }
-
- uses connectivity-matrix-entry-attributes;
- } // local-link-connectivity
- } // local-link-connectivities
- } // te-node-tunnel-termination-attributes
-
- grouping te-path-element {
- description
- "A group of attributes defining an element in a TE path
- such as TE node, TE link, TE atomic resource or label.";
- uses te-types:explicit-route-subobject;
- } // te-path-element
-
- grouping te-termination-point-augment {
- description
- "Augmentation for TE termination point.";
-
- leaf te-tp-id {
- type te-types:te-tp-id;
- description
- "An identifier to uniquely identify a TE termination
- point.";
- }
-
- container te {
- must "../te-tp-id";
- presence "TE support.";
- description
- "Indicates TE support.";
-
- container config {
- description
- "Configuration data.";
- uses te-termination-point-config;
- } // config
- container state {
- config false;
- description
- "Operational state data.";
- uses te-termination-point-config;
- uses geolocation-container;
- } // state
- } // te
- } // te-termination-point-augment
-
- grouping te-termination-point-config {
- description
- "TE termination point configuration grouping.";
- uses interface-switching-capability-list;
- leaf inter-layer-lock-id {
- type uint32;
- description
- "Inter layer lock ID, used for path computation in a TE
- topology covering multiple layers or multiple regions.";
- reference
- "RFC5212: Requirements for GMPLS-Based Multi-Region and
- Multi-Layer Networks (MRN/MLN).
- RFC6001: Generalized MPLS (GMPLS) Protocol Extensions
- for Multi-Layer and Multi-Region Networks (MLN/MRN).";
- }
- } // te-termination-point-config
-
- grouping te-topologies-augment {
- description
- "Augmentation for TE topologies.";
-
- container te {
- presence "TE support.";
- description
- "Indicates TE support.";
-
- container templates {
- description
- "Configuration parameters for templates used for TE
- topology.";
-
- list node-template {
- if-feature template;
- key "name";
- leaf name {
- type te-types:te-template-name;
- description
- "The name to identify a TE node template.";
- }
- description
- "The list of TE node templates used to define sharable
- and reusable TE node attributes.";
- uses template-attributes;
- uses te-node-config-attributes-template;
- } // node-template
-
- list link-template {
- if-feature template;
- key "name";
- leaf name {
- type te-types:te-template-name;
- description
- "The name to identify a TE link template.";
- }
- description
- "The list of TE link templates used to define sharable
- and reusable TE link attributes.";
- uses template-attributes;
- uses te-link-config-attributes;
- } // link-template
- } // templates
- } // te
- } // te-topologies-augment
-
- grouping te-topology-augment {
- description
- "Augmentation for TE topology.";
-
- leaf provider-id {
- type te-types:te-global-id;
- description
- "An identifier to uniquely identify a provider.";
- }
- leaf client-id {
- type te-types:te-global-id;
- description
- "An identifier to uniquely identify a client.";
- }
- leaf te-topology-id {
- type te-types:te-topology-id;
- description
- "It is presumed that a datastore will contain many
- topologies. To distinguish between topologies it is
- vital to have UNIQUE topology identifiers.";
- }
-
- container te {
- must "../provider-id and ../client-id and ../te-topology-id";
- presence "TE support.";
- description
- "Indicates TE support.";
-
- container config {
- description
- "Configuration data.";
- uses te-topology-config;
- } // config
- container state {
- config false;
- description
- "Operational state data.";
- uses te-topology-config;
- uses geolocation-container;
- } // state
- } // te
- } // te-topology-augment
-
- grouping te-topology-config {
- description
- "TE topology configuration grouping.";
- leaf preference {
- type uint8 {
- range "1..255";
- }
- description
- "Specifies a preference for this topology. A lower number
- indicates a higher preference.";
- }
- leaf optimization-criterion {
- type identityref {
- base te-types:te-optimization-criterion;
- }
- description
- "Optimization criterion applied to this topology.";
- reference
- "RFC3272: Overview and Principles of Internet Traffic
- Engineering.";
- }
- list nsrlg {
- if-feature nsrlg;
- key "id";
- description
- "List of NSRLGs (Not Sharing Risk Link Groups).";
- reference
- "RFC4872: RSVP-TE Extensions in Support of End-to-End
- Generalized Multi-Protocol Label Switching (GMPLS)
- Recovery";
- leaf id {
- type uint32;
- description
- "Identify the NSRLG entry.";
- }
- leaf disjointness {
- type te-path-disjointness;
- description
- "The type of resource disjointness.";
- }
- } // nsrlg
- } // te-topology-config
-
- grouping te-topology-ref {
- description
- "References a TE topology.";
- leaf network-ref {
- type leafref {
- path "/nw:networks/nw:network/nw:network-id";
- require-instance false;
- }
- description
- "A reference to a network-id in base ietf-network module.";
- }
- } // te-topology-ref
-
- grouping te-topology-type {
- description
- "Identifies the TE topology type.";
- container te-topology {
- presence "Indicates TE topology.";
- description
- "Its presence identifies the TE topology type.";
- }
- } // te-topology-type
-
- grouping te-tunnel-tp-ref {
- description
- "References a tunnel termination point in a TE topology.";
- leaf tunnel-tp-ref {
- type leafref {
- path "/nw:networks/nw:network[nw:network-id=current()/../"+
- "network-ref]/nw:node[nw:node-id=current()/../node-ref]/"+
- "te/tunnel-termination-point/tunnel-tp-id";
- require-instance false;
- }
- description
- "An absolute reference to a tunnel termination point.
- (This should not be used for relative references.
- In such a case, a relative path should be used instead.)";
- }
- uses nw:node-ref;
- } // te-tunnel-tp-ref
-
- grouping template-attributes {
- description
- "Common attributes for all templates.";
-
- leaf priority {
- type uint16;
- description
- "The preference value to resolve conflicts between different
- templates. When two or more templates specify values for
- one configuration attribute, the value from the template
- with the highest priority is used.";
- }
- leaf reference-change-policy {
- type enumeration {
- enum no-action {
- description
- "When an attribute changes in this template, the
- configuration node referring to this template does
- not take any action.";
- }
- enum not-allowed {
- description
- "When any configuration object has a reference to this
- template, changing this template is not allowed.";
- }
- enum cascade {
- description
- "When an attribute changes in this template, the
- configuration object referring to this template applies
- the new attribute value to the corresponding
- configuration.";
- }
- }
- description
- "This attribute specifies the action taken to a configuration
- node that has a reference to this template.";
- }
- } // template-attributes
-
- /*
- * Configuration data nodes
- */
- augment "/nw:networks/nw:network/nw:network-types" {
- description
- "Introduce new network type for TE topology.";
- uses te-topology-type;
- }
-
- augment "/nw:networks" {
- description
- "Augmentation parameters for TE topologies.";
- uses te-topologies-augment;
- }
-
- augment "/nw:networks/nw:network" {
- when "nw:network-types/te-topology" {
- description
- "Augmentation parameters apply only for networks with
- TE topology type.";
- }
- description
- "Configuration parameters for TE topology.";
- uses te-topology-augment;
- }
-
- augment "/nw:networks/nw:network/nw:node" {
- when "../nw:network-types/te-topology" {
- description
- "Augmentation parameters apply only for networks with
- TE topology type.";
- }
- description
- "Configuration parameters for TE at node level.";
- uses te-node-augment;
- }
-
- augment "/nw:networks/nw:network/nt:link" {
- when "../nw:network-types/te-topology" {
- description
- "Augmentation parameters apply only for networks with
- TE topology type.";
- }
- description
- "Configuration parameters for TE at link level";
- uses te-link-augment;
- }
-
- augment "/nw:networks/nw:network/nw:node/"
- + "nt:termination-point" {
- when "../../nw:network-types/te-topology" {
- description
- "Augmentation parameters apply only for networks with
- TE topology type.";
- }
- description
- "Configuration parameters for TE at termination point level";
- uses te-termination-point-augment;
- }
-
- /*
- * Notifications
- */
- grouping te-node-config-attributes-notification {
- description
- "Configuration node attributes for template in a TE topology.";
- container te-node-attributes {
- description "Containing node attributes in a TE topology.";
- leaf admin-status {
- type te-types:te-admin-status;
- description
- "The administrative state of the link.";
- }
- uses te-node-connectivity-matrix-abs;
- uses te-node-info-attributes;
- } // te-node-attributes
- } // te-node-config-attributes-notification
-
- notification te-node-event {
- description "Notification event for TE node.";
- leaf event-type {
- type te-types:te-topology-event-type;
- description "Event type.";
- }
- uses nw:node-ref;
- uses te-topology-type;
- uses tet:te-node-config-attributes-notification;
- uses tet:te-node-state-derived-notification;
- }
-
- notification te-link-event {
- description "Notification event for TE link.";
- leaf event-type {
- type te-types:te-topology-event-type;
- description "Event type";
- }
- uses nt:link-ref;
- uses te-topology-type;
- uses tet:te-link-config-attributes;
- uses tet:te-link-state-derived;
- }
-
- augment "/te-link-event/te-link-attributes/underlay" {
- description "Add state attributes to te-link underlay.";
- uses te-link-state-underlay-attributes;
- }
-
-}
diff --git a/apps/tenbi/yangmodel/src/main/yang/ietf-te-types.yang b/apps/tenbi/yangmodel/src/main/yang/ietf-te-types.yang
deleted file mode 100644
index 2e76380..0000000
--- a/apps/tenbi/yangmodel/src/main/yang/ietf-te-types.yang
+++ /dev/null
@@ -1,1229 +0,0 @@
-module ietf-te-types {
-
- namespace "urn:ietf:params:xml:ns:yang:ietf-te-types";
-
- /* Replace with IANA when assigned */
- prefix "te-types";
-
- import ietf-inet-types {
- prefix inet;
- }
-
- import ietf-yang-types {
- prefix "yang";
- }
-
- organization
- "IETF Traffic Engineering Architecture and Signaling (TEAS)
- Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/teas/>
- WG List: <mailto:teas@ietf.org>
-
- WG Chair: Lou Berger
- <mailto:lberger@labn.net>
-
- WG Chair: Vishnu Pavan Beeram
- <mailto:vbeeram@juniper.net>
-
- Editor: Tarek Saad
- <mailto:tsaad@cisco.com>
-
- Editor: Rakesh Gandhi
- <mailto:rgandhi@cisco.com>
-
- Editor: Vishnu Pavan Beeram
- <mailto:vbeeram@juniper.net>
-
- Editor: Himanshu Shah
- <mailto:hshah@ciena.com>
-
- Editor: Xufeng Liu
- <mailto:xufeng.liu@ericsson.com>
-
- Editor: Xia Chen
- <mailto:jescia.chenxia@huawei.com>
-
- Editor: Raqib Jones
- <mailto:raqib@Brocade.com>
-
- Editor: Bin Wen
- <mailto:Bin_Wen@cable.comcast.com>";
-
- description
- "This module contains a collection of generally
- useful TE specific YANG data type defintions.";
-
- revision "2016-07-05" {
- description "Latest revision of TE basic types";
- reference "RFC3209";
- }
-
- /*
- * Identities
- */
- identity tunnel-type {
- description
- "Base identity from which specific tunnel types are
- derived.";
- }
-
- identity tunnel-p2p {
- base tunnel-type;
- description
- "TE point-to-point tunnel type.";
- }
-
- identity tunnel-p2mp {
- base tunnel-type;
- description
- "TE point-to-multipoint tunnel type.";
- }
-
- identity state-type {
- description
- "Base identity for TE states";
- }
-
- identity state-up {
- base state-type;
- description
- "State up";
- }
-
- identity state-down {
- base state-type;
- description
- "State down";
- }
-
- identity path-invalidation-action-type {
- description
- "Base identity for TE path invalidation action types";
- }
-
- identity tunnel-invalidation-action-drop-type {
- base path-invalidation-action-type;
- description
- "TE path invalidation action drop";
- }
-
- identity tunnel-invalidation-action-drop-tear {
- base path-invalidation-action-type;
- description
- "TE path invalidation action tear";
- }
-
- identity lsp-prot-type {
- description
- "Base identity from which LSP protection types are
- derived.";
- }
-
- identity lsp-prot-unprotected {
- base lsp-prot-type;
- description
- "LSP protection 'Unprotected'";
- reference "RFC4872";
- }
-
- identity lsp-prot-reroute-extra {
- base lsp-prot-type;
- description
- "LSP protection '(Full) Rerouting'";
- reference "RFC4872";
- }
-
- identity lsp-prot-reroute {
- base lsp-prot-type;
- description
- "LSP protection 'Rerouting without Extra-Traffic'";
- reference "RFC4872";
- }
-
- identity lsp-prot-1-for-n {
- base lsp-prot-type;
- description
- "LSP protection '1:N Protection with Extra-Traffic'";
- reference "RFC4872";
- }
-
- identity lsp-prot-unidir-1-to-1 {
- base lsp-prot-type;
- description
- "LSP protection '1+1 Unidirectional Protection'";
- reference "RFC4872";
- }
-
- identity lsp-prot-bidir-1-to-1 {
- base lsp-prot-type;
- description
- "LSP protection '1+1 Bidirectional Protection'";
- reference "RFC4872";
- }
-
- identity switching-capabilities {
- description
- "Base identity for interface switching capabilities";
- }
-
- identity switching-psc1 {
- base switching-capabilities;
- description
- "Packet-Switch Capable-1 (PSC-1)";
- }
-
- identity switching-evpl {
- base switching-capabilities;
- description
- "Ethernet Virtual Private Line (EVPL)";
- }
-
- identity switching-l2sc {
- base switching-capabilities;
- description
- "Layer-2 Switch Capable (L2SC)";
- }
-
- identity switching-tdm {
- base switching-capabilities;
- description
- "Time-Division-Multiplex Capable (TDM)";
- }
-
- identity switching-otn {
- base switching-capabilities;
- description
- "OTN-TDM capable";
- }
-
- identity switching-dcsc {
- base switching-capabilities;
- description
- "Data Channel Switching Capable (DCSC)";
- }
-
- identity switching-lsc {
- base switching-capabilities;
- description
- "Lambda-Switch Capable (LSC)";
- }
-
- identity switching-fsc {
- base switching-capabilities;
- description
- "Fiber-Switch Capable (FSC)";
- }
-
- identity lsp-encoding-types {
- description
- "Base identity for encoding types";
- }
-
- identity lsp-encoding-packet {
- base lsp-encoding-types;
- description
- "Packet LSP encoding";
- }
-
- identity lsp-encoding-ethernet {
- base lsp-encoding-types;
- description
- "Ethernet LSP encoding";
- }
-
- identity lsp-encoding-pdh {
- base lsp-encoding-types;
- description
- "ANSI/ETSI LSP encoding";
- }
-
- identity lsp-encoding-sdh {
- base lsp-encoding-types;
- description
- "SDH ITU-T G.707 / SONET ANSI T1.105 LSP encoding";
- }
-
- identity lsp-encoding-digital-wrapper {
- base lsp-encoding-types;
- description
- "Digital Wrapper LSP encoding";
- }
-
- identity lsp-encoding-lambda {
- base lsp-encoding-types;
- description
- "Lambda (photonic) LSP encoding";
- }
-
- identity lsp-encoding-fiber {
- base lsp-encoding-types;
- description
- "Fiber LSP encoding";
- }
-
- identity lsp-encoding-fiber-channel {
- base lsp-encoding-types;
- description
- "FiberChannel LSP encoding";
- }
-
- identity lsp-encoding-oduk {
- base lsp-encoding-types;
- description
- "G.709 ODUk (Digital Path)LSP encoding";
- }
-
- identity lsp-encoding-optical-channel {
- base lsp-encoding-types;
- description
- "Line (e.g., 8B/10B) LSP encoding";
- }
-
- identity lsp-encoding-line {
- base lsp-encoding-types;
- description
- "Line (e.g., 8B/10B) LSP encoding";
- }
-
- identity path-signaling-type {
- description
- "Base identity from which specific path signaling
- types are derived.";
- }
-
- identity path-signaling-rsvpte {
- base tunnel-type;
- description
- "RSVP-TE path signaling type";
- }
-
- identity path-signaling-sr {
- base tunnel-type;
- description
- "Segment-routing path signaling type";
- }
-
- /* TE basic features */
- feature p2mp-te {
- description
- "Indicates support for P2MP-TE";
- }
-
- feature frr-te {
- description
- "Indicates support for TE FastReroute (FRR)";
- }
-
- feature extended-admin-groups {
- description
- "Indicates support for TE link extended admin
- groups.";
- }
-
- feature named-path-affinities {
- description
- "Indicates support for named path affinities";
- }
-
- feature named-extended-admin-groups {
- description
- "Indicates support for named extended admin groups";
- }
-
- feature named-srlg-groups {
- description
- "Indicates support for named SRLG groups";
- }
-
- feature named-path-constraints {
- description
- "Indicates support for named path constraints";
- }
-
- grouping explicit-route-subobject {
- description
- "The explicit route subobject grouping";
- choice type {
- description
- "The explicit route subobject type";
- case ipv4-address {
- description
- "IPv4 address explicit route subobject";
- leaf v4-address {
- type inet:ipv4-address;
- description
- "An IPv4 address. This address is
- treated as a prefix based on the
- prefix length value below. Bits beyond
- the prefix are ignored on receipt and
- SHOULD be set to zero on transmission.";
- }
- leaf v4-prefix-length {
- type uint8;
- description
- "Length in bits of the IPv4 prefix";
- }
- leaf v4-loose {
- type boolean;
- description
- "Describes whether the object is loose
- if set, or otherwise strict";
- }
- }
- case ipv6-address {
- description
- "IPv6 address Explicit Route Object";
- leaf v6-address {
- type inet:ipv6-address;
- description
- "An IPv6 address. This address is
- treated as a prefix based on the
- prefix length value below. Bits
- beyond the prefix are ignored on
- receipt and SHOULD be set to zero
- on transmission.";
- }
- leaf v6-prefix-length {
- type uint8;
- description
- "Length in bits of the IPv4 prefix";
- }
- leaf v6-loose {
- type boolean;
- description
- "Describes whether the object is loose
- if set, or otherwise strict";
- }
- }
- case as-number {
- leaf as-number {
- type uint16;
- description "AS number";
- }
- description
- "Autonomous System explicit route subobject";
- }
- case unnumbered-link {
- leaf router-id {
- type inet:ip-address;
- description
- "A router-id address";
- }
- leaf interface-id {
- type uint32;
- description "The interface identifier";
- }
- description
- "Unnumbered link explicit route subobject";
- reference
- "RFC3477: Signalling Unnumbered Links in
- RSVP-TE";
- }
- case label {
- leaf value {
- type uint32;
- description "the label value";
- }
- description
- "The Label ERO subobject";
- }
- /* AS domain sequence..? */
- }
- }
-
- grouping record-route-subobject {
- description
- "The record route subobject grouping";
- choice type {
- description
- "The record route subobject type";
- case ipv4-address {
- leaf v4-address {
- type inet:ipv4-address;
- description
- "An IPv4 address. This address is
- treated as a prefix based on the prefix
- length value below. Bits beyond the
- prefix are ignored on receipt and
- SHOULD be set to zero on transmission.";
- }
- leaf v4-prefix-length {
- type uint8;
- description
- "Length in bits of the IPv4 prefix";
- }
- leaf v4-flags {
- type uint8;
- description
- "IPv4 address sub-object flags";
- reference "RFC3209";
- }
- }
- case ipv6-address {
- leaf v6-address {
- type inet:ipv6-address;
- description
- "An IPv6 address. This address is
- treated as a prefix based on the
- prefix length value below. Bits
- beyond the prefix are ignored on
- receipt and SHOULD be set to zero
- on transmission.";
- }
- leaf v6-prefix-length {
- type uint8;
- description
- "Length in bits of the IPv4 prefix";
- }
- leaf v6-flags {
- type uint8;
- description
- "IPv6 address sub-object flags";
- reference "RFC3209";
- }
- }
- case unnumbered-link {
- leaf router-id {
- type inet:ip-address;
- description
- "A router-id address";
- }
- leaf interface-id {
- type uint32;
- description "The interface identifier";
- }
- description
- "Unnumbered link record route subobject";
- reference
- "RFC3477: Signalling Unnumbered Links in
- RSVP-TE";
- }
- case label {
- leaf value {
- type uint32;
- description "the label value";
- }
- leaf flags {
- type uint8;
- description
- "Label sub-object flags";
- reference "RFC3209";
- }
- description
- "The Label ERO subobject";
- }
- }
- }
-
- identity route-usage-type {
- description
- "Base identity for route usage";
- }
-
- identity route-include-ero {
- base route-usage-type;
- description
- "Include ERO from route";
- }
-
- identity route-exclude-ero {
- base route-usage-type;
- description
- "Exclude ERO from route";
- }
-
- identity route-exclude-srlg {
- base route-usage-type;
- description
- "Exclude SRLG from route";
- }
-
- identity path-metric-type {
- description
- "Base identity for path metric type";
- }
-
- identity path-metric-te {
- base path-metric-type;
- description
- "TE path metric";
- }
-
- identity path-metric-igp {
- base path-metric-type;
- description
- "IGP path metric";
- }
-
- identity path-tiebreaker-type {
- description
- "Base identity for path tie-breaker type";
- }
-
- identity path-tiebreaker-minfill {
- base path-tiebreaker-type;
- description
- "Min-Fill LSP path placement";
- }
-
- identity path-tiebreaker-maxfill {
- base path-tiebreaker-type;
- description
- "Max-Fill LSP path placement";
- }
-
- identity path-tiebreaker-randoom {
- base path-tiebreaker-type;
- description
- "Random LSP path placement";
- }
-
- identity bidir-provisioning-mode {
- description
- "Base identity for bidirectional provisioning
- mode.";
- }
-
- identity bidir-provisioning-single-sided {
- base bidir-provisioning-mode;
- description
- "Single-sided bidirectional provioning mode";
- }
-
- identity bidir-provisioning-double-sided {
- base bidir-provisioning-mode;
- description
- "Double-sided bidirectional provioning mode";
- }
-
- identity bidir-association-type {
- description
- "Base identity for bidirectional association type";
- }
-
- identity bidir-assoc-corouted {
- base bidir-association-type;
- description
- "Co-routed bidirectional association type";
- }
-
- identity bidir-assoc-non-corouted {
- base bidir-association-type;
- description
- "Non co-routed bidirectional association type";
- }
-
- identity resource-affinities-type {
- description
- "Base identity for resource affinities";
- }
-
- identity resource-aff-include-all {
- base resource-affinities-type;
- description
- "The set of attribute filters associated with a
- tunnel all of which must be present for a link
- to be acceptable";
- }
-
- identity resource-aff-include-any {
- base resource-affinities-type;
- description
- "The set of attribute filters associated with a
- tunnel any of which must be present for a link
- to be acceptable";
- }
-
- identity resource-aff-exclude-any {
- base resource-affinities-type;
- description
- "The set of attribute filters associated with a
- tunnel any of which renders a link unacceptable";
- }
-
- identity te-optimization-criterion {
- description
- "Base identity for TE optimization criterion.";
- reference
- "RFC3272: Overview and Principles of Internet Traffic
- Engineering.";
- }
-
- identity not-optimized {
- base te-optimization-criterion;
- description "Optimization is not applied.";
- }
-
- identity cost {
- base te-optimization-criterion;
- description "Optimized on cost.";
- }
-
- identity delay {
- base te-optimization-criterion;
- description "Optimized on delay.";
- }
-
- /*
- * Typedefs
- */
- typedef performance-metric-normality {
- type enumeration {
- enum "unknown" {
- value 0;
- description
- "Unknown.";
- }
- enum "normal" {
- value 1;
- description
- "Normal.";
- }
- enum "abnormal" {
- value 2;
- description
- "Abnormal. The anomalous bit is set.";
- }
- }
- description
- "Indicates whether a performance metric is normal, abnormal, or
- unknown.";
- reference
- "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.
- RFC7810: IS-IS Traffic Engineering (TE) Metric Extensions.
- RFC7823: Performance-Based Path Selection for Explicitly
- Routed Label Switched Paths (LSPs) Using TE Metric
- Extensions";
- }
-
- typedef te-admin-status {
- type enumeration {
- enum up {
- description
- "Enabled.";
- }
- enum down {
- description
- "Disabled.";
- }
- enum testing {
- description
- "In some test mode.";
- }
- enum preparing-maintenance {
- description
- "Resource is disabled in the control plane to prepare for
- graceful shutdown for maintenance purposes.";
- reference
- "RFC5817: Graceful Shutdown in MPLS and Generalized MPLS
- Traffic Engineering Networks";
- }
- enum maintenance {
- description
- "Resource is disabled in the data plane for maintenance
- purposes.";
- }
- }
- description
- "Defines a type representing the administrative status of
- a TE resource.";
- }
-
- typedef te-global-id {
- type uint32;
- description
- "An identifier to uniquely identify an operator, which can be
- either a provider or a client.
- The definition of this type is taken from RFC6370 and RFC5003.
- This attribute type is used solely to provide a globally
- unique context for TE topologies.";
- }
-
- typedef te-link-access-type {
- type enumeration {
- enum point-to-point {
- description
- "The link is point-to-point.";
- }
- enum multi-access {
- description
- "The link is multi-access, including broacast and NBMA.";
- }
- }
- description
- "Defines a type representing the access type of a TE link.";
- reference
- "RFC3630: Traffic Engineering (TE) Extensions to OSPF
- Version 2.";
- }
-
- typedef te-node-id {
- type yang:dotted-quad;
- description
- "An identifier for a node in a topology.
- The identifier is represented as 32-bit unsigned integer in
- the dotted-quad notation.
- This attribute is mapped to Router ID in
- RFC3630, RFC5329, RFC5305, and RFC6119.";
- }
-
- typedef te-oper-status {
- type enumeration {
- enum up {
- description
- "Operational up.";
- }
- enum down {
- description
- "Operational down.";
- }
- enum testing {
- description
- "In some test mode.";
- }
- enum unknown {
- description
- "Status cannot be determined for some reason.";
- }
- enum preparing-maintenance {
- description
- "Resource is disabled in the control plane to prepare for
- graceful shutdown for maintenance purposes.";
- reference
- "RFC5817: Graceful Shutdown in MPLS and Generalized MPLS
- Traffic Engineering Networks";
- }
- enum maintenance {
- description
- "Resource is disabled in the data plane for maintenance
- purposes.";
- }
- }
- description
- "Defines a type representing the operational status of
- a TE resource.";
- }
-
- typedef te-recovery-status {
- type enumeration {
- enum normal {
- description
- "Both the recovery and working spans are fully
- allocated and active, data traffic is being
- transported over (or selected from) the working
- span, and no trigger events are reported.";
- }
- enum recovery-started {
- description
- "The recovery action has been started, but not completed.";
- }
- enum recovery-succeeded {
- description
- "The recovery action has succeeded. The working span has
- reported a failure/degrade condition and the user traffic
- is being transported (or selected) on the recovery span.";
- }
- enum recovery-failed {
- description
- "The recovery action has failed.";
- }
- enum reversion-started {
- description
- "The reversion has started.";
- }
- enum reversion-failed {
- description
- "The reversion has failed.";
- }
- enum recovery-unavailable {
- description
- "The recovery is unavailable -- either as a result of an
- operator Lockout command or a failure condition detected
- on the recovery span.";
- }
- enum recovery-admin {
- description
- "The operator has issued a command switching the user
- traffic to the recovery span.";
- }
- enum wait-to-restore {
- description
- "The recovery domain is recovering from a failuer/degrade
- condition on the working span that is being controlled by
- the Wait-to-Restore (WTR) timer.";
- }
- }
- description
- "Defines the status of a recovery action.";
- reference
- "RFC4427: Recovery (Protection and Restoration) Terminology
- for Generalized Multi-Protocol Label Switching (GMPLS).
- RFC6378: MPLS Transport Profile (MPLS-TP) Linear Protection";
- }
-
- typedef te-template-name {
- type string {
- pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
- }
- description
- "A type for the name of a TE node template or TE link
- template.";
- }
-
- typedef te-topology-event-type {
- type enumeration {
- enum "add" {
- value 0;
- description
- "A TE node or te-link has been added.";
- }
- enum "remove" {
- value 1;
- description
- "A TE node or te-link has been removed.";
- }
- enum "update" {
- value 2;
- description
- "A TE node or te-link has been updated.";
- }
- }
- description "TE Event type for notifications";
- } // te-topology-event-type
-
-
- typedef te-tunnel-event-type {
- type enumeration {
- enum "add" {
- value 0;
- description
- "A TE tunnel has been added.";
- }
- enum "remove" {
- value 1;
- description
- "A TE tunnel has been removed.";
- }
- enum "update" {
- value 2;
- description
- "A TE tunnel has been updated.";
- }
- }
- description "TE Event type for notifications";
- } // te-tunnel-event-type
-
- typedef te-topology-id {
- type string {
- pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
- }
- description
- "An identifier for a topology.";
- }
-
- typedef te-tp-id {
- type union {
- type uint32; // Unnumbered
- type inet:ip-address; // IPv4 or IPv6 address
- }
- description
- "An identifier for a TE link endpoint on a node.
- This attribute is mapped to local or remote link identifier in
- RFC3630 and RFC5305.";
- }
-
- typedef generalized-label {
- type binary;
- description
- "Generalized label. Nodes sending and receiving the
- Generalized Label know what kinds of link they are
- using, the Generalized Label does not identify its
- type. Instead, nodes are expected to know from the
- context what type of label to expect.";
- reference "rfc3471: section 3.2";
- }
-
- typedef admin-group {
- type binary {
- length 32;
- }
- description
- "Administrative group/Resource class/Color.";
- }
-
- typedef extended-admin-group {
- type binary;
- description
- "Extended administrative group/Resource class/Color.";
- }
-
- typedef admin-groups {
- type union {
- type admin-group;
- type extended-admin-group;
- }
- description "TE administrative group derived type";
- }
-
- typedef srlg {
- type uint32;
- description "SRLG type";
- }
-
- identity path-computation-srlg-type {
- description
- "Base identity for SRLG path computation";
- }
-
- identity srlg-ignore {
- base path-computation-srlg-type;
- description
- "Ignores SRLGs in path computation";
- }
-
- identity srlg-strict {
- base path-computation-srlg-type;
- description
- "Include strict SRLG check in path computation";
- }
-
- identity srlg-preferred {
- base path-computation-srlg-type;
- description
- "Include preferred SRLG check in path computation";
- }
-
- identity srlg-weighted {
- base path-computation-srlg-type;
- description
- "Include weighted SRLG check in path computation";
- }
-
- typedef te-metric {
- type uint32;
- description
- "TE link metric";
- }
-
- /**
- * TE tunnel generic groupings
- **/
-
- /* Tunnel path selection parameters */
- grouping tunnel-path-selection {
- description
- "Tunnel path selection properties grouping";
- container path-selection {
- description
- "Tunnel path selection properties container";
- leaf topology-id {
- type te-types:te-topology-id;
- description
- "The tunnel path is computed using the specific
- topology identified by this identifier";
- }
- leaf cost-limit {
- type uint32 {
- range "1..4294967295";
- }
- description
- "The tunnel path cost limit.";
- }
- leaf hop-limit {
- type uint8 {
- range "1..255";
- }
- description
- "The tunnel path hop limit.";
- }
- leaf metric-type {
- type identityref {
- base path-metric-type;
- }
- default path-metric-te;
- description
- "The tunnel path metric type.";
- }
- leaf tiebreaker-type {
- type identityref {
- base path-tiebreaker-type;
- }
- default path-tiebreaker-maxfill;
- description
- "The tunnel path computation tie breakers.";
- }
- leaf ignore-overload {
- type boolean;
- description
- "The tunnel path can traverse overloaded node.";
- }
- uses tunnel-path-affinities;
- uses tunnel-path-srlgs;
- }
- }
-
- grouping tunnel-path-affinities {
- description
- "Path affinities grouping";
- container tunnel-path-affinities {
- if-feature named-path-affinities;
- description
- "Path affinities container";
- choice style {
- description
- "Path affinities representation style";
- case values {
- leaf value {
- type uint32 {
- range "0..4294967295";
- }
- description
- "Affinity value";
- }
- leaf mask {
- type uint32 {
- range "0..4294967295";
- }
- description
- "Affinity mask";
- }
- }
- case named {
- list constraints {
- key "usage";
- leaf usage {
- type identityref {
- base resource-affinities-type;
- }
- description "Affinities usage";
- }
- container constraint {
- description
- "Container for named affinities";
- list affinity-names {
- key "name";
- leaf name {
- type string;
- description
- "Affinity name";
- }
- description
- "List of named affinities";
- }
- }
- description
- "List of named affinity constraints";
- }
- }
- }
- }
- }
-
- grouping tunnel-path-srlgs {
- description
- "Path SRLG properties grouping";
- container tunnel-path-srlgs {
- description
- "Path SRLG properties container";
- choice style {
- description
- "Type of SRLG representation";
- case values {
- leaf usage {
- type identityref {
- base route-exclude-srlg;
- }
- description "SRLG usage";
- }
- leaf-list values {
- type te-types:srlg;
- description "SRLG value";
- }
- }
- case named {
- list constraints {
- key "usage";
- leaf usage {
- type identityref {
- base route-exclude-srlg;
- }
- description "SRLG usage";
- }
- container constraint {
- description
- "Container for named SRLG list";
- list srlg-names {
- key "name";
- leaf name {
- type string;
- description
- "The SRLG name";
- }
- description
- "List named SRLGs";
- }
- }
- description
- "List of named SRLG constraints";
- }
- }
- }
- }
- }
-
- grouping tunnel-bidir-assoc-properties {
- description
- "TE tunnel associated bidirectional properties
- grouping";
- container bidirectional {
- description
- "TE tunnel associated bidirectional attributes.";
- container association {
- description
- "Tunnel bidirectional association properties";
- leaf id {
- type uint16;
- description
- "The TE tunnel association identifier.";
- }
- leaf source {
- type inet:ip-address;
- description
- "The TE tunnel association source.";
- }
- leaf global-source {
- type inet:ip-address;
- description
- "The TE tunnel association global
- source.";
- }
- leaf type {
- type identityref {
- base bidir-association-type;
- }
- default bidir-assoc-non-corouted;
- description
- "The TE tunnel association type.";
- }
- leaf provisioing {
- type identityref {
- base bidir-provisioning-mode;
- }
- description
- "Describes the provisioning model of the
- associated bidirectional LSP";
- reference
- "draft-ietf-teas-mpls-tp-rsvpte-ext-
- associated-lsp, section-3.2";
- }
- }
- }
- }
- /*** End of TE tunnel groupings ***/
-
- /**
- * TE interface generic groupings
- **/
-}
diff --git a/apps/tenbi/yangmodel/src/main/yang/ietf-te.yang b/apps/tenbi/yangmodel/src/main/yang/ietf-te.yang
deleted file mode 100644
index 40374fe..0000000
--- a/apps/tenbi/yangmodel/src/main/yang/ietf-te.yang
+++ /dev/null
@@ -1,882 +0,0 @@
-module ietf-te {
-
- namespace "urn:ietf:params:xml:ns:yang:ietf-te";
-
- /* Replace with IANA when assigned */
- prefix "te";
-
- /* Import TE generic types */
- import ietf-te-types {
- prefix te-types;
- }
-
- import ietf-inet-types {
- prefix inet;
- }
-
- organization
- "IETF Traffic Engineering Architecture and Signaling (TEAS)
- Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/teas/>
- WG List: <mailto:teas@ietf.org>
-
- WG Chair: Lou Berger
- <mailto:lberger@labn.net>
-
- WG Chair: Vishnu Pavan Beeram
- <mailto:vbeeram@juniper.net>
-
- Editor: Tarek Saad
- <mailto:tsaad@cisco.com>
-
- Editor: Rakesh Gandhi
- <mailto:rgandhi@cisco.com>
-
- Editor: Vishnu Pavan Beeram
- <mailto:vbeeram@juniper.net>
-
- Editor: Himanshu Shah
- <mailto:hshah@ciena.com>
-
- Editor: Xufeng Liu
- <mailto:xufeng.liu@ericsson.com>
-
- Editor: Xia Chen
- <mailto:jescia.chenxia@huawei.com>
-
- Editor: Raqib Jones
- <mailto:raqib@Brocade.com>
-
- Editor: Bin Wen
- <mailto:Bin_Wen@cable.comcast.com>";
-
- description
- "YANG data module for TE configuration,
- state, RPC and notifications.";
-
- revision "2016-07-05" {
- description "Latest update to TE generic YANG module.";
- reference "TBD";
- }
-
- typedef tunnel-ref {
- type leafref {
- path "/te:te/te:tunnels/te:tunnel/te:name";
- }
- description
- "This type is used by data models that need to reference
- configured TE tunnel.";
- }
-
- /**
- * TE tunnel generic groupings
- */
-
- grouping p2p-secondary-path-params {
- description
- "tunnel path properties.";
- container config {
- description
- "Configuration parameters relating to
- tunnel properties";
- uses path-properties_config;
- uses path-params_config;
- }
- container state {
- config false;
- description
- "State information associated with tunnel
- properties";
- uses path-properties_config;
- uses path-params_config;
- uses p2p-secondary-path-params_state;
- }
- }
-
- grouping p2p-primary-path-params {
- description
- "TE tunnel primary path properties grouping";
- container config {
- description
- "Configuration parameters relating to
- tunnel properties";
- uses path-properties_config;
- uses path-params_config;
- }
- container state {
- config false;
- description
- "State information associated with tunnel
- properties";
- uses path-params_config;
- uses p2p-primary-path-params_state;
- }
- }
-
- grouping p2p-primary-path-params_state {
- description "TE primary path state parameters";
- list lsp {
- key
- "source destination tunnel-id lsp-id "+
- "extended-tunnel-id type";
- description "List of LSPs associated with the tunnel.";
-
- leaf source {
- type leafref {
- path "../../../../../../lsps-state/lsp/source";
- }
- description
- "Tunnel sender address extracted from
- SENDER_TEMPLATE object";
- reference "RFC3209";
- }
- leaf destination {
- type leafref {
- path "../../../../../../lsps-state/lsp/destination";
- }
- description
- "Tunnel endpoint address extracted from
- SESSION object";
- reference "RFC3209";
- }
- leaf tunnel-id {
- type leafref {
- path "../../../../../../lsps-state/lsp/tunnel-id";
- }
- description
- "Tunnel identifier used in the SESSION
- that remains constant over the life
- of the tunnel.";
- reference "RFC3209";
- }
- leaf lsp-id {
- type leafref {
- path "../../../../../../lsps-state/lsp/lsp-id";
- }
- description
- "Identifier used in the SENDER_TEMPLATE
- and the FILTER_SPEC that can be changed
- to allow a sender to share resources with
- itself.";
- reference "RFC3209";
- }
- leaf extended-tunnel-id {
- type leafref {
- path "../../../../../../lsps-state/lsp/extended-tunnel-id";
- }
- description
- "Extended Tunnel ID of the LSP.";
- reference "RFC3209";
- }
- leaf type {
- type leafref {
- path "../../../../../../lsps-state/lsp/type";
- }
- description "LSP type P2P or P2MP";
- }
- }
- }
-
- grouping p2p-secondary-path-params_state {
- description "TE secondary path state parameters";
- list lsp {
- key "source";
- description "List of LSPs associated with the tunnel.";
-
- leaf source {
- type leafref {
- path "../../../../../../../lsps-state/lsp/source";
- }
- description
- "Tunnel sender address extracted from
- SENDER_TEMPLATE object";
- reference "RFC3209";
- }
- leaf destination {
- type leafref {
- path "../../../../../../../lsps-state/lsp/destination";
- }
- description
- "Tunnel endpoint address extracted from
- SESSION object";
- reference "RFC3209";
- }
- leaf tunnel-id {
- type leafref {
- path "../../../../../../../lsps-state/lsp/tunnel-id";
- }
- description
- "Tunnel identifier used in the SESSION
- that remains constant over the life
- of the tunnel.";
- reference "RFC3209";
- }
- leaf lsp-id {
- type leafref {
- path "../../../../../../../lsps-state/lsp/lsp-id";
- }
- description
- "Identifier used in the SENDER_TEMPLATE
- and the FILTER_SPEC that can be changed
- to allow a sender to share resources with
- itself.";
- reference "RFC3209";
- }
- leaf extended-tunnel-id {
- type leafref {
- path "../../../../../../../lsps-state/lsp/extended-tunnel-id";
- }
- description
- "Extended Tunnel ID of the LSP.";
- reference "RFC3209";
- }
- leaf type {
- type leafref {
- path "../../../../../../../lsps-state/lsp/type";
- }
- description "LSP type P2P or P2MP";
- }
- }
- }
-
- grouping path-params_config {
- description
- "TE tunnel path parameters configuration grouping";
- leaf path-named-constraint {
- if-feature te-types:named-path-constraints;
- type string;
- description
- "Reference to a globally defined named path
- constraint set";
- }
- uses te-types:tunnel-path-selection;
- choice type {
- description
- "Describes the path type";
- case dynamic {
- leaf dynamic {
- type empty;
- description
- "A CSPF dynamically computed path";
- }
- }
- case explicit {
- leaf explicit-path-name {
- type string;
- description
- "The explicit-path name";
- }
-
- list explicit-route-objects {
- key "index";
- description
- "List of explicit route objects";
- leaf index {
- type uint8 {
- range "0..255";
- }
- description
- "Index of this explicit route object";
- }
- leaf explicit-route-usage {
- type identityref {
- base te-types:route-usage-type;
- }
- description "An explicit-route hop action.";
- }
- uses te-types:explicit-route-subobject;
- }
- }
- }
- leaf no-cspf {
- type empty;
- description
- "Indicates no CSPF is to be attempted on this
- path.";
- }
- leaf lockdown {
- type empty;
- description
- "Indicates no reoptimization to be attempted for
- this path.";
- }
- }
-
- /* TE tunnel configuration data */
- grouping tunnel-params_config {
- description
- "Configuration parameters relating to TE tunnel";
- leaf name {
- type string;
- description "TE tunnel name.";
- }
- leaf type {
- type identityref {
- base te-types:tunnel-type;
- }
- description "TE tunnel type.";
- }
- leaf identifier {
- type uint16;
- description
- "TE tunnel Identifier.";
- }
- leaf description {
- type string;
- description
- "Textual description for this TE tunnel";
- }
- leaf lsp-priority-setup {
- type uint8 {
- range "0..7";
- }
- description
- "TE LSP setup priority";
- }
- leaf lsp-priority-hold {
- type uint8 {
- range "0..7";
- }
- description
- "TE LSP hold priority";
- }
- leaf lsp-protection-type {
- type identityref {
- base te-types:lsp-prot-type;
- }
- description "LSP protection type.";
- }
- leaf admin-status {
- type identityref {
- base te-types:state-type;
- }
- default te-types:state-up;
- description "TE tunnel administrative state.";
- }
- leaf source {
- type inet:ip-address;
- description
- "TE tunnel source address.";
- }
- leaf destination {
- /* Add when check */
- type inet:ip-address;
- description
- "P2P tunnel destination address";
- }
- leaf src-tp-id {
- type binary;
- description
- "TE tunnel source termination point identifier.";
- }
- leaf dst-tp-id {
- /* Add when check */
- type binary;
- description
- "TE tunnel destination termination point identifier.";
- }
- container hierarchical-link-id {
- description
- "Identifies a hierarchical link (in server layer)
- that this tunnel is associated with.";
- leaf local-te-node-id {
- type te-types:te-node-id;
- description
- "Local TE node identifier";
- }
- leaf local-te-link-tp-id {
- type te-types:te-tp-id;
- description
- "Local TE link termination point identifier";
- }
- leaf remote-te-node-id {
- type te-types:te-node-id;
- description
- "Remote TE node identifier";
- }
- leaf te-topology-id {
- type te-types:te-topology-id;
- description
- "It is presumed that a datastore will contain many
- topologies. To distinguish between topologies it is
- vital to have UNIQUE topology identifiers.";
- }
- }
- uses te-types:tunnel-bidir-assoc-properties;
- }
-
- grouping tunnel-params_state {
- description
- "State parameters relating to TE tunnel";
- leaf oper-status {
- type identityref {
- base te-types:state-type;
- }
- description "TE tunnel operational state.";
- }
- }
-
- grouping path-properties_config {
- description "TE path properties grouping";
- leaf name {
- type string;
- description "TE path name";
- }
- leaf preference {
- type uint8 {
- range "1..255";
- }
- description
- "Specifies a preference for this path. The lower the
- number higher the preference";
- }
- }
-
- /* TE tunnel configuration/state grouping */
- grouping tunnel-properties {
- description
- "Top level grouping for tunnel properties.";
- container config {
- description
- "Configuration parameters relating to
- tunnel properties";
- uses tunnel-params_config;
- }
- container state {
- config false;
- description
- "State information associated with tunnel
- properties";
- uses tunnel-params_config;
- uses tunnel-params_state;
- }
- list primary-paths {
- key "name";
- description
- "List of primary paths for this tunnel.";
- leaf name {
- type leafref {
- path "../config/name";
- }
- description "TE path name";
- }
- leaf preference {
- type leafref {
- path "../config/preference";
- }
- description
- "Specifies a preference for this path. The lower the
- number higher the preference";
- }
- uses p2p-primary-path-params;
- list secondary-paths {
- key "name";
- description
- "List of secondary paths for this tunnel.";
- leaf name {
- type leafref {
- path "../config/name";
- }
- description "TE path name";
- }
- leaf preference {
- type leafref {
- path "../config/preference";
- }
- description
- "Specifies a preference for this path. The lower the
- number higher the preference";
- }
- uses p2p-secondary-path-params;
- }
- }
- }
- /*** End of TE tunnel groupings ***/
-
- /**
- * LSP related generic groupings
- */
- grouping lsp-record-route-information_state {
- description "recorded route information grouping";
- container lsp-record-route {
- description "RSVP recorded route object information";
- list record-route-subobjects {
- when "../origin-type != 'ingress'" {
- description "Applicable on non-ingress LSPs only";
- }
- key "subobject-index";
- description "";
- leaf subobject-index {
- type uint32;
- description "RRO subobject index";
- }
- uses te-types:record-route-subobject;
- }
- }
- }
-
- grouping lsp-properties_state {
- description
- "State parameters relating to LSP";
- leaf oper-status {
- type identityref {
- base te-types:state-type;
- }
- description "LSP operational state.";
- }
-
- leaf origin-type {
- type enumeration {
- enum ingress {
- description
- "Origin ingress";
- }
- enum egress {
- description
- "Origin egress";
- }
- enum transit {
- description
- "transit";
- }
- }
- description
- "Origin type of LSP relative to the location
- of the local switch in the path.";
- }
-
- leaf lsp-resource-status {
- type enumeration {
- enum primary {
- description
- "A primary LSP is a fully established LSP for
- which the resource allocation has been committed
- at the data plane";
- }
- enum secondary {
- description
- "A secondary LSP is an LSP that has been provisioned
- in the control plane only; e.g. resource allocation
- has not been committed at the data plane";
- }
- }
- description "LSP resource allocation type";
- reference "rfc4872, section 4.2.1";
- }
-
- leaf lsp-protection-role {
- type enumeration {
- enum working {
- description
- "A working LSP must be a primary LSP whilst a protecting
- LSP can be either a primary or a secondary LSP. Also,
- known as protected LSPs when working LSPs are associated
- with protecting LSPs.";
- }
- enum protecting {
- description
- "A secondary LSP is an LSP that has been provisioned
- in the control plane only; e.g. resource allocation
- has not been committed at the data plane";
- }
- }
- description "LSP role type";
- reference "rfc4872, section 4.2.1";
- }
-
- leaf lsp-operational-status {
- type empty;
- description
- "This bit is set when a protecting LSP is carrying the normal
- traffic after protection switching";
- }
- }
- /*** End of TE LSP groupings ***/
-
- /**
- * TE global generic groupings
- */
-
- /* Global named admin-groups configuration data */
- grouping named-admin-groups_config {
- description
- "Global named administrative groups configuration
- grouping";
- list named-admin-groups {
- if-feature te-types:extended-admin-groups;
- if-feature te-types:named-extended-admin-groups;
- key "name";
- description
- "List of named TE admin-groups";
- leaf name {
- type string;
- description
- "A string name that uniquely identifies a TE
- interface named admin-group";
- }
- leaf bit-position {
- type uint32;
- description
- "Bit position representing the administrative group";
- }
- }
- }
-
- /* Global named admin-srlgs configuration data */
- grouping named-srlgs_config {
- description
- "Global named SRLGs configuration
- grouping";
- list named-srlgs {
- if-feature te-types:named-srlg-groups;
- key "name";
- description
- "A list of named SRLG groups";
- leaf name {
- type string;
- description
- "A string name that uniquely identifies a TE
- interface named srlg";
- }
- leaf group {
- type te-types:srlg;
- description "An SRLG value";
- }
- }
- }
-
- /* Global named explicit-paths configuration data */
- grouping named-explicit-paths_config {
- description
- "Global explicit path configuration
- grouping";
- list named-explicit-paths {
- key "name";
- description
- "A list of explicit paths";
- leaf name {
- type string;
- description
- "A string name that uniquely identifies an
- explicit path";
- }
- list explicit-route-objects {
- key "index";
- description
- "List of explicit route objects";
- leaf index {
- type uint8 {
- range "0..255";
- }
- description
- "Index of this explicit route object";
- }
- leaf explicit-route-usage {
- type identityref {
- base te-types:route-usage-type;
- }
- description "An explicit-route hop action.";
- }
- uses te-types:explicit-route-subobject;
- }
- }
- }
-
- /* Global named paths constraints configuration data */
- grouping named-path-constraints_config {
- description
- "Global named path constraints configuration
- grouping";
- list named-constraints {
- if-feature te-types:named-path-constraints;
- key "name";
- description
- "A list of named path constraints";
- leaf name {
- type string;
- description
- "A string name that uniquely identifies a
- path constraint set";
- }
- uses te-types:tunnel-path-selection;
- }
- }
-
- /* TE globals container data */
- grouping globals-grouping {
- description
- "Globals TE system-wide configuration data grouping";
- container globals {
- description
- "Globals TE system-wide configuration data container";
- container config {
- description
- "Configuration parameters for system-wide
- parameters";
- uses named-admin-groups_config;
- uses named-srlgs_config;
- uses named-explicit-paths_config;
- uses named-path-constraints_config;
- }
- container state {
- config false;
- description
- "State for system-wide parameters";
- uses named-admin-groups_config;
- uses named-srlgs_config;
- uses named-explicit-paths_config;
- uses named-path-constraints_config;
- }
- }
- }
-
- /* TE tunnels container data */
- grouping tunnels-grouping {
- description
- "Tunnels TE configuration data grouping";
- container tunnels {
- description
- "Tunnels TE configuration data container";
-
- list tunnel {
- key "name type";
- unique "identifier";
- description "TE tunnel.";
- leaf name {
- type leafref {
- path "../config/name";
- }
- description "TE tunnel name.";
- }
- leaf type {
- type leafref {
- path "../config/type";
- }
- description "TE tunnel type.";
- }
- leaf identifier {
- type leafref {
- path "../config/identifier";
- }
- description
- "TE tunnel Identifier.";
- }
- uses tunnel-properties;
- }
- }
- }
-
- /* TE LSPs ephemeral state container data */
- grouping lsps-state-grouping {
- description
- "LSPs state operational data grouping";
- container lsps-state {
- config "false";
- description "LSPs operational state data.";
-
- list lsp {
- key
- "source destination tunnel-id lsp-id "+
- "extended-tunnel-id type";
- description
- "List of LSPs associated with the tunnel.";
- leaf source {
- type inet:ip-address;
- description
- "Tunnel sender address extracted from
- SENDER_TEMPLATE object";
- reference "RFC3209";
- }
- leaf destination {
- type inet:ip-address;
- description
- "Tunnel endpoint address extracted from
- SESSION object";
- reference "RFC3209";
- }
- leaf tunnel-id {
- type uint16;
- description
- "Tunnel identifier used in the SESSION
- that remains constant over the life
- of the tunnel.";
- reference "RFC3209";
- }
- leaf lsp-id {
- type uint16;
- description
- "Identifier used in the SENDER_TEMPLATE
- and the FILTER_SPEC that can be changed
- to allow a sender to share resources with
- itself.";
- reference "RFC3209";
- }
- leaf extended-tunnel-id {
- type inet:ip-address;
- description
- "Extended Tunnel ID of the LSP.";
- reference "RFC3209";
- }
- leaf type {
- type identityref {
- base te-types:tunnel-type;
- }
- description "The LSP type P2P or P2MP";
- }
- uses lsp-properties_state;
- uses lsp-record-route-information_state;
- }
- }
- }
- /*** End of TE global groupings ***/
-
- /**
- * TE configurations container
- */
- container te {
- presence "Enable TE feature.";
- description
- "TE global container.";
-
- /* TE Global Configuration Data */
- uses globals-grouping;
-
- /* TE Tunnel Configuration Data */
- uses tunnels-grouping;
-
- /* TE LSPs State Data */
- uses lsps-state-grouping;
- }
-
- /* TE Global RPCs/execution Data */
- rpc globals-rpc {
- description
- "Execution data for TE global.";
- }
-
- /* TE interfaces RPCs/execution Data */
- rpc interfaces-rpc {
- description
- "Execution data for TE interfaces.";
- }
-
- /* TE Tunnel RPCs/execution Data */
- rpc tunnels-rpc {
- description
- "TE tunnels RPC nodes";
- }
-
- /* TE Global Notification Data */
- notification globals-notif {
- description
- "Notification messages for Global TE.";
- }
-
- /* TE Tunnel Notification Data */
- notification tunnels-notif {
- description
- "Notification messages for TE tunnels.";
- }
-}
diff --git a/apps/tenbi/yangmodel/src/main/yang/ietf-yang-types@2013-07-15.yang b/apps/tenbi/yangmodel/src/main/yang/ietf-yang-types@2013-07-15.yang
deleted file mode 100644
index 371a091..0000000
--- a/apps/tenbi/yangmodel/src/main/yang/ietf-yang-types@2013-07-15.yang
+++ /dev/null
@@ -1,480 +0,0 @@
-module ietf-yang-types {
-
- namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types";
- prefix "yang";
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/netmod/>
- WG List: <mailto:netmod@ietf.org>
-
- WG Chair: David Kessens
- <mailto:david.kessens@nsn.com>
-
- WG Chair: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>
-
- Editor: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>";
-
- description
- "This module contains a collection of generally useful derived
- YANG data types.
-
- Copyright (c) 2013 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC 6991; see
- the RFC itself for full legal notices.";
-
- revision 2013-07-15 {
- description
- "This revision adds the following new data types:
- - yang-identifier
- - hex-string
- - uuid
- - dotted-quad";
- reference
- "RFC 6991: Common YANG Data Types";
- }
-
- revision 2010-09-24 {
- description
- "Initial revision.";
- reference
- "RFC 6021: Common YANG Data Types";
- }
-
- /*** collection of counter and gauge types ***/
-
- typedef counter32 {
- type uint32;
- description
- "The counter32 type represents a non-negative integer
- that monotonically increases until it reaches a
- maximum value of 2^32-1 (4294967295 decimal), when it
- wraps around and starts increasing again from zero.
-
- Counters have no defined 'initial' value, and thus, a
- single value of a counter has (in general) no information
- content. Discontinuities in the monotonically increasing
- value normally occur at re-initialization of the
- management system, and at other times as specified in the
- description of a schema node using this type. If such
- other times can occur, for example, the creation of
- a schema node of type counter32 at times other than
- re-initialization, then a corresponding schema node
- should be defined, with an appropriate type, to indicate
- the last discontinuity.
-
- The counter32 type should not be used for configuration
- schema nodes. A default statement SHOULD NOT be used in
- combination with the type counter32.
-
- In the value set and its semantics, this type is equivalent
- to the Counter32 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2
- (SMIv2)";
- }
-
- typedef zero-based-counter32 {
- type yang:counter32;
- default "0";
- description
- "The zero-based-counter32 type represents a counter32
- that has the defined 'initial' value zero.
-
- A schema node of this type will be set to zero (0) on creation
- and will thereafter increase monotonically until it reaches
- a maximum value of 2^32-1 (4294967295 decimal), when it
- wraps around and starts increasing again from zero.
-
- Provided that an application discovers a new schema node
- of this type within the minimum time to wrap, it can use the
- 'initial' value as a delta. It is important for a management
- station to be aware of this minimum time and the actual time
- between polls, and to discard data if the actual time is too
- long or there is no defined minimum time.
-
- In the value set and its semantics, this type is equivalent
- to the ZeroBasedCounter32 textual convention of the SMIv2.";
- reference
- "RFC 4502: Remote Network Monitoring Management Information
- Base Version 2";
- }
-
- typedef counter64 {
- type uint64;
- description
- "The counter64 type represents a non-negative integer
- that monotonically increases until it reaches a
- maximum value of 2^64-1 (18446744073709551615 decimal),
- when it wraps around and starts increasing again from zero.
-
- Counters have no defined 'initial' value, and thus, a
- single value of a counter has (in general) no information
- content. Discontinuities in the monotonically increasing
- value normally occur at re-initialization of the
- management system, and at other times as specified in the
- description of a schema node using this type. If such
- other times can occur, for example, the creation of
- a schema node of type counter64 at times other than
- re-initialization, then a corresponding schema node
- should be defined, with an appropriate type, to indicate
- the last discontinuity.
-
- The counter64 type should not be used for configuration
- schema nodes. A default statement SHOULD NOT be used in
- combination with the type counter64.
-
- In the value set and its semantics, this type is equivalent
- to the Counter64 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2
- (SMIv2)";
- }
-
- typedef zero-based-counter64 {
- type yang:counter64;
- default "0";
- description
- "The zero-based-counter64 type represents a counter64 that
- has the defined 'initial' value zero.
-
-
-
-
- A schema node of this type will be set to zero (0) on creation
- and will thereafter increase monotonically until it reaches
- a maximum value of 2^64-1 (18446744073709551615 decimal),
- when it wraps around and starts increasing again from zero.
-
- Provided that an application discovers a new schema node
- of this type within the minimum time to wrap, it can use the
- 'initial' value as a delta. It is important for a management
- station to be aware of this minimum time and the actual time
- between polls, and to discard data if the actual time is too
- long or there is no defined minimum time.
-
- In the value set and its semantics, this type is equivalent
- to the ZeroBasedCounter64 textual convention of the SMIv2.";
- reference
- "RFC 2856: Textual Conventions for Additional High Capacity
- Data Types";
- }
-
- typedef gauge32 {
- type uint32;
- description
- "The gauge32 type represents a non-negative integer, which
- may increase or decrease, but shall never exceed a maximum
- value, nor fall below a minimum value. The maximum value
- cannot be greater than 2^32-1 (4294967295 decimal), and
- the minimum value cannot be smaller than 0. The value of
- a gauge32 has its maximum value whenever the information
- being modeled is greater than or equal to its maximum
- value, and has its minimum value whenever the information
- being modeled is smaller than or equal to its minimum value.
- If the information being modeled subsequently decreases
- below (increases above) the maximum (minimum) value, the
- gauge32 also decreases (increases).
-
- In the value set and its semantics, this type is equivalent
- to the Gauge32 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2
- (SMIv2)";
- }
-
- typedef gauge64 {
- type uint64;
- description
- "The gauge64 type represents a non-negative integer, which
- may increase or decrease, but shall never exceed a maximum
- value, nor fall below a minimum value. The maximum value
- cannot be greater than 2^64-1 (18446744073709551615), and
- the minimum value cannot be smaller than 0. The value of
- a gauge64 has its maximum value whenever the information
- being modeled is greater than or equal to its maximum
- value, and has its minimum value whenever the information
- being modeled is smaller than or equal to its minimum value.
- If the information being modeled subsequently decreases
- below (increases above) the maximum (minimum) value, the
- gauge64 also decreases (increases).
-
- In the value set and its semantics, this type is equivalent
- to the CounterBasedGauge64 SMIv2 textual convention defined
- in RFC 2856";
- reference
- "RFC 2856: Textual Conventions for Additional High Capacity
- Data Types";
- }
-
- /*** collection of identifier-related types ***/
-
- typedef object-identifier {
- type string {
- pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))'
- + '(\.(0|([1-9]\d*)))*';
- }
- description
- "The object-identifier type represents administratively
- assigned names in a registration-hierarchical-name tree.
-
- Values of this type are denoted as a sequence of numerical
- non-negative sub-identifier values. Each sub-identifier
- value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers
- are separated by single dots and without any intermediate
- whitespace.
-
- The ASN.1 standard restricts the value space of the first
- sub-identifier to 0, 1, or 2. Furthermore, the value space
- of the second sub-identifier is restricted to the range
- 0 to 39 if the first sub-identifier is 0 or 1. Finally,
- the ASN.1 standard requires that an object identifier
- has always at least two sub-identifiers. The pattern
- captures these restrictions.
-
- Although the number of sub-identifiers is not limited,
- module designers should realize that there may be
- implementations that stick with the SMIv2 limit of 128
- sub-identifiers.
-
- This type is a superset of the SMIv2 OBJECT IDENTIFIER type
- since it is not restricted to 128 sub-identifiers. Hence,
- this type SHOULD NOT be used to represent the SMIv2 OBJECT
- IDENTIFIER type; the object-identifier-128 type SHOULD be
- used instead.";
- reference
- "ISO9834-1: Information technology -- Open Systems
- Interconnection -- Procedures for the operation of OSI
- Registration Authorities: General procedures and top
- arcs of the ASN.1 Object Identifier tree";
- }
-
- typedef object-identifier-128 {
- type object-identifier {
- pattern '\d*(\.\d*){1,127}';
- }
- description
- "This type represents object-identifiers restricted to 128
- sub-identifiers.
-
- In the value set and its semantics, this type is equivalent
- to the OBJECT IDENTIFIER type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2
- (SMIv2)";
- }
-
- typedef yang-identifier {
- type string {
- length "1..max";
- pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*';
- pattern '.|..|[^xX].*|.[^mM].*|..[^lL].*';
- }
- description
- "A YANG identifier string as defined by the 'identifier'
- rule in Section 12 of RFC 6020. An identifier must
- start with an alphabetic character or an underscore
- followed by an arbitrary sequence of alphabetic or
- numeric characters, underscores, hyphens, or dots.
-
- A YANG identifier MUST NOT start with any possible
- combination of the lowercase or uppercase character
- sequence 'xml'.";
- reference
- "RFC 6020: YANG - A Data Modeling Language for the Network
- Configuration Protocol (NETCONF)";
- }
-
- /*** collection of types related to date and time***/
-
- typedef date-and-time {
- type string {
- pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?'
- + '(Z|[\+\-]\d{2}:\d{2})';
- }
- description
- "The date-and-time type is a profile of the ISO 8601
- standard for representation of dates and times using the
- Gregorian calendar. The profile is defined by the
- date-time production in Section 5.6 of RFC 3339.
-
- The date-and-time type is compatible with the dateTime XML
- schema type with the following notable exceptions:
-
- (a) The date-and-time type does not allow negative years.
-
- (b) The date-and-time time-offset -00:00 indicates an unknown
- time zone (see RFC 3339) while -00:00 and +00:00 and Z
- all represent the same time zone in dateTime.
-
- (c) The canonical format (see below) of data-and-time values
- differs from the canonical format used by the dateTime XML
- schema type, which requires all times to be in UTC using
- the time-offset 'Z'.
-
- This type is not equivalent to the DateAndTime textual
- convention of the SMIv2 since RFC 3339 uses a different
- separator between full-date and full-time and provides
- higher resolution of time-secfrac.
-
- The canonical format for date-and-time values with a known time
- zone uses a numeric time zone offset that is calculated using
- the device's configured known offset to UTC time. A change of
- the device's offset to UTC time will cause date-and-time values
- to change accordingly. Such changes might happen periodically
- in case a server follows automatically daylight saving time
- (DST) time zone offset changes. The canonical format for
- date-and-time values with an unknown time zone (usually
- referring to the notion of local time) uses the time-offset
- -00:00.";
- reference
- "RFC 3339: Date and Time on the Internet: Timestamps
- RFC 2579: Textual Conventions for SMIv2
- XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
- }
-
- typedef timeticks {
- type uint32;
- description
- "The timeticks type represents a non-negative integer that
- represents the time, modulo 2^32 (4294967296 decimal), in
- hundredths of a second between two epochs. When a schema
- node is defined that uses this type, the description of
- the schema node identifies both of the reference epochs.
-
- In the value set and its semantics, this type is equivalent
- to the TimeTicks type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2
- (SMIv2)";
- }
-
- typedef timestamp {
- type yang:timeticks;
- description
- "The timestamp type represents the value of an associated
- timeticks schema node at which a specific occurrence
- happened. The specific occurrence must be defined in the
- description of any schema node defined using this type. When
- the specific occurrence occurred prior to the last time the
- associated timeticks attribute was zero, then the timestamp
- value is zero. Note that this requires all timestamp values
- to be reset to zero when the value of the associated timeticks
- attribute reaches 497+ days and wraps around to zero.
-
- The associated timeticks schema node must be specified
- in the description of any schema node using this type.
-
- In the value set and its semantics, this type is equivalent
- to the TimeStamp textual convention of the SMIv2.";
- reference
- "RFC 2579: Textual Conventions for SMIv2";
- }
-
- /*** collection of generic address types ***/
-
- typedef phys-address {
- type string {
- pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
- }
-
-
-
-
- description
- "Represents media- or physical-level addresses represented
- as a sequence octets, each octet represented by two hexadecimal
- numbers. Octets are separated by colons. The canonical
- representation uses lowercase characters.
-
- In the value set and its semantics, this type is equivalent
- to the PhysAddress textual convention of the SMIv2.";
- reference
- "RFC 2579: Textual Conventions for SMIv2";
- }
-
- typedef mac-address {
- type string {
- pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
- }
- description
- "The mac-address type represents an IEEE 802 MAC address.
- The canonical representation uses lowercase characters.
-
- In the value set and its semantics, this type is equivalent
- to the MacAddress textual convention of the SMIv2.";
- reference
- "IEEE 802: IEEE Standard for Local and Metropolitan Area
- Networks: Overview and Architecture
- RFC 2579: Textual Conventions for SMIv2";
- }
-
- /*** collection of XML-specific types ***/
-
- typedef xpath1.0 {
- type string;
- description
- "This type represents an XPATH 1.0 expression.
-
- When a schema node is defined that uses this type, the
- description of the schema node MUST specify the XPath
- context in which the XPath expression is evaluated.";
- reference
- "XPATH: XML Path Language (XPath) Version 1.0";
- }
-
- /*** collection of string types ***/
-
- typedef hex-string {
- type string {
- pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
- }
- description
- "A hexadecimal string with octets represented as hex digits
- separated by colons. The canonical representation uses
- lowercase characters.";
- }
-
- typedef uuid {
- type string {
- pattern '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-'
- + '[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
- }
- description
- "A Universally Unique IDentifier in the string representation
- defined in RFC 4122. The canonical representation uses
- lowercase characters.
-
- The following is an example of a UUID in string representation:
- f81d4fae-7dec-11d0-a765-00a0c91e6bf6
- ";
- reference
- "RFC 4122: A Universally Unique IDentifier (UUID) URN
- Namespace";
- }
-
- typedef dotted-quad {
- type string {
- pattern
- '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
- + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
- }
- description
- "An unsigned 32-bit number expressed in the dotted-quad
- notation, i.e., four octets written as decimal numbers
- and separated with the '.' (full stop) character.";
- }
-}
diff --git a/apps/tetopology/BUILD b/apps/tetopology/BUILD
deleted file mode 100644
index 9f16249..0000000
--- a/apps/tetopology/BUILD
+++ /dev/null
@@ -1,13 +0,0 @@
-BUNDLES = [
- "//apps/tetopology/api:onos-apps-tetopology-api",
- "//apps/tetopology/app:onos-apps-tetopology-app",
-]
-
-onos_app(
- app_name = "org.onosproject.tetopology",
- category = "Traffic Engineering",
- description = "Application to create and manage hierarchical TE topologies.",
- included_bundles = BUNDLES,
- title = "TE Topology Core",
- url = "http://onosproject.org",
-)
diff --git a/apps/tetopology/api/BUILD b/apps/tetopology/api/BUILD
deleted file mode 100644
index f72e3bc..0000000
--- a/apps/tetopology/api/BUILD
+++ /dev/null
@@ -1,3 +0,0 @@
-osgi_jar_with_tests(
- deps = CORE_DEPS,
-)
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/CommonTopologyData.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/CommonTopologyData.java
deleted file mode 100644
index 9c32895..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/CommonTopologyData.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import org.onosproject.net.DeviceId;
-
-import java.util.BitSet;
-
-/**
- * Representation of topology common attributes.
- */
-public class CommonTopologyData {
- private final OptimizationType optimization;
- private final BitSet flags;
- private final KeyId networkId;
- private final DeviceId ownerId;
-
- /**
- * Create an instance of CommonTopologyData.
- *
- * @param networkId the network identifier
- * @param optimization the TE topology optimization criteria
- * @param flags the topology characteristics flags
- * @param ownerId the controller identifier owning this topology
- */
- public CommonTopologyData(KeyId networkId, OptimizationType optimization,
- BitSet flags, DeviceId ownerId) {
- this.optimization = optimization;
- this.flags = flags;
- this.networkId = networkId;
- this.ownerId = ownerId;
- }
-
- /**
- * Creates an instance of CommonTopologyData from a given TE topology.
- *
- * @param teTopology the given TE Topology
- */
- public CommonTopologyData(TeTopology teTopology) {
- optimization = teTopology.optimization();
- flags = teTopology.flags();
- networkId = teTopology.networkId();
- ownerId = teTopology.ownerId();
- }
-
-
- /**
- * Returns the topology optimization type.
- *
- * @return the optimization type
- */
- public OptimizationType optimization() {
- return optimization;
- }
-
- /**
- * Returns the network identifier.
- *
- * @return the network id
- */
- public KeyId networkId() {
- return networkId;
- }
-
- /**
- * Returns the topology characteristics flags.
- *
- * @return the flags
- */
- public BitSet flags() {
- return flags;
- }
-
- /**
- * Returns the SDN controller identifier owning this topology.
- *
- * @return the SDN controller id
- */
- public DeviceId ownerId() {
- return ownerId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(optimization, flags, ownerId, networkId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof CommonTopologyData) {
- CommonTopologyData that = (CommonTopologyData) object;
- return Objects.equal(optimization, that.optimization) &&
- Objects.equal(flags, that.flags) &&
- Objects.equal(networkId, that.networkId) &&
- Objects.equal(ownerId, that.ownerId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("optimization", optimization)
- .add("flags", flags)
- .add("ownerId", ownerId)
- .add("networkId", networkId)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/DefaultNetwork.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/DefaultNetwork.java
deleted file mode 100644
index fd726c9..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/DefaultNetwork.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import java.util.List;
-import java.util.Map;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.node.NetworkNode;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-/**
- * Default Network implementation.
- */
-public class DefaultNetwork implements Network {
- private final KeyId networkId;
- private final List<KeyId> supportingNetworkIds;
- private final Map<KeyId, NetworkNode> nodes;
- private final Map<KeyId, NetworkLink> links;
- private final TeTopologyId teTopologyId;
- private final boolean serverProvided;
- private final DeviceId ownerId;
- private final OptimizationType optimization;
-
- /**
- * Creates an instance of DefaultNetwork.
- *
- * @param networkId network identifier
- * @param supportingNetworkIds supporting network identifier
- * @param nodes list of nodes within the network
- * @param links list of links within the network
- * @param teTopologyId TE topology identifier associated with the network
- * @param serverProvided whether the network is received from server
- * @param ownerId the the controller identifier owning this topology
- * @param optimization TE topology optimization criteria
- */
- public DefaultNetwork(KeyId networkId, List<KeyId> supportingNetworkIds,
- Map<KeyId, NetworkNode> nodes, Map<KeyId, NetworkLink> links,
- TeTopologyId teTopologyId, boolean serverProvided,
- DeviceId ownerId, OptimizationType optimization) {
- this.networkId = networkId;
- this.supportingNetworkIds = supportingNetworkIds != null ?
- Lists.newArrayList(supportingNetworkIds) : null;
- this.nodes = nodes != null ? Maps.newHashMap(nodes) : null;
- this.links = links != null ? Maps.newHashMap(links) : null;
- this.teTopologyId = teTopologyId;
- this.serverProvided = serverProvided;
- this.ownerId = ownerId;
- this.optimization = optimization;
- }
-
-
- @Override
- public KeyId networkId() {
- return networkId;
- }
-
- @Override
- public List<KeyId> supportingNetworkIds() {
- if (supportingNetworkIds == null) {
- return null;
- }
- return ImmutableList.copyOf(supportingNetworkIds);
- }
-
- @Override
- public Map<KeyId, NetworkNode> nodes() {
- if (nodes == null) {
- return null;
- }
- return ImmutableMap.copyOf(nodes);
- }
-
- @Override
- public NetworkNode node(KeyId nodeId) {
- return nodes.get(nodeId);
- }
-
- @Override
- public Map<KeyId, NetworkLink> links() {
- if (links == null) {
- return null;
- }
- return ImmutableMap.copyOf(links);
- }
-
- @Override
- public NetworkLink link(KeyId linkId) {
- return links.get(linkId);
- }
-
- @Override
- public boolean isServerProvided() {
- return serverProvided;
- }
-
- @Override
- public TeTopologyId teTopologyId() {
- return teTopologyId;
- }
-
- @Override
- public DeviceId ownerId() {
- return ownerId;
- }
-
- @Override
- public OptimizationType optimization() {
- return optimization;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(networkId, supportingNetworkIds,
- nodes, links, serverProvided, teTopologyId,
- ownerId, optimization);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof DefaultNetwork) {
- DefaultNetwork that = (DefaultNetwork) object;
- return Objects.equal(networkId, that.networkId) &&
- Objects.equal(supportingNetworkIds, that.supportingNetworkIds) &&
- Objects.equal(nodes, that.nodes) &&
- Objects.equal(links, that.links) &&
- Objects.equal(serverProvided, that.serverProvided) &&
- Objects.equal(teTopologyId, that.teTopologyId) &&
- Objects.equal(ownerId, that.ownerId)
- && Objects.equal(optimization, that.optimization);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("networkId", networkId)
- .add("supportingNetworkIds", supportingNetworkIds)
- .add("nodes", nodes)
- .add("links", links)
- .add("serverProvided", serverProvided)
- .add("teTopologyId", teTopologyId)
- .add("ownerId", ownerId)
- .add("optimization", optimization)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/DefaultNetworks.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/DefaultNetworks.java
deleted file mode 100644
index b67b2f4..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/DefaultNetworks.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-import java.util.List;
-
-/**
- * Default Networks implementation.
- */
-public class DefaultNetworks implements Networks {
- private final List<Network> networks;
-
- /**
- * Creates an instance of DefaultNetworks.
- *
- * @param networks list of networks
- */
- public DefaultNetworks(List<Network> networks) {
- this.networks = networks != null ?
- Lists.newArrayList(networks) : null;
- }
-
- @Override
- public List<Network> networks() {
- if (networks == null) {
- return null;
- }
- return ImmutableList.copyOf(networks);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(networks);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof DefaultNetworks) {
- DefaultNetworks that = (DefaultNetworks) object;
- return Objects.equal(networks, that.networks);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("networks", networks)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/DefaultTeTopologies.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/DefaultTeTopologies.java
deleted file mode 100644
index d5a83f7..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/DefaultTeTopologies.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableMap;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Default TeTopologies implementation.
- */
-public class DefaultTeTopologies implements TeTopologies {
- private final String name;
- private final Map<TeTopologyKey, TeTopology> teTopologies;
-
- /**
- * Creates an instance of DefaultTeTopologies.
- *
- * @param name the name of a TeTopology set
- * @param teTopologies the list of TeTopology
- */
- public DefaultTeTopologies(String name, Map<TeTopologyKey, TeTopology> teTopologies) {
- this.name = name;
- this.teTopologies = teTopologies != null ?
- new HashMap<>(teTopologies) : null;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public Map<TeTopologyKey, TeTopology> teTopologies() {
- if (teTopologies == null) {
- return null;
- }
- return ImmutableMap.copyOf(teTopologies);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(name, teTopologies);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof DefaultTeTopologies) {
- DefaultTeTopologies that = (DefaultTeTopologies) object;
- return Objects.equal(name, that.name) &&
- Objects.equal(teTopologies, that.teTopologies);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("name", name)
- .add("teTopologies", teTopologies)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/DefaultTeTopology.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/DefaultTeTopology.java
deleted file mode 100644
index e20f32e..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/DefaultTeTopology.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-import org.onosproject.net.DeviceId;
-import org.onosproject.tetopology.management.api.link.TeLink;
-import org.onosproject.tetopology.management.api.link.TeLinkTpKey;
-import org.onosproject.tetopology.management.api.node.TeNode;
-
-import java.util.BitSet;
-import java.util.Map;
-
-/**
- * Default implementation of TeTopology.
- */
-public class DefaultTeTopology implements TeTopology {
- private final TeTopologyKey teKey;
- private final Map<Long, TeNode> teNodes;
- private final Map<TeLinkTpKey, TeLink> teLinks;
- private final String idString;
- private final CommonTopologyData common;
-
- /**
- * Creates an instance of DefaultTeTopology.
- *
- * @param teKey the TE topology key used for searching
- * @param teNodes the list of TE nodes in the topology
- * @param teLinks the list of TE links in the topology
- * @param idString the TE Topology id string value
- * @param common the common topology attributes
- */
- public DefaultTeTopology(TeTopologyKey teKey, Map<Long, TeNode> teNodes,
- Map<TeLinkTpKey, TeLink> teLinks, String idString,
- CommonTopologyData common) {
- this.teKey = teKey;
- this.teNodes = teNodes != null ? Maps.newHashMap(teNodes) : null;
- this.teLinks = teLinks != null ? Maps.newHashMap(teLinks) : null;
- this.idString = idString;
- this.common = common;
- }
-
- @Override
- public TeTopologyKey teTopologyId() {
- return teKey;
- }
-
- @Override
- public BitSet flags() {
- if (common == null) {
- return null;
- }
- return common.flags();
- }
-
- @Override
- public OptimizationType optimization() {
- if (common == null) {
- return null;
- }
- return common.optimization();
- }
-
- @Override
- public Map<Long, TeNode> teNodes() {
- if (teNodes == null) {
- return null;
- }
- return ImmutableMap.copyOf(teNodes);
- }
-
- @Override
- public TeNode teNode(long teNodeId) {
- return teNodes.get(teNodeId);
- }
-
- @Override
- public Map<TeLinkTpKey, TeLink> teLinks() {
- if (teLinks == null) {
- return null;
- }
- return ImmutableMap.copyOf(teLinks);
- }
-
- @Override
- public TeLink teLink(TeLinkTpKey teLinkId) {
- return teLinks.get(teLinkId);
- }
-
- @Override
- public String teTopologyIdStringValue() {
- return idString;
- }
-
- @Override
- public KeyId networkId() {
- if (common == null) {
- return null;
- }
- return common.networkId();
- }
-
- @Override
- public DeviceId ownerId() {
- if (common == null) {
- return null;
- }
- return common.ownerId();
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(teKey, teNodes,
- teLinks, common, idString);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof DefaultTeTopology) {
- DefaultTeTopology that = (DefaultTeTopology) object;
- return Objects.equal(teKey, that.teKey) &&
- Objects.equal(teNodes, that.teNodes) &&
- Objects.equal(teLinks, that.teLinks) &&
- Objects.equal(common, that.common) &&
- Objects.equal(idString, that.idString);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("teKey", teKey)
- .add("teNodes", teNodes)
- .add("teLinks", teLinks)
- .add("common", common)
- .add("idString", idString)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/EncodingType.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/EncodingType.java
deleted file mode 100644
index 8650753..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/EncodingType.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-/**
- * LSP encoding type.
- * See RFC 3471 for details.
- */
-public enum EncodingType {
-
- /**
- * Designates Packet LSP encoding.
- */
- LSP_ENCODING_PACKET(1),
-
- /**
- * Designates Ethernet LSP encoding.
- */
- LSP_ENCODING_ETHERNET(2),
-
- /**
- * Designates ANSI/ETSI PDH encoding.
- */
- LSP_ENCODING_PDH(3),
-
- /**
- * Designates SDH ITU-T G.707 / SONET ANSI T1.105 LSP encoding.
- */
- LSP_ENCODING_SDH(5),
-
- /**
- * Designates Digital Wrapper LSP encoding.
- */
- LSP_ENCODING_DIGITAL_WRAPPER(7),
-
- /**
- * Designates Lambda (photonic) LSP encoding.
- */
- LSP_ENCODING_LAMBDA(8),
-
- /**
- * Designates Fiber LSP encoding.
- */
- LSP_ENCODING_FIBER(9),
-
- /**
- * Designates Fiber Channel LSP encoding.
- */
- LSP_ENCODING_FIBER_CHANNEL(11),
-
- /**
- * Designates G.709 ODUk (Digital Path)LSP encoding.
- */
- LSP_ENCODING_ODUK(12);
-
- private int value;
-
- /**
- * Creates an instance of EncodingType.
- *
- * @param value value of encoding type
- */
- EncodingType(int value) {
- this.value = value;
- }
-
- /**
- * Returns the corresponding integer value of the encoding type.
- *
- * @return corresponding integer value
- */
- public int value() {
- return value;
- }
-
- /**
- * Returns the encoding type constant corresponding to the given integer
- * value. If the given value cannot be mapped to any valid encoding type,
- * a null is returned.
- *
- * @param value integer value
- * @return corresponding encoding type constant
- */
- public static EncodingType of(int value) {
- switch (value) {
- case 1:
- return LSP_ENCODING_PACKET;
- case 2:
- return LSP_ENCODING_ETHERNET;
- case 3:
- return LSP_ENCODING_PDH;
- case 5:
- return LSP_ENCODING_SDH;
- case 7:
- return LSP_ENCODING_DIGITAL_WRAPPER;
- case 8:
- return LSP_ENCODING_LAMBDA;
- case 9:
- return LSP_ENCODING_FIBER;
- case 11:
- return LSP_ENCODING_FIBER_CHANNEL;
- case 12:
- return LSP_ENCODING_ODUK;
- default:
- return null;
- }
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/KeyId.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/KeyId.java
deleted file mode 100644
index 5c8b400..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/KeyId.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetopology.management.api;
-
-import java.net.URI;
-import java.util.Objects;
-
-/**
- * Representation of an key identifier in URI.
- */
-public class KeyId {
- /**
- * Represents either no uri, or an unspecified uri.
- */
- public static final KeyId NONE = keyId("none:none");
-
- private final URI uri;
- private final String str;
-
- // Public construction is prohibited
- private KeyId(URI uri) {
- this.uri = uri;
- //this.str = uri.toString().toLowerCase();
- this.str = uri.toString();
- }
-
-
- /**
- * Default constructor for serialization of KeyId.
- */
- protected KeyId() {
- this.uri = null;
- this.str = null;
- }
-
- /**
- * Returns the backing URI.
- *
- * @return backing URI
- */
- public URI uri() {
- return uri;
- }
-
- @Override
- public int hashCode() {
- return str.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof KeyId) {
- KeyId that = (KeyId) obj;
- return this.getClass() == that.getClass() &&
- Objects.equals(this.str, that.str);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return str;
- }
-
- /**
- * Creates a uri id using the supplied URI.
- *
- * @param uri URI
- * @return UriId
- */
- public static KeyId keyId(URI uri) {
- return new KeyId(uri);
- }
-
- /**
- * Creates a uri id using the supplied URI string.
- *
- * @param string URI string
- * @return UriId
- */
- public static KeyId keyId(String string) {
- return keyId(URI.create(string));
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/LongValue.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/LongValue.java
deleted file mode 100644
index 17a488a..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/LongValue.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import com.google.common.base.MoreObjects;
-
-import java.util.Objects;
-
-/**
- * Implementation of using a long integer to represent
- * an ElementType.
- */
-public class LongValue {
- private final long value;
-
- /**
- * Creates an instance of LongValue.
- *
- * @param value long value
- */
- public LongValue(long value) {
- this.value = value;
- }
-
- /**
- * Returns the long integer representing the ElementType.
- *
- * @return long integer
- */
- public long value() {
- return value;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(value);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof LongValue) {
- LongValue other = (LongValue) obj;
- return Objects.equals(value, other.value);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("value", value)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/Network.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/Network.java
deleted file mode 100644
index 0226a03..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/Network.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import java.util.List;
-import java.util.Map;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.node.NetworkNode;
-
-/**
- * Abstraction of a network element.
- */
-public interface Network extends TeTopologyEventSubject {
-
- /**
- * Returns the network identifier / key.
- *
- * @return network identifier
- */
- KeyId networkId();
-
- /**
- * Returns the network keys (or identifiers) of the supporting
- * networks which serve as the underlay networks of the current
- * network which is mapped by the specified network identifier.
- *
- * @return list of network keys
- */
- List<KeyId> supportingNetworkIds();
-
- /**
- * Returns a collection of the network nodes of the network mapped
- * by the specified network identifier.
- *
- * @return a collection of network nodes
- */
- Map<KeyId, NetworkNode> nodes();
-
- /**
- * Returns the network node corresponding to the given identifier
- * which is encoded as a URI. If no node is found, a null
- * is returned.
- *
- * @param nodeId node id
- * @return value of node or null
- */
- NetworkNode node(KeyId nodeId);
-
- /**
- * Returns a collection of links in the network mapped by the specified
- * network identifier.
- *
- * @return a collection of currently known links
- */
- Map<KeyId, NetworkLink> links();
-
- /**
- * Returns the link corresponding to the given identifier which is
- * encoded as a URI. If no such a link is found, a null is returned.
- *
- * @param linkId link id
- * @return value of the link
- */
- NetworkLink link(KeyId linkId);
-
- /**
- * Returns true if the network is provided by a server, or false if
- * configured by a client.
- *
- * @return true if the network is provided by a server; false otherwise
- */
- boolean isServerProvided();
-
- /**
- * Returns the TE topology identifier for this network.
- *
- * @return TE topology id
- */
- TeTopologyId teTopologyId();
-
- /**
- * Returns the topology optimization criteria.
- *
- * @return the optimization
- */
- OptimizationType optimization();
-
- /**
- * Returns the controller identifier owning this abstracted topology.
- *
- * @return the controller id
- */
- DeviceId ownerId();
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/Networks.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/Networks.java
deleted file mode 100644
index 1a61a12..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/Networks.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import java.util.List;
-
-/**
- * Abstraction of an entity which represents the functionality of networks.
- */
-public interface Networks {
-
- /**
- * Returns the list of networks.
- *
- * @return list of networks
- */
- List<Network> networks();
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/OptimizationType.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/OptimizationType.java
deleted file mode 100644
index acef6a6..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/OptimizationType.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-/**
- * TE optimization type.
- */
-public enum OptimizationType {
-
- /**
- * Designates optimization is not applied.
- */
- NOT_OPTIMIZED(0),
-
- /**
- * Designates optimization criteria least cost.
- */
- LEAST_COST(1),
-
- /**
- * Designates optimization criteria shortest delay.
- */
- SHORTEST_DELAY(2),
-
- /**
- * Designates optimization criteria best link utilization.
- */
- BEST_LINK_UTILIZATION(3),
-
- /**
- * Designates optimization criteria best link protection.
- */
- BEST_LINK_PROTECTION(4);
-
- private int value;
-
- /**
- * Creates an instance of OptimizationType.
- *
- * @param value value of optimization type
- */
- OptimizationType(int value) {
- this.value = value;
- }
-
- /**
- * Returns the optimization type value.
- *
- * @return the value of optimization type
- */
- public int value() {
- return value;
- }
-
- /**
- * Returns the optimization constant corresponding to the given value.
- * If the given value cannot be mapped to any optimization type, a null
- * is returned.
- *
- * @param value the value of the optimization type
- * @return corresponding optimization type constant
- */
- public static OptimizationType of(int value) {
- switch (value) {
- case 0:
- return OptimizationType.NOT_OPTIMIZED;
- case 1:
- return OptimizationType.LEAST_COST;
- case 2:
- return OptimizationType.SHORTEST_DELAY;
- case 3:
- return OptimizationType.BEST_LINK_UTILIZATION;
- case 4:
- return OptimizationType.BEST_LINK_PROTECTION;
- default:
- return null;
- }
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/ProviderClientId.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/ProviderClientId.java
deleted file mode 100644
index f70bbe6..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/ProviderClientId.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Objects;
-
-/**
- * TE topology provider and client identifiers.
- */
-public abstract class ProviderClientId {
- private final long providerId;
- private final long clientId;
-
- /**
- * Creates an instance of TE topology provider client identifier.
- *
- * @param providerId provider identifier
- * @param clientId client identifier
- */
- public ProviderClientId(long providerId, long clientId) {
- this.providerId = providerId;
- this.clientId = clientId;
- }
-
- /**
- * Returns the provider identifier.
- *
- * @return provider identifier
- */
- public long providerId() {
- return providerId;
- }
-
- /**
- * Returns the client identifier.
- *
- * @return client identifier
- */
- public long clientId() {
- return clientId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(providerId, clientId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof ProviderClientId) {
- ProviderClientId that = (ProviderClientId) object;
- return Objects.equal(providerId, that.providerId) &&
- Objects.equal(clientId, that.clientId);
- }
- return false;
- }
-
- /**
- * Returns ToStringHelper with providerId and clientId.
- *
- * @return toStringHelper
- */
- protected ToStringHelper toStringHelper() {
- return MoreObjects.toStringHelper(this)
- .add("providerId", providerId)
- .add("clientId", clientId);
- }
-
- @Override
- public String toString() {
- return toStringHelper().toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/SwitchingType.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/SwitchingType.java
deleted file mode 100644
index 3410672..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/SwitchingType.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-/**
- * Type of switching on a link.
- * See RFC 3471 for details.
- */
-public enum SwitchingType {
-
- /**
- * Designates packet-switch capable-1 (PSC-1).
- */
- PACKET_SWITCH_CAPABLE1(1),
-
- /**
- * Designates packet-switch capable-2 (PSC-2).
- */
- PACKET_SWITCH_CAPABLE2(2),
-
- /**
- * Designates packet-switch capable-3 (PSC-3).
- */
- PACKET_SWITCH_CAPABLE3(3),
-
- /**
- * Designates packet-switch capable-4 (PSC-4).
- */
- PACKET_SWITCH_CAPABLE4(4),
-
- /**
- * Designates ethernet virtual private line (EVPL).
- */
- ETHERNET_VIRTUAL_PRIVATE_LINE(5),
-
- /**
- * Designates layer-2 switch capable (L2SC).
- */
- LAYER2_SWITCH_CAPABLE(51),
-
- /**
- * Designates time-division-multiplex capable (TDM).
- */
- TIME_DIVISION_MULTIPLEX_CAPABLE(100),
-
- /**
- * Designates OTN-TDM capable.
- */
- OTN_TDM_CAPABLE(101),
-
- /**
- * Designates lambda-switch capable (LSC).
- */
- LAMBDA_SWITCH_CAPABLE(150),
-
- /**
- * Designates fiber-switch capable (FSC).
- */
- FIBER_SWITCH_CAPABLE(200);
-
- private int value;
-
- /**
- * Creates an instance of a switching type constant corresponding
- * to the given integer value.
- *
- * @param value integer value
- */
- SwitchingType(int value) {
- this.value = value;
- }
-
- /**
- * Returns the integer value of the switching type.
- *
- * @return integer value
- */
- public int value() {
- return value;
- }
-
- /**
- * Returns the switching type corresponding to a given integer
- * value. If the given value is not valid, a null is returned.
- *
- * @param value integer value
- * @return corresponding switching type; or null if value is invalid
- */
- public static SwitchingType of(int value) {
- switch (value) {
- case 1:
- return PACKET_SWITCH_CAPABLE1;
- case 2:
- return PACKET_SWITCH_CAPABLE2;
- case 3:
- return PACKET_SWITCH_CAPABLE3;
- case 4:
- return PACKET_SWITCH_CAPABLE4;
- case 5:
- return ETHERNET_VIRTUAL_PRIVATE_LINE;
- case 51:
- return LAYER2_SWITCH_CAPABLE;
- case 100:
- return TIME_DIVISION_MULTIPLEX_CAPABLE;
- case 101:
- return OTN_TDM_CAPABLE;
- case 150:
- return LAMBDA_SWITCH_CAPABLE;
- case 200:
- return FIBER_SWITCH_CAPABLE;
- default:
- return null;
- }
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeConstants.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeConstants.java
deleted file mode 100644
index e95574a..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeConstants.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-/**
- * The common TE constants.
- */
-public final class TeConstants {
- /**
- * Lowest priority of a GMPLS traffic link.
- */
- public static final short MIN_PRIORITY = 0;
-
- /**
- * Highest priority of a GMPLS traffic link.
- */
- public static final short MAX_PRIORITY = 7;
-
- /**
- * Size of the BitSet flags used in TE Topology data structures, such as
- * TE links, TE nodes, and TE topologies.
- */
- public static final short FLAG_MAX_BITS = 16;
-
- /**
- * Indication of a Nil flag or a uninitialized long integer.
- */
- public static final long NIL_LONG_VALUE = 0;
-
- // no instantiation
- private TeConstants() {
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeStatus.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeStatus.java
deleted file mode 100644
index b914061..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeStatus.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetopology.management.api;
-
-/**
- * Represents ENUM data of teStatus.
- */
-public enum TeStatus {
-
- /**
- * Represents up.
- */
- UP(0),
-
- /**
- * Represents down.
- */
- DOWN(1),
-
- /**
- * Represents testing.
- */
- TESTING(2),
-
- /**
- * Represents preparingMaintenance.
- */
- PREPARING_MAINTENANCE(3),
-
- /**
- * Represents maintenance.
- */
- MAINTENANCE(4),
-
- /**
- * Status cannot be determined for some reason.
- */
- UNKNOWN(5);
-
- private int teStatus;
-
- /**
- * Creates an instance of teStatus.
- *
- * @param value value of teStatus
- */
- TeStatus(int value) {
- teStatus = value;
- }
-
- /**
- * Returns the attribute teStatus.
- *
- * @return value of teStatus
- */
- public int teStatus() {
- return teStatus;
- }
-
- /**
- * Returns the object of teAdminStatusEnumForTypeInt.Returns null
- * when string conversion fails or converted integer value is not
- * recognized.
- *
- * @param value value of teAdminStatusEnumForTypeInt
- * @return Object of teAdminStatusEnumForTypeInt
- */
- public static TeStatus of(int value) {
- switch (value) {
- case 0:
- return TeStatus.UP;
- case 1:
- return TeStatus.DOWN;
- case 2:
- return TeStatus.TESTING;
- case 3:
- return TeStatus.PREPARING_MAINTENANCE;
- case 4:
- return TeStatus.MAINTENANCE;
- case 5:
- return TeStatus.UNKNOWN;
- default :
- return null;
- }
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologies.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologies.java
deleted file mode 100644
index 1fb5194..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologies.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import java.util.Map;
-
-/**
- * Abstraction of an entity which represents a set of TE topologies.
- */
-public interface TeTopologies {
-
- /**
- * Returns the name of the TE topology set.
- *
- * @return name
- */
- String name();
-
- /**
- * Returns a collection of currently known TE topologies.
- *
- * @return list of TE topologies
- */
- Map<TeTopologyKey, TeTopology> teTopologies();
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopology.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopology.java
deleted file mode 100644
index cdded32..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopology.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.tetopology.management.api.link.TeLink;
-import org.onosproject.tetopology.management.api.link.TeLinkTpKey;
-import org.onosproject.tetopology.management.api.node.TeNode;
-
-import java.util.BitSet;
-import java.util.Map;
-
-/**
- * Abstraction of a TE topology.
- */
-public interface TeTopology extends TeTopologyEventSubject {
- /**
- * Indicates that the specified topology is not usable for
- * any ACTN operations.
- */
- public static final int BIT_DISABLED = 0;
-
- /**
- * Indicates that the topology is auto-constructed by
- * the controller by an auto-discovery mechanism.
- */
- public static final int BIT_LEARNT = 1;
-
- /**
- * Indicates that the topology is merged from other
- * supporting topologies.
- */
- public static final int BIT_MERGED = 2;
-
- /**
- * Indicates that the topology is customized based on
- * another topology.
- */
- public static final int BIT_CUSTOMIZED = 3;
-
- /**
- * Returns the TE topology identifier.
- *
- * @return the topology id
- */
- TeTopologyKey teTopologyId();
-
- /**
- * Returns the topology characteristics flags.
- *
- * @return the flags
- */
- public BitSet flags();
-
- /**
- * Returns the topology optimization criteria.
- *
- * @return the optimization
- */
- public OptimizationType optimization();
-
- /**
- * Returns a collection of TE nodes in the topology.
- *
- * @return a collection of currently known TE nodes
- */
- Map<Long, TeNode> teNodes();
-
- /**
- * Returns a TE node in the topology that matches the given node
- * identifier. A null will be returned if no such node exists.
- *
- * @param teNodeId the TE node id
- * @return the corresponding node; or null if not found
- */
- TeNode teNode(long teNodeId);
-
- /**
- * Returns a collection of links in the topology.
- *
- * @return a collection of currently known te links
- */
- Map<TeLinkTpKey, TeLink> teLinks();
-
- /**
- * Returns a TE link in the topology that matches the given
- * link identifier. If no such a link is found, a null is returned.
- *
- * @param teLinkId the TE link id
- * @return the corresponding link; or null if not found
- */
- TeLink teLink(TeLinkTpKey teLinkId);
-
- /**
- * Returns the TE topology identifier string value.
- *
- * @return the topology id in String format
- */
- String teTopologyIdStringValue();
-
- /**
- * Returns the network identifier.
- *
- * @return network identifier
- */
- KeyId networkId();
-
- /**
- * Returns the identity of the controller owning this abstracted topology.
- *
- * @return the controller id
- */
- DeviceId ownerId();
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyEvent.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyEvent.java
deleted file mode 100644
index 4c778b2..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyEvent.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import org.onosproject.event.AbstractEvent;
-
-/**
- * TE topology event.
- */
-public class TeTopologyEvent
- extends AbstractEvent<TeTopologyEvent.Type, TeTopologyEventSubject> {
-
- /**
- * Type of TE topology events.
- */
- public enum Type {
- /**
- * Designates addition of a network.
- */
- NETWORK_ADDED,
-
- /**
- * Designates update of a network.
- */
- NETWORK_UPDATED,
-
- /**
- * Designates removal of a network.
- */
- NETWORK_REMOVED,
-
- /**
- * Designates addition of a network node.
- */
- NODE_ADDED,
-
- /**
- * Designates update of a network node.
- */
- NODE_UPDATED,
-
- /**
- * Designates removal of a network node.
- */
- NODE_REMOVED,
-
- /**
- * Designates addition of a termination point.
- */
- TP_ADDED,
-
- /**
- * Designates update of a termination point.
- */
- TP_UPDATED,
-
- /**
- * Designates removal of a termination point.
- */
- TP_REMOVED,
-
- /**
- * Designates addition of a network link.
- */
- LINK_ADDED,
-
- /**
- * Designates update of a network link.
- */
- LINK_UPDATED,
-
- /**
- * Designates removal of a network link.
- */
- LINK_REMOVED,
-
- /**
- * Designates addition of a TE topology.
- */
- TE_TOPOLOGY_ADDED,
-
- /**
- * Designates update of a TE topology.
- */
- TE_TOPOLOGY_UPDATED,
-
- /**
- * Designates removal of a TE topology.
- */
- TE_TOPOLOGY_REMOVED,
-
- /**
- * Designates addition of a TE node.
- */
- TE_NODE_ADDED,
-
- /**
- * Designates update of a TE node.
- */
- TE_NODE_UPDATED,
-
- /**
- * Designates removal of a TE node.
- */
- TE_NODE_REMOVED,
-
- /**
- * Designates addition of a TE link.
- */
- TE_LINK_ADDED,
-
- /**
- * Designates update of a TE link.
- */
- TE_LINK_UPDATED,
-
- /**
- * Designates removal of a TE link.
- */
- TE_LINK_REMOVED
- }
-
- /**
- * Constructor for TeTopologyEvent.
- *
- * @param type type of topology event
- * @param subject event subject interface
- */
- public TeTopologyEvent(Type type, TeTopologyEventSubject subject) {
- super(type, subject);
- }
-
- /**
- * Constructor for TeTopologyEvent.
- *
- * @param type type of topology event
- * @param subject event subject interface
- * @param time event time
- */
- public TeTopologyEvent(Type type, TeTopologyEventSubject subject, long time) {
- super(type, subject, time);
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyEventSubject.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyEventSubject.java
deleted file mode 100644
index 585e423..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyEventSubject.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-/**
- * Abstraction of TE network topology event subject.
- */
-public interface TeTopologyEventSubject {
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyId.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyId.java
deleted file mode 100644
index 1b88d00..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyId.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import com.google.common.base.Objects;
-
-/**
- * TE Topology identifier in String format.
- */
-public class TeTopologyId extends ProviderClientId {
- private final String topologyId;
-
- /**
- * Creates an instance of TE topology identifier.
- *
- * @param providerId value of provider identifier
- * @param clientId value of client identifier
- * @param topologyId value of topology identifier
- */
- public TeTopologyId(long providerId, long clientId, String topologyId) {
- super(providerId, clientId);
- this.topologyId = topologyId;
- }
-
- /**
- * Returns the topology identifier.
- *
- * @return topology identifier
- */
- public String topologyId() {
- return topologyId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), topologyId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof TeTopologyId) {
- if (!super.equals(object)) {
- return false;
- }
- TeTopologyId that = (TeTopologyId) object;
- return Objects.equal(this.topologyId, that.topologyId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper()
- .add("topologyId", topologyId)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyKey.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyKey.java
deleted file mode 100644
index cfab616..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyKey.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Objects;
-
-/**
- * TE topology key in long integer format.
- */
-public class TeTopologyKey extends ProviderClientId {
- private final long topologyId;
-
- /**
- * Creates an instance of TE topology identifier.
- *
- * @param providerId provider identifier
- * @param clientId client identifier
- * @param topologyId topology identifier
- */
- public TeTopologyKey(long providerId, long clientId, long topologyId) {
- super(providerId, clientId);
- this.topologyId = topologyId;
- }
-
- /**
- * Returns the topology identifier.
- *
- * @return topology identifier
- */
- public long topologyId() {
- return topologyId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), topologyId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof TeTopologyKey) {
- if (!super.equals(object)) {
- return false;
- }
- TeTopologyKey that = (TeTopologyKey) object;
- return Objects.equal(topologyId, that.topologyId);
- }
- return false;
- }
-
- /**
- * Returns ToStringHelper with additional topologyId.
- *
- * @return toStringHelper
- */
- protected ToStringHelper toTopologyKeyStringHelper() {
- return toStringHelper().add("topologyId", topologyId);
- }
-
- @Override
- public String toString() {
- return toTopologyKeyStringHelper().toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyListener.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyListener.java
deleted file mode 100644
index 2e71e6c..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Entity capable of receiving TE network Topology related events.
- */
-public interface TeTopologyListener extends EventListener<TeTopologyEvent> {
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyProvider.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyProvider.java
deleted file mode 100644
index ab60408..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyProvider.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import org.onosproject.net.provider.Provider;
-
-/**
- * Abstraction of an IETF network provider.
- * APIs for Manager to signal Provider.
- */
-public interface TeTopologyProvider extends Provider {
-
- /**
- * TODO:
- *
- * Signals provider that abstract networks/network/link/node has been created/updated/deleted.
- * It's used by producers.
- *
- */
-
- // TODO: Need to look at the following functions are required for TE Nodes
-
- // TODO: consider how dirty the triggerProbe gets; if it costs too much, let's drop it
-
- /**
- * Triggers an asynchronous probe of the specified device, intended to
- * determine whether the device is present or not. An indirect result of this
- * should be invocation of
- * {@link org.onosproject.net.device.DeviceProviderService#deviceConnected} )} or
- * {@link org.onosproject.net.device.DeviceProviderService#deviceDisconnected}
- * at some later point in time.
- *
- * @param deviceId ID of device to be probed
- */
- //void triggerProbe(DeviceId deviceId);
-
- /**
- * Notifies the provider of a mastership role change for the specified
- * device as decided by the core.
- *
- * @param deviceId device identifier
- * @param newRole newly determined mastership role
- */
- //void roleChanged(DeviceId deviceId, MastershipRole newRole);
-
- /**
- * Checks the reachability (connectivity) of a device from this provider.
- *
- * @param deviceId device identifier
- * @return true if reachable, false otherwise
- */
- //boolean isReachable(DeviceId deviceId);
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyProviderRegistry.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyProviderRegistry.java
deleted file mode 100644
index 2f6bef9..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyProviderRegistry.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import org.onosproject.net.provider.ProviderRegistry;
-
-/**
- * Abstraction of TE topology provider registry.
- */
-public interface TeTopologyProviderRegistry
- extends ProviderRegistry<TeTopologyProvider, TeTopologyProviderService> {
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyProviderService.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyProviderService.java
deleted file mode 100644
index 139343a..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyProviderService.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import org.onosproject.net.provider.ProviderService;
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.node.NetworkNode;
-import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
-import org.onosproject.tetopology.management.api.node.TerminationPoint;
-import org.onosproject.tetopology.management.api.node.TerminationPointKey;
-
-/**
- * APIs for Provider to notify Manager about the network topology updates.
- */
-public interface TeTopologyProviderService
- extends ProviderService<TeTopologyProvider> {
-
- /**
- * Signals that a Network has been created/updated.
- *
- * @param network value of the network to be updated
- */
- void networkUpdated(Network network);
-
- /**
- * Signals that a Network has been removed.
- *
- * @param networkId network id in URI format
- */
- void networkRemoved(KeyId networkId);
-
- /**
- * Signals that a Link has been created/updated.
- *
- * @param linkKey link id
- * @param link link object to be updated
- */
- void linkUpdated(NetworkLinkKey linkKey, NetworkLink link);
-
- /**
- * Signals that a Network has been removed.
- *
- * @param linkKey link id
- */
- void linkRemoved(NetworkLinkKey linkKey);
-
- /**
- * Signals that a Node has been created/updated.
- *
- * @param nodeKey node id
- * @param node node object to be updated
- */
- void nodeUpdated(NetworkNodeKey nodeKey, NetworkNode node);
-
- /**
- * Signals that a Node has been removed.
- *
- * @param nodeKey node id
- */
- void nodeRemoved(NetworkNodeKey nodeKey);
-
- /**
- * Signals that a TerminationPoint has been created/updated.
- *
- * @param terminationPointKey termination point id
- * @param terminationPoint termination point object to be updated
- */
- void terminationPointUpdated(TerminationPointKey terminationPointKey,
- TerminationPoint terminationPoint);
-
- /**
- * Signals that a TerminationPoint has been removed.
- *
- * @param terminationPointKey termination point id
- */
- void terminationPointRemoved(TerminationPointKey terminationPointKey);
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyService.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyService.java
deleted file mode 100644
index dd4826b..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeTopologyService.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import org.onosproject.event.ListenerService;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.link.TeLink;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
-import org.onosproject.tetopology.management.api.node.TeNode;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TerminationPointKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.tetopology.management.api.node.TunnelTerminationPoint;
-
-/**
- * TE Topology Service API.
- */
-public interface TeTopologyService
- extends ListenerService<TeTopologyEvent, TeTopologyListener> {
-
- /**
- * Returns a collection of currently known networks.
- *
- * @return a collection of networks
- */
- Networks networks();
-
- /**
- * Returns the network identified by its network identifier. if no
- * network can be found, a null is returned.
- *
- * @param networkId network id in URI format
- * @return the corresponding network; or null if not found
- */
- Network network(KeyId networkId);
-
- /**
- * Updates the network.
- *
- * @param network network to be updated
- */
- void updateNetwork(Network network);
-
- /**
- * Removes the network corresponding to the given network identifier.
- *
- * @param networkId network id in URI format
- */
- void removeNetwork(KeyId networkId);
-
- /**
- * Returns a collection of currently known TE topologies.
- *
- * @return a collection of topologies
- */
- TeTopologies teTopologies();
-
- /**
- * Returns the TE Topology identified by the given key.
- *
- * @param topologyKey the given TE topology Key
- * @return the corresponding TE topology
- */
- TeTopology teTopology(TeTopologyKey topologyKey);
-
- /**
- * Returns the merged topology in MDSC.
- *
- * @return the merged topology
- */
- TeTopology mergedTopology();
-
- /**
- * Creates or Updates a TE topology based on the given topology.
- *
- * @param teTopology the given TE topology
- */
- void updateTeTopology(TeTopology teTopology);
-
- /**
- * Removes the TE Topology identified by its key. Does nothing if
- * no topology is found which matches the key.
- *
- * @param topologyKey the TE topology key
- */
- void removeTeTopology(TeTopologyKey topologyKey);
-
- /**
- * Returns the TE node identified by the given node key. If no TE
- * node is found, a null is returned.
- *
- * @param nodeKey the TE node key
- * @return the corresponding TE node,or null
- */
- TeNode teNode(TeNodeKey nodeKey);
-
- /**
- * Returns the TE link identified by the given TE link key. If no
- * TE link is found, a null is returned.
- *
- * @param linkKey the TE link key
- * @return the corresponding TE link or null
- */
- TeLink teLink(TeLinkTpGlobalKey linkKey);
-
- /**
- * Returns a tunnel termination point identified by the given tunnel
- * termination point key. If no tunnel termination point is found,
- * a null is returned.
- *
- * @param ttpKey the tunnel termination point key
- * @return the corresponding tunnel termination point
- */
- TunnelTerminationPoint tunnelTerminationPoint(TtpKey ttpKey);
-
- /**
- * Returns the network Id for a TE Topology key.
- *
- * @param teTopologyKey the TE topology key
- * @return value of network Id
- */
- KeyId networkId(TeTopologyKey teTopologyKey);
-
- /**
- * Returns the network node key for a TE node key.
- *
- * @param teNodeKey a TE node key
- * @return value of network node key
- */
- NetworkNodeKey nodeKey(TeNodeKey teNodeKey);
-
- /**
- * Returns the network link key for a TE link key.
- *
- * @param teLinkKey a TE node key
- * @return value of network link key
- */
- NetworkLinkKey linkKey(TeLinkTpGlobalKey teLinkKey);
-
- /**
- * Returns the termination point key for a TE termination point key.
- *
- * @param teTpKey a TE termination point key
- * @return value of termination point key
- */
- TerminationPointKey terminationPointKey(TeLinkTpGlobalKey teTpKey);
-
- /**
- * Returns the TE controller global identification.
- *
- * @return value of controller id
- */
- long teContollerId();
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeUtils.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeUtils.java
deleted file mode 100644
index fe05ed7..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/TeUtils.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api;
-
-import com.google.common.collect.Lists;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * TE utility functions.
- */
-public final class TeUtils {
-
- // no instantiation
- private TeUtils() {
- }
-
- /**
- * Returns true if the given collection is empty; false otherwise.
- *
- * @param c the given collection
- * @return true or false
- */
- public static boolean nonEmpty(Collection<?> c) {
- return c != null && !c.isEmpty();
- }
-
- /**
- * Adds a given element to a given list. If element is null, the
- * given list is returned without modification. If the list is null,
- * the function will instantiate and return a new list.
- *
- * @param list the given list
- * @param element the given list element
- * @param <T> the element type
- * @return the resulting list
- */
- public static <T> List<T> addListElement(List<T> list, T element) {
- if (element == null) {
- return list;
- }
-
- List<T> result = (list == null) ? Lists.newArrayList() : list;
-
- result.add(element);
-
- return result;
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/AsNumber.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/AsNumber.java
deleted file mode 100644
index 2e97f21..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/AsNumber.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import java.util.Objects;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Implementation of Autonomous System (AS) number as an ElementType.
- */
-public class AsNumber implements ElementType {
- private final int asNumber;
-
- /**
- * Creates an instance of AsNumber.
- *
- * @param asNumber autonomous system number
- */
- public AsNumber(int asNumber) {
- this.asNumber = asNumber;
- }
-
- /**
- * Returns the autonomous system number.
- *
- * @return the AS number
- */
- public int asNumber() {
- return asNumber;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(asNumber);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof AsNumber) {
- AsNumber other = (AsNumber) obj;
- return Objects.equals(asNumber, other.asNumber);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("asNumber", asNumber)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/CommonLinkData.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/CommonLinkData.java
deleted file mode 100644
index dd3724d..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/CommonLinkData.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.onosproject.tetopology.management.api.EncodingType;
-import org.onosproject.tetopology.management.api.SwitchingType;
-import org.onosproject.tetopology.management.api.TeStatus;
-
-import java.util.BitSet;
-import java.util.List;
-
-/**
- * Representation of link common attributes.
- */
-public class CommonLinkData {
- private final TeStatus adminStatus;
- private final TeStatus opStatus;
- private final BitSet flags;
-
- private final SwitchingType switchingLayer;
- private final EncodingType encodingLayer;
-
- private final ExternalLink externalLink;
- private final UnderlayPath underlayPath;
- private final TePathAttributes teAttributes;
- private final List<Long> interLayerLocks;
- private final LinkBandwidth bandwidth;
- private final Long adminGroup;
-
- /**
- * Creates an instance of CommonLinkData.
- *
- * @param adminStatus the admin status
- * @param opStatus the operational Status
- * @param flags the flags
- * @param switchingLayer the network layer switching type
- * @param encodingLayer the network layer encoding type
- * @param externalLink the external link specific attributes
- * @param underlayPath the link underlay path and supporting tunnel
- * @param teAttributes the link path TE attributes
- * @param adminGroup the administrative group
- * @param interLayerLocks the supported inter-layer locks
- * @param bandwidth the link maximum and available bandwidth at
- * each priority level
- */
- public CommonLinkData(TeStatus adminStatus,
- TeStatus opStatus, BitSet flags, SwitchingType switchingLayer,
- EncodingType encodingLayer, ExternalLink externalLink,
- UnderlayPath underlayPath, TePathAttributes teAttributes,
- Long adminGroup, List<Long> interLayerLocks,
- LinkBandwidth bandwidth) {
- this.adminStatus = adminStatus;
- this.opStatus = opStatus;
- this.flags = flags;
- this.switchingLayer = switchingLayer;
- this.encodingLayer = encodingLayer;
- this.externalLink = externalLink;
- this.underlayPath = underlayPath;
- this.teAttributes = teAttributes;
- this.adminGroup = adminGroup;
- this.interLayerLocks = interLayerLocks != null ?
- Lists.newArrayList(interLayerLocks) : null;
- this.bandwidth = bandwidth;
- }
-
- /**
- * Creates an instance of CommonLinkData with a TeLink.
- *
- * @param link the TE link
- */
- public CommonLinkData(TeLink link) {
- this.adminStatus = link.adminStatus();
- this.opStatus = link.opStatus();
- this.flags = link.flags();
- this.switchingLayer = link.switchingLayer();
- this.encodingLayer = link.encodingLayer();
- this.externalLink = link.externalLink();
- this.underlayPath = new UnderlayPath(link);
- this.teAttributes = new TePathAttributes(link);
- this.adminGroup = link.administrativeGroup();
- this.interLayerLocks = link.interLayerLocks() != null ?
- Lists.newArrayList(link.interLayerLocks()) : null;
- this.bandwidth = new LinkBandwidth(link);
- }
-
-
- /**
- * Returns the admin status.
- *
- * @return the admin status
- */
- public TeStatus adminStatus() {
- return adminStatus;
- }
-
- /**
- * Returns the operational status.
- *
- * @return the optional status
- */
- public TeStatus opStatus() {
- return opStatus;
- }
-
- /**
- * Returns the flags.
- *
- * @return the flags
- */
- public BitSet flags() {
- return flags;
- }
-
- /**
- * Returns the network layer switching type for this link.
- *
- * @return the switching layer type
- */
- public SwitchingType switchingLayer() {
- return switchingLayer;
- }
-
- /**
- * Returns the network layer encoding type for this link.
- *
- * @return the encoding type
- */
- public EncodingType encodingLayer() {
- return encodingLayer;
- }
-
- /**
- * Returns the external link.
- *
- * @return the external link
- */
- public ExternalLink externalLink() {
- return externalLink;
- }
-
- /**
- * Returns the link underlay path and tunnel.
- *
- * @return the underlay path
- */
- public UnderlayPath underlayPath() {
- return underlayPath;
- }
-
- /**
- * Returns the path TE attributes.
- *
- * @return the path TE Attributes
- */
- public TePathAttributes teAttributes() {
- return teAttributes;
- }
-
- /**
- * Returns the link administrative group.
- *
- * @return the admin group
- */
- public Long adminGroup() {
- return adminGroup;
- }
-
- /**
- * Returns the supported inter-layer locks.
- *
- * @return the inter-layer locks
- */
- public List<Long> interLayerLocks() {
- if (interLayerLocks == null) {
- return null;
- }
- return ImmutableList.copyOf(interLayerLocks);
- }
-
- /**
- * Returns the link maximum and available bandwidth at each priority level.
- *
- * @return the bandwidth
- */
- public LinkBandwidth bandwidth() {
- return bandwidth;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(adminStatus, opStatus, flags, switchingLayer,
- encodingLayer, externalLink, underlayPath,
- teAttributes, interLayerLocks, bandwidth);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof CommonLinkData) {
- CommonLinkData that = (CommonLinkData) object;
- return Objects.equal(adminStatus, that.adminStatus) &&
- Objects.equal(opStatus, that.opStatus) &&
- Objects.equal(flags, that.flags) &&
- Objects.equal(switchingLayer, that.switchingLayer) &&
- Objects.equal(encodingLayer, that.encodingLayer) &&
- Objects.equal(externalLink, that.externalLink) &&
- Objects.equal(underlayPath, that.underlayPath) &&
- Objects.equal(teAttributes, that.teAttributes) &&
- Objects.equal(interLayerLocks, that.interLayerLocks) &&
- Objects.equal(bandwidth, that.bandwidth);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("adminStatus", adminStatus)
- .add("opStatus", opStatus)
- .add("flags", flags)
- .add("switchingLayer", switchingLayer)
- .add("encodingLayer", encodingLayer)
- .add("externalLink", externalLink)
- .add("underlayPath", underlayPath)
- .add("teAttributes", teAttributes)
- .add("interLayerLocks", interLayerLocks)
- .add("bandwidth", bandwidth)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/ConnectivityMatrixId.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/ConnectivityMatrixId.java
deleted file mode 100644
index 056b1f0..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/ConnectivityMatrixId.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import org.onosproject.tetopology.management.api.LongValue;
-
-/**
- * Implementation of Connectivity matrix entry id as an element type.
- */
-public class ConnectivityMatrixId extends LongValue implements ElementType {
-
- /**
- * Creates a connectivity matrix identifier.
- *
- * @param entryId the entry identifier
- */
- public ConnectivityMatrixId(long entryId) {
- super(entryId);
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/DefaultNetworkLink.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/DefaultNetworkLink.java
deleted file mode 100644
index d8f97f3..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/DefaultNetworkLink.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.node.NodeTpKey;
-
-import java.util.List;
-
-/**
- * Default implementation of a network link.
- */
-public class DefaultNetworkLink implements NetworkLink {
- private final KeyId linkId;
- private final NodeTpKey source;
- private final NodeTpKey destination;
- private final List<NetworkLinkKey> supportingLinkIds;
- private final TeLink teLink;
-
- /**
- * Creates an instance of a network link.
- *
- * @param linkId link identifier
- * @param source source of termination point
- * @param destination destination termination point
- * @param supportingLinkIds supporting links
- * @param teLink TE link which this network link maps to
- */
- public DefaultNetworkLink(KeyId linkId,
- NodeTpKey source,
- NodeTpKey destination,
- List<NetworkLinkKey> supportingLinkIds,
- TeLink teLink) {
- this.linkId = linkId;
- this.source = source;
- this.destination = destination;
- this.supportingLinkIds = supportingLinkIds != null ?
- Lists.newArrayList(supportingLinkIds) : null;
- this.teLink = teLink;
- }
-
- @Override
- public KeyId linkId() {
- return linkId;
- }
-
- @Override
- public NodeTpKey source() {
- return source;
- }
-
- @Override
- public NodeTpKey destination() {
- return destination;
- }
-
- @Override
- public List<NetworkLinkKey> supportingLinkIds() {
- if (supportingLinkIds == null) {
- return null;
- }
- return ImmutableList.copyOf(supportingLinkIds);
- }
-
- @Override
- public TeLink teLink() {
- return teLink;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(linkId, source, destination,
- supportingLinkIds, teLink);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof DefaultNetworkLink) {
- DefaultNetworkLink that = (DefaultNetworkLink) object;
- return Objects.equal(linkId, that.linkId) &&
- Objects.equal(source, that.source) &&
- Objects.equal(destination, that.destination) &&
- Objects.equal(supportingLinkIds, that.supportingLinkIds) &&
- Objects.equal(teLink, that.teLink);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("linkId", linkId)
- .add("source", source)
- .add("destination", destination)
- .add("supportingLinkIds", supportingLinkIds)
- .add("teLink", teLink)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/DefaultTeLink.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/DefaultTeLink.java
deleted file mode 100644
index fb728b8..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/DefaultTeLink.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import org.onosproject.tetopology.management.api.EncodingType;
-import org.onosproject.tetopology.management.api.SwitchingType;
-import org.onosproject.tetopology.management.api.TeConstants;
-import org.onosproject.tetopology.management.api.TeStatus;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-
-import java.util.BitSet;
-import java.util.List;
-
-/**
- * The default implementation of TE link.
- */
-public class DefaultTeLink implements TeLink {
- private final TeLinkTpKey teLinkKey;
- private final TeLinkTpKey peerTeLinkKey;
- private final TeTopologyKey underlayTopologyId;
- private final TeLinkTpGlobalKey supportTeLinkId;
- private final TeLinkTpGlobalKey sourceTeLinkId;
- private final CommonLinkData teData;
-
- /**
- * Creates an instance of a TE link.
- *
- * @param teLinkKey the TE link key
- * @param peerTeLinkKey the bi-directional peer link key
- * @param underlayTopologyId the link underlay TE topology id
- * @param supportTeLinkId the supporting TE link id
- * @param sourceTeLinkId the source TE link id
- * @param teData the link common te data
- */
- public DefaultTeLink(TeLinkTpKey teLinkKey,
- TeLinkTpKey peerTeLinkKey,
- TeTopologyKey underlayTopologyId,
- TeLinkTpGlobalKey supportTeLinkId,
- TeLinkTpGlobalKey sourceTeLinkId,
- CommonLinkData teData) {
- this.teLinkKey = teLinkKey;
- this.peerTeLinkKey = peerTeLinkKey;
- this.underlayTopologyId = underlayTopologyId;
- this.supportTeLinkId = supportTeLinkId;
- this.sourceTeLinkId = sourceTeLinkId;
- this.teData = teData;
- }
-
- @Override
- public TeLinkTpKey teLinkKey() {
- return teLinkKey;
- }
-
- @Override
- public TeLinkTpKey peerTeLinkKey() {
- return peerTeLinkKey;
- }
-
- @Override
- public BitSet flags() {
- if (teData == null) {
- return null;
- }
- return teData.flags();
- }
-
- @Override
- public SwitchingType switchingLayer() {
- if (teData == null) {
- return null;
- }
- return teData.switchingLayer();
- }
-
- @Override
- public EncodingType encodingLayer() {
- if (teData == null) {
- return null;
- }
- return teData.encodingLayer();
- }
-
- @Override
- public ExternalLink externalLink() {
- if (teData == null) {
- return null;
- }
- return teData.externalLink();
- }
-
- @Override
- public TeTopologyKey underlayTeTopologyId() {
- return underlayTopologyId;
- }
-
- @Override
- public UnderlayPrimaryPath primaryPath() {
- if (teData == null || teData.underlayPath() == null) {
- return null;
- }
- return teData.underlayPath().primaryPath();
- }
-
- @Override
- public List<UnderlayBackupPath> backupPaths() {
- if (teData == null || teData.underlayPath() == null) {
- return null;
- }
- return teData.underlayPath().backupPaths();
- }
-
- @Override
- public TunnelProtectionType tunnelProtectionType() {
- if (teData == null || teData.underlayPath() == null) {
- return null;
- }
- return teData.underlayPath().tunnelProtectionType();
- }
-
- @Override
- public long sourceTtpId() {
- if (teData == null || teData.underlayPath() == null) {
- return TeConstants.NIL_LONG_VALUE;
- }
- return teData.underlayPath().srcTtpId();
- }
-
- @Override
- public long destinationTtpId() {
- if (teData == null || teData.underlayPath() == null) {
- return TeConstants.NIL_LONG_VALUE;
- }
- return teData.underlayPath().dstTtpId();
- }
-
- @Override
- public TeTunnelId teTunnelId() {
- if (teData == null || teData.underlayPath() == null) {
- return null;
- }
- return teData.underlayPath().teTunnelId();
- }
-
- @Override
- public TeLinkTpGlobalKey supportingTeLinkId() {
- return supportTeLinkId;
- }
-
- @Override
- public TeLinkTpGlobalKey sourceTeLinkId() {
- return sourceTeLinkId;
- }
-
- @Override
- public Long cost() {
- if (teData == null || teData.teAttributes() == null) {
- return TeConstants.NIL_LONG_VALUE;
- }
- return teData.teAttributes().cost();
- }
-
- @Override
- public Long delay() {
- if (teData == null || teData.teAttributes() == null) {
- return TeConstants.NIL_LONG_VALUE;
- }
- return teData.teAttributes().delay();
- }
-
- @Override
- public List<Long> srlgs() {
- if (teData == null || teData.teAttributes() == null) {
- return null;
- }
- return teData.teAttributes().srlgs();
- }
-
- @Override
- public Long administrativeGroup() {
- if (teData == null) {
- return null;
- }
- return teData.adminGroup();
- }
-
- @Override
- public List<Long> interLayerLocks() {
- if (teData == null) {
- return null;
- }
- return teData.interLayerLocks();
- }
-
- @Override
- public float[] maxBandwidth() {
- if (teData == null || teData.bandwidth() == null) {
- return null;
- }
- return teData.bandwidth().maxBandwidth();
- }
-
- @Override
- public float[] availBandwidth() {
- if (teData == null || teData.bandwidth() == null) {
- return null;
- }
- return teData.bandwidth().availBandwidth();
- }
-
- @Override
- public float[] maxAvailLspBandwidth() {
- if (teData == null || teData.bandwidth() == null) {
- return null;
- }
- return teData.bandwidth().maxAvailLspBandwidth();
- }
-
- @Override
- public float[] minAvailLspBandwidth() {
- if (teData == null || teData.bandwidth() == null) {
- return null;
- }
- return teData.bandwidth().minAvailLspBandwidth();
- }
-
- @Override
- public OduResource oduResource() {
- if (teData == null || teData.bandwidth() == null) {
- return null;
- }
- return teData.bandwidth().oduResource();
- }
-
- @Override
- public TeStatus adminStatus() {
- if (teData == null) {
- return null;
- }
- return teData.adminStatus();
- }
-
- @Override
- public TeStatus opStatus() {
- if (teData == null) {
- return null;
- }
- return teData.opStatus();
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(teLinkKey, peerTeLinkKey, underlayTopologyId,
- supportTeLinkId, sourceTeLinkId, teData);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof DefaultTeLink) {
- DefaultTeLink that = (DefaultTeLink) object;
- return Objects.equal(teLinkKey, that.teLinkKey) &&
- Objects.equal(peerTeLinkKey, that.peerTeLinkKey) &&
- Objects.equal(underlayTopologyId, that.underlayTopologyId) &&
- Objects.equal(supportTeLinkId, that.supportTeLinkId) &&
- Objects.equal(sourceTeLinkId, that.sourceTeLinkId) &&
- Objects.equal(teData, that.teData);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("teLinkKey", teLinkKey)
- .add("peerTeLinkKey", peerTeLinkKey)
- .add("underlayTopologyId", underlayTopologyId)
- .add("supportTeLinkId", supportTeLinkId)
- .add("sourceTeLinkId", sourceTeLinkId)
- .add("teData", teData)
- .toString();
- }
-
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/ElementType.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/ElementType.java
deleted file mode 100644
index 3c938c8..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/ElementType.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-/**
- * Abstraction of a path element type.
- */
-public interface ElementType {
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/ExternalLink.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/ExternalLink.java
deleted file mode 100644
index cb91ed1..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/ExternalLink.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-/**
- * Representation of an external domain link.
- */
-public class ExternalLink {
- private final TeLinkTpGlobalKey externalLinkKey;
- private final Long plugId;
-
- /**
- * Creates an instance of an external domain link.
- *
- * @param externalLinkKey external TE link key
- * @param plugId global plug identifier
- */
- public ExternalLink(TeLinkTpGlobalKey externalLinkKey, long plugId) {
- this.externalLinkKey = externalLinkKey;
- this.plugId = plugId;
- }
-
- /**
- * Returns the external TE link key.
- *
- * @return the externalLinkKey
- */
- public TeLinkTpGlobalKey externalLinkKey() {
- return externalLinkKey;
- }
-
- /**
- * Returns the global plug identifier.
- *
- * @return value of the global plug id
- */
- public Long plugId() {
- return plugId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(externalLinkKey, plugId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof ExternalLink) {
- ExternalLink that = (ExternalLink) object;
- return Objects.equal(externalLinkKey, that.externalLinkKey) &&
- Objects.equal(plugId, that.plugId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("externalLinkKey", externalLinkKey)
- .add("plugId", plugId)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/Label.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/Label.java
deleted file mode 100644
index 8130f78..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/Label.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import org.onosproject.tetopology.management.api.LongValue;
-
-/**
- * Implementation of a label as an element type.
- */
-public class Label extends LongValue implements ElementType {
- /**
- * Creates a label instance.
- *
- * @param label label value
- */
- public Label(long label) {
- super(label);
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/LinkBandwidth.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/LinkBandwidth.java
deleted file mode 100644
index 22b1c86..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/LinkBandwidth.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-import java.util.Arrays;
-
-/**
- * Representation the TE link bandwidths.
- */
-public class LinkBandwidth {
- /**
- * Maximum bandwidth, Size is MAX_PRIORITY + 1.
- */
- private final float[] maxBandwidth;
-
- /**
- * Unreserved bandwidth, Size is MAX_PRIORITY + 1.
- */
- private final float[] availBandwidth;
-
- /**
- * Maximum available bandwidth for a LSP.
- */
- private final float[] maxAvailLspBandwidth;
-
- /**
- * Minimum available bandwidth for a LSP.
- */
- private final float[] minAvailLspBandwidth;
-
- /**
- * ODU resources.
- */
- private final OduResource odu;
-
- /**
- * Creates an instance of link bandwidth.
- *
- * @param maxBandwidth the maximum bandwidth at each priority level
- * @param availBandwidth the available bandwidth at each priority level
- * @param maxAvailLspBandwidth the maximum available bandwidth for a LSP at
- * each priority level
- * @param minAvailLspBandwidth the minimum available bandwidth for a LSP at
- * each priority level
- * @param odu ODU resources
- */
- public LinkBandwidth(float[] maxBandwidth,
- float[] availBandwidth,
- float[] maxAvailLspBandwidth,
- float[] minAvailLspBandwidth,
- OduResource odu) {
- this.maxBandwidth = maxBandwidth != null ?
- Arrays.copyOf(maxBandwidth, maxBandwidth.length) : null;
- this.availBandwidth = availBandwidth != null ?
- Arrays.copyOf(availBandwidth, availBandwidth.length) : null;
- this.maxAvailLspBandwidth = maxAvailLspBandwidth != null ?
- Arrays.copyOf(maxAvailLspBandwidth,
- maxAvailLspBandwidth.length) : null;
- this.minAvailLspBandwidth = minAvailLspBandwidth != null ?
- Arrays.copyOf(minAvailLspBandwidth,
- minAvailLspBandwidth.length) : null;
- this.odu = odu;
- }
-
- /**
- * Creates an instance of link bandwidth with a TE link.
- *
- * @param link the TE link
- */
- public LinkBandwidth(TeLink link) {
- this.maxBandwidth = link.maxBandwidth();
- this.availBandwidth = link.maxAvailLspBandwidth();
- this.maxAvailLspBandwidth = link.maxAvailLspBandwidth();
- this.minAvailLspBandwidth = link.minAvailLspBandwidth();
- this.odu = link.oduResource();
- }
-
- /**
- * Returns the maximum bandwidth at each priority level.
- *
- * @return the maxBandwidth
- */
- public float[] maxBandwidth() {
- if (maxBandwidth == null) {
- return null;
- }
- return Arrays.copyOf(maxBandwidth, maxBandwidth.length);
- }
-
- /**
- * Returns the available bandwidth at each priority level.
- *
- * @return the available bandwidth
- */
- public float[] availBandwidth() {
- if (availBandwidth == null) {
- return null;
- }
- return Arrays.copyOf(availBandwidth, availBandwidth.length);
- }
-
- /**
- * Returns the maximum available bandwidth for a LSP at each priority
- * level.
- *
- * @return the maximum available bandwidth
- */
- public float[] maxAvailLspBandwidth() {
- if (maxAvailLspBandwidth == null) {
- return null;
- }
- return Arrays.copyOf(maxAvailLspBandwidth, maxAvailLspBandwidth.length);
- }
-
- /**
- * Returns the minimum available bandwidth for a LSP at each priority level.
- *
- * @return the minimum available bandwidth
- */
- public float[] minAvailLspBandwidth() {
- if (minAvailLspBandwidth == null) {
- return null;
- }
- return Arrays.copyOf(minAvailLspBandwidth, minAvailLspBandwidth.length);
- }
-
- /**
- * Returns the link ODUk resources.
- *
- * @return the ODUk resources
- */
- public OduResource oduResource() {
- return odu;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(Arrays.hashCode(maxBandwidth),
- Arrays.hashCode(availBandwidth),
- Arrays.hashCode(maxAvailLspBandwidth),
- Arrays.hashCode(minAvailLspBandwidth),
- odu);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof LinkBandwidth) {
- LinkBandwidth that = (LinkBandwidth) object;
- return Arrays.equals(maxBandwidth, that.maxBandwidth) &&
- Arrays.equals(availBandwidth, that.availBandwidth) &&
- Arrays.equals(maxAvailLspBandwidth, that.maxAvailLspBandwidth) &&
- Arrays.equals(minAvailLspBandwidth, that.minAvailLspBandwidth) &&
- Objects.equal(odu, that.odu);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("maxBandwidth", maxBandwidth)
- .add("availBandwidth", availBandwidth)
- .add("maxAvailLspBandwidth", maxAvailLspBandwidth)
- .add("minAvailLspBandwidth", minAvailLspBandwidth)
- .add("odu", odu)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/NetworkLink.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/NetworkLink.java
deleted file mode 100644
index d40e6c1..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/NetworkLink.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.node.NodeTpKey;
-
-import java.util.List;
-
-/**
- * Abstraction of a base network link.
- */
-public interface NetworkLink {
-
- /**
- * Returns the link identifier.
- *
- * @return link identifier
- */
- KeyId linkId();
-
- /**
- * Returns the link source termination point.
- *
- * @return source link termination point identifier
- */
- NodeTpKey source();
-
- /**
- * Returns the link destination termination point.
- *
- * @return destination link termination point id
- */
- NodeTpKey destination();
-
- /**
- * Returns the supporting link identifiers.
- *
- * @return list of the ids of the supporting links
- */
- List<NetworkLinkKey> supportingLinkIds();
-
- /**
- * Returns the link TE extension.
- *
- * @return TE link attributes
- */
- TeLink teLink();
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/NetworkLinkEventSubject.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/NetworkLinkEventSubject.java
deleted file mode 100644
index 50d4100..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/NetworkLinkEventSubject.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import org.onosproject.tetopology.management.api.TeTopologyEventSubject;
-
-/**
- * Representation of a network link event.
- */
-public class NetworkLinkEventSubject implements TeTopologyEventSubject {
- private final NetworkLinkKey key;
- private final NetworkLink networkLink;
-
- /**
- * Creates a network link event instance.
- *
- * @param key the network link global key
- * @param networkLink the network link object
- */
- public NetworkLinkEventSubject(NetworkLinkKey key, NetworkLink networkLink) {
- this.key = key;
- this.networkLink = networkLink;
- }
-
- /**
- * Returns the network link global key.
- *
- * @return the key
- */
- public NetworkLinkKey key() {
- return key;
- }
-
- /**
- * Returns the network link.
- *
- * @return the network link
- */
- public NetworkLink networkLink() {
- return networkLink;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(key, networkLink);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof NetworkLinkEventSubject) {
- NetworkLinkEventSubject that = (NetworkLinkEventSubject) object;
- return Objects.equal(key, that.key) &&
- Objects.equal(networkLink, that.networkLink);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("key", key)
- .add("networkLink", networkLink)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/NetworkLinkKey.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/NetworkLinkKey.java
deleted file mode 100644
index 2e04566..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/NetworkLinkKey.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import org.onosproject.tetopology.management.api.KeyId;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-/**
- * Representation of a link key or link reference.
- */
-public class NetworkLinkKey {
- private final KeyId networkId;
- private final KeyId linkId;
-
- /**
- * Creates an instance of NetworkLinkKey.
- *
- * @param networkId network identifier
- * @param linkId link identifier
- */
- public NetworkLinkKey(KeyId networkId, KeyId linkId) {
- this.networkId = networkId;
- this.linkId = linkId;
- }
-
- /**
- * Returns the network identifier.
- *
- * @return network identifier
- */
- public KeyId networkId() {
- return networkId;
- }
-
- /**
- * Returns the link identifier.
- *
- * @return link identifier
- */
- public KeyId linkId() {
- return linkId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(networkId, linkId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof NetworkLinkKey) {
- NetworkLinkKey that = (NetworkLinkKey) object;
- return Objects.equal(this.networkId, that.networkId) &&
- Objects.equal(this.linkId, that.linkId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("networkId", networkId)
- .add("linkId", linkId)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/OduResource.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/OduResource.java
deleted file mode 100644
index 93d5d1f..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/OduResource.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-/**
- * Representation of an ODU link resource.
- */
-public class OduResource {
- private final short odu0s;
- private final short odu1s;
- private final short odu2s;
- private final short odu2es;
- private final short odu3s;
- private final short odu4s;
- private final short oduFlexes;
-
- /**
- * Creates an instance of an ODU link resource.
- *
- * @param odu0s number of available ODU0 containers
- * @param odu1s number of available ODU1 containers
- * @param odu2s number of available ODU2 containers
- * @param odu2es number of available ODU2e containers
- * @param odu3s number of available ODU3 containers
- * @param odu4s number of available ODU4 containers
- * @param oduFlexes available ODUflex bandwidth in terms of ODU0 containers
- */
- public OduResource(short odu0s, short odu1s, short odu2s,
- short odu2es, short odu3s, short odu4s,
- short oduFlexes) {
- this.odu0s = odu0s;
- this.odu1s = odu1s;
- this.odu2s = odu2s;
- this.odu2es = odu2es;
- this.odu3s = odu3s;
- this.odu4s = odu4s;
- this.oduFlexes = oduFlexes;
- }
-
- /**
- * Returns the number of available ODU0s.
- *
- * @return the odu0s
- */
- public short odu0s() {
- return odu0s;
- }
-
- /**
- * Returns the number of available ODU1s.
- *
- * @return the odu1s
- */
- public short odu1s() {
- return odu1s;
- }
-
- /**
- * Returns the number of available ODU2s.
- *
- * @return the odu2s
- */
- public short odu2s() {
- return odu2s;
- }
-
- /**
- * Returns the number of available ODU2es.
- *
- * @return the odu2es
- */
- public short odu2es() {
- return odu2es;
- }
-
- /**
- * Returns the number of available ODU3s.
- *
- * @return the odu3s
- */
- public short odu3s() {
- return odu3s;
- }
-
- /**
- * Returns the number of available ODU4s.
- *
- * @return the odu4s
- */
- public short odu4s() {
- return odu4s;
- }
-
- /**
- * Returns available ODUflex bandwidth in terms of ODU0 containers.
- *
- * @return the oduFlexes
- */
- public short oduFlexes() {
- return oduFlexes;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(odu0s, odu1s, odu2s, odu2es, odu3s,
- odu4s, oduFlexes);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof OduResource) {
- OduResource that = (OduResource) object;
- return (this.odu0s == that.odu0s) &&
- (this.odu1s == that.odu1s) &&
- (this.odu2s == that.odu2s) &&
- (this.odu2es == that.odu2es) &&
- (this.odu3s == that.odu3s) &&
- (this.odu4s == that.odu4s) &&
- (this.oduFlexes == that.oduFlexes);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("odu0s", odu0s)
- .add("odu1s", odu1s)
- .add("odu2s", odu2s)
- .add("odu2es", odu2es)
- .add("odu3s", odu3s)
- .add("odu4s", odu4s)
- .add("oduFlexes", oduFlexes)
- .toString();
- }
-
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/PathElement.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/PathElement.java
deleted file mode 100644
index 3cbaae8..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/PathElement.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-/**
- * Representation of a path element.
- */
-public class PathElement {
- private final long pathElementId;
- private final long teNodeId;
- private final ElementType type;
- private final boolean loose;
-
- /**
- * Creates a path element.
- *
- * @param pathElementId path element identifier
- * @param teNodeId identifier of the TE node to which this
- * path element belongs
- * @param type path element type
- * @param loose loose if true; strict if false
- */
- public PathElement(long pathElementId, long teNodeId,
- ElementType type, boolean loose) {
- this.pathElementId = pathElementId;
- this.teNodeId = teNodeId;
- this.type = type;
- this.loose = loose;
- }
-
- /**
- * Returns the path element identifier.
- *
- * @return path element id
- */
- public long pathElementId() {
- return pathElementId;
- }
-
- /**
- * Returns the TE node identifier.
- *
- * @return te node id
- */
- public long teNodeId() {
- return teNodeId;
- }
-
- /**
- * Returns the path element type.
- *
- * @return path element type
- */
- public ElementType type() {
- return type;
- }
-
- /**
- * Returns the loose flag. true = loose; false = strict.
- *
- * @return loose value
- */
- public boolean loose() {
- return loose;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(pathElementId, teNodeId, type, loose);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof PathElement) {
- PathElement that = (PathElement) object;
- return Objects.equal(pathElementId, that.pathElementId) &&
- Objects.equal(teNodeId, that.teNodeId) &&
- Objects.equal(type, that.type) &&
- Objects.equal(loose, that.loose);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("pathElementId", pathElementId)
- .add("teNodeId", teNodeId)
- .add("type", type)
- .add("loose", loose)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeIpv4.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeIpv4.java
deleted file mode 100644
index 454fed3..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeIpv4.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * Copyright 2016 Open Networking Foundation
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import org.onlab.packet.Ip4Address;
-
-import java.util.Objects;
-
-/**
- * Implementation of IPv4 address as an element type.
- */
-public class TeIpv4 implements ElementType {
- private final Ip4Address v4Address;
- private final short v4PrefixLength;
-
- /**
- * Creates an IPv4 address.
- *
- * @param v4Address the IPv4 address
- * @param v4PrefixLength the length of IPv4 prefix
- */
- public TeIpv4(Ip4Address v4Address, short v4PrefixLength) {
- this.v4Address = v4Address;
- this.v4PrefixLength = v4PrefixLength;
- }
-
- /**
- * Returns the IPv4 address.
- *
- * @return IPv4 address
- */
- public Ip4Address v4Address() {
- return v4Address;
- }
-
- /**
- * Returns the length of the IPv4 address prefix.
- *
- * @return IPv4 address prefix length
- */
- public short v4PrefixLength() {
- return v4PrefixLength;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(v4Address, v4PrefixLength);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof TeIpv4) {
- TeIpv4 other = (TeIpv4) obj;
- return Objects.equals(v4Address, other.v4Address) &&
- Objects.equals(v4PrefixLength, other.v4PrefixLength);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("v4Address", v4Address)
- .add("v4PrefixLength", v4PrefixLength)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeIpv6.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeIpv6.java
deleted file mode 100644
index baa033b..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeIpv6.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import org.onlab.packet.Ip6Address;
-
-import java.util.Objects;
-
-/**
- * Implementation of an IPv6 address as an element type.
- */
-public class TeIpv6 implements ElementType {
- private final Ip6Address v6Address;
- private final short v6PrefixLength;
-
- /**
- * Creates an IPv6 address.
- *
- * @param v6Address the IP v6 address to set
- * @param v6PrefixLength the length of the IPv6 address prefix
- */
- public TeIpv6(Ip6Address v6Address, short v6PrefixLength) {
- this.v6Address = v6Address;
- this.v6PrefixLength = v6PrefixLength;
- }
-
- /**
- * Returns the IPv6 address.
- *
- * @return the IPv6 address
- */
- public Ip6Address v6Address() {
- return v6Address;
- }
-
- /**
- * Returns the length of the IPv6 address prefix.
- *
- * @return IPv6 address prefix length
- */
- public short v6PrefixLength() {
- return v6PrefixLength;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(v6Address, v6PrefixLength);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof TeIpv6) {
- TeIpv6 other = (TeIpv6) obj;
- return Objects.equals(v6Address, other.v6Address) &&
- Objects.equals(v6PrefixLength, other.v6PrefixLength);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("v6Address", v6Address)
- .add("v6PrefixLength", v6PrefixLength)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLink.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLink.java
deleted file mode 100644
index b43f406..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLink.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import org.onosproject.tetopology.management.api.EncodingType;
-import org.onosproject.tetopology.management.api.SwitchingType;
-import org.onosproject.tetopology.management.api.TeStatus;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-
-import java.util.BitSet;
-import java.util.List;
-
-/**
- * Abstraction of a TE link.
- */
-public interface TeLink {
- /**
- * Indicates that the TE link belongs to an abstract topology.
- */
- public static final short BIT_ABSTRACT = 0;
-
- /**
- * Indicates that the underlay topology that supports this TE link
- * is dynamically created as opposed to being created by provisioning.
- */
- public static final short BIT_DYNAMIC = 1;
-
- /**
- * Indicates that the underlay topology is committed to service.
- */
- public static final short BIT_COMMITTED = 2;
-
- /**
- * Indicates that the TE link connects 2 TE domains.
- */
- public static final short BIT_ACCESS_INTERDOMAIN = 3;
-
- /**
- * Indicates that the TE link is not numbered.
- */
- public static final short BIT_UNNUMBERED = 4;
-
- /**
- * Returns the TE link key.
- *
- * @return the TE link key
- */
- TeLinkTpKey teLinkKey();
-
- /**
- * Returns the key of the bi-directional peer TE link.
- *
- * @return peer TE link key
- */
- TeLinkTpKey peerTeLinkKey();
-
- /**
- * Returns the flags of this TE link.
- *
- * @return the flags
- */
- BitSet flags();
-
- /**
- * Returns the network layer switching type for this link.
- *
- * @return the network layer switching type
- */
- SwitchingType switchingLayer();
-
- /**
- * Returns the network layer encoding type for this link.
- *
- * @return the encoding type
- */
- EncodingType encodingLayer();
-
- /**
- * Returns the external link.
- *
- * @return the external link
- */
- ExternalLink externalLink();
-
- /**
- * Returns the underlay TE topology identifier for the link.
- *
- * @return the underlay TE topology id
- */
- TeTopologyKey underlayTeTopologyId();
-
- /**
- * Returns the primary path.
- *
- * @return underlay primary path
- */
- UnderlayPrimaryPath primaryPath();
-
- /**
- * Returns the backup paths.
- *
- * @return list of underlay backup paths
- */
- List<UnderlayBackupPath> backupPaths();
-
- /**
- * Returns the supporting tunnel protection type.
- *
- * @return the tunnel protection type
- */
- TunnelProtectionType tunnelProtectionType();
-
- /**
- * Returns the supporting tunnel's source tunnel termination point
- * identifier.
- *
- * @return the source TTP id
- */
- long sourceTtpId();
-
- /**
- * Returns the supporting tunnel's destination tunnel termination
- * point identifier.
- *
- * @return the destination TTP id
- */
- long destinationTtpId();
-
- /**
- * Returns the supporting tunnel identifier.
- *
- * @return the supporting tunnel id
- */
- TeTunnelId teTunnelId();
-
- /**
- * Returns the supporting TE link identifier.
- *
- * @return the supporting TE link id
- */
- TeLinkTpGlobalKey supportingTeLinkId();
-
- /**
- * Returns the source TE link identifier.
- *
- * @return the source link id
- */
- TeLinkTpGlobalKey sourceTeLinkId();
-
- /**
- * Returns the link cost.
- *
- * @return the cost
- */
- Long cost();
-
- /**
- * Returns the link delay.
- *
- * @return the delay
- */
- Long delay();
-
- /**
- * Returns the link SRLG values.
- *
- * @return the srlgs
- */
- List<Long> srlgs();
-
- /**
- * Returns the link administrative group.
- *
- * @return the adminGroup
- */
- Long administrativeGroup();
-
- /**
- * Returns the supported inter-layer locks.
- *
- * @return the inter-layer locks
- */
- List<Long> interLayerLocks();
-
- /**
- * Returns the maximum bandwidth at each priority level.
- *
- * @return a list of maximum bandwidths
- */
- float[] maxBandwidth();
-
- /**
- * Returns the available bandwidth at each priority level.
- *
- * @return a list of available bandwidths
- */
- float[] availBandwidth();
-
- /**
- * Returns the maximum available bandwidth for a LSP at each priority level.
- *
- * @return a list of maximum available bandwidths
- */
- float[] maxAvailLspBandwidth();
-
- /**
- * Returns the minimum available bandwidth for a LSP at each priority level.
- *
- * @return a list of minimum available bandwidths
- */
- float[] minAvailLspBandwidth();
-
- /**
- * Returns the administrative status of this TE link.
- *
- * @return the admin status
- */
- TeStatus adminStatus();
-
- /**
- * Returns the operational status of this TE link.
- *
- * @return the operational status
- */
- TeStatus opStatus();
-
- /**
- * Returns the link ODUk resources.
- *
- * @return the ODUk resources
- */
- OduResource oduResource();
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkAccessType.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkAccessType.java
deleted file mode 100644
index 5698ff9..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkAccessType.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-/**
- * Represents ENUM data of teLinkAccessType.
- */
-public enum TeLinkAccessType {
- /**
- * Represents pointToPoint.
- */
- POINT_TO_POINT(0),
-
- /**
- * Represents multiAccess.
- */
- MULTI_ACCESS(1);
-
- private int teLinkAccessType;
-
- TeLinkAccessType(int value) {
- teLinkAccessType = value;
- }
-
- /**
- * Returns the attribute teLinkAccessType.
- *
- * @return value of teLinkAccessType
- */
- public int teLinkAccessType() {
- return teLinkAccessType;
- }
-
- /**
- * Returns the object of teLinkAccessType from input String. Returns null
- * when string conversion fails or converted integer value is not recognized.
- *
- * @param valInString input String
- * @return Object of teLinkAccessType
- */
- public static TeLinkAccessType of(String valInString) {
- try {
- int tmpVal = Integer.parseInt(valInString);
- return of(tmpVal);
- } catch (NumberFormatException e) {
- }
- return null;
- }
-
- /**
- * Returns the object of teLinkAccessTypeForTypeInt. Returns null
- * when the integer value is not recognized.
- *
- * @param value value of teLinkAccessTypeForTypeInt
- * @return Object of teLinkAccessTypeForTypeInt
- */
- public static TeLinkAccessType of(int value) {
- switch (value) {
- case 0:
- return TeLinkAccessType.POINT_TO_POINT;
- case 1:
- return TeLinkAccessType.MULTI_ACCESS;
- default :
- return null;
- }
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkEventSubject.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkEventSubject.java
deleted file mode 100644
index 4a3a961..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkEventSubject.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import org.onosproject.tetopology.management.api.TeTopologyEventSubject;
-
-/**
- * Representation of a TE link event.
- */
-public class TeLinkEventSubject implements TeTopologyEventSubject {
- private final TeLinkTpGlobalKey key;
- private final TeLink teLink;
-
- /**
- * Creates an instance of TE link event.
- *
- * @param key the TE link key
- * @param teLink the TE link
- */
- public TeLinkEventSubject(TeLinkTpGlobalKey key, TeLink teLink) {
- this.key = key;
- this.teLink = teLink;
- }
-
- /**
- * Returns the TE link global key.
- *
- * @return the key
- */
- public TeLinkTpGlobalKey key() {
- return key;
- }
-
- /**
- * Returns the TE link.
- *
- * @return the TE link
- */
- public TeLink teLink() {
- return teLink;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(key, teLink);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof TeLinkEventSubject) {
- TeLinkEventSubject that = (TeLinkEventSubject) object;
- return Objects.equal(key, that.key) &&
- Objects.equal(teLink, that.teLink);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("key", key)
- .add("teLink", teLink)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkId.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkId.java
deleted file mode 100644
index 0be9032..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkId.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import org.onosproject.tetopology.management.api.LongValue;
-
-/**
- * Implementation of a TE link identifier as an element type.
- */
-public class TeLinkId extends LongValue implements ElementType {
-
- /**
- * Creates a TE link identifier based on a given long integer.
- *
- * @param linkId TE link id
- */
- public TeLinkId(long linkId) {
- super(linkId);
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkTpGlobalKey.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkTpGlobalKey.java
deleted file mode 100644
index 63977db..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkTpGlobalKey.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Objects;
-
-/**
- * Representation of a global TE link TP (i.e., TE termination point) key.
- */
-public class TeLinkTpGlobalKey extends TeNodeKey {
- private final long teLinkTpId;
-
- /**
- * Creates a global TE link TP key.
- *
- * @param providerId provider identifier
- * @param clientId client identifier
- * @param topologyId topology identifier
- * @param teNodeId TE node identifier
- * @param teLinkTpId TE link termination point identifier
- */
- public TeLinkTpGlobalKey(long providerId, long clientId,
- long topologyId, long teNodeId,
- long teLinkTpId) {
- super(providerId, clientId, topologyId, teNodeId);
- this.teLinkTpId = teLinkTpId;
- }
-
- /**
- * Creates a global TE link TP key based on a given local TE node key.
- *
- * @param teNodeKey the local TE node key
- * @param teLinkTpId TE link termination point identifier
- */
- public TeLinkTpGlobalKey(TeNodeKey teNodeKey, long teLinkTpId) {
- super(teNodeKey.providerId(), teNodeKey.clientId(),
- teNodeKey.topologyId(), teNodeKey.teNodeId());
- this.teLinkTpId = teLinkTpId;
- }
-
- /**
- * Creates a global TE link TP key based on a given TE topology key
- * and a local TE link TP key.
- *
- * @param teTopologyKey the key of TE Topology to which this link belongs
- * @param teLinkTpKey the local TE link key
- */
- public TeLinkTpGlobalKey(TeTopologyKey teTopologyKey,
- TeLinkTpKey teLinkTpKey) {
- super(teTopologyKey.providerId(), teTopologyKey.clientId(),
- teTopologyKey.topologyId(), teLinkTpKey.teNodeId());
- this.teLinkTpId = teLinkTpKey.teLinkTpId();
- }
-
- /**
- * Returns the TE link TP identifier.
- *
- * @return the TE link id
- */
- public long teLinkTpId() {
- return teLinkTpId;
- }
-
- /**
- * Returns the key of the TE node from which this link TP originates.
- *
- * @return the TE node key
- */
- public TeNodeKey teNodeKey() {
- return new TeNodeKey(providerId(), clientId(), topologyId(), teNodeId());
- }
-
- /**
- * Returns the key of the TE Topology to which this link TP belongs.
- *
- * @return the TE topology key
- */
- @Override
- public TeTopologyKey teTopologyKey() {
- return new TeTopologyKey(providerId(), clientId(), topologyId());
- }
-
- /**
- * Returns the local TE link TP key.
- *
- * @return the TE link TP key
- */
- public TeLinkTpKey teLinkTpKey() {
- return new TeLinkTpKey(teNodeId(), teLinkTpId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), teLinkTpId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof TeLinkTpGlobalKey) {
- if (!super.equals(object)) {
- return false;
- }
- TeLinkTpGlobalKey that = (TeLinkTpGlobalKey) object;
- return Objects.equal(teLinkTpId, that.teLinkTpId);
- }
- return false;
- }
-
- /**
- * Returns a helper for toString() with additional TE link TP identifier.
- *
- * @return a toString helper
- */
- protected ToStringHelper toTeLinkTpKeyStringHelper() {
- return toTeNodeKeyStringHelper().add("teLinkTpId", teLinkTpId);
- }
-
- @Override
- public String toString() {
- return toTeLinkTpKeyStringHelper().toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkTpKey.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkTpKey.java
deleted file mode 100644
index 2f88572..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeLinkTpKey.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-/**
- * Representation of the TE link TP (i.e., TE termination point) Key in
- * the scope of a TE node.
- */
-public final class TeLinkTpKey {
- private final long teNodeId;
- private final long teLinkTpId;
-
- /**
- * Creates a TE link TP key.
- *
- * @param teNodeId TE Node identifier
- * @param teLinkTpId TE Link termination point identifier
- */
- public TeLinkTpKey(long teNodeId, long teLinkTpId) {
- this.teNodeId = teNodeId;
- this.teLinkTpId = teLinkTpId;
- }
-
- /**
- * Returns the TE Node identifier.
- *
- * @return the TE node id
- */
- public long teNodeId() {
- return teNodeId;
- }
-
- /**
- * Returns the TE link termination point identifier.
- *
- * @return the TE link TP id
- */
- public long teLinkTpId() {
- return teLinkTpId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(teNodeId, teLinkTpId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof TeLinkTpKey) {
- TeLinkTpKey that = (TeLinkTpKey) object;
- return Objects.equal(teNodeId, that.teNodeId) &&
- Objects.equal(teLinkTpId, that.teLinkTpId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("teNodeId", teNodeId)
- .add("teLinkTpId", teLinkTpId)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TePathAttributes.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TePathAttributes.java
deleted file mode 100644
index b74694a..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TePathAttributes.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-import java.util.List;
-
-/**
- * Represents the common attributes of a TE path or segment.
- */
-public class TePathAttributes {
- private final Long cost;
- private final Long delay;
- private final List<Long> srlgs;
-
- /**
- * Creates an instance of TE path attributes.
- *
- * @param cost the path's cost
- * @param delay the path's delay
- * @param srlgs the path's shared risk link groups (SRLGs)
- */
- public TePathAttributes(Long cost, Long delay, List<Long> srlgs) {
- this.cost = cost;
- this.delay = delay;
- this.srlgs = srlgs != null ? Lists.newArrayList(srlgs) : null;
- }
-
- /**
- * Creates an instance of TE path attributes based on a given TE link.
- *
- * @param link the TE link
- */
- public TePathAttributes(TeLink link) {
- this.cost = link.cost();
- this.delay = link.delay();
- this.srlgs = link.srlgs() != null ?
- Lists.newArrayList(link.srlgs()) : null;
- }
-
- /**
- * Returns the path cost.
- *
- * @return the cost
- */
- public Long cost() {
- return cost;
- }
-
- /**
- * Returns the path delay.
- *
- * @return the delay
- */
- public Long delay() {
- return delay;
- }
-
- /**
- * Returns the path SRLG values.
- *
- * @return the srlgs
- */
- public List<Long> srlgs() {
- if (srlgs == null) {
- return null;
- }
- return ImmutableList.copyOf(srlgs);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(cost, delay, srlgs);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof TePathAttributes) {
- TePathAttributes that = (TePathAttributes) object;
- return Objects.equal(cost, that.cost) &&
- Objects.equal(delay, that.delay) &&
- Objects.equal(srlgs, that.srlgs);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("cost", cost)
- .add("delay", delay)
- .add("srlgs", srlgs)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeTunnelId.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeTunnelId.java
deleted file mode 100644
index 0744608..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TeTunnelId.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-/**
- * Representation of a TE tunnel identifier.
- */
-public class TeTunnelId {
- private final long srcTeNodeId;
- private final long dstTeNodeId;
- private final long tunnelId;
-
- /**
- * Create a TE tunnel identifier.
- *
- * @param srcTeNodeId source TE node id
- * @param dstTeNodeId destination TE node id
- * @param tunnelId tunnel id
- */
- public TeTunnelId(long srcTeNodeId, long dstTeNodeId, long tunnelId) {
- this.srcTeNodeId = srcTeNodeId;
- this.dstTeNodeId = dstTeNodeId;
- this.tunnelId = tunnelId;
- }
-
- /**
- * Returns the source TE node identifier of the tunnel.
- *
- * @return the source TE node id
- */
- public long sourceTeNodeId() {
- return srcTeNodeId;
- }
-
- /**
- * Returns the destination TE node identifier of the tunnel.
- *
- * @return the destination TE node id
- */
- public long destinationTeNodeId() {
- return dstTeNodeId;
- }
-
- /**
- * Returns the tunnel identifier.
- *
- * @return the tunnel id
- */
- public long tunnelId() {
- return tunnelId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(srcTeNodeId, dstTeNodeId, tunnelId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof TeTunnelId) {
- TeTunnelId that = (TeTunnelId) object;
- return (srcTeNodeId == that.srcTeNodeId) &&
- (dstTeNodeId == that.dstTeNodeId) &&
- (tunnelId == that.tunnelId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("srcTeNodeId", srcTeNodeId)
- .add("dstTeNodeId", dstTeNodeId)
- .add("tunnelId", tunnelId)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TunnelProtectionType.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TunnelProtectionType.java
deleted file mode 100644
index 34174a0..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/TunnelProtectionType.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetopology.management.api.link;
-
-/**
- * Represents the tunnel protection type.
- */
-public enum TunnelProtectionType {
-
- /**
- * Represents unprotected.
- */
- UNPROTECTED(0),
-
- /**
- * Represents extra traffic.
- */
- EXTRA_TRAFFIC(1),
-
- /**
- * Represents shared.
- */
- SHARED(2),
-
- /**
- * Represents one-for-one.
- */
- ONE_FOR_ONE(3),
-
- /**
- * Represents one-plus-one.
- */
- ONE_PLUS_ONE(4),
-
- /**
- * Represents enhanced.
- */
- ENHANCED(5);
-
- private int value;
-
- TunnelProtectionType(int value) {
- this.value = value;
- }
-
- /**
- * Returns the value of the tunnel protection type.
- *
- * @return value of tunnel protection type
- */
- public int value() {
- return value;
- }
-
- /**
- * Returns the tunnel protection type constant corresponding to the given
- * string. Returns null when string conversion fails or converted integer
- * value is not recognized.
- *
- * @param s input string
- * @return corresponding protection type constant
- */
- public static TunnelProtectionType of(String s) {
- try {
- int tmpVal = Integer.parseInt(s);
- return of(tmpVal);
- } catch (NumberFormatException ignored) {
- }
- return null;
- }
-
- /**
- * Returns the tunnel protection type constant corresponding to the
- * given integer. Returns null when the integer value is not recognized.
- *
- * @param value integer value
- * @return corresponding protection type constant
- */
- public static TunnelProtectionType of(int value) {
- switch (value) {
- case 0:
- return UNPROTECTED;
- case 1:
- return EXTRA_TRAFFIC;
- case 2:
- return SHARED;
- case 3:
- return ONE_FOR_ONE;
- case 4:
- return ONE_PLUS_ONE;
- case 5:
- return ENHANCED;
- default:
- return null;
- }
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnderlayAbstractPath.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnderlayAbstractPath.java
deleted file mode 100644
index 43bfd75..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnderlayAbstractPath.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.Lists;
-
-/**
- * Represents the common definition of an underlay path that supports a TE link.
- */
-public class UnderlayAbstractPath {
- private final List<PathElement> pathElements;
- private final Boolean loose;
-
- /**
- * Creates a underlay abstract path.
- *
- * @param pathElements the list of elements along the path
- * @param loose loose if true, or otherwise strict
- */
- public UnderlayAbstractPath(List<PathElement> pathElements, Boolean loose) {
- this.pathElements = Lists.newArrayList(pathElements);
- this.loose = loose;
- }
-
- /**
- * Returns the loose flag, indicating whether the path is loose or strict.
- *
- * @return true if the path is loose, false if it is strict.
- */
- public Boolean loose() {
- return loose;
- }
-
- /**
- * Returns the list of path elements.
- *
- * @return list of path elements
- */
- public List<PathElement> pathElements() {
- return Collections.unmodifiableList(pathElements);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(pathElements, loose);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof UnderlayAbstractPath) {
- UnderlayAbstractPath other = (UnderlayAbstractPath) obj;
- return Objects.equals(pathElements, other.pathElements) &&
- Objects.equals(loose, other.loose);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("pathElements", pathElements)
- .add("loose", loose)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnderlayBackupPath.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnderlayBackupPath.java
deleted file mode 100644
index 5b1a33f..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnderlayBackupPath.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import java.util.List;
-import java.util.Objects;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Represents a list of backup service paths on the underlay topology that
- * protect the underlay primary path.
- */
-public class UnderlayBackupPath extends UnderlayAbstractPath {
- private final long index;
-
- /**
- * Creates a underlay backup path.
- *
- * @param index the path index
- * @param pathElements list of backup service paths
- * @param loose loose if true; restrict otherwise
- */
- public UnderlayBackupPath(long index, List<PathElement> pathElements,
- Boolean loose) {
- super(pathElements, loose);
- this.index = index;
- }
-
- /**
- * Returns the path index.
- *
- * @return path index
- */
- public long index() {
- return index;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), index);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof UnderlayBackupPath) {
- if (!super.equals(obj)) {
- return false;
- }
- UnderlayBackupPath that = (UnderlayBackupPath) obj;
- return this.index == that.index;
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("index", index)
- .add("pathElements", pathElements())
- .add("loose", loose())
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnderlayPath.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnderlayPath.java
deleted file mode 100644
index e244abb..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnderlayPath.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-import java.util.List;
-
-/**
- * Represents the TE link underlay path and tunnel data.
- */
-public class UnderlayPath {
- private final UnderlayPrimaryPath primaryPath;
- private final List<UnderlayBackupPath> backupPaths;
- private final TunnelProtectionType tunnelProtectionType;
- private final long srcTtpId;
- private final long dstTtpId;
- private final TeTunnelId teTunnelId;
-
- /**
- * Creates a underlay path.
- *
- * @param primaryPath the underlay primary path
- * @param backupPaths the underlay backup paths
- * @param tunnelProtectionType the supporting tunnel protection type to set
- * @param srcTtpId the source tunnel termination point id
- * @param dstTtpId the destination tunnel termination point id
- * @param teTunnelId the supporting TE tunnel id
- */
- public UnderlayPath(UnderlayPrimaryPath primaryPath,
- List<UnderlayBackupPath> backupPaths,
- TunnelProtectionType tunnelProtectionType,
- long srcTtpId,
- long dstTtpId,
- TeTunnelId teTunnelId) {
- this.primaryPath = primaryPath;
- this.backupPaths = backupPaths != null ?
- Lists.newArrayList(backupPaths) : null;
- this.tunnelProtectionType = tunnelProtectionType;
- this.srcTtpId = srcTtpId;
- this.dstTtpId = dstTtpId;
- this.teTunnelId = teTunnelId;
- }
-
- /**
- * Creates a underlay path based on a TE link.
- *
- * @param link the TE link
- */
- public UnderlayPath(TeLink link) {
- this.primaryPath = link.primaryPath();
- this.backupPaths = link.backupPaths() != null ?
- Lists.newArrayList(link.backupPaths()) : null;
- this.tunnelProtectionType = link.tunnelProtectionType();
- this.srcTtpId = link.sourceTtpId();
- this.dstTtpId = link.destinationTtpId();
- this.teTunnelId = link.teTunnelId();
- }
-
- /**
- * Returns the primary path.
- *
- * @return underlay primary path
- */
- public UnderlayPrimaryPath primaryPath() {
- return primaryPath;
- }
-
- /**
- * Returns the backup paths.
- *
- * @return list of underlay backup paths
- */
- public List<UnderlayBackupPath> backupPaths() {
- if (backupPaths == null) {
- return null;
- }
- return ImmutableList.copyOf(backupPaths);
- }
-
- /**
- * Returns the supporting tunnel protection type.
- *
- * @return the supporting tunnel protection type
- */
- public TunnelProtectionType tunnelProtectionType() {
- return tunnelProtectionType;
- }
-
- /**
- * Returns the supporting TE tunnel's source tunnel termination point
- * identifier.
- *
- * @return the supporting source TTP id
- */
- public long srcTtpId() {
- return srcTtpId;
- }
-
- /**
- * Returns the supporting TE tunnel's destination tunnel termination
- * point identifier.
- *
- * @return the destination TTP id
- */
- public long dstTtpId() {
- return dstTtpId;
- }
-
- /**
- * Returns the supporting TE tunnel identifier.
- *
- * @return the supporting tunnel id
- */
- public TeTunnelId teTunnelId() {
- return teTunnelId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(primaryPath, backupPaths, tunnelProtectionType,
- srcTtpId, dstTtpId, teTunnelId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof UnderlayPath) {
- UnderlayPath that = (UnderlayPath) object;
- return Objects.equal(primaryPath, that.primaryPath) &&
- Objects.equal(backupPaths, that.backupPaths) &&
- Objects.equal(tunnelProtectionType, that.tunnelProtectionType) &&
- Objects.equal(srcTtpId, that.srcTtpId) &&
- Objects.equal(dstTtpId, that.dstTtpId) &&
- Objects.equal(teTunnelId, that.teTunnelId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("primaryPath", primaryPath)
- .add("backupPaths", backupPaths)
- .add("tunnelProtectionType", tunnelProtectionType)
- .add("srcTtpId", srcTtpId)
- .add("dstTtpId", dstTtpId)
- .add("teTunnelId", teTunnelId)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnderlayPrimaryPath.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnderlayPrimaryPath.java
deleted file mode 100644
index d65dccd..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnderlayPrimaryPath.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import java.util.List;
-
-/**
- * Represents the underlay primary path that supports a TE link.
- */
-public class UnderlayPrimaryPath extends UnderlayAbstractPath {
- // Underlay primary path currently has the same data structure defined in
- // the underlay abstract path. It may be extended per standard definitions.
-
- /**
- * Creates an instance of UnderlayPrimaryPath.
- *
- * @param pathElements the list of elements along the path
- * @param loose loose if true, or otherwise strict
- */
- public UnderlayPrimaryPath(List<PathElement> pathElements, Boolean loose) {
- super(pathElements, loose);
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnnumberedLink.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnnumberedLink.java
deleted file mode 100644
index d4f0638..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/UnnumberedLink.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.link;
-
-import com.google.common.base.MoreObjects;
-import org.onlab.packet.IpAddress;
-
-import java.util.Objects;
-
-/**
- * Implementation of unnumbered link as an element type.
- */
-public class UnnumberedLink implements ElementType {
- private final IpAddress routerId;
- private final long interfaceId;
-
- /**
- * Creates a unnumbered link.
- *
- * @param routerId the router id to set
- * @param interfaceId the interface id to set
- */
- public UnnumberedLink(IpAddress routerId, long interfaceId) {
- this.routerId = routerId;
- this.interfaceId = interfaceId;
- }
-
- /**
- * Returns the router identifier.
- *
- * @return router id
- */
- public IpAddress routerId() {
- return routerId;
- }
-
- /**
- * Returns the interface identifier.
- *
- * @return interface id
- */
- public long interfaceId() {
- return interfaceId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(routerId, interfaceId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof UnnumberedLink) {
- UnnumberedLink other = (UnnumberedLink) obj;
- return
- Objects.equals(routerId, other.routerId) &&
- Objects.equals(interfaceId, other.interfaceId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("routerId", routerId)
- .add("interfaceId", interfaceId)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/package-info.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/package-info.java
deleted file mode 100644
index f12499d..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/link/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * TE link API.
- */
-package org.onosproject.tetopology.management.api.link;
\ No newline at end of file
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/AbstractConnectivity.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/AbstractConnectivity.java
deleted file mode 100644
index 712c7bd..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/AbstractConnectivity.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import java.util.BitSet;
-import java.util.Collections;
-import java.util.List;
-
-import com.google.common.collect.Lists;
-import org.onosproject.tetopology.management.api.link.ElementType;
-import org.onosproject.tetopology.management.api.link.TePathAttributes;
-import org.onosproject.tetopology.management.api.link.UnderlayAbstractPath;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-/**
- * The abstraction of a TE node internal connectivity to link
- * termination points.
- */
-public class AbstractConnectivity {
- // list of elements that can be constrained/connected to
- private final List<ElementType> constrainingElements;
- private final BitSet flags;
- private final TePathAttributes teAttributes;
- private final UnderlayAbstractPath underlayPath;
-
- /**
- * Creates an abstract connectivity instance.
- *
- * @param constrainingElements list of elements that can be constrained
- * or connected to
- * @param flags indicate whether this connectivity is usable
- * @param teAttributes the connectivity path TE attributes
- * @param underlayPath the underlay path
- */
- public AbstractConnectivity(List<ElementType> constrainingElements,
- BitSet flags,
- TePathAttributes teAttributes,
- UnderlayAbstractPath underlayPath) {
- this.constrainingElements = Lists.newArrayList(constrainingElements);
- this.flags = flags;
- this.teAttributes = teAttributes;
- this.underlayPath = underlayPath;
- }
-
- /**
- * Returns the "constraining elements" that can be constrained
- * or connected to "from" element.
- *
- * @return the "constraining elements" of the connectivity
- */
- public List<ElementType> constrainingElements() {
- return Collections.unmodifiableList(constrainingElements);
- }
-
- /**
- * Returns the flags indicating if the connectivity is usable.
- *
- * @return flags of the connectivity
- */
- public BitSet flags() {
- return flags;
- }
-
- /**
- * Returns the TE attributes of the connectivity.
- *
- * @return the TE attributes
- */
- public TePathAttributes teAttributes() {
- return teAttributes;
- }
-
- /**
- * Returns the underlay path.
- *
- * @return the underlay path
- */
- public UnderlayAbstractPath underlayPath() {
- return underlayPath;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(constrainingElements, flags,
- teAttributes, underlayPath);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof AbstractConnectivity) {
- AbstractConnectivity that = (AbstractConnectivity) object;
- return Objects.equal(constrainingElements, that.constrainingElements) &&
- Objects.equal(flags, that.flags) &&
- Objects.equal(teAttributes, that.teAttributes) &&
- Objects.equal(underlayPath, that.underlayPath);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("constrainingElements", constrainingElements)
- .add("flags", flags)
- .add("teAttributes", teAttributes)
- .add("underlayPath", underlayPath)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/CommonNodeData.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/CommonNodeData.java
deleted file mode 100644
index 35daf8b..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/CommonNodeData.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import java.util.BitSet;
-
-import org.onosproject.tetopology.management.api.TeStatus;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-/**
- * Representation of common node attributes.
- */
-public class CommonNodeData {
- private final String name;
- private final TeStatus adminStatus;
- private final TeStatus opStatus;
- private final BitSet flags;
-
- /**
- * Creates a common node data instance.
- *
- * @param name the TE node name
- * @param adminStatus the admin status
- * @param opStatus the operational status
- * @param flags the node flags
- */
- public CommonNodeData(String name, TeStatus adminStatus,
- TeStatus opStatus, BitSet flags) {
- this.name = name;
- this.adminStatus = adminStatus;
- this.opStatus = opStatus;
- this.flags = flags;
- }
-
- /**
- * Creates a common node data instance based on a given TE node.
- *
- * @param node the given TE node
- */
- public CommonNodeData(TeNode node) {
- this.name = node.name();
- this.adminStatus = node.adminStatus();
- this.opStatus = node.opStatus();
- this.flags = node.flags();
- }
-
- /**
- * Returns the TE node name.
- *
- * @return the name
- */
- public String name() {
- return name;
- }
-
- /**
- * Returns the administrative status.
- *
- * @return the admin status
- */
- public TeStatus adminStatus() {
- return adminStatus;
- }
-
- /**
- * Returns the operational status.
- *
- * @return the operational status
- */
- public TeStatus opStatus() {
- return opStatus;
- }
-
- /**
- * Returns the flags in the common node data.
- *
- * @return the flags
- */
- public BitSet flags() {
- return flags;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(name, adminStatus, opStatus, flags);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof CommonNodeData) {
- CommonNodeData that = (CommonNodeData) object;
- return Objects.equal(name, that.name) &&
- Objects.equal(adminStatus, that.adminStatus) &&
- Objects.equal(opStatus, that.opStatus) &&
- Objects.equal(flags, that.flags);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("name", name)
- .add("adminStatus", adminStatus)
- .add("opStatus", opStatus)
- .add("flags", flags)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/ConnectivityMatrix.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/ConnectivityMatrix.java
deleted file mode 100644
index b30d110..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/ConnectivityMatrix.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.onosproject.tetopology.management.api.link.ElementType;
-import org.onosproject.tetopology.management.api.link.TePathAttributes;
-import org.onosproject.tetopology.management.api.link.UnderlayAbstractPath;
-
-import java.util.BitSet;
-import java.util.List;
-
-/**
- * Represents node's switching limitations.
- */
-public class ConnectivityMatrix extends AbstractConnectivity {
- /**
- * Indicates that switching is disallowed.
- */
- public static final short BIT_DISALLOWED = 0;
-
- /**
- * Indicates that an alternative switching connection path
- * is available.
- */
- public static final short BIT_ALTERNATIVE_PATH_AVAILABLE = 1;
-
- /**
- * Indicates that switching in this node is disabled.
- */
- public static final short BIT_DISABLED = 2;
-
- private final long key;
- private final ElementType from;
- // list of elements that can be merged with the "from" element
- private final List<ElementType> mergingList;
-
- /**
- * Creates a connectivity matrix instance.
- *
- * @param key the connectivity matrix key
- * @param from the "from" element (e.g. TE link id or
- * label) in the matrix
- * @param mergingList the list of elements that can be merged
- * with the "from" element
- * @param constrainingElements the list of elements that can be constrained
- * or connected to the "from" element
- * @param flags the indicator whether this connectivity
- * matrix is usable
- * @param teAttributes the connectivity TE attributes of this matrix
- * @param underlayPath the underlay path of the matrix
- */
- public ConnectivityMatrix(long key,
- ElementType from,
- List<ElementType> mergingList,
- List<ElementType> constrainingElements,
- BitSet flags,
- TePathAttributes teAttributes,
- UnderlayAbstractPath underlayPath) {
- super(constrainingElements, flags, teAttributes, underlayPath);
- this.key = key;
- this.from = from;
- this.mergingList = mergingList != null ?
- Lists.newArrayList(mergingList) : null;
- }
-
- /**
- * Returns the key.
- *
- * @return connectivity matrix key
- */
- public long key() {
- return key;
- }
-
- /**
- * Returns the "from" element of a connectivity matrix.
- *
- * @return the "from" of the connectivity matrix
- */
- public ElementType from() {
- return from;
- }
-
- /**
- * Returns the "merging list" can be merged with the "from" element.
- *
- * @return the "merging list" of the connectivity matrix
- */
- public List<ElementType> mergingList() {
- if (mergingList == null) {
- return null;
- }
- return ImmutableList.copyOf(mergingList);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(key, from, mergingList, super.hashCode());
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof ConnectivityMatrix) {
- if (!super.equals(object)) {
- return false;
- }
- ConnectivityMatrix that = (ConnectivityMatrix) object;
- return Objects.equal(this.key, that.key) &&
- Objects.equal(this.from, that.from) &&
- Objects.equal(this.mergingList, that.mergingList);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("key", key)
- .add("from", from)
- .add("mergingList", mergingList)
- .add("constrainingElements", constrainingElements())
- .add("flags", flags())
- .add("teAttributes", teAttributes())
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/ConnectivityMatrixKey.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/ConnectivityMatrixKey.java
deleted file mode 100644
index 598954e..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/ConnectivityMatrixKey.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Objects;
-
-/**
- * Representation of a TE connectivity matrix entry key.
- */
-public class ConnectivityMatrixKey extends TeNodeKey {
- private final long entryId;
-
- /**
- * Creates a connectivity matrix key.
- *
- * @param providerId provider identifier
- * @param clientId client identifier
- * @param topologyId topology identifier
- * @param teNodeId TE node identifier
- * @param entryId connectivity matrix entry id
- */
- public ConnectivityMatrixKey(long providerId, long clientId,
- long topologyId, long teNodeId,
- long entryId) {
- super(providerId, clientId, topologyId, teNodeId);
- this.entryId = entryId;
- }
-
- /**
- * Creates a connectivity matrix key base on a given TE node key.
- *
- * @param teNodeKey TE node key
- * @param entryId connectivity matrix entry id
- */
- public ConnectivityMatrixKey(TeNodeKey teNodeKey, long entryId) {
- super(teNodeKey.providerId(), teNodeKey.clientId(),
- teNodeKey.topologyId(), teNodeKey.teNodeId());
- this.entryId = entryId;
- }
-
- /**
- * Returns the TE node key.
- *
- * @return the TE node key
- */
- public TeNodeKey teNodekey() {
- return new TeNodeKey(providerId(), clientId(), topologyId(), teNodeId());
- }
-
- /**
- * Returns the connectivity matrix entry identifier.
- *
- * @return the connectivity matrix entry id
- */
- public long entryId() {
- return entryId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), entryId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof ConnectivityMatrixKey) {
- if (!super.equals(object)) {
- return false;
- }
- ConnectivityMatrixKey that = (ConnectivityMatrixKey) object;
- return Objects.equal(this.entryId, that.entryId);
- }
- return false;
- }
-
- /**
- * Returns ToStringHelper with additional entry identifier.
- *
- * @return toStringHelper
- */
- protected ToStringHelper toConnMatrixKeyStringHelper() {
- return toTeNodeKeyStringHelper().add("entryId", entryId);
- }
-
- @Override
- public String toString() {
- return toConnMatrixKeyStringHelper().toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/DefaultNetworkNode.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/DefaultNetworkNode.java
deleted file mode 100644
index 6062617..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/DefaultNetworkNode.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.onosproject.tetopology.management.api.KeyId;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Default network node implementation.
- */
-public class DefaultNetworkNode implements NetworkNode {
- private final KeyId id;
- private final List<NetworkNodeKey> supportingNodeIds;
- private final TeNode teNode;
- private final Map<KeyId, TerminationPoint> tps;
-
-
- /**
- * Creates a network node instance.
- *
- * @param id network node identifier
- * @param nodeIds support node identifiers
- * @param teNode te parameter of the node
- * @param tps the tps to set
- */
- public DefaultNetworkNode(KeyId id,
- List<NetworkNodeKey> nodeIds,
- TeNode teNode,
- Map<KeyId, TerminationPoint> tps) {
- this.id = id;
- this.supportingNodeIds = nodeIds != null ?
- Lists.newArrayList(nodeIds) : null;
- this.teNode = teNode;
- this.tps = tps != null ? Maps.newHashMap(tps) : null;
- }
-
- /**
- * Returns the node identifier.
- *
- * @return node identifier
- */
- @Override
- public KeyId nodeId() {
- return id;
- }
-
- /**
- * Returns the list of supporting node identifiers for this node.
- *
- * @return list of supporting node identifiers
- */
- @Override
- public List<NetworkNodeKey> supportingNodeIds() {
- if (supportingNodeIds == null) {
- return null;
- }
- return ImmutableList.copyOf(supportingNodeIds);
- }
-
- /**
- * Returns the node TE attributes.
- *
- * @return TE attributes of this node
- */
- @Override
- public TeNode teNode() {
- return teNode;
- }
-
- /**
- * Returns the list of termination points associated with this node.
- *
- * @return a list of termination points
- */
- @Override
- public Map<KeyId, TerminationPoint> terminationPoints() {
- if (tps == null) {
- return null;
- }
- return ImmutableMap.copyOf(tps);
- }
-
- /**
- * Returns the termination point.
- *
- * @return the termination point
- */
- @Override
- public TerminationPoint terminationPoint(KeyId tpId) {
- return tps.get(tpId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(id, supportingNodeIds, teNode, tps);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof DefaultNetworkNode) {
- DefaultNetworkNode that = (DefaultNetworkNode) object;
- return Objects.equal(id, that.id) &&
- Objects.equal(supportingNodeIds, that.supportingNodeIds) &&
- Objects.equal(teNode, that.teNode) &&
- Objects.equal(tps, that.tps);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("id", id)
- .add("supportingNodeIds", supportingNodeIds)
- .add("teNode", teNode)
- .add("tps", tps)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/DefaultTeNode.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/DefaultTeNode.java
deleted file mode 100644
index 71cd9c9..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/DefaultTeNode.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.onosproject.tetopology.management.api.TeStatus;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-
-import java.util.BitSet;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-/**
- * The default implementation of TE Node.
- */
-public class DefaultTeNode implements TeNode {
- private final long teNodeId;
- private final TeTopologyKey underlayTopologyId;
- private final TeNodeKey supportTeNodeId;
- private final TeNodeKey sourceTeNodeId;
- private final CommonNodeData teData;
- private final Map<Long, ConnectivityMatrix> connMatrices;
- private final List<Long> teLinkIds;
- private final Map<Long, TunnelTerminationPoint> ttps;
- private final List<Long> teTpIds;
-
- /**
- * Creates a TE node instance.
- *
- * @param teNodeId TE node identifier
- * @param underlayTopologyIdId the node underlay TE topology id
- * @param supportTeNodeId the supporting TE node id
- * @param sourceTeNodeId the source TE node id
- * @param teData the node common te data
- * @param connMatrices the connectivity matrix table
- * @param teLinkIds the list of TE link ids originating from the node
- * @param ttps the list of tunnel termination points
- * @param teTpIds the currently known termination point ids
- */
- public DefaultTeNode(long teNodeId,
- TeTopologyKey underlayTopologyIdId,
- TeNodeKey supportTeNodeId,
- TeNodeKey sourceTeNodeId,
- CommonNodeData teData,
- Map<Long, ConnectivityMatrix> connMatrices,
- List<Long> teLinkIds,
- Map<Long, TunnelTerminationPoint> ttps,
- List<Long> teTpIds) {
- this.teNodeId = teNodeId;
- this.underlayTopologyId = underlayTopologyIdId;
- this.supportTeNodeId = supportTeNodeId;
- this.sourceTeNodeId = sourceTeNodeId;
- this.teData = teData;
- this.connMatrices = connMatrices != null ?
- Maps.newHashMap(connMatrices) : null;
- this.teLinkIds = teLinkIds != null ?
- Lists.newArrayList(teLinkIds) : null;
- this.ttps = ttps != null ? Maps.newHashMap(ttps) : null;
- this.teTpIds = teTpIds != null ?
- Lists.newArrayList(teTpIds) : null;
- }
-
- @Override
- public long teNodeId() {
- return teNodeId;
- }
-
- @Override
- public String name() {
- if (teData == null) {
- return null;
- }
- return teData.name();
- }
-
- @Override
- public BitSet flags() {
- if (teData == null) {
- return null;
- }
- return teData.flags();
- }
-
- @Override
- public TeTopologyKey underlayTeTopologyId() {
- return underlayTopologyId;
- }
-
- @Override
- public TeNodeKey supportingTeNodeId() {
- return supportTeNodeId;
- }
-
- @Override
- public TeNodeKey sourceTeNodeId() {
- return sourceTeNodeId;
- }
-
- @Override
- public Map<Long, ConnectivityMatrix> connectivityMatrices() {
- if (connMatrices == null) {
- return null;
- }
- return ImmutableMap.copyOf(connMatrices);
- }
-
- @Override
- public ConnectivityMatrix connectivityMatrix(long entryId) {
- return connMatrices.get(entryId);
- }
-
- @Override
- public List<Long> teLinkIds() {
- if (teLinkIds == null) {
- return null;
- }
- return ImmutableList.copyOf(teLinkIds);
- }
-
- @Override
- public Map<Long, TunnelTerminationPoint> tunnelTerminationPoints() {
- if (ttps == null) {
- return null;
- }
- return ImmutableMap.copyOf(ttps);
- }
-
- @Override
- public TunnelTerminationPoint tunnelTerminationPoint(long ttpId) {
- return ttps.get(ttpId);
- }
-
- @Override
- public TeStatus adminStatus() {
- if (teData == null) {
- return null;
- }
- return teData.adminStatus();
- }
-
- @Override
- public TeStatus opStatus() {
- if (teData == null) {
- return null;
- }
- return teData.opStatus();
- }
-
- @Override
- public List<Long> teTerminationPointIds() {
- return Collections.unmodifiableList(teTpIds);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(teNodeId, underlayTopologyId,
- supportTeNodeId, sourceTeNodeId, teData,
- connMatrices, teLinkIds, ttps, teTpIds);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof DefaultTeNode) {
- DefaultTeNode that = (DefaultTeNode) object;
- return Objects.equal(teNodeId, that.teNodeId) &&
- Objects.equal(underlayTopologyId, that.underlayTopologyId) &&
- Objects.equal(supportTeNodeId, that.supportTeNodeId) &&
- Objects.equal(sourceTeNodeId, that.sourceTeNodeId) &&
- Objects.equal(teData, that.teData) &&
- Objects.equal(connMatrices, that.connMatrices) &&
- Objects.equal(teLinkIds, that.teLinkIds) &&
- Objects.equal(ttps, that.ttps) &&
- Objects.equal(teTpIds, that.teTpIds);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("teNodeId", teNodeId)
- .add("underlayTopologyId", underlayTopologyId)
- .add("supportTeNodeId", supportTeNodeId)
- .add("sourceTeNodeId", sourceTeNodeId)
- .add("teData", teData)
- .add("connMatrices", connMatrices)
- .add("teLinkIds", teLinkIds)
- .add("ttps", ttps)
- .add("teTpIds", teTpIds)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/DefaultTerminationPoint.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/DefaultTerminationPoint.java
deleted file mode 100644
index b3afd85..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/DefaultTerminationPoint.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.onosproject.tetopology.management.api.KeyId;
-
-import java.util.List;
-
-/**
- * The default implementation of TE termination point.
- */
-public class DefaultTerminationPoint implements TerminationPoint {
- private final KeyId tpId;
- private final List<TerminationPointKey> supportingTpIds;
- private final Long teTpId;
-
- /**
- * Creates a termination point.
- *
- * @param tpId termination point identifier
- * @param tps support termination point identifier
- * @param teTpId TE termination point identifier
- */
- public DefaultTerminationPoint(KeyId tpId,
- List<TerminationPointKey> tps,
- Long teTpId) {
- this.tpId = tpId;
- this.supportingTpIds = tps != null ? Lists.newArrayList(tps) : null;
- this.teTpId = teTpId;
- }
-
- @Override
- public KeyId tpId() {
- return tpId;
- }
-
- @Override
- public Long teTpId() {
- return teTpId;
- }
-
- @Override
- public List<TerminationPointKey> supportingTpIds() {
- if (supportingTpIds == null) {
- return null;
- }
- return ImmutableList.copyOf(supportingTpIds);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(tpId, supportingTpIds, teTpId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof DefaultTerminationPoint) {
- DefaultTerminationPoint that = (DefaultTerminationPoint) object;
- return Objects.equal(tpId, that.tpId) &&
- Objects.equal(supportingTpIds, that.supportingTpIds) &&
- Objects.equal(teTpId, that.teTpId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("tpId", tpId)
- .add("supportingTpIds", supportingTpIds)
- .add("teTpId", teTpId)
- .toString();
- }
-
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/DefaultTunnelTerminationPoint.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/DefaultTunnelTerminationPoint.java
deleted file mode 100644
index efe82f1..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/DefaultTunnelTerminationPoint.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import java.util.Arrays;
-import java.util.BitSet;
-import java.util.List;
-
-import org.onosproject.tetopology.management.api.EncodingType;
-import org.onosproject.tetopology.management.api.SwitchingType;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-/**
- * Default implementation of a tunnel termination point.
- */
-public class DefaultTunnelTerminationPoint implements TunnelTerminationPoint {
- private final long ttpId;
- private final SwitchingType switchingLayer;
- private final EncodingType encodingLayer;
- private final BitSet flags;
- private final List<Long> interLayerLockList;
- private final List<LocalLinkConnectivity> localLinkConnectivityList;
- private final float[] availAdaptBandwidth;
- private final TtpKey supportTtpKey;
-
- /**
- * Create a tunnel termination point.
- *
- * @param ttpId tunnel termination point id
- * @param switchingLayer switching network layer to which this
- * TTP belongs
- * @param encodingLayer encoding layer to which this TTP belongs
- * @param flags the TTP flags
- * @param interLayerLockList the supported inter-layer locks
- * @param localLinkConnectivityList the local link connectivity list
- * @param availAdaptBandwidth the remaining adaptation bandwidth
- * at each priority level
- * @param supportTtpKey supporting TTP key from underlay topology
- */
- public DefaultTunnelTerminationPoint(long ttpId,
- SwitchingType switchingLayer,
- EncodingType encodingLayer,
- BitSet flags,
- List<Long> interLayerLockList,
- List<LocalLinkConnectivity> localLinkConnectivityList,
- float[] availAdaptBandwidth,
- TtpKey supportTtpKey) {
- this.ttpId = ttpId;
- this.switchingLayer = switchingLayer;
- this.encodingLayer = encodingLayer;
- this.flags = flags;
- this.interLayerLockList = interLayerLockList != null ?
- Lists.newArrayList(interLayerLockList) : null;
- this.localLinkConnectivityList = localLinkConnectivityList != null ?
- Lists.newArrayList(localLinkConnectivityList) : null;
- this.availAdaptBandwidth = availAdaptBandwidth != null ?
- Arrays.copyOf(availAdaptBandwidth,
- availAdaptBandwidth.length) : null;
- this.supportTtpKey = supportTtpKey;
- }
-
- @Override
- public long ttpId() {
- return ttpId;
- }
-
- @Override
- public SwitchingType switchingLayer() {
- return switchingLayer;
- }
-
- @Override
- public EncodingType encodingLayer() {
- return encodingLayer;
- }
-
- @Override
- public BitSet flags() {
- return flags;
- }
-
- @Override
- public List<Long> interLayerLockList() {
- if (interLayerLockList == null) {
- return null;
- }
- return ImmutableList.copyOf(interLayerLockList);
- }
-
- @Override
- public List<LocalLinkConnectivity> localLinkConnectivityList() {
- if (localLinkConnectivityList == null) {
- return null;
- }
- return ImmutableList.copyOf(localLinkConnectivityList);
- }
-
- @Override
- public float[] availAdaptBandwidth() {
- if (availAdaptBandwidth == null) {
- return null;
- }
- return Arrays.copyOf(availAdaptBandwidth, availAdaptBandwidth.length);
- }
-
- @Override
- public TtpKey supportingTtpId() {
- return supportTtpKey;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(ttpId, switchingLayer, encodingLayer, flags,
- interLayerLockList, localLinkConnectivityList,
- Arrays.hashCode(availAdaptBandwidth), supportTtpKey);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof DefaultTunnelTerminationPoint) {
- DefaultTunnelTerminationPoint that = (DefaultTunnelTerminationPoint) object;
- return Objects.equal(ttpId, that.ttpId) &&
- Objects.equal(switchingLayer, that.switchingLayer) &&
- Objects.equal(encodingLayer, that.encodingLayer) &&
- Objects.equal(flags, that.flags) &&
- Objects.equal(interLayerLockList, that.interLayerLockList) &&
- Objects.equal(localLinkConnectivityList, that.localLinkConnectivityList) &&
- Arrays.equals(availAdaptBandwidth, that.availAdaptBandwidth) &&
- Objects.equal(supportTtpKey, that.supportTtpKey);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("ttpId", ttpId)
- .add("switchingLayer", switchingLayer)
- .add("encodingLayer", encodingLayer)
- .add("flags", flags)
- .add("interLayerLockList", interLayerLockList)
- .add("localLinkConnectivityList", localLinkConnectivityList)
- .add("availAdaptBandwidth", availAdaptBandwidth)
- .add("supportTtpKey", supportTtpKey)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/LocalLinkConnectivity.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/LocalLinkConnectivity.java
deleted file mode 100644
index ae8f314..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/LocalLinkConnectivity.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import org.onosproject.tetopology.management.api.link.ElementType;
-import org.onosproject.tetopology.management.api.link.TePathAttributes;
-import org.onosproject.tetopology.management.api.link.UnderlayAbstractPath;
-
-import java.util.BitSet;
-import java.util.List;
-
-/**
- * The connectivity between tunnel termination point and link termination
- * points.
- */
-public class LocalLinkConnectivity extends AbstractConnectivity {
- /**
- * Indicates that the link connectivity is disabled.
- */
- public static final short BIT_DISABLED = 0;
-
- /**
- * Indicates that an alternative path of the link connection is
- * available.
- */
- public static final short BIT_ALTERNATIVE_PATH_AVAILABLE = 1;
-
- /**
- * Creates a local link connectivity instance.
- *
- * @param constrainingElements list of elements that can be constrained
- * or connected to
- * @param flags indicate whether this connectivity is usable
- * @param teAttributes the connectivity path TE attributes
- * @param underlayPath the underlay path
- */
- public LocalLinkConnectivity(List<ElementType> constrainingElements, BitSet flags,
- TePathAttributes teAttributes,
- UnderlayAbstractPath underlayPath) {
- super(constrainingElements, flags, teAttributes, underlayPath);
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/NetworkNode.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/NetworkNode.java
deleted file mode 100644
index 3d45806..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/NetworkNode.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import java.util.List;
-import java.util.Map;
-
-import org.onosproject.tetopology.management.api.KeyId;
-
-/**
- * Abstraction of a network node.
- */
-public interface NetworkNode {
-
- /**
- * Returns the node identifier.
- *
- * @return node identifier
- */
- KeyId nodeId();
-
- /**
- * Returns the supporting node identifiers.
- *
- * @return list of the ids of the supporting nodes
- */
- List<NetworkNodeKey> supportingNodeIds();
-
- /**
- * Returns the node TE extension attributes.
- *
- * @return node TE extension attributes
- */
- TeNode teNode();
-
- /**
- * Returns a collection of currently known termination points.
- *
- * @return a collection of termination points associated with this node
- */
- Map<KeyId, TerminationPoint> terminationPoints();
-
- /**
- * Returns the termination point.
- *
- * @param tpId termination point id
- * @return value of termination point
- */
- TerminationPoint terminationPoint(KeyId tpId);
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/NetworkNodeEventSubject.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/NetworkNodeEventSubject.java
deleted file mode 100644
index 12fa5a0..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/NetworkNodeEventSubject.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import org.onosproject.tetopology.management.api.TeTopologyEventSubject;
-
-/**
- * Representation of a network node event.
- */
-public class NetworkNodeEventSubject implements TeTopologyEventSubject {
- private final NetworkNodeKey key;
- private final NetworkNode node;
-
- /**
- * Creates a network node event.
- *
- * @param key the network node global key
- * @param node the network node
- */
- public NetworkNodeEventSubject(NetworkNodeKey key, NetworkNode node) {
- this.key = key;
- this.node = node;
- }
-
- /**
- * Returns the network node global key.
- *
- * @return the key
- */
- public NetworkNodeKey key() {
- return key;
- }
-
- /**
- * Returns the network node.
- *
- * @return the node
- */
- public NetworkNode neworkNode() {
- return node;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(key, node);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof NetworkNodeEventSubject) {
- NetworkNodeEventSubject that = (NetworkNodeEventSubject) object;
- return Objects.equal(key, that.key) &&
- Objects.equal(node, that.node);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("key", key)
- .add("node", node)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/NetworkNodeKey.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/NetworkNodeKey.java
deleted file mode 100644
index 22b806a..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/NetworkNodeKey.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import org.onosproject.tetopology.management.api.KeyId;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-/**
- * Representation of a node key or node reference.
- */
-public class NetworkNodeKey {
- private final KeyId networkId;
- private final KeyId nodeId;
-
- /**
- * Creates an instance of NetworkNodeKey.
- *
- * @param networkId network identifier
- * @param nodeId node identifier
- */
- public NetworkNodeKey(KeyId networkId, KeyId nodeId) {
- this.networkId = networkId;
- this.nodeId = nodeId;
- }
-
- /**
- * Returns the network identifier.
- *
- * @return network identifier
- */
- public KeyId networkId() {
- return networkId;
- }
-
- /**
- * Returns the node identifier.
- *
- * @return node identifier
- */
- public KeyId nodeId() {
- return nodeId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(networkId, nodeId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof NetworkNodeKey) {
- NetworkNodeKey that = (NetworkNodeKey) object;
- return Objects.equal(this.networkId, that.networkId) &&
- Objects.equal(this.nodeId, that.nodeId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("networkId", networkId)
- .add("nodeId", nodeId)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/NodeTpKey.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/NodeTpKey.java
deleted file mode 100644
index 4ad3b29..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/NodeTpKey.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import org.onosproject.tetopology.management.api.KeyId;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-/**
- * Representation of a node's termination point key under a known network.
- */
-public class NodeTpKey {
- private final KeyId nodeId;
- private final KeyId tpId;
-
- /**
- * Creates a node's termination point key.
- *
- * @param nodeId node identifier
- * @param tpId termination point identifier
- */
- public NodeTpKey(KeyId nodeId, KeyId tpId) {
- this.nodeId = nodeId;
- this.tpId = tpId;
- }
-
- /**
- * Returns the node identifier.
- *
- * @return node id
- */
- public KeyId nodeId() {
- return nodeId;
- }
-
- /**
- * Returns the termination point identifier.
- *
- * @return termination point identifier
- */
- public KeyId tpId() {
- return tpId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(nodeId, tpId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof NodeTpKey) {
- NodeTpKey that = (NodeTpKey) object;
- return Objects.equal(nodeId, that.nodeId) &&
- Objects.equal(tpId, that.tpId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("nodeId", nodeId)
- .add("tpId", tpId)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TeNode.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TeNode.java
deleted file mode 100644
index 2387576..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TeNode.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import java.util.BitSet;
-import java.util.List;
-import java.util.Map;
-
-import org.onosproject.tetopology.management.api.TeStatus;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-
-/**
- * Abstraction of a TE node.
- */
-public interface TeNode {
- /**
- * Indicates that the TE node belongs to an abstract topology.
- */
- public static final short BIT_ABSTRACT = 0;
-
- /**
- * Indicates that the TE node is disabled.
- */
- public static final short BIT_DISABLED = 1;
-
- /**
- * Returns the TE node identifier.
- *
- * @return TE node identifier
- */
- long teNodeId();
-
- /**
- * Returns the TE node name.
- *
- * @return the te node name
- */
- String name();
-
- /**
- * Returns the flags.
- *
- * @return the flags
- */
- BitSet flags();
-
- /**
- * Returns the underlay TE topology identifier for the node.
- *
- * @return the underlay TE topology id
- */
- TeTopologyKey underlayTeTopologyId();
-
- /**
- * Returns the supporting TE node identifier.
- *
- * @return the id of the supporting node
- */
- TeNodeKey supportingTeNodeId();
-
- /**
- * Returns the source TE node identifier.
- *
- * @return the id of the source node
- */
- TeNodeKey sourceTeNodeId();
-
- /**
- * Returns the connectivity matrix table of the node.
- *
- * @return the connectivity matrix table
- */
- Map<Long, ConnectivityMatrix> connectivityMatrices();
-
- /**
- * Returns the connectivity matrix identified by its entry identifier.
- *
- * @param entryId connection matrix id
- * @return the connectivity matrix
- */
- ConnectivityMatrix connectivityMatrix(long entryId);
-
- /**
- * Returns a list of TE link identifiers originating from the node.
- *
- * @return a list of TE link ids
- */
- List<Long> teLinkIds();
-
- /**
- * Returns a collection of currently known tunnel termination points.
- *
- * @return a collection of tunnel termination points associated with this node
- */
- Map<Long, TunnelTerminationPoint> tunnelTerminationPoints();
-
- /**
- * Returns a tunnel termination point identified by its identifier.
- *
- * @param ttpId tunnel termination point identifier
- * @return the tunnel termination point
- */
- TunnelTerminationPoint tunnelTerminationPoint(long ttpId);
-
- /**
- * Returns the admin status.
- *
- * @return the adminStatus
- */
- TeStatus adminStatus();
-
- /**
- * Returns the operational status.
- *
- * @return the opStatus
- */
- TeStatus opStatus();
-
- /**
- * Returns a collection of currently known TE termination point identifiers.
- *
- * @return a collection of termination point ids associated with this node
- */
- List<Long> teTerminationPointIds();
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TeNodeEventSubject.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TeNodeEventSubject.java
deleted file mode 100644
index 6faa846..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TeNodeEventSubject.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import org.onosproject.tetopology.management.api.TeTopologyEventSubject;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-/**
- * Representation of TE node event.
- */
-public class TeNodeEventSubject implements TeTopologyEventSubject {
- private final TeNodeKey key;
- private final TeNode teNode;
-
- /**
- * Creates a TE node event.
- *
- * @param key the TE node global key
- * @param teNode the TE node
- */
- public TeNodeEventSubject(TeNodeKey key, TeNode teNode) {
- this.key = key;
- this.teNode = teNode;
- }
-
- /**
- * Returns the TE node global key.
- *
- * @return the key
- */
- public TeNodeKey key() {
- return key;
- }
-
- /**
- * Returns the TE node.
- *
- * @return the TE node
- */
- public TeNode teNode() {
- return teNode;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(key, teNode);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof TeNodeEventSubject) {
- TeNodeEventSubject that = (TeNodeEventSubject) object;
- return Objects.equal(key, that.key) &&
- Objects.equal(teNode, that.teNode);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("key", key)
- .add("teNode", teNode)
- .toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TeNodeKey.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TeNodeKey.java
deleted file mode 100644
index f0b7149..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TeNodeKey.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Objects;
-
-/**
- * TE node Key.
- */
-public class TeNodeKey extends TeTopologyKey {
- private final long teNodeId;
-
- /**
- * Creates a TE node key.
- *
- * @param providerId provider identifier
- * @param clientId client identifier
- * @param topologyId topology identifier
- * @param teNodeId TE node identifier
- */
- public TeNodeKey(long providerId, long clientId,
- long topologyId, long teNodeId) {
- super(providerId, clientId, topologyId);
- this.teNodeId = teNodeId;
- }
-
- /**
- * Creates a TE node key based on a given TE topology key and a
- * TE node identifier.
- *
- * @param teTopologyKey the key of TE Topology to which this node belongs
- * @param nodeId TE node identifier
- */
- public TeNodeKey(TeTopologyKey teTopologyKey, long nodeId) {
- super(teTopologyKey.providerId(), teTopologyKey.clientId(),
- teTopologyKey.topologyId());
- this.teNodeId = nodeId;
- }
-
- /**
- * Returns the TE Node identifier.
- *
- * @return the TE node id
- */
- public long teNodeId() {
- return teNodeId;
- }
-
- public TeTopologyKey teTopologyKey() {
- return new TeTopologyKey(providerId(), clientId(), topologyId());
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), teNodeId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof TeNodeKey) {
- if (!super.equals(object)) {
- return false;
- }
- TeNodeKey that = (TeNodeKey) object;
- return Objects.equal(this.teNodeId, that.teNodeId);
- }
- return false;
- }
-
- /**
- * Returns ToStringHelper with an additional TE node identifier.
- *
- * @return toStringHelper
- */
- protected ToStringHelper toTeNodeKeyStringHelper() {
- return toTopologyKeyStringHelper().add("teNodeId", teNodeId);
- }
-
- @Override
- public String toString() {
- return toTeNodeKeyStringHelper().toString();
- }
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TerminationPoint.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TerminationPoint.java
deleted file mode 100644
index 9880098..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TerminationPoint.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import java.util.List;
-
-import org.onosproject.tetopology.management.api.KeyId;
-
-/**
- * Abstraction of a termination point.
- */
-public interface TerminationPoint {
-
- /**
- * Returns the termination point identifier.
- *
- * @return termination point id
- */
- KeyId tpId();
-
- /**
- * Returns list of supporting termination point identifiers.
- *
- * @return the supporting termination point ids
- */
- List<TerminationPointKey> supportingTpIds();
-
- /**
- * Returns TE termination point identifier.
- *
- * @return the TE TP id
- */
- Long teTpId();
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TerminationPointKey.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TerminationPointKey.java
deleted file mode 100644
index 249c88f..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TerminationPointKey.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import com.google.common.base.Objects;
-import org.onosproject.tetopology.management.api.KeyId;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Representation of a termination point key or reference.
- */
-public class TerminationPointKey extends NetworkNodeKey {
- private final KeyId tpId;
-
- /**
- * Creates a termination point key.
- *
- * @param networkId network identifier
- * @param nodeId node identifier
- * @param tpId termination point identifier
- */
- public TerminationPointKey(KeyId networkId, KeyId nodeId, KeyId tpId) {
- super(networkId, nodeId);
- this.tpId = tpId;
- }
-
- /**
- * Creates an instance of termination point key based on a given
- * network node key.
- *
- * @param nodeKey node key
- * @param tpId termination point identifier
- */
- public TerminationPointKey(NetworkNodeKey nodeKey, KeyId tpId) {
- super(nodeKey.networkId(), nodeKey.nodeId());
- this.tpId = tpId;
- }
-
- /**
- * Returns the termination point identifier.
- *
- * @return termination point identifier
- */
- public NetworkNodeKey networkNodeKey() {
- return new NetworkNodeKey(networkId(), nodeId());
- }
-
- /**
- * Returns the termination point identifier.
- *
- * @return termination point identifier
- */
- public KeyId tpId() {
- return tpId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), tpId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (object instanceof TerminationPointKey) {
- if (!super.equals(object)) {
- return false;
- }
- TerminationPointKey that = (TerminationPointKey) object;
- return Objects.equal(tpId, that.tpId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("networkId", networkId())
- .add("nodeId", nodeId())
- .add("tpId", tpId)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TtpKey.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TtpKey.java
deleted file mode 100644
index e43200a..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TtpKey.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Objects;
-
-/**
- * Representation of a TE tunnel termination point key.
- */
-public class TtpKey extends TeNodeKey {
- private final long ttpId;
-
- /**
- * Creates a TE tunnel termination point key.
- *
- * @param providerId provider identifier
- * @param clientId client identifier
- * @param topologyId topology identifier
- * @param teNodeId TE node identifier
- * @param ttpId tunnel termination point identifier
- */
- public TtpKey(long providerId, long clientId, long topologyId,
- long teNodeId, long ttpId) {
- super(providerId, clientId, topologyId, teNodeId);
- this.ttpId = ttpId;
- }
-
- /**
- * Creates a TE tunnel termination point key based on a given TE node
- * key and a tunnel termination point identifier.
- *
- * @param teNodeKey TE node key
- * @param ttpId tunnel termination point id
- */
- public TtpKey(TeNodeKey teNodeKey, long ttpId) {
- super(teNodeKey.providerId(), teNodeKey.clientId(),
- teNodeKey.topologyId(), teNodeKey.teNodeId());
- this.ttpId = ttpId;
- }
-
- /**
- * Returns the TE node key.
- *
- * @return the TE node key
- */
- public TeNodeKey teNodekey() {
- return new TeNodeKey(providerId(), clientId(), topologyId(), teNodeId());
- }
-
- /**
- * Returns the tunnel termination point identifier.
- *
- * @return the tunnel termination point id
- */
- public long ttpId() {
- return ttpId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), ttpId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof TtpKey) {
- if (!super.equals(object)) {
- return false;
- }
- TtpKey that = (TtpKey) object;
- return Objects.equal(ttpId, that.ttpId);
- }
- return false;
- }
-
- /**
- * Returns ToStringHelper with an additional tunnel termination point
- * identifier.
- *
- * @return toStringHelper
- */
- protected ToStringHelper toTtpKeyStringHelper() {
- return toTeNodeKeyStringHelper().add("ttpId", ttpId);
- }
-
- @Override
- public String toString() {
- return toTtpKeyStringHelper().toString();
- }
-
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TunnelTerminationPoint.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TunnelTerminationPoint.java
deleted file mode 100644
index 9f488f1..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/TunnelTerminationPoint.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.api.node;
-
-import java.util.BitSet;
-import java.util.List;
-
-import org.onosproject.tetopology.management.api.EncodingType;
-import org.onosproject.tetopology.management.api.SwitchingType;
-
-/**
- * Representation of a tunnel termination point.
- */
-public interface TunnelTerminationPoint {
- /**
- * Indicates that the TTP supports one-plus-one protection.
- */
- public static final short BIT_1PLUS1_PROTECTION_CAPABLE = 0;
-
- /**
- * Indicates that the TTP is disabled.
- */
- public static final short BIT_DISABLED = 1;
-
- /**
- * Indicates that the TTP is operationally down.
- */
- public static final short BIT_STATUS_DOWN = 2;
-
- /**
- * Returns the tunnel termination point identifier.
- *
- * @return tunnel termination point id
- */
- long ttpId();
-
- /**
- * Returns the network layer switching type to which this TTP belongs.
- *
- * @return the switching type
- */
- SwitchingType switchingLayer();
-
- /**
- * Returns the network layer encoding type to which this TTP belongs.
- *
- * @return the encoding type
- */
- EncodingType encodingLayer();
-
- /**
- * Returns the flags of this TTP.
- *
- * @return the flags
- */
- BitSet flags();
-
- /**
- * Returns the supported inter-layer locks.
- *
- * @return list of inter-layer locks
- */
- List<Long> interLayerLockList();
-
- /**
- * Returns the local link connectivity list.
- *
- * @return the local link connectivity list
- */
- List<LocalLinkConnectivity> localLinkConnectivityList();
-
- /**
- * Returns the remaining adaptation bandwidth at each priority level.
- *
- * @return list of available adaptation bandwidth
- */
- float[] availAdaptBandwidth();
-
- /**
- * Returns the supporting TTP identifier.
- *
- * @return the supporting TTP key
- */
- TtpKey supportingTtpId();
-}
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/package-info.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/package-info.java
deleted file mode 100644
index 6dbf03b..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/node/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * TE node API.
- */
-package org.onosproject.tetopology.management.api.node;
\ No newline at end of file
diff --git a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/package-info.java b/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/package-info.java
deleted file mode 100644
index 5dca9eb..0000000
--- a/apps/tetopology/api/src/main/java/org/onosproject/tetopology/management/api/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * TE topology management API.
- */
-package org.onosproject.tetopology.management.api;
\ No newline at end of file
diff --git a/apps/tetopology/api/src/test/java/org/onosproject/tetopology/manager/api/TeLinkApiTest.java b/apps/tetopology/api/src/test/java/org/onosproject/tetopology/manager/api/TeLinkApiTest.java
deleted file mode 100644
index 04621b5..0000000
--- a/apps/tetopology/api/src/test/java/org/onosproject/tetopology/manager/api/TeLinkApiTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.manager.api;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.tetopology.management.api.link.ElementType;
-import org.onosproject.tetopology.management.api.link.Label;
-import org.onosproject.tetopology.management.api.link.PathElement;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.link.UnderlayBackupPath;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-
-/**
- * Unit tests for TE link APIs.
- */
-public class TeLinkApiTest {
- private static final long DEFAULT_PROVIDER_ID = 123;
- private static final long DEFAULT_CLIENT_ID = 456;
- private static final long DEFAULT_TOPOLOGY_ID = 789;
- private static final long DEFAULT_TE_NODE_ID = 1234;
- private static final long DEFAULT_TE_LINK_TP_ID = 5678;
- private static final String DEFAULT_TOPOLOGY_ID_STRING =
- "default-topology-123";
- private static final long DEFAULT_PATH_ELEMENT_ID = 234;
- private static final long DEFAULT_UNDERLAY_BACKUP_PATH_IDX = 10;
-
- private long providerId;
- private long clientId;
- private long topologyId;
- private long teNodeId;
- private long teLinkTpId;
- private long pathElementId;
- private long underlayBackupPathIndex;
-
- private String topologyIdString;
-
- @Before
- public void setUp() {
- providerId = DEFAULT_PROVIDER_ID;
- clientId = DEFAULT_CLIENT_ID;
- topologyId = DEFAULT_TOPOLOGY_ID;
- teNodeId = DEFAULT_TE_NODE_ID;
- teLinkTpId = DEFAULT_TE_LINK_TP_ID;
- topologyIdString = DEFAULT_TOPOLOGY_ID_STRING;
- pathElementId = DEFAULT_PATH_ELEMENT_ID;
- underlayBackupPathIndex = DEFAULT_UNDERLAY_BACKUP_PATH_IDX;
- }
-
- @Test
- public void teLinkTpGlobalKeyEqualOperatorTest() {
- TeLinkTpGlobalKey key1 = new TeLinkTpGlobalKey(providerId, clientId,
- topologyId, teNodeId,
- teLinkTpId);
- TeLinkTpGlobalKey key2 = new TeLinkTpGlobalKey(providerId, clientId,
- topologyId, teNodeId,
- teLinkTpId);
- TeLinkTpGlobalKey key3 = new TeLinkTpGlobalKey(providerId + 1, clientId,
- topologyId, teNodeId,
- teLinkTpId);
- TeLinkTpGlobalKey key4 = new TeLinkTpGlobalKey(providerId, clientId + 1,
- topologyId, teNodeId,
- teLinkTpId);
- TeLinkTpGlobalKey key5 = new TeLinkTpGlobalKey(providerId, clientId,
- topologyId + 1,
- teNodeId, teLinkTpId);
- TeLinkTpGlobalKey key6 = new TeLinkTpGlobalKey(providerId, clientId,
- topologyId,
- teNodeId + 1, teLinkTpId);
- TeLinkTpGlobalKey key7 = new TeLinkTpGlobalKey(providerId, clientId,
- topologyId,
- teNodeId, teLinkTpId + 1);
-
- assertTrue("Two topology Ids must be equal", key1.equals(key2));
-
- assertFalse("Two topology Ids must be unequal", key1.equals(key3));
- assertFalse("Two topology Ids must be unequal", key3.equals(key1));
-
- assertFalse("Two topology Ids must be unequal", key1.equals(key4));
- assertFalse("Two topology Ids must be unequal", key4.equals(key1));
-
- assertFalse("Two topology Ids must be unequal", key1.equals(key5));
- assertFalse("Two topology Ids must be unequal", key5.equals(key1));
-
- assertFalse("Two topology Ids must be unequal", key1.equals(key6));
- assertFalse("Two topology Ids must be unequal", key6.equals(key1));
-
- assertFalse("Two topology Ids must be unequal", key1.equals(key7));
- assertFalse("Two topology Ids must be unequal", key7.equals(key1));
- }
-
- @Test
- public void underLayBackupPathEqualOperatorTest() {
- ElementType pathElementType1 = new Label(pathElementId + 1);
- ElementType pathElementType2 = new Label(pathElementId + 2);
- ElementType pathElementType3 = new Label(pathElementId + 3);
- ElementType pathElementType4 = new Label(pathElementId + 4);
-
- PathElement pathElement1 = new PathElement(pathElementId, teNodeId,
- pathElementType1, true);
- PathElement pathElement2 = new PathElement(pathElementId + 1,
- teNodeId + 1,
- pathElementType2, true);
- PathElement pathElement3 = new PathElement(pathElementId + 2,
- teNodeId + 2,
- pathElementType3, true);
- PathElement pathElement4 = new PathElement(pathElementId + 3,
- teNodeId + 3,
- pathElementType4, true);
-
- List<PathElement> pathElementList1 = new ArrayList<>();
- pathElementList1.add(pathElement1);
- pathElementList1.add(pathElement2);
- pathElementList1.add(pathElement3);
-
- List<PathElement> pathElementList2 = new ArrayList<>();
- pathElementList1.add(pathElement1);
- pathElementList1.add(pathElement2);
- pathElementList1.add(pathElement4);
-
- // bp1 and bp2 are the same. bp3, bp4, and bp5 differ by one
- // attribute comparing to bp1.
- UnderlayBackupPath bp1 = new UnderlayBackupPath(
- underlayBackupPathIndex, pathElementList1, true);
- UnderlayBackupPath bp2 = new UnderlayBackupPath(
- underlayBackupPathIndex, pathElementList1, true);
-
- UnderlayBackupPath bp3 = new UnderlayBackupPath(
- underlayBackupPathIndex + 1, pathElementList1, true);
- UnderlayBackupPath bp4 = new UnderlayBackupPath(
- underlayBackupPathIndex, pathElementList2, true);
- UnderlayBackupPath bp5 = new UnderlayBackupPath(
- underlayBackupPathIndex, pathElementList1, false);
-
-
- assertTrue("Two backup paths must be equal", bp1.equals(bp2));
-
- assertFalse("Two backup paths must be unequal", bp1.equals(bp3));
- assertFalse("Two backup paths must be unequal", bp3.equals(bp1));
-
- assertFalse("Two backup paths must be unequal", bp1.equals(bp4));
- assertFalse("Two backup paths must be unequal", bp4.equals(bp1));
-
- assertFalse("Two backup paths must be unequal", bp1.equals(bp5));
- assertFalse("Two backup paths must be unequal", bp5.equals(bp1));
- }
-}
diff --git a/apps/tetopology/api/src/test/java/org/onosproject/tetopology/manager/api/TeNetworkApiTest.java b/apps/tetopology/api/src/test/java/org/onosproject/tetopology/manager/api/TeNetworkApiTest.java
deleted file mode 100644
index 77d14f5..0000000
--- a/apps/tetopology/api/src/test/java/org/onosproject/tetopology/manager/api/TeNetworkApiTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.manager.api;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.tetopology.management.api.TeTopologyId;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-
-/**
- * Unit tests for TE topology APIs.
- */
-public class TeNetworkApiTest {
- private static final long DEFAULT_PROVIDER_ID = 1234;
- private static final long DEFAULT_CLIENT_ID = 5678;
- private static final long DEFAULT_TOPOLOGY_ID = 9876;
- private static final String DEFAULT_TOPOLOGY_ID_STRING =
- "default-topology-123";
-
- private long providerId;
- private long clientId;
- private long topologyId;
- private String topologyIdString;
-
- @Before
- public void setUp() {
- providerId = DEFAULT_PROVIDER_ID;
- clientId = DEFAULT_CLIENT_ID;
- topologyId = DEFAULT_TOPOLOGY_ID;
- topologyIdString = DEFAULT_TOPOLOGY_ID_STRING;
- }
-
- @Test
- public void topologyIdEqualOperatorTest() {
- TeTopologyId id1 = new TeTopologyId(providerId, clientId,
- topologyIdString);
- TeTopologyId id2 = new TeTopologyId(providerId, clientId,
- topologyIdString);
- TeTopologyId id3 = new TeTopologyId(providerId + 1, clientId,
- topologyIdString);
- TeTopologyId id4 = new TeTopologyId(providerId, clientId + 1,
- topologyIdString);
- TeTopologyId id5 = new TeTopologyId(providerId, clientId,
- topologyIdString + "abc");
-
- assertTrue("Two topology ids must be equal", id1.equals(id2));
-
- assertFalse("Two topology ids must be unequal", id1.equals(id3));
- assertFalse("Two topology ids must be unequal", id3.equals(id1));
-
- assertFalse("Two topology ids must be unequal", id1.equals(id4));
- assertFalse("Two topology ids must be unequal", id4.equals(id1));
-
- assertFalse("Two topology ids must be unequal", id1.equals(id5));
- assertFalse("Two topology ids must be unequal", id5.equals(id1));
- }
-
- @Test
- public void topologyKeyEqualOperatorTest() {
- TeTopologyKey key1 = new TeTopologyKey(providerId, clientId,
- topologyId);
- TeTopologyKey key2 = new TeTopologyKey(providerId, clientId,
- topologyId);
- TeTopologyKey key3 = new TeTopologyKey(providerId + 1, clientId,
- topologyId);
- TeTopologyKey key4 = new TeTopologyKey(providerId, clientId + 1,
- topologyId);
- TeTopologyKey key5 = new TeTopologyKey(providerId, clientId,
- topologyId + 1);
-
- assertTrue("Two topology keys must be equal", key1.equals(key2));
-
- assertFalse("Two topology keys must be unequal", key1.equals(key3));
- assertFalse("Two topology keys must be unequal", key3.equals(key1));
-
- assertFalse("Two topology keys must be unequal", key1.equals(key4));
- assertFalse("Two topology keys must be unequal", key4.equals(key1));
-
- assertFalse("Two topology keys must be unequal", key1.equals(key5));
- assertFalse("Two topology keys must be unequal", key5.equals(key1));
- }
-}
diff --git a/apps/tetopology/api/src/test/java/org/onosproject/tetopology/manager/api/TeNodeApiTest.java b/apps/tetopology/api/src/test/java/org/onosproject/tetopology/manager/api/TeNodeApiTest.java
deleted file mode 100644
index fb4b8b8..0000000
--- a/apps/tetopology/api/src/test/java/org/onosproject/tetopology/manager/api/TeNodeApiTest.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.manager.api;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.tetopology.management.api.link.ConnectivityMatrixId;
-import org.onosproject.tetopology.management.api.link.ElementType;
-import org.onosproject.tetopology.management.api.link.Label;
-import org.onosproject.tetopology.management.api.link.PathElement;
-import org.onosproject.tetopology.management.api.link.TePathAttributes;
-import org.onosproject.tetopology.management.api.link.UnderlayAbstractPath;
-import org.onosproject.tetopology.management.api.link.UnderlayBackupPath;
-import org.onosproject.tetopology.management.api.node.ConnectivityMatrix;
-import org.onosproject.tetopology.management.api.node.ConnectivityMatrixKey;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.List;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-
-/**
- * Unit tests for TE node APIs.
- */
-public class TeNodeApiTest {
- private static final long DEFAULT_PROVIDER_ID = 123;
- private static final long DEFAULT_CLIENT_ID = 456;
- private static final long DEFAULT_TOPOLOGY_ID = 789;
- private static final long DEFAULT_TE_NODE_ID = 1234;
- private static final long DEFAULT_CONNECTIVITY_ENTRY_ID = 5678;
- private static final long DEFAULT_TTP_ID = 897;
- private static final String DEFAULT_TOPOLOGY_ID_STRING =
- "default-topology-123";
- private static final long DEFAULT_PATH_ELEMENT_ID = 234;
- private static final long DEFAULT_UNDERLAY_BACKUP_PATH_IDX = 10;
-
- private long providerId;
- private long clientId;
- private long topologyId;
- private long teNodeId;
- private long connectivityMatrixEntryId;
- private long pathElementId;
- private long underlayBackupPathIndex;
- private long ttpId;
-
- private String topologyIdString;
-
- @Before
- public void setUp() {
- providerId = DEFAULT_PROVIDER_ID;
- clientId = DEFAULT_CLIENT_ID;
- topologyId = DEFAULT_TOPOLOGY_ID;
- teNodeId = DEFAULT_TE_NODE_ID;
- connectivityMatrixEntryId = DEFAULT_CONNECTIVITY_ENTRY_ID;
- topologyIdString = DEFAULT_TOPOLOGY_ID_STRING;
- pathElementId = DEFAULT_PATH_ELEMENT_ID;
- underlayBackupPathIndex = DEFAULT_UNDERLAY_BACKUP_PATH_IDX;
- ttpId = DEFAULT_TTP_ID;
- }
-
- @Test
- public void connectivityMatrixKeyEqualOperatorTest() {
- ConnectivityMatrixKey key1 = new ConnectivityMatrixKey(providerId,
- clientId,
- topologyId,
- teNodeId,
- connectivityMatrixEntryId);
- ConnectivityMatrixKey key2 = new ConnectivityMatrixKey(providerId,
- clientId,
- topologyId,
- teNodeId,
- connectivityMatrixEntryId);
- ConnectivityMatrixKey key3 = new ConnectivityMatrixKey(providerId + 1,
- clientId,
- topologyId,
- teNodeId,
- connectivityMatrixEntryId);
- ConnectivityMatrixKey key4 = new ConnectivityMatrixKey(providerId,
- clientId + 1,
- topologyId,
- teNodeId,
- connectivityMatrixEntryId);
- ConnectivityMatrixKey key5 = new ConnectivityMatrixKey(providerId,
- clientId,
- topologyId + 1,
- teNodeId,
- connectivityMatrixEntryId);
- ConnectivityMatrixKey key6 = new ConnectivityMatrixKey(providerId,
- clientId,
- topologyId,
- teNodeId + 1,
- connectivityMatrixEntryId);
- ConnectivityMatrixKey key7 = new ConnectivityMatrixKey(providerId,
- clientId,
- topologyId,
- teNodeId,
- connectivityMatrixEntryId + 1);
-
- assertTrue("Two matrix keys must be equal", key1.equals(key2));
-
- assertFalse("Two matrix keys must be unequal", key1.equals(key3));
- assertFalse("Two matrix keys must be unequal", key3.equals(key1));
-
- assertFalse("Two matrix keys must be unequal", key1.equals(key4));
- assertFalse("Two matrix keys must be unequal", key4.equals(key1));
-
- assertFalse("Two matrix keys must be unequal", key1.equals(key5));
- assertFalse("Two matrix keys must be unequal", key5.equals(key1));
-
- assertFalse("Two matrix keys must be unequal", key1.equals(key6));
- assertFalse("Two matrix keys must be unequal", key6.equals(key1));
-
- assertFalse("Two matrix keys must be unequal", key1.equals(key7));
- assertFalse("Two matrix keys must be unequal", key7.equals(key1));
- }
-
- @Test
- public void underlayBackupPathEqualOperatorTest() {
- ElementType pathElementType1 = new Label(pathElementId + 1);
- ElementType pathElementType2 = new Label(pathElementId + 2);
- ElementType pathElementType3 = new Label(pathElementId + 3);
- ElementType pathElementType4 = new Label(pathElementId + 4);
-
- PathElement pathElement1 = new PathElement(pathElementId, teNodeId,
- pathElementType1, true);
- PathElement pathElement2 = new PathElement(pathElementId + 1,
- teNodeId + 1,
- pathElementType2, true);
- PathElement pathElement3 = new PathElement(pathElementId + 2,
- teNodeId + 2,
- pathElementType3, true);
- PathElement pathElement4 = new PathElement(pathElementId + 3,
- teNodeId + 3,
- pathElementType4, true);
-
- List<PathElement> pathElementList1 = new ArrayList<>();
- pathElementList1.add(pathElement1);
- pathElementList1.add(pathElement2);
- pathElementList1.add(pathElement3);
-
- List<PathElement> pathElementList2 = new ArrayList<>();
- pathElementList2.add(pathElement1);
- pathElementList2.add(pathElement2);
- pathElementList2.add(pathElement4);
-
- // bp1 and bp2 are the same. bp3, bp4, and bp5 differ by one
- // attribute comparing to bp1.
- UnderlayBackupPath bp1 = new UnderlayBackupPath(
- underlayBackupPathIndex, pathElementList1, true);
- UnderlayBackupPath bp2 = new UnderlayBackupPath(
- underlayBackupPathIndex, pathElementList1, true);
-
- UnderlayBackupPath bp3 = new UnderlayBackupPath(
- underlayBackupPathIndex + 1, pathElementList1, true);
- UnderlayBackupPath bp4 = new UnderlayBackupPath(
- underlayBackupPathIndex, pathElementList2, true);
- UnderlayBackupPath bp5 = new UnderlayBackupPath(
- underlayBackupPathIndex, pathElementList1, false);
-
-
- assertTrue("Two backup paths must be equal", bp1.equals(bp2));
-
- assertFalse("Two backup paths must be unequal", bp1.equals(bp3));
- assertFalse("Two backup paths must be unequal", bp3.equals(bp1));
-
- assertFalse("Two backup paths must be unequal", bp1.equals(bp4));
- assertFalse("Two backup paths must be unequal", bp4.equals(bp1));
-
- assertFalse("Two backup paths must be unequal", bp1.equals(bp5));
- assertFalse("Two backup paths must be unequal", bp5.equals(bp1));
- }
-
-
- @Test
- public void connectivityMatrixEqualOperatorTest() {
- long key1 = connectivityMatrixEntryId;
- long key2 = connectivityMatrixEntryId + 1;
-
- ElementType pathElementType1 = new Label(pathElementId + 1);
- ElementType pathElementType2 = new Label(pathElementId + 2);
- ElementType pathElementType3 = new Label(pathElementId + 3);
- ElementType pathElementType4 = new Label(pathElementId + 4);
-
- PathElement pathElement1 = new PathElement(pathElementId, teNodeId,
- pathElementType1, true);
- PathElement pathElement2 = new PathElement(pathElementId + 1,
- teNodeId + 1,
- pathElementType2, true);
- PathElement pathElement3 = new PathElement(pathElementId + 2,
- teNodeId + 2,
- pathElementType3, true);
- PathElement pathElement4 = new PathElement(pathElementId + 3,
- teNodeId + 3,
- pathElementType4, true);
-
- List<PathElement> pathElementList1 = new ArrayList<>();
- pathElementList1.add(pathElement1);
- pathElementList1.add(pathElement2);
- pathElementList1.add(pathElement3);
-
- List<PathElement> pathElementList2 = new ArrayList<>();
- pathElementList2.add(pathElement1);
- pathElementList2.add(pathElement2);
- pathElementList2.add(pathElement4);
-
- UnderlayAbstractPath abstractPath1 = new UnderlayAbstractPath(
- pathElementList1, true);
- UnderlayAbstractPath abstractPath2 = new UnderlayAbstractPath(
- pathElementList2, true);
-
- ElementType from = new ConnectivityMatrixId(connectivityMatrixEntryId);
- List<ElementType> mergingList = new ArrayList<>();
- mergingList.add(new ConnectivityMatrixId(connectivityMatrixEntryId + 1));
- mergingList.add(new ConnectivityMatrixId(connectivityMatrixEntryId + 2));
-
- List<ElementType> constrainList = new ArrayList<>();
- constrainList.add(new ConnectivityMatrixId(connectivityMatrixEntryId + 3));
- constrainList.add(new ConnectivityMatrixId(connectivityMatrixEntryId + 4));
-
- BitSet flags = new BitSet(1);
-
- List<Long> srlgs = new ArrayList<>();
- srlgs.add(new Long(10));
- TePathAttributes tePathAttributes = new TePathAttributes(new Long(10),
- new Long(10),
- srlgs);
-
- ConnectivityMatrix matrix1 = new ConnectivityMatrix(key1,
- from,
- mergingList,
- constrainList,
- flags,
- tePathAttributes,
- abstractPath1);
- ConnectivityMatrix matrix2 = new ConnectivityMatrix(key1,
- from,
- mergingList,
- constrainList,
- flags,
- tePathAttributes,
- abstractPath1);
- ConnectivityMatrix matrix3 = new ConnectivityMatrix(key1,
- from,
- mergingList,
- constrainList,
- flags,
- tePathAttributes,
- abstractPath2);
- ConnectivityMatrix matrix4 = new ConnectivityMatrix(key2,
- from,
- mergingList,
- constrainList,
- flags,
- tePathAttributes,
- abstractPath1);
-
- assertTrue("Two conn matrices must be equal", matrix1.equals(matrix2));
-
- assertFalse("Two conn matrices must be unequal", matrix1.equals(matrix3));
- assertFalse("Two conn matrices must be unequal", matrix3.equals(matrix1));
-
- assertFalse("Two conn matrices must be unequal", matrix1.equals(matrix4));
- assertFalse("Two conn matrices must be unequal", matrix4.equals(matrix1));
- }
-
- @Test
- public void teNodeKeyEqualOperatorTest() {
- TeNodeKey key1 = new TeNodeKey(providerId, clientId,
- topologyId, teNodeId);
- TeNodeKey key2 = new TeNodeKey(providerId, clientId,
- topologyId, teNodeId);
- TeNodeKey key3 = new TeNodeKey(providerId + 1, clientId,
- topologyId, teNodeId);
- TeNodeKey key4 = new TeNodeKey(providerId, clientId + 1,
- topologyId, teNodeId);
- TeNodeKey key5 = new TeNodeKey(providerId, clientId,
- topologyId + 1, teNodeId);
- TeNodeKey key6 = new TeNodeKey(providerId, clientId,
- topologyId, teNodeId + 1);
-
- assertTrue("Two matrix keys must be equal", key1.equals(key2));
-
- assertFalse("Two matrix keys must be unequal", key1.equals(key3));
- assertFalse("Two matrix keys must be unequal", key3.equals(key1));
-
- assertFalse("Two matrix keys must be unequal", key1.equals(key4));
- assertFalse("Two matrix keys must be unequal", key4.equals(key1));
-
- assertFalse("Two matrix keys must be unequal", key1.equals(key5));
- assertFalse("Two matrix keys must be unequal", key5.equals(key1));
-
- assertFalse("Two matrix keys must be unequal", key1.equals(key6));
- assertFalse("Two matrix keys must be unequal", key6.equals(key1));
- }
-
- @Test
- public void ttpMatrixKeyEqualOperatorTest() {
- TtpKey key1 = new TtpKey(providerId, clientId, topologyId,
- teNodeId, ttpId);
- TtpKey key2 = new TtpKey(providerId, clientId, topologyId,
- teNodeId, ttpId);
- TtpKey key3 = new TtpKey(providerId + 1, clientId, topologyId,
- teNodeId, ttpId);
- TtpKey key4 = new TtpKey(providerId, clientId + 1, topologyId,
- teNodeId, ttpId);
- TtpKey key5 = new TtpKey(providerId, clientId, topologyId + 1,
- teNodeId, ttpId);
- TtpKey key6 = new TtpKey(providerId, clientId, topologyId,
- teNodeId + 1, ttpId);
- TtpKey key7 = new TtpKey(providerId, clientId, topologyId,
- teNodeId, ttpId + 1);
-
- assertTrue("Two TTP keys must be equal", key1.equals(key2));
-
- assertFalse("Two TTP keys must be unequal", key1.equals(key3));
- assertFalse("Two TTP keys must be unequal", key3.equals(key1));
-
- assertFalse("Two TTP keys must be unequal", key1.equals(key4));
- assertFalse("Two TTP keys must be unequal", key4.equals(key1));
-
- assertFalse("Two TTP keys must be unequal", key1.equals(key5));
- assertFalse("Two TTP keys must be unequal", key5.equals(key1));
-
- assertFalse("Two TTP keys must be unequal", key1.equals(key6));
- assertFalse("Two TTP keys must be unequal", key6.equals(key1));
-
- assertFalse("Two TTP keys must be unequal", key1.equals(key7));
- assertFalse("Two TTP keys must be unequal", key7.equals(key1));
- }
-
-}
diff --git a/apps/tetopology/api/src/test/java/org/onosproject/tetopology/manager/api/package-info.java b/apps/tetopology/api/src/test/java/org/onosproject/tetopology/manager/api/package-info.java
deleted file mode 100644
index 928c96d..0000000
--- a/apps/tetopology/api/src/test/java/org/onosproject/tetopology/manager/api/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * The TE topology APis test functions.
- *
- */
-package org.onosproject.tetopology.manager.api;
diff --git a/apps/tetopology/app/BUILD b/apps/tetopology/app/BUILD
deleted file mode 100644
index d38ffbc..0000000
--- a/apps/tetopology/app/BUILD
+++ /dev/null
@@ -1,13 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + JACKSON + KRYO + [
- "//apps/tetopology/api:onos-apps-tetopology-api",
- "//core/store/serializers:onos-core-serializers",
-]
-
-TEST_DEPS = TEST_ADAPTERS + [
- "//utils/osgi:onlab-osgi-tests",
-]
-
-osgi_jar_with_tests(
- test_deps = TEST_DEPS,
- deps = COMPILE_DEPS,
-)
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/DistributedTeTopologyStore.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/DistributedTeTopologyStore.java
deleted file mode 100644
index 4b37857..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/DistributedTeTopologyStore.java
+++ /dev/null
@@ -1,1424 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.impl;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.net.DeviceId;
-import org.onosproject.store.AbstractStore;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.AtomicCounter;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.MapEvent;
-import org.onosproject.store.service.MapEventListener;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.tetopology.management.api.CommonTopologyData;
-import org.onosproject.tetopology.management.api.DefaultNetwork;
-import org.onosproject.tetopology.management.api.DefaultTeTopologies;
-import org.onosproject.tetopology.management.api.DefaultTeTopology;
-import org.onosproject.tetopology.management.api.EncodingType;
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.LongValue;
-import org.onosproject.tetopology.management.api.Network;
-import org.onosproject.tetopology.management.api.OptimizationType;
-import org.onosproject.tetopology.management.api.ProviderClientId;
-import org.onosproject.tetopology.management.api.SwitchingType;
-import org.onosproject.tetopology.management.api.TeConstants;
-import org.onosproject.tetopology.management.api.TeStatus;
-import org.onosproject.tetopology.management.api.TeTopologies;
-import org.onosproject.tetopology.management.api.TeTopology;
-import org.onosproject.tetopology.management.api.TeTopologyEvent;
-import org.onosproject.tetopology.management.api.TeTopologyEvent.Type;
-import org.onosproject.tetopology.management.api.TeTopologyId;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.TeUtils;
-import org.onosproject.tetopology.management.api.link.AsNumber;
-import org.onosproject.tetopology.management.api.link.CommonLinkData;
-import org.onosproject.tetopology.management.api.link.ConnectivityMatrixId;
-import org.onosproject.tetopology.management.api.link.DefaultNetworkLink;
-import org.onosproject.tetopology.management.api.link.DefaultTeLink;
-import org.onosproject.tetopology.management.api.link.ElementType;
-import org.onosproject.tetopology.management.api.link.ExternalLink;
-import org.onosproject.tetopology.management.api.link.Label;
-import org.onosproject.tetopology.management.api.link.LinkBandwidth;
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.link.OduResource;
-import org.onosproject.tetopology.management.api.link.PathElement;
-import org.onosproject.tetopology.management.api.link.TeIpv4;
-import org.onosproject.tetopology.management.api.link.TeIpv6;
-import org.onosproject.tetopology.management.api.link.TeLink;
-import org.onosproject.tetopology.management.api.link.TeLinkId;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.link.TeLinkTpKey;
-import org.onosproject.tetopology.management.api.link.TePathAttributes;
-import org.onosproject.tetopology.management.api.link.TunnelProtectionType;
-import org.onosproject.tetopology.management.api.link.UnderlayAbstractPath;
-import org.onosproject.tetopology.management.api.link.UnderlayBackupPath;
-import org.onosproject.tetopology.management.api.link.UnderlayPath;
-import org.onosproject.tetopology.management.api.link.UnderlayPrimaryPath;
-import org.onosproject.tetopology.management.api.link.UnnumberedLink;
-import org.onosproject.tetopology.management.api.node.CommonNodeData;
-import org.onosproject.tetopology.management.api.node.ConnectivityMatrix;
-import org.onosproject.tetopology.management.api.node.ConnectivityMatrixKey;
-import org.onosproject.tetopology.management.api.node.DefaultNetworkNode;
-import org.onosproject.tetopology.management.api.node.DefaultTeNode;
-import org.onosproject.tetopology.management.api.node.DefaultTerminationPoint;
-import org.onosproject.tetopology.management.api.node.DefaultTunnelTerminationPoint;
-import org.onosproject.tetopology.management.api.node.LocalLinkConnectivity;
-import org.onosproject.tetopology.management.api.node.NetworkNode;
-import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
-import org.onosproject.tetopology.management.api.node.NodeTpKey;
-import org.onosproject.tetopology.management.api.node.TeNode;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TerminationPoint;
-import org.onosproject.tetopology.management.api.node.TerminationPointKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.tetopology.management.api.node.TunnelTerminationPoint;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.BitSet;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import static org.onosproject.tetopology.management.api.OptimizationType.NOT_OPTIMIZED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.LINK_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.LINK_REMOVED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.LINK_UPDATED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NETWORK_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NETWORK_REMOVED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NETWORK_UPDATED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NODE_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NODE_REMOVED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NODE_UPDATED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_LINK_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_LINK_REMOVED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_LINK_UPDATED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_NODE_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_NODE_REMOVED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_NODE_UPDATED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_TOPOLOGY_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_TOPOLOGY_REMOVED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_TOPOLOGY_UPDATED;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Implementation of the TE network store.
- */
-@Component(immediate = true, service = TeTopologyStore.class)
-public class DistributedTeTopologyStore
- extends AbstractStore<TeTopologyEvent, TeTopologyStoreDelegate>
- implements TeTopologyStore {
- private static final String STORE_NAME = "TE_NETWORK_TOPOLOGY_STORE";
- private static final String COUNTER_NAME = "TeTopology-TeTopologyId";
- private static final String TETOPOLOGYKEY_INTERNALTETOPOLOGY = "TeTopologyKey-InternalTeTopology";
- private static final String NETWORKID_NETWORK = "NetworkId-InternalNetwork";
- private static final String TENODEKEY_INTERNALTENODE = "TeNodeKey-InternalTeNode";
- private static final String CONNMATRIXKEY_CONNECTIVITYMATRIX = "ConnMatrixKey-ConnectivityMatrix";
- private static final String NETWORKNODEKEY_INTERNALNETWORKNODE = "NetworkNodeKey-InternalNetworkNode";
- private static final String TELINKGLOBALKEY_INTERNALTELINK = "TeLinkGlobalKey-InternalTeLink";
- private static final String NETWORKLINKKEY_INTERNALNETWORKLINK = "NetworkLinkKey-InternalNetworkLink";
- private static final String TPKEY_INTERNALTERMINATIONPOINT = "tpKey-InternalTerminationPoint";
- private static final String TELINKTPGLOBALKEY_TERMINATIONPOINTKEY = "TeLinkGlobalKey-TerminationPointKey";
- private static final String TTPKEY_TUNNELTERMINATIONPOINT = "TtpKey-TunnelTerminationPoint";
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
- // Track TE topologies by TE Topology key
- private ConsistentMap<TeTopologyKey, InternalTeTopology> teTopologyConsistentMap;
- private Map<TeTopologyKey, InternalTeTopology> teTopologyMap;
- private AtomicCounter nextTeTopologyId;
- // Listener for te topology events
- private final MapEventListener<TeTopologyKey, InternalTeTopology> teTopologyListener =
- new InternalTeTopologyListener();
- // Track networks by network Id
- private ConsistentMap<KeyId, InternalNetwork> networkConsistentMap;
- private Map<KeyId, InternalNetwork> networkMap;
- // Listener for network events
- private final MapEventListener<KeyId, InternalNetwork> networkListener =
- new InternalNetworkListener();
- // Track TE nodes by TE node key
- private ConsistentMap<TeNodeKey, InternalTeNode> teNodeConsistentMap;
- private Map<TeNodeKey, InternalTeNode> teNodeMap;
- // Track ConnectivityMatrix by its key
- private ConsistentMap<ConnectivityMatrixKey, ConnectivityMatrix> connMatrixConsistentMap;
- private Map<ConnectivityMatrixKey, ConnectivityMatrix> connMatrixMap;
- // Track Tunnel Termination Points by its key
- private ConsistentMap<TtpKey, TunnelTerminationPoint> ttpConsistentMap;
- private Map<TtpKey, TunnelTerminationPoint> ttpMap;
- // Listener for TE node events
- private final MapEventListener<TeNodeKey, InternalTeNode> teNodeListener =
- new InternalTeNodeListener();
- // Track network nodes by network node key
- private ConsistentMap<NetworkNodeKey, InternalNetworkNode> networkNodeConsistentMap;
- private Map<NetworkNodeKey, InternalNetworkNode> networkNodeMap;
- // Listener for network node events
- private final MapEventListener<NetworkNodeKey, InternalNetworkNode> networkNodeListener =
- new InternalNetworkNodeListener();
- // Track TE links by its key
- private ConsistentMap<TeLinkTpGlobalKey, InternalTeLink> teLinkConsistentMap;
- private Map<TeLinkTpGlobalKey, InternalTeLink> teLinkMap;
- // Listener for te link events
- private final MapEventListener<TeLinkTpGlobalKey, InternalTeLink> teLinkListener =
- new InternalTeLinkListener();
- // Track network links by network link key
- private ConsistentMap<NetworkLinkKey, InternalNetworkLink> networkLinkConsistentMap;
- private Map<NetworkLinkKey, InternalNetworkLink> networkLinkMap;
- // Listener for network link events
- private final MapEventListener<NetworkLinkKey, InternalNetworkLink> networkLinkListener =
- new InternalNetworkLinkListener();
- // Track Termination points by termination point key
- private ConsistentMap<TerminationPointKey, InternalTerminationPoint> tpConsistentMap;
- private Map<TerminationPointKey, InternalTerminationPoint> tpMap;
- // Track termination point keys by TE termination point Key
- private ConsistentMap<TeLinkTpGlobalKey, TerminationPointKey> tpKeyConsistentMap;
- private Map<TeLinkTpGlobalKey, TerminationPointKey> tpKeyMap;
- private final BlockingQueue<TeTopologyMapEvent> mapEventQueue = new LinkedBlockingQueue<>();
-
- private long providerId;
- private static final Serializer TETOPOLOGY_SERIALIZER = Serializer
- .using(new KryoNamespace.Builder().register(KryoNamespaces.API)
- .register(TeTopologyKey.class)
- .register(ProviderClientId.class)
- .register(TeNodeKey.class)
- .register(TeLinkTpGlobalKey.class)
- .register(CommonTopologyData.class)
- .register(KeyId.class)
- .register(OptimizationType.class)
- .register(InternalTeTopology.class)
- .register(InternalNetwork.class)
- .register(InternalTerminationPoint.class)
- .register(InternalTeNode.class)
- .register(InternalNetworkNode.class)
- .register(CommonNodeData.class)
- .register(ConnectivityMatrixKey.class)
- .register(ConnectivityMatrix.class)
- .register(TtpKey.class)
- .register(NetworkNodeKey.class)
- .register(TeStatus.class)
- .register(ElementType.class)
- .register(TeIpv4.class)
- .register(TeIpv6.class)
- .register(AsNumber.class)
- .register(Label.class)
- .register(UnnumberedLink.class)
- .register(TeLinkId.class)
- .register(ConnectivityMatrixId.class)
- .register(InternalTeLink.class)
- .register(InternalNetworkLink.class)
- .register(TeLinkTpKey.class)
- .register(NetworkLinkKey.class)
- .register(NodeTpKey.class)
- .register(CommonLinkData.class)
- .register(SwitchingType.class)
- .register(EncodingType.class)
- .register(ExternalLink.class)
- .register(UnderlayPath.class)
- .register(LinkBandwidth.class)
- .register(OduResource.class)
- .register(PathElement.class)
- .register(UnderlayAbstractPath.class)
- .register(UnderlayBackupPath.class)
- .register(UnderlayPrimaryPath.class)
- .register(TePathAttributes.class)
- .register(TerminationPoint.class)
- .register(TunnelTerminationPoint.class)
- .register(DefaultTunnelTerminationPoint.class)
- .register(TerminationPointKey.class)
- .register(TunnelProtectionType.class)
- .register(LongValue.class)
- .register(LocalLinkConnectivity.class)
- .build());
-
- /**
- * Distributed network store service activate method.
- */
- @Activate
- public void activate() {
- teTopologyConsistentMap = storageService
- .<TeTopologyKey, InternalTeTopology>consistentMapBuilder()
- .withSerializer(TETOPOLOGY_SERIALIZER)
- .withName(TETOPOLOGYKEY_INTERNALTETOPOLOGY)
- .withRelaxedReadConsistency()
- .build();
- teTopologyConsistentMap.addListener(teTopologyListener);
- teTopologyMap = teTopologyConsistentMap.asJavaMap();
- networkConsistentMap = storageService
- .<KeyId, InternalNetwork>consistentMapBuilder()
- .withSerializer(TETOPOLOGY_SERIALIZER)
- .withName(NETWORKID_NETWORK)
- .withRelaxedReadConsistency()
- .build();
- networkConsistentMap.addListener(networkListener);
- networkMap = networkConsistentMap.asJavaMap();
- teNodeConsistentMap = storageService
- .<TeNodeKey, InternalTeNode>consistentMapBuilder()
- .withSerializer(TETOPOLOGY_SERIALIZER)
- .withName(TENODEKEY_INTERNALTENODE)
- .withRelaxedReadConsistency()
- .build();
- teNodeConsistentMap.addListener(teNodeListener);
- teNodeMap = teNodeConsistentMap.asJavaMap();
- connMatrixConsistentMap = storageService
- .<ConnectivityMatrixKey, ConnectivityMatrix>consistentMapBuilder()
- .withSerializer(TETOPOLOGY_SERIALIZER)
- .withName(CONNMATRIXKEY_CONNECTIVITYMATRIX)
- .withRelaxedReadConsistency()
- .build();
- connMatrixMap = connMatrixConsistentMap.asJavaMap();
- networkNodeConsistentMap = storageService
- .<NetworkNodeKey, InternalNetworkNode>consistentMapBuilder()
- .withSerializer(TETOPOLOGY_SERIALIZER)
- .withName(NETWORKNODEKEY_INTERNALNETWORKNODE)
- .withRelaxedReadConsistency()
- .build();
- networkNodeConsistentMap.addListener(networkNodeListener);
- networkNodeMap = networkNodeConsistentMap.asJavaMap();
- teLinkConsistentMap = storageService
- .<TeLinkTpGlobalKey, InternalTeLink>consistentMapBuilder()
- .withSerializer(TETOPOLOGY_SERIALIZER)
- .withName(TELINKGLOBALKEY_INTERNALTELINK)
- .withRelaxedReadConsistency()
- .build();
- teLinkConsistentMap.addListener(teLinkListener);
- teLinkMap = teLinkConsistentMap.asJavaMap();
- networkLinkConsistentMap = storageService
- .<NetworkLinkKey, InternalNetworkLink>consistentMapBuilder()
- .withSerializer(TETOPOLOGY_SERIALIZER)
- .withName(NETWORKLINKKEY_INTERNALNETWORKLINK)
- .withRelaxedReadConsistency()
- .build();
- networkLinkConsistentMap.addListener(networkLinkListener);
- networkLinkMap = networkLinkConsistentMap.asJavaMap();
- tpConsistentMap = storageService
- .<TerminationPointKey, InternalTerminationPoint>consistentMapBuilder()
- .withSerializer(TETOPOLOGY_SERIALIZER)
- .withName(TPKEY_INTERNALTERMINATIONPOINT)
- .withRelaxedReadConsistency()
- .build();
- tpMap = tpConsistentMap.asJavaMap();
- tpKeyConsistentMap = storageService
- .<TeLinkTpGlobalKey, TerminationPointKey>consistentMapBuilder()
- .withSerializer(TETOPOLOGY_SERIALIZER)
- .withName(TELINKTPGLOBALKEY_TERMINATIONPOINTKEY)
- .withRelaxedReadConsistency()
- .build();
- tpKeyMap = tpKeyConsistentMap.asJavaMap();
- ttpConsistentMap = storageService
- .<TtpKey, TunnelTerminationPoint>consistentMapBuilder()
- .withSerializer(TETOPOLOGY_SERIALIZER)
- .withName(TTPKEY_TUNNELTERMINATIONPOINT)
- .withRelaxedReadConsistency()
- .build();
- ttpMap = ttpConsistentMap.asJavaMap();
-
- nextTeTopologyId = storageService.getAtomicCounter(COUNTER_NAME);
- log.info("Started");
- }
-
- /**
- * Distributed network store service deactivate method.
- */
- @Deactivate
- public void deactivate() {
- teTopologyConsistentMap.removeListener(teTopologyListener);
- teTopologyConsistentMap.destroy();
- teTopologyMap.clear();
- networkConsistentMap.removeListener(networkListener);
- networkConsistentMap.destroy();
- networkMap.clear();
- teNodeConsistentMap.removeListener(teNodeListener);
- teNodeConsistentMap.destroy();
- teNodeMap.clear();
- connMatrixConsistentMap.destroy();
- connMatrixMap.clear();
- networkNodeConsistentMap.destroy();
- networkNodeConsistentMap.removeListener(networkNodeListener);
- networkNodeMap.clear();
- teLinkConsistentMap.removeListener(teLinkListener);
- teLinkConsistentMap.destroy();
- teLinkMap.clear();
- networkLinkConsistentMap.destroy();
- networkLinkConsistentMap.removeListener(networkLinkListener);
- networkLinkMap.clear();
- tpConsistentMap.destroy();
- tpMap.clear();
- tpKeyConsistentMap.destroy();
- tpKeyMap.clear();
- ttpConsistentMap.destroy();
- ttpMap.clear();
- mapEventQueue.clear();
- log.info("Stopped");
- }
-
- /**
- * Listener class to map listener map events to the TETOPOLOGY events.
- */
- private class InternalTeTopologyListener implements MapEventListener<TeTopologyKey, InternalTeTopology> {
- @Override
- public void event(MapEvent<TeTopologyKey, InternalTeTopology> event) {
- Type type = null;
- switch (event.type()) {
- case INSERT:
- type = TE_TOPOLOGY_ADDED;
- break;
- case UPDATE:
- if (event.newValue().value().childUpdate()) {
- // Masked by the child events (e.g. Removal)
- break;
- }
- type = TE_TOPOLOGY_UPDATED;
- break;
- case REMOVE:
- type = TE_TOPOLOGY_REMOVED;
- break;
- default:
- log.error("Unsupported event type: {}", event.type());
- }
- if (type != null) {
- TeTopologyMapEvent mapEvent = new TeTopologyMapEvent(type);
- mapEvent.setTeTopologyKey(event.key());
- try {
- mapEventQueue.put(mapEvent);
- } catch (InterruptedException e) {
- log.warn("Unable to queue event {} ", mapEvent, e);
- Thread.currentThread().interrupt();
- }
- }
- }
- }
-
- /**
- * Listener class to map listener map events to the network events.
- */
- private class InternalNetworkListener implements MapEventListener<KeyId, InternalNetwork> {
- @Override
- public void event(MapEvent<KeyId, InternalNetwork> event) {
- Type type = null;
- switch (event.type()) {
- case INSERT:
- type = NETWORK_ADDED;
- break;
- case UPDATE:
- if (event.newValue().value().childUpdate()) {
- // Masked by the child events (e.g. Removal)
- break;
- }
- type = NETWORK_UPDATED;
- break;
- case REMOVE:
- type = NETWORK_REMOVED;
- break;
- default:
- log.error("Unsupported event type: {}", event.type());
- }
- if (type != null) {
- TeTopologyMapEvent mapEvent = new TeTopologyMapEvent(type);
- mapEvent.setNetworkKey(event.key());
- try {
- mapEventQueue.put(mapEvent);
- } catch (InterruptedException e) {
- log.warn("Unable to queue event {} ", mapEvent, e);
- Thread.currentThread().interrupt();
- }
- }
- }
- }
-
- /**
- * Listener class to map listener map events to the TENODE events.
- */
- private class InternalTeNodeListener implements MapEventListener<TeNodeKey, InternalTeNode> {
- @Override
- public void event(MapEvent<TeNodeKey, InternalTeNode> event) {
- Type type = null;
- switch (event.type()) {
- case INSERT:
- if (event.newValue().value().parentUpdate()) {
- // Masked by the parent event (e.g. Add)
- break;
- }
- type = TE_NODE_ADDED;
- break;
- case UPDATE:
- if (event.newValue().value().childUpdate() ||
- event.newValue().value().parentUpdate()) {
- // Masked by the child event (e.g. Removal) or parent event
- break;
- }
- type = TE_NODE_UPDATED;
- break;
- case REMOVE:
- type = TE_NODE_REMOVED;
- break;
- default:
- log.error("Unsupported event type: {}", event.type());
- }
- if (type != null) {
- TeTopologyMapEvent mapEvent = new TeTopologyMapEvent(type);
- mapEvent.setTeNodeKey(event.key());
- try {
- mapEventQueue.put(mapEvent);
- } catch (InterruptedException e) {
- log.warn("Unable to queue event {} ", mapEvent, e);
- Thread.currentThread().interrupt();
- }
- }
- }
- }
-
- /**
- * Listener class to map listener map events to the NETWORK NODE events.
- */
- private class InternalNetworkNodeListener implements MapEventListener<NetworkNodeKey, InternalNetworkNode> {
- @Override
- public void event(MapEvent<NetworkNodeKey, InternalNetworkNode> event) {
- Type type = null;
- switch (event.type()) {
- case INSERT:
- if (event.newValue().value().parentUpdate()) {
- // Masked by the parent event (e.g. Add)
- break;
- }
- type = NODE_ADDED;
- break;
- case UPDATE:
- if (event.newValue().value().childUpdate() ||
- event.newValue().value().parentUpdate()) {
- // Masked by the child event (e.g. Removal) or parent event
- break;
- }
- type = NODE_UPDATED;
- break;
- case REMOVE:
- type = NODE_REMOVED;
- break;
- default:
- log.error("Unsupported event type: {}", event.type());
- }
- if (type != null) {
- TeTopologyMapEvent mapEvent = new TeTopologyMapEvent(type);
- mapEvent.setNetworkNodeKey(event.key());
- try {
- mapEventQueue.put(mapEvent);
- } catch (InterruptedException e) {
- log.warn("Unable to queue event {} ", mapEvent, e);
- Thread.currentThread().interrupt();
- }
- }
- }
- }
-
- /**
- * Listener class to map listener map events to the TELINK events.
- */
- private class InternalTeLinkListener implements MapEventListener<TeLinkTpGlobalKey, InternalTeLink> {
- @Override
- public void event(MapEvent<TeLinkTpGlobalKey, InternalTeLink> event) {
- Type type = null;
- switch (event.type()) {
- case INSERT:
- if (event.newValue().value().parentUpdate()) {
- // Masked by the parent event (e.g. Add)
- break;
- }
- type = TE_LINK_ADDED;
- break;
- case UPDATE:
- if (event.newValue().value().parentUpdate()) {
- // Masked by parent event
- break;
- }
- type = TE_LINK_UPDATED;
- break;
- case REMOVE:
- type = TE_LINK_REMOVED;
- break;
- default:
- log.error("Unsupported event type: {}", event.type());
- }
- if (type != null) {
- TeTopologyMapEvent mapEvent = new TeTopologyMapEvent(type);
- mapEvent.setTeLinkKey(event.key());
- try {
- mapEventQueue.put(mapEvent);
- } catch (InterruptedException e) {
- log.warn("Unable to queue event {} ", mapEvent, e);
- Thread.currentThread().interrupt();
- }
- }
- }
- }
-
- /**
- * Listener class to map listener map events to the NETWORK LINK events.
- */
- private class InternalNetworkLinkListener implements MapEventListener<NetworkLinkKey, InternalNetworkLink> {
- @Override
- public void event(MapEvent<NetworkLinkKey, InternalNetworkLink> event) {
- Type type = null;
- switch (event.type()) {
- case INSERT:
- if (event.newValue().value().parentUpdate()) {
- // Masked by the parent event (e.g. Add)
- break;
- }
- type = LINK_ADDED;
- break;
- case UPDATE:
- if (event.newValue().value().parentUpdate()) {
- // Masked by the child event (e.g. Removal) or parent event
- break;
- }
- type = LINK_UPDATED;
- break;
- case REMOVE:
- type = LINK_REMOVED;
- break;
- default:
- log.error("Unsupported event type: {}", event.type());
- }
- if (type != null) {
- TeTopologyMapEvent mapEvent = new TeTopologyMapEvent(type);
- mapEvent.setNetworkLinkKey(event.key());
- try {
- mapEventQueue.put(mapEvent);
- } catch (InterruptedException e) {
- log.warn("Unable to queue event {} ", mapEvent, e);
- Thread.currentThread().interrupt();
- }
- }
- }
- }
-
- @Override
- public TeTopologies teTopologies() {
- Map<TeTopologyKey, TeTopology> teTopologies = Maps.newHashMap();
- if (MapUtils.isNotEmpty(teTopologyMap)) {
- for (TeTopologyKey key : teTopologyMap.keySet()) {
- teTopologies.put(key, teTopology(key));
- }
- }
- return new DefaultTeTopologies(STORE_NAME, teTopologies);
- }
-
- private TeTopology teTopology(TeTopologyKey topologyId,
- InternalTeTopology intTopology) {
- if (intTopology == null) {
- return null;
- }
- Map<Long, TeNode> teNodes = null;
- if (CollectionUtils.isNotEmpty(intTopology.teNodeKeys())) {
- teNodes = Maps.newHashMap();
- for (TeNodeKey key : intTopology.teNodeKeys()) {
- teNodes.put(key.teNodeId(), teNode(key));
- }
- }
- Map<TeLinkTpKey, TeLink> teLinks = null;
- if (CollectionUtils.isNotEmpty(intTopology.teLinkKeys())) {
- teLinks = Maps.newHashMap();
- for (TeLinkTpGlobalKey key : intTopology.teLinkKeys()) {
- teLinks.put(key.teLinkTpKey(), teLink(key));
- }
- }
- return new DefaultTeTopology(topologyId, teNodes, teLinks,
- intTopology.teTopologyId(), intTopology.topologyData());
- }
-
- @Override
- public TeTopology teTopology(TeTopologyKey topologyId) {
- InternalTeTopology intTopology = teTopologyMap.get(topologyId);
- return teTopology(topologyId, intTopology);
- }
-
- private void removeTopologyeMapEntrys(InternalTeTopology curTopology) {
- // Remove TE nodes
- if (CollectionUtils.isNotEmpty(curTopology.teNodeKeys())) {
- for (TeNodeKey key : curTopology.teNodeKeys()) {
- removeTeNode(key, true);
- }
- }
- // Remove TE Links
- if (CollectionUtils.isNotEmpty(curTopology.teLinkKeys())) {
- for (TeLinkTpGlobalKey key : curTopology.teLinkKeys()) {
- removeTeLink(key, true);
- }
- }
- }
-
- @Override
- public void updateTeTopology(TeTopology teTopology) {
- InternalTeTopology curTopology = teTopologyMap.get(teTopology.teTopologyId());
- // Update TE nodes
- List<NetworkNodeKey> nodeIds = null;
- if (MapUtils.isNotEmpty(teTopology.teNodes())) {
- nodeIds = Lists.newArrayList();
- for (Map.Entry<Long, TeNode> entry : teTopology.teNodes().entrySet()) {
- TeNodeKey teNodeKey = new TeNodeKey(teTopology.teTopologyId(), entry.getKey());
- NetworkNodeKey nodeKey = TeMgrUtil.networkNodeKey(teNodeKey);
- updateTeNode(teNodeKey, entry.getValue(), true, true, nodeKey);
- nodeIds.add(nodeKey);
- }
- }
- // Update TE links
- List<NetworkLinkKey> linkIds = null;
- if (MapUtils.isNotEmpty(teTopology.teLinks())) {
- linkIds = Lists.newArrayList();
- for (Map.Entry<TeLinkTpKey, TeLink> entry : teTopology.teLinks().entrySet()) {
- TeLinkTpGlobalKey teLinkKey = new TeLinkTpGlobalKey(teTopology.teTopologyId(),
- entry.getKey());
- NetworkLinkKey linkKey = TeMgrUtil.networkLinkKey(teLinkKey);
- updateTeLink(teLinkKey, entry.getValue(), true, true, linkKey);
- linkIds.add(linkKey);
- }
- }
- // Finally Update teTopologyMap
- InternalTeTopology newTopology = new InternalTeTopology(teTopology);
- teTopologyMap.put(teTopology.teTopologyId(), newTopology);
-
- if (curTopology == null) {
- // New topology, update networkMap
- InternalNetwork intNetwork = new InternalNetwork();
- intNetwork.setServerProvided(false);
- intNetwork.setTeTopologyKey(teTopology.teTopologyId());
- intNetwork.setNodeIds(nodeIds);
- intNetwork.setLinkIds(linkIds);
- networkMap.put(teTopology.networkId(), intNetwork);
- }
- }
-
- @Override
- public void removeTeTopology(TeTopologyKey topologyId) {
- // Remove it from teTopologyMap
- InternalTeTopology topology = teTopologyMap.remove(topologyId);
- if (topology != null) {
- removeTopologyeMapEntrys(topology);
- // Remove it from networkMap;
- networkMap.remove(topology.topologyData().networkId());
- }
- }
-
- @Override
- public List<Network> networks() {
- if (MapUtils.isEmpty(networkMap)) {
- return null;
- }
- List<Network> networks = Lists.newArrayList();
- for (KeyId networkId : networkMap.keySet()) {
- networks.add(network(networkId));
- }
- return networks;
- }
-
- private Network network(KeyId networkId, InternalNetwork curNetwork) {
- if (curNetwork == null) {
- return null;
- }
- List<KeyId> supportingNetworkIds = curNetwork.supportingNetworkIds();
- Map<KeyId, NetworkNode> nodes = null;
- if (CollectionUtils.isNotEmpty(curNetwork.nodeIds())) {
- nodes = Maps.newHashMap();
- for (NetworkNodeKey key : curNetwork.nodeIds()) {
- nodes.put(key.nodeId(), networkNode(key));
- }
- }
- Map<KeyId, NetworkLink> links = null;
- if (CollectionUtils.isNotEmpty(curNetwork.linkIds())) {
- links = Maps.newHashMap();
- for (NetworkLinkKey key : curNetwork.linkIds()) {
- links.put(key.linkId(), networkLink(key));
- }
- }
- TeTopologyId topologyId = null;
- DeviceId ownerId = null;
- OptimizationType opt = NOT_OPTIMIZED;
- if (curNetwork.teTopologyKey() != null &&
- teTopologyMap.get(curNetwork.teTopologyKey()) != null) {
- topologyId = new TeTopologyId(curNetwork.teTopologyKey().providerId(),
- curNetwork.teTopologyKey().clientId(),
- teTopologyMap.get(curNetwork.teTopologyKey())
- .teTopologyId());
- ownerId = teTopologyMap.get(curNetwork.teTopologyKey())
- .topologyData().ownerId();
- opt = teTopologyMap.get(curNetwork.teTopologyKey()).topologyData().optimization();
- }
- return new DefaultNetwork(networkId, supportingNetworkIds, nodes, links,
- topologyId, curNetwork.serverProvided(), ownerId, opt);
- }
-
- @Override
- public Network network(KeyId networkId) {
- InternalNetwork curNetwork = networkMap.get(networkId);
- return network(networkId, curNetwork);
- }
-
- private void removeNetworkMapEntrys(InternalNetwork curNetwork, boolean teRemove) {
- // Remove TE nodes
- if (CollectionUtils.isNotEmpty(curNetwork.nodeIds())) {
- for (NetworkNodeKey key : curNetwork.nodeIds()) {
- removeNetworkNode(key, teRemove);
- }
- }
- // Remove TE Links
- if (CollectionUtils.isNotEmpty(curNetwork.linkIds())) {
- for (NetworkLinkKey key : curNetwork.linkIds()) {
- removeNetworkLink(key, teRemove);
- }
- }
- }
-
- private TeTopologyKey newTeTopologyKey(TeTopologyId teTopologyId) {
- long idValue;
- try {
- idValue = Long.parseLong(teTopologyId.topologyId());
- } catch (NumberFormatException e) {
- // Can't get the long value from the string.
- // Use an assigned id value from local id pool,
- // Ideally id should be assigned per provider base.
- idValue = nextTeTopologyId();
- }
- return new TeTopologyKey(teTopologyId.providerId(), teTopologyId.clientId(), idValue);
- }
-
- @Override
- public void updateNetwork(Network network) {
- log.debug("updateNetwork {}", network);
- InternalNetwork curNetwork = networkMap.get(network.networkId());
- TeTopologyKey topoKey = null;
- if (network.teTopologyId() != null) {
- topoKey = newTeTopologyKey(network.teTopologyId());
- }
- // Update TE nodes
- List<TeNodeKey> teNodeKeys = null;
- if (MapUtils.isNotEmpty(network.nodes())) {
- teNodeKeys = Lists.newArrayList();
- for (Map.Entry<KeyId, NetworkNode> entry : network.nodes().entrySet()) {
- NetworkNodeKey nodeKey = new NetworkNodeKey(network.networkId(), entry.getKey());
- TeNodeKey teNodeKey = null;
- if (topoKey != null && entry.getValue().teNode() != null) {
- teNodeKey = new TeNodeKey(topoKey, entry.getValue().teNode().teNodeId());
- }
- updateNetworkNode(nodeKey, entry.getValue(), true, false, teNodeKey);
- teNodeKeys.add(teNodeKey);
- }
- }
- // Update TE links
- List<TeLinkTpGlobalKey> teLinkKeys = null;
- if (MapUtils.isNotEmpty(network.links())) {
- teLinkKeys = Lists.newArrayList();
- for (Map.Entry<KeyId, NetworkLink> entry : network.links().entrySet()) {
- NetworkLinkKey linkKey = new NetworkLinkKey(network.networkId(), entry.getKey());
- TeLinkTpGlobalKey teLinkKey = null;
- if (topoKey != null && entry.getValue().teLink() != null) {
- teLinkKey = new TeLinkTpGlobalKey(topoKey, entry.getValue().teLink().teLinkKey());
- }
- updateNetworkLink(linkKey, entry.getValue(), true, false, teLinkKey);
- teLinkKeys.add(teLinkKey);
- }
- }
-
- // New network, update TE Topology first
- if (curNetwork == null) {
- InternalTeTopology intTopo = new InternalTeTopology(network.teTopologyId().topologyId());
- intTopo.setTeNodeKeys(teNodeKeys);
- intTopo.setTeLinkKeys(teLinkKeys);
- BitSet flags = new BitSet(TeConstants.FLAG_MAX_BITS);
- flags.set(TeTopology.BIT_LEARNT);
- if (network.teTopologyId().clientId() == providerId) {
- // Hard rule for now
- flags.set(TeTopology.BIT_CUSTOMIZED);
- }
- CommonTopologyData common = new CommonTopologyData(network.networkId(),
- network.optimization(),
- flags,
- network.ownerId());
- intTopo.setTopologydata(common);
- teTopologyMap.put(topoKey, intTopo);
- }
- // Finally Update networkMap
- InternalNetwork newNetwork = new InternalNetwork(network);
- newNetwork.setTeTopologyKey(topoKey);
- networkMap.put(network.networkId(), newNetwork);
- }
-
- @Override
- public void removeNetwork(KeyId networkId) {
- // Remove it from networkMap
- InternalNetwork network = networkMap.remove(networkId);
- if (network != null && network.teTopologyKey() != null) {
- removeNetworkMapEntrys(network, false);
- teTopologyMap.remove(network.teTopologyKey());
- }
- }
-
- private TeNode teNode(TeNodeKey nodeKey, InternalTeNode intNode) {
- if (intNode == null) {
- return null;
- }
- Map<Long, ConnectivityMatrix> connMatrices = null;
- if (CollectionUtils.isNotEmpty(intNode.connMatrixKeys())) {
- connMatrices = Maps.newHashMap();
- for (ConnectivityMatrixKey key : intNode.connMatrixKeys()) {
- connMatrices.put(key.entryId(), connMatrixMap.get(key));
- }
- }
- List<Long> teLinkIds = null;
- if (CollectionUtils.isNotEmpty(intNode.teLinkTpKeys())) {
- teLinkIds = Lists.newArrayList();
- for (TeLinkTpGlobalKey key : intNode.teLinkTpKeys()) {
- teLinkIds = TeUtils.addListElement(teLinkIds, key.teLinkTpId());
- }
- }
- List<Long> tps = null;
- if (CollectionUtils.isNotEmpty(intNode.teTpKeys())) {
- tps = Lists.newArrayList();
- for (TeLinkTpGlobalKey key : intNode.teTpKeys()) {
- tps = TeUtils.addListElement(tps, key.teLinkTpId());
- }
- }
- Map<Long, TunnelTerminationPoint> ttps = null;
- if (CollectionUtils.isNotEmpty(intNode.ttpKeys())) {
- ttps = Maps.newHashMap();
- for (TtpKey key : intNode.ttpKeys()) {
- ttps.put(key.ttpId(), ttpMap.get(key));
- }
- }
- return new DefaultTeNode(nodeKey.teNodeId(),
- intNode.underlayTopologyKey(),
- intNode.supportNodeKey(),
- intNode.sourceTeNodeKey(),
- intNode.teData(),
- connMatrices, teLinkIds, ttps, tps);
- }
-
- @Override
- public TeNode teNode(TeNodeKey nodeKey) {
- InternalTeNode intNode = teNodeMap.get(nodeKey);
- return teNode(nodeKey, intNode);
- }
-
- private void removeTeNodeMapEntrys(InternalTeNode intNode) {
- // Remove connMatrixMap entries for the node
- if (CollectionUtils.isNotEmpty(intNode.connMatrixKeys())) {
- for (ConnectivityMatrixKey key : intNode.connMatrixKeys()) {
- connMatrixMap.remove(key);
- }
- }
- // Remove ttpMap entries for the node
- if (CollectionUtils.isNotEmpty(intNode.ttpKeys())) {
- for (TtpKey key : intNode.ttpKeys()) {
- ttpMap.remove(key);
- }
- }
- }
-
- private void updateTeNode(TeNodeKey nodeKey, TeNode node, boolean parentUpdate,
- boolean teNodeUpdate, NetworkNodeKey networkNodeKey) {
- InternalTeTopology intTopo = teTopologyMap.get(nodeKey.teTopologyKey());
- if (intTopo == null && !parentUpdate) {
- log.error("TE Topology is not in dataStore for nodeUpdate {}", nodeKey);
- return;
- }
- InternalTeNode curNode = teNodeMap.get(nodeKey);
- // Update connMatrixMap
- if (MapUtils.isNotEmpty(node.connectivityMatrices())) {
- for (Map.Entry<Long, ConnectivityMatrix> entry : node.connectivityMatrices().entrySet()) {
- connMatrixMap.put(new ConnectivityMatrixKey(nodeKey, entry.getKey()),
- entry.getValue());
- }
- }
- // Update ttpMap
- if (MapUtils.isNotEmpty(node.tunnelTerminationPoints())) {
- for (Map.Entry<Long, TunnelTerminationPoint> entry : node.tunnelTerminationPoints().entrySet()) {
- ttpMap.put(new TtpKey(nodeKey, entry.getKey()), entry.getValue());
- }
- }
- // Update teNodeMap
- InternalTeNode intNode = new InternalTeNode(nodeKey, node, networkNodeKey, parentUpdate);
- teNodeMap.put(nodeKey, intNode);
- if (curNode == null && !parentUpdate && intTopo != null) {
- // Update InternalTeTopology
- intTopo.setChildUpdate(true);
- TeUtils.addListElement(intTopo.teNodeKeys(), nodeKey);
- }
- // Update networkNodeMap
- if (teNodeUpdate) {
- updateNetworkNode(networkNodeKey, networkNode(node), parentUpdate,
- teNodeUpdate, nodeKey);
- }
- }
-
- private NetworkNode networkNode(TeNode node) {
- KeyId nodeId = KeyId.keyId(Long.toString(node.teNodeId()));
- List<NetworkNodeKey> supportingNodeIds = null;
- if (node.supportingTeNodeId() != null) {
- supportingNodeIds = Lists.newArrayList();
- supportingNodeIds.add(new NetworkNodeKey(
- TeMgrUtil.toNetworkId((node.supportingTeNodeId().teTopologyKey())),
- KeyId.keyId(Long.toString(node.supportingTeNodeId().teNodeId()))));
- }
- Map<KeyId, TerminationPoint> tps = null;
- if (node.teTerminationPointIds() != null) {
- tps = Maps.newHashMap();
- for (Long teTpId : node.teTerminationPointIds()) {
- tps.put(KeyId.keyId(Long.toString(teTpId)),
- new DefaultTerminationPoint(KeyId.keyId(Long.toString(teTpId)),
- null, teTpId));
- }
- }
- return new DefaultNetworkNode(nodeId, supportingNodeIds, node, tps);
- }
-
- @Override
- public void updateTeNode(TeNodeKey nodeKey, TeNode node) {
- updateTeNode(nodeKey, node, false, true, TeMgrUtil.networkNodeKey(nodeKey));
- }
-
- private void removeTeNode(TeNodeKey nodeKey, boolean teNodeRemove) {
- // Remove it from InternalTeTopology first
- InternalTeTopology intTopo = teTopologyMap.get(nodeKey.teTopologyKey());
- if (intTopo != null && CollectionUtils.isNotEmpty(intTopo.teNodeKeys())) {
- intTopo.setChildUpdate(true);
- intTopo.teNodeKeys().remove(nodeKey);
- }
- // Then remove it from teNodeMap
- InternalTeNode node = teNodeMap.remove(nodeKey);
-
- if (node == null) {
- log.error("No node found for nodeKey {}", nodeKey);
- return;
- }
-
- removeTeNodeMapEntrys(node);
- // Remove it from networkNodeMap
- if (teNodeRemove && node != null) {
- removeNetworkNode(node.networkNodeKey(), teNodeRemove);
- }
- }
-
- @Override
- public void removeTeNode(TeNodeKey nodeKey) {
- removeTeNode(nodeKey, true);
- }
-
- private NetworkNode networkNode(NetworkNodeKey nodeKey, InternalNetworkNode intNode) {
- if (intNode == null) {
- return null;
- }
- Map<KeyId, TerminationPoint> tps = Maps.newHashMap();
- for (KeyId tpId : intNode.tpIds()) {
- tps.put(tpId, terminationPoint(
- new TerminationPointKey(nodeKey, tpId)));
-
- }
- return new DefaultNetworkNode(nodeKey.nodeId(), intNode.supportingNodeIds(),
- teNode(intNode.teNodeKey()), tps);
- }
-
- @Override
- public NetworkNode networkNode(NetworkNodeKey nodeKey) {
- InternalNetworkNode intNode = networkNodeMap.get(nodeKey);
- return networkNode(nodeKey, intNode);
- }
-
- private void updateNetworkNode(NetworkNodeKey nodeKey, NetworkNode node,
- boolean parentUpdate, boolean teNodeUpdate, TeNodeKey teNodeKey) {
- InternalNetwork intNework = null;
- if (!parentUpdate) {
- intNework = networkMap.get(nodeKey.networkId());
- if (intNework == null) {
- log.error("Network is not in dataStore for nodeUpdate {}", nodeKey);
- return;
- }
- }
-
- InternalNetworkNode exNode = networkNodeMap.get(nodeKey);
- if (exNode != null && CollectionUtils.isNotEmpty(exNode.tpIds())) {
- // Remove the TerminationPoints first
- for (KeyId tpId : exNode.tpIds()) {
- removeTerminationPoint(new TerminationPointKey(nodeKey, tpId));
- }
- }
-
- if (MapUtils.isNotEmpty(node.terminationPoints())) {
- // Update with new TerminationPoints
- for (Map.Entry<KeyId, TerminationPoint> entry : node.terminationPoints().entrySet()) {
- updateTerminationPoint(new TerminationPointKey(nodeKey, entry.getKey()),
- entry.getValue(), parentUpdate, teNodeKey);
- }
- }
-
- // Update teNodeMap first
- if (!teNodeUpdate && teNodeKey != null && node.teNode() != null) {
- updateTeNode(teNodeKey, node.teNode(), parentUpdate, teNodeUpdate, nodeKey);
- }
- // Update networkNodeMap
- InternalNetworkNode intNode = new InternalNetworkNode(node, parentUpdate);
- intNode.setTeNodeKey(teNodeKey);
- networkNodeMap.put(nodeKey, intNode);
- if (exNode == null && !parentUpdate && intNework != null) {
- // Update the InternalNetwork
- intNework.setChildUpdate(true);
- TeUtils.addListElement(intNework.nodeIds(), nodeKey);
- }
- }
-
- @Override
- public void updateNetworkNode(NetworkNodeKey nodeKey, NetworkNode node) {
- TeNodeKey teNodeKey = null;
- if (node.teNode() != null) {
- teNodeKey = new TeNodeKey(networkMap.get(nodeKey.networkId()).teTopologyKey(),
- node.teNode().teNodeId());
- }
- updateNetworkNode(nodeKey, node, false, false, teNodeKey);
- }
-
- private void removeNetworkNode(NetworkNodeKey nodeKey, boolean teNodeRemove) {
- // Update the InternalNetwork
- InternalNetwork intNework = networkMap.get(nodeKey.networkId());
- if (intNework != null && CollectionUtils.isNotEmpty(intNework.nodeIds())) {
- intNework.setChildUpdate(true);
- intNework.nodeIds().remove(nodeKey);
- }
- InternalNetworkNode intNode = networkNodeMap.remove(nodeKey);
- if (intNode != null && CollectionUtils.isNotEmpty(intNode.tpIds())) {
- // Remove the TerminationPoints first
- for (KeyId tpId : intNode.tpIds()) {
- removeTerminationPoint(new TerminationPointKey(nodeKey, tpId));
- }
- }
- if (!teNodeRemove && intNode != null) {
- // Now remove it from teNodeMap
- removeTeNode(intNode.teNodeKey(), teNodeRemove);
- }
- }
-
- @Override
- public void removeNetworkNode(NetworkNodeKey nodeKey) {
- removeNetworkNode(nodeKey, false);
- }
-
- private TeLink teLink(TeLinkTpGlobalKey linkKey, InternalTeLink intLink) {
- if (intLink == null) {
- return null;
- }
- return new DefaultTeLink(linkKey.teLinkTpKey(),
- intLink.peerTeLinkKey(),
- intLink.underlayTopologyKey(),
- intLink.supportingLinkKey(),
- intLink.sourceTeLinkKey(),
- intLink.teData());
- }
-
- @Override
- public TeLink teLink(TeLinkTpGlobalKey linkKey) {
- InternalTeLink intLink = teLinkMap.get(linkKey);
- return teLink(linkKey, intLink);
- }
-
- private void updateTeLink(TeLinkTpGlobalKey linkKey, TeLink link,
- boolean parentUpdate, boolean teLinkUpdate, NetworkLinkKey networkLinkKey) {
- InternalTeTopology intTopo = teTopologyMap.get(linkKey.teTopologyKey());
- if (intTopo == null && !parentUpdate) {
- log.error("TE Topology is not in dataStore for linkUpdate {}", linkKey);
- return;
- }
- InternalTeNode intNode = teNodeMap.get(linkKey.teNodeKey());
- if (intNode == null && !parentUpdate) {
- log.error("TE node is not in dataStore for linkUpdate {}", linkKey);
- return;
- }
- InternalTeLink exLink = teLinkMap.get(linkKey);
-
- // Update teLinkMap
- InternalTeLink intLink = new InternalTeLink(link, parentUpdate);
- intLink.setNetworkLinkKey(networkLinkKey);
- teLinkMap.put(linkKey, intLink);
- if (exLink == null && !parentUpdate) {
- if (intTopo != null) {
- // Update the InternalTeTopology
- intTopo.setChildUpdate(true);
- intTopo.setTeLinkKeys(TeUtils.addListElement(intTopo.teLinkKeys(), linkKey));
- }
- if (intNode != null) {
- // Update the InternalNode
- intNode.setChildUpdate(true);
- intNode.setTeLinkTpKeys(TeUtils.addListElement(intNode.teLinkTpKeys(), linkKey));
- }
- }
-
- // Update networkLinkMap
- if (teLinkUpdate) {
- updateNetworkLink(networkLinkKey, networkLink(link), parentUpdate,
- teLinkUpdate, linkKey);
- }
- }
-
- private NetworkLink networkLink(TeLink link) {
- KeyId linkId = TeMgrUtil.toNetworkLinkId(link.teLinkKey());
- NodeTpKey source = null;
- if (link.teLinkKey() != null) {
- source = new NodeTpKey(KeyId.keyId(Long.toString(link.teLinkKey().teNodeId())),
- KeyId.keyId(Long.toString(link.teLinkKey().teLinkTpId())));
- }
- NodeTpKey dest = null;
- if (link.peerTeLinkKey() != null) {
- dest = new NodeTpKey(KeyId.keyId(Long.toString(link.peerTeLinkKey().teNodeId())),
- KeyId.keyId(Long.toString(link.peerTeLinkKey().teLinkTpId())));
- }
- List<NetworkLinkKey> supportingLinkIds = null;
- if (link.supportingTeLinkId() != null) {
- supportingLinkIds = Lists.newArrayList();
- supportingLinkIds.add(new NetworkLinkKey(
- TeMgrUtil.toNetworkId(link.supportingTeLinkId().teTopologyKey()),
- TeMgrUtil.toNetworkLinkId(link.supportingTeLinkId().teLinkTpKey())));
- }
- return new DefaultNetworkLink(linkId, source, dest, supportingLinkIds, link);
- }
-
- @Override
- public void updateTeLink(TeLinkTpGlobalKey linkKey, TeLink link) {
- updateTeLink(linkKey, link, false, true, TeMgrUtil.networkLinkKey(linkKey));
- }
-
- private void removeTeLink(TeLinkTpGlobalKey linkKey, boolean teLinkRemove) {
- // Remove it from InternalTeTopology first
- InternalTeTopology intTopo = teTopologyMap.get(linkKey.teTopologyKey());
- if (intTopo != null && CollectionUtils.isNotEmpty(intTopo.teLinkKeys())) {
- intTopo.setChildUpdate(true);
- intTopo.teLinkKeys().remove(linkKey);
- }
- // Remove it from InternalTeNode
- InternalTeNode intNode = teNodeMap.get(linkKey.teNodeKey());
- if (intNode != null && CollectionUtils.isNotEmpty(intNode.teLinkTpKeys())) {
- intNode.setChildUpdate(true);
- intNode.teLinkTpKeys().remove(linkKey);
- }
- // Then remove it from teLinkMap
- InternalTeLink link = teLinkMap.remove(linkKey);
- if (teLinkRemove && link != null) {
- // Remove it from networkLinkMap
- removeNetworkLink(link.networkLinkKey(), teLinkRemove);
- }
- }
-
- @Override
- public void removeTeLink(TeLinkTpGlobalKey linkKey) {
- removeTeLink(linkKey, true);
- }
-
- private NetworkLink networkLink(NetworkLinkKey linkKey, InternalNetworkLink intLink) {
- if (intLink == null) {
- return null;
- }
- return new DefaultNetworkLink(linkKey.linkId(), intLink.source(),
- intLink.destination(), intLink.supportingLinkIds(), teLink(intLink.teLinkKey()));
- }
-
- @Override
- public NetworkLink networkLink(NetworkLinkKey linkKey) {
- InternalNetworkLink intLink = networkLinkMap.get(linkKey);
- return networkLink(linkKey, intLink);
- }
-
- private void updateNetworkLink(NetworkLinkKey linkKey, NetworkLink link,
- boolean parentUpdate, boolean teLinkUpdate, TeLinkTpGlobalKey teLinkKey) {
- InternalNetwork intNework = null;
- if (!parentUpdate) {
- intNework = networkMap.get(linkKey.networkId());
- if (intNework == null) {
- log.error("Network is not in dataStore for linkUpdate {}", linkKey);
- return;
- }
- }
-
- InternalNetworkLink exLink = networkLinkMap.get(linkKey);
-
- // Now update teLinkMap first
- if (!teLinkUpdate && teLinkKey != null) {
- updateTeLink(teLinkKey, link.teLink(), parentUpdate, teLinkUpdate, linkKey);
- }
- // Update networkLinkMap
- InternalNetworkLink intLink = new InternalNetworkLink(link, parentUpdate);
- intLink.setTeLinkKey(teLinkKey);
- networkLinkMap.put(linkKey, intLink);
- if (exLink == null && !parentUpdate && intNework != null) {
- // Update the InternalNetwork
- intNework.setChildUpdate(true);
- TeUtils.addListElement(intNework.linkIds(), linkKey);
- }
- }
-
- @Override
- public void updateNetworkLink(NetworkLinkKey linkKey, NetworkLink link) {
- TeLinkTpGlobalKey teLinkKey = null;
- if (link.teLink() != null) {
- teLinkKey = new TeLinkTpGlobalKey(networkMap.get(linkKey.networkId()).teTopologyKey(),
- link.teLink().teLinkKey());
- }
-
- updateNetworkLink(linkKey, link, false, false, teLinkKey);
- }
-
- private void removeNetworkLink(NetworkLinkKey linkKey, boolean teLinkRemove) {
- // Update the InternalNetwork
- InternalNetwork intNework = networkMap.get(linkKey.networkId());
- if (intNework != null && CollectionUtils.isNotEmpty(intNework.linkIds())) {
- intNework.setChildUpdate(true);
- intNework.linkIds().remove(linkKey);
- }
- // Remove it from networkLinkMap
- InternalNetworkLink intLink = networkLinkMap.remove(linkKey);
- if (!teLinkRemove && intLink != null && intLink.teLinkKey() != null) {
- // Now remove it from teLinkMap
- removeTeLink(intLink.teLinkKey(), teLinkRemove);
- }
- }
-
- @Override
- public void removeNetworkLink(NetworkLinkKey linkKey) {
- removeNetworkLink(linkKey, false);
- }
-
- private TerminationPoint terminationPoint(TerminationPointKey tpKey) {
- InternalTerminationPoint intTp = tpMap.get(tpKey);
- if (intTp == null) {
- return null;
- }
- return new DefaultTerminationPoint(tpKey.tpId(), intTp.supportingTpIds(),
- intTp.teTpKey().teLinkTpId());
- }
-
- private void updateTerminationPoint(TerminationPointKey tpKey,
- TerminationPoint tp, boolean parentUpdate, TeNodeKey teNodeKey) {
- TeNodeKey myTeNodeKey;
- InternalNetworkNode intNode = null;
- if (!parentUpdate) {
- intNode = networkNodeMap.get(tpKey);
- if (intNode == null) {
- log.error(" node is not in dataStore for tp update {}", tpKey);
- return;
- }
- myTeNodeKey = intNode.teNodeKey();
- } else {
- myTeNodeKey = teNodeKey;
- }
- TeLinkTpGlobalKey teTpKey = new TeLinkTpGlobalKey(myTeNodeKey, tp.teTpId());
-
- boolean newTp = tpMap.get(tpKey) == null;
- InternalTerminationPoint intTp = new InternalTerminationPoint(tp);
- intTp.setTeTpKey(teTpKey);
- tpMap.put(tpKey, intTp);
- if (newTp) {
- // Update tpKeyMap
- tpKeyMap.put(teTpKey, tpKey);
- if (!parentUpdate && intNode != null) {
- // Update InternalNetworkNode
- intNode.setChildUpdate(true);
- intNode.setTpIds(TeUtils.addListElement(intNode.tpIds(), tpKey.tpId()));
- }
- }
- }
-
- @Override
- public void updateTerminationPoint(TerminationPointKey tpKey,
- TerminationPoint tp) {
- updateTerminationPoint(tpKey, tp, false, null);
- }
-
- @Override
- public void removeTerminationPoint(TerminationPointKey tpKey) {
- // Update InternalNetworkNode
- InternalNetworkNode intNode = networkNodeMap.get(tpKey);
- if (intNode != null && CollectionUtils.isNotEmpty(intNode.tpIds())) {
- intNode.setChildUpdate(true);
- intNode.tpIds().remove(tpKey.tpId());
- }
- // Remove it from tpMap
- InternalTerminationPoint tp = tpMap.remove(tpKey);
- // Remove it from tpKeyMap
- if (tp != null) {
- tpKeyMap.remove(tp.teTpKey());
- }
- }
-
- @Override
- public TunnelTerminationPoint tunnelTerminationPoint(TtpKey ttpId) {
- return ttpMap.get(ttpId);
- }
-
- @Override
- public long nextTeTopologyId() {
- return nextTeTopologyId.getAndIncrement();
- }
-
- @Override
- public long nextTeNodeId(TeTopologyKey topoKey) {
- return teTopologyMap.get(topoKey).nextTeNodeId();
- }
-
- @Override
- public void setNextTeNodeId(TeTopologyKey topoKey, long nextNodeId) {
- teTopologyMap.get(topoKey).setNextTeNodeId(nextNodeId);
- }
-
- @Override
- public KeyId networkId(TeTopologyKey teTopologyKey) {
- return teTopologyMap.get(teTopologyKey) == null ||
- teTopologyMap.get(teTopologyKey).topologyData() == null ? null :
- teTopologyMap.get(teTopologyKey).topologyData().networkId();
- }
-
- @Override
- public NetworkNodeKey nodeKey(TeNodeKey teNodeKey) {
- return teNodeMap.get(teNodeKey) == null ? null :
- teNodeMap.get(teNodeKey).networkNodeKey();
- }
-
- @Override
- public NetworkLinkKey linkKey(TeLinkTpGlobalKey teLinkKey) {
- return teLinkMap.get(teLinkKey) == null ? null :
- teLinkMap.get(teLinkKey).networkLinkKey();
- }
-
- @Override
- public TerminationPointKey terminationPointKey(TeLinkTpGlobalKey teTpKey) {
- return tpKeyMap.get(teTpKey);
- }
-
- @Override
- public BlockingQueue<TeTopologyMapEvent> mapEventQueue() {
- return mapEventQueue;
- }
-
- @Override
- public void setProviderId(long providerId) {
- this.providerId = providerId;
- }
-}
-
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalNetwork.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalNetwork.java
deleted file mode 100644
index 710a567..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalNetwork.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.impl;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.collections.MapUtils;
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.Network;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.node.NetworkNode;
-import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-/**
- * Network representation in store.
- */
-public class InternalNetwork {
- private TeTopologyKey teTopologyKey;
- private List<KeyId> supportingNetworkIds;
- private boolean serverProvided;
- private List<NetworkNodeKey> nodeIds;
- private List<NetworkLinkKey> linkIds;
- private boolean childUpdate = false;
-
- /**
- * Creates an instance of InternalNetwork.
- *
- * @param network the Network object
- */
- public InternalNetwork(Network network) {
- this.supportingNetworkIds = network
- .supportingNetworkIds() == null ? null
- : Lists.newArrayList(network
- .supportingNetworkIds());
- this.serverProvided = network.isServerProvided();
- // NetworkNodeKey
- if (MapUtils.isNotEmpty(network.nodes())) {
- this.nodeIds = Lists.newArrayList();
- for (Map.Entry<KeyId, NetworkNode> entry : network.nodes().entrySet()) {
- this.nodeIds.add(new NetworkNodeKey(network.networkId(), entry.getKey()));
- }
- }
- // NetworkLinkKey
- if (MapUtils.isNotEmpty(network.links())) {
- this.linkIds = Lists.newArrayList();
- for (Map.Entry<KeyId, NetworkLink> entry : network.links().entrySet()) {
- this.linkIds.add(new NetworkLinkKey(network.networkId(), entry.getKey()));
- }
- }
- }
-
- /**
- * Creates a default instance of InternalNetwork.
- */
- public InternalNetwork() {
- }
-
- /**
- * Returns the supporting network Ids.
- *
- * @return the supportingNetworkIds
- */
- public List<KeyId> supportingNetworkIds() {
- if (supportingNetworkIds == null) {
- return null;
- }
- return ImmutableList.copyOf(supportingNetworkIds);
- }
-
- /**
- * Returns if the network topology is provided by a server or is
- * configured by a client.
- *
- * @return true if the network is provided by a server; false otherwise
- */
- public boolean serverProvided() {
- return serverProvided;
- }
-
- /**
- * @param serverProvided the serverProvided to set
- */
- public void setServerProvided(boolean serverProvided) {
- this.serverProvided = serverProvided;
- }
-
- /**
- * Returns the list of node Ids in the network.
- *
- * @return the nodeIds
- */
- public List<NetworkNodeKey> nodeIds() {
- return nodeIds;
- }
-
- /**
- * Returns the TE topology key for the network.
- *
- * @return the teTopologyKey
- */
- public TeTopologyKey teTopologyKey() {
- return teTopologyKey;
- }
-
- /**
- * Sets the TE topology key for the network.
- *
- * @param teTopologyKey the teTopologyKey to set
- */
- public void setTeTopologyKey(TeTopologyKey teTopologyKey) {
- this.teTopologyKey = teTopologyKey;
- }
-
- /**
- * Set the list of node Ids in the network.
- *
- * @param nodeIds the nodeIds to set
- */
- public void setNodeIds(List<NetworkNodeKey> nodeIds) {
- this.nodeIds = nodeIds;
- }
-
- /**
- * Returns the list of link Ids in the network.
- *
- * @return the linkIds
- */
- public List<NetworkLinkKey> linkIds() {
- return linkIds;
- }
-
- /**
- * Set the list of link Ids in the network.
- *
- * @param linkIds the linkIds to set
- */
- public void setLinkIds(List<NetworkLinkKey> linkIds) {
- this.linkIds = linkIds;
- }
-
- /**
- * Returns the flag if the data was updated by child change.
- *
- * @return value of childUpdate
- */
- public boolean childUpdate() {
- return childUpdate;
- }
-
- /**
- * Sets the flag if the data was updated by child change.
- *
- * @param childUpdate the childUpdate value to set
- */
- public void setChildUpdate(boolean childUpdate) {
- this.childUpdate = childUpdate;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(teTopologyKey, nodeIds, linkIds,
- supportingNetworkIds, serverProvided);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof InternalNetwork) {
- InternalNetwork that = (InternalNetwork) object;
- return Objects.equal(this.teTopologyKey, that.teTopologyKey) &&
- Objects.equal(this.nodeIds, that.nodeIds) &&
- Objects.equal(this.linkIds, that.linkIds) &&
- Objects.equal(this.supportingNetworkIds, that.supportingNetworkIds) &&
- Objects.equal(this.serverProvided, that.serverProvided);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("teTopologyKey", teTopologyKey)
- .add("nodeIds", nodeIds)
- .add("linkIds", linkIds)
- .add("supportingNetworkIds", supportingNetworkIds)
- .add("serverProvided", serverProvided)
- .add("childUpdate", childUpdate)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalNetworkLink.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalNetworkLink.java
deleted file mode 100644
index 7d82295..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalNetworkLink.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.impl;
-
-import java.util.List;
-
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.node.NodeTpKey;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-/**
- * Network Link representation in store.
- */
-public class InternalNetworkLink {
- private NodeTpKey source;
- private NodeTpKey destination;
- private List<NetworkLinkKey> supportingLinkIds;
- private TeLinkTpGlobalKey teLinkKey;
- private boolean parentUpdate;
-
- /**
- * Creates an instance of InternalNetworkLink.
- *
- * @param link the network link
- * @param parentUpdate the flag if the data is updated by parent
- */
- public InternalNetworkLink(NetworkLink link, boolean parentUpdate) {
- source = link.source();
- destination = link.destination();
- supportingLinkIds = link
- .supportingLinkIds() == null ? null
- : Lists.newArrayList(link
- .supportingLinkIds());
- this.parentUpdate = parentUpdate;
- }
-
- /**
- * Returns the link source termination point.
- *
- * @return source link termination point id
- */
- public NodeTpKey source() {
- return source;
- }
-
- /**
- * Returns the link destination termination point.
- *
- * @return destination link termination point id
- */
- public NodeTpKey destination() {
- return destination;
- }
-
- /**
- * Returns the supporting link ids.
- *
- * @return list of the ids of the supporting links
- */
- public List<NetworkLinkKey> supportingLinkIds() {
- return supportingLinkIds == null ? null
- : ImmutableList
- .copyOf(supportingLinkIds);
- }
-
- /**
- * Returns the TE link key.
- *
- * @return the teLinkKey
- */
- public TeLinkTpGlobalKey teLinkKey() {
- return teLinkKey;
- }
-
- /**
- * Sets the TE link key.
- *
- * @param teLinkKey the teLinkKey to set
- */
- public void setTeLinkKey(TeLinkTpGlobalKey teLinkKey) {
- this.teLinkKey = teLinkKey;
- }
-
- /**
- * Returns the flag if the data was updated by parent change.
- *
- * @return value of parentUpdate
- */
- public boolean parentUpdate() {
- return parentUpdate;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(source, destination, supportingLinkIds, teLinkKey);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof InternalNetworkLink) {
- InternalNetworkLink that = (InternalNetworkLink) object;
- return Objects.equal(source, that.source)
- && Objects.equal(destination, that.destination)
- && Objects.equal(supportingLinkIds, that.supportingLinkIds)
- && Objects.equal(teLinkKey, that.teLinkKey);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("source", source)
- .add("destination", destination)
- .add("supportingLinkIds", supportingLinkIds)
- .add("teLinkKey", teLinkKey)
- .toString();
- }
-}
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalNetworkNode.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalNetworkNode.java
deleted file mode 100644
index f70210b..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalNetworkNode.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.impl;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.collections.MapUtils;
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.node.NetworkNode;
-import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TerminationPoint;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-/**
- * Network Node representation in store.
- */
-public class InternalNetworkNode {
- private List<NetworkNodeKey> supportingNodeIds;
- private List<KeyId> tpIds;
- private TeNodeKey teNodeKey;
- private boolean parentUpdate;
- private boolean childUpdate;
-
- /**
- * Creates an instance of InternalNetworkNode.
- *
- * @param node the network node
- * @param parentUpdate the flag if the data is updated by parent
- */
- public InternalNetworkNode(NetworkNode node, boolean parentUpdate) {
- supportingNodeIds = node
- .supportingNodeIds() == null ? null
- : Lists.newArrayList(node
- .supportingNodeIds());
- if (MapUtils.isNotEmpty(node.terminationPoints())) {
- tpIds = Lists.newArrayList();
- for (Map.Entry<KeyId, TerminationPoint> entry : node
- .terminationPoints().entrySet()) {
- tpIds.add(entry.getKey());
- }
- }
- this.parentUpdate = parentUpdate;
- }
-
- /**
- * Returns the list of supporting node Ids.
- *
- * @return the supporting nodeIds
- */
- public List<NetworkNodeKey> supportingNodeIds() {
- return supportingNodeIds == null ? null
- : ImmutableList
- .copyOf(supportingNodeIds);
- }
-
- /**
- * Sets the list of supporting node Ids.
- *
- * @param supportingNodeIds the supportingNodeIds to set
- */
- public void setSupportingNodeIds(List<NetworkNodeKey> supportingNodeIds) {
- this.supportingNodeIds = supportingNodeIds == null ? null
- : Lists.newArrayList(supportingNodeIds);
- }
-
- /**
- * Returns the list of termination point Ids.
- *
- * @return the termination point Ids
- */
- public List<KeyId> tpIds() {
- return tpIds;
- }
-
- /**
- * Sets the list of termination point Ids.
- *
- * @param tpIds the tpIds to set
- */
- public void setTpIds(List<KeyId> tpIds) {
- this.tpIds = tpIds;
- }
-
- /**
- * Returns the TE Node key.
- *
- * @return the teNodeKey
- */
- public TeNodeKey teNodeKey() {
- return teNodeKey;
- }
-
- /**
- * Sets the TE Node key.
- *
- * @param teNodeKey the teNodeKey to set
- */
- public void setTeNodeKey(TeNodeKey teNodeKey) {
- this.teNodeKey = teNodeKey;
- }
-
- /**
- * Returns the flag if the data was updated by parent change.
- *
- * @return value of parentUpdate
- */
- public boolean parentUpdate() {
- return parentUpdate;
- }
-
- /**
- * Returns the flag if the data was updated by child change.
- *
- * @return value of childUpdate
- */
- public boolean childUpdate() {
- return childUpdate;
- }
-
- /**
- * Sets the flag if the data was updated by child change.
- *
- * @param childUpdate the childUpdate value to set
- */
- public void setChildUpdate(boolean childUpdate) {
- this.childUpdate = childUpdate;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(supportingNodeIds, tpIds, teNodeKey);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof InternalNetworkNode) {
- InternalNetworkNode that = (InternalNetworkNode) object;
- return Objects.equal(supportingNodeIds, that.supportingNodeIds)
- && Objects.equal(tpIds, that.tpIds)
- && Objects.equal(teNodeKey, that.teNodeKey);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("supportingNodeIds", supportingNodeIds)
- .add("tpIds", tpIds)
- .add("teNodeKey", teNodeKey)
- .add("parentUpdate", parentUpdate)
- .add("childUpdate", childUpdate)
- .toString();
- }
-}
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalTeLink.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalTeLink.java
deleted file mode 100644
index 799ed30..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalTeLink.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.impl;
-
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.link.CommonLinkData;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.link.TeLink;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.link.TeLinkTpKey;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-
-/**
- * The TE link representation in store.
- */
-public class InternalTeLink {
- private TeLinkTpKey peerTeLinkKey;
- private TeTopologyKey underlayTopologyKey;
- private TeLinkTpGlobalKey supportingLinkKey;
- private TeLinkTpGlobalKey sourceTeLinkKey;
- private CommonLinkData teData;
- private NetworkLinkKey networkLinkKey;
- private boolean parentUpdate;
-
- /**
- * Creates an instance of InternalLink.
- *
- * @param link the TE link
- * @param parentUpdate indicator the TE node is updated by parent
- */
- public InternalTeLink(TeLink link, boolean parentUpdate) {
- this.parentUpdate = parentUpdate;
- // Peer link key
- this.peerTeLinkKey = link.peerTeLinkKey();
- // Underlay topology
- this.underlayTopologyKey = link.underlayTeTopologyId();
- // Supporting topology
- this.supportingLinkKey = link.supportingTeLinkId();
- // Source topology
- this.sourceTeLinkKey = link.sourceTeLinkId();
- // Common data
- this.teData = new CommonLinkData(link);
- }
-
- /**
- * Returns the bi-directional peer link key.
- *
- * @return the peerTeLinkKey
- */
- public TeLinkTpKey peerTeLinkKey() {
- return peerTeLinkKey;
- }
-
- /**
- * Sets the bi-directional peer link key.
- *
- * @param peerTeLinkKey the peerTeLinkKey to set
- */
- public void setPeerTeLinkKey(TeLinkTpKey peerTeLinkKey) {
- this.peerTeLinkKey = peerTeLinkKey;
- }
-
- /**
- * Returns the link underlay topology key.
- *
- * @return the underlayTopologyKey
- */
- public TeTopologyKey underlayTopologyKey() {
- return underlayTopologyKey;
- }
-
- /**
- * Sets the link underlay topology key.
- *
- * @param underlayTopologyKey the underlayTopologyKey to set
- */
- public void setUnderlayTopologyKey(TeTopologyKey underlayTopologyKey) {
- this.underlayTopologyKey = underlayTopologyKey;
- }
-
- /**
- * Returns the supporting link key.
- *
- * @return the supportingLinkKey
- */
- public TeLinkTpGlobalKey supportingLinkKey() {
- return supportingLinkKey;
- }
-
- /**
- * Sets the supporting link key.
- *
- * @param supportingLinkKey the supportingLinkKey to set
- */
- public void setSupportingLinkKey(TeLinkTpGlobalKey supportingLinkKey) {
- this.supportingLinkKey = supportingLinkKey;
- }
-
- /**
- * Returns the source link key.
- *
- * @return the sourceTeLinkKey
- */
- public TeLinkTpGlobalKey sourceTeLinkKey() {
- return sourceTeLinkKey;
- }
-
- /**
- * Sets the source link key.
- *
- * @param sourceTeLinkKey the sourceTeLinkKey to set
- */
- public void setSourceTeNodeKey(TeLinkTpGlobalKey sourceTeLinkKey) {
- this.sourceTeLinkKey = sourceTeLinkKey;
- }
-
- /**
- * Returns the link common data.
- *
- * @return the teData
- */
- public CommonLinkData teData() {
- return teData;
- }
-
- /**
- * Sets the link common data.
- *
- * @param teData the teData to set
- */
- public void setTeData(CommonLinkData teData) {
- this.teData = teData;
- }
-
- /**
- * Sets the network link key.
- *
- * @param networkLinkKey the networkLinkKey to set
- */
- public void setNetworkLinkKey(NetworkLinkKey networkLinkKey) {
- this.networkLinkKey = networkLinkKey;
- }
-
- /**
- * Returns the network link key.
- *
- * @return the networkLinkKey
- */
- public NetworkLinkKey networkLinkKey() {
- return networkLinkKey;
- }
-
- /**
- * Returns the indicator if the data was updated by parent.
- *
- * @return value of parentUpdate
- */
- public boolean parentUpdate() {
- return parentUpdate;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(peerTeLinkKey, underlayTopologyKey,
- supportingLinkKey, sourceTeLinkKey, teData, networkLinkKey);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof InternalTeLink) {
- InternalTeLink that = (InternalTeLink) object;
- return Objects.equal(peerTeLinkKey, that.peerTeLinkKey)
- && Objects.equal(underlayTopologyKey,
- that.underlayTopologyKey)
- && Objects.equal(supportingLinkKey, that.supportingLinkKey)
- && Objects.equal(sourceTeLinkKey, that.sourceTeLinkKey)
- && Objects.equal(networkLinkKey, that.networkLinkKey)
- && Objects.equal(teData, that.teData);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("peerTeLinkKey", peerTeLinkKey)
- .add("underlayTopologyKey", underlayTopologyKey)
- .add("supportingLinkKey", supportingLinkKey)
- .add("sourceTeLinkKey", sourceTeLinkKey)
- .add("teData", teData)
- .add("networkLinkKey", networkLinkKey)
- .add("parentUpdate", parentUpdate)
- .toString();
- }
-}
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalTeNode.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalTeNode.java
deleted file mode 100644
index cd47929..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalTeNode.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.impl;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.node.CommonNodeData;
-import org.onosproject.tetopology.management.api.node.ConnectivityMatrix;
-import org.onosproject.tetopology.management.api.node.ConnectivityMatrixKey;
-import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
-import org.onosproject.tetopology.management.api.node.TeNode;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.tetopology.management.api.node.TunnelTerminationPoint;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.Lists;
-
-/**
- * The Node representation in store.
- */
-public class InternalTeNode {
- private CommonNodeData teData;
- private TeTopologyKey underlayTopologyKey;
- private TeNodeKey supportNodeKey;
- private TeNodeKey sourceTeNodeKey;
- private List<ConnectivityMatrixKey> connMatrixKeys;
- private List<TeLinkTpGlobalKey> teLinkTpKeys;
- private List<TeLinkTpGlobalKey> teTpKeys;
- private List<TtpKey> ttpKeys;
- private NetworkNodeKey networkNodeKey;
- private boolean parentUpdate;
- private boolean childUpdate;
-
- // Next available TE link Id egressing from the TE node.
- private long nextTeLinkId;
-
- /**
- * Creates an instance of InternalTeNode.
- *
- * @param nodeKey the TE node key
- * @param node the TE node
- * @param networkNodeKey the network node key
- * @param parentUpdate the flag if the data is updated by parent
- */
- public InternalTeNode(TeNodeKey nodeKey, TeNode node,
- NetworkNodeKey networkNodeKey, boolean parentUpdate) {
- this.networkNodeKey = networkNodeKey;
- this.parentUpdate = parentUpdate;
- // Underlay topology
- this.underlayTopologyKey = node.underlayTeTopologyId();
- // Supporting topology
- this.supportNodeKey = node.supportingTeNodeId();
- // Source topology
- this.sourceTeNodeKey = node.sourceTeNodeId();
- // Common data
- this.teData = new CommonNodeData(node);
- // Connectivity matrix
- if (MapUtils.isNotEmpty(node.connectivityMatrices())) {
- this.connMatrixKeys = Lists.newArrayList();
- for (Map.Entry<Long, ConnectivityMatrix> entry : node.connectivityMatrices().entrySet()) {
- this.connMatrixKeys.add(new ConnectivityMatrixKey(nodeKey, entry.getKey()));
- }
- }
- // Tunnel termination point
- if (MapUtils.isNotEmpty(node.tunnelTerminationPoints())) {
- this.ttpKeys = Lists.newArrayList();
- for (Map.Entry<Long, TunnelTerminationPoint> entry : node.tunnelTerminationPoints().entrySet()) {
- this.ttpKeys.add(new TtpKey(nodeKey, entry.getKey()));
- }
- }
- // teLink Keys
- if (CollectionUtils.isNotEmpty(node.teLinkIds())) {
- this.teLinkTpKeys = Lists.newArrayList();
- for (Long linkId : node.teLinkIds()) {
- this.teLinkTpKeys.add(new TeLinkTpGlobalKey(nodeKey, linkId));
- }
-
- }
- // teTp Keys
- if (CollectionUtils.isNotEmpty(node.teTerminationPointIds())) {
- this.teTpKeys = Lists.newArrayList();
- for (Long tpId : node.teTerminationPointIds()) {
- this.teTpKeys.add(new TeLinkTpGlobalKey(nodeKey, tpId));
- }
- }
- }
-
- /**
- * Returns the node common data.
- *
- * @return the teData
- */
- public CommonNodeData teData() {
- return teData;
- }
-
- /**
- * Sets the node common data.
- *
- * @param teData the teData to set
- */
- public void setTeData(CommonNodeData teData) {
- this.teData = teData;
- }
-
- /**
- * Returns the node underlay topology key.
- *
- * @return the underlayTopologyKey
- */
- public TeTopologyKey underlayTopologyKey() {
- return underlayTopologyKey;
- }
-
- /**
- * Sets the node underlay topology key.
- *
- * @param underlayTopologyKey the underlayTopologyKey to set
- */
- public void setUnderlayTopologyKey(TeTopologyKey underlayTopologyKey) {
- this.underlayTopologyKey = underlayTopologyKey;
- }
-
- /**
- * Returns the supporting node key.
- *
- * @return the supportNodeKey
- */
- public TeNodeKey supportNodeKey() {
- return supportNodeKey;
- }
-
- /**
- * Sets the supporting node key.
- *
- * @param supportNodeKey the supportNodeKey to set
- */
- public void setSupportNodeKey(TeNodeKey supportNodeKey) {
- this.supportNodeKey = supportNodeKey;
- }
-
- /**
- * Returns the source node key.
- *
- * @return the sourceTeNodeKey
- */
- public TeNodeKey sourceTeNodeKey() {
- return sourceTeNodeKey;
- }
-
- /**
- * Sets the source node key.
- *
- * @param sourceTeNodeKey the sourceTeNodeKey to set
- */
- public void setSourceTeNodeKey(TeNodeKey sourceTeNodeKey) {
- this.sourceTeNodeKey = sourceTeNodeKey;
- }
-
- /**
- * Returns the node connect matrix keys.
- *
- * @return the connMatrixKeys
- */
- public List<ConnectivityMatrixKey> connMatrixKeys() {
- return connMatrixKeys;
- }
-
- /**
- * Sets the node connect matrix keys.
- *
- * @param connMatrixKeys the connMatrixKeys to set
- */
- public void setConnMatrixKeys(List<ConnectivityMatrixKey> connMatrixKeys) {
- this.connMatrixKeys = connMatrixKeys;
- }
-
- /**
- * Returns the TE link Ids.
- *
- * @return the teLinkTpKeys
- */
- public List<TeLinkTpGlobalKey> teLinkTpKeys() {
- return teLinkTpKeys;
- }
-
- /**
- * Sets the TE link Ids from the node.
- *
- * @param teLinkTpKeys the teLinkTpKeys to set
- */
- public void setTeLinkTpKeys(List<TeLinkTpGlobalKey> teLinkTpKeys) {
- this.teLinkTpKeys = teLinkTpKeys;
- }
-
- /**
- * Returns the TE termitation point Ids.
- *
- * @return the teTpKeys
- */
- public List<TeLinkTpGlobalKey> teTpKeys() {
- return teTpKeys;
- }
-
- /**
- * Sets the TE termitation point Ids.
- *
- * @param teTpKeys the teTpKeys to set
- */
- public void setTeTpKeys(List<TeLinkTpGlobalKey> teTpKeys) {
- this.teTpKeys = teTpKeys;
- }
-
- /**
- * Returns the list of Tunnel Termination Point keys of the node.
- *
- * @return the ttpKeys
- */
- public List<TtpKey> ttpKeys() {
- return ttpKeys;
- }
-
- /**
- * Sets the list of Tunnel Termination Point keys.
- *
- * @param ttpKeys the ttpKeys to set
- */
- public void setTtpKeys(List<TtpKey> ttpKeys) {
- this.ttpKeys = ttpKeys;
- }
-
- /**
- * Returns the network node Key.
- *
- * @return the networkNodeKey
- */
- public NetworkNodeKey networkNodeKey() {
- return networkNodeKey;
- }
-
- /**
- * Returns the next available TE link id from the node.
- *
- * @return the nextTeLinkId
- */
- public long nextTeLinkId() {
- return nextTeLinkId;
- }
-
- /**
- * Sets the next available TE link id.
- *
- * @param nextTeLinkId the nextTeLinkId to set
- */
- public void setNextTeLinkId(long nextTeLinkId) {
- this.nextTeLinkId = nextTeLinkId;
- }
-
- /**
- * Returns the flag if the data was updated by parent change.
- *
- * @return value of parentUpdate
- */
- public boolean parentUpdate() {
- return parentUpdate;
- }
-
- /**
- * Returns the flag if the data was updated by child change.
- *
- * @return value of childUpdate
- */
- public boolean childUpdate() {
- return childUpdate;
- }
-
- /**
- * Sets the flag if the data was updated by child change.
- *
- * @param childUpdate the childUpdate value to set
- */
- public void setChildUpdate(boolean childUpdate) {
- this.childUpdate = childUpdate;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(teData, underlayTopologyKey, supportNodeKey,
- sourceTeNodeKey, connMatrixKeys, teLinkTpKeys, ttpKeys, networkNodeKey);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof InternalTeNode) {
- InternalTeNode that = (InternalTeNode) object;
- return Objects.equal(teData, that.teData)
- && Objects.equal(underlayTopologyKey,
- that.underlayTopologyKey)
- && Objects.equal(supportNodeKey, that.supportNodeKey)
- && Objects.equal(sourceTeNodeKey, that.sourceTeNodeKey)
- && Objects.equal(connMatrixKeys, that.connMatrixKeys)
- && Objects.equal(teLinkTpKeys, that.teLinkTpKeys)
- && Objects.equal(ttpKeys, that.ttpKeys)
- && Objects.equal(networkNodeKey, that.networkNodeKey);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("teData", teData)
- .add("underlayTopologyKey", underlayTopologyKey)
- .add("supportNodeKey", supportNodeKey)
- .add("sourceTeNodeKey", sourceTeNodeKey)
- .add("connMatrixKeys", connMatrixKeys)
- .add("teLinkTpKeys", teLinkTpKeys)
- .add("ttpKeys", ttpKeys)
- .add("nextTeLinkId", nextTeLinkId)
- .add("networkNodeKey", networkNodeKey)
- .add("parentUpdate", parentUpdate)
- .add("childUpdate", childUpdate)
- .toString();
- }
-}
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalTeTopology.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalTeTopology.java
deleted file mode 100644
index 247e934..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalTeTopology.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.impl;
-
-import static org.onosproject.tetopology.management.api.TeConstants.NIL_LONG_VALUE;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.collections.MapUtils;
-import org.onosproject.tetopology.management.api.CommonTopologyData;
-import org.onosproject.tetopology.management.api.TeTopology;
-import org.onosproject.tetopology.management.api.link.TeLink;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.link.TeLinkTpKey;
-import org.onosproject.tetopology.management.api.node.TeNode;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.Lists;
-
-/**
- * TE topology representation in store.
- */
-public class InternalTeTopology {
- private String teTopologyId;
- private List<TeNodeKey> teNodeKeys;
- private List<TeLinkTpGlobalKey> teLinkKeys;
- private CommonTopologyData topologyData;
- private long nextTeNodeId = NIL_LONG_VALUE;
- private boolean childUpdate;
-
- /**
- * Creates an instance of InternalTeTopology.
- *
- * @param teTopology the TE Topology object
- */
- public InternalTeTopology(TeTopology teTopology) {
- this.teTopologyId = teTopology.teTopologyIdStringValue();
- this.topologyData = new CommonTopologyData(teTopology);
- // teNodeKeys
- if (MapUtils.isNotEmpty(teTopology.teNodes())) {
- this.teNodeKeys = Lists.newArrayList();
- for (Map.Entry<Long, TeNode> entry : teTopology.teNodes().entrySet()) {
- this.teNodeKeys.add(new TeNodeKey(teTopology.teTopologyId(), entry.getKey()));
- }
- }
- // teLink Keys
- if (MapUtils.isNotEmpty(teTopology.teLinks())) {
- this.teLinkKeys = Lists.newArrayList();
- for (Map.Entry<TeLinkTpKey, TeLink> entry : teTopology.teLinks().entrySet()) {
- this.teLinkKeys.add(new TeLinkTpGlobalKey(teTopology.teTopologyId(), entry.getKey()));
- }
- }
- }
-
- /**
- * Creates a default instance of InternalNetwork.
- *
- * @param teTopologyId string value of id
- */
- public InternalTeTopology(String teTopologyId) {
- this.teTopologyId = teTopologyId;
- }
-
- /**
- * Returns the TE Topology Id string value.
- *
- * @return the teTopologyId
- */
- public String teTopologyId() {
- return teTopologyId;
- }
-
- /**
- * Returns the list of TE node keys in the topology.
- *
- * @return the teNodeKeys
- */
- public List<TeNodeKey> teNodeKeys() {
- return teNodeKeys;
- }
-
- /**
- * Sets the list of TE node keys.
- *
- * @param teNodeKeys the teNodeKeys to set
- */
- public void setTeNodeKeys(List<TeNodeKey> teNodeKeys) {
- this.teNodeKeys = teNodeKeys;
- }
-
- /**
- * Returns the list of TE link keys in the topology.
- *
- * @return the teLinkKeys
- */
- public List<TeLinkTpGlobalKey> teLinkKeys() {
- return teLinkKeys;
- }
-
- /**
- * Sets the list of TE link keys.
- *
- * @param teLinkKeys the teLinkKeys to set
- */
- public void setTeLinkKeys(List<TeLinkTpGlobalKey> teLinkKeys) {
- this.teLinkKeys = teLinkKeys;
- }
-
- /**
- * Returns the common TE topology data.
- *
- * @return the topology data
- */
- public CommonTopologyData topologyData() {
- return topologyData;
- }
-
- /**
- * Sets the common TE topology data.
- *
- * @param topologyData the topologyData to set
- */
- public void setTopologydata(CommonTopologyData topologyData) {
- this.topologyData = topologyData;
- }
-
- /**
- * Returns the next available TE node Id.
- *
- * @return the next TE nodeId
- */
- public long nextTeNodeId() {
- return nextTeNodeId;
- }
-
- /**
- * Sets the next available TE node Id.
- *
- * @param nextTeNodeId the nextTeNodeId to set
- */
- public void setNextTeNodeId(long nextTeNodeId) {
- this.nextTeNodeId = nextTeNodeId;
- }
-
- /**
- * Returns the flag if the data was updated by child change.
- *
- * @return value of childUpdate
- */
- public boolean childUpdate() {
- return childUpdate;
- }
-
- /**
- * Sets the flag if the data was updated by child change.
- *
- * @param childUpdate the childUpdate value to set
- */
- public void setChildUpdate(boolean childUpdate) {
- this.childUpdate = childUpdate;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(teTopologyId, teNodeKeys, teLinkKeys,
- topologyData);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof InternalTeTopology) {
- InternalTeTopology that = (InternalTeTopology) object;
- return Objects.equal(teTopologyId, that.teTopologyId)
- && Objects.equal(teNodeKeys, that.teNodeKeys)
- && Objects.equal(teLinkKeys, that.teLinkKeys)
- && Objects.equal(topologyData, that.topologyData);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("teTopologyId", teTopologyId)
- .add("teNodeKeys", teNodeKeys)
- .add("teLinkKeys", teLinkKeys)
- .add("topologyData", topologyData)
- .add("nextTeNodeId", nextTeNodeId)
- .add("childUpdate", childUpdate)
- .toString();
- }
-}
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalTerminationPoint.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalTerminationPoint.java
deleted file mode 100644
index f47f0d9..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/InternalTerminationPoint.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.impl;
-
-import java.util.List;
-
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.node.TerminationPoint;
-import org.onosproject.tetopology.management.api.node.TerminationPointKey;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-/**
- * The TerminationPoint representation in store.
- */
-public class InternalTerminationPoint {
- private TeLinkTpGlobalKey teTpKey;
- private List<TerminationPointKey> supportingTpIds;
-
- /**
- * Creates an instance of InternalTerminationPoint.
- *
- * @param tp the termination point
- */
- public InternalTerminationPoint(TerminationPoint tp) {
- this.supportingTpIds = tp
- .supportingTpIds() == null ? null
- : Lists.newArrayList(tp
- .supportingTpIds());
- }
-
- /**
- * Returns the TE termination point key.
- *
- * @return the teTpKey
- */
- public TeLinkTpGlobalKey teTpKey() {
- return teTpKey;
- }
-
- /**
- * Returns the supporting termination point Ids.
- *
- * @return the supportingTpIds
- */
- public List<TerminationPointKey> supportingTpIds() {
- return supportingTpIds == null ? null
- : ImmutableList.copyOf(supportingTpIds);
- }
-
- /**
- * Sets the TE termination point key.
- *
- * @param teTpKey the teTpKey to set
- */
- public void setTeTpKey(TeLinkTpGlobalKey teTpKey) {
- this.teTpKey = teTpKey;
- }
-
- /**
- * Sets the supporting termination point Ids.
- *
- * @param supportingTpIds the supportingTpIds to set
- */
- public void setSupportingTpIds(List<TerminationPointKey> supportingTpIds) {
- this.supportingTpIds = supportingTpIds == null ? null
- : Lists.newArrayList(supportingTpIds);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(supportingTpIds, teTpKey);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof InternalTerminationPoint) {
- InternalTerminationPoint that = (InternalTerminationPoint) object;
- return Objects.equal(supportingTpIds, that.supportingTpIds)
- && Objects.equal(teTpKey, that.teTpKey);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("supportingTpIds", supportingTpIds)
- .add("teTpKey", teTpKey)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeMgrUtil.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeMgrUtil.java
deleted file mode 100644
index 93170d1..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeMgrUtil.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.impl;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.collections.MapUtils;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.tetopology.management.api.DefaultNetwork;
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.Network;
-import org.onosproject.tetopology.management.api.TeTopology;
-import org.onosproject.tetopology.management.api.TeTopologyId;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.link.DefaultNetworkLink;
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.link.TeLink;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.link.TeLinkTpKey;
-import org.onosproject.tetopology.management.api.node.DefaultNetworkNode;
-import org.onosproject.tetopology.management.api.node.DefaultTerminationPoint;
-import org.onosproject.tetopology.management.api.node.NetworkNode;
-import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
-import org.onosproject.tetopology.management.api.node.NodeTpKey;
-import org.onosproject.tetopology.management.api.node.TeNode;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TerminationPoint;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-/**
- * TE Topology Manager utility functions.
- */
-public final class TeMgrUtil {
- private static final String TENODE_ID = "teNodeId/";
- private static final String TELINK_ID = "/teLinkId/";
- private static final String PROVIDER_ID = "providerId/";
- private static final String CLIENT_ID = "/clientId/";
- private static final String TOPOLOGY_ID = "/topologyId/";
-
- // no instantiation
- private TeMgrUtil() {
- }
-
- /**
- * Returns the network link id for a TE link local key.
- *
- * @param key TE link local key
- * @return value of network link id
- */
- public static KeyId toNetworkLinkId(TeLinkTpKey key) {
- return KeyId.keyId(new StringBuilder()
- .append(TENODE_ID)
- .append(Ip4Address.valueOf((int) key.teNodeId()).toString())
- .append(TELINK_ID)
- .append(key.teLinkTpId()).toString());
- }
-
- /**
- * Returns the network id for a TE topology id.
- *
- * @param teTopologyId TE topology id
- * @return value of network id
- */
- public static KeyId toNetworkId(TeTopologyId teTopologyId) {
- return KeyId.keyId(new StringBuilder()
- .append(PROVIDER_ID)
- .append(teTopologyId.providerId())
- .append(CLIENT_ID)
- .append(teTopologyId.clientId())
- .append(TOPOLOGY_ID)
- .append(teTopologyId.topologyId()).toString());
- }
-
- /**
- * Returns the network id for a TE topology key.
- *
- * @param teTopologyKey TE topology key
- * @return value of network id
- */
- public static KeyId toNetworkId(TeTopologyKey teTopologyKey) {
- return KeyId.keyId(new StringBuilder()
- .append(PROVIDER_ID)
- .append(teTopologyKey.providerId())
- .append(CLIENT_ID)
- .append(teTopologyKey.clientId())
- .append(TOPOLOGY_ID)
- .append(teTopologyKey.topologyId()).toString());
- }
-
- /**
- * Returns the network node key for a TE node global key.
- *
- * @param teNodeKey TE node global key
- * @return value of network node key
- */
- public static NetworkNodeKey networkNodeKey(TeNodeKey teNodeKey) {
- return new NetworkNodeKey(toNetworkId(teNodeKey.teTopologyKey()),
- KeyId.keyId(Ip4Address
- .valueOf((int) teNodeKey.teNodeId())
- .toString()));
- }
-
- /**
- * Returns the network link key for a TE link global key.
- *
- * @param teLinkKey TE link global key
- * @return value of network link key
- */
- public static NetworkLinkKey networkLinkKey(TeLinkTpGlobalKey teLinkKey) {
- return new NetworkLinkKey(toNetworkId(teLinkKey.teTopologyKey()),
- toNetworkLinkId(teLinkKey.teLinkTpKey()));
- }
-
- /**
- * Returns the TE topology id for a TE topology.
- *
- * @param teTopology an instance of TE topology
- * @return value of TE topology id
- */
- public static TeTopologyId teTopologyId(TeTopology teTopology) {
- return new TeTopologyId(teTopology.teTopologyId().providerId(),
- teTopology.teTopologyId().clientId(),
- teTopology.teTopologyIdStringValue());
- }
-
- /**
- * Returns a default instance of termination point for a TE termination point id.
- *
- * @param teTpId TE termination point id
- * @return an instance of termination point
- */
- private static TerminationPoint tpBuilder(long teTpId) {
- return new DefaultTerminationPoint(KeyId.keyId(Long.toString(teTpId)), null, teTpId);
- }
-
- /**
- * Returns an instance of network node for a TE node.
- *
- * @param id value of the network node id
- * @param teNode value of TE node
- * @return an instance of network node
- */
- public static NetworkNode nodeBuilder(KeyId id, TeNode teNode) {
- List<NetworkNodeKey> supportingNodeIds = null;
- if (teNode.supportingTeNodeId() != null) {
- supportingNodeIds = Lists.newArrayList(networkNodeKey(teNode.supportingTeNodeId()));
- }
- Map<KeyId, TerminationPoint> tps = Maps.newConcurrentMap();
- for (Long teTpid : teNode.teTerminationPointIds()) {
- tps.put(KeyId.keyId(Long.toString(teTpid)), tpBuilder(teTpid));
- }
- return new DefaultNetworkNode(id, supportingNodeIds, teNode, tps);
- }
-
- /**
- * Returns the network node termination point key for a TE link end point key.
- *
- * @param teLinkKey TE link end point key
- * @return value of network node termination point key
- */
- public static NodeTpKey nodeTpKey(TeLinkTpKey teLinkKey) {
- return new NodeTpKey(KeyId.keyId(Ip4Address
- .valueOf((int) teLinkKey.teNodeId()).toString()),
- KeyId.keyId(Long.toString(teLinkKey.teLinkTpId())));
- }
-
- /**
- * Returns an instance of network link for a TE link.
- *
- * @param id value of the network link id
- * @param teLink value of TE link
- * @return an instance of network link
- */
- public static NetworkLink linkBuilder(KeyId id, TeLink teLink) {
- NodeTpKey source = nodeTpKey(teLink.teLinkKey());
- NodeTpKey destination = null;
- if (teLink.peerTeLinkKey() != null) {
- destination = nodeTpKey(teLink.peerTeLinkKey());
- }
- List<NetworkLinkKey> supportingLinkIds = null;
- if (teLink.supportingTeLinkId() != null) {
- supportingLinkIds = Lists.newArrayList(networkLinkKey(teLink.supportingTeLinkId()));
- }
- return new DefaultNetworkLink(id, source, destination, supportingLinkIds, teLink);
- }
-
- /**
- * Returns an instance of network for a TE topology.
- *
- * @param teTopology value of TE topology
- * @return an instance of network
- */
- public static Network networkBuilder(TeTopology teTopology) {
- KeyId networkId = TeMgrUtil.toNetworkId(teTopology.teTopologyId());
- TeTopologyId topologyId = teTopologyId(teTopology);
- Map<KeyId, NetworkNode> nodes = null;
- if (MapUtils.isNotEmpty(teTopology.teNodes())) {
- nodes = Maps.newHashMap();
- for (TeNode tenode : teTopology.teNodes().values()) {
- KeyId key = KeyId.keyId(Ip4Address
- .valueOf((int) tenode.teNodeId()).toString());
- nodes.put(key, nodeBuilder(key, tenode));
- }
- }
- Map<KeyId, NetworkLink> links = null;
- if (MapUtils.isNotEmpty(teTopology.teLinks())) {
- links = Maps.newHashMap();
- for (TeLink telink : teTopology.teLinks().values()) {
- KeyId key = toNetworkLinkId(telink.teLinkKey());
- links.put(key, linkBuilder(key, telink));
-
- }
- }
- return new DefaultNetwork(networkId, null, nodes, links,
- topologyId, false, teTopology.ownerId(),
- teTopology.optimization());
- }
-
-}
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyConfig.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyConfig.java
deleted file mode 100644
index c52d9ee..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyConfig.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.impl;
-
-import org.onlab.packet.Ip4Address;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.config.ConfigException;
-import org.onosproject.net.config.Config;
-
-/**
- * Configuration for TE Topology parameters.
- */
-public class TeTopologyConfig extends Config<ApplicationId> {
- private static final String CONFIG_VALUE_ERROR = "Error parsing config value";
- private static final String PROVIDER_ID = "provider-id";
- private static final String MDSC = "mdsc";
- private static final String TENODE_ID_START = "tenode-id-start";
- private static final String TENODE_ID_END = "tenode-id-end";
-
- /**
- * Retrieves TE topology provider identifier.
- *
- * @return provider Id
- * @throws ConfigException if the parameters are not correctly configured
- * or conversion of the parameters fails
- */
- public long providerId() throws ConfigException {
- try {
- return object.path(PROVIDER_ID).asLong();
- } catch (IllegalArgumentException e) {
- throw new ConfigException(CONFIG_VALUE_ERROR, e);
- }
- }
-
- /**
- * Retrieves TE node starting IPv4 address.
- *
- * @return the IPv4 address
- * @throws ConfigException if the parameters are not correctly configured
- * or conversion of the parameters fails
- */
- public Ip4Address teNodeIpStart() throws ConfigException {
- try {
- return Ip4Address.valueOf(object.path(TENODE_ID_START).asText());
- } catch (IllegalArgumentException e) {
- throw new ConfigException(CONFIG_VALUE_ERROR, e);
- }
- }
-
- /**
- * Retrieves TE node end IPv4 address.
- *
- * @return the IPv4 address
- * @throws ConfigException if the parameters are not correctly configured
- * or conversion of the parameters fails
- */
- public Ip4Address teNodeIpEnd() throws ConfigException {
- try {
- return Ip4Address.valueOf(object.path(TENODE_ID_END).asText());
- } catch (IllegalArgumentException e) {
- throw new ConfigException(CONFIG_VALUE_ERROR, e);
- }
- }
-
- /**
- * Retrieves if this is a MDSC(Multi-Domain Super Controller).
- *
- * @return MDSC value
- * @throws ConfigException if the parameters are not correctly configured or
- * conversion of the parameters fails
- */
- public String mdsc() throws ConfigException {
- try {
- return object.path(MDSC).asText();
- } catch (IllegalArgumentException e) {
- throw new ConfigException(CONFIG_VALUE_ERROR, e);
- }
- }
-
-}
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyManager.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyManager.java
deleted file mode 100644
index a3c0aed..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyManager.java
+++ /dev/null
@@ -1,1019 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.impl;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.app.ApplicationException;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.config.ConfigException;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigRegistry;
-import org.onosproject.net.device.DeviceProviderRegistry;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.link.LinkProviderRegistry;
-import org.onosproject.net.link.LinkService;
-import org.onosproject.net.provider.AbstractListenerProviderRegistry;
-import org.onosproject.net.provider.AbstractProviderService;
-import org.onosproject.tetopology.management.api.CommonTopologyData;
-import org.onosproject.tetopology.management.api.DefaultNetwork;
-import org.onosproject.tetopology.management.api.DefaultNetworks;
-import org.onosproject.tetopology.management.api.DefaultTeTopologies;
-import org.onosproject.tetopology.management.api.DefaultTeTopology;
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.Network;
-import org.onosproject.tetopology.management.api.Networks;
-import org.onosproject.tetopology.management.api.TeConstants;
-import org.onosproject.tetopology.management.api.TeTopologies;
-import org.onosproject.tetopology.management.api.TeTopology;
-import org.onosproject.tetopology.management.api.TeTopologyEvent;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.TeTopologyListener;
-import org.onosproject.tetopology.management.api.TeTopologyProvider;
-import org.onosproject.tetopology.management.api.TeTopologyProviderRegistry;
-import org.onosproject.tetopology.management.api.TeTopologyProviderService;
-import org.onosproject.tetopology.management.api.TeTopologyService;
-import org.onosproject.tetopology.management.api.link.CommonLinkData;
-import org.onosproject.tetopology.management.api.link.DefaultTeLink;
-import org.onosproject.tetopology.management.api.link.ExternalLink;
-import org.onosproject.tetopology.management.api.link.LinkBandwidth;
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.link.NetworkLinkEventSubject;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.link.TeLink;
-import org.onosproject.tetopology.management.api.link.TeLinkEventSubject;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.link.TeLinkTpKey;
-import org.onosproject.tetopology.management.api.link.TePathAttributes;
-import org.onosproject.tetopology.management.api.link.UnderlayPath;
-import org.onosproject.tetopology.management.api.node.CommonNodeData;
-import org.onosproject.tetopology.management.api.node.ConnectivityMatrix;
-import org.onosproject.tetopology.management.api.node.DefaultTeNode;
-import org.onosproject.tetopology.management.api.node.DefaultTunnelTerminationPoint;
-import org.onosproject.tetopology.management.api.node.NetworkNode;
-import org.onosproject.tetopology.management.api.node.NetworkNodeEventSubject;
-import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
-import org.onosproject.tetopology.management.api.node.TeNode;
-import org.onosproject.tetopology.management.api.node.TeNodeEventSubject;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TerminationPoint;
-import org.onosproject.tetopology.management.api.node.TerminationPointKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.tetopology.management.api.node.TunnelTerminationPoint;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.BitSet;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-
-import static java.util.concurrent.Executors.newFixedThreadPool;
-import static org.onlab.util.Tools.groupedThreads;
-import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_ADDED;
-import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_UPDATED;
-import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
-import static org.onosproject.tetopology.management.api.OptimizationType.NOT_OPTIMIZED;
-import static org.onosproject.tetopology.management.api.TeTopology.BIT_CUSTOMIZED;
-import static org.onosproject.tetopology.management.api.TeTopology.BIT_LEARNT;
-import static org.onosproject.tetopology.management.api.TeTopology.BIT_MERGED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.LINK_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.LINK_REMOVED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.LINK_UPDATED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NETWORK_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NETWORK_REMOVED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NODE_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NODE_REMOVED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NODE_UPDATED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_LINK_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_LINK_REMOVED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_LINK_UPDATED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_NODE_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_NODE_REMOVED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_NODE_UPDATED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_TOPOLOGY_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_TOPOLOGY_REMOVED;
-import static org.onosproject.tetopology.management.api.link.TeLink.BIT_ACCESS_INTERDOMAIN;
-import static org.onosproject.tetopology.management.impl.TeMgrUtil.linkBuilder;
-import static org.onosproject.tetopology.management.impl.TeMgrUtil.networkBuilder;
-import static org.onosproject.tetopology.management.impl.TeMgrUtil.networkLinkKey;
-import static org.onosproject.tetopology.management.impl.TeMgrUtil.networkNodeKey;
-import static org.onosproject.tetopology.management.impl.TeMgrUtil.nodeBuilder;
-import static org.onosproject.tetopology.management.impl.TeMgrUtil.toNetworkId;
-import static org.onosproject.tetopology.management.impl.TeMgrUtil.toNetworkLinkId;
-
-/**
- * Implementation of the topology management service.
- */
-@Component(immediate = true, service = { TeTopologyService.class, TeTopologyProviderRegistry.class })
-public class TeTopologyManager
- extends AbstractListenerProviderRegistry<TeTopologyEvent, TeTopologyListener,
- TeTopologyProvider, TeTopologyProviderService>
- implements TeTopologyService, TeTopologyProviderRegistry {
- private static final String APP_NAME = "org.onosproject.tetopology";
- private static final long DEFAULT_PROVIDER_ID = 77777;
- private static final long DEFAULT_CLIENT_ID = 0x00L;
- private long providerId = DEFAULT_PROVIDER_ID;
- private static final int MAX_THREADS = 1;
- private static final Ip4Address DEFAULT_TENODE_ID_START = Ip4Address.valueOf("10.10.10.10");
- private static final Ip4Address DEFAULT_TENODE_ID_END = Ip4Address.valueOf("250.250.250.250");
- private Ip4Address teNodeIpStart = DEFAULT_TENODE_ID_START;
- private Ip4Address teNodeIpEnd = DEFAULT_TENODE_ID_END;
- private long nextTeNodeId = teNodeIpStart.toInt();
- private boolean mdsc = true;
- private static final String MDSC_MODE = "true";
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigRegistry cfgService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceService deviceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LinkService linkService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceProviderRegistry deviceProviderRegistry;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LinkProviderRegistry linkProviderRegistry;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- public TeTopologyStore store;
-
- private TeTopologyStoreDelegate delegate = this::post;
- private final ConfigFactory<ApplicationId, TeTopologyConfig> factory =
- new ConfigFactory<ApplicationId, TeTopologyConfig>(APP_SUBJECT_FACTORY,
- TeTopologyConfig.class,
- "teTopologyCfg",
- false) {
- @Override
- public TeTopologyConfig createConfig() {
- return new TeTopologyConfig();
- }
- };
- private final NetworkConfigListener cfgLister = new InternalConfigListener();
- private ApplicationId appId;
- // The topology merged in MDSC
- private TeTopology mergedTopology = null;
- private TeTopologyKey mergedTopologyKey;
- private Network mergedNetwork = null;
- // Track new TE node id by its source TE node key
- private Map<TeNodeKey, Long> sourceNewTeNodeIdMap = Maps.newHashMap();
- // Track the external link keys by the plugId
- private Map<Long, LinkKeyPair> externalLinkMap = Maps.newHashMap();
- private ExecutorService executor;
-
- /**
- * Activation helper function.
- */
- public void activateBasics() {
- store.setDelegate(delegate);
- store.setProviderId(providerId);
- eventDispatcher.addSink(TeTopologyEvent.class, listenerRegistry);
- }
-
- /**
- * Deactivation helper function.
- */
- public void deactivateBasics() {
- store.unsetDelegate(delegate);
- eventDispatcher.removeSink(TeTopologyEvent.class);
- }
-
- @Activate
- public void activate() {
- activateBasics();
- appId = coreService.registerApplication(APP_NAME);
- cfgService.registerConfigFactory(factory);
- executor = newFixedThreadPool(MAX_THREADS, groupedThreads("onos/tetopology", "build-%d", log));
-
- cfgService.addListener(cfgLister);
- executor.execute(new TopologyMergerTask());
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- deactivateBasics();
- externalLinkMap.clear();
- cfgService.removeListener(cfgLister);
- cfgService.unregisterConfigFactory(factory);
- executor.shutdownNow();
- executor = null;
- log.info("Stopped");
- }
-
- @Override
- protected TeTopologyProviderService createProviderService(TeTopologyProvider provider) {
- return new InternalTopologyProviderService(provider);
- }
-
- private class InternalTopologyProviderService
- extends AbstractProviderService<TeTopologyProvider>
- implements TeTopologyProviderService {
-
- protected InternalTopologyProviderService(TeTopologyProvider provider) {
- super(provider);
- }
-
- @Override
- public void networkUpdated(Network network) {
- store.updateNetwork(network);
- }
-
- @Override
- public void networkRemoved(KeyId networkId) {
- store.removeNetwork(networkId);
- }
-
- @Override
- public void linkUpdated(NetworkLinkKey linkKey, NetworkLink link) {
- store.updateNetworkLink(linkKey, link);
- }
-
- @Override
- public void linkRemoved(NetworkLinkKey linkKey) {
- store.removeNetworkLink(linkKey);
- }
-
- @Override
- public void nodeUpdated(NetworkNodeKey nodeKey, NetworkNode node) {
- store.updateNetworkNode(nodeKey, node);
- }
-
- @Override
- public void nodeRemoved(NetworkNodeKey nodeKey) {
- store.removeNetworkNode(nodeKey);
- }
-
- @Override
- public void terminationPointUpdated(TerminationPointKey terminationPointKey,
- TerminationPoint terminationPoint) {
- store.updateTerminationPoint(terminationPointKey, terminationPoint);
- }
-
- @Override
- public void terminationPointRemoved(TerminationPointKey terminationPointKey) {
- store.removeTerminationPoint(terminationPointKey);
- }
- }
-
- private boolean isCustomizedLearnedTopology(TeTopologyKey key) {
- if (store.teTopology(key).flags().get(BIT_CUSTOMIZED) &&
- store.teTopology(key).flags().get(BIT_LEARNT)) {
- return true;
- }
- return false;
- }
-
- // Task for merge the learned topology.
- private class TopologyMergerTask implements Runnable {
-
- public TopologyMergerTask() {
- }
-
- @Override
- public void run() {
- try {
- TeTopologyMapEvent event;
- while ((event = store.mapEventQueue().take()) != null) {
- switch (event.type()) {
- case TE_TOPOLOGY_ADDED:
- case TE_TOPOLOGY_UPDATED:
- TeTopology teTopology = store.teTopology(event.teTopologyKey());
- post(new TeTopologyEvent(event.type(), teTopology));
- if (mdsc && event.type() == TE_TOPOLOGY_ADDED &&
- teTopology.flags().get(BIT_CUSTOMIZED) &&
- teTopology.flags().get(BIT_LEARNT)) {
- log.debug("TeTopology to be merged: {}", teTopology);
- mergeTopology(teTopology);
- }
- break;
- case TE_TOPOLOGY_REMOVED:
- post(new TeTopologyEvent(TE_TOPOLOGY_REMOVED,
- new DefaultTeTopology(event.teTopologyKey(),
- null, null, null, null)));
- break;
- case TE_NODE_ADDED:
- case TE_NODE_UPDATED:
- if (store.teTopology(event.teNodeKey().teTopologyKey()) == null) {
- // Event should be ignored when the topology is not there.
- break;
- }
- TeNode teNode = store.teNode(event.teNodeKey());
- post(new TeTopologyEvent(event.type(),
- new TeNodeEventSubject(event.teNodeKey(), teNode)));
- if (mdsc && isCustomizedLearnedTopology(event.teNodeKey().teTopologyKey())) {
- updateSourceTeNode(mergedTopology.teNodes(),
- event.teNodeKey().teTopologyKey(), teNode, true);
- }
- break;
- case TE_NODE_REMOVED:
- if (store.teTopology(event.teNodeKey().teTopologyKey()) == null) {
- // Event should be ignored when the topology is not there.
- break;
- }
- post(new TeTopologyEvent(TE_NODE_REMOVED,
- new TeNodeEventSubject(event.teNodeKey(), null)));
- if (mdsc && isCustomizedLearnedTopology(event.teNodeKey().teTopologyKey())) {
- removeSourceTeNode(mergedTopology.teNodes(), event.teNodeKey(), true);
- }
- break;
- case TE_LINK_ADDED:
- case TE_LINK_UPDATED:
- if (store.teTopology(event.teLinkKey().teTopologyKey()) == null ||
- store.teNode(event.teLinkKey().teNodeKey()) == null) {
- // Event should be ignored when the topology or node is not there.
- break;
- }
- TeLink teLink = store.teLink(event.teLinkKey());
- post(new TeTopologyEvent(event.type(),
- new TeLinkEventSubject(event.teLinkKey(), teLink)));
- if (mdsc && isCustomizedLearnedTopology(event.teLinkKey().teTopologyKey())) {
- Map<TeLinkTpKey, TeLink> teLinks = Maps.newHashMap(mergedTopology.teLinks());
- updateSourceTeLink(teLinks, event.teLinkKey().teTopologyKey(), teLink, true);
- updateMergedTopology(mergedTopology.teNodes(), teLinks);
- }
- break;
- case TE_LINK_REMOVED:
- if (store.teTopology(event.teLinkKey().teTopologyKey()) == null ||
- store.teNode(event.teLinkKey().teNodeKey()) == null) {
- // Event should be ignored when the topology or node is not there.
- break;
- }
- post(new TeTopologyEvent(TE_LINK_REMOVED,
- new TeLinkEventSubject(event.teLinkKey(), null)));
- if (mdsc && isCustomizedLearnedTopology(event.teLinkKey().teTopologyKey())) {
- Map<TeLinkTpKey, TeLink> teLinks = Maps.newHashMap(mergedTopology.teLinks());
- removeSourceTeLink(teLinks, event.teLinkKey(), true);
- updateMergedTopology(mergedTopology.teNodes(), teLinks);
- }
- break;
- case NETWORK_ADDED:
- case NETWORK_UPDATED:
- Network network = store.network(event.networkKey());
- post(new TeTopologyEvent(event.type(), network));
- break;
- case NETWORK_REMOVED:
- post(new TeTopologyEvent(NETWORK_REMOVED,
- new DefaultNetwork(event.networkKey(), null, null,
- null, null, false, null,
- NOT_OPTIMIZED)));
- break;
- case NODE_ADDED:
- case NODE_UPDATED:
- if (store.network(event.networkNodeKey().networkId()) == null) {
- // Event should be ignored when the network is not there.
- break;
- }
- NetworkNode node = store.networkNode(event.networkNodeKey());
- post(new TeTopologyEvent(event.type(),
- new NetworkNodeEventSubject(event.networkNodeKey(), node)));
- break;
- case NODE_REMOVED:
- if (store.network(event.networkNodeKey().networkId()) == null) {
- // Event should be ignored when the network is not there.
- break;
- }
- post(new TeTopologyEvent(NODE_REMOVED,
- new NetworkNodeEventSubject(event.networkNodeKey(), null)));
- break;
- case LINK_ADDED:
- case LINK_UPDATED:
- if (store.network(event.networkLinkKey().networkId()) == null) {
- // Event should be ignored when the network is not there.
- break;
- }
- NetworkLink link = store.networkLink(event.networkLinkKey());
- post(new TeTopologyEvent(event.type(),
- new NetworkLinkEventSubject(event.networkLinkKey(), link)));
- break;
- case LINK_REMOVED:
- if (store.network(event.networkLinkKey().networkId()) == null) {
- // Event should be ignored when the network is not there.
- break;
- }
- post(new TeTopologyEvent(LINK_REMOVED,
- new NetworkLinkEventSubject(event.networkLinkKey(), null)));
- break;
- default:
- break;
- }
- }
- } catch (InterruptedException e) {
- log.warn("TopologyMergerTask is interrupted");
- Thread.currentThread().interrupt();
- } catch (Exception e) {
- log.warn("Unable to merge topology", e);
- }
- }
- }
-
- private void removeSourceTeNode(Map<Long, TeNode> teNodes,
- TeNodeKey srcNodeKey, boolean postEvent) {
- Long mergedTeNodeId = sourceNewTeNodeIdMap.remove(srcNodeKey);
- if (mergedTeNodeId == null) {
- return;
- }
- if (teNodes.remove(mergedTeNodeId) != null && postEvent) {
- TeNodeKey nodeKey = new TeNodeKey(mergedTopologyKey,
- mergedTeNodeId);
- post(new TeTopologyEvent(TE_NODE_REMOVED,
- new TeNodeEventSubject(nodeKey, null)));
- post(new TeTopologyEvent(NODE_REMOVED,
- new NetworkNodeEventSubject(TeMgrUtil
- .networkNodeKey(nodeKey), null)));
- }
- }
-
- private void updateSourceTeNode(Map<Long, TeNode> teNodes, TeTopologyKey srcTopoKey,
- TeNode srcNode, boolean postEvent) {
- TeNodeKey sourceTeNodeId = new TeNodeKey(srcTopoKey, srcNode.teNodeId());
- Long mergedTeNodeId = sourceNewTeNodeIdMap.get(sourceTeNodeId);
- boolean addNode = false;
- if (mergedTeNodeId == null) {
- // New node
- addNode = true;
- mergedTeNodeId = nextTeNodeId;
- nextTeNodeId++;
- if (nextTeNodeId >= teNodeIpEnd.toInt()) {
- nextTeNodeId = teNodeIpStart.toInt();
- log.warn("TE node Id is wrapped back");
- }
- sourceNewTeNodeIdMap.put(sourceTeNodeId, mergedTeNodeId);
- }
- TeTopologyKey underlayTopologyId = null; // No underlay
- TeNodeKey supportTeNodeId = null; // No supporting
-
- CommonNodeData common = new CommonNodeData(srcNode.name(), srcNode.adminStatus(),
- srcNode.opStatus(), srcNode.flags()); // No change
- Map<Long, ConnectivityMatrix> connMatrices = srcNode.connectivityMatrices();
- List<Long> teLinkIds = srcNode.teLinkIds(); // No change
- Map<Long, TunnelTerminationPoint> ttps = null;
- if (MapUtils.isNotEmpty(srcNode.tunnelTerminationPoints())) {
- ttps = Maps.newHashMap();
- for (Map.Entry<Long, TunnelTerminationPoint> entry : srcNode.tunnelTerminationPoints().entrySet()) {
- TunnelTerminationPoint ttp = entry.getValue();
- ttps.put(entry.getKey(),
- new DefaultTunnelTerminationPoint(ttp.ttpId(), ttp.switchingLayer(),
- ttp.encodingLayer(), ttp.flags(),
- ttp.interLayerLockList(),
- ttp.localLinkConnectivityList(),
- ttp.availAdaptBandwidth(),
- null)); //Remove supporting TTP Ids
- }
- }
-
- List<Long> teTpIds = srcNode.teTerminationPointIds(); // No change
- DefaultTeNode newNode = new DefaultTeNode(mergedTeNodeId, underlayTopologyId,
- supportTeNodeId, sourceTeNodeId, common, connMatrices, teLinkIds,
- ttps, teTpIds);
- teNodes.put(mergedTeNodeId, newNode);
- if (postEvent) {
- //Post event for the TE node in the merged topology
- TeNodeKey globalKey = new TeNodeKey(mergedTopologyKey, mergedTeNodeId);
- post(new TeTopologyEvent(addNode ? TE_NODE_ADDED : TE_NODE_UPDATED,
- new TeNodeEventSubject(globalKey, newNode)));
- post(new TeTopologyEvent(addNode ? NODE_ADDED : NODE_UPDATED,
- new NetworkNodeEventSubject(networkNodeKey(globalKey),
- nodeBuilder(KeyId.keyId(
- Ip4Address.valueOf((int) newNode.teNodeId()).toString()),
- newNode))));
- }
- }
-
- // Merge TE nodes
- private void mergeNodes(Map<Long, TeNode> nodes, TeTopology topology) {
-
- if (!MapUtils.isEmpty(topology.teNodes())) {
- for (Map.Entry<Long, TeNode> entry : topology.teNodes().entrySet()) {
- updateSourceTeNode(nodes, topology.teTopologyId(), entry.getValue(),
- mergedTopology != null);
- }
- }
- }
-
- // Returns a new TeLink based on an existing TeLink with new attributes
- private TeLink updateTeLink(TeLinkTpKey newKey, TeLinkTpKey peerTeLinkKey,
- TeTopologyKey underlayTopologyId, TeLinkTpGlobalKey supportTeLinkId,
- TeLinkTpGlobalKey sourceTeLinkId, ExternalLink externalLink,
- TeLink exLink) {
- UnderlayPath underlayPath = null;
- if (underlayTopologyId != null &&
- underlayTopologyId.equals(exLink.underlayTeTopologyId())) {
- underlayPath = new UnderlayPath(exLink.primaryPath(),
- exLink.backupPaths(), exLink.tunnelProtectionType(),
- exLink.sourceTtpId(), exLink.destinationTtpId(),
- exLink.teTunnelId()
- );
- }
-
- TePathAttributes teAttributes = new TePathAttributes(exLink.cost(),
- exLink.delay(), exLink.srlgs());
- LinkBandwidth bandwidth = new LinkBandwidth(exLink.maxBandwidth(),
- exLink.availBandwidth(),
- exLink.maxAvailLspBandwidth(),
- exLink.minAvailLspBandwidth(),
- exLink.oduResource());
- BitSet flags = exLink.flags();
- if (peerTeLinkKey != null &&
- externalLink != null && externalLink.plugId() != null) {
- // Assuming this is an inter-domain link which is merged with its peer,
- // needs to clear BIT_ACCESS_INTERDOMAIN
- flags.clear(BIT_ACCESS_INTERDOMAIN);
- } else if (peerTeLinkKey == null &&
- externalLink != null && externalLink.plugId() != null) {
- // Assuming this is an inter-domain link which lost its peer,
- // needs to clear BIT_ACCESS_INTERDOMAIN
- flags.set(BIT_ACCESS_INTERDOMAIN);
- }
-
- CommonLinkData common = new CommonLinkData(exLink.adminStatus(), exLink.opStatus(),
- flags, exLink.switchingLayer(), exLink.encodingLayer(),
- externalLink, underlayPath, teAttributes,
- exLink.administrativeGroup(), exLink.interLayerLocks(),
- bandwidth);
- return new DefaultTeLink(newKey, peerTeLinkKey, underlayTopologyId,
- supportTeLinkId, sourceTeLinkId, common);
- }
-
- private class LinkKeyPair {
- private TeLinkTpKey firstKey;
- private TeLinkTpKey secondKey;
-
- public LinkKeyPair(TeLinkTpKey firstKey) {
- this.firstKey = firstKey;
- }
-
- public TeLinkTpKey firstKey() {
- return firstKey;
- }
-
- public void setFirstKey(TeLinkTpKey firstKey) {
- this.firstKey = firstKey;
- }
-
- public TeLinkTpKey secondKey() {
- return secondKey;
- }
-
- public void setSecondKey(TeLinkTpKey secondKey) {
- this.secondKey = secondKey;
- }
-
- public boolean isFirstKey(TeLinkTpKey linkKey) {
- return firstKey == null ? false : firstKey.equals(linkKey);
- }
-
- public boolean isSecondKey(TeLinkTpKey linkKey) {
- return secondKey == null ? false : secondKey.equals(linkKey);
- }
-
- public boolean isEmpty() {
- return firstKey == null && secondKey == null;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("firstKey", firstKey)
- .add("secondKey", secondKey)
- .toString();
- }
- }
-
- private void removeSourceTeLink(Map<TeLinkTpKey, TeLink> teLinks, TeLinkTpGlobalKey teLinkKey,
- boolean postEvent) {
- TeNodeKey sourceTeNodeKey = teLinkKey.teNodeKey();
- Long newTeNodeId = sourceNewTeNodeIdMap.get(sourceTeNodeKey);
- if (newTeNodeId == null) {
- return;
- }
- TeLinkTpKey newLinkKey = new TeLinkTpKey(newTeNodeId, teLinkKey.teLinkTpId());
- TeLink teLink = teLinks.remove(newLinkKey);
- if (teLink == null) {
- return;
- }
- //Post event
- if (postEvent) {
- TeLinkTpGlobalKey globalKey = new TeLinkTpGlobalKey(mergedTopologyKey,
- newLinkKey);
- post(new TeTopologyEvent(TE_LINK_REMOVED,
- new TeLinkEventSubject(globalKey, null)));
- post(new TeTopologyEvent(LINK_REMOVED,
- new NetworkLinkEventSubject(networkLinkKey(globalKey),
- null)));
- }
-
- if (teLink.externalLink() != null && teLink.externalLink().plugId() != null) {
- // Update the LinkKeyPair in externalLinkMap
- LinkKeyPair pair = externalLinkMap.get(teLink.externalLink().plugId());
- if (pair.isFirstKey(newLinkKey)) {
- pair.setFirstKey(null);
- } else if (pair.isSecondKey(newLinkKey)) {
- pair.setSecondKey(null);
- }
- if (pair.isEmpty()) {
- externalLinkMap.remove(teLink.externalLink().plugId());
- }
- }
- TeLinkTpKey peerTeLinkKey = teLink.peerTeLinkKey();
- if (peerTeLinkKey != null) {
- // Update peerLink's peerTeLinkKey to null
- TeLink peerLink = teLinks.get(peerTeLinkKey);
- if (peerLink == null || peerLink.peerTeLinkKey() == null) {
- return;
- }
- TeLink newPeerLink = updateTeLink(peerTeLinkKey, null,
- peerLink.underlayTeTopologyId(), peerLink.supportingTeLinkId(),
- peerLink.sourceTeLinkId(), peerLink.externalLink(), peerLink);
- teLinks.put(peerTeLinkKey, newPeerLink);
- if (postEvent) {
- TeLinkTpGlobalKey globalKey = new TeLinkTpGlobalKey(mergedTopologyKey,
- peerTeLinkKey);
- post(new TeTopologyEvent(TE_LINK_UPDATED,
- new TeLinkEventSubject(globalKey,
- newPeerLink)));
- post(new TeTopologyEvent(LINK_UPDATED,
- new NetworkLinkEventSubject(networkLinkKey(globalKey),
- linkBuilder(toNetworkLinkId(peerTeLinkKey),
- newPeerLink))));
- }
- }
- }
-
- private void updateSourceTeLink(Map<TeLinkTpKey, TeLink> teLinks, TeTopologyKey srcTopoKey,
- TeLink srcLink, boolean postEvent) {
- TeNodeKey sourceTeNodeId = new TeNodeKey(srcTopoKey,
- srcLink.teLinkKey().teNodeId());
- TeLinkTpKey newKey = new TeLinkTpKey(
- sourceNewTeNodeIdMap.get(sourceTeNodeId),
- srcLink.teLinkKey().teLinkTpId());
- TeLinkTpKey peerTeLinkKey = null;
- if (srcLink.peerTeLinkKey() != null) {
- TeNodeKey sourcePeerNode = new TeNodeKey(srcTopoKey,
- srcLink.peerTeLinkKey().teNodeId());
- peerTeLinkKey = new TeLinkTpKey(
- sourceNewTeNodeIdMap.get(sourcePeerNode),
- srcLink.peerTeLinkKey().teLinkTpId());
- }
-
- if (srcLink.externalLink() != null &&
- srcLink.externalLink().plugId() != null) {
- // externalLinkKey doesn't have topology Id.
- // using plugId for now
- LinkKeyPair pair = externalLinkMap.get(srcLink.externalLink().plugId());
- if (pair == null) {
- // Store it in the map
- externalLinkMap.put(srcLink.externalLink().plugId(),
- new LinkKeyPair(newKey));
- } else {
- if (newKey.equals(pair.firstKey())) {
- peerTeLinkKey = pair.secondKey();
- } else if (newKey.equals(pair.secondKey())) {
- peerTeLinkKey = pair.firstKey();
- } else if (pair.firstKey() == null) {
- peerTeLinkKey = pair.secondKey();
- pair.setFirstKey(newKey);
- } else if (pair.secondKey() == null) {
- peerTeLinkKey = pair.firstKey();
- pair.setSecondKey(newKey);
- }
-
- if (peerTeLinkKey != null) {
- TeLink peerLink = teLinks.get(peerTeLinkKey);
- if (peerLink != null && (peerLink.peerTeLinkKey() == null
- || !peerLink.peerTeLinkKey().equals(newKey))) {
- // Update peer Link with local link key
- TeLink newPeerLink = updateTeLink(peerTeLinkKey, newKey,
- peerLink.underlayTeTopologyId(),
- peerLink.supportingTeLinkId(),
- peerLink.sourceTeLinkId(),
- peerLink.externalLink(),
- peerLink);
- teLinks.put(peerTeLinkKey, newPeerLink);
- if (postEvent) {
- TeLinkTpGlobalKey globalKey = new TeLinkTpGlobalKey(mergedTopologyKey,
- peerTeLinkKey);
- post(new TeTopologyEvent(TE_LINK_UPDATED,
- new TeLinkEventSubject(globalKey,
- newPeerLink)));
- post(new TeTopologyEvent(LINK_UPDATED,
- new NetworkLinkEventSubject(
- networkLinkKey(globalKey),
- linkBuilder(toNetworkLinkId(peerTeLinkKey),
- newPeerLink))));
- }
- }
- }
- }
- }
-
- TeTopologyKey underlayTopologyId = null; // No underlay
- TeLinkTpGlobalKey supportTeLinkId = null; // No support
- // Source link for the new updated link
- TeLinkTpGlobalKey sourceTeLinkId = new TeLinkTpGlobalKey(srcTopoKey, srcLink.teLinkKey());
- TeLink updatedLink = updateTeLink(newKey, peerTeLinkKey, underlayTopologyId,
- supportTeLinkId, sourceTeLinkId,
- srcLink.externalLink(), srcLink);
- TeLinkTpGlobalKey newGlobalKey = new TeLinkTpGlobalKey(mergedTopologyKey, newKey);
- boolean newLink = teLinks.get(newKey) == null ? true : false;
- teLinks.put(newKey, updatedLink);
- if (postEvent) {
- //Post event
- post(new TeTopologyEvent(newLink ? TE_LINK_ADDED : TE_LINK_UPDATED,
- new TeLinkEventSubject(newGlobalKey, updatedLink)));
- post(new TeTopologyEvent(newLink ? LINK_ADDED : LINK_UPDATED,
- new NetworkLinkEventSubject(networkLinkKey(newGlobalKey),
- linkBuilder(toNetworkLinkId(updatedLink.teLinkKey()),
- updatedLink))));
- }
- }
-
- // Merge TE links
- private void mergeLinks(Map<TeLinkTpKey, TeLink> teLinks, TeTopology topology) {
- if (!MapUtils.isEmpty(topology.teLinks())) {
- for (Map.Entry<TeLinkTpKey, TeLink> entry : topology.teLinks().entrySet()) {
- TeLink srcLink = entry.getValue();
- updateSourceTeLink(teLinks, topology.teTopologyId(), srcLink,
- mergedTopology != null);
- }
- }
- }
-
- // Update the merged topology with new TE nodes and links
- private void updateMergedTopology(Map<Long, TeNode> teNodes, Map<TeLinkTpKey, TeLink> teLinks) {
- boolean newTopology = mergedTopology == null;
- BitSet flags = newTopology ? new BitSet(TeConstants.FLAG_MAX_BITS) : mergedTopology.flags();
- flags.set(BIT_MERGED);
- CommonTopologyData commonData = new CommonTopologyData(newTopology ?
- toNetworkId(mergedTopologyKey) :
- mergedTopology.networkId(),
- NOT_OPTIMIZED,
- flags, DeviceId.deviceId("localHost"));
- mergedTopology = new DefaultTeTopology(mergedTopologyKey, teNodes, teLinks,
- Long.toString(mergedTopologyKey.topologyId()), commonData);
- mergedNetwork = networkBuilder(mergedTopology);
- log.info("Nodes# {}, Links# {}", mergedTopology.teNodes().size(), mergedTopology.teLinks().size());
- }
-
- // Merge the new learned topology
- private void mergeTopology(TeTopology topology) {
- boolean newTopology = mergedTopology == null;
- mergedTopologyKey = newTopology ?
- new TeTopologyKey(providerId, DEFAULT_CLIENT_ID,
- store.nextTeTopologyId()) :
- mergedTopology.teTopologyId();
-
- Map<Long, TeNode> teNodes = newTopology || mergedTopology.teNodes() == null ?
- Maps.newHashMap() : Maps.newHashMap(mergedTopology.teNodes());
- mergeNodes(teNodes, topology);
- Map<TeLinkTpKey, TeLink> teLinks = newTopology || mergedTopology.teLinks() == null ?
- Maps.newHashMap() : Maps.newHashMap(mergedTopology.teLinks());
- mergeLinks(teLinks, topology);
- updateMergedTopology(teNodes, teLinks);
- log.debug("mergedTopology {}", mergedTopology);
-
- if (newTopology) {
- // Post events for the merged network topology;
- post(new TeTopologyEvent(TE_TOPOLOGY_ADDED, mergedTopology));
- post(new TeTopologyEvent(NETWORK_ADDED, mergedNetwork));
- }
- }
-
- private TeTopologyKey newTeTopologyKey(TeTopology teTopology) {
- TeTopologyKey key = teTopology.teTopologyId();
- if (key == null || teTopology.teTopologyIdStringValue() == null) {
- log.error("Ignoring the non-TE topology");
- throw new ApplicationException("Missing TE topology ID");
- }
- // Get the topologyId numeric value
- long idValue = key.topologyId();
- if (idValue == TeConstants.NIL_LONG_VALUE) {
- if (teTopology.teTopologyIdStringValue() != null) {
- try {
- idValue = Long.parseLong(teTopology.teTopologyIdStringValue());
- } catch (NumberFormatException e) {
- // Can't get the long value from the string.
- // Use an assigned id value from local id pool,
- idValue = store.nextTeTopologyId();
- }
- return new TeTopologyKey(key.providerId(), key.clientId(), idValue);
- }
- }
- return null;
- }
-
- private class InternalConfigListener implements NetworkConfigListener {
-
- @Override
- public void event(NetworkConfigEvent event) {
- try {
- providerId = cfgService.getConfig(appId, TeTopologyConfig.class)
- .providerId();
- store.setProviderId(providerId);
- teNodeIpStart = cfgService.getConfig(appId, TeTopologyConfig.class)
- .teNodeIpStart();
- teNodeIpEnd = cfgService.getConfig(appId, TeTopologyConfig.class)
- .teNodeIpEnd();
- mdsc = cfgService.getConfig(appId, TeTopologyConfig.class)
- .mdsc().equals(MDSC_MODE);
- nextTeNodeId = teNodeIpStart.toInt();
- } catch (ConfigException e) {
- log.error("Configuration error {}", e);
- }
- }
-
- @Override
- public boolean isRelevant(NetworkConfigEvent event) {
- return event.configClass().equals(TeTopologyConfig.class) &&
- (event.type() == CONFIG_ADDED ||
- event.type() == CONFIG_UPDATED);
- }
- }
-
- @Override
- public TeTopologies teTopologies() {
- Map<TeTopologyKey, TeTopology> map;
- if (MapUtils.isNotEmpty(store.teTopologies().teTopologies())) {
- map = Maps.newHashMap(store.teTopologies().teTopologies());
- } else {
- map = Maps.newHashMap();
- }
- if (mergedTopology != null) {
- map.put(mergedTopologyKey, mergedTopology);
- }
- return new DefaultTeTopologies(store.teTopologies().name(), map);
- }
-
- @Override
- public TeTopology teTopology(TeTopologyKey topologyId) {
- if (mergedTopology != null &&
- topologyId != null &&
- topologyId.equals(mergedTopologyKey)) {
- return mergedTopology;
- }
- return store.teTopology(topologyId);
- }
-
- @Override
- public TeTopology mergedTopology() {
- return mergedTopology;
- }
-
- @Override
- public void updateTeTopology(TeTopology teTopology) {
- TeTopologyKey newKey = null;
- try {
- newKey = newTeTopologyKey(teTopology);
- } catch (ApplicationException e) {
- log.error("Ignoring the non-TE topology");
- return;
- }
-
- // TE topology is updated here from other APP or NBI, the flag
- // BIT_CUSTOMIZED or BIT_MERGED should be set.
- BitSet flags = teTopology.flags();
- if (flags == null ||
- !(flags.get(BIT_CUSTOMIZED) || flags.get(BIT_MERGED))) {
- log.error("TE topology flags {} are not set properly", flags);
- return;
- }
-
- if (newKey != null) {
- DefaultTeTopology newTopology = new DefaultTeTopology(
- newKey,
- teTopology.teNodes(), teTopology.teLinks(),
- teTopology.teTopologyIdStringValue(), new CommonTopologyData(teTopology));
- // Update with new data
- store.updateTeTopology(newTopology);
- } else {
- store.updateTeTopology(teTopology);
- }
- }
-
- @Override
- public void removeTeTopology(TeTopologyKey topologyId) {
- store.removeTeTopology(topologyId);
- }
-
- @Override
- public Networks networks() {
- List<Network> networks;
- if (CollectionUtils.isNotEmpty(store.networks())) {
- networks = Lists.newArrayList(store.networks());
- } else {
- networks = Lists.newArrayList();
- }
- if (mergedNetwork != null) {
- networks.add(mergedNetwork);
- }
- return new DefaultNetworks(networks);
- }
-
- @Override
- public Network network(KeyId networkId) {
- if (mergedNetwork != null &&
- mergedNetwork.networkId().equals(networkId)) {
- return mergedNetwork;
- }
- return store.network(networkId);
- }
-
- @Override
- public void updateNetwork(Network network) {
- // TODO: This will be implemented if required.
- }
-
- @Override
- public void removeNetwork(KeyId networkId) {
- // TODO: This will be implemented if required.
- }
-
- @Override
- public TeNode teNode(TeNodeKey nodeId) {
- return nodeId.teTopologyKey().equals(mergedTopologyKey) ?
- mergedTopology.teNode(nodeId.teNodeId()) :
- store.teNode(nodeId);
- }
-
- @Override
- public TeLink teLink(TeLinkTpGlobalKey linkId) {
- return linkId.teTopologyKey().equals(mergedTopologyKey) ?
- mergedTopology.teLink(linkId.teLinkTpKey()) :
- store.teLink(linkId);
- }
-
- @Override
- public TunnelTerminationPoint tunnelTerminationPoint(TtpKey ttpId) {
- return ttpId.teTopologyKey().equals(mergedTopologyKey) ?
- mergedTopology.teNode(ttpId.teNodeId()).tunnelTerminationPoint(ttpId.ttpId()) :
- store.tunnelTerminationPoint(ttpId);
- }
-
- @Override
- public KeyId networkId(TeTopologyKey teTopologyKey) {
- return teTopologyKey.equals(mergedTopologyKey) ?
- mergedNetwork.networkId() :
- store.networkId(teTopologyKey);
- }
-
- @Override
- public NetworkNodeKey nodeKey(TeNodeKey teNodeKey) {
- return teNodeKey.teTopologyKey().equals(mergedTopologyKey) ?
- networkNodeKey(teNodeKey) :
- store.nodeKey(teNodeKey);
- }
-
- @Override
- public NetworkLinkKey linkKey(TeLinkTpGlobalKey teLinkKey) {
- return teLinkKey.teTopologyKey().equals(mergedTopologyKey) ?
- networkLinkKey(teLinkKey) :
- store.linkKey(teLinkKey);
- }
-
- @Override
- public TerminationPointKey terminationPointKey(TeLinkTpGlobalKey teTpKey) {
- return teTpKey.teTopologyKey().equals(mergedTopologyKey) ?
- new TerminationPointKey(networkNodeKey(teTpKey.teNodeKey()),
- KeyId.keyId(Long.toString(teTpKey.teLinkTpId()))) :
- store.terminationPointKey(teTpKey);
- }
-
- @Override
- public long teContollerId() {
- return providerId;
- }
-}
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyMapEvent.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyMapEvent.java
deleted file mode 100644
index 285c5a5..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyMapEvent.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.impl;
-
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.TeTopologyEvent.Type;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-
-import com.google.common.base.MoreObjects;
-
-public class TeTopologyMapEvent {
- private final Type type;
- private TeTopologyKey teTopologyKey;
- private TeNodeKey teNodeKey;
- private TeLinkTpGlobalKey teLinkKey;
- private KeyId networkKey;
- private NetworkNodeKey networkNodeKey;
- private NetworkLinkKey networkLinkKey;
-
- /**
- * Creates an instance of TeTopologyMapEvent.
- *
- * @param type the map event type
- */
- public TeTopologyMapEvent(Type type) {
- this.type = type;
- }
-
- /**
- * Returns the map event type.
- *
- * @return the type
- */
- public Type type() {
- return type;
- }
-
- /**
- * Returns the TE topology key of the event.
- *
- * @return the teTopologyKey
- */
- public TeTopologyKey teTopologyKey() {
- return teTopologyKey;
- }
-
- /**
- * Sets the TE topology key of the event.
- *
- * @param teTopologyKey the teTopologyKey to set
- */
- public void setTeTopologyKey(TeTopologyKey teTopologyKey) {
- this.teTopologyKey = teTopologyKey;
- }
-
- /**
- * Returns the TE node key of the event.
- *
- * @return the teNodeKey
- */
- public TeNodeKey teNodeKey() {
- return teNodeKey;
- }
-
- /**
- * Sets the TE node key of the event.
- *
- * @param teNodeKey the teNodeKey to set
- */
- public void setTeNodeKey(TeNodeKey teNodeKey) {
- this.teNodeKey = teNodeKey;
- }
-
- /**
- * Returns the TE link key of the event.
- *
- * @return the teLinkKey
- */
- public TeLinkTpGlobalKey teLinkKey() {
- return teLinkKey;
- }
-
- /**
- * Sets the TE link key of the event.
- *
- * @param teLinkKey the teLinkKey to set
- */
- public void setTeLinkKey(TeLinkTpGlobalKey teLinkKey) {
- this.teLinkKey = teLinkKey;
- }
-
- /**
- * Returns the network key of the event.
- *
- * @return the networkKey
- */
- public KeyId networkKey() {
- return networkKey;
- }
-
- /**
- * Sets the network key of the event.
- *
- * @param networkKey the networkKey to set
- */
- public void setNetworkKey(KeyId networkKey) {
- this.networkKey = networkKey;
- }
-
- /**
- * Returns the network node key of the event.
- *
- * @return the networkNodeKey
- */
- public NetworkNodeKey networkNodeKey() {
- return networkNodeKey;
- }
-
- /**
- * Sets the network node key of the event.
- *
- * @param networkNodeKey the networkNodeKey to set
- */
- public void setNetworkNodeKey(NetworkNodeKey networkNodeKey) {
- this.networkNodeKey = networkNodeKey;
- }
-
- /**
- * Returns the network link key of the event.
- *
- * @return the networkLinkKey
- */
- public NetworkLinkKey networkLinkKey() {
- return networkLinkKey;
- }
-
- /**
- * Sets the network link key of the event.
- *
- * @param networkLinkKey the networkLinkKey to set
- */
- public void setNetworkLinkKey(NetworkLinkKey networkLinkKey) {
- this.networkLinkKey = networkLinkKey;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("type", type)
- .add("teTopologyKey", teTopologyKey)
- .add("teNodeKey", teNodeKey)
- .add("teLinkKey", teLinkKey)
- .add("networkKey", networkKey)
- .add("networkNodeKey", networkNodeKey)
- .add("networkLinkKey", networkLinkKey)
- .toString();
- }
-
-}
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyStore.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyStore.java
deleted file mode 100644
index 007d940..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyStore.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.impl;
-
-import java.util.List;
-import java.util.concurrent.BlockingQueue;
-
-import org.onosproject.store.Store;
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.Network;
-import org.onosproject.tetopology.management.api.TeTopologies;
-import org.onosproject.tetopology.management.api.TeTopology;
-import org.onosproject.tetopology.management.api.TeTopologyEvent;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.link.TeLink;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.node.NetworkNode;
-import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
-import org.onosproject.tetopology.management.api.node.TeNode;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TerminationPoint;
-import org.onosproject.tetopology.management.api.node.TerminationPointKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.tetopology.management.api.node.TunnelTerminationPoint;
-
-/**
- * Inventory of TE network topology.
- */
-public interface TeTopologyStore
- extends Store<TeTopologyEvent, TeTopologyStoreDelegate> {
-
- /**
- * Returns a collection of currently known networks.
- *
- * @return a collection of stored networks
- */
- List<Network> networks();
-
- /**
- * Returns a network.
- *
- * @param networkId network id in URI format
- * @return value of network
- */
- Network network(KeyId networkId);
-
- /**
- * Updates a network.
- *
- * @param network value of the network to be updated
- */
- void updateNetwork(Network network);
-
- /**
- * Removes a network.
- *
- * @param networkId network id in URI format
- */
- void removeNetwork(KeyId networkId);
-
- /**
- * Returns a network link.
- *
- * @param linkKey link key
- * @return value of network link
- */
- NetworkLink networkLink(NetworkLinkKey linkKey);
-
- /**
- * Updates a network link.
- *
- * @param linkKey link key
- * @param link link object to be updated
- */
- void updateNetworkLink(NetworkLinkKey linkKey, NetworkLink link);
-
- /**
- * Removes a network link.
- *
- * @param linkKey link key
- */
- void removeNetworkLink(NetworkLinkKey linkKey);
-
- /**
- * Returns a network node.
- *
- * @param nodeKey node key
- * @return value of network node
- */
- NetworkNode networkNode(NetworkNodeKey nodeKey);
-
- /**
- * Updates a network node.
- *
- * @param nodeKey node key
- * @param node node object to be updated
- */
- void updateNetworkNode(NetworkNodeKey nodeKey, NetworkNode node);
-
- /**
- * Removes a network node.
- *
- * @param nodeKey node key
- */
- void removeNetworkNode(NetworkNodeKey nodeKey);
-
- /**
- * Updates a terminationPoint.
- *
- * @param terminationPointKey termination point id
- * @param terminationPoint termination point object to be updated
- */
- void updateTerminationPoint(TerminationPointKey terminationPointKey,
- TerminationPoint terminationPoint);
-
- /**
- * Removes a terminationPoint.
- *
- * @param terminationPointKey termination point id
- */
- void removeTerminationPoint(TerminationPointKey terminationPointKey);
-
- /**
- * Returns a collection of currently known TE topologies.
- *
- * @return a collection of topologies
- */
- TeTopologies teTopologies();
-
- /**
- * Returns the TE Topology identified by its Id.
- *
- * @param topologyId TE topology Key
- * @return value of TeTopology
- */
- TeTopology teTopology(TeTopologyKey topologyId);
-
- /**
- * Creates or updates a TE topology.
- *
- * @param teTopology value of the TE topology to be updated
- */
- void updateTeTopology(TeTopology teTopology);
-
- /**
- * Removes the TE Topology identified by its Id.
- *
- * @param topologyId TE topology key
- */
- void removeTeTopology(TeTopologyKey topologyId);
-
- /**
- * Returns the TE node identified by its Id.
- *
- * @param nodeId the te node key
- * @return value of node
- */
- TeNode teNode(TeNodeKey nodeId);
-
- /**
- * Creates or updates a TE Node.
- *
- * @param nodeKey te node id
- * @param node node object to be updated
- */
- void updateTeNode(TeNodeKey nodeKey, TeNode node);
-
- /**
- * Removes the TE node identified by its Id.
- *
- * @param nodeId the te node key
- */
- void removeTeNode(TeNodeKey nodeId);
-
- /**
- * Returns the TE link identified by its Id.
- *
- * @param linkId the te link key
- * @return value of link
- */
- TeLink teLink(TeLinkTpGlobalKey linkId);
-
- /**
- * Creates or updates a TE Link.
- *
- * @param linkKey link id
- * @param link teLink object to be updated
- */
- void updateTeLink(TeLinkTpGlobalKey linkKey, TeLink link);
-
- /**
- * Removes the TE link identified by its Id.
- *
- * @param linkId the te link key
- */
- void removeTeLink(TeLinkTpGlobalKey linkId);
-
- /**
- * Returns a tunnel termination point identified by its id.
- *
- * @param ttpId the tunnel termination point key
- * @return the tunnel termination point
- */
- TunnelTerminationPoint tunnelTerminationPoint(TtpKey ttpId);
-
- /**
- * Returns the network Id for a TE Topology key.
- *
- * @param teTopologyKey a TE topology key
- * @return value of network Id
- */
- KeyId networkId(TeTopologyKey teTopologyKey);
-
- /**
- * Returns the network node key for a TE node key.
- *
- * @param teNodeKey a TE node key
- * @return value of network node key
- */
- NetworkNodeKey nodeKey(TeNodeKey teNodeKey);
-
- /**
- * Returns the network link key for a TE link key.
- *
- * @param teLinkKey a TE node key
- * @return value of network link key
- */
- NetworkLinkKey linkKey(TeLinkTpGlobalKey teLinkKey);
-
- /**
- * Returns the termination point key for a TE termination point key.
- *
- * @param teTpKey a TE termination point key
- * @return value of termination point key
- */
- TerminationPointKey terminationPointKey(TeLinkTpGlobalKey teTpKey);
-
- /**
- * Returns the long value of next available TE topology id.
- *
- * @return value of TE topology id
- */
- long nextTeTopologyId();
-
- /**
- * Returns the next available TE node Id in a TE topology.
- *
- * @param topologyKey TE topology key
- * @return value of TE node id
- */
- long nextTeNodeId(TeTopologyKey topologyKey);
-
- /**
- * Sets the next available TE node Id in a TE topology.
- *
- * @param topologyKey TE topology key
- * @param nextNodeId value of next TE node id
- */
- void setNextTeNodeId(TeTopologyKey topologyKey, long nextNodeId);
-
- /**
- * Returns the queue to store the events originating from consistent maps.
- *
- * @return value of the blocking queue
- */
- BlockingQueue<TeTopologyMapEvent> mapEventQueue();
-
- /**
- * Sets the provider ID.
- *
- * @param providerId value of provider Id
- */
- void setProviderId(long providerId);
-
-}
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyStoreDelegate.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyStoreDelegate.java
deleted file mode 100644
index cfecd63..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/TeTopologyStoreDelegate.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management.impl;
-
-import org.onosproject.store.StoreDelegate;
-import org.onosproject.tetopology.management.api.TeTopologyEvent;
-
-/**
- * Abstraction of TE networks store delegate.
- */
-public interface TeTopologyStoreDelegate extends StoreDelegate<TeTopologyEvent> {
-
-}
diff --git a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/package-info.java b/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/package-info.java
deleted file mode 100644
index fb0324e..0000000
--- a/apps/tetopology/app/src/main/java/org/onosproject/tetopology/management/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * TE Topology Management implementation.
- */
-package org.onosproject.tetopology.management.impl;
diff --git a/apps/tetopology/app/src/test/java/org/onosproject/tetopology/management/DefaultBuilder.java b/apps/tetopology/app/src/test/java/org/onosproject/tetopology/management/DefaultBuilder.java
deleted file mode 100644
index 1c82fcc..0000000
--- a/apps/tetopology/app/src/test/java/org/onosproject/tetopology/management/DefaultBuilder.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management;
-
-import java.util.BitSet;
-import java.util.List;
-import java.util.Map;
-
-import org.onlab.packet.Ip4Address;
-import org.onosproject.net.DeviceId;
-import org.onosproject.tetopology.management.api.DefaultNetwork;
-import org.onosproject.tetopology.management.api.EncodingType;
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.Network;
-import org.onosproject.tetopology.management.api.OptimizationType;
-import org.onosproject.tetopology.management.api.SwitchingType;
-import org.onosproject.tetopology.management.api.TeConstants;
-import org.onosproject.tetopology.management.api.TeStatus;
-import org.onosproject.tetopology.management.api.TeTopologyId;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.link.CommonLinkData;
-import org.onosproject.tetopology.management.api.link.DefaultNetworkLink;
-import org.onosproject.tetopology.management.api.link.DefaultTeLink;
-import org.onosproject.tetopology.management.api.link.ExternalLink;
-import org.onosproject.tetopology.management.api.link.LinkBandwidth;
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.link.OduResource;
-import org.onosproject.tetopology.management.api.link.TeLink;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.link.TeLinkTpKey;
-import org.onosproject.tetopology.management.api.link.TePathAttributes;
-import org.onosproject.tetopology.management.api.link.UnderlayPath;
-import org.onosproject.tetopology.management.api.node.CommonNodeData;
-import org.onosproject.tetopology.management.api.node.ConnectivityMatrix;
-import org.onosproject.tetopology.management.api.node.DefaultNetworkNode;
-import org.onosproject.tetopology.management.api.node.DefaultTeNode;
-import org.onosproject.tetopology.management.api.node.DefaultTerminationPoint;
-import org.onosproject.tetopology.management.api.node.DefaultTunnelTerminationPoint;
-import org.onosproject.tetopology.management.api.node.NetworkNode;
-import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
-import org.onosproject.tetopology.management.api.node.NodeTpKey;
-import org.onosproject.tetopology.management.api.node.TeNode;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TerminationPoint;
-import org.onosproject.tetopology.management.api.node.TunnelTerminationPoint;
-import org.onosproject.tetopology.management.impl.TeMgrUtil;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-/**
- * Builds a sample abstract TE Topology, which consists of one node(represents
- * an entire network), one inter-domain link and one TTP.
- */
-public final class DefaultBuilder {
- private static final String NODEIP = "100.10.10.10";
- // Bandwidth in GigaBits/second
- private static final float[] ODU0BW = {1.25f, 1.25f, 1.25f, 1.25f, 1.25f, 1.25f, 1.25f, 1.25f};
- private static final float[] ODU2BW = {10, 10, 10, 10, 10, 10, 10, 10};
- private static final float[] ODU3BW = {40, 40, 40, 40, 40, 40, 40, 40};
- private static final float[] ODU4BW = {100, 100, 100, 100, 100, 100, 100, 100};
-
- private static final String ODU2 = "ODU2";
- private static final String ODU3 = "ODU3";
- private static final String ODU4 = "ODU4";
-
- private static final long PROVIDER_ID = 0x100;
- private static final long CLIENT_ID = 0x0a0a0a0a;
- private static final long CLIENT_NIL = 0;
- private static final long ABSTRACT_TOPOLOGY_ID = 100;
- private static final long NATIVE_TOPOLOGY_ID = 1;
- private static final long NUM_TPS = 1;
- private static final long NUM_TTPS = 1;
- private static final boolean ABSTRACT = true;
- private static final boolean UNABSTRACT = false;
- private static final int FIRST_INDEX = 0;
- private static final long INTER_DOMAIN_LINK_PLUGID = 100;
- private static final long LINK_COST = 500;
- private static final long LINK_DELAY = 2000;
- private static final long LINK_SRLG = 150;
- private static final String DOMAIN_ID = "DomainX";
-
- private static NetworkNode networkNode;
- private static TeNode teNode;
- private static NetworkLink networkLink;
- private static TeLink teLink;
- private static Network network;
- private static TunnelTerminationPoint ttp;
-
- private static TeTopologyKey teTopologyKey = new TeTopologyKey(PROVIDER_ID,
- CLIENT_ID,
- ABSTRACT_TOPOLOGY_ID);
-
- // no instantiation
- private DefaultBuilder() {
- }
-
- private static TunnelTerminationPoint ttpBuilder(long ttpId) {
- return new DefaultTunnelTerminationPoint(ttpId, SwitchingType.OTN_TDM_CAPABLE,
- EncodingType.LSP_ENCODING_ODUK,
- new BitSet(TeConstants.FLAG_MAX_BITS),
- null, null,
- ODU2BW, null); //10G for ODU2
- }
-
- private static TerminationPoint tpBuilder(long teTpId) {
- return new DefaultTerminationPoint(KeyId.keyId(Long.toString(teTpId)), null, teTpId);
- }
-
- private static NetworkNode nodeBuilder(String nodeIp, long numTps, long numTtps,
- TeTopologyKey underlayTopologyId, TeNodeKey supportTeNodeId,
- TeNodeKey sourceTeNodeId, boolean isAbstract) {
- long teNodeId = Ip4Address.valueOf(nodeIp).toInt();
- BitSet flags = new BitSet(TeConstants.FLAG_MAX_BITS);
-
- if (isAbstract) {
- flags.set(TeNode.BIT_ABSTRACT);
- }
- CommonNodeData common = new CommonNodeData(nodeIp, TeStatus.UP, TeStatus.UP, flags);
- Map<Long, ConnectivityMatrix> connMatrices = null;
- List<Long> teTpIds = Lists.newArrayList();
- Map<KeyId, TerminationPoint> tps = Maps.newHashMap();
- for (long i = 0; i < numTps; i++) {
- teTpIds.add(i);
- tps.put(KeyId.keyId(Long.toString(i)), tpBuilder(i));
- }
- //TTP
- Map<Long, TunnelTerminationPoint> ttps = Maps.newHashMap();
- for (long i = 0; i < numTtps; i++) {
- ttps.put(i, ttpBuilder(i));
- }
- ttp = ttps.get((long) FIRST_INDEX);
- //TeNode
- teNode = new DefaultTeNode(teNodeId, underlayTopologyId,
- supportTeNodeId, sourceTeNodeId,
- common, connMatrices, teTpIds, ttps, teTpIds);
- List<NetworkNodeKey> supportingNodeIds = null;
- if (supportTeNodeId != null) {
- supportingNodeIds = Lists
- .newArrayList(TeMgrUtil.networkNodeKey(supportTeNodeId));
- }
-
- return new DefaultNetworkNode(KeyId.keyId(nodeIp), supportingNodeIds, teNode, tps);
- }
-
- private static LinkBandwidth linkBwBuilder(String odu) {
-
- float[] maxBandwidth; //Maximum bandwidth, Size is MAX_PRIORITY + 1
- float[] avaiBandwidth; //Unreserved bandwidth, Size is MAX_PRIORITY + 1
- float[] maxAvialLspBandwidth; //Maximum available bandwidth for a LSP
- float[] minAvialLspBandwidth; //Minimum available bandwidth for a LSP
- short odu0s;
- short odu1s;
- short odu2s;
- short odu2es = 0;
- short odu3s;
- short odu4s;
- short oduFlexes = 0;
-
- switch (odu) {
- case ODU3:
- maxBandwidth = ODU3BW;
- avaiBandwidth = ODU3BW;
- maxAvialLspBandwidth = ODU3BW;
- minAvialLspBandwidth = ODU0BW;
- odu0s = 32;
- odu1s = 16;
- odu2s = 4;
- odu3s = 1;
- odu4s = 0;
- break;
- case ODU4:
- maxBandwidth = ODU4BW;
- avaiBandwidth = ODU4BW;
- maxAvialLspBandwidth = ODU4BW;
- minAvialLspBandwidth = ODU0BW;
- odu0s = 80;
- odu1s = 40;
- odu2s = 10;
- odu3s = 2;
- odu4s = 1;
- break;
- default:
- maxBandwidth = ODU2BW;
- avaiBandwidth = ODU2BW;
- maxAvialLspBandwidth = ODU2BW;
- minAvialLspBandwidth = ODU0BW;
- odu0s = 8;
- odu1s = 4;
- odu2s = 1;
- odu3s = 0;
- odu4s = 0;
- }
-
- OduResource oduRrc = new OduResource(odu0s, odu1s, odu2s, odu2es, odu3s,
- odu4s, oduFlexes);
- return new LinkBandwidth(maxBandwidth, avaiBandwidth, maxAvialLspBandwidth,
- minAvialLspBandwidth, oduRrc);
- }
-
- private static NetworkLink linkBuilder(TeLinkTpKey teLinkKey, TeLinkTpKey peerTeLinkKey,
- TeTopologyKey underlayTopologyId, TeLinkTpGlobalKey supportTeLinkId,
- TeLinkTpGlobalKey sourceTeLinkId, boolean isAbstract, Long plugid,
- Long cost, Long delay, List<Long> srlgs, String odu) {
- //NetworkLink
- KeyId linkId = TeMgrUtil.toNetworkLinkId(teLinkKey);
- NodeTpKey source = TeMgrUtil.nodeTpKey(teLinkKey);
- NodeTpKey destination = null;
- if (peerTeLinkKey != null) {
- destination = TeMgrUtil.nodeTpKey(peerTeLinkKey);
- }
- List<NetworkLinkKey> supportingLinkIds = null;
- if (supportTeLinkId != null) {
- supportingLinkIds = Lists
- .newArrayList(TeMgrUtil.networkLinkKey(supportTeLinkId));
- }
- BitSet flags = new BitSet(TeConstants.FLAG_MAX_BITS);
- if (isAbstract) {
- flags.set(TeLink.BIT_ABSTRACT);
- }
- ExternalLink externalLink = null;
-
- if (plugid != null) {
- // Inter-Domain Link
- flags.set(TeLink.BIT_ACCESS_INTERDOMAIN);
- externalLink = new ExternalLink(null, plugid);
- }
- UnderlayPath underlayPath = null;
- Long adminGroup = null;
- List<Long> interLayerLocks = null;
- teLink = new DefaultTeLink(teLinkKey, peerTeLinkKey, underlayTopologyId,
- supportTeLinkId, sourceTeLinkId,
- new CommonLinkData(TeStatus.UP, TeStatus.UP, flags,
- SwitchingType.OTN_TDM_CAPABLE,
- EncodingType.LSP_ENCODING_ODUK,
- externalLink, underlayPath,
- new TePathAttributes(cost, delay, srlgs),
- adminGroup, interLayerLocks, linkBwBuilder(odu)));
- return new DefaultNetworkLink(linkId, source, destination, supportingLinkIds, teLink);
- }
-
- private static Network networkBuilder(TeTopologyId teTopologyId, KeyId supportingNetworkId,
- Map<KeyId, NetworkNode> nodes,
- Map<KeyId, NetworkLink> links,
- boolean serverProvided,
- DeviceId ownerId,
- OptimizationType optType) {
- KeyId networkId = TeMgrUtil.toNetworkId(teTopologyId);
- List<KeyId> supportingNetworkIds = null;
- if (supportingNetworkId != null) {
- supportingNetworkIds = Lists.newArrayList(supportingNetworkId);
- }
- return new DefaultNetwork(networkId, supportingNetworkIds, nodes, links, teTopologyId,
- serverProvided, ownerId, optType);
- }
-
- /**
- * Returns the key for the sample TE Topology.
- *
- * @return value of TE Topology key
- */
- public static TeTopologyKey teTopologyKey() {
- return teTopologyKey;
- }
-
- /**
- * Returns the abstract TE Node in the sample TE Topology.
- *
- * @return value of TE node
- */
- public static TeNode teNode() {
- return teNode;
- }
-
- /**
- * Returns the TE link in the sample TE Topology.
- *
- * @return value of TE link
- */
- public static TeLink teLink() {
- return teLink;
- }
-
- /**
- * Builds a sample abstract TE Topology, which consists of one abstract node
- * representing an entire physical network, one inter-domain link and one
- * TTP.
- *
- * @return value of network with an abstract TE Topology
- */
- public static Network buildSampleAbstractNetwork() {
- TeTopologyKey underlayTopologyId = new TeTopologyKey(PROVIDER_ID,
- CLIENT_NIL,
- NATIVE_TOPOLOGY_ID);
- Map<KeyId, NetworkNode> nodes = Maps.newHashMap();
- networkNode = nodeBuilder(NODEIP, NUM_TPS, NUM_TTPS, underlayTopologyId,
- null, null, ABSTRACT);
- nodes.put(networkNode.nodeId(), networkNode);
-
- Map<KeyId, NetworkLink> links = Maps.newHashMap();
- TeLinkTpKey node1tp1 = new TeLinkTpKey(networkNode.teNode().teNodeId(),
- networkNode.teNode()
- .teTerminationPointIds()
- .get(FIRST_INDEX));
- networkLink = linkBuilder(node1tp1, null, null, null, null, UNABSTRACT,
- INTER_DOMAIN_LINK_PLUGID, LINK_COST,
- LINK_DELAY, Lists.newArrayList(LINK_SRLG),
- ODU4);
- links.put(networkLink.linkId(), networkLink);
- DeviceId ownerId = DeviceId.deviceId(DOMAIN_ID);
- TeTopologyId topologyId = new TeTopologyId(PROVIDER_ID, CLIENT_ID,
- Long.toString(ABSTRACT_TOPOLOGY_ID));
- network = networkBuilder(topologyId, null, nodes, links, false,
- ownerId, OptimizationType.NOT_OPTIMIZED);
- return network;
- }
-
-}
diff --git a/apps/tetopology/app/src/test/java/org/onosproject/tetopology/management/SimpleTeTopologyStore.java b/apps/tetopology/app/src/test/java/org/onosproject/tetopology/management/SimpleTeTopologyStore.java
deleted file mode 100644
index 24dcad5..0000000
--- a/apps/tetopology/app/src/test/java/org/onosproject/tetopology/management/SimpleTeTopologyStore.java
+++ /dev/null
@@ -1,1037 +0,0 @@
-/**
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
-import org.onosproject.net.DeviceId;
-import org.onosproject.store.AbstractStore;
-import org.onosproject.tetopology.management.api.CommonTopologyData;
-import org.onosproject.tetopology.management.api.DefaultNetwork;
-import org.onosproject.tetopology.management.api.DefaultTeTopologies;
-import org.onosproject.tetopology.management.api.DefaultTeTopology;
-import org.onosproject.tetopology.management.api.KeyId;
-import org.onosproject.tetopology.management.api.Network;
-import org.onosproject.tetopology.management.api.OptimizationType;
-import org.onosproject.tetopology.management.api.TeConstants;
-import org.onosproject.tetopology.management.api.TeTopologies;
-import org.onosproject.tetopology.management.api.TeTopology;
-import org.onosproject.tetopology.management.api.TeTopologyEvent;
-import org.onosproject.tetopology.management.api.TeTopologyId;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.TeUtils;
-import org.onosproject.tetopology.management.api.link.DefaultNetworkLink;
-import org.onosproject.tetopology.management.api.link.DefaultTeLink;
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.link.TeLink;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.link.TeLinkTpKey;
-import org.onosproject.tetopology.management.api.node.ConnectivityMatrix;
-import org.onosproject.tetopology.management.api.node.ConnectivityMatrixKey;
-import org.onosproject.tetopology.management.api.node.DefaultNetworkNode;
-import org.onosproject.tetopology.management.api.node.DefaultTeNode;
-import org.onosproject.tetopology.management.api.node.DefaultTerminationPoint;
-import org.onosproject.tetopology.management.api.node.NetworkNode;
-import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
-import org.onosproject.tetopology.management.api.node.NodeTpKey;
-import org.onosproject.tetopology.management.api.node.TeNode;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TerminationPoint;
-import org.onosproject.tetopology.management.api.node.TerminationPointKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.tetopology.management.api.node.TunnelTerminationPoint;
-import org.onosproject.tetopology.management.impl.InternalNetwork;
-import org.onosproject.tetopology.management.impl.InternalNetworkLink;
-import org.onosproject.tetopology.management.impl.InternalNetworkNode;
-import org.onosproject.tetopology.management.impl.InternalTeLink;
-import org.onosproject.tetopology.management.impl.InternalTeNode;
-import org.onosproject.tetopology.management.impl.InternalTeTopology;
-import org.onosproject.tetopology.management.impl.InternalTerminationPoint;
-import org.onosproject.tetopology.management.impl.TeMgrUtil;
-import org.onosproject.tetopology.management.impl.TeTopologyMapEvent;
-import org.onosproject.tetopology.management.impl.TeTopologyStore;
-import org.onosproject.tetopology.management.impl.TeTopologyStoreDelegate;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.slf4j.Logger;
-
-import java.util.BitSet;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.BlockingQueue;
-
-import static org.onosproject.tetopology.management.api.OptimizationType.NOT_OPTIMIZED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NETWORK_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NETWORK_REMOVED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_TOPOLOGY_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_TOPOLOGY_REMOVED;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Implementation of the TE network store.
- */
-@Component(immediate = true, service = TeTopologyStore.class)
-public class SimpleTeTopologyStore
- extends AbstractStore<TeTopologyEvent, TeTopologyStoreDelegate>
- implements TeTopologyStore {
- private static final String STORE_NAME = "TE_NETWORK_TOPOLOGY_STORE";
- private final Logger log = getLogger(getClass());
-
- // Track TE topologies by TE Topology key
- private Map<TeTopologyKey, InternalTeTopology> teTopologyMap = Maps
- .newConcurrentMap();
- // Track networks by network Id
- private Map<KeyId, InternalNetwork> networkMap = Maps.newConcurrentMap();
- // Track TE nodes by TE node key
- private Map<TeNodeKey, InternalTeNode> teNodeMap = Maps.newConcurrentMap();
- // Track ConnectivityMatrix by its key
- private Map<ConnectivityMatrixKey, ConnectivityMatrix> connMatrixMap = Maps
- .newConcurrentMap();
- // Track Tunnel Termination Points by its key
- private Map<TtpKey, TunnelTerminationPoint> ttpMap = Maps
- .newConcurrentMap();
- // Track network nodes by network node key
- private Map<NetworkNodeKey, InternalNetworkNode> networkNodeMap = Maps
- .newConcurrentMap();
- // Track TE links by its key
- private Map<TeLinkTpGlobalKey, InternalTeLink> teLinkMap = Maps
- .newConcurrentMap();
- // Track network links by network link key
- private Map<NetworkLinkKey, InternalNetworkLink> networkLinkMap = Maps
- .newConcurrentMap();
- // Track Termination points by termination point key
- private Map<TerminationPointKey, InternalTerminationPoint> tpMap = Maps
- .newConcurrentMap();
- // Track termination point keys by TE termination point Key
- private Map<TeLinkTpGlobalKey, TerminationPointKey> tpKeyMap = Maps
- .newConcurrentMap();
- private long providerId;
-
- @Activate
- public void activate() {
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- teTopologyMap.clear();
- networkMap.clear();
- teNodeMap.clear();
- connMatrixMap.clear();
- networkNodeMap.clear();
- teLinkMap.clear();
- networkLinkMap.clear();
- tpMap.clear();
- tpKeyMap.clear();
- ttpMap.clear();
- log.info("Stopped");
- }
-
- @Override
- public TeTopologies teTopologies() {
- Map<TeTopologyKey, TeTopology> teTopologies = Maps.newHashMap();
- if (MapUtils.isNotEmpty(teTopologyMap)) {
- for (TeTopologyKey key : teTopologyMap.keySet()) {
- teTopologies.put(key, teTopology(key));
- }
- }
- return new DefaultTeTopologies(STORE_NAME, teTopologies);
- }
-
- private TeTopology teTopology(TeTopologyKey topologyId,
- InternalTeTopology intTopology) {
- if (intTopology == null) {
- return null;
- }
- Map<Long, TeNode> teNodes = null;
- if (CollectionUtils.isNotEmpty(intTopology.teNodeKeys())) {
- teNodes = Maps.newHashMap();
- for (TeNodeKey key : intTopology.teNodeKeys()) {
- teNodes.put(key.teNodeId(), teNode(key));
- }
- }
- Map<TeLinkTpKey, TeLink> teLinks = null;
- if (CollectionUtils.isNotEmpty(intTopology.teLinkKeys())) {
- teLinks = Maps.newHashMap();
- for (TeLinkTpGlobalKey key : intTopology.teLinkKeys()) {
- teLinks.put(key.teLinkTpKey(), teLink(key));
- }
- }
- return new DefaultTeTopology(topologyId, teNodes, teLinks,
- intTopology.teTopologyId(),
- intTopology.topologyData());
- }
-
- @Override
- public TeTopology teTopology(TeTopologyKey topologyId) {
- InternalTeTopology intTopology = teTopologyMap.get(topologyId);
- return teTopology(topologyId, intTopology);
- }
-
- private void removeTopologyeMapEntrys(InternalTeTopology curTopology) {
- // Remove TE nodes
- if (CollectionUtils.isNotEmpty(curTopology.teNodeKeys())) {
- for (TeNodeKey key : curTopology.teNodeKeys()) {
- removeTeNode(key, true);
- }
- }
- // Remove TE Links
- if (CollectionUtils.isNotEmpty(curTopology.teLinkKeys())) {
- for (TeLinkTpGlobalKey key : curTopology.teLinkKeys()) {
- removeTeLink(key, true);
- }
- }
- }
-
- @Override
- public void updateTeTopology(TeTopology teTopology) {
- InternalTeTopology curTopology = teTopologyMap
- .get(teTopology.teTopologyId());
- if (curTopology != null) {
- // Existing topology update
- // Remove existing map entries first, which should be removed by
- // its own events
- removeTopologyeMapEntrys(curTopology);
- }
- // Update TE nodes
- List<NetworkNodeKey> nodeIds = null;
- if (MapUtils.isNotEmpty(teTopology.teNodes())) {
- nodeIds = Lists.newArrayList();
- for (Map.Entry<Long, TeNode> entry : teTopology.teNodes()
- .entrySet()) {
- TeNodeKey teNodeKey = new TeNodeKey(teTopology.teTopologyId(),
- entry.getKey());
- NetworkNodeKey nodeKey = TeMgrUtil.networkNodeKey(teNodeKey);
- updateTeNode(teNodeKey, entry.getValue(), true, true, nodeKey);
- nodeIds.add(nodeKey);
- }
- }
- // Update TE links
- List<NetworkLinkKey> linkIds = null;
- if (MapUtils.isNotEmpty(teTopology.teLinks())) {
- linkIds = Lists.newArrayList();
- for (Map.Entry<TeLinkTpKey, TeLink> entry : teTopology.teLinks()
- .entrySet()) {
- TeLinkTpGlobalKey teLinkKey = new TeLinkTpGlobalKey(teTopology
- .teTopologyId(), entry.getKey());
- NetworkLinkKey linkKey = TeMgrUtil.networkLinkKey(teLinkKey);
- updateTeLink(teLinkKey, entry.getValue(), true, true, linkKey);
- linkIds.add(linkKey);
- }
- }
- // Finally Update teTopologyMap
- InternalTeTopology newTopology = new InternalTeTopology(teTopology);
- teTopologyMap.put(teTopology.teTopologyId(), newTopology);
-
- if (curTopology == null) {
- // New topology, update networkMap
- InternalNetwork intNetwork = new InternalNetwork();
- intNetwork.setServerProvided(false);
- intNetwork.setTeTopologyKey(teTopology.teTopologyId());
- intNetwork.setNodeIds(nodeIds);
- intNetwork.setLinkIds(linkIds);
- networkMap.put(teTopology.networkId(), intNetwork);
- }
- }
-
- @Override
- public void removeTeTopology(TeTopologyKey topologyId) {
- // Remove it from teTopologyMap
- InternalTeTopology topology = teTopologyMap.remove(topologyId);
- if (topology != null) {
- removeTopologyeMapEntrys(topology);
- // Remove it from networkMap;
- networkMap.remove(topology.topologyData().networkId());
- }
- }
-
- @Override
- public List<Network> networks() {
- if (MapUtils.isEmpty(networkMap)) {
- return null;
- }
- List<Network> networks = Lists.newArrayList();
- for (KeyId networkId : networkMap.keySet()) {
- networks.add(network(networkId));
- }
- return networks;
- }
-
- private Network network(KeyId networkId, InternalNetwork curNetwork) {
- if (curNetwork == null) {
- return null;
- }
- List<KeyId> supportingNetworkIds = curNetwork.supportingNetworkIds();
- Map<KeyId, NetworkNode> nodes = null;
- if (CollectionUtils.isNotEmpty(curNetwork.nodeIds())) {
- nodes = Maps.newHashMap();
- for (NetworkNodeKey key : curNetwork.nodeIds()) {
- nodes.put(key.nodeId(), networkNode(key));
- }
- }
- Map<KeyId, NetworkLink> links = null;
- if (CollectionUtils.isNotEmpty(curNetwork.linkIds())) {
- links = Maps.newHashMap();
- for (NetworkLinkKey key : curNetwork.linkIds()) {
- links.put(key.linkId(), networkLink(key));
- }
- }
- TeTopologyId topologyId = null;
- DeviceId ownerId = null;
- OptimizationType opt = NOT_OPTIMIZED;
- if (curNetwork.teTopologyKey() != null
- && teTopology(curNetwork.teTopologyKey()) != null) {
- topologyId = new TeTopologyId(curNetwork.teTopologyKey()
- .providerId(), curNetwork.teTopologyKey().clientId(),
- teTopology(curNetwork.teTopologyKey())
- .teTopologyIdStringValue());
- ownerId = teTopology(curNetwork.teTopologyKey()).ownerId();
- opt = teTopologyMap.get(curNetwork.teTopologyKey()).topologyData()
- .optimization();
- }
- return new DefaultNetwork(networkId, supportingNetworkIds, nodes, links,
- topologyId, curNetwork.serverProvided(),
- ownerId, opt);
- }
-
- @Override
- public Network network(KeyId networkId) {
- InternalNetwork curNetwork = networkMap.get(networkId);
- return network(networkId, curNetwork);
- }
-
- private void removeNetworkMapEntrys(InternalNetwork curNetwork,
- boolean teRemove) {
- // Remove TE nodes
- if (CollectionUtils.isNotEmpty(curNetwork.nodeIds())) {
- for (NetworkNodeKey key : curNetwork.nodeIds()) {
- removeNetworkNode(key, teRemove);
- }
- }
- // Remove TE Links
- if (CollectionUtils.isNotEmpty(curNetwork.linkIds())) {
- for (NetworkLinkKey key : curNetwork.linkIds()) {
- removeNetworkLink(key, teRemove);
- }
- }
- }
-
- private TeTopologyKey newTeTopologyKey(TeTopologyId teTopologyId) {
- long idValue;
- try {
- idValue = Long.parseLong(teTopologyId.topologyId());
- } catch (NumberFormatException e) {
- // Can't get the long value from the string.
- // Use an assigned id value from local id pool,
- // Ideally id should be assigned per provider base.
- idValue = nextTeTopologyId();
- }
- return new TeTopologyKey(teTopologyId.providerId(),
- teTopologyId.clientId(), idValue);
- }
-
- @Override
- public void updateNetwork(Network network) {
- InternalNetwork curNetwork = networkMap.get(network.networkId());
- if (curNetwork != null) {
- // Existing topology update
- // Remove existing map entries first,
- removeNetworkMapEntrys(curNetwork, false);
- }
- TeTopologyKey topoKey = null;
- if (network.teTopologyId() != null) {
- topoKey = newTeTopologyKey(network.teTopologyId());
- }
- // Update TE nodes
- List<TeNodeKey> teNodeKeys = null;
- if (MapUtils.isNotEmpty(network.nodes())) {
- teNodeKeys = Lists.newArrayList();
- for (Map.Entry<KeyId, NetworkNode> entry : network.nodes()
- .entrySet()) {
- NetworkNodeKey nodeKey = new NetworkNodeKey(network.networkId(),
- entry.getKey());
- TeNodeKey teNodeKey = null;
- if (topoKey != null && entry.getValue().teNode() != null) {
- teNodeKey = new TeNodeKey(topoKey, entry.getValue().teNode()
- .teNodeId());
- }
- updateNetworkNode(nodeKey, entry.getValue(), true, false,
- teNodeKey);
- teNodeKeys.add(teNodeKey);
- }
- }
- // Update TE links
- List<TeLinkTpGlobalKey> teLinkKeys = null;
- if (MapUtils.isNotEmpty(network.links())) {
- teLinkKeys = Lists.newArrayList();
- for (Map.Entry<KeyId, NetworkLink> entry : network.links()
- .entrySet()) {
- NetworkLinkKey linkKey = new NetworkLinkKey(network.networkId(),
- entry.getKey());
- TeLinkTpGlobalKey teLinkKey = null;
- if (topoKey != null && entry.getValue().teLink() != null) {
- teLinkKey = new TeLinkTpGlobalKey(topoKey, entry.getValue()
- .teLink().teLinkKey());
- }
- updateNetworkLink(linkKey, entry.getValue(), true, false,
- teLinkKey);
- teLinkKeys.add(teLinkKey);
- }
- }
-
- // New network, update TE Topology first
- if (curNetwork == null) {
- InternalTeTopology intTopo = new InternalTeTopology(network
- .teTopologyId().topologyId());
- intTopo.setTeNodeKeys(teNodeKeys);
- intTopo.setTeLinkKeys(teLinkKeys);
- BitSet flags = new BitSet(TeConstants.FLAG_MAX_BITS);
- flags.set(TeTopology.BIT_LEARNT);
- if (network.teTopologyId().clientId() == providerId) {
- // Hard rule for now
- flags.set(TeTopology.BIT_CUSTOMIZED);
- }
- CommonTopologyData common = new CommonTopologyData(network.networkId(), NOT_OPTIMIZED,
- flags, network.ownerId());
- intTopo.setTopologydata(common);
- teTopologyMap.put(topoKey, intTopo);
- // Assume new topology
- TeTopologyEvent topologyEvent = new TeTopologyEvent(TE_TOPOLOGY_ADDED,
- teTopology(topoKey));
- notifyDelegate(topologyEvent);
- }
- // Finally Update networkMap
- InternalNetwork newNetwork = new InternalNetwork(network);
- newNetwork.setTeTopologyKey(topoKey);
- networkMap.put(network.networkId(), newNetwork);
- // Assume new network
- TeTopologyEvent topologyEvent = new TeTopologyEvent(NETWORK_ADDED,
- network(network.networkId()));
- notifyDelegate(topologyEvent);
- }
-
- @Override
- public void removeNetwork(KeyId networkId) {
- // Remove it from networkMap
- InternalNetwork network = networkMap.remove(networkId);
- TeTopologyEvent topologyEvent = new TeTopologyEvent(NETWORK_REMOVED,
- new DefaultNetwork(networkId,
- null,
- null,
- null,
- null,
- false,
- null,
- NOT_OPTIMIZED));
- notifyDelegate(topologyEvent);
- if (network != null && network.teTopologyKey() != null) {
- removeNetworkMapEntrys(network, false);
- teTopologyMap.remove(network.teTopologyKey());
- topologyEvent = new TeTopologyEvent(TE_TOPOLOGY_REMOVED,
- new DefaultTeTopology(network
- .teTopologyKey(), null, null, null, null));
- notifyDelegate(topologyEvent);
- }
- }
-
- private TeNode teNode(TeNodeKey nodeKey, InternalTeNode intNode) {
- if (intNode == null) {
- return null;
- }
- Map<Long, ConnectivityMatrix> connMatrices = null;
- if (CollectionUtils.isNotEmpty(intNode.connMatrixKeys())) {
- connMatrices = Maps.newHashMap();
- for (ConnectivityMatrixKey key : intNode.connMatrixKeys()) {
- connMatrices.put(key.entryId(), connMatrixMap.get(key));
- }
- }
- List<Long> teLinkIds = null;
- if (CollectionUtils.isNotEmpty(intNode.teLinkTpKeys())) {
- teLinkIds = Lists.newArrayList();
- for (TeLinkTpGlobalKey key : intNode.teLinkTpKeys()) {
- teLinkIds = TeUtils.addListElement(teLinkIds, key.teLinkTpId());
- }
- }
- List<Long> tps = null;
- if (CollectionUtils.isNotEmpty(intNode.teTpKeys())) {
- tps = Lists.newArrayList();
- for (TeLinkTpGlobalKey key : intNode.teTpKeys()) {
- tps = TeUtils.addListElement(tps, key.teLinkTpId());
- }
- }
- Map<Long, TunnelTerminationPoint> ttps = null;
- if (CollectionUtils.isNotEmpty(intNode.ttpKeys())) {
- ttps = Maps.newHashMap();
- for (TtpKey key : intNode.ttpKeys()) {
- ttps.put(key.ttpId(), ttpMap.get(key));
- }
- }
- return new DefaultTeNode(nodeKey.teNodeId(),
- intNode.underlayTopologyKey(),
- intNode.supportNodeKey(),
- intNode.sourceTeNodeKey(), intNode.teData(),
- connMatrices, teLinkIds, ttps, tps);
- }
-
- @Override
- public TeNode teNode(TeNodeKey nodeKey) {
- InternalTeNode intNode = teNodeMap.get(nodeKey);
- return teNode(nodeKey, intNode);
- }
-
- private void removeTeNodeMapEntrys(InternalTeNode intNode) {
- // Remove connMatrixMap entries for the node
- if (CollectionUtils.isNotEmpty(intNode.connMatrixKeys())) {
- for (ConnectivityMatrixKey key : intNode.connMatrixKeys()) {
- connMatrixMap.remove(key);
- }
- }
- // Remove ttpMap entries for the node
- if (CollectionUtils.isNotEmpty(intNode.ttpKeys())) {
- for (TtpKey key : intNode.ttpKeys()) {
- ttpMap.remove(key);
- }
- }
- }
-
- private void updateTeNode(TeNodeKey nodeKey, TeNode node,
- boolean parentUpdate, boolean teNodeUpdate,
- NetworkNodeKey networkNodeKey) {
- InternalTeTopology intTopo = teTopologyMap.get(nodeKey.teTopologyKey());
- if (intTopo == null && !parentUpdate) {
- log.error("TE Topology is not in dataStore for nodeUpdate {}",
- nodeKey);
- return;
- }
- InternalTeNode curNode = teNodeMap.get(nodeKey);
- // Update connMatrixMap
- if (MapUtils.isNotEmpty(node.connectivityMatrices())) {
- for (Map.Entry<Long, ConnectivityMatrix> entry : node
- .connectivityMatrices().entrySet()) {
- connMatrixMap
- .put(new ConnectivityMatrixKey(nodeKey, entry.getKey()),
- entry.getValue());
- }
- }
- // Update ttpMap
- if (MapUtils.isNotEmpty(node.tunnelTerminationPoints())) {
- for (Map.Entry<Long, TunnelTerminationPoint> entry : node
- .tunnelTerminationPoints().entrySet()) {
- ttpMap.put(new TtpKey(nodeKey, entry.getKey()),
- entry.getValue());
- }
- }
- // Update TE Termination Points
-
- // Update teNodeMap
- InternalTeNode intNode = new InternalTeNode(nodeKey, node,
- networkNodeKey,
- parentUpdate);
- teNodeMap.put(nodeKey, intNode);
- if (curNode == null && !parentUpdate && intTopo != null) {
- // Update InternalTeTopology
- intTopo.setChildUpdate(true);
- TeUtils.addListElement(intTopo.teNodeKeys(), nodeKey);
- }
- // Update networkNodeMap
- if (teNodeUpdate) {
- updateNetworkNode(networkNodeKey, networkNode(node), parentUpdate,
- teNodeUpdate, nodeKey);
- }
- }
-
- private NetworkNode networkNode(TeNode node) {
- KeyId nodeId = KeyId.keyId(Long.toString(node.teNodeId()));
- List<NetworkNodeKey> supportingNodeIds = null;
- if (node.supportingTeNodeId() != null) {
- supportingNodeIds = Lists.newArrayList();
- supportingNodeIds.add(new NetworkNodeKey(TeMgrUtil.toNetworkId((node
- .supportingTeNodeId().teTopologyKey())), KeyId.keyId(Long
- .toString(node.supportingTeNodeId().teNodeId()))));
- }
- Map<KeyId, TerminationPoint> tps = null;
- if (node.teTerminationPointIds() != null) {
- tps = Maps.newHashMap();
- for (Long teTpId : node.teTerminationPointIds()) {
- tps.put(KeyId.keyId(Long.toString(teTpId)),
- new DefaultTerminationPoint(KeyId
- .keyId(Long.toString(teTpId)), null, teTpId));
- }
- }
- return new DefaultNetworkNode(nodeId, supportingNodeIds, node, tps);
- }
-
- @Override
- public void updateTeNode(TeNodeKey nodeKey, TeNode node) {
- updateTeNode(nodeKey, node, false, true,
- TeMgrUtil.networkNodeKey(nodeKey));
- }
-
- private void removeTeNode(TeNodeKey nodeKey, boolean teNodeRemove) {
- // Remove it from InternalTeTopology first
- InternalTeTopology intTopo = teTopologyMap.get(nodeKey.teTopologyKey());
- if (intTopo != null
- && CollectionUtils.isNotEmpty(intTopo.teNodeKeys())) {
- intTopo.setChildUpdate(true);
- intTopo.teNodeKeys().remove(nodeKey);
- }
- // Then remove it from teNodeMap
- InternalTeNode node = teNodeMap.remove(nodeKey);
- removeTeNodeMapEntrys(node);
- // Remove it from networkNodeMap
- if (teNodeRemove && node != null) {
- removeNetworkNode(node.networkNodeKey(), teNodeRemove);
- }
- }
-
- @Override
- public void removeTeNode(TeNodeKey nodeKey) {
- removeTeNode(nodeKey, true);
- }
-
- private NetworkNode networkNode(NetworkNodeKey nodeKey,
- InternalNetworkNode intNode) {
- if (intNode == null) {
- return null;
- }
- Map<KeyId, TerminationPoint> tps = Maps.newHashMap();
- for (KeyId tpId : intNode.tpIds()) {
- tps.put(tpId,
- terminationPoint(new TerminationPointKey(nodeKey, tpId)));
-
- }
- return new DefaultNetworkNode(nodeKey.nodeId(),
- intNode.supportingNodeIds(),
- teNode(intNode.teNodeKey()), tps);
- }
-
- @Override
- public NetworkNode networkNode(NetworkNodeKey nodeKey) {
- InternalNetworkNode intNode = networkNodeMap.get(nodeKey);
- return networkNode(nodeKey, intNode);
- }
-
- private void updateNetworkNode(NetworkNodeKey nodeKey, NetworkNode node,
- boolean parentUpdate, boolean teNodeUpdate,
- TeNodeKey teNodeKey) {
- InternalNetwork intNework = null;
- if (!parentUpdate) {
- intNework = networkMap.get(nodeKey.networkId());
- if (intNework == null) {
- log.error("Network is not in dataStore for nodeUpdate {}",
- nodeKey);
- return;
- }
- }
-
- InternalNetworkNode exNode = networkNodeMap.get(nodeKey);
- if (exNode != null && CollectionUtils.isNotEmpty(exNode.tpIds())) {
- // Remove the TerminationPoints first
- for (KeyId tpId : exNode.tpIds()) {
- removeTerminationPoint(new TerminationPointKey(nodeKey, tpId));
- }
- }
-
- if (MapUtils.isNotEmpty(node.terminationPoints())) {
- // Update with new TerminationPoints
- for (Map.Entry<KeyId, TerminationPoint> entry : node
- .terminationPoints().entrySet()) {
- updateTerminationPoint(new TerminationPointKey(nodeKey,
- entry.getKey()),
- entry.getValue(), parentUpdate,
- teNodeKey);
- }
- }
-
- // Update teNodeMap first
- if (!teNodeUpdate && teNodeKey != null && node.teNode() != null) {
- updateTeNode(teNodeKey, node.teNode(), parentUpdate, teNodeUpdate,
- nodeKey);
- }
- // Update networkNodeMap
- InternalNetworkNode intNode = new InternalNetworkNode(node,
- parentUpdate);
- intNode.setTeNodeKey(teNodeKey);
- networkNodeMap.put(nodeKey, intNode);
- if (exNode == null && !parentUpdate && intNework != null) {
- // Update the InternalNetwork
- intNework.setChildUpdate(true);
- TeUtils.addListElement(intNework.nodeIds(), nodeKey);
- }
- }
-
- @Override
- public void updateNetworkNode(NetworkNodeKey nodeKey, NetworkNode node) {
- TeNodeKey teNodeKey = null;
- if (node.teNode() != null) {
- teNodeKey = new TeNodeKey(networkMap.get(nodeKey.networkId())
- .teTopologyKey(), node.teNode().teNodeId());
- }
- updateNetworkNode(nodeKey, node, false, false, teNodeKey);
- }
-
- private void removeNetworkNode(NetworkNodeKey nodeKey,
- boolean teNodeRemove) {
- // Update the InternalNetwork
- InternalNetwork intNework = networkMap.get(nodeKey.networkId());
- if (intNework != null
- && CollectionUtils.isNotEmpty(intNework.nodeIds())) {
- intNework.setChildUpdate(true);
- intNework.nodeIds().remove(nodeKey);
- }
- InternalNetworkNode intNode = networkNodeMap.remove(nodeKey);
- if (intNode != null && CollectionUtils.isNotEmpty(intNode.tpIds())) {
- // Remove the TerminationPoints first
- for (KeyId tpId : intNode.tpIds()) {
- removeTerminationPoint(new TerminationPointKey(nodeKey, tpId));
- }
- }
- if (!teNodeRemove && intNode != null) {
- // Now remove it from teNodeMap
- removeTeNode(intNode.teNodeKey(), teNodeRemove);
- }
- }
-
- @Override
- public void removeNetworkNode(NetworkNodeKey nodeKey) {
- removeNetworkNode(nodeKey, false);
- }
-
- private TeLink teLink(TeLinkTpGlobalKey linkKey, InternalTeLink intLink) {
- if (intLink == null) {
- return null;
- }
- return new DefaultTeLink(linkKey.teLinkTpKey(), intLink.peerTeLinkKey(),
- intLink.underlayTopologyKey(),
- intLink.supportingLinkKey(),
- intLink.sourceTeLinkKey(), intLink.teData());
- }
-
- @Override
- public TeLink teLink(TeLinkTpGlobalKey linkKey) {
- InternalTeLink intLink = teLinkMap.get(linkKey);
- return teLink(linkKey, intLink);
- }
-
- private void updateTeLink(TeLinkTpGlobalKey linkKey, TeLink link,
- boolean parentUpdate, boolean teLinkUpdate,
- NetworkLinkKey networkLinkKey) {
- InternalTeTopology intTopo = teTopologyMap.get(linkKey.teTopologyKey());
- if (intTopo == null && !parentUpdate) {
- log.error("TE Topology is not in dataStore for linkUpdate {}",
- linkKey);
- return;
- }
- InternalTeNode intNode = teNodeMap.get(linkKey.teNodeKey());
- if (intNode == null && !parentUpdate) {
- log.error("TE node is not in dataStore for linkUpdate {}", linkKey);
- return;
- }
- InternalTeLink exLink = teLinkMap.get(linkKey);
-
- // Update teLinkMap
- InternalTeLink intLink = new InternalTeLink(link, parentUpdate);
- intLink.setNetworkLinkKey(networkLinkKey);
- teLinkMap.put(linkKey, intLink);
- if (exLink == null && !parentUpdate) {
- if (intTopo != null) {
- // Update the InternalTeTopology
- intTopo.setChildUpdate(true);
- intTopo.setTeLinkKeys(TeUtils
- .addListElement(intTopo.teLinkKeys(), linkKey));
- }
- if (intNode != null) {
- // Update the InternalNode
- intNode.setChildUpdate(true);
- intNode.setTeLinkTpKeys(TeUtils
- .addListElement(intNode.teLinkTpKeys(), linkKey));
- }
- }
-
- // Update networkLinkMap
- if (teLinkUpdate) {
- updateNetworkLink(networkLinkKey, networkLink(link), parentUpdate,
- teLinkUpdate, linkKey);
- }
- }
-
- private NetworkLink networkLink(TeLink link) {
- KeyId linkId = TeMgrUtil.toNetworkLinkId(link.teLinkKey());
- NodeTpKey source = null;
- if (link.teLinkKey() != null) {
- source = new NodeTpKey(KeyId
- .keyId(Long.toString(link.teLinkKey().teNodeId())), KeyId
- .keyId(Long
- .toString(link.teLinkKey().teLinkTpId())));
- }
- NodeTpKey dest = null;
- if (link.peerTeLinkKey() != null) {
- dest = new NodeTpKey(KeyId
- .keyId(Long.toString(link.peerTeLinkKey().teNodeId())),
- KeyId.keyId(Long.toString(link.peerTeLinkKey()
- .teLinkTpId())));
- }
- List<NetworkLinkKey> supportingLinkIds = null;
- if (link.supportingTeLinkId() != null) {
- supportingLinkIds = Lists.newArrayList();
- supportingLinkIds.add(new NetworkLinkKey(TeMgrUtil.toNetworkId(link
- .supportingTeLinkId().teTopologyKey()), TeMgrUtil
- .toNetworkLinkId(link.supportingTeLinkId()
- .teLinkTpKey())));
- }
- return new DefaultNetworkLink(linkId, source, dest, supportingLinkIds,
- link);
- }
-
- @Override
- public void updateTeLink(TeLinkTpGlobalKey linkKey, TeLink link) {
- updateTeLink(linkKey, link, false, true,
- TeMgrUtil.networkLinkKey(linkKey));
- }
-
- private void removeTeLink(TeLinkTpGlobalKey linkKey, boolean teLinkRemove) {
- // Remove it from InternalTeTopology first
- InternalTeTopology intTopo = teTopologyMap.get(linkKey.teTopologyKey());
- if (intTopo != null
- && CollectionUtils.isNotEmpty(intTopo.teLinkKeys())) {
- intTopo.setChildUpdate(true);
- intTopo.teLinkKeys().remove(linkKey);
- }
- // Remove it from InternalTeNode
- InternalTeNode intNode = teNodeMap.get(linkKey.teNodeKey());
- if (intNode != null
- && CollectionUtils.isNotEmpty(intNode.teLinkTpKeys())) {
- intNode.setChildUpdate(true);
- intNode.teLinkTpKeys().remove(linkKey);
- }
- // Then remove it from teLinkMap
- InternalTeLink link = teLinkMap.remove(linkKey);
- if (teLinkRemove && link != null) {
- // Remove it from networkLinkMap
- removeNetworkLink(link.networkLinkKey(), teLinkRemove);
- }
- }
-
- @Override
- public void removeTeLink(TeLinkTpGlobalKey linkKey) {
- removeTeLink(linkKey, true);
- }
-
- private NetworkLink networkLink(NetworkLinkKey linkKey,
- InternalNetworkLink intLink) {
- if (intLink == null) {
- return null;
- }
- return new DefaultNetworkLink(linkKey.linkId(), intLink.source(),
- intLink.destination(),
- intLink.supportingLinkIds(),
- teLink(intLink.teLinkKey()));
- }
-
- @Override
- public NetworkLink networkLink(NetworkLinkKey linkKey) {
- InternalNetworkLink intLink = networkLinkMap.get(linkKey);
- return networkLink(linkKey, intLink);
- }
-
- private void updateNetworkLink(NetworkLinkKey linkKey, NetworkLink link,
- boolean parentUpdate, boolean teLinkUpdate,
- TeLinkTpGlobalKey teLinkKey) {
- InternalNetwork intNework = null;
- if (!parentUpdate) {
- intNework = networkMap.get(linkKey.networkId());
- if (intNework == null) {
- log.error("Network is not in dataStore for linkUpdate {}",
- linkKey);
- return;
- }
- }
-
- InternalNetworkLink exLink = networkLinkMap.get(linkKey);
-
- // Now update teLinkMap first
- if (!teLinkUpdate && teLinkKey != null) {
- updateTeLink(teLinkKey, link.teLink(), parentUpdate, teLinkUpdate,
- linkKey);
- }
- // Update networkLinkMap
- InternalNetworkLink intLink = new InternalNetworkLink(link,
- parentUpdate);
- intLink.setTeLinkKey(teLinkKey);
- networkLinkMap.put(linkKey, intLink);
- if (exLink == null && !parentUpdate && intNework != null) {
- // Update the InternalNetwork
- intNework.setChildUpdate(true);
- TeUtils.addListElement(intNework.linkIds(), linkKey);
- }
- }
-
- @Override
- public void updateNetworkLink(NetworkLinkKey linkKey, NetworkLink link) {
- TeLinkTpGlobalKey teLinkKey = null;
- if (link.teLink() != null) {
- teLinkKey = new TeLinkTpGlobalKey(networkMap
- .get(linkKey.networkId()).teTopologyKey(),
- link.teLink().teLinkKey());
- }
-
- updateNetworkLink(linkKey, link, false, false, teLinkKey);
- }
-
- private void removeNetworkLink(NetworkLinkKey linkKey,
- boolean teLinkRemove) {
- // Update the InternalNetwork
- InternalNetwork intNework = networkMap.get(linkKey.networkId());
- if (intNework != null
- && CollectionUtils.isNotEmpty(intNework.linkIds())) {
- intNework.setChildUpdate(true);
- intNework.linkIds().remove(linkKey);
- }
- // Remove it from networkLinkMap
- InternalNetworkLink intLink = networkLinkMap.remove(linkKey);
- if (!teLinkRemove && intLink != null && intLink.teLinkKey() != null) {
- // Now remove it from teLinkMap
- removeTeLink(intLink.teLinkKey(), teLinkRemove);
- }
- }
-
- @Override
- public void removeNetworkLink(NetworkLinkKey linkKey) {
- removeNetworkLink(linkKey, false);
- }
-
- private TerminationPoint terminationPoint(TerminationPointKey tpKey) {
- InternalTerminationPoint intTp = tpMap.get(tpKey);
- if (intTp == null) {
- return null;
- }
- return new DefaultTerminationPoint(tpKey.tpId(),
- intTp.supportingTpIds(),
- intTp.teTpKey().teLinkTpId());
- }
-
- private void updateTerminationPoint(TerminationPointKey tpKey,
- TerminationPoint tp,
- boolean parentUpdate,
- TeNodeKey teNodeKey) {
- TeNodeKey myTeNodeKey;
- InternalNetworkNode intNode = null;
- if (!parentUpdate) {
- intNode = networkNodeMap.get(tpKey);
- if (intNode == null) {
- log.error(" node is not in dataStore for tp update {}", tpKey);
- return;
- }
- myTeNodeKey = intNode.teNodeKey();
- } else {
- myTeNodeKey = teNodeKey;
- }
- TeLinkTpGlobalKey teTpKey = new TeLinkTpGlobalKey(myTeNodeKey,
- tp.teTpId());
-
- boolean newTp = tpMap.get(tpKey) == null;
- InternalTerminationPoint intTp = new InternalTerminationPoint(tp);
- intTp.setTeTpKey(teTpKey);
- tpMap.put(tpKey, intTp);
- if (newTp) {
- // Update tpKeyMap
- tpKeyMap.put(teTpKey, tpKey);
- if (!parentUpdate && intNode != null) {
- // Update InternalNetworkNode
- intNode.setChildUpdate(true);
- intNode.setTpIds(TeUtils.addListElement(intNode.tpIds(),
- tpKey.tpId()));
- }
- }
- }
-
- @Override
- public void updateTerminationPoint(TerminationPointKey tpKey,
- TerminationPoint tp) {
- updateTerminationPoint(tpKey, tp, false, null);
- }
-
- @Override
- public void removeTerminationPoint(TerminationPointKey tpKey) {
- // Update InternalNetworkNode
- InternalNetworkNode intNode = networkNodeMap.get(tpKey);
- if (intNode != null && CollectionUtils.isNotEmpty(intNode.tpIds())) {
- intNode.setChildUpdate(true);
- intNode.tpIds().remove(tpKey.tpId());
- }
- // Remove it from tpMap
- InternalTerminationPoint tp = tpMap.remove(tpKey);
- // Remove it from tpKeyMap
- if (tp != null) {
- tpKeyMap.remove(tp.teTpKey());
- }
- }
-
- @Override
- public TunnelTerminationPoint tunnelTerminationPoint(TtpKey ttpId) {
- return ttpMap.get(ttpId);
- }
-
- @Override
- public long nextTeTopologyId() {
- return 0;
- }
-
- @Override
- public long nextTeNodeId(TeTopologyKey topoKey) {
- return teTopologyMap.get(topoKey).nextTeNodeId();
- }
-
- @Override
- public void setNextTeNodeId(TeTopologyKey topoKey, long nextNodeId) {
- teTopologyMap.get(topoKey).setNextTeNodeId(nextNodeId);
- }
-
- @Override
- public KeyId networkId(TeTopologyKey teTopologyKey) {
- return teTopologyMap.get(teTopologyKey).topologyData().networkId();
- }
-
- @Override
- public NetworkNodeKey nodeKey(TeNodeKey teNodeKey) {
- return teNodeMap.get(teNodeKey).networkNodeKey();
- }
-
- @Override
- public NetworkLinkKey linkKey(TeLinkTpGlobalKey teLinkKey) {
- return teLinkMap.get(teLinkKey).networkLinkKey();
- }
-
- @Override
- public TerminationPointKey terminationPointKey(TeLinkTpGlobalKey teTpKey) {
- return tpKeyMap.get(teTpKey);
- }
-
- @Override
- public void setProviderId(long providerId) {
- this.providerId = providerId;
- }
-
- @Override
- public BlockingQueue<TeTopologyMapEvent> mapEventQueue() {
- return null;
- }
-}
-
diff --git a/apps/tetopology/app/src/test/java/org/onosproject/tetopology/management/TeTopologyManagerTest.java b/apps/tetopology/app/src/test/java/org/onosproject/tetopology/management/TeTopologyManagerTest.java
deleted file mode 100644
index 770b2c9..0000000
--- a/apps/tetopology/app/src/test/java/org/onosproject/tetopology/management/TeTopologyManagerTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.tetopology.management;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.onosproject.net.NetTestTools.injectEventDispatcher;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NETWORK_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.NETWORK_REMOVED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_TOPOLOGY_ADDED;
-import static org.onosproject.tetopology.management.api.TeTopologyEvent.Type.TE_TOPOLOGY_REMOVED;
-
-import java.util.List;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.common.event.impl.TestEventDispatcher;
-import org.onosproject.event.Event;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.tetopology.management.api.Network;
-import org.onosproject.tetopology.management.api.TeTopology;
-import org.onosproject.tetopology.management.api.TeTopologyEvent;
-import org.onosproject.tetopology.management.api.TeTopologyListener;
-import org.onosproject.tetopology.management.api.TeTopologyProvider;
-import org.onosproject.tetopology.management.api.TeTopologyProviderRegistry;
-import org.onosproject.tetopology.management.api.TeTopologyProviderService;
-import org.onosproject.tetopology.management.api.TeTopologyService;
-import org.onosproject.tetopology.management.api.link.TeLink;
-import org.onosproject.tetopology.management.api.link.TeLinkTpGlobalKey;
-import org.onosproject.tetopology.management.api.node.TeNode;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.impl.TeMgrUtil;
-import org.onosproject.tetopology.management.impl.TeTopologyManager;
-
-import com.google.common.collect.Lists;
-
-/**
- * Test TeTopology service and TeTopologyProvider service.
- */
-public class TeTopologyManagerTest {
- private static final ProviderId PID = new ProviderId("test", "TeTopologyManagerTest");
-
- private TeTopologyManager mgr;
- protected TeTopologyService service;
- protected TeTopologyProviderRegistry registry;
- protected TeTopologyProviderService providerService;
- protected TestProvider provider;
- protected TestListener listener = new TestListener();
-
- @Before
- public void setUp() {
- mgr = new TeTopologyManager();
- service = mgr;
- registry = mgr;
- mgr.store = new SimpleTeTopologyStore();
-
- injectEventDispatcher(mgr, new TestEventDispatcher());
-
- mgr.activateBasics();
- service.addListener(listener);
-
- provider = new TestProvider();
- providerService = registry.register(provider);
- assertTrue("providerService should not be null", providerService != null);
- assertTrue("Provider should be registered",
- registry.getProviders().contains(provider.id()));
- }
-
- @After
- public void tearDown() {
- registry.unregister(provider);
- assertFalse("provider should not be registered",
- registry.getProviders().contains(provider.id()));
- service.removeListener(listener);
- mgr.deactivateBasics();
- }
-
- private void createNetwork() {
- Network originNetwork = DefaultBuilder.buildSampleAbstractNetwork();
- providerService.networkUpdated(originNetwork);
- Network network = service
- .network(TeMgrUtil.toNetworkId(DefaultBuilder.teTopologyKey()));
- assertNotNull("Network should be found", network);
- }
-
- /**
- * Checks the right events are received when a network with TE topology is
- * added.
- */
- @Test
- public void networkAdded() {
- createNetwork();
- validateEvents(TE_TOPOLOGY_ADDED, NETWORK_ADDED);
- }
-
- /**
- * Checks the TE topology components are set properly in Manager and Store
- * when a network is added.
- */
- @Test
- public void teTopologyVerify() {
- createNetwork();
- TeTopology teTopology = service
- .teTopology(DefaultBuilder.teTopologyKey());
- assertNotNull("TeTopology should be found", teTopology);
- assertTrue("Number of TE nodes should be 1",
- teTopology.teNodes().size() == 1);
- assertTrue("Number of TE links should be 1",
- teTopology.teLinks().size() == 1);
- TeNode teNode = service
- .teNode(new TeNodeKey(DefaultBuilder.teTopologyKey(),
- DefaultBuilder.teNode().teNodeId()));
- assertNotNull("TeNode should be found", teNode);
- assertTrue("TE node should be identical", teNode.equals(DefaultBuilder.teNode()));
- assertTrue("Number of TTPs should be 1",
- teNode.tunnelTerminationPoints().size() == 1);
- TeLink teLink = service
- .teLink(new TeLinkTpGlobalKey(DefaultBuilder
- .teTopologyKey(), DefaultBuilder.teLink().teLinkKey()));
- assertNotNull("TeLink should be found", teLink);
- }
-
- /**
- * Checks the right events are received when a network with TE topology is
- * added and then removed.
- */
- @Test
- public void networkRemoved() {
- createNetwork();
- providerService.networkRemoved(TeMgrUtil
- .toNetworkId(DefaultBuilder.teTopologyKey()));
- validateEvents(TE_TOPOLOGY_ADDED, NETWORK_ADDED, NETWORK_REMOVED,
- TE_TOPOLOGY_REMOVED);
- }
-
- /**
- * Validates whether the manager receives the right events.
- *
- * @param types a set of types of control message event
- */
- protected void validateEvents(Enum... types) {
- int i = 0;
- assertEquals("wrong events received", types.length, listener.events.size());
- for (Event event : listener.events) {
- assertEquals("incorrect event type", types[i], event.type());
- i++;
- }
- listener.events.clear();
- }
-
- private class TestProvider extends AbstractProvider implements TeTopologyProvider {
- protected TestProvider() {
- super(PID);
- }
- }
-
- private static class TestListener implements TeTopologyListener {
- final List<TeTopologyEvent> events = Lists.newArrayList();
-
- @Override
- public void event(TeTopologyEvent event) {
- events.add(event);
- }
- }
-
-}
diff --git a/apps/tetopology/app/src/test/java/org/onosproject/tetopology/management/package-info.java b/apps/tetopology/app/src/test/java/org/onosproject/tetopology/management/package-info.java
deleted file mode 100644
index a9bb817..0000000
--- a/apps/tetopology/app/src/test/java/org/onosproject/tetopology/management/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * The TE topology implementation test functions.
- */
-package org.onosproject.tetopology.management;
diff --git a/apps/tetunnel/BUILD b/apps/tetunnel/BUILD
deleted file mode 100644
index 9467b00..0000000
--- a/apps/tetunnel/BUILD
+++ /dev/null
@@ -1,15 +0,0 @@
-BUNDLES = [
- "//apps/tunnel/api:onos-apps-tunnel-api",
- "//apps/tetunnel/api:onos-apps-tetunnel-api",
- "//apps/tetunnel/app:onos-apps-tetunnel-app",
-]
-
-onos_app(
- app_name = "org.onosproject.tetunnel",
- category = "Traffic Engineering",
- description = "Application to create and manage TE tunnels.",
- included_bundles = BUNDLES,
- required_apps = ["org.onosproject.tetopology"],
- title = "TE Tunnel Core",
- url = "http://onosproject.org",
-)
diff --git a/apps/tetunnel/api/BUILD b/apps/tetunnel/api/BUILD
deleted file mode 100644
index 0d45477..0000000
--- a/apps/tetunnel/api/BUILD
+++ /dev/null
@@ -1,8 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + [
- "//apps/tunnel/api:onos-apps-tunnel-api",
- "//apps/tetopology/api:onos-apps-tetopology-api",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/TeTunnelAdminService.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/TeTunnelAdminService.java
deleted file mode 100644
index d99d988..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/TeTunnelAdminService.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api;
-
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.tetunnel.api.tunnel.TeTunnel;
-import org.onosproject.tetunnel.api.tunnel.TeTunnelKey;
-
-import java.util.List;
-
-/**
- * Service for administering the TE Tunnel attributes.
- * <p>
- * Please note that this service works with the existing Tunnel subsystem
- * together, just as an extension to the tunnel subsystem, and only focuses
- * on TE Tunnel attributes management.
- */
-public interface TeTunnelAdminService extends TeTunnelService {
-
- /**
- * Creates a TE Tunnel with the supplied attributes, and returns an
- * identifier for the tunnel on success, or null on failure.
- *
- * @param teTunnel TE Tunnel attributes
- * @return created tunnel identifier or null if failed
- */
- TunnelId createTeTunnel(TeTunnel teTunnel);
-
- /**
- * Sets the corresponding Tunnel identifier of the TE Tunnel specified
- * by the given key.
- *
- * @param teTunnelKey TE Tunnel key
- * @param tunnelId corresponding tunnel identifier
- */
- void setTunnelId(TeTunnelKey teTunnelKey, TunnelId tunnelId);
-
- /**
- * Updates TE Tunnel attributes with supplied information, the old
- * attributes will be totally overwrote by the new attributes.
- *
- * @param teTunnel new TE Tunnel attributes
- */
- void updateTeTunnel(TeTunnel teTunnel);
-
- /**
- * Updates state of a TE tunnel specified by the given key.
- *
- * @param key TE tunnel key
- * @param state new state of the tunnel
- */
- void updateTunnelState(TeTunnelKey key, Tunnel.State state);
-
- /**
- * Removes a TE Tunnel specified by the given key.
- *
- * @param teTunnelKey TE Tunnel key
- */
- void removeTeTunnel(TeTunnelKey teTunnelKey);
-
- /**
- * Sets segment tunnels of a E2E cross-domain tunnel.
- *
- * @param e2eTunnelKey key of the E2E tunnel
- * @param segmentTunnels list of segment tunnels
- */
- void setSegmentTunnel(TeTunnelKey e2eTunnelKey,
- List<TeTunnelKey> segmentTunnels);
-
- //TODO: add interfaces for teGlobal and teLspState
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/TeTunnelProviderService.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/TeTunnelProviderService.java
deleted file mode 100644
index f1038e9..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/TeTunnelProviderService.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api;
-
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.tetunnel.api.lsp.TeLsp;
-import org.onosproject.tetunnel.api.lsp.TeLspKey;
-import org.onosproject.tetunnel.api.tunnel.TeTunnel;
-import org.onosproject.tetunnel.api.tunnel.TeTunnelKey;
-
-/**
- * Service through which tunnel providers can inject TE Tunnel attributes
- * into the system.
- * <p>
- * Please note that this service works with the existing Tunnel subsystem
- * together, just as an extension to the tunnel subsystem, and only focus on TE
- * Tunnel attributes management.
- */
-public interface TeTunnelProviderService {
-
- /**
- * Signals that a TE Tunnel is created with supplied attributes.
- *
- * @param teTunnel new created TE Tunnel attributes
- * @return created tunnel identifier or null if failed
- */
- TunnelId teTunnelAdded(TeTunnel teTunnel);
-
- /**
- * Signals that a TE Tunnel with specified attributes is removed.
- *
- * @param teTunnel removed TE Tunnel
- */
- void teTunnelRemoved(TeTunnel teTunnel);
-
- /**
- * Updates TE Tunnel attributes with supplied information, the old
- * attributes will be totally overwrote by the new attributes.
- *
- * @param teTunnel new TE Tunnel attributes
- */
- void updateTeTunnel(TeTunnel teTunnel);
-
- /**
- * Updates state of a TE tunnel specified by the given key.
- *
- * @param key TE tunnel key
- * @param state new state of the tunnel
- */
- void updateTunnelState(TeTunnelKey key, Tunnel.State state);
-
- /**
- * Signifies that a TE LSP is created.
- *
- * @param lsp new created TE LSP attributes
- * @return key of the TE LSP or null if failed
- */
- TeLspKey teLspAdded(TeLsp lsp);
-
- /**
- * Signifies that a TE LSP is removed.
- *
- * @param lsp removed TE LSP
- */
- void teLspRemoved(TeLsp lsp);
-
- /**
- * Updates TE LSP attributes.
- *
- * @param lsp new TE LSP attributes
- */
- void updateTeLsp(TeLsp lsp);
-
- //TODO: add interfaces for teGlobal and teLspState
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/TeTunnelService.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/TeTunnelService.java
deleted file mode 100644
index b610621..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/TeTunnelService.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api;
-
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetunnel.api.lsp.TeLsp;
-import org.onosproject.tetunnel.api.lsp.TeLspKey;
-import org.onosproject.tetunnel.api.tunnel.TeTunnel;
-import org.onosproject.tetunnel.api.tunnel.TeTunnelKey;
-
-import java.util.Collection;
-
-/**
- * Service for TE Tunnel attributes management.
- * <p>
- * Please note that this service works with the existing Tunnel subsystem
- * together, just as an extension to the tunnel subsystem, and only focus on TE
- * Tunnel attributes management.
- */
-public interface TeTunnelService {
-
- /**
- * Returns the TE Tunnel with the specified key.
- *
- * @param teTunnelKey TE Tunnel key
- * @return TeTunnel or null if one with the given key is not known
- */
- TeTunnel getTeTunnel(TeTunnelKey teTunnelKey);
-
- /**
- * Returns the TE Tunnel with the specified identifier.
- *
- * @param tunnelId corresponding tunnel identifier
- * @return TeTunnel or null if one with the given identifier is not known
- */
- TeTunnel getTeTunnel(TunnelId tunnelId);
-
- /**
- * Returns the corresponding tunnel identifier of a TE tunnel with the
- * specified key.
- *
- * @param teTunnelKey TE Tunnel key
- * @return corresponding tunnel identifier or null if one with the given
- * key is not known
- */
- TunnelId getTunnelId(TeTunnelKey teTunnelKey);
-
- /**
- * Returns a collection of currently known TE tunnels.
- *
- * @return collection of TE tunnels
- */
- Collection<TeTunnel> getTeTunnels();
-
- /**
- * Returns a collection of currently known TE Tunnels filtered by the
- * specified TE tunnel type.
- *
- * @param type TE tunnel type to filter by
- * @return filtered collection of TE tunnels
- */
- Collection<TeTunnel> getTeTunnels(TeTunnel.Type type);
-
- /**
- * Returns a collection of currently known TE tunnels filtered by specified
- * TE topology key.
- *
- * @param teTopologyKey TE topology key to filter by
- * @return filtered collection of TE tunnels
- */
- Collection<TeTunnel> getTeTunnels(TeTopologyKey teTopologyKey);
-
- /**
- * Returns the TE LSP with the specified key.
- *
- * @param key TE LSP key
- * @return TeLsp or null if one with the given key is not known
- */
- TeLsp getTeLsp(TeLspKey key);
-
- /**
- * Returns a collection of currently known TE LSPs.
- *
- * @return collection of TeLsp
- */
- Collection<TeLsp> getTeLsps();
-
- //TODO: add interfaces for teGlobal and teLspState
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/TeTunnelStore.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/TeTunnelStore.java
deleted file mode 100644
index 13d834e..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/TeTunnelStore.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api;
-
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetunnel.api.lsp.TeLsp;
-import org.onosproject.tetunnel.api.lsp.TeLspKey;
-import org.onosproject.tetunnel.api.tunnel.TeTunnel;
-import org.onosproject.tetunnel.api.tunnel.TeTunnelKey;
-
-import java.util.Collection;
-
-/**
- * Manages TE tunnel attributes.
- * <p>
- * Please note that this service works with the existing Tunnel subsystem
- * together, just as an extension to the tunnel subsystem, and only focus on TE
- * Tunnel attributes management.
- */
-public interface TeTunnelStore {
-
- /**
- * Creates a TE Tunnel with the supplied attributes, and returns true on
- * success, or false on failure.
- *
- * @param teTunnel TE Tunnel attributes
- * @return true on success, or false on failure
- */
- boolean addTeTunnel(TeTunnel teTunnel);
-
- /**
- * Sets the corresponding Tunnel identifier of the TE Tunnel specified
- * by the given key.
- *
- * @param teTunnelKey TE Tunnel key
- * @param tunnelId corresponding tunnel identifier
- */
- void setTunnelId(TeTunnelKey teTunnelKey, TunnelId tunnelId);
-
- /**
- * Returns the corresponding Tunnel identifier of the TE tunnel.
- *
- * @param teTunnelKey TE Tunnel key
- * @return corresponding Tunnel identifier
- */
- TunnelId getTunnelId(TeTunnelKey teTunnelKey);
-
- /**
- * Updates TE Tunnel attributes with supplied information, the old
- * attributes will be totally overwrote by the new attributes.
- *
- * @param teTunnel new TE Tunnel attributes
- */
- void updateTeTunnel(TeTunnel teTunnel);
-
- /**
- * Removes a TE Tunnel specified by the given key.
- *
- * @param teTunnelKey TE Tunnel key
- */
- void removeTeTunnel(TeTunnelKey teTunnelKey);
-
- /**
- * Returns the TE Tunnel with the specified key.
- *
- * @param teTunnelKey TE Tunnel key
- * @return TeTunnel or null if one with the given key is not known
- */
- TeTunnel getTeTunnel(TeTunnelKey teTunnelKey);
-
- /**
- * Returns the TE Tunnel with the specified identifier.
- *
- * @param tunnelId corresponding tunnel identifier
- * @return TeTunnel or null if one with the given identifier is not known
- */
- TeTunnel getTeTunnel(TunnelId tunnelId);
-
-
- /**
- * Returns a collection of currently known TE Tunnels.
- *
- * @return collection of TeTunnels
- */
- Collection<TeTunnel> getTeTunnels();
-
- /**
- * Returns a collection of currently known TE Tunnels filtered by the
- * specified TE tunnel type.
- *
- * @param type TE tunnel type to filter by
- * @return filtered collection of TE tunnels
- */
- Collection<TeTunnel> getTeTunnels(TeTunnel.Type type);
-
- /**
- * Returns a collection of currently known TE tunnels filtered by specified
- * TE topology key.
- *
- * @param teTopologyKey TE topology key to filter by
- * @return filtered collection of TE tunnels
- */
- Collection<TeTunnel> getTeTunnels(TeTopologyKey teTopologyKey);
-
- /**
- * Adds a TE LSP.
- *
- * @param lsp TE LSP attributes
- * @return true when success
- */
- boolean addTeLsp(TeLsp lsp);
-
- /**
- * Updates TE LSP attributes.
- *
- * @param lsp new TE LSP attributes
- */
- void updateTeLsp(TeLsp lsp);
-
- /**
- * Removes a TE LSP.
- *
- * @param key TE LSP key
- */
- void removeTeLsp(TeLspKey key);
-
- /**
- * Returns the TE LSP with the specified key.
- *
- * @param key TE LSP key
- * @return TeLsp or null if one with the given key is not known
- */
- TeLsp getTeLsp(TeLspKey key);
-
- /**
- * Returns a collection of currently known TE LSP.
- *
- * @return collection of TeLsp
- */
- Collection<TeLsp> getTeLsps();
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/lsp/DefaultTeLsp.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/lsp/DefaultTeLsp.java
deleted file mode 100644
index 2f75900..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/lsp/DefaultTeLsp.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.lsp;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.tetunnel.api.tunnel.TeTunnel;
-import org.onosproject.tetunnel.api.tunnel.TeTunnelKey;
-import org.onosproject.tetunnel.api.tunnel.path.TeRouteSubobject;
-
-import java.util.List;
-
-/**
- * Default implementation of TE LSP.
- */
-public class DefaultTeLsp implements TeLsp {
-
- private final TeLspKey teLspKey;
- private final TeNodeKey srcNode;
- private final TeNodeKey dstNode;
- private final TtpKey srcTp;
- private final TtpKey dstTp;
- private final TeTunnelKey teTunnelKey;
- private final TeTunnel.Type tunnelType;
- private final TeTunnel.State operStatus;
- private final LspProtectionRole lspProtectionRole;
- private final OriginType originType;
- private final List<TeRouteSubobject> lspRecordRoutes;
-
- /**
- * Creates an instance of default TE LSP with supplied information.
- *
- * @param teLspKey TE LSP key
- * @param srcNode source TE node key
- * @param dstNode destination TE node key
- * @param srcTp source TE termination point key
- * @param dstTp destination TE termination point key
- * @param teTunnelKey TE tunnel key
- * @param tunnelType TE tunnel type
- * @param operStatus operational status
- * @param lspProtectionRole protection type
- * @param originType origin type
- * @param lspRecordRoutes route of the LSP
- */
- protected DefaultTeLsp(TeLspKey teLspKey, TeNodeKey srcNode, TeNodeKey dstNode,
- TtpKey srcTp, TtpKey dstTp, TeTunnelKey teTunnelKey,
- TeTunnel.Type tunnelType, TeTunnel.State operStatus,
- LspProtectionRole lspProtectionRole,
- OriginType originType,
- List<TeRouteSubobject> lspRecordRoutes) {
- this.srcNode = srcNode;
- this.dstNode = dstNode;
- this.srcTp = srcTp;
- this.dstTp = dstTp;
- this.teTunnelKey = teTunnelKey;
- this.tunnelType = tunnelType;
- this.operStatus = operStatus;
- this.lspProtectionRole = lspProtectionRole;
- this.originType = originType;
- this.lspRecordRoutes = Lists.newArrayList(lspRecordRoutes);
- this.teLspKey = teLspKey;
- }
-
- @Override
- public TeLspKey teLspKey() {
- return teLspKey;
- }
-
- @Override
- public TeNodeKey srcNode() {
- return srcNode;
- }
-
- @Override
- public TeNodeKey dstNode() {
- return dstNode;
- }
-
- @Override
- public TtpKey srcTp() {
- return srcTp;
- }
-
- @Override
- public TtpKey dstTp() {
- return dstTp;
- }
-
- @Override
- public TeTunnelKey teTunnelKey() {
- return teTunnelKey;
- }
-
- @Override
- public TeTunnel.Type tunnelType() {
- return tunnelType;
- }
-
- @Override
- public TeTunnel.State operStatus() {
- return operStatus;
- }
-
- @Override
- public LspProtectionRole lspProtectionRole() {
- return lspProtectionRole;
- }
-
- @Override
- public OriginType originType() {
- return originType;
- }
-
- @Override
- public List<TeRouteSubobject> lspRecordRoutes() {
- return ImmutableList.copyOf(lspRecordRoutes);
- }
-
-
- /**
- * Creates a new default TE LSP builder.
- *
- * @return default builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder for default TE LSP objects.
- */
- public static class Builder {
-
- private TeLspKey teLspKey = null;
- private TeNodeKey srcNode = null;
- private TeNodeKey dstNode = null;
- private TtpKey srcTp = null;
- private TtpKey dstTp = null;
- private TeTunnelKey teTunnelKey = null;
- private TeTunnel.Type tunnelType = null;
- private TeTunnel.State operStatus = null;
- private LspProtectionRole lspProtectionRole = null;
- private OriginType originType = null;
- private List<TeRouteSubobject> lspRecordRoutes = Lists.newArrayList();
-
- /**
- * Builds a default TE LSP object from the accumulated parameters.
- *
- * @return default TE LSP object
- */
- public DefaultTeLsp build() {
- return new DefaultTeLsp(teLspKey, srcNode, dstNode, srcTp, dstTp,
- teTunnelKey, tunnelType, operStatus,
- lspProtectionRole, originType,
- lspRecordRoutes);
- }
-
- /**
- * Sets TE LSP key to be used by this builder.
- *
- * @param teLspKey TE LSP key
- * @return self
- */
- public Builder teLspKey(TeLspKey teLspKey) {
- this.teLspKey = teLspKey;
- return this;
- }
-
- /**
- * Sets source node key to be used by this builder.
- *
- * @param srcNode source node key
- * @return self
- */
- public Builder srcNode(TeNodeKey srcNode) {
- this.srcNode = srcNode;
- return this;
- }
-
- /**
- * Sets destination node key to be used by this builder.
- *
- * @param dstNode destination node key
- * @return self
- */
- public Builder dstNode(TeNodeKey dstNode) {
- this.dstNode = dstNode;
- return this;
- }
-
- /**
- * Sets source termination point key to be used by this builder.
- *
- * @param srcTp source termination point key
- * @return self
- */
- public Builder srcTp(TtpKey srcTp) {
- this.srcTp = srcTp;
- return this;
- }
-
- /**
- * Sets destination termination point key to be used by this builder.
- *
- * @param dstTp destination termination point key
- * @return self
- */
- public Builder dstTp(TtpKey dstTp) {
- this.dstTp = dstTp;
- return this;
- }
-
- /**
- * Sets TE tunnel key to be used by this builder.
- *
- * @param teTunnelKey TE tunnel key
- * @return self
- */
- public Builder teTunnelKey(TeTunnelKey teTunnelKey) {
- this.teTunnelKey = teTunnelKey;
- return this;
- }
-
- /**
- * Sets TE tunnel type to be used by this builder.
- *
- * @param tunnelType TE tunnel type
- * @return self
- */
- public Builder tunnelType(TeTunnel.Type tunnelType) {
- this.tunnelType = tunnelType;
- return this;
- }
-
- /**
- * Sets LSP operational status to be used by this builder.
- *
- * @param operStatus LSP operational status
- * @return self
- */
- public Builder operStatus(TeTunnel.State operStatus) {
- this.operStatus = operStatus;
- return this;
- }
-
- /**
- * Sets LSP protection role to be used by this builder.
- *
- * @param lspProtectionRole LSP protection role
- * @return self
- */
- public Builder lspProtectionRole(LspProtectionRole lspProtectionRole) {
- this.lspProtectionRole = lspProtectionRole;
- return this;
- }
-
- /**
- * Sets LSP origin type to be used by this builder.
- *
- * @param originType LSP origin type
- * @return self
- */
- public Builder originType(OriginType originType) {
- this.originType = originType;
- return this;
- }
-
- /**
- * Sets LSP record routes to be used by this builder.
- *
- * @param lspRecordRoutes LSP record routes
- * @return self
- */
- public Builder lspRecordRoutes(List<TeRouteSubobject> lspRecordRoutes) {
- if (lspRecordRoutes != null) {
- this.lspRecordRoutes = lspRecordRoutes;
- }
- return this;
- }
- }
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/lsp/TeLsp.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/lsp/TeLsp.java
deleted file mode 100644
index e44c7d1..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/lsp/TeLsp.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.lsp;
-
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.tetunnel.api.tunnel.TeTunnel;
-import org.onosproject.tetunnel.api.tunnel.TeTunnelKey;
-import org.onosproject.tetunnel.api.tunnel.path.TeRouteSubobject;
-
-import java.util.List;
-
-/**
- * Representation of a TE LSP.
- */
-public interface TeLsp {
-
- /**
- * Protection roles of TE LSP.
- */
- enum LspProtectionRole {
- /**
- * Designates a working LSP.
- */
- WORKING,
- /**
- * Designates a protection LSP.
- */
- PROTECTION
- }
-
- /**
- * Origin type of LSP relative to the location of the local switch in the
- * path.
- */
- enum OriginType {
- INGRESS,
- EGRESS,
- TRANSIT
- }
-
- /**
- * Returns key of this TE LSP.
- *
- * @return key of this TE LSP
- */
- TeLspKey teLspKey();
-
- /**
- * Returns source TE node of this tunnel.
- *
- * @return source TE node key
- */
- TeNodeKey srcNode();
-
- /**
- * Returns source TE termination point of this tunnel.
- *
- * @return source TE termination point key
- */
- TtpKey srcTp();
-
- /**
- * Returns destination TE node of this tunnel.
- *
- * @return destination TE node key
- */
- TeNodeKey dstNode();
-
- /**
- * Returns destination TE termination point of this tunnel.
- *
- * @return destination TE termination point key
- */
- TtpKey dstTp();
-
- /**
- * Returns the TE tunnel used in the SESSION that remains constant over
- * the life of the tunnel.
- *
- * @return TE tunnel key
- */
- TeTunnelKey teTunnelKey();
-
- /**
- * Returns corresponding tunnel type.
- *
- * @return TE tunnel type
- */
- TeTunnel.Type tunnelType();
-
- /**
- * Returns operational status of the LSP.
- *
- * @return operational status
- */
- TeTunnel.State operStatus();
-
- /**
- * Returns protection role of the LSP.
- *
- * @return protection role
- */
- LspProtectionRole lspProtectionRole();
-
- /**
- * Return origin type of the LSP.
- *
- * @return origin type
- */
- OriginType originType();
-
- /**
- * Returns route of this LSP.
- *
- * @return list of TeRouteSubobject
- */
- List<TeRouteSubobject> lspRecordRoutes();
-
- //TODO add more attributes here.
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/lsp/TeLspKey.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/lsp/TeLspKey.java
deleted file mode 100644
index 829233b..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/lsp/TeLspKey.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.lsp;
-
-import com.google.common.base.Objects;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-
-/**
- * Representation of a TE LSP key, which identifies a TE Label-switched path
- * globally.
- */
-public class TeLspKey extends TeTopologyKey {
-
- private final long teLspId;
-
- /**
- * Creates an instance of TeLspKey with supplied information.
- *
- * @param providerId provider identifier
- * @param clientId client identifier
- * @param topologyId topology identifier
- * @param teLspId TE LSP identifier
- */
- public TeLspKey(long providerId, long clientId,
- long topologyId, long teLspId) {
- super(providerId, clientId, topologyId);
- this.teLspId = teLspId;
- }
-
- /**
- * Creates an instance of TeLspKey with specified TeTopologyKey and
- * supplied TE LSP identifier.
- *
- * @param key the key of TE Topology to which this LSP belongs
- * @param teLspId TE LSP identifier
- */
- public TeLspKey(TeTopologyKey key, long teLspId) {
- super(key.providerId(), key.clientId(), key.topologyId());
- this.teLspId = teLspId;
- }
-
- /**
- * Returns the TE LSP identifier corresponding to this key.
- *
- * @return TE LSP identifier
- */
- public long teLspId() {
- return teLspId;
- }
-
- /**
- * Returns the key of the TE topology to which this LSP belongs.
- *
- * @return corresponding TE topology key
- */
- public TeTopologyKey teTopologyKey() {
- return new TeTopologyKey(providerId(), clientId(), topologyId());
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), teLspId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof TeLspKey) {
- if (!super.equals(object)) {
- return false;
- }
- TeLspKey that = (TeLspKey) object;
- return Objects.equal(this.teLspId, that.teLspId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper()
- .add("topologyId", topologyId())
- .add("teLspId", teLspId)
- .toString();
- }
-}
-
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/lsp/package-info.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/lsp/package-info.java
deleted file mode 100644
index e3388cb..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/lsp/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * IETF TE Tunnel LSP management API.
- */
-package org.onosproject.tetunnel.api.lsp;
\ No newline at end of file
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/package-info.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/package-info.java
deleted file mode 100644
index 4bd2d1c..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * IETF TE Tunnel attributes management service API.
- */
-package org.onosproject.tetunnel.api;
\ No newline at end of file
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/DefaultTeTunnel.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/DefaultTeTunnel.java
deleted file mode 100644
index 4f7740e..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/DefaultTeTunnel.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.tunnel;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.tetunnel.api.tunnel.path.TePath;
-
-import java.util.List;
-
-/**
- * Default TE tunnel implementation.
- */
-public class DefaultTeTunnel implements TeTunnel {
-
- private final TeTunnelKey teTunnelKey;
- private final String name;
- private final Type type;
- private final LspProtectionType lspProtectionType;
- private final State adminState;
- private final TeNodeKey srcNode;
- private final TeNodeKey dstNode;
- private final TtpKey srcTp;
- private final TtpKey dstTp;
- private final List<TePath> primaryPaths;
-
- private List<TeTunnelKey> segmentTunnels = null;
- private TeTunnelKey e2eTunnel = null;
-
- /**
- * Creates a TE tunnel with supplied information.
- *
- * @param teTunnelKey TE tunnel key
- * @param name TE tunnel name
- * @param type TE tunnel type
- * @param lspProtectionType LSP protection type of the TE tunnel
- * @param adminState TE tunnel administrative state
- * @param srcNode source TE node
- * @param dstNode destination TE node
- * @param srcTp source termination point
- * @param dstTp destination termination point
- * @param primaryPaths primary paths
- */
- protected DefaultTeTunnel(TeTunnelKey teTunnelKey, String name, Type type,
- LspProtectionType lspProtectionType,
- State adminState, TeNodeKey srcNode,
- TeNodeKey dstNode, TtpKey srcTp, TtpKey dstTp,
- List<TePath> primaryPaths) {
- this.teTunnelKey = teTunnelKey;
- this.name = name;
- this.type = type;
- this.lspProtectionType = lspProtectionType;
- this.adminState = adminState;
- this.srcNode = srcNode;
- this.dstNode = dstNode;
- this.srcTp = srcTp;
- this.dstTp = dstTp;
- this.primaryPaths = Lists.newArrayList(primaryPaths);
- }
-
- @Override
- public TeTunnelKey teTunnelKey() {
- return teTunnelKey;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public Type type() {
- return type;
- }
-
- @Override
- public LspProtectionType lspProtectionType() {
- return lspProtectionType;
- }
-
- @Override
- public State adminStatus() {
- return adminState;
- }
-
- @Override
- public TeNodeKey srcNode() {
- return srcNode;
- }
-
- @Override
- public TeNodeKey dstNode() {
- return dstNode;
- }
-
- @Override
- public List<TePath> primaryPaths() {
- return ImmutableList.copyOf(primaryPaths);
- }
-
- @Override
- public List<TeTunnelKey> segmentTunnels() {
- return ImmutableList.copyOf(segmentTunnels);
- }
-
- @Override
- public void segmentTunnels(List<TeTunnelKey> segmentTunnels) {
- this.segmentTunnels = Lists.newArrayList(segmentTunnels);
- }
-
- @Override
- public TeTunnelKey e2eTunnelKey() {
- return e2eTunnel;
- }
-
- @Override
- public void e2eTunnelKey(TeTunnelKey e2eTunnelKey) {
- this.e2eTunnel = e2eTunnelKey;
- }
-
- @Override
- public TtpKey srcTp() {
- return srcTp;
- }
-
- @Override
- public TtpKey dstTp() {
- return dstTp;
- }
-
-
- /**
- * Creates a new default TE tunnel builder.
- *
- * @return default builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder for default TE tunnel objects.
- */
- public static class Builder {
-
- private TeTunnelKey teTunnelKey = null;
- private String name = "";
- private Type type = null;
- private LspProtectionType lspProtectionType = null;
- private State adminState = State.UP;
- private TeNodeKey srcNode = null;
- private TeNodeKey dstNode = null;
- private TtpKey srcTp = null;
- private TtpKey dstTp = null;
- private List<TePath> primaryPaths = Lists.newArrayList();
-
- /**
- * Builds a default TE tunnel object from the accumulated parameters.
- *
- * @return default TE tunnel object
- */
- public DefaultTeTunnel build() {
- return new DefaultTeTunnel(teTunnelKey, name, type,
- lspProtectionType,
- adminState, srcNode, dstNode,
- srcTp, dstTp, primaryPaths);
- }
-
- /**
- * Sets TE tunnel key to be used by this builder.
- *
- * @param teTunnelKey TE tunnel key
- * @return self
- */
- public Builder teTunnelKey(TeTunnelKey teTunnelKey) {
- this.teTunnelKey = teTunnelKey;
- return this;
- }
-
- /**
- * Sets TE tunnel name to be used by this builder.
- *
- * @param name TE tunnel name
- * @return self
- */
- public Builder name(String name) {
- this.name = name;
- return this;
- }
-
- /**
- * Sets TE tunnel type to be used by this builder.
- *
- * @param type TE tunnel type
- * @return self
- */
- public Builder type(Type type) {
- this.type = type;
- return this;
- }
-
- /**
- * Sets tunnel LSP protection type to be used by this builder.
- *
- * @param lspProtectionType protection type
- * @return self
- */
- public Builder lspProtectionType(LspProtectionType lspProtectionType) {
- this.lspProtectionType = lspProtectionType;
- return this;
- }
-
- /**
- * Sets administrative state to be used by this builder.
- *
- * @param adminState administrative state
- * @return self
- */
- public Builder adminState(State adminState) {
- this.adminState = adminState;
- return this;
- }
-
- /**
- * Sets source node key to be used by this builder.
- *
- * @param srcNode source node key
- * @return self
- */
- public Builder srcNode(TeNodeKey srcNode) {
- this.srcNode = srcNode;
- return this;
- }
-
- /**
- * Sets destination node key to be used by this builder.
- *
- * @param dstNode destination node key
- * @return self
- */
- public Builder dstNode(TeNodeKey dstNode) {
- this.dstNode = dstNode;
- return this;
- }
-
- /**
- * Sets source termination point key to be used by this builder.
- *
- * @param srcTp source termination point key
- * @return self
- */
- public Builder srcTp(TtpKey srcTp) {
- this.srcTp = srcTp;
- return this;
- }
-
- /**
- * Sets destination point key to be used by this builder.
- *
- * @param dstTp destination point key
- * @return self
- */
- public Builder dstTp(TtpKey dstTp) {
- this.dstTp = dstTp;
- return this;
- }
-
- /**
- * Sets primary paths to be used by this builder.
- *
- * @param primaryPaths list of TePath
- * @return self
- */
- public Builder primaryPaths(List<TePath> primaryPaths) {
- if (primaryPaths != null) {
- this.primaryPaths = primaryPaths;
- }
- return this;
- }
- }
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/TeTunnel.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/TeTunnel.java
deleted file mode 100644
index 8be5d4d..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/TeTunnel.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.tunnel;
-
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.tetunnel.api.tunnel.path.TePath;
-
-import java.util.List;
-
-/**
- * Representation of a TE tunnel attributes.
- */
-public interface TeTunnel {
-
- /**
- * TE tunnel types.
- */
- enum Type {
- /**
- * Designates TE point-to-point tunnel.
- */
- P2P,
- /**
- * Designates TE point-to-multipoint tunnel.
- */
- P2MP,
- /**
- * Designates RSVP-TE path signaling tunnel.
- */
- PATH_SIGNALING_RSVPTE,
- /**
- * Designates Segment-routing path signaling tunnel.
- */
- PATH_SIGNALING_SR
- }
-
- /**
- * LSP protection types.
- */
- enum LspProtectionType {
- /**
- * Designates LSP protection "Unprotected".
- */
- LSP_PROT_UNPROTECTED,
- /**
- * Designates LSP protection "Rerouting without Extra-Traffic".
- */
- LSP_PROT_REROUTE,
- /**
- * Designates LSP protection "(Full) Rerouting".
- */
- LSP_PROT_REROUTE_EXTRA,
- /**
- * Designates LSP protection "1+1 Unidirectional Protection".
- */
- LSP_PROT_UNIDIR_1_TO_1,
- /**
- * Designates LSP protection "1+1 Bidirectional Protection".
- */
- LSP_PROT_BIDIR_1_TO_1,
- /**
- * Designates LSP protection "1:N Protection with Extra-Traffic".
- */
- LSP_PROT_1_FOR_N
- }
-
- /**
- * TE Tunnel state.
- */
- enum State {
- /**
- * Designates the tunnel is down (non-operational).
- */
- DOWN,
- /**
- * Designates the tunnel is up.
- */
- UP
- }
-
- /**
- * Returns the TE tunnel key.
- *
- * @return TE tunnel key
- */
- TeTunnelKey teTunnelKey();
-
- /**
- * Returns the name of the TE tunnel.
- *
- * @return name of the TE tunnel
- */
- String name();
-
- /**
- * Returns the type of the TE tunnel.
- *
- * @return type of the TE tunnel
- */
- Type type();
-
- /**
- * Returns the key of source TE node of this TE tunnel.
- *
- * @return key of the source TE node
- */
- TeNodeKey srcNode();
-
- /**
- * Returns key of the source TE termination point of this tunnel.
- *
- * @return key of the source TE termination point
- */
- TtpKey srcTp();
-
- /**
- * Returns key of the destination TE node of this TE tunnel.
- *
- * @return key of the destination TE node
- */
- TeNodeKey dstNode();
-
- /**
- * Returns key of the destination TE termination point of this TE tunnel.
- *
- * @return key of the destination TE termination point
- */
- TtpKey dstTp();
-
- /**
- * Returns the TE LSP protection type of the TE tunnel.
- *
- * @return TE LSP protection type of the TE tunnel
- */
- LspProtectionType lspProtectionType();
-
- /**
- * Returns the TE tunnel administrative state.
- *
- * @return TE tunnel administrative state
- */
- State adminStatus();
-
- /**
- * Returns primary paths of this TE tunnel.
- *
- * @return a list of TE paths
- */
- List<TePath> primaryPaths();
-
- /**
- * Returns segment tunnels of this (E2E cross-domain) tunnel.
- *
- * @return a list of keys of the segment tunnels
- */
- List<TeTunnelKey> segmentTunnels();
-
- /**
- * Sets segment tunnels of this (E2E cross-domain) tunnel.
- *
- * @param segmentTunnels a list of keys of segment tunnels
- */
- void segmentTunnels(List<TeTunnelKey> segmentTunnels);
-
- /**
- * Returns key of the E2E tunnel of this (segment) tunnel.
- *
- * @return key of the corresponding E2E TE tunnel
- */
- TeTunnelKey e2eTunnelKey();
-
- /**
- * Sets the E2E tunnel of this (segment) tunnel.
- *
- * @param e2eTunnelKey key of the corresponding E2E tunnel
- */
- void e2eTunnelKey(TeTunnelKey e2eTunnelKey);
-
- //TODO: add more required TE attributes
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/TeTunnelEndpoint.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/TeTunnelEndpoint.java
deleted file mode 100644
index c8aed14..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/TeTunnelEndpoint.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.tunnel;
-
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import java.util.Objects;
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * TE tunnel endpoint implementation.
- */
-public class TeTunnelEndpoint implements TunnelEndPoint {
-
- private final TeNodeKey teNodeKey;
- private final TtpKey ttpKey;
-
- /**
- * Creates a TE tunnel end point instance with supplied information.
- *
- * @param teNodeKey key of the TE node of this end point
- * @param ttpKey key of the TE termination point of this end point
- */
- public TeTunnelEndpoint(TeNodeKey teNodeKey, TtpKey ttpKey) {
- this.teNodeKey = teNodeKey;
- this.ttpKey = ttpKey;
- }
-
- /**
- * Returns key of the TE node of this end point.
- *
- * @return key of corresponding TE node
- */
- public TeNodeKey teNodeKey() {
- return teNodeKey;
- }
-
- /**
- * Returns key of the TE termination point of this end point.
- *
- * @return key of corresponding TE termination point
- */
- public TtpKey ttpKey() {
- return ttpKey;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(teNodeKey, ttpKey);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof TeTunnelEndpoint) {
- final TeTunnelEndpoint other = (TeTunnelEndpoint) obj;
- return Objects.equals(this.teNodeKey, other.teNodeKey) &&
- Objects.equals(this.ttpKey, other.ttpKey);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("teNodeKey", teNodeKey)
- .add("ttpKey", ttpKey)
- .toString();
- }
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/TeTunnelKey.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/TeTunnelKey.java
deleted file mode 100644
index 45cdb0b..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/TeTunnelKey.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.tunnel;
-
-import com.google.common.base.Objects;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Representation of a TE tunnel key, which identifies a TE tunnel globally.
- */
-public class TeTunnelKey extends TeTopologyKey {
-
- private final long teTunnelId;
-
- /**
- * Creates an instance of TE tunnel key with supplied information.
- *
- * @param providerId provider identifier
- * @param clientId client identifier
- * @param topologyId topology identifier
- * @param teTunnelId TE tunnel identifier
- */
- public TeTunnelKey(long providerId, long clientId,
- long topologyId, long teTunnelId) {
- super(providerId, clientId, topologyId);
- this.teTunnelId = teTunnelId;
- }
-
- /**
- * Creates an instance of TE tunnel key with specified TeTopologyKey and
- * supplied TE tunnel identifier.
- *
- * @param key the key of TE topology to which this tunnel belongs
- * @param tunnelId TE tunnel identifier
- */
- public TeTunnelKey(TeTopologyKey key, long tunnelId) {
- super(key.providerId(), key.clientId(), key.topologyId());
- this.teTunnelId = tunnelId;
- }
-
- /**
- * Returns the TE tunnel identifier.
- *
- * @return TE tunnel identifier
- */
- public long teTunnelId() {
- return teTunnelId;
- }
-
- /**
- * Returns key of the TE topology to which this tunnel belongs.
- *
- * @return corresponding TE topology key
- */
- public TeTopologyKey teTopologyKey() {
- return new TeTopologyKey(providerId(), clientId(), topologyId());
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(super.hashCode(), teTunnelId);
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof TeTunnelKey) {
- if (!super.equals(object)) {
- return false;
- }
- TeTunnelKey that = (TeTunnelKey) object;
- return Objects.equal(this.teTunnelId, that.teTunnelId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper()
- .add("topologyId", topologyId())
- .add("teTunnelId", teTunnelId)
- .toString();
- }
-}
-
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/package-info.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/package-info.java
deleted file mode 100644
index 606dc7b..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * IETF TE Tunnel attributes management API.
- */
-package org.onosproject.tetunnel.api.tunnel;
\ No newline at end of file
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/DefaultTePath.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/DefaultTePath.java
deleted file mode 100644
index 289cf61..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/DefaultTePath.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.tunnel.path;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.onosproject.tetunnel.api.lsp.TeLspKey;
-
-import java.util.List;
-
-/**
- * Default implementation of TE path.
- */
-public class DefaultTePath implements TePath {
-
- private final Type type;
- private final List<TeLspKey> lsps;
- private final List<TeRouteSubobject> explicitRoute;
- private final List<TePath> secondaryPaths;
-
- /**
- * Creates a default implementation of TE path with supplied information.
- *
- * @param type type of TE Path
- * @param lsps LSPs of the TE Path
- * @param explicitRoute explicit route of the (Explicit) TE path
- * @param secondaryPaths secondary paths of the TE path
- */
- public DefaultTePath(Type type, List<TeLspKey> lsps,
- List<TeRouteSubobject> explicitRoute,
- List<TePath> secondaryPaths) {
- this.type = type;
- if (lsps == null) {
- this.lsps = Lists.newArrayList();
- } else {
- this.lsps = Lists.newArrayList(lsps);
- }
- if (explicitRoute == null) {
- this.explicitRoute = Lists.newArrayList();
- } else {
- this.explicitRoute = Lists.newArrayList(explicitRoute);
- }
- if (secondaryPaths == null) {
- this.secondaryPaths = Lists.newArrayList();
- } else {
- this.secondaryPaths = Lists.newArrayList(secondaryPaths);
- }
- }
-
- @Override
- public Type type() {
- return type;
- }
-
- @Override
- public List<TeLspKey> lsps() {
- return ImmutableList.copyOf(lsps);
- }
-
- @Override
- public List<TeRouteSubobject> explicitRoute() {
- return ImmutableList.copyOf(explicitRoute);
- }
-
- @Override
- public List<TePath> secondaryPaths() {
- return ImmutableList.copyOf(secondaryPaths);
- }
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/DefaultTePathSelection.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/DefaultTePathSelection.java
deleted file mode 100644
index 8b9c2c6..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/DefaultTePathSelection.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.tunnel.path;
-
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-
-/**
- * Default implementation of TE path selection.
- */
-public class DefaultTePathSelection implements TePathSelection {
-
- private final TeTopologyKey teTopologyKey;
- private final long costLimit;
- private final short hopLimit;
-
- /**
- * Creates a default implementation of TE path selection with supplied
- * information.
- *
- * @param teTopologyKey key of corresponding TE topology
- * @param costLimit cost limit of the TE path
- * @param hopLimit hot limit of the TE path
- */
- public DefaultTePathSelection(TeTopologyKey teTopologyKey,
- long costLimit, short hopLimit) {
- this.teTopologyKey = teTopologyKey;
- this.costLimit = costLimit;
- this.hopLimit = hopLimit;
- }
-
- @Override
- public TeTopologyKey teTopologyKey() {
- return teTopologyKey;
- }
-
- @Override
- public long costLimit() {
- return costLimit;
- }
-
- @Override
- public short hopLimit() {
- return hopLimit;
- }
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/DefaultTeRouteUnnumberedLink.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/DefaultTeRouteUnnumberedLink.java
deleted file mode 100644
index c8ed39e..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/DefaultTeRouteUnnumberedLink.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.tunnel.path;
-
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-
-/**
- * Default implementation of a TE unnumbered link route object.
- */
-public class DefaultTeRouteUnnumberedLink implements TeRouteUnnumberedLink {
-
- private final TeNodeKey node;
- private final TtpKey ttp;
-
- /**
- * Creates a default implementation of a TE unnumbered link route object.
- *
- * @param node key of TE node of the route subobject
- * @param ttp key of TE termination point of the route subobject
- */
- public DefaultTeRouteUnnumberedLink(TeNodeKey node, TtpKey ttp) {
- this.node = node;
- this.ttp = ttp;
- }
-
- @Override
- public Type type() {
- return Type.UNNUMBERED_LINK;
- }
-
- @Override
- public TeNodeKey node() {
- return node;
- }
-
- @Override
- public TtpKey ttp() {
- return ttp;
- }
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/TePath.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/TePath.java
deleted file mode 100644
index 7c5e6b8..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/TePath.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.tunnel.path;
-
-import org.onosproject.tetunnel.api.lsp.TeLspKey;
-
-import java.util.List;
-
-/**
- * Representation of a TE tunnel path.
- */
-public interface TePath {
-
- /**
- * Types of TE path.
- */
- enum Type {
- /**
- * Designates a dynamically computed path.
- */
- DYNAMIC,
- /**
- * Designates a path with explicit route.
- */
- EXPLICIT
- }
-
- /**
- * Returns type of this TE path.
- *
- * @return type of this TE path
- */
- Type type();
-
- /**
- * Returns keys of TE LSPs of this TE path.
- *
- * @return list of keys of TE LSPs
- */
- List<TeLspKey> lsps();
-
- /**
- * Returns specified route of ths (Explicit) TE path.
- *
- * @return list of TE route subobjects.
- */
- List<TeRouteSubobject> explicitRoute();
-
- /**
- * Returns secondary TE paths of this TE path.
- *
- * @return list of secondary TE paths.
- */
- List<TePath> secondaryPaths();
-
- //TODO add more attributes here.
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/TePathSelection.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/TePathSelection.java
deleted file mode 100644
index 9c5edcf..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/TePathSelection.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.tunnel.path;
-
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-
-/**
- * Representation of a TE tunnel path selection attributes.
- */
-public interface TePathSelection {
-
- /**
- * Returns key of corresponding TE topology of the TE path.
- *
- * @return key of corresponding TE topology
- */
- TeTopologyKey teTopologyKey();
-
- /**
- * Returns cost limit of the TE path.
- *
- * @return cost limit
- */
- long costLimit();
-
- /**
- * Returns hop limit of the TE path.
- *
- * @return hop limit
- */
- short hopLimit();
-
- //TODO add more attributes here.
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/TeRouteSubobject.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/TeRouteSubobject.java
deleted file mode 100644
index 3facc21..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/TeRouteSubobject.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.tunnel.path;
-
-/**
- * Representation of a TE LSP route element.
- */
-public interface TeRouteSubobject {
-
- /**
- * Types of TE route subobject.
- */
- enum Type {
- /**
- * Designates Unnumbered link route sub-object.
- */
- UNNUMBERED_LINK,
- /**
- * Designates a label route sub-object.
- */
- LABEL,
- /**
- * Designates an IPv4 address route sub-object.
- */
- IPV4_ADDRESS,
- /**
- * Designates an IPv6 address route sub-object.
- */
- IPV6_ADDRESS
- }
-
- /**
- * Return type of the route subobject.
- *
- * @return type of route subobject
- */
- Type type();
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/TeRouteUnnumberedLink.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/TeRouteUnnumberedLink.java
deleted file mode 100644
index 0a4862d..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/TeRouteUnnumberedLink.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.tunnel.path;
-
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-
-/**
- * Representation of a UnnumberedLink as a TE LSP route element.
- */
-public interface TeRouteUnnumberedLink extends TeRouteSubobject {
-
- /**
- * Returns node of this route subobject.
- *
- * @return TE node key
- */
- TeNodeKey node();
-
- /**
- * Returns termination point of this route subobject.
- *
- * @return TE termination point key
- */
- TtpKey ttp();
-}
diff --git a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/package-info.java b/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/package-info.java
deleted file mode 100644
index 1d1b3f5..0000000
--- a/apps/tetunnel/api/src/main/java/org/onosproject/tetunnel/api/tunnel/path/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * IETF TE Tunnel paths management API.
- */
-package org.onosproject.tetunnel.api.tunnel.path;
\ No newline at end of file
diff --git a/apps/tetunnel/api/src/test/java/org/onosproject/tetunnel/api/tunnel/DefaultTeTunnelTest.java b/apps/tetunnel/api/src/test/java/org/onosproject/tetunnel/api/tunnel/DefaultTeTunnelTest.java
deleted file mode 100644
index 8fa25d0..0000000
--- a/apps/tetunnel/api/src/test/java/org/onosproject/tetunnel/api/tunnel/DefaultTeTunnelTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.tunnel;
-
-import com.google.common.collect.Lists;
-import org.junit.Assert;
-import org.junit.Test;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.tetunnel.api.lsp.TeLspKey;
-import org.onosproject.tetunnel.api.tunnel.path.DefaultTePath;
-import org.onosproject.tetunnel.api.tunnel.path.TePath;
-
-import java.util.List;
-
-/**
- * Unit tests for default TE tunnel implementation.
- */
-public class DefaultTeTunnelTest {
-
- /**
- * Tests constructor of TeTunnelKey.
- */
- @Test
- public void testConstructorOfTeTunnelKey() {
- final int providerId = 1;
- final int clientId = 2;
- final int topologyId = 3;
- final int teTunnelId = 4;
-
- TeTunnelKey key = new TeTunnelKey(providerId, clientId, topologyId,
- teTunnelId);
-
- Assert.assertEquals(key.teTunnelId(), teTunnelId);
- Assert.assertEquals(key.teTopologyKey(),
- new TeTopologyKey(providerId, clientId,
- topologyId));
- Assert.assertTrue(key.equals(
- new TeTunnelKey(providerId, clientId, topologyId,
- teTunnelId)));
- }
-
- /**
- * Tests constructor of TeLspKey.
- */
- @Test
- public void testConstructorOfTeLspKey() {
- final int providerId = 1;
- final int clientId = 2;
- final int topologyId = 3;
- final int teLspId = 4;
-
- TeLspKey key = new TeLspKey(providerId, clientId, topologyId,
- teLspId);
-
- Assert.assertEquals(key.teLspId(), teLspId);
- Assert.assertEquals(key.teTopologyKey(),
- new TeTopologyKey(providerId, clientId,
- topologyId));
- Assert.assertTrue(key.equals(
- new TeLspKey(providerId, clientId, topologyId,
- teLspId)));
- }
-
- /**
- * Tests builder of the DefaultTeTunnel.
- */
- @Test
- public void testDefaultTeTunnelBuilder() {
- final int providerId = 1;
- final int clientId = 2;
- final int topologyId = 3;
- final int srcNodeId = 4;
- final int srcTtpId = 5;
- final int dstNodeId = 6;
- final int dstTtpId = 7;
- final int teTunnelId = 8;
- final String teTunnelName = "Test TE tunnel";
- final List<TePath> paths = Lists.newArrayList(
- new DefaultTePath(TePath.Type.DYNAMIC, null, null, null));
- final int segTunnelId1 = 1001;
- final int segTunnelId2 = 1002;
- final int segTunnelId3 = 1003;
-
- TeTunnel teTunnel = DefaultTeTunnel.builder()
- .teTunnelKey(
- new TeTunnelKey(providerId, clientId, topologyId,
- teTunnelId))
- .srcNode(new TeNodeKey(providerId, clientId, topologyId,
- srcNodeId))
- .srcTp(new TtpKey(providerId, clientId, topologyId, srcNodeId,
- srcTtpId))
- .dstNode(new TeNodeKey(providerId, clientId, topologyId,
- dstNodeId))
- .dstTp(new TtpKey(providerId, clientId, topologyId, dstNodeId,
- dstTtpId))
- .name(teTunnelName)
- .adminState(TeTunnel.State.UP)
- .lspProtectionType(TeTunnel.LspProtectionType.LSP_PROT_REROUTE)
- .type(TeTunnel.Type.P2P)
- .primaryPaths(paths)
- .build();
-
- Assert.assertEquals(teTunnel.teTunnelKey().teTopologyKey(),
- new TeTopologyKey(providerId, clientId,
- topologyId));
- Assert.assertEquals(teTunnel.teTunnelKey().teTunnelId(), teTunnelId);
- Assert.assertEquals(teTunnel.srcNode(),
- new TeNodeKey(providerId, clientId, topologyId,
- srcNodeId));
- Assert.assertEquals(teTunnel.dstNode(),
- new TeNodeKey(providerId, clientId, topologyId,
- dstNodeId));
- Assert.assertEquals(teTunnel.srcTp(),
- new TtpKey(providerId, clientId, topologyId,
- srcNodeId, srcTtpId));
- Assert.assertEquals(teTunnel.dstTp(),
- new TtpKey(providerId, clientId, topologyId,
- dstNodeId, dstTtpId));
- Assert.assertEquals(teTunnel.name(), teTunnelName);
- Assert.assertEquals(teTunnel.adminStatus(), TeTunnel.State.UP);
- Assert.assertEquals(teTunnel.lspProtectionType(),
- TeTunnel.LspProtectionType.LSP_PROT_REROUTE);
- Assert.assertEquals(teTunnel.type(), TeTunnel.Type.P2P);
- Assert.assertEquals(teTunnel.primaryPaths().get(0).type(),
- TePath.Type.DYNAMIC);
- Assert.assertEquals(teTunnel.primaryPaths(), paths);
-
- TeTunnelKey segTunnel1 = new TeTunnelKey(providerId, clientId,
- topologyId, segTunnelId1);
- TeTunnelKey segTunnel2 = new TeTunnelKey(providerId, clientId,
- topologyId, segTunnelId2);
- TeTunnelKey segTunnel3 = new TeTunnelKey(providerId, clientId,
- topologyId, segTunnelId3);
- List<TeTunnelKey> segTunnels = Lists.newArrayList(segTunnel1,
- segTunnel2,
- segTunnel3);
- teTunnel.segmentTunnels(segTunnels);
- Assert.assertEquals(teTunnel.segmentTunnels(), segTunnels);
- }
-}
diff --git a/apps/tetunnel/api/src/test/java/org/onosproject/tetunnel/api/tunnel/path/DefaultTePathTest.java b/apps/tetunnel/api/src/test/java/org/onosproject/tetunnel/api/tunnel/path/DefaultTePathTest.java
deleted file mode 100644
index daafa00..0000000
--- a/apps/tetunnel/api/src/test/java/org/onosproject/tetunnel/api/tunnel/path/DefaultTePathTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.api.tunnel.path;
-
-import com.google.common.collect.Lists;
-import org.junit.Assert;
-import org.junit.Test;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.node.TeNodeKey;
-import org.onosproject.tetopology.management.api.node.TtpKey;
-import org.onosproject.tetunnel.api.lsp.TeLspKey;
-
-import java.util.List;
-
-/**
- * Unit tests for default TE path implementation.
- */
-public class DefaultTePathTest {
-
- /**
- * Tests constructor of DefaultTePathSelection.
- */
- @Test
- public void testConstructorOfDefaultTePathSelection() {
- final int providerId = 1;
- final int clientId = 2;
- final int topologyId = 3;
- final long costLimit = 4;
- final short hopLimit = 5;
-
- TePathSelection tePathSelection = new DefaultTePathSelection(
- new TeTopologyKey(providerId, clientId, topologyId),
- costLimit, hopLimit);
- Assert.assertEquals(tePathSelection.teTopologyKey(),
- new TeTopologyKey(providerId, clientId, topologyId));
- Assert.assertEquals(tePathSelection.costLimit(), costLimit);
- Assert.assertEquals(tePathSelection.hopLimit(), hopLimit);
- }
-
- /**
- * Tests constructor of DefaultTeRouteUnnumberedLink.
- */
- @Test
- public void testConstructorOfDefaultTeRouteUnnumberedLink() {
- final int providerId = 1;
- final int clientId = 2;
- final int topologyId = 3;
- final int teNodeId = 4;
- final int teTtpId = 5;
-
- TeRouteUnnumberedLink teRouteUnnumberedLink =
- new DefaultTeRouteUnnumberedLink(
- new TeNodeKey(providerId, clientId,
- topologyId, teNodeId),
- new TtpKey(providerId, clientId,
- topologyId, teNodeId, teTtpId));
-
- Assert.assertEquals(teRouteUnnumberedLink.type(),
- TeRouteSubobject.Type.UNNUMBERED_LINK);
- Assert.assertEquals(teRouteUnnumberedLink.node(),
- new TeNodeKey(providerId, clientId,
- topologyId, teNodeId));
- Assert.assertEquals(teRouteUnnumberedLink.ttp(),
- new TtpKey(providerId, clientId,
- topologyId, teNodeId, teTtpId));
- }
-
- /**
- * Tests constructor of DefaultTePath.
- */
- @Test
- public void testConstructorOfDefaultTePath() {
- final int providerId = 1;
- final int clientId = 2;
- final int topologyId = 3;
- final int teNodeId = 4;
- final int teTtpId = 5;
- final int teLspId = 6;
-
- List<TeLspKey> lspKeys = Lists.newArrayList(
- new TeLspKey(providerId, clientId, topologyId, teLspId));
-
- TeRouteUnnumberedLink teRouteUnnumberedLink =
- new DefaultTeRouteUnnumberedLink(
- new TeNodeKey(providerId, clientId,
- topologyId, teNodeId),
- new TtpKey(providerId, clientId,
- topologyId, teNodeId, teTtpId));
- List<TeRouteSubobject> explicitRoute = Lists.newArrayList(
- teRouteUnnumberedLink);
-
- List<TePath> secondaryPaths = Lists.newArrayList(
- new DefaultTePath(TePath.Type.DYNAMIC, null, null, null)
- );
-
- TePath tePath = new DefaultTePath(TePath.Type.EXPLICIT, lspKeys,
- explicitRoute, secondaryPaths);
-
- Assert.assertEquals(tePath.type(), TePath.Type.EXPLICIT);
- Assert.assertEquals(tePath.explicitRoute(), explicitRoute);
- Assert.assertEquals(tePath.lsps(), lspKeys);
- Assert.assertEquals(tePath.secondaryPaths(), secondaryPaths);
- }
-}
diff --git a/apps/tetunnel/app/BUILD b/apps/tetunnel/app/BUILD
deleted file mode 100644
index d5a367e..0000000
--- a/apps/tetunnel/app/BUILD
+++ /dev/null
@@ -1,16 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + KRYO + [
- "//apps/tetopology/api:onos-apps-tetopology-api",
- "//apps/tetunnel/api:onos-apps-tetunnel-api",
- "//apps/tunnel/api:onos-apps-tunnel-api",
- "//core/store/serializers:onos-core-serializers",
-]
-
-TEST_DEPS = TEST_ADAPTERS + [
- "//utils/osgi:onlab-osgi-tests",
- "//apps/tunnel/api:onos-apps-tunnel-api-tests",
-]
-
-osgi_jar_with_tests(
- test_deps = TEST_DEPS,
- deps = COMPILE_DEPS,
-)
diff --git a/apps/tetunnel/app/src/main/java/org/onosproject/tetunnel/impl/DistributedTeTunnelStore.java b/apps/tetunnel/app/src/main/java/org/onosproject/tetunnel/impl/DistributedTeTunnelStore.java
deleted file mode 100644
index e9da5e4..0000000
--- a/apps/tetunnel/app/src/main/java/org/onosproject/tetunnel/impl/DistributedTeTunnelStore.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.impl;
-
-import com.google.common.collect.ImmutableList;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.LogicalClockService;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetunnel.api.TeTunnelStore;
-import org.onosproject.tetunnel.api.lsp.TeLsp;
-import org.onosproject.tetunnel.api.lsp.TeLspKey;
-import org.onosproject.tetunnel.api.tunnel.TeTunnel;
-import org.onosproject.tetunnel.api.tunnel.TeTunnelKey;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.Collection;
-import java.util.stream.Collectors;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Manages the TE tunnel attributes using an eventually consistent map.
- */
-@Component(immediate = true, service = TeTunnelStore.class)
-public class DistributedTeTunnelStore implements TeTunnelStore {
-
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LogicalClockService clockService;
-
- private EventuallyConsistentMap<TeTunnelKey, TeTunnel> teTunnels;
- private EventuallyConsistentMap<TeTunnelKey, TunnelId> tunnelIds;
- private EventuallyConsistentMap<TeLspKey, TeLsp> lsps;
-
- @Activate
- public void activate() {
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API)
- .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID)
- .register(TeTunnel.class);
-
- teTunnels = storageService.<TeTunnelKey, TeTunnel>eventuallyConsistentMapBuilder()
- .withName("TeTunnelStore")
- .withSerializer(serializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
-
- tunnelIds = storageService.<TeTunnelKey, TunnelId>eventuallyConsistentMapBuilder()
- .withName("TeTunnelIdStore")
- .withSerializer(serializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
-
- lsps = storageService.<TeLspKey, TeLsp>eventuallyConsistentMapBuilder()
- .withName("TeLspStore")
- .withSerializer(serializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- teTunnels.destroy();
- tunnelIds.destroy();
- lsps.destroy();
-
- log.info("Stopped");
- }
-
- @Override
- public boolean addTeTunnel(TeTunnel teTunnel) {
- if (teTunnel == null) {
- log.warn("teTunnel is null");
- return false;
- }
- if (teTunnels.containsKey(teTunnel.teTunnelKey())) {
- log.warn("teTunnel already exist");
- return false;
- }
- teTunnels.put(teTunnel.teTunnelKey(), teTunnel);
- return true;
- }
-
- @Override
- public void setTunnelId(TeTunnelKey teTunnelKey, TunnelId tunnelId) {
- tunnelIds.put(teTunnelKey, tunnelId);
- }
-
- @Override
- public TunnelId getTunnelId(TeTunnelKey teTunnelKey) {
- return tunnelIds.get(teTunnelKey);
- }
-
- @Override
- public void updateTeTunnel(TeTunnel teTunnel) {
- if (teTunnel == null) {
- log.warn("TeTunnel is null");
- return;
- }
- teTunnels.put(teTunnel.teTunnelKey(), teTunnel);
- }
-
- @Override
- public void removeTeTunnel(TeTunnelKey teTunnelKey) {
- teTunnels.remove(teTunnelKey);
- tunnelIds.remove(teTunnelKey);
- }
-
- @Override
- public TeTunnel getTeTunnel(TeTunnelKey teTunnelKey) {
- return teTunnels.get(teTunnelKey);
- }
-
- @Override
- public TeTunnel getTeTunnel(TunnelId tunnelId) {
- if (tunnelIds.containsValue(tunnelId)) {
- for (TeTunnel teTunnel : teTunnels.values()) {
- if (tunnelIds.get(teTunnel.teTunnelKey()).equals(tunnelId)) {
- return teTunnel;
- }
- }
- }
- return null;
- }
-
- @Override
- public Collection<TeTunnel> getTeTunnels() {
- return ImmutableList.copyOf(teTunnels.values());
- }
-
- @Override
- public Collection<TeTunnel> getTeTunnels(TeTunnel.Type type) {
- return ImmutableList.copyOf(teTunnels.values()
- .stream()
- .filter(teTunnel -> teTunnel.type().equals(type))
- .collect(Collectors.toList()));
- }
-
- @Override
- public Collection<TeTunnel> getTeTunnels(TeTopologyKey teTopologyKey) {
- return ImmutableList.copyOf(teTunnels.values()
- .stream()
- .filter(teTunnel -> teTunnel.teTunnelKey()
- .teTopologyKey()
- .equals(teTopologyKey))
- .collect(Collectors.toList()));
- }
-
- @Override
- public boolean addTeLsp(TeLsp lsp) {
- if (lsp == null) {
- log.warn("TeLsp is null");
- return false;
- }
- if (lsps.containsKey(lsp.teLspKey())) {
- log.error("TeLsp exist {}", lsp.teLspKey());
- return false;
- }
- lsps.put(lsp.teLspKey(), lsp);
- return true;
- }
-
- @Override
- public void updateTeLsp(TeLsp lsp) {
- if (lsp == null) {
- log.warn("TeLsp is null");
- return;
- }
- lsps.put(lsp.teLspKey(), lsp);
- }
-
- @Override
- public void removeTeLsp(TeLspKey key) {
- lsps.remove(key);
- }
-
- @Override
- public TeLsp getTeLsp(TeLspKey key) {
- return lsps.get(key);
- }
-
- @Override
- public Collection<TeLsp> getTeLsps() {
- return ImmutableList.copyOf(lsps.values());
- }
-}
diff --git a/apps/tetunnel/app/src/main/java/org/onosproject/tetunnel/impl/TeTunnelManager.java b/apps/tetunnel/app/src/main/java/org/onosproject/tetunnel/impl/TeTunnelManager.java
deleted file mode 100644
index cd99d0c..0000000
--- a/apps/tetunnel/app/src/main/java/org/onosproject/tetunnel/impl/TeTunnelManager.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.tetunnel.impl;
-
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.core.GroupId;
-import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelAdminService;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.tetopology.management.api.TeTopology;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.TeTopologyService;
-import org.onosproject.tetunnel.api.TeTunnelAdminService;
-import org.onosproject.tetunnel.api.TeTunnelProviderService;
-import org.onosproject.tetunnel.api.TeTunnelService;
-import org.onosproject.tetunnel.api.TeTunnelStore;
-import org.onosproject.tetunnel.api.lsp.TeLsp;
-import org.onosproject.tetunnel.api.lsp.TeLspKey;
-import org.onosproject.tetunnel.api.tunnel.TeTunnel;
-import org.onosproject.tetunnel.api.tunnel.TeTunnelEndpoint;
-import org.onosproject.tetunnel.api.tunnel.TeTunnelKey;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.Collection;
-import java.util.List;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Implementation of TE tunnel attributes management service.
- */
-@Component(immediate = true, service = { TeTunnelService.class, TeTunnelAdminService.class,
- TeTunnelProviderService.class })
-public class TeTunnelManager implements TeTunnelService, TeTunnelAdminService,
- TeTunnelProviderService {
-
- private static final String TE_TUNNEL_APP = "onos-app-tetunnel";
-
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TeTunnelStore store;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TunnelService tunnelService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TunnelAdminService tunnelAdminService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TeTopologyService teTopologyService;
-
- private ApplicationId appId;
-
- @Activate
- public void activate() {
- appId = coreService.registerApplication(TE_TUNNEL_APP);
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public TunnelId createTeTunnel(TeTunnel teTunnel) {
- if (!store.addTeTunnel(teTunnel)) {
- log.error("can not add teTunnel: {}", teTunnel);
- return null;
- }
-
- TunnelId tunnelId = TunnelId.valueOf(teTunnel.teTunnelKey().toString());
- Tunnel tunnel = new DefaultTunnel(ProviderId.NONE,
- new TeTunnelEndpoint(teTunnel.srcNode(),
- teTunnel.srcTp()),
- new TeTunnelEndpoint(teTunnel.dstNode(),
- teTunnel.dstTp()),
- Tunnel.Type.MPLS, new GroupId(0),
- tunnelId,
- TunnelName.tunnelName(teTunnel.name()),
- null,
- DefaultAnnotations.builder().build());
- store.setTunnelId(teTunnel.teTunnelKey(), tunnelId);
- TeTopology srcTopology = teTopologyService.teTopology(
- teTopologyService.teNode(teTunnel.srcNode())
- .underlayTeTopologyId());
- if (srcTopology == null) {
- srcTopology = teTopologyService.teTopology(teTunnel.srcNode()
- .teTopologyKey());
- }
- DeviceId domainId = srcTopology.ownerId();
- TunnelId id = tunnelService.setupTunnel(appId, domainId, tunnel, null);
- if (id == null) {
- log.error("can not create tunnel for te {}",
- teTunnel.teTunnelKey());
- store.removeTeTunnel(teTunnel.teTunnelKey());
- return null;
- }
- if (!id.equals(tunnelId)) {
- //this should not happen
- log.error("tunnelId changed, oldId:{}, newId:{}", tunnelId, id);
- store.setTunnelId(teTunnel.teTunnelKey(), id);
- }
- return id;
- }
-
- @Override
- public void setTunnelId(TeTunnelKey teTunnelKey, TunnelId tunnelId) {
- store.setTunnelId(teTunnelKey, tunnelId);
- }
-
- @Override
- public void updateTeTunnel(TeTunnel teTunnel) {
- //TODO: updateTeTunnel
- }
-
- @Override
- public void updateTunnelState(TeTunnelKey key, Tunnel.State state) {
- tunnelAdminService.updateTunnelState(
- tunnelService.queryTunnel(getTunnelId(key)), state);
- }
-
- @Override
- public TeLspKey teLspAdded(TeLsp lsp) {
- if (store.addTeLsp(lsp)) {
- return lsp.teLspKey();
- }
-
- return null;
- }
-
- @Override
- public void teLspRemoved(TeLsp lsp) {
- store.removeTeLsp(lsp.teLspKey());
- }
-
- @Override
- public void updateTeLsp(TeLsp lsp) {
- store.updateTeLsp(lsp);
- }
-
- @Override
- public void removeTeTunnel(TeTunnelKey teTunnelKey) {
- tunnelAdminService.updateTunnelState(
- tunnelService.queryTunnel(getTunnelId(teTunnelKey)),
- Tunnel.State.REMOVING);
- List<TeTunnelKey> segmentTunnels =
- getTeTunnel(teTunnelKey).segmentTunnels();
- if (segmentTunnels == null || segmentTunnels.isEmpty()) {
- // this is a single domain tunnel, removes it right away
- tunnelAdminService.removeTunnel(getTunnelId(teTunnelKey));
- }
- }
-
- @Override
- public void setSegmentTunnel(TeTunnelKey e2eTunnelKey,
- List<TeTunnelKey> segmentTunnels) {
- TeTunnel e2eTunnel = store.getTeTunnel(e2eTunnelKey);
- if (e2eTunnel == null) {
- log.error("unknown e2eTunnelKey: {}", e2eTunnelKey);
- return;
- }
- e2eTunnel.segmentTunnels(segmentTunnels);
-
- for (TeTunnelKey key : segmentTunnels) {
- TeTunnel segmentTunnel = store.getTeTunnel(key);
- if (segmentTunnel == null) {
- log.warn("unknown segmentTunnel: {}", key);
- continue;
- }
- segmentTunnel.e2eTunnelKey(e2eTunnelKey);
- }
- }
-
- @Override
- public TeTunnel getTeTunnel(TeTunnelKey key) {
- return store.getTeTunnel(key);
- }
-
- @Override
- public TeTunnel getTeTunnel(TunnelId id) {
- return store.getTeTunnel(id);
- }
-
- @Override
- public TunnelId getTunnelId(TeTunnelKey key) {
- return store.getTunnelId(key);
- }
-
- @Override
- public Collection<TeTunnel> getTeTunnels() {
- return store.getTeTunnels();
- }
-
- @Override
- public Collection<TeTunnel> getTeTunnels(TeTunnel.Type type) {
- return store.getTeTunnels(type);
- }
-
- @Override
- public Collection<TeTunnel> getTeTunnels(TeTopologyKey key) {
- return store.getTeTunnels(key);
- }
-
- @Override
- public TeLsp getTeLsp(TeLspKey key) {
- return store.getTeLsp(key);
- }
-
- @Override
- public Collection<TeLsp> getTeLsps() {
- return store.getTeLsps();
- }
-
- @Override
- public TunnelId teTunnelAdded(TeTunnel teTunnel) {
- //TODO teTunnelAdded
- return null;
- }
-
- @Override
- public void teTunnelRemoved(TeTunnel teTunnel) {
- TeTunnelKey e2eTunnelKey = teTunnel.e2eTunnelKey();
- store.removeTeTunnel(teTunnel.teTunnelKey());
-
- // it's a segment tunnel
- if (e2eTunnelKey != null) {
- boolean finished = true;
- for (TeTunnelKey key : getTeTunnel(e2eTunnelKey).segmentTunnels()) {
- if (getTeTunnel(key) != null) {
- // FIXME need a better way to determine whether a segment tunnel is removed.
- finished = false;
- }
- }
- if (finished) {
- // all segment tunnels are removed
- tunnelAdminService.removeTunnel(getTunnelId(e2eTunnelKey));
- store.removeTeTunnel(e2eTunnelKey);
- }
- }
- }
-}
diff --git a/apps/tetunnel/app/src/main/java/org/onosproject/tetunnel/impl/package-info.java b/apps/tetunnel/app/src/main/java/org/onosproject/tetunnel/impl/package-info.java
deleted file mode 100644
index f07ffe9..0000000
--- a/apps/tetunnel/app/src/main/java/org/onosproject/tetunnel/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * IETF TE Tunnel attributes management implementation.
- */
-package org.onosproject.tetunnel.impl;
\ No newline at end of file
diff --git a/apps/vtn/BUILD b/apps/vtn/BUILD
deleted file mode 100644
index 8331afd..0000000
--- a/apps/vtn/BUILD
+++ /dev/null
@@ -1,14 +0,0 @@
-BUNDLES = [
- "//apps/vtn/vtnrsc:onos-apps-vtn-vtnrsc",
- "//apps/vtn/sfcmgr:onos-apps-vtn-sfcmgr",
- "//apps/vtn/vtnmgr:onos-apps-vtn-vtnmgr",
- "//apps/vtn/vtnweb:onos-apps-vtn-vtnweb",
-]
-
-onos_app(
- category = "Integration",
- description = "ONOS framework applications",
- included_bundles = BUNDLES,
- title = "OPNFV",
- url = "http://onosproject.org",
-)
diff --git a/apps/vtn/sfcmgr/BUILD b/apps/vtn/sfcmgr/BUILD
deleted file mode 100644
index e45ac6e..0000000
--- a/apps/vtn/sfcmgr/BUILD
+++ /dev/null
@@ -1,9 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + KRYO + [
- "//core/store/serializers:onos-core-serializers",
- "//apps/vtn/vtnrsc:onos-apps-vtn-vtnrsc",
-]
-
-osgi_jar_with_tests(
- test_deps = TEST_ADAPTERS,
- deps = COMPILE_DEPS,
-)
diff --git a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/SfcFlowRuleInstallerService.java b/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/SfcFlowRuleInstallerService.java
deleted file mode 100644
index fa17aad..0000000
--- a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/SfcFlowRuleInstallerService.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.installer;
-
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.NshServicePathId;
-import org.onosproject.vtnrsc.FiveTuple;
-import org.onosproject.vtnrsc.PortChain;
-
-/**
- * Abstraction of an entity which installs flow classification rules in ovs.
- */
-public interface SfcFlowRuleInstallerService {
-
- /**
- * Install flow classifier.
- *
- * @param portChain port-chain
- * @param nshSpiId service path index identifier
- * @return connectPoint the network identifier
- */
- ConnectPoint installFlowClassifier(PortChain portChain, NshServicePathId nshSpiId);
-
- /**
- * Uninstall flow classifier.
- *
- * @param portChain port-chain
- * @param nshSpiId service path index identifier
- * @return connectPoint the network identifier
- */
- ConnectPoint unInstallFlowClassifier(PortChain portChain, NshServicePathId nshSpiId);
-
- /**
- * Install load balanced flow rules.
- *
- * @param portChain port-chain
- * @param fiveTuple five tuple packet information
- * @param nshSpiId service path index identifier
- * @return connectPoint the network identifier
- */
- ConnectPoint installLoadBalancedFlowRules(PortChain portChain, FiveTuple fiveTuple,
- NshServicePathId nshSpiId);
-
- /**
- * Uninstall load balanced flow rules.
- *
- * @param portChain port-chain
- * @param fiveTuple five tuple packet information
- * @param nshSpiId service path index identifier
- * @return connectPoint the network identifier
- */
- ConnectPoint unInstallLoadBalancedFlowRules(PortChain portChain, FiveTuple fiveTuple,
- NshServicePathId nshSpiId);
-
- /**
- * Uninstall load balanced classifier rules.
- *
- * @param portChain port-chain
- * @param fiveTuple five tuple packet information
- * @param nshSpiId service path index identifier
- * @return connectPoint the network identifier
- */
- ConnectPoint unInstallLoadBalancedClassifierRules(PortChain portChain, FiveTuple fiveTuple,
- NshServicePathId nshSpiId);
-}
diff --git a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/SfcFlowRuleInstallerImpl.java b/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/SfcFlowRuleInstallerImpl.java
deleted file mode 100644
index 3c76e89..0000000
--- a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/SfcFlowRuleInstallerImpl.java
+++ /dev/null
@@ -1,908 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.installer.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.net.flow.criteria.ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_ENCAP_ETH_TYPE;
-import static org.onosproject.net.flow.criteria.ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SI;
-import static org.onosproject.net.flow.criteria.ExtensionSelectorType.ExtensionSelectorTypes.NICIRA_MATCH_NSH_SPI;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_ENCAP_ETH_DST;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_ENCAP_ETH_SRC;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_NSH_MDTYPE;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_NSH_NP;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_POP_NSH;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_PUSH_NSH;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_RESUBMIT_TABLE;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH1;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH2;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH3;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_CH4;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SI;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_TUN_GPE_NP;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Set;
-
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.TpPort;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.HostId;
-import org.onosproject.net.NshContextHeader;
-import org.onosproject.net.NshServiceIndex;
-import org.onosproject.net.NshServicePathId;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.behaviour.BridgeConfig;
-import org.onosproject.net.behaviour.ExtensionSelectorResolver;
-import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.criteria.Criteria;
-import org.onosproject.net.flow.criteria.ExtensionSelector;
-import org.onosproject.net.flow.instructions.ExtensionTreatment;
-import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
-import org.onosproject.net.flow.instructions.Instructions;
-import org.onosproject.net.flowobjective.DefaultForwardingObjective;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.flowobjective.ForwardingObjective.Flag;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.net.host.HostService;
-import org.onosproject.sfc.installer.SfcFlowRuleInstallerService;
-import org.onosproject.vtnrsc.FiveTuple;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService;
-import org.onosproject.vtnrsc.portpair.PortPairService;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
-import org.onosproject.vtnrsc.service.VtnRscService;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.slf4j.Logger;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
-/**
- * Provides flow classifier installer implementation.
- */
-public class SfcFlowRuleInstallerImpl implements SfcFlowRuleInstallerService {
- private final Logger log = getLogger(getClass());
-
- protected VirtualPortService virtualPortService;
- protected VtnRscService vtnRscService;
- protected PortPairService portPairService;
- protected PortPairGroupService portPairGroupService;
- protected FlowClassifierService flowClassifierService;
- protected DriverService driverService;
- protected DeviceService deviceService;
- protected HostService hostService;
- protected TenantNetworkService tenantNetworkService;
- protected FlowObjectiveService flowObjectiveService;
- protected ApplicationId appId;
-
- private static final String PORT_CHAIN_NOT_NULL = "Port-Chain cannot be null";
- private static final int FLOW_CLASSIFIER_PRIORITY = 0xC738;
- private static final int DEFAULT_FORWARDER_PRIORITY = 0xD6D8;
- private static final int ENCAP_OUTPUT_PRIORITY = 0x64;
- private static final int TUNNEL_SEND_PRIORITY = 0xC8;
- private static final String SWITCH_CHANNEL_ID = "channelId";
- private static final int ENCAP_OUTPUT_TABLE = 4;
- private static final int TUNNEL_SEND_TABLE = 7;
- private static final short ENCAP_ETH_TYPE = (short) 0x894f;
- private static final String DEFAULT_IP = "0.0.0.0";
- private static final String VXLANPORT_HEAD = "vxlan-0.0.0.0";
-
- /* Port chain params */
- private short nshSi;
- List<DeviceId> classifierList;
- List<DeviceId> forwarderList;
-
- /**
- * Default constructor.
- */
- public SfcFlowRuleInstallerImpl() {
- }
-
- /**
- * Explicit constructor.
- *
- * @param appId application id.
- */
- public SfcFlowRuleInstallerImpl(ApplicationId appId) {
- this.appId = checkNotNull(appId, "ApplicationId can not be null");
- ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
- this.flowObjectiveService = serviceDirectory.get(FlowObjectiveService.class);
- this.driverService = serviceDirectory.get(DriverService.class);
- this.deviceService = serviceDirectory.get(DeviceService.class);
- this.hostService = serviceDirectory.get(HostService.class);
- this.virtualPortService = serviceDirectory.get(VirtualPortService.class);
- this.vtnRscService = serviceDirectory.get(VtnRscService.class);
- this.portPairService = serviceDirectory.get(PortPairService.class);
- this.portPairGroupService = serviceDirectory.get(PortPairGroupService.class);
- this.flowClassifierService = serviceDirectory.get(FlowClassifierService.class);
- this.tenantNetworkService = serviceDirectory.get(TenantNetworkService.class);
- nshSi = 0xff;
- }
-
- @Override
- public ConnectPoint installFlowClassifier(PortChain portChain, NshServicePathId nshSpiId) {
- checkNotNull(portChain, PORT_CHAIN_NOT_NULL);
- // Get the portPairGroup
- List<PortPairGroupId> llPortPairGroupIdList = portChain.portPairGroups();
- ListIterator<PortPairGroupId> portPairGroupIdListIterator = llPortPairGroupIdList.listIterator();
- PortPairGroupId portPairGroupId = portPairGroupIdListIterator.next();
- PortPairGroup portPairGroup = portPairGroupService.getPortPairGroup(portPairGroupId);
- List<PortPairId> llPortPairIdList = portPairGroup.portPairs();
-
- // Get port pair
- ListIterator<PortPairId> portPairListIterator = llPortPairIdList.listIterator();
- PortPairId portPairId = portPairListIterator.next();
- PortPair portPair = portPairService.getPortPair(portPairId);
-
- return installSfcClassifierRules(portChain, portPair, nshSpiId, null, Objective.Operation.ADD);
- }
-
- @Override
- public ConnectPoint unInstallFlowClassifier(PortChain portChain, NshServicePathId nshSpiId) {
- checkNotNull(portChain, PORT_CHAIN_NOT_NULL);
- // Get the portPairGroup
- List<PortPairGroupId> llPortPairGroupIdList = portChain.portPairGroups();
- ListIterator<PortPairGroupId> portPairGroupIdListIterator = llPortPairGroupIdList.listIterator();
- PortPairGroupId portPairGroupId = portPairGroupIdListIterator.next();
- PortPairGroup portPairGroup = portPairGroupService.getPortPairGroup(portPairGroupId);
- List<PortPairId> llPortPairIdList = portPairGroup.portPairs();
-
- // Get port pair
- ListIterator<PortPairId> portPairListIterator = llPortPairIdList.listIterator();
- PortPairId portPairId = portPairListIterator.next();
- PortPair portPair = portPairService.getPortPair(portPairId);
-
- return installSfcClassifierRules(portChain, portPair, nshSpiId, null, Objective.Operation.REMOVE);
- }
-
- @Override
- public ConnectPoint installLoadBalancedFlowRules(PortChain portChain, FiveTuple fiveTuple,
- NshServicePathId nshSpiId) {
- checkNotNull(portChain, PORT_CHAIN_NOT_NULL);
-
- return installSfcFlowRules(portChain, fiveTuple, nshSpiId, Objective.Operation.ADD);
- }
-
- @Override
- public ConnectPoint unInstallLoadBalancedFlowRules(PortChain portChain, FiveTuple fiveTuple,
- NshServicePathId nshSpiId) {
- checkNotNull(portChain, PORT_CHAIN_NOT_NULL);
- return installSfcFlowRules(portChain, fiveTuple, nshSpiId, Objective.Operation.REMOVE);
- }
-
- @Override
- public ConnectPoint unInstallLoadBalancedClassifierRules(PortChain portChain, FiveTuple fiveTuple,
- NshServicePathId nshSpiId) {
- checkNotNull(portChain, PORT_CHAIN_NOT_NULL);
-
- List<PortPairId> portPairs = portChain.getLoadBalancePath(fiveTuple);
- // Get the first port pair
- ListIterator<PortPairId> portPairListIterator = portPairs.listIterator();
- PortPairId portPairId = portPairListIterator.next();
- PortPair portPair = portPairService.getPortPair(portPairId);
-
- return installSfcClassifierRules(portChain, portPair, nshSpiId, fiveTuple, Objective.Operation.REMOVE);
- }
-
- public ConnectPoint installSfcFlowRules(PortChain portChain, FiveTuple fiveTuple, NshServicePathId nshSpiId,
- Objective.Operation type) {
- checkNotNull(portChain, PORT_CHAIN_NOT_NULL);
-
- classifierList = Lists.newArrayList();
- forwarderList = Lists.newArrayList();
-
- // Get the load balanced path
- List<PortPairId> portPairs = portChain.getLoadBalancePath(fiveTuple);
-
- // Get the first port pair
- ListIterator<PortPairId> portPairListIterator = portPairs.listIterator();
- PortPairId portPairId = portPairListIterator.next();
- PortPair currentPortPair = portPairService.getPortPair(portPairId);
-
- ConnectPoint connectPoint = installSfcClassifierRules(portChain, currentPortPair, nshSpiId, fiveTuple, type);
-
- log.info("Installing encap and output for first port pair");
-
- installSfcEncapOutputRule(currentPortPair, nshSpiId, type);
-
- PortPair nextPortPair;
- while (portPairListIterator.hasNext()) {
- portPairId = portPairListIterator.next();
- nextPortPair = portPairService.getPortPair(portPairId);
- installSfcForwardRule(currentPortPair, nextPortPair, nshSpiId, type);
- installSfcEncapOutputRule(nextPortPair, nshSpiId, type);
- currentPortPair = nextPortPair;
- }
- installSfcEndRule(currentPortPair, nshSpiId, type);
-
- if (type.equals(Objective.Operation.ADD)) {
- portChain.addSfcClassifiers(portChain.getLoadBalanceId(fiveTuple), classifierList);
- portChain.addSfcForwarders(portChain.getLoadBalanceId(fiveTuple), forwarderList);
- } else {
- portChain.removeSfcClassifiers(portChain.getLoadBalanceId(fiveTuple), classifierList);
- portChain.removeSfcForwarders(portChain.getLoadBalanceId(fiveTuple), forwarderList);
- }
- return connectPoint;
- }
-
- public void installSfcTunnelReceiveRule(DeviceId deviceId, NshServicePathId nshSpiId, Objective.Operation type) {
-
- DriverHandler handler = driverService.createHandler(deviceId);
- ExtensionSelectorResolver selectorResolver = handler.behaviour(ExtensionSelectorResolver.class);
- ExtensionSelector nshSpiSelector = selectorResolver.getExtensionSelector(NICIRA_MATCH_NSH_SPI.type());
- ExtensionSelector nshSiSelector = selectorResolver.getExtensionSelector(NICIRA_MATCH_NSH_SI.type());
-
- try {
- nshSpiSelector.setPropertyValue("nshSpi", nshSpiId);
- } catch (Exception e) {
- log.error("Failed to set extension selector to match Nsh Spi Id for end rule {}", e.getMessage());
- }
- try {
- nshSiSelector.setPropertyValue("nshSi", NshServiceIndex.of(nshSi));
- } catch (Exception e) {
- log.error("Failed to set extension selector to match Nsh Si Id for end rule {}", e.getMessage());
- }
-
- TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
- selector.extension(nshSpiSelector, deviceId);
- selector.extension(nshSiSelector, deviceId);
-
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.transition(ENCAP_OUTPUT_TABLE);
-
- sendSfcRule(selector, treatment, deviceId, type, DEFAULT_FORWARDER_PRIORITY);
- }
-
- public void installSfcTunnelSendRule(DeviceId deviceId, NshServicePathId nshSpiId, Objective.Operation type) {
-
- // Prepare selector with nsp, nsi and inport from egress of port pair
- DriverHandler handler = driverService.createHandler(deviceId);
- ExtensionSelectorResolver selectorResolver = handler.behaviour(ExtensionSelectorResolver.class);
- ExtensionSelector nshSpiSelector = selectorResolver.getExtensionSelector(NICIRA_MATCH_NSH_SPI.type());
- ExtensionSelector nshSiSelector = selectorResolver.getExtensionSelector(NICIRA_MATCH_NSH_SI.type());
- ExtensionSelector encapEthTypeSelector = selectorResolver.getExtensionSelector(NICIRA_MATCH_ENCAP_ETH_TYPE
- .type());
- try {
- nshSpiSelector.setPropertyValue("nshSpi", nshSpiId);
- } catch (Exception e) {
- log.error("Failed to set extension selector to match Nsh Spi Id for end rule {}", e.getMessage());
- }
- try {
- nshSiSelector.setPropertyValue("nshSi", NshServiceIndex.of(nshSi));
- } catch (Exception e) {
- log.error("Failed to set extension selector to match Nsh Si Id for end rule {}", e.getMessage());
- }
- try {
- encapEthTypeSelector.setPropertyValue("encapEthType", ENCAP_ETH_TYPE);
- } catch (Exception e) {
- log.error("Failed to set extension selector to match encapEthType {}", deviceId);
- }
-
- TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
- selector.extension(nshSpiSelector, deviceId);
- selector.extension(nshSiSelector, deviceId);
-
- ExtensionTreatmentResolver treatmentResolver = handler.behaviour(ExtensionTreatmentResolver.class);
- ExtensionTreatment tunGpeNpTreatment = treatmentResolver.getExtensionInstruction(NICIRA_TUN_GPE_NP.type());
- try {
- tunGpeNpTreatment.setPropertyValue("tunGpeNp", ((byte) 4));
- } catch (Exception e) {
- log.error("Failed to get extension instruction to set tunGpeNp {}", deviceId);
- }
-
- ExtensionTreatment moveC1ToC1 = treatmentResolver
- .getExtensionInstruction(ExtensionTreatmentType.ExtensionTreatmentTypes
- .NICIRA_MOV_NSH_C1_TO_C1.type());
-
- ExtensionTreatment moveC2ToC2 = treatmentResolver
- .getExtensionInstruction(ExtensionTreatmentType.ExtensionTreatmentTypes
- .NICIRA_MOV_NSH_C2_TO_C2.type());
-
- ExtensionTreatment moveC3ToC3 = treatmentResolver
- .getExtensionInstruction(ExtensionTreatmentType.ExtensionTreatmentTypes
- .NICIRA_MOV_NSH_C3_TO_C3.type());
-
- ExtensionTreatment moveC4ToC4 = treatmentResolver
- .getExtensionInstruction(ExtensionTreatmentType.ExtensionTreatmentTypes
- .NICIRA_MOV_NSH_C4_TO_C4.type());
-
- ExtensionTreatment moveTunIpv4DstToTunIpv4Dst = treatmentResolver
- .getExtensionInstruction(ExtensionTreatmentType.ExtensionTreatmentTypes
- .NICIRA_MOV_TUN_IPV4_DST_TO_TUN_IPV4_DST.type());
-
- ExtensionTreatment moveTunIdToTunId = treatmentResolver
- .getExtensionInstruction(ExtensionTreatmentType.ExtensionTreatmentTypes
- .NICIRA_MOV_TUN_ID_TO_TUN_ID.type());
-
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.extension(tunGpeNpTreatment, deviceId);
- treatment.extension(moveC1ToC1, deviceId);
- treatment.extension(moveC2ToC2, deviceId);
- treatment.extension(moveC3ToC3, deviceId);
- treatment.extension(moveC4ToC4, deviceId);
- treatment.extension(moveTunIpv4DstToTunIpv4Dst, deviceId);
- treatment.extension(moveTunIdToTunId, deviceId);
-
- Iterable<Device> devices = deviceService.getAvailableDevices();
- DeviceId localControllerId = getControllerId(deviceService.getDevice(deviceId), devices);
- DriverHandler controllerHandler = driverService.createHandler(localControllerId);
-
- BridgeConfig bridgeConfig = controllerHandler.behaviour(BridgeConfig.class);
- Set<PortNumber> ports = bridgeConfig.getPortNumbers();
- String tunnelName = "vxlan-" + DEFAULT_IP;
- ports.stream()
- .filter(p -> p.name().equalsIgnoreCase(tunnelName))
- .forEach(p -> {
- treatment.setOutput(p);
- sendSfcRule(selector, treatment, deviceId, type, TUNNEL_SEND_PRIORITY);
- });
- }
-
- public void installSfcEndRule(PortPair portPair, NshServicePathId nshSpiId, Objective.Operation type) {
- DeviceId deviceId = vtnRscService.getSfToSffMaping(VirtualPortId.portId(portPair.egress()));
- MacAddress srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.egress())).macAddress();
- Host host = hostService.getHost(HostId.hostId(srcMacAddress));
- PortNumber port = host.location().port();
-
- // Prepare selector with nsp, nsi and inport from egress of port pair
- DriverHandler handler = driverService.createHandler(deviceId);
- ExtensionSelectorResolver selectorResolver = handler.behaviour(ExtensionSelectorResolver.class);
- ExtensionSelector nshSpiSelector = selectorResolver.getExtensionSelector(NICIRA_MATCH_NSH_SPI.type());
- ExtensionSelector nshSiSelector = selectorResolver.getExtensionSelector(NICIRA_MATCH_NSH_SI.type());
- ExtensionSelector encapEthTypeSelector = selectorResolver.getExtensionSelector(NICIRA_MATCH_ENCAP_ETH_TYPE
- .type());
- try {
- nshSpiSelector.setPropertyValue("nshSpi", nshSpiId);
- } catch (Exception e) {
- log.error("Failed to set extension selector to match Nsh Spi Id for end rule {}", e.getMessage());
- }
- // Decrement the SI
- nshSi = (short) (nshSi - 1);
- try {
- nshSiSelector.setPropertyValue("nshSi", NshServiceIndex.of(nshSi));
- } catch (Exception e) {
- log.error("Failed to set extension selector to match Nsh Si Id for end rule {}", e.getMessage());
- }
- try {
- encapEthTypeSelector.setPropertyValue("encapEthType", ENCAP_ETH_TYPE);
- } catch (Exception e) {
- log.error("Failed to set extension selector to match encapEthType {}", deviceId);
- }
- TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
- selector.extension(encapEthTypeSelector, deviceId);
- selector.extension(nshSpiSelector, deviceId);
- selector.extension(nshSiSelector, deviceId);
- selector.matchInPort(port);
-
- // Set treatment to pop nsh header, set tunnel id and resubmit to table
- // 0.
- ExtensionTreatmentResolver treatmentResolver = handler.behaviour(ExtensionTreatmentResolver.class);
- ExtensionTreatment popNshTreatment = treatmentResolver.getExtensionInstruction(NICIRA_POP_NSH.type());
-
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.extension(popNshTreatment, deviceId);
-
- VirtualPort virtualPort = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress()));
- SegmentationId segmentationId = tenantNetworkService.getNetwork(virtualPort.networkId()).segmentationId();
- treatment.add(Instructions.modTunnelId(Long.parseLong(segmentationId.toString())));
-
- ExtensionTreatment resubmitTableTreatment = treatmentResolver.getExtensionInstruction(NICIRA_RESUBMIT_TABLE
- .type());
-
- PortNumber vxlanPortNumber = getVxlanPortNumber(deviceId);
-
- try {
- resubmitTableTreatment.setPropertyValue("inPort", vxlanPortNumber);
- } catch (Exception e) {
- log.error("Failed to set extension treatment for resubmit table in port {}", deviceId);
- }
- try {
- resubmitTableTreatment.setPropertyValue("table", ((short) 0));
- } catch (Exception e) {
- log.error("Failed to set extension treatment for resubmit table {}", deviceId);
- }
- treatment.extension(resubmitTableTreatment, deviceId);
-
- sendSfcRule(selector, treatment, deviceId, type, DEFAULT_FORWARDER_PRIORITY);
- }
-
- public void installSfcForwardRule(PortPair portPair, PortPair nextPortPair, NshServicePathId nshSpiId,
- Objective.Operation type) {
- DeviceId deviceId = vtnRscService.getSfToSffMaping(VirtualPortId.portId(portPair.egress()));
- MacAddress srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.egress())).macAddress();
- Host host = hostService.getHost(HostId.hostId(srcMacAddress));
- PortNumber port = host.location().port();
-
- DriverHandler handler = driverService.createHandler(deviceId);
- ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class);
-
- // Prepare selector with nsp, nsi and inport from egress of port pair
- ExtensionSelector nshSpiSelector = resolver.getExtensionSelector(NICIRA_MATCH_NSH_SPI.type());
- ExtensionSelector nshSiSelector = resolver.getExtensionSelector(NICIRA_MATCH_NSH_SI.type());
- try {
- nshSpiSelector.setPropertyValue("nshSpi", nshSpiId);
- } catch (Exception e) {
- log.error("Failed to set extension selector to match Nsh Spi Id for forward rule {}", e.getMessage());
- }
- // Decrement the SI
- nshSi = (short) (nshSi - 1);
- try {
- nshSiSelector.setPropertyValue("nshSi", NshServiceIndex.of(nshSi));
- } catch (Exception e) {
- log.error("Failed to set extension selector to match Nsh Si Id for forward rule {}", e.getMessage());
- }
- TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
- selector.extension(nshSpiSelector, deviceId);
- selector.extension(nshSiSelector, deviceId);
- selector.matchInPort(port);
-
- DeviceId nextDeviceId = vtnRscService.getSfToSffMaping(VirtualPortId.portId(nextPortPair.ingress()));
- if (deviceId.equals(nextDeviceId)) {
-
- // Treatment with transition
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.transition(ENCAP_OUTPUT_TABLE);
-
- sendSfcRule(selector, treatment, deviceId, type, DEFAULT_FORWARDER_PRIORITY);
- } else {
- // Treatment with with transition to send on tunnel
- ExtensionTreatmentResolver treatmentResolver = handler.behaviour(ExtensionTreatmentResolver.class);
- ExtensionTreatment moveC2ToTunId = treatmentResolver
- .getExtensionInstruction(ExtensionTreatmentType.ExtensionTreatmentTypes
- .NICIRA_MOV_NSH_C2_TO_TUN_ID.type());
-
- Device remoteDevice = deviceService.getDevice(nextDeviceId);
- String url = remoteDevice.annotations().value(SWITCH_CHANNEL_ID);
- String remoteControllerIp = url.substring(0, url.lastIndexOf(":"));
- if (remoteControllerIp == null) {
- log.error("Can't find remote controller of device: {}", nextDeviceId.toString());
- return;
- }
-
- ExtensionTreatment tunnelDsttreatment = treatmentResolver.getExtensionInstruction(NICIRA_SET_TUNNEL_DST
- .type());
- try {
- tunnelDsttreatment.setPropertyValue("tunnelDst", Ip4Address.valueOf(remoteControllerIp));
- } catch (Exception e) {
- log.error("Failed to get extension instruction to set tunnel dst {}", deviceId);
- }
-
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.extension(moveC2ToTunId, deviceId);
- treatment.extension(tunnelDsttreatment, deviceId);
- treatment.transition(TUNNEL_SEND_TABLE);
-
- sendSfcRule(selector, treatment, deviceId, type, DEFAULT_FORWARDER_PRIORITY);
-
- installSfcTunnelSendRule(deviceId, nshSpiId, type);
- installSfcTunnelReceiveRule(nextDeviceId, nshSpiId, type);
- }
- }
-
- public void installSfcEncapOutputRule(PortPair portPair, NshServicePathId nshSpiId, Objective.Operation type) {
-
- DeviceId deviceId = vtnRscService.getSfToSffMaping(VirtualPortId.portId(portPair.ingress()));
- MacAddress srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress())).macAddress();
- Host host = hostService.getHost(HostId.hostId(srcMacAddress));
- PortNumber port = host.location().port();
-
- DriverHandler handler = driverService.createHandler(deviceId);
- ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class);
-
- // Prepare selector with nsp, nsi and encap eth type
- ExtensionSelector nshSpiSelector = resolver.getExtensionSelector(NICIRA_MATCH_NSH_SPI.type());
- ExtensionSelector nshSiSelector = resolver.getExtensionSelector(NICIRA_MATCH_NSH_SI.type());
- ExtensionSelector nshEncapEthTypeSelector = resolver.getExtensionSelector(NICIRA_MATCH_ENCAP_ETH_TYPE.type());
-
- try {
- nshSpiSelector.setPropertyValue("nshSpi", nshSpiId);
- } catch (Exception e) {
- log.error("Failed to set extension selector to match Nsh Spi Id for encap rule {}", e.getMessage());
- }
- try {
- nshSiSelector.setPropertyValue("nshSi", NshServiceIndex.of(nshSi));
- } catch (Exception e) {
- log.error("Failed to set extension selector to match Nsh Si Id for encap rule {}", e.getMessage());
- }
- try {
- nshEncapEthTypeSelector.setPropertyValue("encapEthType", ENCAP_ETH_TYPE);
- } catch (Exception e) {
- log.error("Failed to set extension selector to match Nsh Si Id {}", deviceId);
- }
- TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
- selector.extension(nshSpiSelector, deviceId);
- selector.extension(nshSiSelector, deviceId);
-
- ExtensionTreatmentResolver treatmentResolver = handler.behaviour(ExtensionTreatmentResolver.class);
- ExtensionTreatment encapEthSrcTreatment = treatmentResolver
- .getExtensionInstruction(NICIRA_ENCAP_ETH_SRC.type());
- ExtensionTreatment encapEthDstTreatment = treatmentResolver
- .getExtensionInstruction(NICIRA_ENCAP_ETH_DST.type());
-
- try {
- encapEthDstTreatment.setPropertyValue("encapEthDst", srcMacAddress);
- } catch (Exception e) {
- log.error("Failed to set extension treatment to set encap eth dst {}", deviceId);
- }
- // TODO: move from packet source mac address
- try {
- encapEthSrcTreatment.setPropertyValue("encapEthSrc", srcMacAddress);
- } catch (Exception e) {
- log.error("Failed to set extension treatment to set encap eth src {}", deviceId);
- }
-
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.extension(encapEthSrcTreatment, deviceId);
- treatment.extension(encapEthDstTreatment, deviceId);
- treatment.setOutput(port);
-
- sendSfcRule(selector, treatment, deviceId, type, ENCAP_OUTPUT_PRIORITY);
- forwarderList.add(deviceId);
- }
-
- public ConnectPoint installSfcClassifierRules(PortChain portChain, PortPair portPair, NshServicePathId nshSpiId,
- FiveTuple fiveTuple, Objective.Operation type) {
-
- DeviceId deviceIdfromPortPair = vtnRscService.getSfToSffMaping(VirtualPortId.portId(portPair.ingress()));
- MacAddress srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress())).macAddress();
- VirtualPort virtualPort = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress()));
- Host host = hostService.getHost(HostId.hostId(srcMacAddress));
- PortNumber port = host.location().port();
-
- DeviceId deviceId = deviceIdfromPortPair;
-
- // get flow classifiers
- List<FlowClassifierId> llFlowClassifierList = portChain.flowClassifiers();
- ListIterator<FlowClassifierId> flowClassifierListIterator = llFlowClassifierList.listIterator();
-
- while (flowClassifierListIterator.hasNext()) {
- FlowClassifierId flowclassifierId = flowClassifierListIterator.next();
- FlowClassifier flowClassifier = flowClassifierService.getFlowClassifier(flowclassifierId);
-
- if ((flowClassifier.srcPort() != null) && (!flowClassifier.srcPort().portId().isEmpty())) {
- deviceId = vtnRscService.getSfToSffMaping(flowClassifier.srcPort());
- }
-
- // Build Traffic selector.
- TrafficSelector.Builder selector = packClassifierSelector(flowClassifier, fiveTuple);
-
- if (fiveTuple == null) {
- // Send the packet to controller
- log.info("Downloading rule to send packet to controller");
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.setOutput(PortNumber.CONTROLLER);
- sendSfcRule(selector, treatment, deviceId, type, FLOW_CLASSIFIER_PRIORITY);
- continue;
- }
-
- if (deviceId != null && !deviceId.equals(deviceIdfromPortPair)) {
- // First SF is in another device. Set tunnel ipv4 destination to
- // treatment
- Device remoteDevice = deviceService.getDevice(deviceIdfromPortPair);
- String url = remoteDevice.annotations().value(SWITCH_CHANNEL_ID);
- String remoteControllerIp = url.substring(0, url.lastIndexOf(":"));
- if (remoteControllerIp == null) {
- log.error("Can't find remote controller of device: {}", deviceIdfromPortPair.toString());
- return null;
- }
-
- DriverHandler handler = driverService.createHandler(deviceId);
- ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class);
- ExtensionTreatment tunnelDsttreatment = resolver.getExtensionInstruction(NICIRA_SET_TUNNEL_DST.type());
- try {
- tunnelDsttreatment.setPropertyValue("tunnelDst", Ip4Address.valueOf(remoteControllerIp));
- } catch (Exception e) {
- log.error("Failed to get extension instruction to set tunnel dst {}", deviceId);
- }
-
- TrafficTreatment.Builder treatment = packClassifierTreatment(deviceId, virtualPort, port,
- nshSpiId, flowClassifier);
- treatment.extension(tunnelDsttreatment, deviceId);
- treatment.transition(TUNNEL_SEND_TABLE);
- sendSfcRule(selector, treatment, deviceId, type, flowClassifier.priority());
-
- selector.matchInPort(PortNumber.CONTROLLER);
- sendSfcRule(selector, treatment, deviceId, type, flowClassifier.priority());
- classifierList.add(deviceId);
-
- installSfcTunnelSendRule(deviceId, nshSpiId, type);
- installSfcTunnelReceiveRule(deviceIdfromPortPair, nshSpiId, type);
-
- } else {
- // classifier and port pair are in the same OVS. So directly
- // send packet to first port pair
- TrafficTreatment.Builder treatment = packClassifierTreatment(deviceIdfromPortPair, virtualPort, port,
- nshSpiId, flowClassifier);
- treatment.transition(ENCAP_OUTPUT_TABLE);
- sendSfcRule(selector, treatment, deviceIdfromPortPair, type, flowClassifier.priority());
-
- selector.matchInPort(PortNumber.CONTROLLER);
- sendSfcRule(selector, treatment, deviceId, type, flowClassifier.priority());
- classifierList.add(deviceIdfromPortPair);
- }
- }
-
- return host.location();
- }
-
- /**
- * Pack Traffic selector.
- *
- * @param flowClassifier flow-classifier
- * @param fiveTuple five tuple info for the packet
- * @return traffic selector
- */
- public TrafficSelector.Builder packClassifierSelector(FlowClassifier flowClassifier, FiveTuple fiveTuple) {
-
- TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
-
- if ((flowClassifier.srcIpPrefix() != null) && (flowClassifier.srcIpPrefix().prefixLength() != 0)) {
- selector.matchIPSrc(flowClassifier.srcIpPrefix());
- } else if (fiveTuple != null && fiveTuple.ipSrc() != null) {
- selector.matchIPSrc(IpPrefix.valueOf(fiveTuple.ipSrc(), 24));
- }
-
- if ((flowClassifier.dstIpPrefix() != null) && (flowClassifier.dstIpPrefix().prefixLength() != 0)) {
- selector.matchIPDst(flowClassifier.dstIpPrefix());
- } else if (fiveTuple != null && fiveTuple.ipDst() != null) {
- selector.matchIPDst(IpPrefix.valueOf(fiveTuple.ipDst(), 24));
- }
-
- if ((flowClassifier.protocol() != null) && (!flowClassifier.protocol().isEmpty())) {
- if ("TCP".equalsIgnoreCase(flowClassifier.protocol())) {
- selector.add(Criteria.matchIPProtocol(IPv4.PROTOCOL_TCP));
- } else if ("UDP".equalsIgnoreCase(flowClassifier.protocol())) {
- selector.add(Criteria.matchIPProtocol(IPv4.PROTOCOL_UDP));
- } else if ("ICMP".equalsIgnoreCase(flowClassifier.protocol())) {
- selector.add(Criteria.matchIPProtocol(IPv4.PROTOCOL_ICMP));
- }
- } else if (fiveTuple != null && fiveTuple.protocol() != 0) {
- selector.add(Criteria.matchIPProtocol(fiveTuple.protocol()));
- }
-
- if (((flowClassifier.etherType() != null) && (!flowClassifier.etherType().isEmpty()))
- && ("IPv4".equals(flowClassifier.etherType()) || "IPv6".equals(flowClassifier.etherType()))) {
- if ("IPv4".equals(flowClassifier.etherType())) {
- selector.matchEthType(Ethernet.TYPE_IPV4);
- } else {
- selector.matchEthType(Ethernet.TYPE_IPV6);
- }
- }
-
- if ((flowClassifier.srcPort() != null) && (!flowClassifier.srcPort().portId().isEmpty())) {
- VirtualPortId vPortId = VirtualPortId.portId(flowClassifier.srcPort().portId());
- MacAddress macAddress = virtualPortService.getPort(vPortId).macAddress();
- Host host = hostService.getHost(HostId.hostId(macAddress));
- selector.matchInPort(host.location().port());
- }
-
- // Take the port information from five tuple only when the protocol is
- // TCP.
- if (fiveTuple != null && fiveTuple.protocol() == IPv4.PROTOCOL_TCP) {
- selector.matchTcpSrc(TpPort.tpPort((int) fiveTuple.portSrc().toLong()));
- selector.matchTcpDst(TpPort.tpPort((int) fiveTuple.portDst().toLong()));
- } else {
- // For udp packets take the port information from flow classifier
- List<TpPort> srcPortRange = new LinkedList<>();
- List<TpPort> dstPortRange = new LinkedList<>();
- if ((flowClassifier.minSrcPortRange() != 0) && flowClassifier.maxSrcPortRange() != 0
- && flowClassifier.minDstPortRange() != 0 && flowClassifier.maxDstPortRange() != 0) {
-
- for (int port = flowClassifier.minSrcPortRange(); port <= flowClassifier.maxSrcPortRange(); port++) {
- srcPortRange.add(TpPort.tpPort(port));
- }
- for (int port = flowClassifier.minDstPortRange(); port <= flowClassifier.maxDstPortRange(); port++) {
- dstPortRange.add(TpPort.tpPort(port));
- }
- }
-
- for (TpPort inPort : srcPortRange) {
- selector.matchUdpSrc(inPort);
- }
- for (TpPort outPort : dstPortRange) {
- selector.matchUdpDst(outPort);
- }
- }
- return selector;
- }
-
- /**
- * Pack traffic treatment.
- *
- * @param deviceId device id
- * @param virtualPort virtual port
- * @param port port number
- * @param nshSpi nsh spi
- * @param flowClassifier flow-classifier
- * @return traffic treatment
- */
- public TrafficTreatment.Builder packClassifierTreatment(DeviceId deviceId, VirtualPort virtualPort,
- PortNumber port, NshServicePathId nshSpi, FlowClassifier flowClassifier) {
-
- TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
-
- // set tunnel id
- SegmentationId segmentationId = tenantNetworkService.getNetwork(virtualPort.networkId()).segmentationId();
- treatmentBuilder.add(Instructions.modTunnelId(Long.parseLong(segmentationId.toString())));
-
- // Set all NSH header fields
- DriverHandler handler = driverService.createHandler(deviceId);
- ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class);
- ExtensionTreatment nspIdTreatment = resolver.getExtensionInstruction(NICIRA_SET_NSH_SPI.type());
- ExtensionTreatment nsiIdTreatment = resolver.getExtensionInstruction(NICIRA_SET_NSH_SI.type());
- ExtensionTreatment pushNshTreatment = resolver.getExtensionInstruction(NICIRA_PUSH_NSH.type());
-
- ExtensionTreatment nshCh1Treatment = resolver.getExtensionInstruction(NICIRA_SET_NSH_CH1.type());
- ExtensionTreatment nshCh2Treatment = resolver.getExtensionInstruction(NICIRA_SET_NSH_CH2.type());
- ExtensionTreatment nshCh3Treatment = resolver.getExtensionInstruction(NICIRA_SET_NSH_CH3.type());
- ExtensionTreatment nshCh4Treatment = resolver.getExtensionInstruction(NICIRA_SET_NSH_CH4.type());
- ExtensionTreatment nshMdTypeTreatment = resolver.getExtensionInstruction(NICIRA_NSH_MDTYPE.type());
- ExtensionTreatment nshNpTreatment = resolver.getExtensionInstruction(NICIRA_NSH_NP.type());
-
- try {
- nshMdTypeTreatment.setPropertyValue("nshMdType", ((byte) 1));
- } catch (Exception e) {
- log.error("Failed to get extension instruction to set nshMdType {}", deviceId);
- }
- try {
- nshNpTreatment.setPropertyValue("nshNp", ((byte) 3));
- } catch (Exception e) {
- log.error("Failed to get extension instruction to set nshNp {}", deviceId);
- }
- try {
- nspIdTreatment.setPropertyValue("nshSpi", nshSpi);
- } catch (Exception e) {
- log.error("Failed to get extension instruction to set Nsh Spi Id {}", deviceId);
- }
- try {
- nsiIdTreatment.setPropertyValue("nshSi", NshServiceIndex.of(nshSi));
- } catch (Exception e) {
- log.error("Failed to get extension instruction to set Nsh Si Id {}", deviceId);
- }
- try {
- nshCh1Treatment.setPropertyValue("nshCh", NshContextHeader.of(1));
- } catch (Exception e) {
- log.error("Failed to get extension instruction to set NshCh1 {}", deviceId);
- }
- try {
- nshCh2Treatment.setPropertyValue("nshCh", NshContextHeader.of(Integer.parseInt(segmentationId.toString())));
- } catch (Exception e) {
- log.error("Failed to get extension instruction to set NshCh2 {}", deviceId);
- }
- try {
- nshCh3Treatment.setPropertyValue("nshCh", NshContextHeader.of(3));
- } catch (Exception e) {
- log.error("Failed to get extension instruction to set NshCh3 {}", deviceId);
- }
- try {
- nshCh4Treatment.setPropertyValue("nshCh", NshContextHeader.of(4));
- } catch (Exception e) {
- log.error("Failed to get extension instruction to set NshCh4 {}", deviceId);
- }
- treatmentBuilder.extension(pushNshTreatment, deviceId);
- treatmentBuilder.extension(nshMdTypeTreatment, deviceId);
- treatmentBuilder.extension(nshNpTreatment, deviceId);
- treatmentBuilder.extension(nspIdTreatment, deviceId);
- treatmentBuilder.extension(nsiIdTreatment, deviceId);
- treatmentBuilder.extension(nshCh1Treatment, deviceId);
- treatmentBuilder.extension(nshCh2Treatment, deviceId);
- treatmentBuilder.extension(nshCh3Treatment, deviceId);
- treatmentBuilder.extension(nshCh4Treatment, deviceId);
-
- return treatmentBuilder;
- }
-
- /**
- * Get the ControllerId from the device .
- *
- * @param device Device
- * @param devices Devices
- * @return Controller Id
- */
- public DeviceId getControllerId(Device device, Iterable<Device> devices) {
- for (Device d : devices) {
- if (d.type() == Device.Type.CONTROLLER && d.id().toString()
- .contains(getControllerIpOfSwitch(device))) {
- return d.id();
- }
- }
- log.info("Can not find controller for device : {}", device.id());
- return null;
- }
-
- /**
- * Get the ControllerIp from the device .
- *
- * @param device Device
- * @return Controller Ip
- */
- public String getControllerIpOfSwitch(Device device) {
- String url = device.annotations().value(SWITCH_CHANNEL_ID);
- return url.substring(0, url.lastIndexOf(":"));
- }
-
- /**
- * Send service-function-forwarder to OVS.
- *
- * @param selector traffic selector
- * @param treatment traffic treatment
- * @param deviceId device id
- * @param type operation type
- * @param priority priority of classifier
- */
- public void sendSfcRule(TrafficSelector.Builder selector, TrafficTreatment.Builder treatment, DeviceId deviceId,
- Objective.Operation type, int priority) {
-
- log.info("Sending sfc flow rule. Selector {}, Treatment {}", selector.toString(),
- treatment.toString());
- ForwardingObjective.Builder objective = DefaultForwardingObjective.builder().withTreatment(treatment.build())
- .withSelector(selector.build()).fromApp(appId).makePermanent().withFlag(Flag.VERSATILE)
- .withPriority(priority);
-
- if (type.equals(Objective.Operation.ADD)) {
- log.debug("flowClassifierRules-->ADD");
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- log.debug("flowClassifierRules-->REMOVE");
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-
- private PortNumber getVxlanPortNumber(DeviceId deviceId) {
- Iterable<Port> ports = deviceService.getPorts(deviceId);
- Port vxlanPort = Sets.newHashSet(ports).stream()
- .filter(p -> !p.number().equals(PortNumber.LOCAL))
- .filter(p -> p.annotations().value(AnnotationKeys.PORT_NAME)
- .startsWith(VXLANPORT_HEAD))
- .findFirst().get();
- return vxlanPort.number();
- }
-}
diff --git a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/package-info.java b/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/package-info.java
deleted file mode 100644
index dd047f4..0000000
--- a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of Service for installing flow classifier rules in OVS.
- */
-package org.onosproject.sfc.installer.impl;
diff --git a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/package-info.java b/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/package-info.java
deleted file mode 100644
index 989a676..0000000
--- a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/installer/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for installing flow classifier rules in OVS.
- */
-package org.onosproject.sfc.installer;
diff --git a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/SfcService.java b/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/SfcService.java
deleted file mode 100644
index 231438a..0000000
--- a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/SfcService.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.manager;
-
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.PortChain;
-
-/**
- * SFC application that applies flows to the device.
- */
-public interface SfcService {
-
- /**
- * When port-pair is created, check whether Forwarding Rule needs to be
- * updated in OVS.
- *
- * @param portPair port-pair
- */
- void onPortPairCreated(PortPair portPair);
-
- /**
- * When port-pair is deleted, check whether Forwarding Rule needs to be
- * updated in OVS.
- *
- * @param portPair port-pair
- */
- void onPortPairDeleted(PortPair portPair);
-
- /**
- * When port-pair-group is created, check whether Forwarding Rule needs to
- * be updated in OVS.
- *
- * @param portPairGroup port-pair-group
- */
- void onPortPairGroupCreated(PortPairGroup portPairGroup);
-
- /**
- * When port-pair-group is deleted, check whether Forwarding Rule needs to
- * be updated in OVS.
- *
- * @param portPairGroup port-pair-group
- */
- void onPortPairGroupDeleted(PortPairGroup portPairGroup);
-
- /**
- * When flow-classifier is created, check whether Forwarding Rule needs to
- * be updated in OVS.
- *
- * @param flowClassifier flow-classifier
- */
- void onFlowClassifierCreated(FlowClassifier flowClassifier);
-
- /**
- * When flow-classifier is deleted, check whether Forwarding Rule needs to
- * be updated in OVS.
- *
- * @param flowClassifier flow-classifier
- */
- void onFlowClassifierDeleted(FlowClassifier flowClassifier);
-
- /**
- * When port-chain is created, check whether Forwarding Rule needs to be
- * updated in OVS.
- *
- * @param portChain port-chain
- */
- void onPortChainCreated(PortChain portChain);
-
- /**
- * When port-chain is deleted, check whether Forwarding Rule needs to be
- * updated in OVS.
- *
- * @param portChain port-chain
- */
- void onPortChainDeleted(PortChain portChain);
-}
diff --git a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/SfcManager.java b/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/SfcManager.java
deleted file mode 100644
index d403502..0000000
--- a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/SfcManager.java
+++ /dev/null
@@ -1,675 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.manager.impl;
-
-import com.google.common.collect.Lists;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.TCP;
-import org.onlab.packet.UDP;
-import org.onlab.util.ItemNotFoundException;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.core.IdGenerator;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.NshServicePathId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.packet.DefaultOutboundPacket;
-import org.onosproject.net.packet.OutboundPacket;
-import org.onosproject.net.packet.PacketContext;
-import org.onosproject.net.packet.PacketProcessor;
-import org.onosproject.net.packet.PacketService;
-import org.onosproject.sfc.installer.impl.SfcFlowRuleInstallerImpl;
-import org.onosproject.sfc.manager.SfcService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.DistributedSet;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.onosproject.vtnrsc.DefaultFiveTuple;
-import org.onosproject.vtnrsc.FiveTuple;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.LoadBalanceId;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.event.VtnRscEvent;
-import org.onosproject.vtnrsc.event.VtnRscListener;
-import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService;
-import org.onosproject.vtnrsc.portchain.PortChainService;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
-import org.onosproject.vtnrsc.service.VtnRscService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Set;
-import java.util.UUID;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of SFC Service.
- */
-@Component(immediate = true, service = SfcService.class)
-public class SfcManager implements SfcService {
-
- private final Logger log = getLogger(getClass());
-
- private String nshSpiIdTopic = "nsh-spi-id";
- private static final String APP_ID = "org.onosproject.app.vtn";
- private static final int SFC_PRIORITY = 1000;
- private static final int MAX_NSH_SPI_ID = 0x7FFFF;
- private static final int MAX_LOAD_BALANCE_ID = 0x20;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected VtnRscService vtnRscService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PacketService packetService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PortChainService portChainService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PortPairGroupService portPairGroupService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected FlowClassifierService flowClassifierService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected VirtualPortService virtualPortService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- protected SfcPacketProcessor processor = new SfcPacketProcessor();
-
- protected ApplicationId appId;
- protected IdGenerator nshSpiIdGenerator;
- protected EventuallyConsistentMap<PortChainId, Integer> nshSpiPortChainMap;
- protected EventuallyConsistentMap<PortChainId, List<FiveTuple>> portChainFiveTupleMap;
- protected DistributedSet<Integer> nshSpiIdFreeList;
-
- private final VtnRscListener vtnRscListener = new InnerVtnRscListener();
-
- @Activate
- public void activate() {
- appId = coreService.registerApplication(APP_ID);
- nshSpiIdGenerator = coreService.getIdGenerator(nshSpiIdTopic);
-
- vtnRscService.addListener(vtnRscListener);
-
- KryoNamespace.Builder serializer = KryoNamespace
- .newBuilder()
- .register(PortChainId.class, UUID.class, FiveTuple.class, IpAddress.class, PortNumber.class,
- DefaultFiveTuple.class, IpAddress.Version.class, TenantId.class);
-
- nshSpiPortChainMap = storageService.<PortChainId, Integer>eventuallyConsistentMapBuilder()
- .withName("nshSpiPortChainMap").withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
-
- portChainFiveTupleMap = storageService.<PortChainId, List<FiveTuple>>eventuallyConsistentMapBuilder()
- .withName("portChainFiveTupleMap").withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
-
- nshSpiIdFreeList = storageService.<Integer>setBuilder()
- .withName("nshSpiIdDeletedList")
- .withSerializer(Serializer.using(KryoNamespaces.API))
- .build()
- .asDistributedSet();
-
- packetService.addProcessor(processor, PacketProcessor.director(SFC_PRIORITY));
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- vtnRscService.removeListener(vtnRscListener);
- packetService.removeProcessor(processor);
- log.info("Stopped");
- }
-
- /*
- * Handle events.
- */
- private class InnerVtnRscListener implements VtnRscListener {
- @Override
- public void event(VtnRscEvent event) {
-
- if (VtnRscEvent.Type.PORT_PAIR_PUT == event.type()) {
- PortPair portPair = event.subject().portPair();
- onPortPairCreated(portPair);
- } else if (VtnRscEvent.Type.PORT_PAIR_DELETE == event.type()) {
- PortPair portPair = event.subject().portPair();
- onPortPairDeleted(portPair);
- } else if (VtnRscEvent.Type.PORT_PAIR_UPDATE == event.type()) {
- PortPair portPair = event.subject().portPair();
- onPortPairDeleted(portPair);
- onPortPairCreated(portPair);
- } else if (VtnRscEvent.Type.PORT_PAIR_GROUP_PUT == event.type()) {
- PortPairGroup portPairGroup = event.subject().portPairGroup();
- onPortPairGroupCreated(portPairGroup);
- } else if (VtnRscEvent.Type.PORT_PAIR_GROUP_DELETE == event.type()) {
- PortPairGroup portPairGroup = event.subject().portPairGroup();
- onPortPairGroupDeleted(portPairGroup);
- } else if (VtnRscEvent.Type.PORT_PAIR_GROUP_UPDATE == event.type()) {
- PortPairGroup portPairGroup = event.subject().portPairGroup();
- onPortPairGroupDeleted(portPairGroup);
- onPortPairGroupCreated(portPairGroup);
- } else if (VtnRscEvent.Type.FLOW_CLASSIFIER_PUT == event.type()) {
- FlowClassifier flowClassifier = event.subject().flowClassifier();
- onFlowClassifierCreated(flowClassifier);
- } else if (VtnRscEvent.Type.FLOW_CLASSIFIER_DELETE == event.type()) {
- FlowClassifier flowClassifier = event.subject().flowClassifier();
- onFlowClassifierDeleted(flowClassifier);
- } else if (VtnRscEvent.Type.FLOW_CLASSIFIER_UPDATE == event.type()) {
- FlowClassifier flowClassifier = event.subject().flowClassifier();
- onFlowClassifierDeleted(flowClassifier);
- onFlowClassifierCreated(flowClassifier);
- } else if (VtnRscEvent.Type.PORT_CHAIN_PUT == event.type()) {
- PortChain portChain = event.subject().portChain();
- if (portChain.oldPortChain() != null) {
- onPortChainDeleted(portChain.oldPortChain());
- }
- onPortChainCreated(portChain);
- } else if (VtnRscEvent.Type.PORT_CHAIN_DELETE == event.type()) {
- PortChain portChain = event.subject().portChain();
- onPortChainDeleted(portChain);
- portChainFiveTupleMap.remove(portChain.portChainId());
- } else if (VtnRscEvent.Type.PORT_CHAIN_UPDATE == event.type()) {
- PortChain portChain = event.subject().portChain();
- onPortChainDeleted(portChain);
- onPortChainCreated(portChain);
- }
- }
- }
-
- @Override
- public void onPortPairCreated(PortPair portPair) {
- log.debug("onPortPairCreated");
- // Do nothing
- }
-
- @Override
- public void onPortPairDeleted(PortPair portPair) {
- log.debug("onPortPairDeleted");
- // Do nothing
- }
-
- @Override
- public void onPortPairGroupCreated(PortPairGroup portPairGroup) {
- log.debug("onPortPairGroupCreated");
- // Do nothing
- }
-
- @Override
- public void onPortPairGroupDeleted(PortPairGroup portPairGroup) {
- log.debug("onPortPairGroupDeleted");
- // Do nothing
- }
-
- @Override
- public void onFlowClassifierCreated(FlowClassifier flowClassifier) {
- log.debug("onFlowClassifierCreated");
- // Do nothing
- }
-
- @Override
- public void onFlowClassifierDeleted(FlowClassifier flowClassifier) {
- log.debug("onFlowClassifierDeleted");
- // Do nothing
- }
-
- @Override
- public void onPortChainCreated(PortChain portChain) {
- NshServicePathId nshSpi;
- log.info("On port chain created");
-
- int spi = getNextNshSpi();
- if (spi > MAX_NSH_SPI_ID) {
- log.error("Reached max limit of service path index." + "Failed to install SFC for port chain {}",
- portChain.portChainId().toString());
- return;
- }
- nshSpi = NshServicePathId.of(spi);
- nshSpiPortChainMap.put(portChain.portChainId(), new Integer(spi));
- if (!portChainFiveTupleMap.containsKey(portChain.portChainId())) {
- portChainFiveTupleMap.put(portChain.portChainId(), Lists.newArrayList());
- }
- // Install classifier rule to send the packet to controller
- SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl(appId);
- flowRuleInstaller.installFlowClassifier(portChain, nshSpi);
-
- // Install rules for already identified five tuples.
- List<FiveTuple> list = portChainFiveTupleMap.get(portChain.portChainId());
- for (FiveTuple fiveTuple : list) {
- LoadBalanceId id = loadBalanceSfc(portChain.portChainId(), fiveTuple);
- // Get nsh service path index
- nshSpi = NshServicePathId.of(getNshServicePathId(id, spi));
- // download the required flow rules for classifier and
- // forwarding
- flowRuleInstaller.installLoadBalancedFlowRules(portChain, fiveTuple, nshSpi);
- }
- }
-
- @Override
- public void onPortChainDeleted(PortChain portChain) {
- log.info("onPortChainDeleted");
- if (!nshSpiPortChainMap.containsKey(portChain.portChainId())) {
- throw new ItemNotFoundException("Unable to find NSH SPI");
- }
-
- int nshSpiId = nshSpiPortChainMap.get(portChain.portChainId());
- // Uninstall classifier rules
- SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl(appId);
- flowRuleInstaller.unInstallFlowClassifier(portChain, NshServicePathId.of(nshSpiId));
- // remove from nshSpiPortChainMap and add to nshSpiIdFreeList
- nshSpiPortChainMap.remove(portChain.portChainId());
- nshSpiIdFreeList.add(nshSpiId);
-
- // Uninstall load balanced classifier and forwarding rules.
- NshServicePathId nshSpi;
- LoadBalanceId id;
- List<LoadBalanceId> processedIdList = Lists.newArrayList();
- Set<FiveTuple> fiveTupleSet = portChain.getLoadBalanceIdMapKeys();
- for (FiveTuple fiveTuple : fiveTupleSet) {
- id = portChain.getLoadBalanceId(fiveTuple);
- nshSpi = NshServicePathId.of(getNshServicePathId(id, nshSpiId));
- if (processedIdList.contains(id)) {
- // Multiple five tuple can have single path. In this case only
- // the classifier rule need to delete
- flowRuleInstaller.unInstallLoadBalancedClassifierRules(portChain, fiveTuple, nshSpi);
- continue;
- } else {
- processedIdList.add(id);
- }
- flowRuleInstaller.unInstallLoadBalancedFlowRules(portChain, fiveTuple, nshSpi);
- }
-
- // Reset load for all the port pairs
- List<PortPairGroupId> ppgIdlist = portChain.portPairGroups();
- ListIterator<PortPairGroupId> ppgIdListIterator = ppgIdlist.listIterator();
- while (ppgIdListIterator.hasNext()) {
- PortPairGroupId portPairGroupId = ppgIdListIterator.next();
- PortPairGroup ppg = portPairGroupService.getPortPairGroup(portPairGroupId);
- ppg.resetLoad();
- }
- }
-
- /**
- * Get next nsh service path identifier.
- *
- * @return value of service path identifier
- */
- int getNextNshSpi() {
- // If there is any free id use it. Otherwise generate new id.
- if (nshSpiIdFreeList.isEmpty()) {
- return (int) nshSpiIdGenerator.getNewId();
- }
- Iterator<Integer> it = nshSpiIdFreeList.iterator();
- Integer value = it.next();
- nshSpiIdFreeList.remove(value);
- return value;
- }
-
- private class SfcPacketProcessor implements PacketProcessor {
-
- /**
- * Check for given ip match with the fixed ips for the virtual port.
- *
- * @param vPortId virtual port id
- * @param ip ip address to match
- * @return true if the ip match with the fixed ips in virtual port false otherwise
- */
- private boolean checkIpInVirtualPort(VirtualPortId vPortId, IpAddress ip) {
- boolean found = false;
- Set<FixedIp> ips = virtualPortService.getPort(vPortId).fixedIps();
- for (FixedIp fixedIp : ips) {
- if (fixedIp.ip().equals(ip)) {
- found = true;
- break;
- }
- }
- return found;
- }
-
- /**
- * Find the port chain for the received packet.
- *
- * @param fiveTuple five tuple info from the packet
- * @return portChainId id of port chain, null if portChain is not found
- */
- private PortChainId findPortChainFromFiveTuple(FiveTuple fiveTuple) {
-
- PortChainId portChainId = null;
-
- Iterable<PortChain> portChains = portChainService.getPortChains();
- if (portChains == null) {
- log.error("Could not retrieve port chain list");
- return null;
- }
-
- // Identify the port chain to which the packet belongs
- for (final PortChain portChain : portChains) {
-
- if (!portChain.tenantId().equals(fiveTuple.tenantId())) {
- continue;
- }
-
- Iterable<FlowClassifierId> flowClassifiers = portChain.flowClassifiers();
-
- // One port chain can have multiple flow classifiers.
- for (final FlowClassifierId flowClassifierId : flowClassifiers) {
-
- FlowClassifier flowClassifier = flowClassifierService.getFlowClassifier(flowClassifierId);
- boolean match = false;
- // Check whether protocol is set in flow classifier
- if (flowClassifier.protocol() != null) {
- if (("TCP".equalsIgnoreCase(flowClassifier.protocol())
- && fiveTuple.protocol() == IPv4.PROTOCOL_TCP)
- || ("UDP".equalsIgnoreCase(flowClassifier.protocol())
- && fiveTuple.protocol() == IPv4.PROTOCOL_UDP)
- || ("ICMP".equalsIgnoreCase(flowClassifier.protocol())
- && fiveTuple.protocol() == IPv4.PROTOCOL_ICMP)) {
- match = true;
- } else {
- continue;
- }
- }
-
- // Check whether source ip prefix is set in flow classifier
- if (flowClassifier.srcIpPrefix() != null) {
- if (flowClassifier.srcIpPrefix().contains(fiveTuple.ipSrc())) {
- match = true;
- } else {
- continue;
- }
- }
-
- // Check whether destination ip prefix is set in flow classifier
- if (flowClassifier.dstIpPrefix() != null) {
- if (flowClassifier.dstIpPrefix().contains(fiveTuple.ipDst())) {
- match = true;
- } else {
- continue;
- }
- }
-
- // Check whether source port is set in flow classifier
- if (fiveTuple.portSrc().toLong() >= flowClassifier.minSrcPortRange() &&
- fiveTuple.portSrc().toLong() <= flowClassifier.maxSrcPortRange()) {
- match = true;
- } else {
- continue;
- }
-
- // Check whether destination port is set in flow classifier
- if (fiveTuple.portDst().toLong() >= flowClassifier.minSrcPortRange() &&
- fiveTuple.portDst().toLong() <= flowClassifier.maxSrcPortRange()) {
- match = true;
- } else {
- continue;
- }
-
- // Check whether neutron source port is set in flow classifier
- if ((flowClassifier.srcPort() != null) && (!flowClassifier.srcPort().portId().isEmpty())) {
- match = checkIpInVirtualPort(VirtualPortId.portId(flowClassifier.srcPort().portId()),
- fiveTuple.ipSrc());
- if (!match) {
- continue;
- }
- }
-
- // Check whether destination neutron destination port is set in flow classifier
- if ((flowClassifier.dstPort() != null) && (!flowClassifier.dstPort().portId().isEmpty())) {
- match = checkIpInVirtualPort(VirtualPortId.portId(flowClassifier.dstPort().portId()),
- fiveTuple.ipDst());
- if (!match) {
- continue;
- }
- }
-
- if (match) {
- portChainId = portChain.portChainId();
- break;
- }
- }
- }
- return portChainId;
- }
-
- /**
- * Get the tenant id for the given mac address.
- *
- * @param mac mac address
- * @return tenantId tenant id for the given mac address
- */
- private TenantId getTenantId(MacAddress mac) {
- Collection<VirtualPort> virtualPorts = virtualPortService.getPorts();
- for (VirtualPort virtualPort : virtualPorts) {
- if (virtualPort.macAddress().equals(mac)) {
- return virtualPort.tenantId();
- }
- }
- return null;
- }
-
- @Override
- public void process(PacketContext context) {
- Ethernet packet = context.inPacket().parsed();
- if (packet == null || portChainService.getPortChainCount() == 0) {
- return;
- }
- // get the five tuple parameters for the packet
- short ethType = packet.getEtherType();
- IpAddress ipSrc = null;
- IpAddress ipDst = null;
- int portSrc = 0;
- int portDst = 0;
- byte protocol = 0;
- MacAddress macSrc = packet.getSourceMAC();
- MacAddress macDst = packet.getDestinationMAC();
- TenantId tenantId = getTenantId(macSrc);
-
- if (ethType == Ethernet.TYPE_IPV4) {
- IPv4 ipv4Packet = (IPv4) packet.getPayload();
- ipSrc = IpAddress.valueOf(ipv4Packet.getSourceAddress());
- ipDst = IpAddress.valueOf(ipv4Packet.getDestinationAddress());
- protocol = ipv4Packet.getProtocol();
- if (protocol == IPv4.PROTOCOL_TCP) {
- TCP tcpPacket = (TCP) ipv4Packet.getPayload();
- portSrc = tcpPacket.getSourcePort();
- portDst = tcpPacket.getDestinationPort();
- } else if (protocol == IPv4.PROTOCOL_UDP) {
- UDP udpPacket = (UDP) ipv4Packet.getPayload();
- portSrc = udpPacket.getSourcePort();
- portDst = udpPacket.getDestinationPort();
- } else if (protocol == IPv4.PROTOCOL_ICMP) {
- // do nothing
- } else {
- // No need to process other packets received by controller.
- return;
- }
- } else {
- return;
- }
-
- FiveTuple fiveTuple = DefaultFiveTuple.builder()
- .setIpSrc(ipSrc)
- .setIpDst(ipDst)
- .setPortSrc(PortNumber.portNumber(portSrc))
- .setPortDst(PortNumber.portNumber(portDst))
- .setProtocol(protocol)
- .setTenantId(tenantId)
- .setMacSrc(macSrc)
- .setMacDst(macDst)
- .build();
-
- PortChainId portChainId = findPortChainFromFiveTuple(fiveTuple);
-
- if (portChainId == null) {
- return;
- }
-
- // Once the 5 tuple and port chain are identified, give this input for load balancing
- addToPortChainIdFiveTupleMap(portChainId, fiveTuple);
- LoadBalanceId id = loadBalanceSfc(portChainId, fiveTuple);
- // Get nsh service path index
- NshServicePathId nshSpi;
- PortChain portChain = portChainService.getPortChain(portChainId);
- if (nshSpiPortChainMap.containsKey(portChain.portChainId())) {
- int nshSpiId = nshSpiPortChainMap.get(portChain.portChainId());
- nshSpi = NshServicePathId.of(getNshServicePathId(id, nshSpiId));
- } else {
- int nshSpiId = getNextNshSpi();
- if (nshSpiId > MAX_NSH_SPI_ID) {
- log.error("Reached max limit of service path index."
- + "Failed to install SFC for port chain {}", portChain.portChainId());
- return;
- }
- nshSpi = NshServicePathId.of(getNshServicePathId(id, nshSpiId));
- nshSpiPortChainMap.put(portChain.portChainId(), new Integer(nshSpiId));
- }
- // download the required flow rules for classifier and forwarding
- // install in OVS.
- SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl(appId);
- flowRuleInstaller.installLoadBalancedFlowRules(portChain, fiveTuple, nshSpi);
- sendPacket(context);
- }
-
- /**
- * Send packet back to classifier.
- *
- * @param context packet context
- */
- private void sendPacket(PacketContext context) {
-
- ConnectPoint sourcePoint = context.inPacket().receivedFrom();
-
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(PortNumber.TABLE).build();
- OutboundPacket packet = new DefaultOutboundPacket(sourcePoint.deviceId(), treatment, context.inPacket()
- .unparsed());
- packetService.emit(packet);
- log.trace("Sending packet: {}", packet);
- }
- }
-
- /**
- * Encapsulate 5 bit load balance id to nsh spi.
- *
- * @param id load balance identifier
- * @param nshSpiId nsh service path index
- * @return updated service path index
- */
- protected int getNshServicePathId(LoadBalanceId id, int nshSpiId) {
- int nshSpiNew = nshSpiId << 5;
- nshSpiNew = nshSpiNew | id.loadBalanceId();
- return nshSpiNew;
- }
-
- private void addToPortChainIdFiveTupleMap(PortChainId portChainId, FiveTuple fiveTuple) {
- List<FiveTuple> list = portChainFiveTupleMap.get(portChainId);
- list.add(fiveTuple);
- portChainFiveTupleMap.put(portChainId, list);
- }
-
- /**
- * Find the load balanced path set it to port chain for the given five
- * tuple.
- *
- * @param portChainId port chain id
- * @param fiveTuple five tuple info
- * @return load balance id
- */
- private LoadBalanceId loadBalanceSfc(PortChainId portChainId, FiveTuple fiveTuple) {
-
- // Get the port chain
- PortChain portChain = portChainService.getPortChain(portChainId);
- List<PortPairId> loadBalancePath = Lists.newArrayList();
- LoadBalanceId id;
- int paths = portChain.getLoadBalancePathSize();
- if (paths >= MAX_LOAD_BALANCE_ID) {
- log.info("Max limit reached for load balance paths. "
- + "Reusing the created path for port chain {} with five tuple {}", portChainId, fiveTuple);
- id = LoadBalanceId.of((byte) ((paths + 1) % MAX_LOAD_BALANCE_ID));
- portChain.addLoadBalancePath(fiveTuple, id, portChain.getLoadBalancePath(id));
- }
-
- // Get the list of port pair groups from port chain
- Iterable<PortPairGroupId> portPairGroups = portChain.portPairGroups();
- for (final PortPairGroupId portPairGroupId : portPairGroups) {
- PortPairGroup portPairGroup = portPairGroupService.getPortPairGroup(portPairGroupId);
-
- // Get the list of port pair ids from port pair group.
- Iterable<PortPairId> portPairs = portPairGroup.portPairs();
- int minLoad = 0xFFF;
- PortPairId minLoadPortPairId = null;
- for (final PortPairId portPairId : portPairs) {
- int load = portPairGroup.getLoad(portPairId);
- if (load == 0) {
- minLoadPortPairId = portPairId;
- break;
- } else {
- // Check the port pair which has min load.
- if (load < minLoad) {
- minLoad = load;
- minLoadPortPairId = portPairId;
- }
- }
- }
- if (minLoadPortPairId != null) {
- loadBalancePath.add(minLoadPortPairId);
- portPairGroup.addLoad(minLoadPortPairId);
- }
- }
-
- // Check if the path already exists, if not create a new id
- id = portChain.matchPath(loadBalancePath);
- if (id == null) {
- id = LoadBalanceId.of((byte) (paths + 1));
- }
-
- portChain.addLoadBalancePath(fiveTuple, id, loadBalancePath);
- return id;
- }
-
-}
diff --git a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/package-info.java b/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/package-info.java
deleted file mode 100644
index 99a01b0..0000000
--- a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * SFC Service manager for interacting with SFC.
- */
-package org.onosproject.sfc.manager.impl;
diff --git a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/package-info.java b/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/package-info.java
deleted file mode 100644
index 47d993a..0000000
--- a/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/manager/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with SFC.
- */
-package org.onosproject.sfc.manager;
diff --git a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/installer/impl/SfcFlowRuleInstallerImplTest.java b/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/installer/impl/SfcFlowRuleInstallerImplTest.java
deleted file mode 100644
index a984e5f..0000000
--- a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/installer/impl/SfcFlowRuleInstallerImplTest.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.installer.impl;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-import static org.onosproject.net.Device.Type.SWITCH;
-import static org.onosproject.net.Port.Type.COPPER;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.junit.Test;
-import org.onlab.packet.ChassisId;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.DefaultApplicationId;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultDevice;
-import org.onosproject.net.DefaultPort;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.HostLocation;
-import org.onosproject.net.NshServicePathId;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.device.DeviceServiceAdapter;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.net.flow.criteria.Criterion;
-import org.onosproject.net.flow.criteria.PortCriterion;
-import org.onosproject.net.flow.instructions.Instruction;
-import org.onosproject.net.flow.instructions.Instructions.OutputInstruction;
-import org.onosproject.net.flowobjective.FlowObjectiveServiceAdapter;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.host.HostService;
-import org.onosproject.net.host.HostServiceAdapter;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.sfc.util.FlowClassifierAdapter;
-import org.onosproject.sfc.util.MockDriverHandler;
-import org.onosproject.sfc.util.PortPairAdapter;
-import org.onosproject.sfc.util.PortPairGroupAdapter;
-import org.onosproject.sfc.util.TenantNetworkAdapter;
-import org.onosproject.sfc.util.VirtualPortAdapter;
-import org.onosproject.sfc.util.VtnRscAdapter;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.DefaultFiveTuple;
-import org.onosproject.vtnrsc.DefaultFlowClassifier;
-import org.onosproject.vtnrsc.DefaultPortChain;
-import org.onosproject.vtnrsc.DefaultPortPair;
-import org.onosproject.vtnrsc.DefaultPortPairGroup;
-import org.onosproject.vtnrsc.DefaultTenantNetwork;
-import org.onosproject.vtnrsc.DefaultVirtualPort;
-import org.onosproject.vtnrsc.FiveTuple;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.LoadBalanceId;
-import org.onosproject.vtnrsc.PhysicalNetwork;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.SecurityGroup;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService;
-import org.onosproject.vtnrsc.portpair.PortPairService;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
-import org.onosproject.vtnrsc.service.VtnRscService;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-public class SfcFlowRuleInstallerImplTest {
-
- FlowObjectiveService flowObjectiveService = new FlowObjectiveServiceAdapter();
- DeviceService deviceService = new DeviceServiceAdapter(createPortList());
-
- HostService hostService = new HostServiceAdapter();
- VirtualPortService virtualPortService = new VirtualPortAdapter();
- VtnRscService vtnRscService = new VtnRscAdapter();
- PortPairService portPairService = new PortPairAdapter();
- PortPairGroupService portPairGroupService = new PortPairGroupAdapter();
- FlowClassifierService flowClassifierService = new FlowClassifierAdapter();
- TenantNetworkService tenantNetworkService = new TenantNetworkAdapter();
-
- final DriverService driverService = createMock(DriverService.class);
-
- private final String networkIdStr = "123";
-
- final PortChainId portChainId = PortChainId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortChain";
- final String description = "PortChain";
- final List<PortPairGroupId> portPairGroups = new LinkedList<PortPairGroupId>();
- final List<FlowClassifierId> flowClassifiers = new LinkedList<FlowClassifierId>();
- PortPairGroupId portPairGroupId1 = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- PortPairGroupId portPairGroupId2 = PortPairGroupId.of("73343531-fc23-aeb6-f44b-56dc5e2fb3af");
-
- PortPairId portPairId1 = PortPairId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- PortPairId portPairId2 = PortPairId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae");
-
- FlowClassifierId flowClassifierId1 = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae");
- FlowClassifierId flowClassifierId2 = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3af");
-
- final String ppName = "PortPair";
- final String ppDescription = "PortPair";
- final String ingress = "d3333333-24fc-4fae-af4b-321c5e2eb3d1";
- final String egress = "a4444444-4a56-2a6e-cd3a-9dee4e2ec345";
-
- final String ppgName = "PortPairGroup";
- final String ppgDescription = "PortPairGroup";
- final List<PortPairId> portPairList = new LinkedList<PortPairId>();
-
- VirtualPortId id1 = VirtualPortId.portId(ingress);
- VirtualPortId id2 = VirtualPortId.portId("3414");
-
- DeviceId deviceId = DeviceId.deviceId("of:000000000000001");
-
- final DriverHandler driverHandler = new MockDriverHandler();
-
- private List<Port> createPortList() {
- List<Port> portList = Lists.newArrayList();
- long sp1 = 1_000_000;
- ProviderId pid = new ProviderId("of", "foo");
- ChassisId cid = new ChassisId();
- Device device = new DefaultDevice(pid, deviceId, SWITCH, "whitebox", "1.1.x", "3.9.1", "43311-12345", cid);
- Annotations annotations = DefaultAnnotations
- .builder()
- .set(AnnotationKeys.PORT_NAME, "vxlan-0.0.0.0").build();
- Port p1 = new DefaultPort(device, PortNumber.ANY, true, COPPER, sp1, annotations);
- portList.add(p1);
- return portList;
- }
-
- private PortPair createPortPair(PortPairId ppId) {
- DefaultPortPair.Builder portPairBuilder = new DefaultPortPair.Builder();
- PortPair portPair = portPairBuilder.setId(ppId).setName(ppName).setTenantId(tenantId)
- .setDescription(ppDescription).setIngress(ingress).setEgress(egress).build();
- return portPair;
- }
-
- private PortPairGroup createPortPairGroup(PortPairGroupId ppgId) {
-
- portPairList.clear();
- // Create same two port-pair-group objects.
- portPairList.add(portPairId1);
- portPairList.add(portPairId2);
-
- DefaultPortPairGroup.Builder portPairGroupBuilder = new DefaultPortPairGroup.Builder();
- PortPairGroup portPairGroup = portPairGroupBuilder.setId(ppgId).setTenantId(tenantId)
- .setName(ppgName).setDescription(ppgDescription).setPortPairs(portPairList).build();
-
- return portPairGroup;
-
- }
-
- private PortChain createPortChain() {
-
- portPairGroups.clear();
- flowClassifiers.clear();
- // create list of Port Pair Groups.
-
- portPairGroups.add(portPairGroupId1);
- portPairGroups.add(portPairGroupId2);
- // create list of Flow classifiers.
- flowClassifiers.add(flowClassifierId1);
- flowClassifiers.add(flowClassifierId2);
-
- DefaultPortChain.Builder portChainBuilder = new DefaultPortChain.Builder();
- final PortChain portChain = portChainBuilder.setId(portChainId).setTenantId(tenantId).setName(name)
- .setDescription(description).setPortPairGroups(portPairGroups).setFlowClassifiers(flowClassifiers)
- .build();
-
- return portChain;
- }
-
- private FlowClassifier createFlowClassifier(FlowClassifierId id) {
- final String name = "FlowClassifier1";
- final String description = "FlowClassifier1";
- final String ethType = "IPv4";
- final String protocol = "tcp";
- final int minSrcPortRange = 5;
- final int maxSrcPortRange = 10;
- final int minDstPortRange = 5;
- final int maxDstPortRange = 10;
- final TenantId tenantId = TenantId.tenantId("1");
- final IpPrefix srcIpPrefix = IpPrefix.valueOf("0.0.0.0/0");
- final IpPrefix dstIpPrefix = IpPrefix.valueOf("10.10.10.10/0");
- final VirtualPortId virtualSrcPort = id1;
- final VirtualPortId virtualDstPort = id2;
-
- DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder();
- final FlowClassifier flowClassifier = flowClassifierBuilder.setFlowClassifierId(id)
- .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType)
- .setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange)
- .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix)
- .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build();
- return flowClassifier;
- }
-
- private VirtualPort createVirtualPort(VirtualPortId id) {
- Set<FixedIp> fixedIps;
- Map<String, String> propertyMap;
- Set<AllowedAddressPair> allowedAddressPairs;
- Set<SecurityGroup> securityGroups = Sets.newHashSet();
-
- String macAddressStr = "fa:12:3e:56:ee:a2";
- String ipAddress = "10.1.1.1";
- String subnet = "1212";
- String hostIdStr = "fa:e2:3e:56:ee:a2";
- String deviceOwner = "james";
- propertyMap = Maps.newHashMap();
- propertyMap.putIfAbsent("deviceOwner", deviceOwner);
-
- TenantNetworkId networkId = TenantNetworkId.networkId(networkIdStr);
- MacAddress macAddress = MacAddress.valueOf(macAddressStr);
- BindingHostId bindingHostId = BindingHostId.bindingHostId(hostIdStr);
- FixedIp fixedIp = FixedIp.fixedIp(SubnetId.subnetId(subnet),
- IpAddress.valueOf(ipAddress));
- fixedIps = Sets.newHashSet();
- fixedIps.add(fixedIp);
-
- allowedAddressPairs = Sets.newHashSet();
- AllowedAddressPair allowedAddressPair = AllowedAddressPair
- .allowedAddressPair(IpAddress.valueOf(ipAddress),
- MacAddress.valueOf(macAddressStr));
- allowedAddressPairs.add(allowedAddressPair);
-
- VirtualPort d1 = new DefaultVirtualPort(id, networkId, true,
- propertyMap,
- VirtualPort.State.ACTIVE,
- macAddress, tenantId, deviceId,
- fixedIps, bindingHostId,
- allowedAddressPairs,
- securityGroups);
- return d1;
- }
-
- @Test
- public void testInstallFlowClassifier() {
-
- ApplicationId appId = new DefaultApplicationId(1, "test");
- SfcFlowRuleInstallerImpl flowClassifierInstaller = new SfcFlowRuleInstallerImpl();
- flowClassifierInstaller.virtualPortService = virtualPortService;
- flowClassifierInstaller.vtnRscService = vtnRscService;
- flowClassifierInstaller.portPairService = portPairService;
- flowClassifierInstaller.portPairGroupService = portPairGroupService;
- flowClassifierInstaller.flowClassifierService = flowClassifierService;
- flowClassifierInstaller.driverService = driverService;
- flowClassifierInstaller.deviceService = deviceService;
- flowClassifierInstaller.hostService = hostService;
- flowClassifierInstaller.flowObjectiveService = flowObjectiveService;
- flowClassifierInstaller.appId = appId;
-
- final PortChain portChain = createPortChain();
- NshServicePathId nshSpiId = NshServicePathId.of(10);
-
- portPairGroupService.createPortPairGroup(createPortPairGroup(portPairGroupId1));
- portPairGroupService.createPortPairGroup(createPortPairGroup(portPairGroupId2));
- portPairService.createPortPair(createPortPair(portPairId1));
- portPairService.createPortPair(createPortPair(portPairId2));
- FlowClassifier fc1 = createFlowClassifier(flowClassifierId1);
- FlowClassifier fc2 = createFlowClassifier(flowClassifierId2);
- flowClassifierService.createFlowClassifier(fc1);
- flowClassifierService.createFlowClassifier(fc2);
-
- List<VirtualPort> virtualPortList = Lists.newArrayList();
- virtualPortList.add(createVirtualPort(VirtualPortId.portId(ingress)));
- virtualPortService.createPorts(virtualPortList);
-
- expect(driverService.createHandler(deviceId)).andReturn(driverHandler).anyTimes();
- replay(driverService);
-
- ConnectPoint connectPoint = flowClassifierInstaller.installFlowClassifier(portChain, nshSpiId);
-
- assertThat(connectPoint, is(HostLocation.NONE));
- }
-
- @Test
- public void testInstallLoadBalancedFlowRules() {
- ApplicationId appId = new DefaultApplicationId(1, "test");
- SfcFlowRuleInstallerImpl flowRuleInstaller = new SfcFlowRuleInstallerImpl();
- flowRuleInstaller.virtualPortService = virtualPortService;
- flowRuleInstaller.vtnRscService = vtnRscService;
- flowRuleInstaller.portPairService = portPairService;
- flowRuleInstaller.portPairGroupService = portPairGroupService;
- flowRuleInstaller.flowClassifierService = flowClassifierService;
- flowRuleInstaller.driverService = driverService;
- flowRuleInstaller.deviceService = deviceService;
- flowRuleInstaller.hostService = hostService;
- flowRuleInstaller.flowObjectiveService = flowObjectiveService;
- flowRuleInstaller.tenantNetworkService = tenantNetworkService;
- flowRuleInstaller.appId = appId;
-
- final PortChain portChain = createPortChain();
-
- final String ppName1 = "PortPair1";
- final String ppDescription1 = "PortPair1";
- final String ingress1 = "d3333333-24fc-4fae-af4b-321c5e2eb3d1";
- final String egress1 = "a4444444-4a56-2a6e-cd3a-9dee4e2ec345";
- DefaultPortPair.Builder portPairBuilder = new DefaultPortPair.Builder();
- PortPair portPair1 = portPairBuilder.setId(portPairId1).setName(ppName1).setTenantId(tenantId)
- .setDescription(ppDescription1).setIngress(ingress1).setEgress(egress1).build();
-
- final String ppName2 = "PortPair2";
- final String ppDescription2 = "PortPair2";
- final String ingress2 = "d5555555-24fc-4fae-af4b-321c5e2eb3d1";
- final String egress2 = "a6666666-4a56-2a6e-cd3a-9dee4e2ec345";
- PortPair portPair2 = portPairBuilder.setId(portPairId2).setName(ppName2).setTenantId(tenantId)
- .setDescription(ppDescription2).setIngress(ingress2).setEgress(egress2).build();
-
- portPairService.createPortPair(portPair1);
- portPairService.createPortPair(portPair2);
-
- FlowClassifier fc1 = createFlowClassifier(flowClassifierId1);
- FlowClassifier fc2 = createFlowClassifier(flowClassifierId2);
- flowClassifierService.createFlowClassifier(fc1);
- flowClassifierService.createFlowClassifier(fc2);
-
- NshServicePathId nshSpiId = NshServicePathId.of(10);
- FiveTuple fiveTuple = DefaultFiveTuple.builder().setIpSrc(IpAddress.valueOf("3.3.3.3"))
- .setIpDst(IpAddress.valueOf("4.4.4.4"))
- .setPortSrc(PortNumber.portNumber(1500))
- .setPortDst(PortNumber.portNumber(2000))
- .setProtocol(IPv4.PROTOCOL_UDP)
- .setTenantId(TenantId.tenantId("bbb"))
- .build();
- LoadBalanceId id = LoadBalanceId.of((byte) 1);
-
- List<PortPairId> path = Lists.newArrayList();
- path.add(portPairId1);
- path.add(portPairId2);
-
- List<VirtualPort> virtualPortList = Lists.newArrayList();
- virtualPortList.add(createVirtualPort(VirtualPortId.portId(ingress1)));
- virtualPortList.add(createVirtualPort(VirtualPortId.portId(egress1)));
- virtualPortList.add(createVirtualPort(VirtualPortId.portId(ingress2)));
- virtualPortList.add(createVirtualPort(VirtualPortId.portId(egress2)));
- virtualPortService.createPorts(virtualPortList);
-
- portChain.addLoadBalancePath(fiveTuple, id, path);
-
- String physicalNetworkStr = "1234";
- String segmentationIdStr = "1";
- SegmentationId segmentationID = SegmentationId
- .segmentationId(segmentationIdStr);
- TenantNetworkId networkid1 = TenantNetworkId.networkId(networkIdStr);
- PhysicalNetwork physicalNetwork = PhysicalNetwork
- .physicalNetwork(physicalNetworkStr);
- TenantNetwork p1 = new DefaultTenantNetwork(networkid1, name, false,
- TenantNetwork.State.ACTIVE,
- false, tenantId, false,
- TenantNetwork.Type.LOCAL,
- physicalNetwork,
- segmentationID);
- tenantNetworkService.createNetworks(Collections.singletonList(p1));
-
- expect(driverService.createHandler(deviceId)).andReturn(driverHandler).anyTimes();
- replay(driverService);
-
- flowRuleInstaller.installLoadBalancedFlowRules(portChain, fiveTuple, nshSpiId);
-
- ForwardingObjective forObj = ((FlowObjectiveServiceAdapter) flowObjectiveService).forwardingObjective();
-
- // Check for Selector
- assertThat(forObj.selector().getCriterion(Criterion.Type.IN_PORT), instanceOf(PortCriterion.class));
-
- // Check for treatment
- List<Instruction> instructions = forObj.treatment().allInstructions();
- for (Instruction instruction : instructions) {
- if (instruction.type() == Instruction.Type.OUTPUT) {
- assertThat(((OutputInstruction) instruction).port(), is(PortNumber.P0));
- }
- }
- }
-}
diff --git a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/manager/impl/SfcManagerTest.java b/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/manager/impl/SfcManagerTest.java
deleted file mode 100644
index 8deb164..0000000
--- a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/manager/impl/SfcManagerTest.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.manager.impl;
-
-import org.junit.Test;
-
-import java.util.List;
-import java.util.LinkedList;
-
-import org.onlab.packet.IpPrefix;
-import org.onosproject.sfc.manager.SfcService;
-import org.onosproject.vtnrsc.DefaultPortChain;
-import org.onosproject.vtnrsc.DefaultPortPair;
-import org.onosproject.vtnrsc.DefaultPortPairGroup;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.DefaultFlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.FlowClassifier;
-
-/**
- * Unit tests for SfcManager class.
- */
-public class SfcManagerTest {
- /**
- * Checks the operation of onPortPairCreated() method.
- */
- @Test
- public void testOnPortPairCreated() {
- final PortPairId portPairId = PortPairId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortPair";
- final String description = "PortPair";
- final String ingress = "d3333333-24fc-4fae-af4b-321c5e2eb3d1";
- final String egress = "a4444444-4a56-2a6e-cd3a-9dee4e2ec345";
- DefaultPortPair.Builder portPairBuilder = new DefaultPortPair.Builder();
- PortPair portPair = null;
- SfcService sfcService = new SfcManager();
-
- // create port pair
- portPair = portPairBuilder.setId(portPairId).setTenantId(tenantId).setName(name).setDescription(description)
- .setIngress(ingress).setEgress(egress).build();
- sfcService.onPortPairCreated(portPair);
- }
-
- /**
- * Checks the operation of onPortPairDeleted() method.
- */
- @Test
- public void testOnPortPairDeleted() {
- final PortPairId portPairId = PortPairId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortPair";
- final String description = "PortPair";
- final String ingress = "d3333333-24fc-4fae-af4b-321c5e2eb3d1";
- final String egress = "a4444444-4a56-2a6e-cd3a-9dee4e2ec345";
- DefaultPortPair.Builder portPairBuilder = new DefaultPortPair.Builder();
- PortPair portPair = null;
- SfcService sfcService = new SfcManager();
-
- // create port pair
- portPair = portPairBuilder.setId(portPairId).setTenantId(tenantId).setName(name).setDescription(description)
- .setIngress(ingress).setEgress(egress).build();
- sfcService.onPortPairDeleted(portPair);
- }
-
- /**
- * Checks the operation of onPortPairGroupCreated() method.
- */
- @Test
- public void testOnPortPairGroupCreated() {
- final PortPairGroupId portPairGroupId = PortPairGroupId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortPairGroup";
- final String description = "PortPairGroup";
- final List<PortPairId> portPairIdList = new LinkedList<PortPairId>();
- DefaultPortPairGroup.Builder portPairGroupBuilder = new DefaultPortPairGroup.Builder();
- PortPairGroup portPairGroup = null;
- SfcService sfcService = new SfcManager();
-
- // create port-pair-id list
- PortPairId portPairId = PortPairId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairIdList.add(portPairId);
- portPairId = PortPairId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairIdList.add(portPairId);
-
- // create port pair
- portPairGroup = portPairGroupBuilder.setId(portPairGroupId).setTenantId(tenantId).setName(name)
- .setDescription(description).setPortPairs(portPairIdList).build();
- sfcService.onPortPairGroupCreated(portPairGroup);
- }
-
- /**
- * Checks the operation of onPortPairGroupDeleted() method.
- */
- @Test
- public void testOnPortPairGroupDeleted() {
- final PortPairGroupId portPairGroupId = PortPairGroupId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortPairGroup";
- final String description = "PortPairGroup";
- final List<PortPairId> portPairIdList = new LinkedList<PortPairId>();
- DefaultPortPairGroup.Builder portPairGroupBuilder = new DefaultPortPairGroup.Builder();
- PortPairGroup portPairGroup = null;
- SfcService sfcService = new SfcManager();
-
- // create port-pair-id list
- PortPairId portPairId = PortPairId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairIdList.add(portPairId);
- portPairId = PortPairId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairIdList.add(portPairId);
-
- // create port pair
- portPairGroup = portPairGroupBuilder.setId(portPairGroupId).setTenantId(tenantId).setName(name)
- .setDescription(description).setPortPairs(portPairIdList).build();
- sfcService.onPortPairGroupDeleted(portPairGroup);
- }
-
- /**
- * Checks the operation of onFlowClassifierCreated() method.
- */
- @Test
- public void testOnFlowClassifierCreated() {
- final String name = "FlowClassifier";
- final String description = "FlowClassifier";
- final String ethType = "IPv4";
- final String protocol = "udp";
- final int minSrcPortRange = 1024;
- final int maxSrcPortRange = 5000;
- final int minDstPortRange = 1024;
- final int maxDstPortRange = 5000;
- final FlowClassifierId flowClassifierId = FlowClassifierId.of("71111111-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("8");
- final IpPrefix srcIpPrefix = IpPrefix.valueOf("0.0.0.0/0");
- final IpPrefix dstIpPrefix = IpPrefix.valueOf("100.100.100.100/0");
- final VirtualPortId virtualSrcPort = VirtualPortId.portId("100");
- final VirtualPortId virtualDstPort = VirtualPortId.portId("200");
- DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder();
- FlowClassifier flowClassifier = null;
- SfcService sfcService = new SfcManager();
-
- // create flow classifier
- flowClassifier = flowClassifierBuilder.setFlowClassifierId(flowClassifierId).setTenantId(tenantId)
- .setName(name).setDescription(description).setEtherType(ethType).setProtocol(protocol)
- .setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange)
- .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix)
- .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build();
- sfcService.onFlowClassifierCreated(flowClassifier);
- }
-
- /**
- * Checks the operation of onFlowClassifierDeleted() method.
- */
- @Test
- public void testOnFlowClassifierDeleted() {
- final String name = "FlowClassifier";
- final String description = "FlowClassifier";
- final String ethType = "IPv4";
- final String protocol = "udp";
- final int minSrcPortRange = 1024;
- final int maxSrcPortRange = 5000;
- final int minDstPortRange = 1024;
- final int maxDstPortRange = 5000;
- final FlowClassifierId flowClassifierId = FlowClassifierId.of("71111111-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("8");
- final IpPrefix srcIpPrefix = IpPrefix.valueOf("0.0.0.0/0");
- final IpPrefix dstIpPrefix = IpPrefix.valueOf("100.100.100.100/0");
- final VirtualPortId virtualSrcPort = VirtualPortId.portId("100");
- final VirtualPortId virtualDstPort = VirtualPortId.portId("200");
- DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder();
- FlowClassifier flowClassifier = null;
- SfcService sfcService = new SfcManager();
-
- // create flow classifier
- flowClassifier = flowClassifierBuilder.setFlowClassifierId(flowClassifierId).setTenantId(tenantId)
- .setName(name).setDescription(description).setEtherType(ethType).setProtocol(protocol)
- .setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange)
- .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix)
- .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build();
- sfcService.onFlowClassifierDeleted(flowClassifier);
- }
-
- /**
- * Checks the operation of onPortChainCreated() method.
- */
- @Test
- public void testOnPortChainCreated() {
- final PortChainId portChainId = PortChainId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortChain";
- final String description = "PortChain";
- final List<PortPairGroupId> portPairGroupList = new LinkedList<PortPairGroupId>();
- final List<FlowClassifierId> flowClassifierList = new LinkedList<FlowClassifierId>();
- DefaultPortChain.Builder portChainBuilder = new DefaultPortChain.Builder();
- DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder();
- PortChain portChain = null;
- SfcService sfcService = new SfcManager();
-
- // create list of Port Pair Groups.
- PortPairGroupId portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairGroupList.add(portPairGroupId);
- portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3af");
- portPairGroupList.add(portPairGroupId);
-
- // create list of Flow classifiers.
- FlowClassifierId flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae");
- flowClassifierList.add(flowClassifierId);
- flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3af");
- flowClassifierList.add(flowClassifierId);
-
- // create port chain
- portChain = portChainBuilder.setId(portChainId).setTenantId(tenantId).setName(name).setDescription(description)
- .setPortPairGroups(portPairGroupList).setFlowClassifiers(flowClassifierList).build();
- //sfcService.onPortChainCreated(portChain);
- }
-
- /**
- * Checks the operation of onPortChainDeleted() method.
- */
- @Test
- public void testOnPortChainDeleted() {
- final PortChainId portChainId = PortChainId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortChain";
- final String description = "PortChain";
- final List<PortPairGroupId> portPairGroupList = new LinkedList<PortPairGroupId>();
- final List<FlowClassifierId> flowClassifierList = new LinkedList<FlowClassifierId>();
- DefaultPortChain.Builder portChainBuilder = new DefaultPortChain.Builder();
- DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder();
- PortChain portChain = null;
- SfcService sfcService = new SfcManager();
-
- // create list of Port Pair Groups.
- PortPairGroupId portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairGroupList.add(portPairGroupId);
- portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3af");
- portPairGroupList.add(portPairGroupId);
-
- // create list of Flow classifiers.
- FlowClassifierId flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae");
- flowClassifierList.add(flowClassifierId);
- flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3af");
- flowClassifierList.add(flowClassifierId);
-
- // create port chain
- portChain = portChainBuilder.setId(portChainId).setTenantId(tenantId).setName(name).setDescription(description)
- .setPortPairGroups(portPairGroupList).setFlowClassifiers(flowClassifierList).build();
- //sfcService.onPortChainDeleted(portChain);
- }
-}
diff --git a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/FlowClassifierAdapter.java b/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/FlowClassifierAdapter.java
deleted file mode 100644
index fbd1527..0000000
--- a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/FlowClassifierAdapter.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.util;
-
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.flowclassifier.FlowClassifierListener;
-import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Provides implementation of the Flow Classifier Service.
- */
-public class FlowClassifierAdapter implements FlowClassifierService {
-
- private final ConcurrentMap<FlowClassifierId, FlowClassifier> flowClassifierStore = new ConcurrentHashMap<>();
-
- @Override
- public boolean exists(FlowClassifierId id) {
- return flowClassifierStore.containsKey(id);
- }
-
- @Override
- public int getFlowClassifierCount() {
- return flowClassifierStore.size();
- }
-
- @Override
- public Iterable<FlowClassifier> getFlowClassifiers() {
- return ImmutableList.copyOf(flowClassifierStore.values());
- }
-
- @Override
- public FlowClassifier getFlowClassifier(FlowClassifierId id) {
- return flowClassifierStore.get(id);
- }
-
- @Override
- public boolean createFlowClassifier(FlowClassifier flowClassifier) {
- FlowClassifierId id = flowClassifier.flowClassifierId();
-
- flowClassifierStore.put(id, flowClassifier);
- if (!flowClassifierStore.containsKey(id)) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean updateFlowClassifier(FlowClassifier flowClassifier) {
-
- if (!flowClassifierStore.containsKey(flowClassifier.flowClassifierId())) {
- return false;
- }
-
- flowClassifierStore.put(flowClassifier.flowClassifierId(), flowClassifier);
-
- if (!flowClassifier.equals(flowClassifierStore.get(flowClassifier.flowClassifierId()))) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removeFlowClassifier(FlowClassifierId id) {
- return true;
- }
-
- @Override
- public void addListener(FlowClassifierListener listener) {
- }
-
- @Override
- public void removeListener(FlowClassifierListener listener) {
- }
-}
diff --git a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockDriverHandler.java b/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockDriverHandler.java
deleted file mode 100644
index c9f1754..0000000
--- a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockDriverHandler.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.sfc.util;
-
-import org.onosproject.net.behaviour.ExtensionSelectorResolver;
-import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
-import org.onosproject.net.driver.Behaviour;
-import org.onosproject.net.driver.Driver;
-import org.onosproject.net.driver.DriverData;
-import org.onosproject.net.driver.DriverHandler;
-
-public class MockDriverHandler implements DriverHandler {
-
- @Override
- public Driver driver() {
- return null;
- }
-
- @Override
- public DriverData data() {
- return null;
- }
-
- @Override
- public <T extends Behaviour> T behaviour(Class<T> behaviourClass) {
- if (behaviourClass == ExtensionSelectorResolver.class) {
- return (T) new MockExtensionSelectorResolver();
- } else if (behaviourClass == ExtensionTreatmentResolver.class) {
- return (T) new MockExtensionTreatmentResolver();
- }
- return null;
- }
-
- @Override
- public <T> T get(Class<T> serviceClass) {
- return null;
- }
-}
\ No newline at end of file
diff --git a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockExtensionSelector.java b/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockExtensionSelector.java
deleted file mode 100644
index 914484f..0000000
--- a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockExtensionSelector.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.util;
-
-import java.util.List;
-
-import org.onosproject.net.flow.criteria.ExtensionSelector;
-import org.onosproject.net.flow.criteria.ExtensionSelectorType;
-import org.onosproject.net.flow.instructions.ExtensionPropertyException;
-
-public class MockExtensionSelector implements ExtensionSelector {
-
- private ExtensionSelectorType type;
-
- public MockExtensionSelector(ExtensionSelectorType type) {
- this.type = type;
- }
-
- @Override
- public <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException {
- }
-
- @Override
- public <T> T getPropertyValue(String key) throws ExtensionPropertyException {
- return null;
- }
-
- @Override
- public List<String> getProperties() {
- return null;
- }
-
- @Override
- public byte[] serialize() {
- return null;
- }
-
- @Override
- public void deserialize(byte[] data) {
- }
-
- @Override
- public ExtensionSelectorType type() {
- return type;
- }
-}
\ No newline at end of file
diff --git a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockExtensionSelectorResolver.java b/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockExtensionSelectorResolver.java
deleted file mode 100644
index 17ac6aa..0000000
--- a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockExtensionSelectorResolver.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.util;
-
-import org.onosproject.net.behaviour.ExtensionSelectorResolver;
-import org.onosproject.net.driver.DriverData;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.flow.criteria.ExtensionSelector;
-import org.onosproject.net.flow.criteria.ExtensionSelectorType;
-
-public class MockExtensionSelectorResolver implements ExtensionSelectorResolver {
-
- @Override
- public DriverHandler handler() {
- return null;
- }
-
- @Override
- public void setHandler(DriverHandler handler) {
- }
-
- @Override
- public DriverData data() {
- return null;
- }
-
- @Override
- public void setData(DriverData data) {
- }
-
- @Override
- public ExtensionSelector getExtensionSelector(ExtensionSelectorType type) {
- return new MockExtensionSelector(type);
- }
-}
\ No newline at end of file
diff --git a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockExtensionTreatment.java b/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockExtensionTreatment.java
deleted file mode 100644
index 8491616..0000000
--- a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockExtensionTreatment.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.util;
-
-import java.util.List;
-
-import org.onosproject.net.flow.instructions.ExtensionPropertyException;
-import org.onosproject.net.flow.instructions.ExtensionTreatment;
-import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
-
-public class MockExtensionTreatment implements ExtensionTreatment {
-
- private ExtensionTreatmentType type;
-
- public MockExtensionTreatment(ExtensionTreatmentType type) {
- this.type = type;
- }
-
- @Override
- public <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException {
- }
-
- @Override
- public <T> T getPropertyValue(String key) throws ExtensionPropertyException {
- return null;
- }
-
- @Override
- public List<String> getProperties() {
- return null;
- }
-
- @Override
- public byte[] serialize() {
- return null;
- }
-
- @Override
- public void deserialize(byte[] data) {
- }
-
- @Override
- public ExtensionTreatmentType type() {
- return type;
- }
-
-}
\ No newline at end of file
diff --git a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockExtensionTreatmentResolver.java b/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockExtensionTreatmentResolver.java
deleted file mode 100644
index c2ec674..0000000
--- a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockExtensionTreatmentResolver.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.util;
-
-import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
-import org.onosproject.net.driver.DriverData;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.flow.instructions.ExtensionTreatment;
-import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
-
-public class MockExtensionTreatmentResolver implements ExtensionTreatmentResolver {
-
- @Override
- public DriverHandler handler() {
- return null;
- }
-
- @Override
- public void setHandler(DriverHandler handler) {
- }
-
- @Override
- public DriverData data() {
- return null;
- }
-
- @Override
- public void setData(DriverData data) {
- }
-
- @Override
- public ExtensionTreatment getExtensionInstruction(ExtensionTreatmentType type) {
- return new MockExtensionTreatment(type);
- }
-
-}
\ No newline at end of file
diff --git a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortChainAdapter.java b/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortChainAdapter.java
deleted file mode 100644
index ff6920d..0000000
--- a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortChainAdapter.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.util;
-
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.Collections;
-
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.portchain.PortChainService;
-import org.onosproject.vtnrsc.portchain.PortChainEvent;
-import org.onosproject.vtnrsc.portchain.PortChainListener;
-import org.onosproject.event.AbstractListenerManager;
-
-/**
- * Provides implementation of the portChainService.
- */
-public class PortChainAdapter
- extends AbstractListenerManager<PortChainEvent, PortChainListener>
- implements PortChainService {
-
- private ConcurrentMap<PortChainId, PortChain> portChainStore = new ConcurrentHashMap<>();
-
- @Override
- public boolean exists(PortChainId portChainId) {
- return portChainStore.containsKey(portChainId);
- }
-
- @Override
- public int getPortChainCount() {
- return portChainStore.size();
- }
-
- @Override
- public Iterable<PortChain> getPortChains() {
- return Collections.unmodifiableCollection(portChainStore.values());
- }
-
- @Override
- public PortChain getPortChain(PortChainId portChainId) {
- return portChainStore.get(portChainId);
- }
-
- @Override
- public boolean createPortChain(PortChain portChain) {
- portChainStore.put(portChain.portChainId(), portChain);
- if (!portChainStore.containsKey(portChain.portChainId())) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean updatePortChain(PortChain portChain) {
- if (!portChainStore.containsKey(portChain.portChainId())) {
- return false;
- }
-
- portChainStore.put(portChain.portChainId(), portChain);
-
- if (!portChain.equals(portChainStore.get(portChain.portChainId()))) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removePortChain(PortChainId portChainId) {
- return true;
- }
-}
diff --git a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortPairAdapter.java b/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortPairAdapter.java
deleted file mode 100644
index 20e1321..0000000
--- a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortPairAdapter.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.util;
-
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.Collections;
-
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.portpair.PortPairListener;
-import org.onosproject.vtnrsc.portpair.PortPairService;
-
-/**
- * Provides implementation of the portPairService.
- */
-public class PortPairAdapter implements PortPairService {
-
- private ConcurrentMap<PortPairId, PortPair> portPairStore = new ConcurrentHashMap<>();
-
- @Override
- public boolean exists(PortPairId portPairId) {
- return portPairStore.containsKey(portPairId);
- }
-
- @Override
- public int getPortPairCount() {
- return portPairStore.size();
- }
-
- @Override
- public Iterable<PortPair> getPortPairs() {
- return Collections.unmodifiableCollection(portPairStore.values());
- }
-
- @Override
- public PortPair getPortPair(PortPairId portPairId) {
- return portPairStore.get(portPairId);
- }
-
- @Override
- public boolean createPortPair(PortPair portPair) {
- portPairStore.put(portPair.portPairId(), portPair);
- if (!portPairStore.containsKey(portPair.portPairId())) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean updatePortPair(PortPair portPair) {
- if (!portPairStore.containsKey(portPair.portPairId())) {
- return false;
- }
-
- portPairStore.put(portPair.portPairId(), portPair);
-
- if (!portPair.equals(portPairStore.get(portPair.portPairId()))) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removePortPair(PortPairId portPairId) {
- return true;
- }
-
- @Override
- public void addListener(PortPairListener listener) {
- }
-
- @Override
- public void removeListener(PortPairListener listener) {
- }
-}
diff --git a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortPairGroupAdapter.java b/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortPairGroupAdapter.java
deleted file mode 100644
index 5326899..0000000
--- a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/PortPairGroupAdapter.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.util;
-
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.Collections;
-
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupListener;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
-
-/**
- * Provides implementation of the portPairGroupService.
- */
-public class PortPairGroupAdapter implements PortPairGroupService {
-
- private ConcurrentMap<PortPairGroupId, PortPairGroup> portPairGroupStore = new ConcurrentHashMap<>();
-
- @Override
- public boolean exists(PortPairGroupId portPairGroupId) {
- return portPairGroupStore.containsKey(portPairGroupId);
- }
-
- @Override
- public int getPortPairGroupCount() {
- return portPairGroupStore.size();
- }
-
- @Override
- public Iterable<PortPairGroup> getPortPairGroups() {
- return Collections.unmodifiableCollection(portPairGroupStore.values());
- }
-
- @Override
- public PortPairGroup getPortPairGroup(PortPairGroupId portPairGroupId) {
- return portPairGroupStore.get(portPairGroupId);
- }
-
- @Override
- public boolean createPortPairGroup(PortPairGroup portPairGroup) {
- portPairGroupStore.put(portPairGroup.portPairGroupId(), portPairGroup);
- if (!portPairGroupStore.containsKey(portPairGroup.portPairGroupId())) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean updatePortPairGroup(PortPairGroup portPairGroup) {
- if (!portPairGroupStore.containsKey(portPairGroup.portPairGroupId())) {
- return false;
- }
-
- portPairGroupStore.put(portPairGroup.portPairGroupId(), portPairGroup);
-
- if (!portPairGroup.equals(portPairGroupStore.get(portPairGroup.portPairGroupId()))) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removePortPairGroup(PortPairGroupId portPairGroupId) {
- return true;
- }
-
- @Override
- public void addListener(PortPairGroupListener listener) {
- }
-
- @Override
- public void removeListener(PortPairGroupListener listener) {
- }
-}
diff --git a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/TenantNetworkAdapter.java b/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/TenantNetworkAdapter.java
deleted file mode 100644
index 142e4bb..0000000
--- a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/TenantNetworkAdapter.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.util;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Provides implementation of the VtnRsc service.
- */
-public class TenantNetworkAdapter implements TenantNetworkService {
-
- private final ConcurrentMap<TenantNetworkId, TenantNetwork> tenantNetworkStore = new ConcurrentHashMap<>();
-
- @Override
- public boolean exists(TenantNetworkId networkId) {
- return tenantNetworkStore.containsKey(networkId);
- }
-
- @Override
- public int getNetworkCount() {
- return tenantNetworkStore.size();
- }
-
- @Override
- public Iterable<TenantNetwork> getNetworks() {
- return ImmutableList.copyOf(tenantNetworkStore.values());
- }
-
- @Override
- public TenantNetwork getNetwork(TenantNetworkId networkId) {
- return tenantNetworkStore.get(networkId);
- }
-
- @Override
- public boolean createNetworks(Iterable<TenantNetwork> networks) {
- for (TenantNetwork network : networks) {
- tenantNetworkStore.put(network.id(), network);
- if (!tenantNetworkStore.containsKey(network.id())) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean updateNetworks(Iterable<TenantNetwork> networks) {
- return false;
- }
-
- @Override
- public boolean removeNetworks(Iterable<TenantNetworkId> networksIds) {
- return false;
- }
-
-}
diff --git a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/VirtualPortAdapter.java b/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/VirtualPortAdapter.java
deleted file mode 100644
index ba4fc0e..0000000
--- a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/VirtualPortAdapter.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.util;
-
-import java.util.Collection;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortListener;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-/**
- * Provides implementation of the VirtualPort APIs.
- */
-public class VirtualPortAdapter implements VirtualPortService {
-
- protected ConcurrentMap<VirtualPortId, VirtualPort> vPortStore = new ConcurrentHashMap<>();
-
- @Override
- public boolean exists(VirtualPortId vPortId) {
- return vPortStore.containsKey(vPortId);
- }
-
- @Override
- public VirtualPort getPort(VirtualPortId vPortId) {
- return vPortStore.get(vPortId);
- }
-
- @Override
- public VirtualPort getPort(FixedIp fixedIP) {
- return null;
- }
-
- @Override
- public VirtualPort getPort(MacAddress mac) {
- return null;
- }
-
- @Override
- public Collection<VirtualPort> getPorts() {
- return null;
- }
-
- @Override
- public Collection<VirtualPort> getPorts(TenantNetworkId networkId) {
- return null;
- }
-
- @Override
- public Collection<VirtualPort> getPorts(TenantId tenantId) {
- return null;
- }
-
- @Override
- public Collection<VirtualPort> getPorts(DeviceId deviceId) {
- return null;
- }
-
- @Override
- public VirtualPort getPort(TenantNetworkId networkId, IpAddress ipAddress) {
- return null;
- }
-
- @Override
- public boolean createPorts(Iterable<VirtualPort> vPorts) {
- for (VirtualPort vPort : vPorts) {
- vPortStore.put(vPort.portId(), vPort);
- if (!vPortStore.containsKey(vPort.portId())) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean updatePorts(Iterable<VirtualPort> vPorts) {
- return true;
- }
-
- @Override
- public boolean removePorts(Iterable<VirtualPortId> vPortIds) {
- return true;
- }
-
- @Override
- public void addListener(VirtualPortListener listener) {
- }
-
- @Override
- public void removeListener(VirtualPortListener listener) {
- }
-}
diff --git a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/VtnRscAdapter.java b/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/VtnRscAdapter.java
deleted file mode 100644
index 62a4cee..0000000
--- a/apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/VtnRscAdapter.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfc.util;
-
-import java.util.Iterator;
-
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.HostId;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantRouter;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.event.VtnRscListener;
-import org.onosproject.vtnrsc.service.VtnRscService;
-
-/**
- * Provides implementation of the VtnRsc service.
- */
-public class VtnRscAdapter implements VtnRscService {
- @Override
- public void addListener(VtnRscListener listener) {
- }
-
- @Override
- public void removeListener(VtnRscListener listener) {
- }
-
- @Override
- public SegmentationId getL3vni(TenantId tenantId) {
- return null;
- }
-
- @Override
- public Iterator<Device> getClassifierOfTenant(TenantId tenantId) {
- return null;
- }
-
- @Override
- public Iterator<Device> getSffOfTenant(TenantId tenantId) {
- return null;
- }
-
- @Override
- public MacAddress getGatewayMac(HostId hostId) {
- return null;
- }
-
- @Override
- public boolean isServiceFunction(VirtualPortId portId) {
- return false;
- }
-
- @Override
- public DeviceId getSfToSffMaping(VirtualPortId portId) {
- return DeviceId.deviceId("of:000000000000001");
- }
-
- @Override
- public void addDeviceIdOfOvsMap(VirtualPortId virtualPortId,
- TenantId tenantId, DeviceId deviceId) {
- }
-
- @Override
- public void removeDeviceIdOfOvsMap(Host host, TenantId tenantId,
- DeviceId deviceId) {
- }
-
- @Override
- public SegmentationId getL3vni(TenantRouter tenantRouter) {
- return null;
- }
-}
diff --git a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcLink.java b/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcLink.java
deleted file mode 100644
index 6f31752..0000000
--- a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcLink.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfcweb;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-import org.onosproject.ui.topo.BiLink;
-import org.onosproject.ui.topo.LinkHighlight;
-import org.onosproject.ui.topo.LinkHighlight.Flavor;
-
-/**
- * Bi-directional link capable of different highlights.
- */
-public class SfcLink extends BiLink {
-
- private boolean primary = false;
- private boolean secondary = false;
-
- public SfcLink(LinkKey key, Link link) {
- super(key, link);
- }
-
- @Override
- public LinkHighlight highlight(Enum<?> anEnum) {
- Flavor flavor = primary ? Flavor.PRIMARY_HIGHLIGHT :
- (secondary ? Flavor.SECONDARY_HIGHLIGHT : Flavor.NO_HIGHLIGHT);
- return new LinkHighlight(this.linkId(), Flavor.PRIMARY_HIGHLIGHT);
- }
-}
diff --git a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcLinkMap.java b/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcLinkMap.java
deleted file mode 100644
index d75514e..0000000
--- a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcLinkMap.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfcweb;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-import org.onosproject.ui.topo.BiLinkMap;
-
-/**
- * Sfc concrete link map.
- */
-public class SfcLinkMap extends BiLinkMap<SfcLink> {
- @Override
- protected SfcLink create(LinkKey linkKey, Link link) {
- return new SfcLink(linkKey, link);
- }
-}
diff --git a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovComponent.java b/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovComponent.java
deleted file mode 100644
index ddd6fa2..0000000
--- a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovComponent.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfcweb;
-
-import com.google.common.collect.ImmutableList;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onosproject.ui.UiExtension;
-import org.onosproject.ui.UiExtensionService;
-import org.onosproject.ui.UiMessageHandlerFactory;
-import org.onosproject.ui.UiTopoOverlayFactory;
-import org.onosproject.ui.UiView;
-import org.onosproject.ui.UiViewHidden;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-/**
- * Skeletal ONOS UI Topology-Overlay application component.
- */
-@Component(immediate = true)
-public class SfcwebUiTopovComponent {
-
- private static final ClassLoader CL = SfcwebUiTopovComponent.class.getClassLoader();
- private static final String VIEW_ID = "sfcwebTopov";
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected UiExtensionService uiExtensionService;
-
- // List of application views
- private final List<UiView> uiViews = ImmutableList.of(
- new UiViewHidden(VIEW_ID)
- );
-
- // Factory for UI message handlers
- private final UiMessageHandlerFactory messageHandlerFactory =
- () -> ImmutableList.of(
- new SfcwebUiTopovMessageHandler()
- );
-
- // Factory for UI topology overlays
- private final UiTopoOverlayFactory topoOverlayFactory =
- () -> ImmutableList.of(
- new SfcwebUiTopovOverlay()
- );
-
- // Application UI extension
- protected UiExtension extension =
- new UiExtension.Builder(CL, uiViews)
- .resourcePath(VIEW_ID)
- .messageHandlerFactory(messageHandlerFactory)
- .topoOverlayFactory(topoOverlayFactory)
- .build();
-
- @Activate
- protected void activate() {
- uiExtensionService.register(extension);
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- uiExtensionService.unregister(extension);
- log.info("Stopped");
- }
-
-}
diff --git a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovMessageHandler.java b/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovMessageHandler.java
deleted file mode 100644
index 3fa9ec0..0000000
--- a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovMessageHandler.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfcweb;
-
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Element;
-import org.onosproject.net.Host;
-import org.onosproject.net.HostId;
-import org.onosproject.net.Link;
-import org.onosproject.net.host.HostService;
-import org.onosproject.net.link.LinkService;
-import org.onosproject.ui.RequestHandler;
-import org.onosproject.ui.UiConnection;
-import org.onosproject.ui.UiMessageHandler;
-import org.onosproject.ui.topo.DeviceHighlight;
-import org.onosproject.ui.topo.Highlights;
-import org.onosproject.ui.topo.HostHighlight;
-import org.onosproject.ui.topo.NodeBadge;
-import org.onosproject.ui.topo.TopoJson;
-import org.onosproject.vtnrsc.FiveTuple;
-import org.onosproject.vtnrsc.LoadBalanceId;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.portchain.PortChainService;
-import org.onosproject.vtnrsc.portpair.PortPairService;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
-import org.onosproject.vtnrsc.service.VtnRscService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Set;
-import java.util.TimerTask;
-
-import static org.onosproject.net.DefaultEdgeLink.createEdgeLink;
-
-/**
- * SFC web gui topology-overlay message handler.
- */
-public class SfcwebUiTopovMessageHandler extends UiMessageHandler {
-
- private static final String SAMPLE_TOPOV_DISPLAY_START = "sfcwebTopovDisplayStart";
- private static final String SAMPLE_TOPOV_DISPLAY_SFC = "showSfcInfo";
- private static final String SAMPLE_TOPOV_DISPLAY_STOP = "sfcTopovClear";
- private static final String CONFIG_SFP_MSG = "configSfpMessage";
- private static final String SAMPLE_TOPOV_SHOW_SFC_PATH = "showSfcPath";
- private static final String ID = "id";
- private static final String MODE = "mode";
- private static final String CLASSIFIER = "CLS";
- private static final String FORWARDER = "SFF";
-
- private static final Link[] EMPTY_LINK_SET = new Link[0];
-
- private enum Mode {
- IDLE, MOUSE, LINK
- }
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private HostService hostService;
- private LinkService linkService;
- private TimerTask demoTask = null;
- private Mode currentMode = Mode.IDLE;
- private Element elementOfNote;
- private Link[] linkSet = EMPTY_LINK_SET;
-
- protected PortPairService portPairService;
- protected VtnRscService vtnRscService;
- protected VirtualPortService virtualPortService;
- protected PortChainService portChainService;
- protected PortPairGroupService portPairGroupService;
-
- @Override
- public void init(UiConnection connection, ServiceDirectory directory) {
- super.init(connection, directory);
- hostService = directory.get(HostService.class);
- linkService = directory.get(LinkService.class);
- portChainService = directory.get(PortChainService.class);
- portPairService = directory.get(PortPairService.class);
- portPairGroupService = directory.get(PortPairGroupService.class);
- }
-
- @Override
- protected Collection<RequestHandler> createRequestHandlers() {
- return ImmutableSet.of(
- new DisplayStartHandler(),
- new DisplayStopHandler(),
- new ConfigSfpMsg()
- );
- }
-
- /**
- * Handler classes.
- */
- private final class DisplayStartHandler extends RequestHandler {
- public DisplayStartHandler() {
- super(SAMPLE_TOPOV_DISPLAY_START);
- }
-
- @Override
- public void process(ObjectNode payload) {
- String mode = string(payload, MODE);
- PortChainService pcs = get(PortChainService.class);
- Iterable<PortChain> portChains = pcs.getPortChains();
- ObjectNode result = objectNode();
-
- ArrayNode arrayNode = arrayNode();
-
- for (final PortChain portChain : portChains) {
- arrayNode.add(portChain.portChainId().value().toString());
- }
- result.putArray("a").addAll(arrayNode);
-
- sendMessage(SAMPLE_TOPOV_DISPLAY_SFC, result);
- }
- }
-
- private final class DisplayStopHandler extends RequestHandler {
- public DisplayStopHandler() {
- super(SAMPLE_TOPOV_DISPLAY_STOP);
- }
-
- @Override
- public void process(ObjectNode payload) {
- log.debug("Stop Display");
- clearState();
- clearForMode();
- cancelTask();
- }
- }
-
- private final class ConfigSfpMsg extends RequestHandler {
- public ConfigSfpMsg() {
- super(CONFIG_SFP_MSG);
- }
-
- @Override
- public void process(ObjectNode payload) {
- String id = string(payload, ID);
- ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
- vtnRscService = serviceDirectory.get(VtnRscService.class);
- virtualPortService = serviceDirectory.get(VirtualPortService.class);
-
- List<String> sfcPathList = Lists.newArrayList();
-
- Highlights highlights = new Highlights();
- SfcLinkMap linkMap = new SfcLinkMap();
-
- PortChainId portChainId = PortChainId.of(id);
- boolean portChainIdExist = portChainService.exists(portChainId);
- if (!portChainIdExist) {
- log.info("portchain id doesn't exist");
- return;
- }
-
- PortChain portChain = portChainService.getPortChain(portChainId);
-
- Set<FiveTuple> fiveTupleSet = portChain.getLoadBalanceIdMapKeys();
- for (FiveTuple fiveTuple : fiveTupleSet) {
- List<PortPairId> path = portChain.getLoadBalancePath(fiveTuple);
- LoadBalanceId lbId = portChain.getLoadBalanceId(fiveTuple);
- ListIterator<PortPairId> pathIterator = path.listIterator();
-
- // Add source
- Host srcHost = hostService.getHost(HostId.hostId(fiveTuple.macSrc()));
-
- HostHighlight hSrc = new HostHighlight(srcHost.id().toString());
- hSrc.setBadge(NodeBadge.text("SRC"));
- String sfcPath = "SRC -> ";
- highlights.add(hSrc);
-
- DeviceId previousDeviceId = null;
- while (pathIterator.hasNext()) {
-
- PortPairId portPairId = pathIterator.next();
- PortPair portPair = portPairService.getPortPair(portPairId);
- DeviceId deviceId = vtnRscService.getSfToSffMaping(VirtualPortId.portId(portPair.egress()));
- VirtualPort vPort = virtualPortService.getPort(VirtualPortId.portId(portPair.egress()));
- MacAddress dstMacAddress = vPort.macAddress();
- Host host = hostService.getHost(HostId.hostId(dstMacAddress));
-
- addEdgeLinks(linkMap, host);
- log.info("before check");
- if (previousDeviceId != null) {
- log.info("pdid not null");
- if (!deviceId.equals(previousDeviceId)) {
- // Highlight the link between devices.
-
- Link link = getLinkBetweenDevices(deviceId, previousDeviceId);
- if (link != null) {
- linkMap.add(link);
- }
- }
- }
-
- DeviceHighlight dh = new DeviceHighlight(deviceId.toString());
- if (portChain.getSfcClassifiers(lbId).contains(deviceId)) {
- dh.setBadge(NodeBadge.text(CLASSIFIER));
- } else {
- dh.setBadge(NodeBadge.text(FORWARDER));
- }
-
- highlights.add(dh);
-
- HostHighlight hhDst = new HostHighlight(host.id().toString());
- hhDst.setBadge(NodeBadge.text(portPair.name()));
- sfcPath = sfcPath + portPair.name() + "(" + vPort.fixedIps().iterator().next().ip() + ") -> ";
-
- if (!portPair.ingress().equals(portPair.egress())) {
- MacAddress srcMacAddress = virtualPortService.getPort(VirtualPortId
- .portId(portPair.ingress()))
- .macAddress();
- Host hostSrc = hostService.getHost(HostId.hostId(srcMacAddress));
- HostHighlight hhSrc = new HostHighlight(hostSrc.id().toString());
- hhSrc.setBadge(NodeBadge.text(portPair.name()));
- highlights.add(hhSrc);
- }
- highlights.add(hhDst);
- previousDeviceId = deviceId;
- }
-
- // Add destination
- Host dstHost = hostService.getHost(HostId.hostId(fiveTuple.macDst()));
-
- HostHighlight hDst = new HostHighlight(dstHost.id().toString());
- hDst.setBadge(NodeBadge.text("DST"));
- sfcPath = sfcPath + "DST";
- highlights.add(hDst);
- sfcPathList.add(sfcPath);
- }
-
- for (SfcLink sfcLink : linkMap.biLinks()) {
- highlights.add(sfcLink.highlight(null));
- }
- sendHighlights(highlights);
-
- ObjectNode result = objectNode();
- ArrayNode arrayNode = arrayNode();
- for (String path : sfcPathList) {
- arrayNode.add(path);
- }
- result.putArray("sfcPathList").addAll(arrayNode);
-
- sendMessage(SAMPLE_TOPOV_SHOW_SFC_PATH, result);
- }
- }
-
- private Link getLinkBetweenDevices(DeviceId deviceId, DeviceId previousDeviceId) {
- Set<Link> deviceLinks = linkService.getDeviceEgressLinks(deviceId);
- Set<Link> previousDeviceLinks = linkService.getDeviceIngressLinks(previousDeviceId);
- for (Link link : deviceLinks) {
- previousDeviceLinks.contains(link);
- return link;
- }
- return null;
- }
-
- private void addEdgeLinks(SfcLinkMap linkMap, Host host1) {
- linkMap.add(createEdgeLink(host1, true));
- linkMap.add(createEdgeLink(host1, false));
- }
-
- private synchronized void cancelTask() {
- if (demoTask != null) {
- demoTask.cancel();
- demoTask = null;
- }
- }
-
- private void clearState() {
- currentMode = Mode.IDLE;
- elementOfNote = null;
- linkSet = EMPTY_LINK_SET;
- }
-
- private void clearForMode() {
- sendHighlights(new Highlights());
- }
-
- private void sendHighlights(Highlights highlights) {
- sendMessage(TopoJson.highlightsMessage(highlights));
- }
-
-}
diff --git a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovOverlay.java b/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovOverlay.java
deleted file mode 100644
index 392d423..0000000
--- a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/SfcwebUiTopovOverlay.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.sfcweb;
-
-import org.onlab.packet.MacAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.HostId;
-import org.onosproject.net.host.HostService;
-import org.onosproject.ui.UiTopoOverlay;
-import org.onosproject.ui.topo.PropertyPanel;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.portpair.PortPairService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-/**
- * Our sfcweb topology overlay.
- */
-public class SfcwebUiTopovOverlay extends UiTopoOverlay {
-
- // NOTE: this must match the ID defined in sfcwebTopov.js
- private static final String OVERLAY_ID = "SFC-Service-overlay";
- private static final String MY_DEVICE_TITLE = "SFF specific device details";
- private static final String MY_HOST_TITLE = "SF specific host details";
-
- public SfcwebUiTopovOverlay() {
- super(OVERLAY_ID);
- }
-
- @Override
- public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
- pp.title(MY_DEVICE_TITLE);
- pp.removeAllProps();
- pp.addProp("SFF Device Id", deviceId.toString());
- }
-
- @Override
- public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
- pp.title(MY_HOST_TITLE);
- pp.removeAllProps();
- PortPairService portPairService = AbstractShellCommand.get(PortPairService.class);
- VirtualPortService virtualPortService = AbstractShellCommand.get(VirtualPortService.class);
- HostService hostService = AbstractShellCommand.get(HostService.class);
- Iterable<PortPair> portPairs = portPairService.getPortPairs();
- for (PortPair portPair : portPairs) {
- VirtualPort vPort = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress()));
- MacAddress dstMacAddress = vPort.macAddress();
- Host host = hostService.getHost(HostId.hostId(dstMacAddress));
- if (hostId.toString().equals(host.id().toString())) {
- pp.addProp("SF Name", portPair.name());
- pp.addProp("SF Ip", vPort.fixedIps().iterator().next().ip());
- }
- }
- pp.addProp("SF host Address", hostId.toString());
- }
-
-}
diff --git a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/package-info.java b/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/package-info.java
deleted file mode 100644
index 3d0d1b1..0000000
--- a/apps/vtn/sfcweb/src/main/java/org/onosproject/sfcweb/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * SFC service topology view overlay.
- */
-package org.onosproject.sfcweb;
diff --git a/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopov.css b/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopov.css
deleted file mode 100644
index 8729afe..0000000
--- a/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopov.css
+++ /dev/null
@@ -1 +0,0 @@
-/* css for sfcweb app topology overlay */
diff --git a/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopov.html b/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopov.html
deleted file mode 100644
index 4a420ea..0000000
--- a/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopov.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<!-- partial HTML -->
-<div id="ov-sfcweb-topov">
- <p>This is a hidden view .. just a placeholder to house the javascript</p>
-</div>
diff --git a/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopovDemo.js b/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopovDemo.js
deleted file mode 100644
index ce55be0..0000000
--- a/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopovDemo.js
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- sfc web gui overlay implementation.
- */
-
-(function () {
- 'use strict';
-
- // injected refs
- var $log, fs, flash, wss, tds, ds, handlerMap = {};
-
- // constants
- var displayStart = 'sfcwebTopovDisplayStart',
- showSfcInf = 'showSfcInfo',
- clearMessage = 'sfcTopovClear',
- configSfpMessage = 'configSfpMessage',
- sfcPath = 'showSfcPath' ;
-
- // internal state
- var currentMode = null;
- var sfpInfo;
-
- // === Main API functions
-
- function start() {
- handlerMap[showSfcInf] = showSfcInformation;
- handlerMap[sfcPath] = showSfcPath;
- wss.bindHandlers(handlerMap);
- wss.sendEvent(displayStart);
- }
-
- function dOkSfp() {
- var tdString;
- var i = 0;
-
- sfpInfo.a.forEach( function () {
- var sfpId = d3.select("#sfp-value-id-"+i).property("checked");
- if (sfpId)
- {
- tdString = sfpInfo.a[i];
- }
- i++;
- } );
-
- if (!tdString) {
- $log.debug("No SFP ID is selected.");
- }
-
- wss.sendEvent(configSfpMessage, {
- id: tdString
- });
-
- flash.flash('SFP ID query:');
- }
-
- function dClose() {
- $log.debug('Dialog Close button clicked (or Esc pressed)');
- }
-
- function createUserTextSfp(data) {
- console.log(data);
-
- var content = ds.createDiv();
- var form = content.append('form');
- var p = form.append('p');
- var i = 0;
-
- p.append('span').text('SFP IDs');
- p.append('br');
- sfpInfo = data;
- data.a.forEach( function () {
-
- p.append('input').attr({
- id: 'sfp-value-id-'+i,
- type: 'radio',
- name: 'sfp-id-name',
- value: data.a[i]
- });
-
- p.append('span').text(data.a[i]);
- p.append('br');
- i++;
- } );
-
- return content;
- }
-
- function showSfcInformation(data) {
- tds.openDialog()
- .setTitle('List of active service functions')
- .addContent(createUserTextSfp(data))
- .addOk(dOkSfp, 'Select SFP ID')
- .addCancel(dClose, 'Close')
- .bindKeys();
-
- }
-
- function createSfcPathText(data) {
-
- var content = ds.createDiv();
- var form = content.append('form');
- var p = form.append('p');
- var i = 0;
-
- p.append('span').text('SFC Path');
- p.append('br');
- data.sfcPathList.forEach( function (val, idx) {
- p.append('span').text(val);
- p.append('br')
- } );
-
- return content;
- }
-
- function showSfcPath(data) {
- tds.openDialog()
- .setTitle('Service function path')
- .addContent(createSfcPathText(data))
- .addCancel(dClose, 'Close')
- .bindKeys();
- }
-
- function clear() {
- wss.sendEvent(clearMessage);
- flash.flash('Cleared SFC overlay');
- }
-
- // === ---------------------------
- // === Module Factory Definition
- angular.module('ovSfcwebTopov', [])
- .factory('SfcwebTopovDemoService',
- ['$log', 'FnService', 'FlashService', 'WebSocketService', 'TopoDialogService', 'DialogService',
- function (_$log_, _fs_, _flash_, _wss_, _tds_, _ds_) {
- $log = _$log_;
- fs = _fs_;
- flash = _flash_;
- wss = _wss_;
- tds = _tds_;
- ds = _ds_;
- return {
- start: start,
- showSfcInformation: showSfcInformation,
- showSfcPath : showSfcPath,
- clear: clear
- };
- }]);
-
-}());
diff --git a/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopovOverlay.js b/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopovOverlay.js
deleted file mode 100644
index 5f5c118..0000000
--- a/apps/vtn/sfcweb/src/main/resources/app/view/sfcwebTopov/sfcwebTopovOverlay.js
+++ /dev/null
@@ -1,71 +0,0 @@
-// sfcweb topology overlay - client side
-//
-// This is the glue that binds our business logic (in sfcwebTopovDemo.js)
-// to the overlay framework.
-
-(function () {
- 'use strict';
-
- // injected refs
- var $log, tov, pps;
- var longPrefix = 'M15.9,19.1h-8v-13h8V19.1z M90.5,6.1H75.6v13h14.9V6.1' +
- 'z M71.9,6.1H56.9v13h14.9V6.1z M53.2,6.1H38.3v13h14.9V6.1z M34.5,' +
- '6.1H19.6v13h14.9V6.1z M102.2,6.1h-8v13h8V6.1z' ;
-
- // our overlay definition
- var overlay = {
- // NOTE: this must match the ID defined in SfcWebUiTopovOverlay
- overlayId: 'SFC-Service-overlay',
- glyphId: '*star4',
- tooltip: 'SFC web service Topo Overlay',
-
- // These glyphs get installed using the overlayId as a prefix.
- // e.g. 'star4' is installed as 'meowster-overlay-star4'
- // They can be referenced (from this overlay) as '*star4'
- // That is, the '*' prefix stands in for 'meowster-overlay-'
- glyphs: {
- star4: {
- vb: '0 0 8 8',
- d: 'M1,4l2,-1l1,-2l1,2l2,1l-2,1l-1,2l-1,-2z'
- }
- },
- activate: function () {
- $log.debug("SFC service topology overlay ACTIVATED");
- },
- deactivate: function () {
- pps.clear();
- $log.debug("SFC service topology overlay DEACTIVATED");
- },
-
- // Key bindings for traffic overlay buttons
- // NOTE: fully qual. button ID is derived from overlay-id and key-name
- // FIXME: find better keys for shortest paths & disjoint paths modes
- keyBindings: {
- 4: {
- cb: function () {
- pps.start();
- },
- tt: 'Query SFP active list information',
- gid: 'summary'
- },
-
- _keyOrder: [
- '4'
- ]
- }
-
- };
-
- // invoke code to register with the overlay service
- angular.module('ovSfcwebTopov')
- .run(['$log', 'TopoOverlayService', 'SfcwebTopovDemoService',
-
- function (_$log_, _tov_, _pps_) {
- $log = _$log_;
- tov = _tov_;
- pps = _pps_;
- tov.register(overlay);
- $log.debug('ovSfcwebTopov run');
- }]);
-
-}());
diff --git a/apps/vtn/sfcweb/src/main/resources/sfcwebTopov/css.html b/apps/vtn/sfcweb/src/main/resources/sfcwebTopov/css.html
deleted file mode 100644
index 4e201d7..0000000
--- a/apps/vtn/sfcweb/src/main/resources/sfcwebTopov/css.html
+++ /dev/null
@@ -1 +0,0 @@
-<link rel="stylesheet" href="app/view/sfcwebTopov/sfcwebTopov.css">
\ No newline at end of file
diff --git a/apps/vtn/sfcweb/src/main/resources/sfcwebTopov/js.html b/apps/vtn/sfcweb/src/main/resources/sfcwebTopov/js.html
deleted file mode 100644
index 4a6ab75..0000000
--- a/apps/vtn/sfcweb/src/main/resources/sfcwebTopov/js.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<script src="app/view/sfcwebTopov/sfcwebTopovDemo.js"></script>
-<script src="app/view/sfcwebTopov/sfcwebTopovOverlay.js"></script>
diff --git a/apps/vtn/vtnmgr/BUILD b/apps/vtn/vtnmgr/BUILD
deleted file mode 100644
index d399cdc..0000000
--- a/apps/vtn/vtnmgr/BUILD
+++ /dev/null
@@ -1,11 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + JACKSON + KRYO + CLI + [
- "//core/store/serializers:onos-core-serializers",
- "//apps/vtn/vtnrsc:onos-apps-vtn-vtnrsc",
-]
-
-osgi_jar_with_tests(
- karaf_command_packages = ["org.onosproject.vtn.cli"],
- resources = glob(["src/main/resources/**"]),
- resources_root = "src/main/resources",
- deps = COMPILE_DEPS,
-)
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/cli/VtnCommand.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/cli/VtnCommand.java
deleted file mode 100644
index 1fed65f..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/cli/VtnCommand.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.cli;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtn.manager.impl.VtnManager;
-
-/**
- * Supports for updating the external gateway virtualPort.
- */
-@Service
-@Command(scope = "onos", name = "externalportname-set",
- description = "Supports for setting the external port name.")
-public class VtnCommand extends AbstractShellCommand {
-
- @Option(name = "-n", aliases = "--name", description = "external port name.", required = true,
- multiValued = false)
- String exPortName = "";
-
- @Override
- protected void doExecute() {
- VtnManager.setExPortName(exPortName);
- }
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/cli/package-info.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/cli/package-info.java
deleted file mode 100644
index 64ac33d..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/cli/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-package org.onosproject.vtn.cli;
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/VtnService.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/VtnService.java
deleted file mode 100644
index caec3fa..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/VtnService.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.manager;
-
-import org.onosproject.net.Device;
-import org.onosproject.net.Host;
-import org.onosproject.vtnrsc.event.VtnRscEventFeedback;
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-public interface VtnService {
-
- /**
- * Creates a vxlan tunnel and creates the ovs when a ovs controller node is
- * detected.
- *
- * @param device controller-type device
- */
- void onControllerDetected(Device device);
-
- /**
- * Drops a vxlan tunnel and drops the ovs when a ovs controller node is
- * vanished.
- *
- * @param device controller-type device
- */
- void onControllerVanished(Device device);
-
- /**
- * Applies default forwarding flows when a ovs is detected.
- *
- * @param device switch-type device
- */
- void onOvsDetected(Device device);
-
- /**
- * Remove default forwarding flows when a ovs is vanished.
- *
- * @param device switch-type device
- */
- void onOvsVanished(Device device);
-
- /**
- * Applies multicast flows and tunnel flows when a VM is detected.
- *
- * @param host a VM
- */
- void onHostDetected(Host host);
-
- /**
- * Remove multicast flows and tunnel flows when a VM is vanished.
- *
- * @param host a VM
- */
- void onHostVanished(Host host);
-
- /**
- * Applies east west flows when neutron created router interface.
- *
- * @param l3Feedback VtnrscEventFeedback
- */
- void onRouterInterfaceDetected(VtnRscEventFeedback l3Feedback);
-
- /**
- * Remove east west flows when neutron removed router interface.
- *
- * @param l3Feedback VtnrscEventFeedback
- */
- void onRouterInterfaceVanished(VtnRscEventFeedback l3Feedback);
-
- /**
- * Applies north south flows when neutron bind floating ip.
- *
- * @param l3Feedback VtnrscEventFeedback
- */
- void onFloatingIpDetected(VtnRscEventFeedback l3Feedback);
-
- /**
- * Applies north south flows when neutron unbind floating ip.
- *
- * @param l3Feedback VtnrscEventFeedback
- */
- void onFloatingIpVanished(VtnRscEventFeedback l3Feedback);
-
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/impl/VtnManager.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/impl/VtnManager.java
deleted file mode 100644
index 427aba8..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/impl/VtnManager.java
+++ /dev/null
@@ -1,1657 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.manager.impl;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import org.onlab.packet.ARP;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.HostId;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.behaviour.BridgeConfig;
-import org.onosproject.net.behaviour.BridgeDescription;
-import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.config.basics.BasicDeviceConfig;
-import org.onosproject.net.config.basics.BasicHostConfig;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.FlowEntry;
-import org.onosproject.net.flow.FlowRuleService;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.TrafficTreatment.Builder;
-import org.onosproject.net.flow.criteria.Criterion;
-import org.onosproject.net.flow.instructions.ExtensionTreatment;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.net.group.DefaultGroupBucket;
-import org.onosproject.net.group.DefaultGroupDescription;
-import org.onosproject.net.group.DefaultGroupKey;
-import org.onosproject.net.group.GroupBucket;
-import org.onosproject.net.group.GroupBuckets;
-import org.onosproject.net.group.GroupDescription;
-import org.onosproject.net.group.GroupKey;
-import org.onosproject.net.group.GroupService;
-import org.onosproject.net.host.HostEvent;
-import org.onosproject.net.host.HostListener;
-import org.onosproject.net.host.HostService;
-import org.onosproject.net.packet.DefaultOutboundPacket;
-import org.onosproject.net.packet.InboundPacket;
-import org.onosproject.net.packet.OutboundPacket;
-import org.onosproject.net.packet.PacketContext;
-import org.onosproject.net.packet.PacketProcessor;
-import org.onosproject.net.packet.PacketService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.LogicalClockService;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.Versioned;
-import org.onosproject.vtn.manager.VtnService;
-import org.onosproject.vtn.table.ArpService;
-import org.onosproject.vtn.table.ClassifierService;
-import org.onosproject.vtn.table.DnatService;
-import org.onosproject.vtn.table.L2ForwardService;
-import org.onosproject.vtn.table.L3ForwardService;
-import org.onosproject.vtn.table.SnatService;
-import org.onosproject.vtn.table.impl.ArpServiceImpl;
-import org.onosproject.vtn.table.impl.ClassifierServiceImpl;
-import org.onosproject.vtn.table.impl.DnatServiceImpl;
-import org.onosproject.vtn.table.impl.L2ForwardServiceImpl;
-import org.onosproject.vtn.table.impl.L3ForwardServiceImpl;
-import org.onosproject.vtn.table.impl.SnatServiceImpl;
-import org.onosproject.vtn.util.DataPathIdGenerator;
-import org.onosproject.vtn.util.IpUtil;
-import org.onosproject.vtn.util.VtnConfig;
-import org.onosproject.vtn.util.VtnData;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.DefaultFloatingIp;
-import org.onosproject.vtnrsc.DefaultVirtualPort;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.FloatingIp;
-import org.onosproject.vtnrsc.FloatingIpId;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.RouterInterface;
-import org.onosproject.vtnrsc.SecurityGroup;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.TenantRouter;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.event.VtnRscEvent;
-import org.onosproject.vtnrsc.event.VtnRscEventFeedback;
-import org.onosproject.vtnrsc.event.VtnRscListener;
-import org.onosproject.vtnrsc.floatingip.FloatingIpService;
-import org.onosproject.vtnrsc.routerinterface.RouterInterfaceService;
-import org.onosproject.vtnrsc.service.VtnRscService;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.stream.Collectors;
-
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of VTNService.
- */
-@Component(immediate = true, service = VtnService.class)
-public class VtnManager implements VtnService {
- private final Logger log = getLogger(getClass());
- private static final String APP_ID = "org.onosproject.app.vtn";
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigService configService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceService deviceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected HostService hostService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TenantNetworkService tenantNetworkService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected VirtualPortService virtualPortService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DriverService driverService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LogicalClockService clockService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected MastershipService mastershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected GroupService groupService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected SubnetService subnetService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected VtnRscService vtnRscService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected FloatingIpService floatingIpService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected RouterInterfaceService routerInterfaceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected FlowRuleService flowRuleService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigService networkConfigService;
-
- private ApplicationId appId;
- private ClassifierService classifierService;
- private L2ForwardService l2ForwardService;
- private ArpService arpService;
- private L3ForwardService l3ForwardService;
- private SnatService snatService;
- private DnatService dnatService;
-
- private final HostListener hostListener = new InnerHostListener();
- private final DeviceListener deviceListener = new InnerDeviceListener();
- private final VtnRscListener l3EventListener = new VtnL3EventListener();
-
- private static final String EX_PORT_KEY = "exPortKey";
- private static final String IFACEID = "ifaceid";
- private static final String CONTROLLER_IP_KEY = "ipaddress";
- public static final String DRIVER_NAME = "onosfw";
- private static final String VIRTUALPORT = "vtn-virtual-port";
- private static final String SWITCHES_OF_CONTROLLER = "switchesOfController";
- private static final String SWITCH_OF_LOCAL_HOST_PORTS = "switchOfLocalHostPorts";
- private static final String ROUTERINF_FLAG_OF_TENANTROUTER = "routerInfFlagOfTenantRouter";
- private static final String HOSTS_OF_SUBNET = "hostsOfSubnet";
- private static final String EX_PORT_OF_DEVICE = "exPortOfDevice";
- private static final String EX_PORT_MAP = "exPortMap";
- private static final String DEFAULT_IP = "0.0.0.0";
- private static final String FLOATINGSTORE = "vtn-floatingIp";
- private static final String USERDATA_IP = "169.254.169.254";
- private static final int SUBNET_NUM = 2;
- private static final int SNAT_TABLE = 40;
- private static final int SNAT_DEFAULT_RULE_PRIORITY = 0;
- private static final byte[] ZERO_MAC_ADDRESS = MacAddress.ZERO.toBytes();
-
- private EventuallyConsistentMap<VirtualPortId, VirtualPort> vPortStore;
- private EventuallyConsistentMap<IpAddress, Boolean> switchesOfController;
- private EventuallyConsistentMap<DeviceId, NetworkOfLocalHostPorts> switchOfLocalHostPorts;
- private EventuallyConsistentMap<SubnetId, Map<HostId, Host>> hostsOfSubnet;
- private EventuallyConsistentMap<TenantRouter, Boolean> routerInfFlagOfTenantRouter;
- private EventuallyConsistentMap<DeviceId, Port> exPortOfDevice;
- private EventuallyConsistentMap<IpAddress, FloatingIp> floatingIpStore;
- private static ConsistentMap<String, String> exPortMap;
-
- private VtnL3PacketProcessor l3PacketProcessor = new VtnL3PacketProcessor();
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PacketService packetService;
-
- @Activate
- public void activate() {
- appId = coreService.registerApplication(APP_ID);
- classifierService = new ClassifierServiceImpl(appId);
- l2ForwardService = new L2ForwardServiceImpl(appId);
- arpService = new ArpServiceImpl(appId);
- l3ForwardService = new L3ForwardServiceImpl(appId);
- snatService = new SnatServiceImpl(appId);
- dnatService = new DnatServiceImpl(appId);
-
- deviceService.addListener(deviceListener);
- hostService.addListener(hostListener);
- vtnRscService.addListener(l3EventListener);
-
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API)
- .register(NetworkOfLocalHostPorts.class)
- .register(TenantNetworkId.class)
- .register(Host.class)
- .register(TenantNetwork.class)
- .register(TenantNetworkId.class)
- .register(TenantId.class)
- .register(SubnetId.class)
- .register(VirtualPortId.class)
- .register(VirtualPort.State.class)
- .register(AllowedAddressPair.class)
- .register(FixedIp.class)
- .register(FloatingIp.class)
- .register(FloatingIpId.class)
- .register(FloatingIp.Status.class)
- .register(UUID.class)
- .register(DefaultFloatingIp.class)
- .register(BindingHostId.class)
- .register(SecurityGroup.class)
- .register(IpAddress.class)
- .register(DefaultVirtualPort.class)
- .register(RouterId.class)
- .register(TenantRouter.class);
- floatingIpStore = storageService
- .<IpAddress, FloatingIp>eventuallyConsistentMapBuilder()
- .withName(FLOATINGSTORE).withSerializer(serializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
-
- vPortStore = storageService
- .<VirtualPortId, VirtualPort>eventuallyConsistentMapBuilder()
- .withName(VIRTUALPORT).withSerializer(serializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
-
- switchesOfController = storageService
- .<IpAddress, Boolean>eventuallyConsistentMapBuilder()
- .withName(SWITCHES_OF_CONTROLLER).withSerializer(serializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
-
- switchOfLocalHostPorts = storageService
- .<DeviceId, NetworkOfLocalHostPorts>eventuallyConsistentMapBuilder()
- .withName(SWITCH_OF_LOCAL_HOST_PORTS).withSerializer(serializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
-
- hostsOfSubnet = storageService
- .<SubnetId, Map<HostId, Host>>eventuallyConsistentMapBuilder()
- .withName(HOSTS_OF_SUBNET).withSerializer(serializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
-
- routerInfFlagOfTenantRouter = storageService
- .<TenantRouter, Boolean>eventuallyConsistentMapBuilder()
- .withName(ROUTERINF_FLAG_OF_TENANTROUTER).withSerializer(serializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
-
- exPortOfDevice = storageService
- .<DeviceId, Port>eventuallyConsistentMapBuilder()
- .withName(EX_PORT_OF_DEVICE).withSerializer(serializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
-
- exPortMap = storageService
- .<String, String>consistentMapBuilder()
- .withName(EX_PORT_MAP)
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API)))
- .build();
-
- packetService.addProcessor(l3PacketProcessor, PacketProcessor.director(0));
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- deviceService.removeListener(deviceListener);
- hostService.removeListener(hostListener);
- vtnRscService.removeListener(l3EventListener);
- log.info("Stopped");
- }
-
- @Override
- public void onControllerDetected(Device controllerDevice) {
- if (controllerDevice == null) {
- log.error("The controller device is null");
- return;
- }
- String localIpAddress = controllerDevice.annotations()
- .value(CONTROLLER_IP_KEY);
- IpAddress localIp = IpAddress.valueOf(localIpAddress);
- DeviceId controllerDeviceId = controllerDevice.id();
- DriverHandler handler = driverService.createHandler(controllerDeviceId);
- if (mastershipService.isLocalMaster(controllerDeviceId)) {
- // Get DataPathIdGenerator
- String ipaddress = controllerDevice.annotations().value("ipaddress");
- DataPathIdGenerator dpidGenerator = DataPathIdGenerator.builder()
- .addIpAddress(ipaddress).build();
- DeviceId deviceId = dpidGenerator.getDeviceId();
- String dpid = dpidGenerator.getDpId();
- // Inject pipeline driver name
- BasicDeviceConfig config = configService.addConfig(deviceId,
- BasicDeviceConfig.class);
- config.driver(DRIVER_NAME);
- configService.applyConfig(deviceId, BasicDeviceConfig.class, config.node());
- // Add Bridge
- Versioned<String> exPortVersioned = exPortMap.get(EX_PORT_KEY);
- if (exPortVersioned != null) {
- VtnConfig.applyBridgeConfig(handler, dpid, exPortVersioned.value());
- log.info("A new ovs is created in node {}", localIp.toString());
- }
- switchesOfController.put(localIp, true);
- }
- // Create tunnel in br-int on all controllers
- programTunnelConfig(controllerDeviceId, localIp, handler);
- }
-
- @Override
- public void onControllerVanished(Device controllerDevice) {
- if (controllerDevice == null) {
- log.error("The device is null");
- return;
- }
- String dstIp = controllerDevice.annotations().value(CONTROLLER_IP_KEY);
- IpAddress dstIpAddress = IpAddress.valueOf(dstIp);
- DeviceId controllerDeviceId = controllerDevice.id();
- if (mastershipService.isLocalMaster(controllerDeviceId)) {
- switchesOfController.remove(dstIpAddress);
- }
- }
-
- @Override
- public void onOvsDetected(Device device) {
- if (device == null) {
- log.error("The device is null");
- return;
- }
- if (!mastershipService.isLocalMaster(device.id())) {
- return;
- }
- // Create tunnel out flow rules
- applyTunnelOut(device, Objective.Operation.ADD);
- // apply L3 arp flows
- Iterable<RouterInterface> interfaces = routerInterfaceService
- .getRouterInterfaces();
- interfaces.forEach(routerInf -> {
- VirtualPort gwPort = virtualPortService.getPort(routerInf.portId());
- if (gwPort == null) {
- gwPort = VtnData.getPort(vPortStore, routerInf.portId());
- }
- applyL3ArpFlows(device.id(), gwPort, Objective.Operation.ADD);
- });
- }
-
- @Override
- public void onOvsVanished(Device device) {
- if (device == null) {
- log.error("The device is null");
- return;
- }
- if (!mastershipService.isLocalMaster(device.id())) {
- return;
- }
- // Remove Tunnel out flow rules
- applyTunnelOut(device, Objective.Operation.REMOVE);
- // apply L3 arp flows
- Iterable<RouterInterface> interfaces = routerInterfaceService
- .getRouterInterfaces();
- interfaces.forEach(routerInf -> {
- VirtualPort gwPort = virtualPortService.getPort(routerInf.portId());
- if (gwPort == null) {
- gwPort = VtnData.getPort(vPortStore, routerInf.portId());
- }
- applyL3ArpFlows(device.id(), gwPort, Objective.Operation.REMOVE);
- });
- }
-
- @Override
- public void onHostDetected(Host host) {
- DeviceId deviceId = host.location().deviceId();
- if (!mastershipService.isLocalMaster(deviceId)) {
- return;
- }
- String ifaceId = host.annotations().value(IFACEID);
- if (ifaceId == null) {
- log.error("The ifaceId of Host is null");
- return;
- }
- programSffAndClassifierHost(host, Objective.Operation.ADD);
- // apply L2 openflow rules
- applyHostMonitoredL2Rules(host, Objective.Operation.ADD);
- // apply L3 openflow rules
- applyHostMonitoredL3Rules(host, Objective.Operation.ADD);
- }
-
- @Override
- public void onHostVanished(Host host) {
- DeviceId deviceId = host.location().deviceId();
- if (!mastershipService.isLocalMaster(deviceId)) {
- return;
- }
- String ifaceId = host.annotations().value(IFACEID);
- if (ifaceId == null) {
- log.error("The ifaceId of Host is null");
- return;
- }
- programSffAndClassifierHost(host, Objective.Operation.REMOVE);
- // apply L2 openflow rules
- applyHostMonitoredL2Rules(host, Objective.Operation.REMOVE);
- // apply L3 openflow rules
- applyHostMonitoredL3Rules(host, Objective.Operation.REMOVE);
- VirtualPortId virtualPortId = VirtualPortId.portId(ifaceId);
- vPortStore.remove(virtualPortId);
- }
-
- private void programTunnelConfig(DeviceId localDeviceId, IpAddress localIp,
- DriverHandler localHandler) {
- if (mastershipService.isLocalMaster(localDeviceId)) {
- VtnConfig.applyTunnelConfig(localHandler, localIp);
- log.info("Add tunnel on {}", localIp);
- }
- }
-
- private void applyTunnelOut(Device device, Objective.Operation type) {
- String controllerIp = VtnData.getControllerIpOfSwitch(device);
- if (controllerIp == null) {
- log.error("Can't find controller of device: {}",
- device.id().toString());
- return;
- }
- IpAddress ipAddress = IpAddress.valueOf(controllerIp);
- if (!switchesOfController.containsKey(ipAddress)) {
- log.error("Can't find controller of device: {}",
- device.id().toString());
- return;
- }
- if (type == Objective.Operation.ADD) {
- // Save external port
- Port export = getExPort(device.id());
- if (export != null) {
- classifierService.programExportPortArpClassifierRules(export,
- device.id(),
- type);
- exPortOfDevice.put(device.id(), export);
- }
- switchOfLocalHostPorts.put(device.id(), new NetworkOfLocalHostPorts());
- } else if (type == Objective.Operation.REMOVE) {
- exPortOfDevice.remove(device.id());
- switchOfLocalHostPorts.remove(device.id());
- }
- Iterable<Device> devices = deviceService.getAvailableDevices();
- DeviceId localControllerId = VtnData.getControllerId(device, devices);
- DriverHandler handler = driverService.createHandler(localControllerId);
- Set<PortNumber> ports = VtnConfig.getPortNumbers(handler);
- Iterable<Host> allHosts = hostService.getHosts();
- String tunnelName = "vxlan-" + DEFAULT_IP;
- if (allHosts != null) {
- Sets.newHashSet(allHosts).forEach(host -> {
- MacAddress hostMac = host.mac();
- String ifaceId = host.annotations().value(IFACEID);
- if (ifaceId == null) {
- log.error("The ifaceId of Host is null");
- return;
- }
- VirtualPortId virtualPortId = VirtualPortId.portId(ifaceId);
- VirtualPort virtualPort = virtualPortService
- .getPort(virtualPortId);
- TenantNetwork network = tenantNetworkService
- .getNetwork(virtualPort.networkId());
- SegmentationId segmentationId = network.segmentationId();
- DeviceId remoteDeviceId = host.location().deviceId();
- Device remoteDevice = deviceService.getDevice(remoteDeviceId);
- String remoteControllerIp = VtnData
- .getControllerIpOfSwitch(remoteDevice);
- if (remoteControllerIp == null) {
- log.error("Can't find remote controller of device: {}",
- remoteDeviceId.toString());
- return;
- }
- IpAddress remoteIpAddress = IpAddress
- .valueOf(remoteControllerIp);
- ports.stream()
- .filter(p -> p.name().equalsIgnoreCase(tunnelName))
- .forEach(p -> {
- l2ForwardService
- .programTunnelOut(device.id(), segmentationId, p,
- hostMac, type, remoteIpAddress);
- });
- });
- }
- }
-
- private void programSffAndClassifierHost(Host host, Objective.Operation type) {
- DeviceId deviceId = host.location().deviceId();
- String ifaceId = host.annotations().value(IFACEID);
- VirtualPortId virtualPortId = VirtualPortId.portId(ifaceId);
- VirtualPort virtualPort = virtualPortService.getPort(virtualPortId);
- if (virtualPort == null) {
- virtualPort = VtnData.getPort(vPortStore, virtualPortId);
- }
- TenantId tenantId = virtualPort.tenantId();
- if (Objective.Operation.ADD == type) {
- vtnRscService.addDeviceIdOfOvsMap(virtualPortId, tenantId, deviceId);
- } else if (Objective.Operation.REMOVE == type) {
- vtnRscService.removeDeviceIdOfOvsMap(host, tenantId, deviceId);
- }
- }
-
- private void applyHostMonitoredL2Rules(Host host, Objective.Operation type) {
- DeviceId deviceId = host.location().deviceId();
- if (!mastershipService.isLocalMaster(deviceId)) {
- return;
- }
- String ifaceId = host.annotations().value(IFACEID);
- if (ifaceId == null) {
- log.error("The ifaceId of Host is null");
- return;
- }
- VirtualPortId virtualPortId = VirtualPortId.portId(ifaceId);
- VirtualPort virtualPort = virtualPortService.getPort(virtualPortId);
- if (virtualPort == null) {
- virtualPort = VtnData.getPort(vPortStore, virtualPortId);
- }
- Iterator<FixedIp> fixip = virtualPort.fixedIps().iterator();
- SubnetId subnetId = null;
- if (fixip.hasNext()) {
- subnetId = fixip.next().subnetId();
- }
- if (subnetId != null) {
- Map<HostId, Host> hosts = new ConcurrentHashMap();
- if (hostsOfSubnet.get(subnetId) != null) {
- hosts = hostsOfSubnet.get(subnetId);
- }
- if (type == Objective.Operation.ADD) {
- hosts.put(host.id(), host);
- hostsOfSubnet.put(subnetId, hosts);
- } else if (type == Objective.Operation.REMOVE) {
- hosts.remove(host.id());
- if (hosts.size() != 0) {
- hostsOfSubnet.put(subnetId, hosts);
- } else {
- hostsOfSubnet.remove(subnetId);
- }
- }
- }
-
- Iterable<Device> devices = deviceService.getAvailableDevices();
- PortNumber inPort = host.location().port();
- MacAddress mac = host.mac();
- Device device = deviceService.getDevice(deviceId);
- String controllerIp = VtnData.getControllerIpOfSwitch(device);
- IpAddress ipAddress = IpAddress.valueOf(controllerIp);
- TenantNetwork network = tenantNetworkService.getNetwork(virtualPort.networkId());
- if (network == null) {
- log.error("Can't find network of the host");
- return;
- }
- SegmentationId segmentationId = network.segmentationId();
- // Get all the tunnel PortNumber in the current node
- Iterable<Port> ports = deviceService.getPorts(deviceId);
- Collection<PortNumber> localTunnelPorts = VtnData.getLocalTunnelPorts(ports);
- // Get all the local vm's PortNumber in the current node
- Map<TenantNetworkId, Set<PortNumber>> localHostPorts = switchOfLocalHostPorts
- .get(deviceId).getNetworkOfLocalHostPorts();
- Set<PortNumber> networkOflocalHostPorts = localHostPorts.get(network.id());
- for (PortNumber p : localTunnelPorts) {
- programGroupTable(deviceId, appId, p, devices, type);
- }
- Subnet subnet = subnetService.getSubnet(subnetId);
- String deviceOwner = virtualPort.deviceOwner();
- if (deviceOwner != null) {
- if ("network:dhcp".equalsIgnoreCase(deviceOwner)) {
- Sets.newHashSet(devices).stream()
- .filter(d -> d.type() == Device.Type.SWITCH)
- .forEach(d -> {
- if (subnet != null) {
- IpAddress dstIp = IpAddress
- .valueOf(USERDATA_IP);
- classifierService
- .programUserdataClassifierRules(d.id(),
- subnet.cidr(),
- dstIp,
- mac,
- segmentationId,
- type);
- }
- });
- }
- }
- if (type == Objective.Operation.ADD) {
- vPortStore.put(virtualPortId, virtualPort);
- if (networkOflocalHostPorts == null) {
- networkOflocalHostPorts = new HashSet<PortNumber>();
- localHostPorts.putIfAbsent(network.id(), networkOflocalHostPorts);
- }
- networkOflocalHostPorts.add(inPort);
- l2ForwardService.programLocalBcastRules(deviceId, segmentationId,
- inPort, networkOflocalHostPorts,
- localTunnelPorts,
- type);
- classifierService.programTunnelIn(deviceId, segmentationId,
- localTunnelPorts,
- type);
- } else if (type == Objective.Operation.REMOVE) {
- if (networkOflocalHostPorts != null) {
- l2ForwardService.programLocalBcastRules(deviceId, segmentationId,
- inPort, networkOflocalHostPorts,
- localTunnelPorts,
- type);
- networkOflocalHostPorts.remove(inPort);
- if (networkOflocalHostPorts.isEmpty()) {
- classifierService.programTunnelIn(deviceId, segmentationId,
- localTunnelPorts,
- type);
- switchOfLocalHostPorts.get(deviceId).getNetworkOfLocalHostPorts()
- .remove(virtualPort.networkId());
- }
- }
- }
-
- l2ForwardService.programLocalOut(deviceId, segmentationId, inPort, mac,
- type);
-
- l2ForwardService.programTunnelBcastRules(deviceId, segmentationId,
- networkOflocalHostPorts,
- localTunnelPorts,
- type);
-
- programTunnelOuts(devices, ipAddress, segmentationId, mac,
- type);
-
- classifierService.programLocalIn(deviceId, segmentationId, inPort, mac,
- appId, type);
- }
-
- private void programTunnelOuts(Iterable<Device> devices,
- IpAddress ipAddress,
- SegmentationId segmentationId,
- MacAddress dstMac,
- Objective.Operation type) {
- String tunnelName = "vxlan-" + DEFAULT_IP;
- Sets.newHashSet(devices).stream()
- .filter(d -> d.type() == Device.Type.CONTROLLER)
- .filter(d -> !("ovsdb:" + ipAddress).equals(d.id().toString()))
- .forEach(d -> {
- DriverHandler handler = driverService.createHandler(d.id());
- BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
- Collection<BridgeDescription> bridgeDescriptions = bridgeConfig.getBridges();
- for (BridgeDescription sw : bridgeDescriptions) {
- if (sw.name().equals(VtnConfig.DEFAULT_BRIDGE_NAME) &&
- sw.deviceId().isPresent()) {
- List<Port> ports = deviceService.getPorts(sw.deviceId().get());
- ports.stream().filter(p -> p.annotations().value(AnnotationKeys.PORT_NAME)
- .equalsIgnoreCase(tunnelName))
- .forEach(p -> l2ForwardService.programTunnelOut(
- sw.deviceId().get(), segmentationId, p.number(),
- dstMac, type, ipAddress));
- break;
- }
- }
- });
- }
-
- private class InnerDeviceListener implements DeviceListener {
-
- @Override
- public void event(DeviceEvent event) {
- Device device = event.subject();
- if (Device.Type.CONTROLLER == device.type()) {
- if (DeviceEvent.Type.DEVICE_ADDED == event.type()) {
- onControllerDetected(device);
- }
- if (DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event.type()) {
- if (deviceService.isAvailable(device.id())) {
- onControllerDetected(device);
- } else {
- onControllerVanished(device);
- }
- }
- } else if (Device.Type.SWITCH == device.type()) {
- if (DeviceEvent.Type.DEVICE_ADDED == event.type()) {
- onOvsDetected(device);
- }
- if (DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event.type()) {
- if (deviceService.isAvailable(device.id())) {
- onOvsDetected(device);
- } else {
- onOvsVanished(device);
- }
- }
- } else {
- log.info("Do nothing for this device type");
- }
- }
- }
-
- private class InnerHostListener implements HostListener {
-
- @Override
- public void event(HostEvent event) {
- Host host = event.subject();
- if (HostEvent.Type.HOST_ADDED == event.type()) {
- onHostDetected(host);
- } else if (HostEvent.Type.HOST_REMOVED == event.type()) {
- onHostVanished(host);
- } else if (HostEvent.Type.HOST_UPDATED == event.type()) {
- onHostVanished(host);
- onHostDetected(host);
- }
- }
-
- }
-
- // Local Host Ports of Network.
- private class NetworkOfLocalHostPorts {
- private final Map<TenantNetworkId, Set<PortNumber>> networkOfLocalHostPorts =
- new HashMap<TenantNetworkId, Set<PortNumber>>();
-
- public Map<TenantNetworkId, Set<PortNumber>> getNetworkOfLocalHostPorts() {
- return networkOfLocalHostPorts;
- }
- }
-
- private void programGroupTable(DeviceId deviceId, ApplicationId appid,
- PortNumber portNumber, Iterable<Device> devices, Objective.Operation type) {
- if (type.equals(Objective.Operation.REMOVE)) {
- return;
- }
-
- List<GroupBucket> buckets = Lists.newArrayList();
- Sets.newHashSet(devices)
- .stream()
- .filter(d -> d.type() == Device.Type.CONTROLLER)
- .filter(d -> !deviceId.equals(d.id()))
- .forEach(d -> {
- String ipAddress = d.annotations()
- .value(CONTROLLER_IP_KEY);
- Ip4Address dst = Ip4Address.valueOf(ipAddress);
- Builder builder = DefaultTrafficTreatment.builder();
-
- DriverHandler handler = driverService.createHandler(deviceId);
- ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class);
- ExtensionTreatment treatment = resolver.getExtensionInstruction(NICIRA_SET_TUNNEL_DST.type());
- try {
- treatment.setPropertyValue("tunnelDst", dst);
- } catch (Exception e) {
- log.error("Failed to get extension instruction to set tunnel dst {}", deviceId);
- }
-
- builder.extension(treatment, deviceId);
- builder.setOutput(portNumber);
- GroupBucket bucket = DefaultGroupBucket
- .createAllGroupBucket(builder.build());
- buckets.add(bucket);
- });
- final GroupKey key = new DefaultGroupKey(APP_ID.getBytes());
- GroupDescription groupDescription = new DefaultGroupDescription(deviceId,
- GroupDescription.Type.ALL,
- new GroupBuckets(buckets),
- key,
- L2ForwardServiceImpl.GROUP_ID,
- appid);
- groupService.addGroup(groupDescription);
- }
-
- private class VtnL3EventListener implements VtnRscListener {
- @Override
- public void event(VtnRscEvent event) {
- VtnRscEventFeedback l3Feedback = event.subject();
- if (VtnRscEvent.Type.ROUTER_INTERFACE_PUT == event.type()) {
- onRouterInterfaceDetected(l3Feedback);
- } else if (VtnRscEvent.Type.ROUTER_INTERFACE_DELETE == event.type()) {
- onRouterInterfaceVanished(l3Feedback);
- } else if (VtnRscEvent.Type.FLOATINGIP_BIND == event.type()) {
- onFloatingIpDetected(l3Feedback);
- } else if (VtnRscEvent.Type.FLOATINGIP_UNBIND == event.type()) {
- onFloatingIpVanished(l3Feedback);
- } else if (VtnRscEvent.Type.VIRTUAL_PORT_PUT == event.type()) {
- onVirtualPortCreated(l3Feedback);
- } else if (VtnRscEvent.Type.VIRTUAL_PORT_DELETE == event.type()) {
- onVirtualPortDeleted(l3Feedback);
- }
- }
-
- }
-
- @Override
- public void onRouterInterfaceDetected(VtnRscEventFeedback l3Feedback) {
- Objective.Operation operation = Objective.Operation.ADD;
- RouterInterface routerInf = l3Feedback.routerInterface();
- VirtualPort gwPort = virtualPortService.getPort(routerInf.portId());
- vPortStore.put(gwPort.portId(), gwPort);
- Iterable<RouterInterface> interfaces = routerInterfaceService
- .getRouterInterfaces();
- Set<RouterInterface> interfacesSet = Sets.newHashSet(interfaces).stream()
- .filter(r -> r.tenantId().equals(routerInf.tenantId()))
- .filter(r -> r.routerId().equals(routerInf.routerId()))
- .collect(Collectors.toSet());
- TenantRouter tenantRouter = TenantRouter
- .tenantRouter(routerInf.tenantId(), routerInf.routerId());
- if (routerInfFlagOfTenantRouter.get(tenantRouter) != null) {
- programRouterInterface(routerInf, operation);
- } else {
- if (interfacesSet.size() >= SUBNET_NUM) {
- programInterfacesSet(interfacesSet, operation);
- }
- }
- // apply L3 arp flows
- applyL3ArpFlows(null, gwPort, operation);
- }
-
- @Override
- public void onRouterInterfaceVanished(VtnRscEventFeedback l3Feedback) {
- Objective.Operation operation = Objective.Operation.REMOVE;
- RouterInterface routerInf = l3Feedback.routerInterface();
- Iterable<RouterInterface> interfaces = routerInterfaceService
- .getRouterInterfaces();
- Set<RouterInterface> interfacesSet = Sets.newHashSet(interfaces)
- .stream().filter(r -> r.tenantId().equals(routerInf.tenantId()))
- .collect(Collectors.toSet());
- TenantRouter tenantRouter = TenantRouter
- .tenantRouter(routerInf.tenantId(), routerInf.routerId());
- if (routerInfFlagOfTenantRouter.get(tenantRouter) != null) {
- programRouterInterface(routerInf, operation);
- if (interfacesSet.size() == 1) {
- routerInfFlagOfTenantRouter.remove(tenantRouter);
- interfacesSet.forEach(r -> {
- programRouterInterface(r, operation);
- });
- }
- }
- VirtualPort gwPort = virtualPortService.getPort(routerInf.portId());
- if (gwPort == null) {
- gwPort = VtnData.getPort(vPortStore, routerInf.portId());
- }
- vPortStore.remove(gwPort.portId());
- // apply L3 arp flows
- applyL3ArpFlows(null, gwPort, operation);
- }
-
- @Override
- public void onFloatingIpDetected(VtnRscEventFeedback l3Feedback) {
- floatingIpStore.put(l3Feedback.floatingIp().floatingIp(),
- l3Feedback.floatingIp());
- programFloatingIpEvent(l3Feedback, VtnRscEvent.Type.FLOATINGIP_BIND);
- }
-
- @Override
- public void onFloatingIpVanished(VtnRscEventFeedback l3Feedback) {
- floatingIpStore.remove(l3Feedback.floatingIp().floatingIp());
- programFloatingIpEvent(l3Feedback, VtnRscEvent.Type.FLOATINGIP_UNBIND);
- }
-
- public void onVirtualPortCreated(VtnRscEventFeedback l3Feedback) {
- VirtualPort vPort = l3Feedback.virtualPort();
- BasicHostConfig basicHostConfig = networkConfigService.addConfig(HostId.hostId(vPort.macAddress()),
- BasicHostConfig.class);
- Set<IpAddress> ips = new HashSet<>();
- for (FixedIp fixedIp : vPort.fixedIps()) {
- ips.add(fixedIp.ip());
- }
- basicHostConfig.setIps(ips).apply();
- }
-
- public void onVirtualPortDeleted(VtnRscEventFeedback l3Feedback) {
- VirtualPort vPort = l3Feedback.virtualPort();
- HostId hostId = HostId.hostId(vPort.macAddress());
- BasicHostConfig basicHostConfig = networkConfigService.addConfig(hostId,
- BasicHostConfig.class);
- Set<IpAddress> oldIps = hostService.getHost(hostId).ipAddresses();
- // Copy to a new set as oldIps is unmodifiable set.
- Set<IpAddress> newIps = new HashSet<>();
- newIps.addAll(oldIps);
- for (FixedIp fixedIp : vPort.fixedIps()) {
- newIps.remove(fixedIp.ip());
- }
- basicHostConfig.setIps(newIps).apply();
- }
-
- private void programInterfacesSet(Set<RouterInterface> interfacesSet,
- Objective.Operation operation) {
- int subnetVmNum = 0;
- for (RouterInterface r : interfacesSet) {
- // Get all the host of the subnet
- Map<HostId, Host> hosts = hostsOfSubnet.get(r.subnetId());
- if (hosts != null && hosts.size() > 0) {
- subnetVmNum++;
- if (subnetVmNum >= SUBNET_NUM) {
- TenantRouter tenantRouter = TenantRouter
- .tenantRouter(r.tenantId(), r.routerId());
- routerInfFlagOfTenantRouter.put(tenantRouter, true);
- interfacesSet.forEach(f -> {
- programRouterInterface(f, operation);
- });
- break;
- }
- }
- }
- }
-
- private void programRouterInterface(RouterInterface routerInf,
- Objective.Operation operation) {
- TenantRouter tenantRouter = TenantRouter
- .tenantRouter(routerInf.tenantId(), routerInf.routerId());
- SegmentationId l3vni = vtnRscService.getL3vni(tenantRouter);
- // Get all the host of the subnet
- Map<HostId, Host> hosts = hostsOfSubnet.get(routerInf.subnetId());
- hosts.values().forEach(h -> {
- applyEastWestL3Flows(h, l3vni, operation);
- });
- }
-
- private void applyL3ArpFlows(DeviceId deviceId, VirtualPort gwPort,
- Objective.Operation operation) {
- IpAddress ip = null;
- Iterator<FixedIp> gwIps = gwPort.fixedIps().iterator();
- if (gwIps.hasNext()) {
- ip = gwIps.next().ip();
- }
- IpAddress gwIp = ip;
- MacAddress gwMac = gwPort.macAddress();
- TenantNetwork network = tenantNetworkService
- .getNetwork(gwPort.networkId());
- if (deviceId != null) {
- // Arp rules
- DriverHandler handler = driverService.createHandler(deviceId);
- arpService.programArpRules(handler, deviceId, gwIp,
- network.segmentationId(), gwMac,
- operation);
- } else {
- Iterable<Device> devices = deviceService.getAvailableDevices();
- Sets.newHashSet(devices).stream()
- .filter(d -> Device.Type.SWITCH == d.type()).forEach(d -> {
- // Arp rules
- DriverHandler handler = driverService.createHandler(d.id());
- arpService.programArpRules(handler, d.id(), gwIp,
- network.segmentationId(), gwMac,
- operation);
- });
- }
- }
-
- private void applyEastWestL3Flows(Host h, SegmentationId l3vni,
- Objective.Operation operation) {
- if (!mastershipService.isLocalMaster(h.location().deviceId())) {
- log.debug("not master device:{}", h.location().deviceId());
- return;
- }
- String ifaceId = h.annotations().value(IFACEID);
- VirtualPort hPort = virtualPortService
- .getPort(VirtualPortId.portId(ifaceId));
- if (hPort == null) {
- hPort = VtnData.getPort(vPortStore, VirtualPortId.portId(ifaceId));
- }
- IpAddress srcIp = null;
- IpAddress srcGwIp = null;
- MacAddress srcVmGwMac = null;
- SubnetId srcSubnetId = null;
- Iterator<FixedIp> srcIps = hPort.fixedIps().iterator();
- if (srcIps.hasNext()) {
- FixedIp fixedIp = srcIps.next();
- srcIp = fixedIp.ip();
- srcSubnetId = fixedIp.subnetId();
- srcGwIp = subnetService.getSubnet(srcSubnetId).gatewayIp();
- FixedIp fixedGwIp = FixedIp.fixedIp(srcSubnetId, srcGwIp);
- VirtualPort gwPort = virtualPortService.getPort(fixedGwIp);
- if (gwPort == null) {
- gwPort = VtnData.getPort(vPortStore, fixedGwIp);
- }
- srcVmGwMac = gwPort.macAddress();
- }
- TenantNetwork network = tenantNetworkService
- .getNetwork(hPort.networkId());
- IpAddress dstVmIP = srcIp;
- MacAddress dstVmGwMac = srcVmGwMac;
- TenantId tenantId = hPort.tenantId();
- // Classifier rules
- if (operation == Objective.Operation.ADD) {
- sendEastWestL3Flows(h, srcVmGwMac, l3vni, srcGwIp, network,
- dstVmIP, dstVmGwMac, operation);
- } else if (operation == Objective.Operation.REMOVE) {
- FloatingIp floatingIp = null;
- Iterable<FloatingIp> floatingIps = floatingIpService.getFloatingIps();
- Set<FloatingIp> floatingIpSet = Sets.newHashSet(floatingIps).stream()
- .filter(f -> f.tenantId().equals(tenantId))
- .collect(Collectors.toSet());
- for (FloatingIp f : floatingIpSet) {
- IpAddress fixedIp = f.fixedIp();
- if (fixedIp != null && fixedIp.equals(srcIp)) {
- floatingIp = f;
- break;
- }
- }
- if (floatingIp == null) {
- sendEastWestL3Flows(h, srcVmGwMac, l3vni, srcGwIp, network,
- dstVmIP, dstVmGwMac, operation);
- }
- }
- }
-
- private void sendEastWestL3Flows(Host h, MacAddress srcVmGwMac,
- SegmentationId l3vni, IpAddress srcGwIp,
- TenantNetwork network, IpAddress dstVmIP,
- MacAddress dstVmGwMac,
- Objective.Operation operation) {
- classifierService
- .programL3InPortClassifierRules(h.location().deviceId(),
- h.location().port(), h.mac(),
- srcVmGwMac, l3vni, operation);
- classifierService
- .programArpClassifierRules(h.location().deviceId(),
- h.location().port(), srcGwIp,
- network.segmentationId(), operation);
- Iterable<Device> devices = deviceService.getAvailableDevices();
- Sets.newHashSet(devices).stream()
- .filter(d -> Device.Type.SWITCH == d.type()).forEach(d -> {
- // L3FWD rules
- l3ForwardService.programRouteRules(d.id(), l3vni, dstVmIP,
- network.segmentationId(),
- dstVmGwMac, h.mac(),
- operation);
- });
- }
-
- private void programFloatingIpEvent(VtnRscEventFeedback l3Feedback,
- VtnRscEvent.Type type) {
- FloatingIp floaingIp = l3Feedback.floatingIp();
- if (floaingIp != null) {
- VirtualPortId vmPortId = floaingIp.portId();
- VirtualPort vmPort = virtualPortService.getPort(vmPortId);
- VirtualPort fipPort = virtualPortService
- .getPort(floaingIp.networkId(), floaingIp.floatingIp());
- if (vmPort == null) {
- vmPort = VtnData.getPort(vPortStore, vmPortId);
- }
- if (fipPort == null) {
- fipPort = VtnData.getPort(vPortStore, floaingIp.networkId(),
- floaingIp.floatingIp());
- }
- Set<Host> hostSet = hostService.getHostsByMac(vmPort.macAddress());
- Host host = null;
- for (Host h : hostSet) {
- String ifaceid = h.annotations().value(IFACEID);
- if (ifaceid != null && ifaceid.equals(vmPortId.portId())) {
- host = h;
- break;
- }
- }
- if (host != null && fipPort != null) {
- DeviceId deviceId = host.location().deviceId();
- Port exPort = exPortOfDevice.get(deviceId);
- TenantRouter tenantRouter = TenantRouter
- .tenantRouter(floaingIp.tenantId(), floaingIp.routerId());
- SegmentationId l3vni = vtnRscService.getL3vni(tenantRouter);
- // Floating ip BIND
- if (type == VtnRscEvent.Type.FLOATINGIP_BIND) {
- vPortStore.put(fipPort.portId(), fipPort);
- applyNorthSouthL3Flows(deviceId, false, tenantRouter, host,
- vmPort, fipPort, floaingIp, l3vni,
- exPort, Objective.Operation.ADD);
- } else if (type == VtnRscEvent.Type.FLOATINGIP_UNBIND) {
- // Floating ip UNBIND
- applyNorthSouthL3Flows(deviceId, false, tenantRouter, host,
- vmPort, fipPort, floaingIp, l3vni,
- exPort,
- Objective.Operation.REMOVE);
- vPortStore.remove(fipPort.portId());
- }
- }
- }
- }
-
- private void sendNorthSouthL3Flows(DeviceId deviceId, FloatingIp floatingIp,
- IpAddress dstVmGwIp,
- MacAddress dstVmGwMac,
- SegmentationId l3vni,
- TenantNetwork vmNetwork,
- VirtualPort vmPort, Host host,
- Objective.Operation operation) {
- l3ForwardService
- .programRouteRules(deviceId, l3vni, floatingIp.fixedIp(),
- vmNetwork.segmentationId(), dstVmGwMac,
- vmPort.macAddress(), operation);
- classifierService.programL3InPortClassifierRules(deviceId,
- host.location().port(),
- host.mac(), dstVmGwMac,
- l3vni, operation);
- classifierService.programArpClassifierRules(deviceId, host.location()
- .port(), dstVmGwIp, vmNetwork.segmentationId(), operation);
- }
-
- private void applyNorthSouthL3Flows(DeviceId deviceId, boolean hostFlag,
- TenantRouter tenantRouter, Host host,
- VirtualPort vmPort, VirtualPort fipPort,
- FloatingIp floatingIp,
- SegmentationId l3vni, Port exPort,
- Objective.Operation operation) {
- if (!mastershipService.isLocalMaster(deviceId)) {
- log.debug("not master device:{}", deviceId);
- return;
- }
- List gwIpMac = getGwIpAndMac(vmPort);
- IpAddress dstVmGwIp = (IpAddress) gwIpMac.get(0);
- MacAddress dstVmGwMac = (MacAddress) gwIpMac.get(1);
- TenantNetwork vmNetwork = tenantNetworkService
- .getNetwork(vmPort.networkId());
- TenantNetwork fipNetwork = tenantNetworkService
- .getNetwork(fipPort.networkId());
- // L3 downlink traffic flow
- MacAddress exPortMac = MacAddress.valueOf(exPort.annotations()
- .value(AnnotationKeys.PORT_MAC));
- classifierService.programL3ExPortClassifierRules(deviceId, exPort.number(),
- floatingIp.floatingIp(), operation);
- dnatService.programRules(deviceId, floatingIp.floatingIp(),
- exPortMac, floatingIp.fixedIp(),
- l3vni, operation);
-
- Subnet subnet = getSubnetOfFloatingIP(floatingIp);
- IpPrefix ipPrefix = subnet.cidr();
- snatService.programSnatSameSegmentUploadControllerRules(deviceId, l3vni,
- floatingIp.fixedIp(),
- floatingIp.floatingIp(),
- ipPrefix,
- operation);
- // L3 uplink traffic flow
- if (operation == Objective.Operation.ADD) {
- sendNorthSouthL3Flows(deviceId, floatingIp, dstVmGwIp, dstVmGwMac,
- l3vni, vmNetwork, vmPort, host, operation);
- l2ForwardService
- .programExternalOut(deviceId, fipNetwork.segmentationId(),
- exPort.number(), exPortMac, operation);
- } else if (operation == Objective.Operation.REMOVE) {
- if (hostFlag || (routerInfFlagOfTenantRouter.get(tenantRouter) == null)) {
- sendNorthSouthL3Flows(deviceId, floatingIp, dstVmGwIp, dstVmGwMac,
- l3vni, vmNetwork, vmPort, host, operation);
- }
- Iterable<FloatingIp> floatingIps = floatingIpService.getFloatingIps();
- boolean exPortFlag = true;
- if (floatingIps != null) {
- Set<FloatingIp> floatingIpSet = Sets.newHashSet(floatingIps);
- for (FloatingIp fip : floatingIpSet) {
- if (fip.fixedIp() != null) {
- exPortFlag = false;
- break;
- }
- }
- }
- if (exPortFlag) {
- l2ForwardService.programExternalOut(deviceId,
- fipNetwork.segmentationId(),
- exPort.number(), exPortMac,
- operation);
- }
- removeRulesInSnat(deviceId, floatingIp.fixedIp());
- }
- }
-
- private Port getExPort(DeviceId deviceId) {
- List<Port> ports = deviceService.getPorts(deviceId);
- Port exPort = null;
- for (Port port : ports) {
- String portName = port.annotations().value(AnnotationKeys.PORT_NAME);
- Versioned<String> exPortVersioned = exPortMap.get(EX_PORT_KEY);
- if (portName != null && exPortVersioned != null && portName.
- equals(exPortVersioned.value())) {
- exPort = port;
- break;
- }
- }
- return exPort;
- }
-
- private List getGwIpAndMac(VirtualPort port) {
- List list = new ArrayList();
- MacAddress gwMac = null;
- SubnetId subnetId = null;
- IpAddress gwIp = null;
- Iterator<FixedIp> fixips = port.fixedIps().iterator();
- if (fixips.hasNext()) {
- FixedIp fixip = fixips.next();
- subnetId = fixip.subnetId();
- gwIp = subnetService.getSubnet(subnetId).gatewayIp();
- FixedIp fixedGwIp = FixedIp.fixedIp(fixip.subnetId(), gwIp);
- VirtualPort gwPort = virtualPortService.getPort(fixedGwIp);
- if (gwPort == null) {
- gwPort = VtnData.getPort(vPortStore, fixedGwIp);
- }
- gwMac = gwPort.macAddress();
- }
- list.add(gwIp);
- list.add(gwMac);
- return list;
- }
-
- private void applyHostMonitoredL3Rules(Host host,
- Objective.Operation operation) {
- String ifaceId = host.annotations().value(IFACEID);
- DeviceId deviceId = host.location().deviceId();
- VirtualPortId portId = VirtualPortId.portId(ifaceId);
- VirtualPort port = virtualPortService.getPort(portId);
- if (port == null) {
- port = VtnData.getPort(vPortStore, portId);
- }
- TenantId tenantId = port.tenantId();
- Port exPort = exPortOfDevice.get(deviceId);
- Iterator<FixedIp> fixips = port.fixedIps().iterator();
- SubnetId sid = null;
- IpAddress hostIp = null;
- if (fixips.hasNext()) {
- FixedIp fixip = fixips.next();
- sid = fixip.subnetId();
- hostIp = fixip.ip();
- }
- final SubnetId subnetId = sid;
- // L3 internal network access to each other
- Iterable<RouterInterface> interfaces = routerInterfaceService
- .getRouterInterfaces();
- Set<RouterInterface> hostInterfaces = Sets.newHashSet(interfaces)
- .stream().filter(r -> r.tenantId().equals(tenantId))
- .filter(r -> r.subnetId().equals(subnetId))
- .collect(Collectors.toSet());
- hostInterfaces.forEach(routerInf -> {
- Set<RouterInterface> interfacesSet = Sets.newHashSet(interfaces)
- .stream().filter(r -> r.tenantId().equals(tenantId))
- .filter(r -> r.routerId().equals(routerInf.routerId()))
- .collect(Collectors.toSet());
- long count = interfacesSet.stream()
- .filter(r -> !r.subnetId().equals(subnetId)).count();
- if (count > 0) {
- TenantRouter tenantRouter = TenantRouter
- .tenantRouter(routerInf.tenantId(), routerInf.routerId());
- SegmentationId l3vni = vtnRscService.getL3vni(tenantRouter);
- if (operation == Objective.Operation.ADD) {
- if (routerInfFlagOfTenantRouter.get(tenantRouter) != null) {
- applyEastWestL3Flows(host, l3vni, operation);
- } else {
- if (interfacesSet.size() > 1) {
- programInterfacesSet(interfacesSet, operation);
- }
- }
- } else if (operation == Objective.Operation.REMOVE) {
- if (routerInfFlagOfTenantRouter.get(tenantRouter) != null) {
- applyEastWestL3Flows(host, l3vni, operation);
- }
- }
- }
- });
- // L3 external and internal network access to each other
- FloatingIp floatingIp = null;
- Iterable<FloatingIp> floatingIps = floatingIpService.getFloatingIps();
- Set<FloatingIp> floatingIpSet = Sets.newHashSet(floatingIps).stream()
- .filter(f -> f.tenantId().equals(tenantId))
- .collect(Collectors.toSet());
- for (FloatingIp f : floatingIpSet) {
- IpAddress fixedIp = f.fixedIp();
- if (fixedIp != null && fixedIp.equals(hostIp)) {
- floatingIp = f;
- break;
- }
- }
- if (floatingIp != null) {
- TenantRouter tenantRouter = TenantRouter
- .tenantRouter(floatingIp.tenantId(), floatingIp.routerId());
- SegmentationId l3vni = vtnRscService.getL3vni(tenantRouter);
- VirtualPort fipPort = virtualPortService
- .getPort(floatingIp.networkId(), floatingIp.floatingIp());
- if (fipPort == null) {
- fipPort = VtnData.getPort(vPortStore, floatingIp.networkId(),
- floatingIp.floatingIp());
- }
- applyNorthSouthL3Flows(deviceId, true, tenantRouter, host, port,
- fipPort, floatingIp, l3vni, exPort,
- operation);
- }
- }
-
- public static void setExPortName(String name) {
- exPortMap.put(EX_PORT_KEY, name);
- }
-
- /**
- * Packet processor responsible for forwarding packets along their paths.
- */
- private class VtnL3PacketProcessor implements PacketProcessor {
-
- @Override
- public void process(PacketContext context) {
- InboundPacket pkt = context.inPacket();
- ConnectPoint connectPoint = pkt.receivedFrom();
- DeviceId deviceId = connectPoint.deviceId();
- Ethernet ethPkt = pkt.parsed();
- if (ethPkt == null) {
- return;
- }
- if (ethPkt.getEtherType() == Ethernet.TYPE_ARP) {
- ARP arpPacket = (ARP) ethPkt.getPayload();
- if ((arpPacket.getOpCode() == ARP.OP_REQUEST)) {
- arprequestProcess(arpPacket, deviceId);
- } else if (arpPacket.getOpCode() == ARP.OP_REPLY) {
- arpresponceProcess(arpPacket, deviceId);
- }
- } else if (ethPkt.getEtherType() == Ethernet.TYPE_IPV4) {
- if (ethPkt.getDestinationMAC().isMulticast()) {
- return;
- }
- IPv4 ip = (IPv4) ethPkt.getPayload();
- upStreamPacketProcessor(ip, deviceId);
-
- } else {
- return;
- }
- }
-
- private void arprequestProcess(ARP arpPacket, DeviceId deviceId) {
- MacAddress dstMac = MacAddress
- .valueOf(arpPacket.getSenderHardwareAddress());
- IpAddress srcIp = IpAddress.valueOf(IPv4
- .toIPv4Address(arpPacket.getTargetProtocolAddress()));
- IpAddress dstIp = IpAddress.valueOf(IPv4
- .toIPv4Address(arpPacket.getSenderProtocolAddress()));
- FloatingIp floatingIp = floatingIpStore.get(srcIp);
- if (floatingIp == null) {
- return;
- }
- DeviceId deviceIdOfFloatingIp = getDeviceIdOfFloatingIP(floatingIp);
- if (!deviceId.equals(deviceIdOfFloatingIp)) {
- return;
- }
- Port exPort = exPortOfDevice.get(deviceId);
- MacAddress srcMac = MacAddress.valueOf(exPort.annotations()
- .value(AnnotationKeys.PORT_MAC));
- if (!downloadSnatRules(deviceId, srcMac, srcIp, dstMac, dstIp,
- floatingIp)) {
- return;
- }
- Ethernet ethernet = buildArpResponse(dstIp, dstMac, srcIp, srcMac);
- if (ethernet != null) {
- sendPacketOut(deviceId, exPort.number(), ethernet);
- }
- }
-
- private void arpresponceProcess(ARP arpPacket, DeviceId deviceId) {
- MacAddress srcMac = MacAddress
- .valueOf(arpPacket.getTargetHardwareAddress());
- MacAddress dstMac = MacAddress
- .valueOf(arpPacket.getSenderHardwareAddress());
- IpAddress srcIp = IpAddress.valueOf(IPv4
- .toIPv4Address(arpPacket.getTargetProtocolAddress()));
- IpAddress dstIp = IpAddress.valueOf(IPv4
- .toIPv4Address(arpPacket.getSenderProtocolAddress()));
- FloatingIp floatingIp = floatingIpStore.get(srcIp);
- if (floatingIp == null) {
- return;
- }
- DeviceId deviceIdOfFloatingIp = getDeviceIdOfFloatingIP(floatingIp);
- if (!deviceId.equals(deviceIdOfFloatingIp)) {
- return;
- }
- if (!downloadSnatRules(deviceId, srcMac, srcIp, dstMac, dstIp,
- floatingIp)) {
- return;
- }
- }
-
- private void upStreamPacketProcessor(IPv4 ipPacket, DeviceId deviceId) {
- IpAddress srcIp = IpAddress.valueOf(ipPacket.getSourceAddress());
- IpAddress dstIp = IpAddress.valueOf(ipPacket.getDestinationAddress());
- FloatingIp floatingIp = null;
- Collection<FloatingIp> floatingIps = floatingIpService
- .getFloatingIps();
- Set<FloatingIp> floatingIpSet = Sets.newHashSet(floatingIps)
- .stream().collect(Collectors.toSet());
- for (FloatingIp f : floatingIpSet) {
- IpAddress fixIp = f.fixedIp();
- if (fixIp != null && fixIp.equals(srcIp)) {
- floatingIp = f;
- break;
- }
- }
- if (floatingIp == null) {
- return;
- }
- Subnet subnet = getSubnetOfFloatingIP(floatingIp);
- IpAddress gwIp = subnet.gatewayIp();
- Port exportPort = exPortOfDevice.get(deviceId);
- MacAddress exPortMac = MacAddress.valueOf(exportPort.annotations()
- .value(AnnotationKeys.PORT_MAC));
- IpPrefix ipPrefix = subnet.cidr();
- if (ipPrefix == null) {
- return;
- }
- int mask = ipPrefix.prefixLength();
- if (mask <= 0) {
- return;
- }
- Ethernet ethernet = null;
- // if the same ip segment
- if (IpUtil.checkSameSegment(floatingIp.floatingIp(), dstIp, mask)) {
- ethernet = buildArpRequest(dstIp, floatingIp.floatingIp(),
- exPortMac);
- } else {
- ethernet = buildArpRequest(gwIp, floatingIp.floatingIp(),
- exPortMac);
- }
- if (ethernet != null) {
- sendPacketOut(deviceId, exportPort.number(), ethernet);
- }
- }
- }
-
- private Ethernet buildArpRequest(IpAddress targetIp, IpAddress sourceIp,
- MacAddress sourceMac) {
- ARP arp = new ARP();
- arp.setHardwareType(ARP.HW_TYPE_ETHERNET)
- .setHardwareAddressLength((byte) Ethernet.DATALAYER_ADDRESS_LENGTH)
- .setProtocolType(ARP.PROTO_TYPE_IP)
- .setProtocolAddressLength((byte) Ip4Address.BYTE_LENGTH)
- .setOpCode(ARP.OP_REQUEST);
-
- arp.setSenderHardwareAddress(sourceMac.toBytes())
- .setSenderProtocolAddress(sourceIp.getIp4Address().toInt())
- .setTargetHardwareAddress(ZERO_MAC_ADDRESS)
- .setTargetProtocolAddress(targetIp.getIp4Address().toInt());
-
- Ethernet ethernet = new Ethernet();
- ethernet.setEtherType(Ethernet.TYPE_ARP)
- .setDestinationMACAddress(MacAddress.BROADCAST)
- .setSourceMACAddress(sourceMac)
- .setPayload(arp);
-
- ethernet.setPad(true);
- return ethernet;
- }
-
- private Ethernet buildArpResponse(IpAddress targetIp, MacAddress targetMac,
- IpAddress sourceIp, MacAddress sourceMac) {
- ARP arp = new ARP();
- arp.setHardwareType(ARP.HW_TYPE_ETHERNET)
- .setHardwareAddressLength((byte) Ethernet.DATALAYER_ADDRESS_LENGTH)
- .setProtocolType(ARP.PROTO_TYPE_IP)
- .setProtocolAddressLength((byte) Ip4Address.BYTE_LENGTH)
- .setOpCode(ARP.OP_REPLY);
-
- arp.setSenderHardwareAddress(sourceMac.toBytes())
- .setSenderProtocolAddress(sourceIp.getIp4Address().toInt())
- .setTargetHardwareAddress(targetMac.toBytes())
- .setTargetProtocolAddress(targetIp.getIp4Address().toInt());
-
- Ethernet ethernet = new Ethernet();
- ethernet.setEtherType(Ethernet.TYPE_ARP)
- .setDestinationMACAddress(targetMac)
- .setSourceMACAddress(sourceMac)
- .setPayload(arp);
-
- ethernet.setPad(true);
-
- return ethernet;
- }
-
- private void sendPacketOut(DeviceId deviceId, PortNumber portNumber,
- Ethernet payload) {
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setOutput(portNumber).build();
- OutboundPacket packet = new DefaultOutboundPacket(deviceId, treatment,
- ByteBuffer
- .wrap(payload
- .serialize()));
- packetService.emit(packet);
- }
-
- private Subnet getSubnetOfFloatingIP(FloatingIp floatingIp) {
- DeviceId exVmPortId = DeviceId
- .deviceId(floatingIp.id().floatingIpId().toString());
- Collection<VirtualPort> exVmPortList = virtualPortService
- .getPorts(exVmPortId);
- VirtualPort exVmPort = null;
- if (exVmPortList != null) {
- exVmPort = exVmPortList.iterator().next();
- }
- if (exVmPort == null) {
- log.debug("exVM Port is null {}.", floatingIp);
- return null;
- }
- Set<FixedIp> fixedIps = exVmPort.fixedIps();
- SubnetId subnetId = null;
- for (FixedIp f : fixedIps) {
- IpAddress fp = f.ip();
- if (fp.equals(floatingIp.floatingIp())) {
- subnetId = f.subnetId();
- break;
- }
- }
- if (subnetId == null) {
- log.debug("subnetId is null {}.", floatingIp);
- return null;
- }
- Subnet subnet = subnetService.getSubnet(subnetId);
- return subnet;
- }
-
- private DeviceId getDeviceIdOfFloatingIP(FloatingIp floatingIp) {
- VirtualPortId vmPortId = floatingIp.portId();
- VirtualPort vmPort = virtualPortService.getPort(vmPortId);
- if (vmPort == null) {
- vmPort = VtnData.getPort(vPortStore, vmPortId);
- }
- Set<Host> hostSet = hostService.getHostsByMac(vmPort.macAddress());
- Host host = null;
- for (Host h : hostSet) {
- String ifaceid = h.annotations().value(IFACEID);
- if (ifaceid != null && ifaceid.equals(vmPortId.portId())) {
- host = h;
- break;
- }
- }
- if (host == null) {
- log.debug("Host is null {}.", floatingIp);
- return null;
- } else {
- return host.location().deviceId();
- }
- }
-
- private boolean downloadSnatRules(DeviceId deviceId, MacAddress srcMac,
- IpAddress srcIp, MacAddress dstMac,
- IpAddress dstIp, FloatingIp floatingIp) {
- TenantNetwork exNetwork = tenantNetworkService
- .getNetwork(floatingIp.networkId());
- IpAddress fixedIp = floatingIp.fixedIp();
- VirtualPortId vmPortId = floatingIp.portId();
- VirtualPort vmPort = virtualPortService.getPort(vmPortId);
- if (vmPort == null) {
- vmPort = VtnData.getPort(vPortStore, vmPortId);
- }
- Subnet subnet = getSubnetOfFloatingIP(floatingIp);
- IpPrefix ipPrefix = subnet.cidr();
- IpAddress gwIp = subnet.gatewayIp();
- if (ipPrefix == null) {
- return false;
- }
- int mask = ipPrefix.prefixLength();
- if (mask <= 0) {
- return false;
- }
- TenantRouter tenantRouter = TenantRouter
- .tenantRouter(floatingIp.tenantId(), floatingIp.routerId());
- SegmentationId l3vni = vtnRscService.getL3vni(tenantRouter);
- // if the same ip segment
- if (IpUtil.checkSameSegment(srcIp, dstIp, mask)) {
- snatService.programSnatSameSegmentRules(deviceId, l3vni, fixedIp,
- dstIp, dstMac, srcMac,
- srcIp,
- exNetwork.segmentationId(),
- Objective.Operation.ADD);
- if (dstIp.equals(gwIp)) {
- snatService
- .programSnatDiffSegmentRules(deviceId, l3vni, fixedIp,
- dstMac, srcMac, srcIp,
- exNetwork.segmentationId(),
- Objective.Operation.ADD);
- }
- }
- return true;
- }
-
- private void removeRulesInSnat(DeviceId deviceId, IpAddress fixedIp) {
- for (FlowEntry f : flowRuleService.getFlowEntries(deviceId)) {
- if (f.tableId() == SNAT_TABLE
- && f.priority() > SNAT_DEFAULT_RULE_PRIORITY) {
- String srcIp = f.selector()
- .getCriterion(Criterion.Type.IPV4_SRC).toString();
- int priority = f.priority();
- if (srcIp != null && srcIp.contains(fixedIp.toString())) {
- log.info("Match snat rules bob");
- TrafficSelector selector = f.selector();
- TrafficTreatment treatment = f.treatment();
- snatService.removeSnatRules(deviceId, selector, treatment,
- priority,
- Objective.Operation.REMOVE);
-
- }
- }
- }
- }
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/impl/package-info.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/impl/package-info.java
deleted file mode 100644
index 0c10369..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-package org.onosproject.vtn.manager.impl;
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/package-info.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/package-info.java
deleted file mode 100644
index 4da1e7a..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/manager/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-package org.onosproject.vtn.manager;
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/ArpService.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/ArpService.java
deleted file mode 100644
index 8dad2bf..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/ArpService.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.table;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.vtnrsc.SegmentationId;
-
-
-/**
- * ArpService interface providing the rules in ARP table which is Table(10).
- */
-public interface ArpService {
-
- /**
- * Assemble the arp rules.
- * Match: arp type, vnid and destination ip.
- * Action: set arp_operation, move arp_eth_src to arp_eth_dst, set arp_eth_src,
- * move arp_ip_src to arp_ip_dst, set arp_ip_src, set output port.
- *
- * @param hander DriverHandler
- * @param deviceId Device Id
- * @param dstIP destination ip
- * @param matchVni the vni of the source network (l2vni)
- * @param dstMac destination mac
- * @param type the operation type of the flow rules
- */
- void programArpRules(DriverHandler hander, DeviceId deviceId, IpAddress dstIP,
- SegmentationId matchVni, MacAddress dstMac,
- Objective.Operation type);
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/ClassifierService.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/ClassifierService.java
deleted file mode 100644
index fb08e2a..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/ClassifierService.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.table;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.net.flowobjective.Objective.Operation;
-import org.onosproject.vtnrsc.SegmentationId;
-
-/**
- * Applies classifier flows to the device. Classifier table is Table(0).
- */
-public interface ClassifierService {
-
- /**
- * The port rule that message from host matches Table(0) Match: host mac and
- * ingress port Action: set vnid and go to L2Forward Table(50).
- *
- * @param deviceId Device Id
- * @param segmentationId the vnid of the host belong to
- * @param inPort the ingress port of the host
- * @param srcMac the mac of the host
- * @param appId the application ID of the vtn
- * @param type the operation of the flow
- */
- void programLocalIn(DeviceId deviceId, SegmentationId segmentationId,
- PortNumber inPort, MacAddress srcMac,
- ApplicationId appId, Objective.Operation type);
-
- /**
- * The port rule that message from tunnel Table(0) Match: tunnel port and
- * vnid Action: go to L2Forward Table(50).
- *
- * @param deviceId Device Id
- * @param segmentationId the vnid of the host belong to
- * @param localTunnelPorts the tunnel pors of the device
- * @param type the operation of the flow
- */
- void programTunnelIn(DeviceId deviceId, SegmentationId segmentationId,
- Iterable<PortNumber> localTunnelPorts,
- Objective.Operation type);
-
- /**
- * Assemble the L3 Classifier table rules which are sended from external port.
- * Match: ipv4 type, ingress port and destination ip.
- * Action: go to DNAT Table(20).
- *
- * @param deviceId Device Id
- * @param inPort external port
- * @param dstIp floating ip
- * @param type the operation type of the flow rules
- */
- void programL3ExPortClassifierRules(DeviceId deviceId, PortNumber inPort,
- IpAddress dstIp,
- Objective.Operation type);
-
- /**
- * Assemble the L3 Classifier table rules which are sended from internal port.
- * Match: ingress port, source mac and destination mac.
- * Action: set vnid and go to L3Forward Table(30).
- *
- * @param deviceId Device Id
- * @param inPort the ingress port of the host
- * @param srcMac source mac
- * @param dstMac destination vm gateway mac
- * @param actionVni the vni of L3 network
- * @param type the operation type of the flow rules
- */
- void programL3InPortClassifierRules(DeviceId deviceId,
- PortNumber inPort, MacAddress srcMac,
- MacAddress dstMac,
- SegmentationId actionVni,
- Objective.Operation type);
-
- /**
- * Assemble the Arp Classifier table rules.
- * Match: arp type and destination ip.
- * Action: set vnid and go to ARP Table(10).
- *
- * @param deviceId Device Id
- * @param dstIp source gateway ip
- * @param actionVni the vni of the source network (l2vni)
- * @param type the operation type of the flow rules
- */
- void programArpClassifierRules(DeviceId deviceId, IpAddress dstIp,
- SegmentationId actionVni,
- Objective.Operation type);
-
- /**
- * Assemble the Arp Classifier table rules.
- * Match: arp type and destination ip.
- * Action: set vnid and go to ARP Table(10).
- *
- * @param deviceId Device Id
- * @param inPort the ingress port of the host
- * @param dstIp source gateway ip
- * @param actionVni the vni of the source network (l2vni)
- * @param type the operation type of the flow rules
- */
- void programArpClassifierRules(DeviceId deviceId, PortNumber inPort,
- IpAddress dstIp, SegmentationId actionVni,
- Objective.Operation type);
-
- /**
- * Assemble the Userdata Classifier table rules.
- * Match: subnet ip prefix and destination ip.
- * Action: add flow rule to specific ip for userdata.
- *
- * @param deviceId Device Id
- * @param ipPrefix source ip prefix
- * @param dstIp userdata ip
- * @param dstmac dst mac
- * @param actionVni the vni of the source network (l2vni)
- * @param type the operation type of the flow rules
- */
- void programUserdataClassifierRules(DeviceId deviceId, IpPrefix ipPrefix,
- IpAddress dstIp, MacAddress dstmac,
- SegmentationId actionVni,
- Objective.Operation type);
-
- /**
- * Assemble the export port Arp Classifier table rules.
- * Match: export port.
- * Action: upload packet to controller.
- *
- * @param exportPort export port of ovs
- * @param deviceId Device Id
- * @param type the operation type of the flow rules
- */
- void programExportPortArpClassifierRules(Port exportPort, DeviceId deviceId,
- Operation type);
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/DnatService.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/DnatService.java
deleted file mode 100644
index 1634027..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/DnatService.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.table;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.vtnrsc.SegmentationId;
-
-/**
- * DnatService interface provides the rules in DNAT table which is Table(20) for ovs pipeline.
- * DNAT means Destination Network Address Translation, it is acronym for network terminology.
- * Handle the downward flows.
- */
-public interface DnatService {
-
- /**
- * Assemble the DNAT table rules.
- * Match: ipv4 type and destination ip.
- * Action: set eth_src, set ip_dst, set vnid and goto L3Forward Table(30).
- *
- * @param deviceId Device Id
- * @param dstIp floating ip
- * @param ethSrc floating ip gateway mac
- * @param ipDst destination vm ip
- * @param actionVni the vni of L3 network
- * @param type the operation type of the flow rules
- */
- void programRules(DeviceId deviceId, IpAddress dstIp,
- MacAddress ethSrc, IpAddress ipDst,
- SegmentationId actionVni, Objective.Operation type);
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/L2ForwardService.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/L2ForwardService.java
deleted file mode 100644
index 68af8bb..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/L2ForwardService.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.table;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.vtnrsc.SegmentationId;
-
-/**
- * Applies L2 flows to the device. L2Forward table is Table(50).
- */
-public interface L2ForwardService {
-
- /**
- * The local broadcast rule that message matches Table(50).
- * Match: broadcast mac and vnid.
- * Action: set output port.
- *
- * @param deviceId Device Id
- * @param segmentationId the vnid of the host belong to
- * @param inPort the ingress port of the host
- * @param localVmPorts the local ports of the network which connect host
- * @param localTunnelPorts the tunnel pors of the device
- * @param type the operation of the flow
- */
- void programLocalBcastRules(DeviceId deviceId,
- SegmentationId segmentationId,
- PortNumber inPort,
- Iterable<PortNumber> localVmPorts,
- Iterable<PortNumber> localTunnelPorts,
- Objective.Operation type);
-
- /**
- * The tunnel broadcast rule that message matches Table(50).
- * Match: broadcast mac and vnid.
- * Action: output port.
- *
- * @param deviceId Device Id
- * @param segmentationId the vnid of the host belong to
- * @param localVmPorts the local ports of the network which connect host
- * @param localTunnelPorts the tunnel pors of the device
- * @param type the operation of the flow
- */
- void programTunnelBcastRules(DeviceId deviceId,
- SegmentationId segmentationId,
- Iterable<PortNumber> localVmPorts,
- Iterable<PortNumber> localTunnelPorts,
- Objective.Operation type);
-
- /**
- * The local out rule that message matches Table(50).
- * Match: local host mac and vnid.
- * Action: output local host port.
- *
- * @param deviceId Device Id
- * @param segmentationId the vnid of the host belong to
- * @param outPort the ingress port of the host
- * @param sourceMac the mac of the host
- * @param type the operation of the flow
- */
- void programLocalOut(DeviceId deviceId, SegmentationId segmentationId,
- PortNumber outPort, MacAddress sourceMac,
- Objective.Operation type);
-
- /**
- * The external out rule that message matches Table(50).
- * Match: external port mac and vnid.
- * Action: output external port.
- *
- * @param deviceId Device Id
- * @param segmentationId the vnid of the host belong to
- * @param outPort the ingress port of the external port
- * @param sourceMac the mac of the external port
- * @param type the operation of the flow
- */
- void programExternalOut(DeviceId deviceId, SegmentationId segmentationId,
- PortNumber outPort, MacAddress sourceMac,
- Objective.Operation type);
-
- /**
- * The tunnel out rule that message matches Table(50).
- * Match: host mac and vnid.
- * Action: output tunnel port.
- *
- * @param deviceId Device Id
- * @param segmentationId the vnid of the host belong to
- * @param tunnelOutPort the port of the tunnel
- * @param dstMac the mac of the host
- * @param type the operation of the flow
- * @param ipAddress the ipAddress of the node
- */
- void programTunnelOut(DeviceId deviceId, SegmentationId segmentationId,
- PortNumber tunnelOutPort, MacAddress dstMac,
- Objective.Operation type, IpAddress ipAddress);
-
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/L3ForwardService.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/L3ForwardService.java
deleted file mode 100644
index 47677e6..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/L3ForwardService.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.table;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.vtnrsc.SegmentationId;
-
-/**
- * L3ForwardService interface provide the rules in L3Forward table which is Table(30).
- */
-public interface L3ForwardService {
-
- /**
- * Assemble the L3Forward table rules.
- * Match: ipv4 type, vnid and destination ip.
- * Action: set eth_src, set eth_dst, set vnid and goto L2Forward Table(50).
- *
- * @param deviceId Device Id
- * @param l3Vni the vni of L3 network
- * @param dstVmIP destination vm ip
- * @param dstVni the vni of the destination network (l2vni)
- * @param dstVmGwMac destination VM gateway mac
- * @param dstVmMac destination VM mac
- * @param type the operation type of the flow rules
- */
- void programRouteRules(DeviceId deviceId, SegmentationId l3Vni,
- IpAddress dstVmIP, SegmentationId dstVni,
- MacAddress dstVmGwMac, MacAddress dstVmMac,
- Objective.Operation type);
-
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/SnatService.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/SnatService.java
deleted file mode 100644
index 30db4ec..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/SnatService.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.table;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.vtnrsc.SegmentationId;
-
-/**
- * SnatService interface provides the rules in SNAT table which is Table(40) for ovs pipeline.
- * SNAT means Source Network Address Translation, it is acronym for network terminology.
- * Handle the upward flows.
- */
-public interface SnatService {
-
- /**
- * Assemble the SNAT table rules.
- * Match: ipv4 type, vnid, destination ip and source ip.
- * Action: set eth_src, set eth_dst, set ip_src, set vnid and goto L2Forward Table(50).
- *
- * @param deviceId Device Id
- * @param matchVni the vni of L3 network
- * @param srcIP source ip
- * @param dstIP destination ip
- * @param ethDst external gateway mac
- * @param ethSrc external port mac
- * @param ipSrc floating ip
- * @param actionVni external network VNI
- * @param type the operation type of the flow rules
- */
- void programSnatSameSegmentRules(DeviceId deviceId, SegmentationId matchVni,
- IpAddress srcIP, IpAddress dstIP, MacAddress ethDst,
- MacAddress ethSrc, IpAddress ipSrc,
- SegmentationId actionVni, Objective.Operation type);
- /**
- * Assemble the SNAT table rules.
- * Match: ipv4 type, vnid and source ip.
- * Action: set eth_src, set eth_dst, set ip_src, set vnid and goto L2Forward Table(50).
- *
- * @param deviceId Device Id
- * @param matchVni the vni of L3 network
- * @param srcIP source ip
- * @param ethDst external gateway mac
- * @param ethSrc external port mac
- * @param ipSrc floating ip
- * @param actionVni external network VNI
- * @param type the operation type of the flow rules
- */
- void programSnatDiffSegmentRules(DeviceId deviceId, SegmentationId matchVni,
- IpAddress srcIP, MacAddress ethDst,
- MacAddress ethSrc, IpAddress ipSrc,
- SegmentationId actionVni, Objective.Operation type);
-
- /**
- * Assemble the SNAT table rules.
- * Match: ipv4 type, vnid, destination ip and source ip.
- * Action: upload to controller.
- *
- * @param deviceId Device Id
- * @param matchVni the vni of L3 network
- * @param srcIP source ip
- * @param dstIP destination ip
- * @param prefix prefix
- * @param type the operation type of the flow rules
- */
- void programSnatSameSegmentUploadControllerRules(DeviceId deviceId,
- SegmentationId matchVni,
- IpAddress srcIP,
- IpAddress dstIP,
- IpPrefix prefix,
- Objective.Operation type);
-
- /**
- * Remove the SNAT table rules.
- *
- * @param deviceId Device Id
- * @param selector selector of rules
- * @param treatment treatment of rules
- * @param priority priority of rules
- * @param type the operation type of the flow rules
- */
- void removeSnatRules(DeviceId deviceId, TrafficSelector selector,
- TrafficTreatment treatment, int priority,
- Objective.Operation type);
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/ArpServiceImpl.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/ArpServiceImpl.java
deleted file mode 100644
index f8c99be..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/ArpServiceImpl.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.table.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.packet.EthType.EtherType;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.instructions.ExtensionTreatment;
-import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
-import org.onosproject.net.flowobjective.DefaultForwardingObjective;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.flowobjective.ForwardingObjective.Flag;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.net.flowobjective.Objective.Operation;
-import org.onosproject.vtn.table.ArpService;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.slf4j.Logger;
-
-/**
- * ArpTable class providing the rules in ARP table.
- */
-public class ArpServiceImpl implements ArpService {
- private final Logger log = getLogger(getClass());
-
- private static final int ARP_PRIORITY = 0xffff;
- private static final short ARP_RESPONSE = 0x2;
- private static final EtherType ARP_TYPE = EtherType.ARP;
-
- private final FlowObjectiveService flowObjectiveService;
- private final ApplicationId appId;
-
- /**
- * Construct a ArpServiceImpl object.
- *
- * @param appId the application id of vtn
- */
- public ArpServiceImpl(ApplicationId appId) {
- this.appId = checkNotNull(appId, "ApplicationId can not be null");
- ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
- this.flowObjectiveService = serviceDirectory.get(FlowObjectiveService.class);
- }
-
- @Override
- public void programArpRules(DriverHandler hander, DeviceId deviceId,
- IpAddress dstIP, SegmentationId srcVni,
- MacAddress dstMac, Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthType(ARP_TYPE.ethType().toShort())
- .matchArpTpa(Ip4Address.valueOf(dstIP.toString()))
- .matchTunnelId(Long.parseLong(srcVni.segmentationId())).build();
-
- ExtensionTreatmentResolver resolver = hander
- .behaviour(ExtensionTreatmentResolver.class);
- ExtensionTreatment ethSrcToDst = resolver
- .getExtensionInstruction(ExtensionTreatmentType.ExtensionTreatmentTypes
- .NICIRA_MOV_ETH_SRC_TO_DST.type());
- ExtensionTreatment arpShaToTha = resolver
- .getExtensionInstruction(ExtensionTreatmentType.ExtensionTreatmentTypes
- .NICIRA_MOV_ARP_SHA_TO_THA.type());
- ExtensionTreatment arpSpaToTpa = resolver
- .getExtensionInstruction(ExtensionTreatmentType.ExtensionTreatmentTypes
- .NICIRA_MOV_ARP_SPA_TO_TPA.type());
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .extension(ethSrcToDst, deviceId)
- .setEthSrc(dstMac).setArpOp(ARP_RESPONSE)
- .extension(arpShaToTha, deviceId)
- .extension(arpSpaToTpa, deviceId)
- .setArpSha(dstMac).setArpSpa(dstIP)
- .setOutput(PortNumber.IN_PORT).build();
-
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(ARP_PRIORITY);
-
- if (type.equals(Objective.Operation.ADD)) {
- log.debug("PrivateArpRules-->ADD");
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- log.debug("PrivateArpRules-->REMOVE");
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/ClassifierServiceImpl.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/ClassifierServiceImpl.java
deleted file mode 100644
index 9df4663..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/ClassifierServiceImpl.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.table.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.packet.EthType.EtherType;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.criteria.Criteria;
-import org.onosproject.net.flow.instructions.Instructions;
-import org.onosproject.net.flowobjective.DefaultForwardingObjective;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.flowobjective.ForwardingObjective.Flag;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.net.flowobjective.Objective.Operation;
-import org.onosproject.vtn.table.ClassifierService;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.slf4j.Logger;
-
-import com.google.common.collect.Sets;
-
-/**
- * Provides implementation of ClassifierService.
- */
-public class ClassifierServiceImpl implements ClassifierService {
- private final Logger log = getLogger(getClass());
-
- private static final EtherType ETH_TYPE = EtherType.ARP;
- private static final int ARP_CLASSIFIER_PRIORITY = 60000;
- private static final int L3_CLASSIFIER_PRIORITY = 0xffff;
- private static final int L2_CLASSIFIER_PRIORITY = 50000;
- private static final int USERDATA_CLASSIFIER_PRIORITY = 65535;
- private final FlowObjectiveService flowObjectiveService;
- private final ApplicationId appId;
-
- /**
- * Constructor.
- *
- * @param appId the application id of vtn
- */
- public ClassifierServiceImpl(ApplicationId appId) {
- this.appId = checkNotNull(appId, "ApplicationId can not be null");
- ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
- this.flowObjectiveService = serviceDirectory.get(FlowObjectiveService.class);
- }
-
- @Override
- public void programLocalIn(DeviceId deviceId,
- SegmentationId segmentationId, PortNumber inPort,
- MacAddress srcMac, ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(inPort).matchEthSrc(srcMac).build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.add(Instructions
- .modTunnelId(Long.parseLong(segmentationId.toString())));
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).makePermanent()
- .withFlag(Flag.SPECIFIC).withPriority(L2_CLASSIFIER_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- log.debug("programLocalIn-->ADD");
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- log.debug("programLocalIn-->REMOVE");
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-
- @Override
- public void programTunnelIn(DeviceId deviceId,
- SegmentationId segmentationId,
- Iterable<PortNumber> localTunnelPorts,
- Objective.Operation type) {
- if (localTunnelPorts == null) {
- log.info("No tunnel port in device");
- return;
- }
- Sets.newHashSet(localTunnelPorts).forEach(tp -> {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(tp).add(Criteria.matchTunnelId(Long
- .parseLong(segmentationId.toString())))
- .build();
-
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC)
- .withPriority(L2_CLASSIFIER_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- log.debug("programTunnelIn-->ADD");
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- log.debug("programTunnelIn-->REMOVE");
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- });
- }
-
- @Override
- public void programL3ExPortClassifierRules(DeviceId deviceId, PortNumber inPort,
- IpAddress dstIp,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthType(Ethernet.TYPE_IPV4).matchInPort(inPort)
- .matchIPDst(IpPrefix.valueOf(dstIp, 32)).build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(L3_CLASSIFIER_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- log.debug("L3ExToInClassifierRules-->ADD");
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- log.debug("L3ExToInClassifierRules-->REMOVE");
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-
- @Override
- public void programL3InPortClassifierRules(DeviceId deviceId, PortNumber inPort,
- MacAddress srcMac, MacAddress dstMac,
- SegmentationId actionVni,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(inPort).matchEthSrc(srcMac).matchEthDst(dstMac)
- .build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setTunnelId(Long.parseLong(actionVni.segmentationId())).build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(L3_CLASSIFIER_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- log.debug("L3InternalClassifierRules-->ADD");
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- log.debug("L3InternalClassifierRules-->REMOVE");
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-
- @Override
- public void programArpClassifierRules(DeviceId deviceId, IpAddress dstIp,
- SegmentationId actionVni,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthType(ETH_TYPE.ethType().toShort())
- .matchArpTpa(Ip4Address.valueOf(dstIp.toString()))
- .build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setTunnelId(Long.parseLong(actionVni.segmentationId()))
- .build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(ARP_CLASSIFIER_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- log.debug("ArpClassifierRules-->ADD");
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- log.debug("ArpClassifierRules-->REMOVE");
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-
- @Override
- public void programArpClassifierRules(DeviceId deviceId, PortNumber inPort,
- IpAddress dstIp,
- SegmentationId actionVni,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(inPort).matchEthType(ETH_TYPE.ethType().toShort())
- .matchArpTpa(Ip4Address.valueOf(dstIp.toString())).build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setTunnelId(Long.parseLong(actionVni.segmentationId()))
- .build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(ARP_CLASSIFIER_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- log.debug("ArpClassifierRules-->ADD");
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- log.debug("ArpClassifierRules-->REMOVE");
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-
- @Override
- public void programUserdataClassifierRules(DeviceId deviceId,
- IpPrefix ipPrefix,
- IpAddress dstIp,
- MacAddress dstmac,
- SegmentationId actionVni,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthType(Ethernet.TYPE_IPV4).matchIPSrc(ipPrefix)
- .matchIPDst(IpPrefix.valueOf(dstIp, 32)).build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setTunnelId(Long.parseLong(actionVni.segmentationId()))
- .setEthDst(dstmac).build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(USERDATA_CLASSIFIER_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- log.debug("UserdataClassifierRules-->ADD");
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- log.debug("UserdataClassifierRules-->REMOVE");
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-
- @Override
- public void programExportPortArpClassifierRules(Port exportPort,
- DeviceId deviceId,
- Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthType(EtherType.ARP.ethType().toShort())
- .matchInPort(exportPort.number()).build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.add(Instructions.createOutput(PortNumber.CONTROLLER));
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(L3_CLASSIFIER_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/DnatServiceImpl.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/DnatServiceImpl.java
deleted file mode 100644
index 7753486..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/DnatServiceImpl.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.table.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flowobjective.DefaultForwardingObjective;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.flowobjective.ForwardingObjective.Flag;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.vtn.table.DnatService;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.slf4j.Logger;
-
-/**
- * Provides implementation of DnatService.
- */
-public class DnatServiceImpl implements DnatService {
- private final Logger log = getLogger(getClass());
-
- private static final int DNAT_PRIORITY = 0xffff;
- private static final int PREFIX_LENGTH = 32;
-
- private final FlowObjectiveService flowObjectiveService;
- private final ApplicationId appId;
-
- /**
- * Construct a DnatServiceImpl object.
- *
- * @param appId the application id of vtn
- */
- public DnatServiceImpl(ApplicationId appId) {
- this.appId = checkNotNull(appId, "ApplicationId can not be null");
- ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
- this.flowObjectiveService = serviceDirectory.get(FlowObjectiveService.class);
- }
-
- @Override
- public void programRules(DeviceId deviceId, IpAddress dstIp,
- MacAddress ethSrc, IpAddress ipDst,
- SegmentationId actionVni, Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthType(Ethernet.TYPE_IPV4)
- .matchIPDst(IpPrefix.valueOf(dstIp, PREFIX_LENGTH)).build();
-
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.setEthSrc(ethSrc).setIpDst(ipDst)
- .setTunnelId(Long.parseLong(actionVni.segmentationId()));
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(DNAT_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- log.debug("RouteRules-->ADD");
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- log.debug("RouteRules-->REMOVE");
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/L2ForwardServiceImpl.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/L2ForwardServiceImpl.java
deleted file mode 100644
index 41089e0..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/L2ForwardServiceImpl.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.table.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_TUNNEL_DST;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.GroupId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.behaviour.ExtensionTreatmentResolver;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.TrafficTreatment.Builder;
-import org.onosproject.net.flow.criteria.Criteria;
-import org.onosproject.net.flow.instructions.ExtensionTreatment;
-import org.onosproject.net.flowobjective.DefaultForwardingObjective;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.flowobjective.ForwardingObjective.Flag;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.vtn.table.L2ForwardService;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.slf4j.Logger;
-
-import com.google.common.collect.Sets;
-
-/**
- * Provides implementation of L2ForwardService.
- */
-public final class L2ForwardServiceImpl implements L2ForwardService {
- private final Logger log = getLogger(getClass());
-
- private static final int MAC_PRIORITY = 0xffff;
- public static final Integer GROUP_ID = 1;
- private final FlowObjectiveService flowObjectiveService;
- private final ApplicationId appId;
- private final DriverService driverService;
- /**
- * Constructor.
- *
- * @param appId the application id of vtn
- */
- public L2ForwardServiceImpl(ApplicationId appId) {
- this.appId = checkNotNull(appId, "ApplicationId can not be null");
- ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
- this.flowObjectiveService = serviceDirectory.get(FlowObjectiveService.class);
- this.driverService = serviceDirectory.get(DriverService.class);
- }
-
- @Override
- public void programLocalBcastRules(DeviceId deviceId,
- SegmentationId segmentationId,
- PortNumber inPort,
- Iterable<PortNumber> localVmPorts,
- Iterable<PortNumber> localTunnelPorts,
- Objective.Operation type) {
- if (localVmPorts == null || localTunnelPorts == null) {
- log.info("No other host port and tunnel in the device");
- return;
- }
- Sets.newHashSet(localVmPorts).forEach(lp -> {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(lp).matchEthDst(MacAddress.BROADCAST)
- .add(Criteria.matchTunnelId(Long
- .parseLong(segmentationId.toString())))
- .build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment
- .builder();
- boolean flag = false;
- for (PortNumber outPort : localVmPorts) {
- flag = true;
- if (outPort != lp) {
- treatment.setOutput(outPort);
- }
- }
- if (type == Objective.Operation.REMOVE && inPort.equals(lp)) {
- flag = false;
- }
- treatment.group(new GroupId(GROUP_ID));
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).makePermanent()
- .withFlag(Flag.SPECIFIC).withPriority(MAC_PRIORITY);
- if (flag) {
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- });
- }
-
- @Override
- public void programTunnelBcastRules(DeviceId deviceId,
- SegmentationId segmentationId,
- Iterable<PortNumber> localVmPorts,
- Iterable<PortNumber> localTunnelPorts,
- Objective.Operation type) {
- if (localVmPorts == null || localTunnelPorts == null) {
- log.info("No other host port or tunnel ports in the device");
- return;
- }
- Sets.newHashSet(localTunnelPorts).forEach(tp -> {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(tp)
- .add(Criteria.matchTunnelId(Long
- .parseLong(segmentationId.toString())))
- .matchEthDst(MacAddress.BROADCAST).build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment
- .builder();
-
- for (PortNumber outPort : localVmPorts) {
- treatment.setOutput(outPort);
- }
-
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).makePermanent()
- .withFlag(Flag.SPECIFIC).withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- if (Sets.newHashSet(localVmPorts).isEmpty()) {
- flowObjectiveService.forward(deviceId, objective.remove());
- } else {
- flowObjectiveService.forward(deviceId, objective.add());
- }
- } else {
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- });
- }
-
- @Override
- public void programLocalOut(DeviceId deviceId,
- SegmentationId segmentationId,
- PortNumber outPort, MacAddress sourceMac,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchTunnelId(Long.parseLong(segmentationId.toString()))
- .matchEthDst(sourceMac).build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setOutput(outPort).build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- flowObjectiveService.forward(deviceId, objective.remove());
- }
-
- }
-
- @Override
- public void programExternalOut(DeviceId deviceId,
- SegmentationId segmentationId,
- PortNumber outPort, MacAddress sourceMac,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchTunnelId(Long.parseLong(segmentationId.toString()))
- .matchEthSrc(sourceMac).build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setOutput(outPort).build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- flowObjectiveService.forward(deviceId, objective.remove());
- }
-
- }
-
- @Override
- public void programTunnelOut(DeviceId deviceId,
- SegmentationId segmentationId,
- PortNumber tunnelOutPort, MacAddress dstMac,
- Objective.Operation type, IpAddress ipAddress) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthDst(dstMac).add(Criteria.matchTunnelId(Long
- .parseLong(segmentationId.toString())))
- .build();
-
- DriverHandler handler = driverService.createHandler(deviceId);
- ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class);
- ExtensionTreatment treatment = resolver.getExtensionInstruction(NICIRA_SET_TUNNEL_DST.type());
- try {
- treatment.setPropertyValue("tunnelDst", Ip4Address.valueOf(ipAddress.toString()));
- } catch (Exception e) {
- log.error("Failed to get extension instruction to set tunnel dst {}", deviceId);
- }
-
- Builder builder = DefaultTrafficTreatment.builder();
- builder.extension(treatment, deviceId)
- .setOutput(tunnelOutPort).build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(builder.build()).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- flowObjectiveService.forward(deviceId, objective.remove());
- }
-
- }
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/L3ForwardServiceImpl.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/L3ForwardServiceImpl.java
deleted file mode 100644
index 0841d36..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/L3ForwardServiceImpl.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.table.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.instructions.Instructions;
-import org.onosproject.net.flowobjective.DefaultForwardingObjective;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.flowobjective.ForwardingObjective.Flag;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.net.flowobjective.Objective.Operation;
-import org.onosproject.vtn.table.L3ForwardService;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.slf4j.Logger;
-
-/**
- * Provides implementation of L3ForwardService.
- */
-public class L3ForwardServiceImpl implements L3ForwardService {
- private final Logger log = getLogger(getClass());
-
- private static final int L3FWD_PRIORITY = 0xffff;
- private static final short IP_TYPE = Ethernet.TYPE_IPV4;
- private static final int PREFIX_LENGTH = 32;
-
- private final FlowObjectiveService flowObjectiveService;
- private final ApplicationId appId;
-
- /**
- * Construct a L3ForwardServiceImpl object.
- *
- * @param appId the application id of vtn
- */
- public L3ForwardServiceImpl(ApplicationId appId) {
- this.appId = checkNotNull(appId, "ApplicationId can not be null");
- ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
- this.flowObjectiveService = serviceDirectory.get(FlowObjectiveService.class);
- }
-
- @Override
- public void programRouteRules(DeviceId deviceId, SegmentationId l3Vni,
- IpAddress dstVmIP, SegmentationId dstVni,
- MacAddress dstVmGwMac, MacAddress dstVmMac,
- Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthType(IP_TYPE)
- .matchTunnelId(Long.parseLong(l3Vni.segmentationId()))
- .matchIPDst(IpPrefix.valueOf(dstVmIP, PREFIX_LENGTH)).build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.setEthSrc(dstVmGwMac)
- .setEthDst(dstVmMac)
- .add(Instructions.modTunnelId(Long.parseLong(dstVni
- .segmentationId())));
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(L3FWD_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- log.debug("RouteRules-->ADD");
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- log.debug("RouteRules-->REMOVE");
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/SnatServiceImpl.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/SnatServiceImpl.java
deleted file mode 100644
index 8b44938..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/SnatServiceImpl.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.table.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.instructions.Instructions;
-import org.onosproject.net.flowobjective.DefaultForwardingObjective;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.flowobjective.ForwardingObjective.Flag;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.net.flowobjective.Objective.Operation;
-import org.onosproject.vtn.table.SnatService;
-import org.onosproject.vtnrsc.SegmentationId;
-
-/**
- * Provides implementation of SnatService.
- */
-public class SnatServiceImpl implements SnatService {
-
- private static final int SNAT_SAME_SEG_PRIORITY = 0xffff;
- private static final int SNAT_SAME_SEG_CON_PRIORITY = 0xfff0;
- private static final int SNAT_DIFF_SEG_PRIORITY = 0xffe0;
- private static final int PREFIC_LENGTH = 32;
-
- private final FlowObjectiveService flowObjectiveService;
- private final ApplicationId appId;
-
- /**
- * Construct a SnatServiceImpl object.
- *
- * @param appId the application id of vtn
- */
- public SnatServiceImpl(ApplicationId appId) {
- this.appId = checkNotNull(appId, "ApplicationId can not be null");
- ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
- this.flowObjectiveService = serviceDirectory.get(FlowObjectiveService.class);
- }
-
- @Override
- public void programSnatSameSegmentRules(DeviceId deviceId, SegmentationId matchVni,
- IpAddress srcIP, IpAddress dstIP, MacAddress ethDst,
- MacAddress ethSrc, IpAddress ipSrc,
- SegmentationId actionVni, Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthType(Ethernet.TYPE_IPV4)
- .matchTunnelId(Long.parseLong(matchVni.segmentationId()))
- .matchIPSrc(IpPrefix.valueOf(srcIP, PREFIC_LENGTH))
- .matchIPDst(IpPrefix.valueOf(dstIP, PREFIC_LENGTH)).build();
-
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.setEthDst(ethDst).setEthSrc(ethSrc).setIpSrc(ipSrc)
- .setTunnelId(Long.parseLong(actionVni.segmentationId()));
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(SNAT_SAME_SEG_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-
- @Override
- public void programSnatDiffSegmentRules(DeviceId deviceId, SegmentationId matchVni,
- IpAddress srcIP, MacAddress ethDst,
- MacAddress ethSrc, IpAddress ipSrc,
- SegmentationId actionVni, Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthType(Ethernet.TYPE_IPV4)
- .matchTunnelId(Long.parseLong(matchVni.segmentationId()))
- .matchIPSrc(IpPrefix.valueOf(srcIP, PREFIC_LENGTH)).build();
-
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.setEthDst(ethDst).setEthSrc(ethSrc).setIpSrc(ipSrc)
- .setTunnelId(Long.parseLong(actionVni.segmentationId()));
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(SNAT_DIFF_SEG_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-
- @Override
- public void programSnatSameSegmentUploadControllerRules(DeviceId deviceId,
- SegmentationId matchVni,
- IpAddress srcIP,
- IpAddress dstIP,
- IpPrefix prefix,
- Operation type) {
-
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthType(Ethernet.TYPE_IPV4)
- .matchTunnelId(Long.parseLong(matchVni.segmentationId()))
- .matchIPSrc(IpPrefix.valueOf(srcIP, PREFIC_LENGTH))
- .matchIPDst(IpPrefix.valueOf(dstIP, prefix.prefixLength()))
- .build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.add(Instructions.createOutput(PortNumber.CONTROLLER));
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(SNAT_SAME_SEG_CON_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-
- @Override
- public void removeSnatRules(DeviceId deviceId, TrafficSelector selector,
- TrafficTreatment treatment, int priority,
- Objective.Operation type) {
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC).withPriority(priority);
- if (type.equals(Objective.Operation.ADD)) {
- flowObjectiveService.forward(deviceId, objective.add());
- } else {
- flowObjectiveService.forward(deviceId, objective.remove());
- }
- }
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/package-info.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/package-info.java
deleted file mode 100644
index eb81a89..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-package org.onosproject.vtn.table.impl;
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/package-info.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/package-info.java
deleted file mode 100644
index a4bda37..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/table/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-package org.onosproject.vtn.table;
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/DataPathIdGenerator.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/DataPathIdGenerator.java
deleted file mode 100644
index f164ea0..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/DataPathIdGenerator.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.util;
-
-import static org.onlab.util.Tools.toHex;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Calendar;
-
-import org.onosproject.core.IdGenerator;
-import org.onosproject.net.DeviceId;
-
-public final class DataPathIdGenerator implements IdGenerator {
- private static final String SCHEME = "of";
- private String ipAddress;
- private String timeStamp;
-
- private DataPathIdGenerator(Builder builder) {
- this.ipAddress = builder.ipAddress;
- Calendar cal = Calendar.getInstance();
- this.timeStamp = String.valueOf(cal.get(Calendar.SECOND))
- + String.valueOf(cal.get(Calendar.MILLISECOND));
- }
-
- @Override
- public long getNewId() {
- String dpid = ipAddress.replace(".", "") + timeStamp;
- return Long.parseLong(dpid);
- }
-
- public String getDpId() {
- return toHex(getNewId());
- }
-
- public DeviceId getDeviceId() {
- try {
- URI uri = new URI(SCHEME, toHex(getNewId()), null);
- return DeviceId.deviceId(uri);
- } catch (URISyntaxException e) {
- return null;
- }
- }
-
- /**
- * Returns a new builder.
- *
- * @return new builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- public static final class Builder {
- private String ipAddress;
-
- public Builder addIpAddress(String ipAddress) {
- this.ipAddress = ipAddress;
- return this;
- }
-
- public DataPathIdGenerator build() {
- return new DataPathIdGenerator(this);
- }
- }
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/IpUtil.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/IpUtil.java
deleted file mode 100644
index afc8ab3..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/IpUtil.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.util;
-
-import org.onlab.packet.IpAddress;
-
-/**
- * IpUtil utility class.
- */
-public final class IpUtil {
-
- private IpUtil() {
- }
-
- /**
- * check source Ip and destination Ip in same Subnet.
- *
- * @param srcIp source Ip
- * @param dstIp destination
- * @param mask netmask length
- * @return boolean
- */
- public static boolean checkSameSegment(IpAddress srcIp, IpAddress dstIp,
- int mask) {
- String[] ips = srcIp.toString().split("\\.");
- int ipAddr = (Integer.parseInt(ips[0]) << 24)
- | (Integer.parseInt(ips[1]) << 16)
- | (Integer.parseInt(ips[2]) << 8)
- | Integer.parseInt(ips[3]);
- int netmask = 0xFFFFFFFF << (32 - mask);
- String[] cidrIps = dstIp.toString().split("\\.");
- int cidrIpAddr = (Integer.parseInt(cidrIps[0]) << 24)
- | (Integer.parseInt(cidrIps[1]) << 16)
- | (Integer.parseInt(cidrIps[2]) << 8)
- | Integer.parseInt(cidrIps[3]);
-
- return (ipAddr & netmask) == (cidrIpAddr & netmask);
- }
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/VtnConfig.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/VtnConfig.java
deleted file mode 100644
index 859818d..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/VtnConfig.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.util;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.onlab.packet.IpAddress;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.behaviour.BridgeConfig;
-import org.onosproject.net.behaviour.BridgeDescription;
-import org.onosproject.net.behaviour.BridgeName;
-import org.onosproject.net.behaviour.DefaultBridgeDescription;
-import org.onosproject.net.behaviour.DefaultTunnelDescription;
-import org.onosproject.net.behaviour.InterfaceConfig;
-import org.onosproject.net.behaviour.TunnelDescription;
-import org.onosproject.net.behaviour.TunnelEndPoints;
-import org.onosproject.net.behaviour.TunnelKeys;
-import org.onosproject.net.driver.DriverHandler;
-
-/**
- * Applies configuration to the device.
- */
-public final class VtnConfig {
-
- public static final String DEFAULT_BRIDGE_NAME = "br-int";
- private static final String DEFAULT_TUNNEL = "vxlan-0.0.0.0";
- private static final Map<String, String> DEFAULT_TUNNEL_OPTIONS = new HashMap<String, String>() {
- {
- put("key", "flow");
- put("remote_ip", "flow");
- put("dst_port", "4790");
- put("in_nsi", "flow");
- put("in_nsp", "flow");
- put("out_nsi", "flow");
- put("out_nsp", "flow");
- put("in_nshc1", "flow");
- put("out_nshc1", "flow");
- put("in_nshc2", "flow");
- put("out_nshc2", "flow");
- put("in_nshc3", "flow");
- put("out_nshc3", "flow");
- put("in_nshc4", "flow");
- put("out_nshc4", "flow");
- put("exts", "gpe");
- }
- };
- /**
- * Constructs a vtn config object. Utility classes should not have a
- * public or default constructor, otherwise IDE will compile unsuccessfully. This
- * class should not be instantiated.
- */
- private VtnConfig() {
- }
-
- /**
- * Creates or update bridge in the controller device.
- *
- * @param handler DriverHandler
- * @param dpid datapath id
- * @param exPortName external port name
- */
- public static void applyBridgeConfig(DriverHandler handler, String dpid, String exPortName) {
- BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
- BridgeDescription bridgeDesc = DefaultBridgeDescription.builder()
- .name(DEFAULT_BRIDGE_NAME)
- .failMode(BridgeDescription.FailMode.SECURE)
- .datapathId(dpid)
- .disableInBand()
- .enableLocalController()
- .build();
-
- bridgeConfig.addBridge(bridgeDesc);
- bridgeConfig.addPort(BridgeName.bridgeName(DEFAULT_BRIDGE_NAME), exPortName);
- }
-
- /**
- * Creates or update tunnel in the controller device.
- *
- * @param handler DriverHandler
- * @param srcIp the ipAddress of the local controller device
- */
- public static void applyTunnelConfig(DriverHandler handler, IpAddress srcIp) {
- DefaultAnnotations.Builder optionBuilder = DefaultAnnotations.builder();
- for (String key : DEFAULT_TUNNEL_OPTIONS.keySet()) {
- optionBuilder.set(key, DEFAULT_TUNNEL_OPTIONS.get(key));
- }
-
- InterfaceConfig interfaceConfig = handler.behaviour(InterfaceConfig.class);
- TunnelDescription tunnel = DefaultTunnelDescription.builder()
- .deviceId(DEFAULT_BRIDGE_NAME)
- .ifaceName(DEFAULT_TUNNEL)
- .type(TunnelDescription.Type.VXLAN)
- .local(TunnelEndPoints.ipTunnelEndpoint(srcIp))
- .remote(TunnelEndPoints.flowTunnelEndpoint())
- .key(TunnelKeys.flowTunnelKey())
- .otherConfigs(optionBuilder.build())
- .build();
- interfaceConfig.addTunnelMode(DEFAULT_TUNNEL, tunnel);
- }
-
- /**
- * Creates or update tunnel in the controller device.
- *
- * @param handler DriverHandler
- */
- public static void removeTunnelConfig(DriverHandler handler) {
- InterfaceConfig interfaceConfig = handler.behaviour(InterfaceConfig.class);
- interfaceConfig.removeTunnelMode(DEFAULT_TUNNEL);
- }
-
- /**
- * Gets ports in the controller device.
- *
- * @param handler DriverHandler
- * @return set of port numbers
- */
- public static Set<PortNumber> getPortNumbers(DriverHandler handler) {
- BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
- return bridgeConfig.getPortNumbers();
- }
-
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/VtnData.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/VtnData.java
deleted file mode 100644
index f401bde..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/VtnData.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.onlab.packet.IpAddress;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Sets;
-
-/**
- * VtnData utility class.
- */
-public final class VtnData {
-
- private static final Logger log = LoggerFactory.getLogger(VtnData.class);
- private static final String SWITCH_CHANNEL_ID = "channelId";
- private static final String PORT_HEAD = "vxlan";
-
- /**
- * Constructs a VtnData object. Utility classes should not have a public or
- * default constructor, otherwise IDE will compile unsuccessfully. This
- * class should not be instantiated.
- */
- private VtnData() {
- }
-
- /**
- * Get the ControllerIp from the device .
- *
- * @param device Device
- * @return Controller Ip
- */
- public static String getControllerIpOfSwitch(Device device) {
- String url = device.annotations().value(SWITCH_CHANNEL_ID);
- return url.substring(0, url.lastIndexOf(":"));
- }
-
- /**
- * Get the ControllerId from the device .
- *
- * @param device Device
- * @param devices Devices
- * @return Controller Id
- */
- public static DeviceId getControllerId(Device device,
- Iterable<Device> devices) {
- for (Device d : devices) {
- if (d.type() == Device.Type.CONTROLLER && d.id().toString()
- .contains(getControllerIpOfSwitch(device))) {
- return d.id();
- }
- }
- log.info("Can not find controller for device : {}", device.id());
- return null;
- }
-
- /**
- * Get local tunnel ports.
- *
- * @param ports Iterable of Port
- * @return Collection of PortNumber
- */
- public static Collection<PortNumber> getLocalTunnelPorts(Iterable<Port> ports) {
- Collection<PortNumber> localTunnelPorts = new ArrayList<>();
- Sets.newHashSet(ports).stream()
- .filter(p -> !p.number().equals(PortNumber.LOCAL))
- .forEach(p -> {
- if (p.annotations().value(AnnotationKeys.PORT_NAME)
- .startsWith(PORT_HEAD)) {
- localTunnelPorts.add(p.number());
- }
- });
- return localTunnelPorts;
- }
-
- /**
- * Get VirtualPort.
- *
- * @param vPortStore EventuallyConsistentMap of VirtualPort
- * @param vPortId VirtualPortId of the VirtualPort
- * @return VirtualPort
- */
- public static VirtualPort getPort(EventuallyConsistentMap<VirtualPortId, VirtualPort> vPortStore,
- VirtualPortId vPortId) {
- if (vPortStore != null) {
- return vPortStore.get(vPortId);
- }
- return null;
- }
-
- /**
- * Get VirtualPort.
- *
- * @param vPortStore EventuallyConsistentMap of VirtualPort
- * @param fixedIP FixedIp of the VirtualPort
- * @return VirtualPort
- */
- public static VirtualPort getPort(EventuallyConsistentMap<VirtualPortId, VirtualPort> vPortStore,
- FixedIp fixedIP) {
- if (vPortStore != null) {
- List<VirtualPort> vPorts = new ArrayList<>();
- vPortStore.values().forEach(p -> {
- Iterator<FixedIp> fixedIps = p.fixedIps().iterator();
- while (fixedIps.hasNext()) {
- if (fixedIps.next().equals(fixedIP)) {
- vPorts.add(p);
- break;
- }
- }
- });
- if (vPorts.isEmpty()) {
- return null;
- }
- return vPorts.get(0);
- }
- return null;
- }
-
- /**
- * Get VirtualPort.
- *
- * @param vPortStore EventuallyConsistentMap of VirtualPort
- * @param networkId TenantNetworkId of the VirtualPort
- * @param ip IpAddress of the VirtualPort
- * @return VirtualPort
- */
- public static VirtualPort getPort(EventuallyConsistentMap<VirtualPortId, VirtualPort> vPortStore,
- TenantNetworkId networkId, IpAddress ip) {
- if (vPortStore != null) {
- List<VirtualPort> vPorts = new ArrayList<>();
- vPortStore.values().stream()
- .filter(p -> p.networkId().equals(networkId))
- .forEach(p -> {
- Iterator<FixedIp> fixedIps = p.fixedIps().iterator();
- while (fixedIps.hasNext()) {
- if (fixedIps.next().ip().equals(ip)) {
- vPorts.add(p);
- break;
- }
- }
- });
- if (vPorts.isEmpty()) {
- return null;
- }
- return vPorts.get(0);
- }
- return null;
- }
-
-}
diff --git a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/package-info.java b/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/package-info.java
deleted file mode 100644
index 5b82f88..0000000
--- a/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/util/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-package org.onosproject.vtn.util;
diff --git a/apps/vtn/vtnrsc/BUILD b/apps/vtn/vtnrsc/BUILD
deleted file mode 100644
index 167e717..0000000
--- a/apps/vtn/vtnrsc/BUILD
+++ /dev/null
@@ -1,21 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + KRYO + CLI + [
- "//core/store/serializers:onos-core-serializers",
-]
-
-osgi_jar_with_tests(
- exclude_tests = [
- "org/onosproject/vtnrsc/util/VtnEventuallyConsistentMapTest",
- "org/onosproject/vtnrsc/util/VtnStorageServiceTest",
- ],
- karaf_command_packages = [
- "org.onosproject.vtnrsc.cli",
- "org.onosproject.vtnrsc.cli.virtualport",
- "org.onosproject.vtnrsc.cli.subnet",
- "org.onosproject.vtnrsc.cli.routerinterface",
- "org.onosproject.vtnrsc.cli.router",
- "org.onosproject.vtnrsc.cli.network",
- "org.onosproject.vtnrsc.cli.floatingip",
- ],
- test_deps = TEST_REST,
- deps = COMPILE_DEPS,
-)
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java
deleted file mode 100644
index 4701577..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.packet.IpAddress;
-
-/**
- * The continuous IP address range between the start address and the end address for the allocation pools.
- */
-public interface AllocationPool {
-
- /**
- * The start address for the allocation pool.
- *
- * @return startIp
- */
- IpAddress startIp();
-
- /**
- * The end address for the allocation pool.
- *
- * @return endIp
- */
- IpAddress endIp();
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java
deleted file mode 100644
index 7ea093a..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-
-/**
- * Immutable representation of a allowed address pair.
- */
-public final class AllowedAddressPair {
- private final IpAddress ip;
- private final MacAddress mac;
- // Public construction is prohibited
- private AllowedAddressPair(IpAddress ip, MacAddress mac) {
- checkNotNull(ip, "IpAddress cannot be null");
- checkNotNull(mac, "MacAddress cannot be null");
- this.ip = ip;
- this.mac = mac;
- }
- /**
- * Returns the AllowedAddressPair ip address.
- *
- * @return ip address
- */
- public IpAddress ip() {
- return ip;
- }
-
- /**
- * Returns the AllowedAddressPair MAC address.
- *
- * @return MAC address
- */
- public MacAddress mac() {
- return mac;
- }
-
-
- /**
- * Creates a allowedAddressPair using the supplied ipAddress &
- * macAddress.
- *
- * @param ip IP address
- * @param mac MAC address
- * @return AllowedAddressPair
- */
- public static AllowedAddressPair allowedAddressPair(IpAddress ip,
- MacAddress mac) {
- return new AllowedAddressPair(ip, mac);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(ip, mac);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof AllowedAddressPair) {
- final AllowedAddressPair that = (AllowedAddressPair) obj;
- return Objects.equals(this.ip, that.ip)
- && Objects.equals(this.mac, that.mac);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("ip", ip).add("mac", mac).toString();
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java
deleted file mode 100644
index 1e7e825..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-public final class BindingHostId extends Identifier<String> {
- // Public construction is prohibited
- private BindingHostId(String bindingHostId) {
- super(checkNotNull(bindingHostId, "BindingHosttId cannot be null"));
- }
-
- /**
- * Creates a BindingHostId identifier.
- *
- * @param bindingHostId the bindingHostId identifier
- * @return the bindingHostId identifier
- */
- public static BindingHostId bindingHostId(String bindingHostId) {
- return new BindingHostId(bindingHostId);
- }
-
- /**
- * Returns the bindingHostId identifier.
- *
- * @return the bindingHostId identifier
- */
- public String bindingHostId() {
- return identifier;
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java
deleted file mode 100644
index aa9120a..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-
-/**
- * The continuous IP address range between the start address and the end address
- * for the allocation pools.
- */
-public final class DefaultAllocationPool implements AllocationPool {
-
- private final IpAddress startIp;
- private final IpAddress endIp;
-
- /**
- * Creates an AllocationPool by using the start IP address and the end IP
- * address.
- *
- * @param startIp the start IP address of the allocation pool
- * @param endIp the end IP address of the allocation pool
- */
- public DefaultAllocationPool(IpAddress startIp, IpAddress endIp) {
- checkNotNull(startIp, "StartIp cannot be null");
- checkNotNull(endIp, "EndIp cannot be null");
- this.startIp = startIp;
- this.endIp = endIp;
- }
-
- @Override
- public IpAddress startIp() {
- return startIp;
- }
-
- @Override
- public IpAddress endIp() {
- return endIp;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(startIp, endIp);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultAllocationPool) {
- final DefaultAllocationPool other = (DefaultAllocationPool) obj;
- return Objects.equals(this.startIp, other.startIp)
- && Objects.equals(this.endIp, other.endIp);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("startIp", startIp).add("endIp", endIp)
- .toString();
- }
-}
-
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFiveTuple.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFiveTuple.java
deleted file mode 100644
index 3ba25bb..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFiveTuple.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.util.Objects;
-
-import org.onlab.packet.IPv4;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.PortNumber;
-
-/**
- * Representation for five tuple information from packet.
- */
-public final class DefaultFiveTuple implements FiveTuple {
-
- private final MacAddress macSrc;
- private final MacAddress macDst;
- private final IpAddress ipSrc;
- private final IpAddress ipDst;
- private final PortNumber portSrc;
- private final PortNumber portDst;
- private final byte protocol;
- private final TenantId tenantId;
-
- /**
- * Constructor for packet five tuple information.
- *
- * @param protocol protocol of the packet
- * @param ipSrc source ip address of the packet
- * @param ipDst destination ip address of the packet
- * @param portSrc source port of the packet
- * @param portDst destination port of the packet
- */
- private DefaultFiveTuple(byte protocol, IpAddress ipSrc, IpAddress ipDst, PortNumber portSrc, PortNumber portDst,
- TenantId tenantId, MacAddress macSrc, MacAddress macDst) {
-
- this.protocol = protocol;
- this.ipSrc = ipSrc;
- this.ipDst = ipDst;
- this.portSrc = portSrc;
- this.portDst = portDst;
- this.tenantId = tenantId;
- this.macSrc = macSrc;
- this.macDst = macDst;
- }
-
- @Override
- public byte protocol() {
- return protocol;
- }
-
- @Override
- public IpAddress ipSrc() {
- return ipSrc;
- }
-
- @Override
- public IpAddress ipDst() {
- return ipDst;
- }
-
- @Override
- public PortNumber portSrc() {
- return portSrc;
- }
-
- @Override
- public PortNumber portDst() {
- return portDst;
- }
-
- @Override
- public MacAddress macSrc() {
- return macSrc;
- }
-
- @Override
- public MacAddress macDst() {
- return macDst;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultFiveTuple) {
- final DefaultFiveTuple other = (DefaultFiveTuple) obj;
- return Objects.equals(this.protocol, other.protocol) &&
- Objects.equals(this.ipSrc, other.ipSrc) &&
- Objects.equals(this.ipDst, other.ipDst) &&
- Objects.equals(this.portSrc, other.portSrc) &&
- Objects.equals(this.portDst, other.portDst);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(this.protocol, this.ipSrc, this.ipDst, this.portSrc, this.portDst);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .omitNullValues()
- .add("protocol", protocol)
- .add("ipSrc", ipSrc)
- .add("ipDst", ipDst)
- .add("portSrc", portSrc)
- .add("portDst", portDst)
- .toString();
- }
-
- /**
- * To create an instance of the builder.
- *
- * @return instance of builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for Five tuple info.
- */
- public static final class Builder implements FiveTuple.Builder {
-
- private IpAddress ipSrc;
- private IpAddress ipDst;
- private PortNumber portSrc;
- private PortNumber portDst;
- private byte protocol;
- private TenantId tenantId;
- private MacAddress macSrc;
- private MacAddress macDst;
-
- @Override
- public Builder setIpSrc(IpAddress ipSrc) {
- this.ipSrc = ipSrc;
- return this;
- }
-
- @Override
- public Builder setIpDst(IpAddress ipDst) {
- this.ipDst = ipDst;
- return this;
- }
-
- @Override
- public Builder setPortSrc(PortNumber portSrc) {
- this.portSrc = portSrc;
- return this;
- }
-
- @Override
- public Builder setPortDst(PortNumber portDst) {
- this.portDst = portDst;
- return this;
- }
-
- @Override
- public Builder setProtocol(byte protocol) {
- this.protocol = protocol;
- return this;
- }
-
- @Override
- public Builder setTenantId(TenantId tenantId) {
- this.tenantId = tenantId;
- return this;
- }
-
- @Override
- public Builder setMacSrc(MacAddress macSrc) {
- this.macSrc = macSrc;
- return this;
- }
-
- @Override
- public Builder setMacDst(MacAddress macDst) {
- this.macDst = macDst;
- return this;
- }
-
- @Override
- public FiveTuple build() {
- checkArgument(protocol == IPv4.PROTOCOL_TCP || protocol == IPv4.PROTOCOL_UDP ||
- protocol == IPv4.PROTOCOL_ICMP, "Unsupported value for protocol while creating five tuple");
-
- return new DefaultFiveTuple(protocol, ipSrc, ipDst, portSrc, portDst, tenantId, macSrc, macDst);
- }
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFloatingIp.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFloatingIp.java
deleted file mode 100644
index 34eb25f..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFloatingIp.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-
-/**
- * Default implementation of FloatingIp interface.
- */
-public final class DefaultFloatingIp implements FloatingIp {
-
- private final FloatingIpId id;
- private final TenantId tenantId;
- private final TenantNetworkId networkId;
- private final VirtualPortId portId;
- private final RouterId routerId;
- private final IpAddress floatingIp;
- private final IpAddress fixedIp;
- private final Status status;
-
- /**
- *
- * Creates a floating Ip object.
- *
- * @param id floatingIp identifier
- * @param tenantId tenant identifier
- * @param networkId the identifier of network associated with the floating Ip
- * @param portId port identifier
- * @param routerId router identifier
- * @param floatingIp floatingIp address
- * @param fixedIp the fixed Ip associated with the floating Ip
- * @param status the floating Ip status
- */
- public DefaultFloatingIp(FloatingIpId id, TenantId tenantId,
- TenantNetworkId networkId, VirtualPortId portId,
- RouterId routerId, IpAddress floatingIp,
- IpAddress fixedIp, Status status) {
- this.id = checkNotNull(id, "id cannot be null");
- this.tenantId = checkNotNull(tenantId, "tenantId cannot be null");
- this.networkId = checkNotNull(networkId, "networkId cannot be null");
- this.portId = portId;
- this.routerId = routerId;
- this.floatingIp = checkNotNull(floatingIp, "floatingIp cannot be null");
- this.fixedIp = fixedIp;
- this.status = checkNotNull(status, "status cannot be null");
- }
-
- @Override
- public FloatingIpId id() {
- return id;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public TenantNetworkId networkId() {
- return networkId;
- }
-
- @Override
- public VirtualPortId portId() {
- return portId;
- }
-
- @Override
- public RouterId routerId() {
- return routerId;
- }
-
- @Override
- public IpAddress floatingIp() {
- return floatingIp;
- }
-
- @Override
- public IpAddress fixedIp() {
- return fixedIp;
- }
-
- @Override
- public Status status() {
- return status;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, tenantId, networkId, portId, routerId,
- floatingIp, fixedIp, status);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultFloatingIp) {
- final DefaultFloatingIp that = (DefaultFloatingIp) obj;
- return Objects.equals(this.id, that.id)
- && Objects.equals(this.tenantId, that.tenantId)
- && Objects.equals(this.networkId, that.networkId)
- && Objects.equals(this.portId, that.portId)
- && Objects.equals(this.routerId, that.routerId)
- && Objects.equals(this.floatingIp, that.floatingIp)
- && Objects.equals(this.fixedIp, that.fixedIp)
- && Objects.equals(this.status, that.status);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("id", id).add("tenantId", tenantId)
- .add("networkId", networkId).add("portId", portId)
- .add("routerId", routerId).add("floatingIp", floatingIp)
- .add("fixedIp", fixedIp).add("floatingIpStatus", status)
- .toString();
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java
deleted file mode 100644
index b944b4f..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-import org.onlab.packet.IpPrefix;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Default flow classifier.
- */
-public final class DefaultFlowClassifier implements FlowClassifier {
-
- private final FlowClassifierId flowClassifierId;
- private final TenantId tenantId;
- private final String name;
- private final String description;
- private final String etherType;
- private final String protocol;
- private final int priority;
- private final int minSrcPortRange;
- private final int maxSrcPortRange;
- private final int minDstPortRange;
- private final int maxDstPortRange;
- private final IpPrefix srcIpPrefix;
- private final IpPrefix dstIpPrefix;
- private final VirtualPortId srcPort;
- private final VirtualPortId dstPort;
- private static final int NULL_PORT = 0;
- private static final String FLOW_CLASSIFIER_ID_NOT_NULL = "FlowClassifier id can not be null.";
- private static final String TENANT_ID_NOT_NULL = "Tenant id can not be null.";
- private static final String NAME_NOT_NULL = "Name can not be null.";
- private static final String ETHER_TYPE_NOT_NULL = "Ether Type can not be null.";
- private static final int DEFAULT_CLASSIFIER_PRIORITY = 0xCB20;
-
- /**
- * Constructor to create default flow classifier.
- *
- * @param flowClassifierId flow classifier Id
- * @param tenantId Tenant ID
- * @param name flow classifier name
- * @param description flow classifier description
- * @param etherType etherType
- * @param protocol IP protocol
- * @param priority priority for classification
- * @param minSrcPortRange Minimum Source port range
- * @param maxSrcPortRange Maximum Source port range
- * @param minDstPortRange Minimum destination port range
- * @param maxDstPortRange Maximum destination port range
- * @param srcIpPrefix Source IP prefix
- * @param dstIpPrefix destination IP prefix
- * @param srcPort Source VirtualPort
- * @param dstPort destination VirtualPort
- */
- private DefaultFlowClassifier(FlowClassifierId flowClassifierId, TenantId tenantId, String name,
- String description, String etherType, String protocol, int priority,
- int minSrcPortRange, int maxSrcPortRange, int minDstPortRange, int maxDstPortRange,
- IpPrefix srcIpPrefix, IpPrefix dstIpPrefix, VirtualPortId srcPort,
- VirtualPortId dstPort) {
- this.flowClassifierId = flowClassifierId;
- this.tenantId = tenantId;
- this.name = name;
- this.description = description;
- this.etherType = etherType;
- this.protocol = protocol;
- this.priority = priority;
- this.minSrcPortRange = minSrcPortRange;
- this.maxSrcPortRange = maxSrcPortRange;
- this.minDstPortRange = minDstPortRange;
- this.maxDstPortRange = maxDstPortRange;
- this.srcIpPrefix = srcIpPrefix;
- this.dstIpPrefix = dstIpPrefix;
- this.srcPort = srcPort;
- this.dstPort = dstPort;
- }
-
- @Override
- public FlowClassifierId flowClassifierId() {
- return flowClassifierId;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public String description() {
- return description;
- }
-
- @Override
- public String etherType() {
- return etherType;
- }
-
- @Override
- public String protocol() {
- return protocol;
- }
-
- @Override
- public int priority() {
- return priority;
- }
-
- @Override
- public int minSrcPortRange() {
- return minSrcPortRange;
- }
-
- @Override
- public int maxSrcPortRange() {
- return maxSrcPortRange;
- }
-
- @Override
- public int minDstPortRange() {
- return minDstPortRange;
- }
-
- @Override
- public int maxDstPortRange() {
- return maxDstPortRange;
- }
-
- @Override
- public IpPrefix srcIpPrefix() {
- return srcIpPrefix;
- }
-
- @Override
- public IpPrefix dstIpPrefix() {
- return dstIpPrefix;
- }
-
- @Override
- public VirtualPortId srcPort() {
- return srcPort;
- }
-
- @Override
- public VirtualPortId dstPort() {
- return dstPort;
- }
-
- /**
- * Builder class for constructing Flow classifier.
- */
- public static class Builder implements FlowClassifier.Builder {
-
- private FlowClassifierId flowClassifierId;
- private TenantId tenantId;
- private String name;
- private String description;
- private boolean isFlowClassifierDescriptionSet = false;
- private String etherType;
- private String protocol;
- private boolean isProtocolSet = false;
- private int priority;
- private boolean isPrioritySet = false;
- private int minSrcPortRange;
- private boolean isMinSrcPortRangeSet = false;
- private int maxSrcPortRange;
- private boolean isMaxSrcPortRangeSet = false;
- private int minDstPortRange;
- private boolean isMinDstPortRangeSet = false;
- private int maxDstPortRange;
- private boolean isMaxDstPortRangeSet = false;
- private IpPrefix srcIpPrefix;
- private boolean isSrcIpPrefixSet = false;
- private IpPrefix dstIpPrefix;
- private boolean isDstIpPrefixSet = false;
- private VirtualPortId srcPort;
- private boolean isSrcPortSet = false;
- private VirtualPortId dstPort;
- private boolean isDstPortSet = false;
-
- @Override
- public FlowClassifier build() {
-
- checkNotNull(flowClassifierId, FLOW_CLASSIFIER_ID_NOT_NULL);
- checkNotNull(tenantId, TENANT_ID_NOT_NULL);
- checkNotNull(name, NAME_NOT_NULL);
- checkNotNull(etherType, ETHER_TYPE_NOT_NULL);
- String description = null;
- String protocol = null;
- int priority = DEFAULT_CLASSIFIER_PRIORITY;
- int minSrcPortRange = NULL_PORT;
- int maxSrcPortRange = NULL_PORT;
- int minDstPortRange = NULL_PORT;
- int maxDstPortRange = NULL_PORT;
- IpPrefix srcIpPrefix = null;
- IpPrefix dstIpPrefix = null;
- VirtualPortId srcPort = null;
- VirtualPortId dstPort = null;
-
- if (isFlowClassifierDescriptionSet) {
- description = this.description;
- }
- if (isProtocolSet) {
- protocol = this.protocol;
- }
- if (isPrioritySet) {
- priority = this.priority;
- }
- if (isMinSrcPortRangeSet) {
- minSrcPortRange = this.minSrcPortRange;
- }
- if (isMaxSrcPortRangeSet) {
- maxSrcPortRange = this.maxSrcPortRange;
- }
- if (isMinDstPortRangeSet) {
- minDstPortRange = this.minDstPortRange;
- }
- if (isMaxDstPortRangeSet) {
- maxDstPortRange = this.maxDstPortRange;
- }
- if (isSrcIpPrefixSet) {
- srcIpPrefix = this.srcIpPrefix;
- }
- if (isDstIpPrefixSet) {
- dstIpPrefix = this.dstIpPrefix;
- }
- if (isSrcPortSet) {
- srcPort = this.srcPort;
- }
- if (isDstPortSet) {
- dstPort = this.dstPort;
- }
-
- return new DefaultFlowClassifier(flowClassifierId, tenantId, name, description, etherType, protocol,
- priority, minSrcPortRange, maxSrcPortRange, minDstPortRange,
- maxDstPortRange, srcIpPrefix, dstIpPrefix, srcPort, dstPort);
- }
-
- @Override
- public Builder setFlowClassifierId(FlowClassifierId flowClassifierId) {
- this.flowClassifierId = flowClassifierId;
- return this;
- }
-
- @Override
- public Builder setTenantId(TenantId tenantId) {
- this.tenantId = tenantId;
- return this;
- }
-
- @Override
- public Builder setName(String name) {
- this.name = name;
- return this;
- }
-
- @Override
- public Builder setDescription(String description) {
- this.description = description;
- this.isFlowClassifierDescriptionSet = true;
- return this;
- }
-
- @Override
- public Builder setEtherType(String etherType) {
- this.etherType = etherType;
- return this;
- }
-
- @Override
- public Builder setProtocol(String protocol) {
- this.protocol = protocol;
- this.isProtocolSet = true;
- return this;
- }
-
- @Override
- public Builder setPriority(int priority) {
- this.priority = priority;
- this.isPrioritySet = true;
- return this;
- }
-
- @Override
- public Builder setMinSrcPortRange(int minSrcPortRange) {
- this.minSrcPortRange = minSrcPortRange;
- this.isMinSrcPortRangeSet = true;
- return this;
- }
-
- @Override
- public Builder setMaxSrcPortRange(int maxSrcPortRange) {
- this.maxSrcPortRange = maxSrcPortRange;
- this.isMaxSrcPortRangeSet = true;
- return this;
- }
-
- @Override
- public Builder setMinDstPortRange(int minDstPortRange) {
- this.minDstPortRange = minDstPortRange;
- this.isMinDstPortRangeSet = true;
- return this;
- }
-
- @Override
- public Builder setMaxDstPortRange(int maxDstPortRange) {
- this.maxDstPortRange = maxDstPortRange;
- this.isMaxDstPortRangeSet = true;
- return this;
- }
-
- @Override
- public Builder setSrcIpPrefix(IpPrefix srcIpPrefix) {
- this.srcIpPrefix = srcIpPrefix;
- this.isSrcIpPrefixSet = true;
- return this;
- }
-
- @Override
- public Builder setDstIpPrefix(IpPrefix dstIpPrefix) {
- this.dstIpPrefix = dstIpPrefix;
- this.isDstIpPrefixSet = true;
- return this;
- }
-
- @Override
- public Builder setSrcPort(VirtualPortId srcPort) {
- this.srcPort = srcPort;
- this.isSrcPortSet = true;
- return this;
- }
-
- @Override
- public Builder setDstPort(VirtualPortId dstPort) {
- this.dstPort = dstPort;
- this.isDstPortSet = true;
- return this;
- }
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(flowClassifierId, tenantId, name, description, etherType, protocol, minSrcPortRange,
- maxSrcPortRange, minDstPortRange, maxDstPortRange, srcIpPrefix, dstIpPrefix, srcPort, dstPort);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultFlowClassifier) {
- DefaultFlowClassifier other = (DefaultFlowClassifier) obj;
- return Objects.equals(this.flowClassifierId, other.flowClassifierId)
- && Objects.equals(this.tenantId, other.tenantId)
- && Objects.equals(this.name, other.name)
- && Objects.equals(this.description, other.description)
- && Objects.equals(this.etherType, other.etherType)
- && Objects.equals(this.protocol, other.protocol)
- && Objects.equals(this.priority, other.priority)
- && Objects.equals(this.minSrcPortRange, other.minSrcPortRange)
- && Objects.equals(this.maxSrcPortRange, other.maxSrcPortRange)
- && Objects.equals(this.minDstPortRange, other.minDstPortRange)
- && Objects.equals(this.maxDstPortRange, other.maxDstPortRange)
- && Objects.equals(this.srcIpPrefix, other.srcIpPrefix)
- && Objects.equals(this.dstIpPrefix, other.dstIpPrefix)
- && Objects.equals(this.srcPort, other.srcPort)
- && Objects.equals(this.dstPort, other.dstPort);
- }
- return false;
- }
-
- @Override
- public boolean exactMatch(FlowClassifier flowClassifier) {
- return this.equals(flowClassifier)
- && Objects.equals(this.flowClassifierId, flowClassifier.flowClassifierId())
- && Objects.equals(this.tenantId, flowClassifier.tenantId())
- && Objects.equals(this.name, flowClassifier.name())
- && Objects.equals(this.description, flowClassifier.description())
- && Objects.equals(this.etherType, flowClassifier.etherType())
- && Objects.equals(this.protocol, flowClassifier.protocol())
- && Objects.equals(this.priority, flowClassifier.priority())
- && Objects.equals(this.minSrcPortRange, flowClassifier.minSrcPortRange())
- && Objects.equals(this.maxSrcPortRange, flowClassifier.maxSrcPortRange())
- && Objects.equals(this.minDstPortRange, flowClassifier.minDstPortRange())
- && Objects.equals(this.maxDstPortRange, flowClassifier.maxDstPortRange())
- && Objects.equals(this.srcIpPrefix, flowClassifier.srcIpPrefix())
- && Objects.equals(this.dstIpPrefix, flowClassifier.dstIpPrefix())
- && Objects.equals(this.srcPort, flowClassifier.srcPort())
- && Objects.equals(this.dstPort, flowClassifier.dstPort());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("FlowClassifierId", flowClassifierId)
- .add("TenantId", tenantId)
- .add("Name", name)
- .add("Description", description)
- .add("String", etherType)
- .add("Protocol", protocol)
- .add("Priority", priority)
- .add("MinSrcPortRange", minSrcPortRange)
- .add("MaxSrcPortRange", maxSrcPortRange)
- .add("MinDstPortRange", minDstPortRange)
- .add("MaxDstPortRange", maxDstPortRange)
- .add("SrcIpPrefix", srcIpPrefix)
- .add("DstIpPrefix", dstIpPrefix)
- .add("SrcPort", srcPort)
- .add("DstPort", dstPort)
- .toString();
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java
deleted file mode 100644
index ca75035..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-
-/**
- * Host route dictionaries for the subnet.
- */
-public final class DefaultHostRoute implements HostRoute {
-
- private final IpAddress nexthop;
- private final IpPrefix destination;
-
- /**
- *
- * Creates a DefaultHostRoute by using the next hop and the destination.
- *
- * @param nexthop of the DefaultHostRoute
- * @param destination of the DefaultHostRoute
- */
- public DefaultHostRoute(IpAddress nexthop, IpPrefix destination) {
- this.nexthop = nexthop;
- this.destination = destination;
- }
-
- @Override
- public IpAddress nexthop() {
- return nexthop;
- }
-
- @Override
- public IpPrefix destination() {
- return destination;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("nexthop", nexthop)
- .add("destination", destination).toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(nexthop, destination);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultHostRoute) {
- final DefaultHostRoute other = (DefaultHostRoute) obj;
- return Objects.equals(this.nexthop, other.nexthop)
- && Objects.equals(this.destination, other.destination);
- }
- return false;
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortChain.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortChain.java
deleted file mode 100644
index dd67d84..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortChain.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.onosproject.net.DeviceId;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Implementation of port chain.
- */
-public final class DefaultPortChain implements PortChain {
-
- private final PortChainId portChainId;
- private final TenantId tenantId;
- private final String name;
- private final String description;
- private final List<PortPairGroupId> portPairGroupList;
- private final List<FlowClassifierId> flowClassifierList;
- private final PortChain oldPortChain;
-
- private final Map<FiveTuple, LoadBalanceId> sfcLoadBalanceIdMap = new ConcurrentHashMap<>();
- private final Map<LoadBalanceId, List<PortPairId>> sfcLoadBalancePathMap = new ConcurrentHashMap<>();
- private final Map<LoadBalanceId, List<DeviceId>> sfcClassifiersMap = new ConcurrentHashMap<>();
- private final Map<LoadBalanceId, List<DeviceId>> sfcForwardersMap = new ConcurrentHashMap<>();
-
- /**
- * Default constructor to create port chain.
- *
- * @param portChainId port chain id
- * @param tenantId tenant id
- * @param name name of port chain
- * @param description description of port chain
- * @param portPairGroupList port pair group list
- * @param flowClassifierList flow classifier list
- */
- private DefaultPortChain(PortChainId portChainId, TenantId tenantId,
- String name, String description,
- List<PortPairGroupId> portPairGroupList,
- List<FlowClassifierId> flowClassifierList,
- PortChain portChain) {
-
- this.portChainId = portChainId;
- this.tenantId = tenantId;
- this.name = name;
- this.description = description;
- this.portPairGroupList = portPairGroupList;
- this.flowClassifierList = flowClassifierList;
- this.oldPortChain = portChain;
- }
-
- /**
- * To create port chain for update with old port chain.
- *
- * @param newPortChain updated port chain
- * @param oldPortChain old port chain
- * @return port chain
- */
- public static PortChain create(PortChain newPortChain, PortChain oldPortChain) {
- return new DefaultPortChain(newPortChain.portChainId(), newPortChain.tenantId(),
- newPortChain.name(), newPortChain.description(),
- newPortChain.portPairGroups(), newPortChain.flowClassifiers(), oldPortChain);
- }
-
- /**
- * Match for two given paths.
- *
- * @param path1 path of sfc
- * @param path2 path of sfc
- * @return true if the given path are same false otherwise
- */
- private boolean comparePath(List<PortPairId> path1, List<PortPairId> path2) {
- Iterator it = path1.iterator();
- for (PortPairId portPairId: path2) {
- if (!portPairId.equals(it.next())) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public PortChainId portChainId() {
- return portChainId;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public String description() {
- return description;
- }
-
- @Override
- public List<PortPairGroupId> portPairGroups() {
- return ImmutableList.copyOf(portPairGroupList);
- }
-
- @Override
- public List<FlowClassifierId> flowClassifiers() {
- return ImmutableList.copyOf(flowClassifierList);
- }
-
- @Override
- public PortChain oldPortChain() {
- return oldPortChain;
- }
-
- @Override
- public void addLoadBalancePath(FiveTuple fiveTuple, LoadBalanceId id,
- List<PortPairId> path) {
- this.sfcLoadBalanceIdMap.put(fiveTuple, id);
- this.sfcLoadBalancePathMap.put(id, path);
- }
-
- @Override
- public void addSfcClassifiers(LoadBalanceId id, List<DeviceId> classifierList) {
- this.sfcClassifiersMap.put(id, classifierList);
- }
-
- @Override
- public void addSfcForwarders(LoadBalanceId id, List<DeviceId> forwarderList) {
- this.sfcForwardersMap.put(id, forwarderList);
- }
-
- @Override
- public void removeSfcClassifiers(LoadBalanceId id, List<DeviceId> classifierList) {
- List<DeviceId> list = sfcClassifiersMap.get(id);
- list.removeAll(classifierList);
- this.sfcForwardersMap.put(id, list);
- }
-
- @Override
- public void removeSfcForwarders(LoadBalanceId id, List<DeviceId> forwarderList) {
- List<DeviceId> list = sfcForwardersMap.get(id);
- list.removeAll(forwarderList);
- this.sfcForwardersMap.put(id, list);
- }
-
- @Override
- public List<DeviceId> getSfcClassifiers(LoadBalanceId id) {
- return ImmutableList.copyOf(this.sfcClassifiersMap.get(id));
- }
-
- @Override
- public List<DeviceId> getSfcForwarders(LoadBalanceId id) {
- return ImmutableList.copyOf(this.sfcForwardersMap.get(id));
- }
-
- @Override
- public LoadBalanceId getLoadBalanceId(FiveTuple fiveTuple) {
- return this.sfcLoadBalanceIdMap.get(fiveTuple);
- }
-
- @Override
- public Set<FiveTuple> getLoadBalanceIdMapKeys() {
- return ImmutableSet.copyOf(sfcLoadBalanceIdMap.keySet());
- }
-
- @Override
- public Set<LoadBalanceId> getLoadBalancePathMapKeys() {
- return ImmutableSet.copyOf(sfcLoadBalancePathMap.keySet());
- }
-
- @Override
- public List<PortPairId> getLoadBalancePath(LoadBalanceId id) {
- return ImmutableList.copyOf(this.sfcLoadBalancePathMap.get(id));
- }
-
- @Override
- public List<PortPairId> getLoadBalancePath(FiveTuple fiveTuple) {
- return ImmutableList.copyOf(this.sfcLoadBalancePathMap.get(this.sfcLoadBalanceIdMap.get(fiveTuple)));
- }
-
- @Override
- public int getLoadBalancePathSize() {
- if (sfcLoadBalanceIdMap.isEmpty()) {
- return 0;
- }
- return sfcLoadBalanceIdMap.size();
- }
-
- @Override
- public LoadBalanceId matchPath(List<PortPairId> path) {
-
- LoadBalanceId id = null;
- for (Map.Entry<LoadBalanceId, List<PortPairId>> entry : sfcLoadBalancePathMap.entrySet()) {
- List<PortPairId> tempPath = entry.getValue();
- if (comparePath(path, tempPath)) {
- id = entry.getKey();
- break;
- }
- }
- return id;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(portChainId, tenantId, name, description,
- portPairGroupList, flowClassifierList);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultPortChain) {
- DefaultPortChain that = (DefaultPortChain) obj;
- return Objects.equals(portChainId, that.portChainId) &&
- Objects.equals(tenantId, that.tenantId) &&
- Objects.equals(name, that.name) &&
- Objects.equals(description, that.description) &&
- Objects.equals(portPairGroupList, that.portPairGroupList) &&
- Objects.equals(flowClassifierList, that.flowClassifierList);
- }
- return false;
- }
-
- @Override
- public boolean exactMatch(PortChain portChain) {
- return this.equals(portChain) &&
- Objects.equals(this.portChainId, portChain.portChainId()) &&
- Objects.equals(this.tenantId, portChain.tenantId());
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("id", portChainId.toString())
- .add("tenantId", tenantId.toString())
- .add("name", name)
- .add("description", description)
- .add("portPairGroupList", portPairGroupList)
- .add("flowClassifier", flowClassifierList)
- .toString();
- }
-
- /**
- * To create an instance of the builder.
- *
- * @return instance of builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for Port chain.
- */
- public static final class Builder implements PortChain.Builder {
-
- private PortChainId portChainId;
- private TenantId tenantId;
- private String name;
- private String description;
- private List<PortPairGroupId> portPairGroupList;
- private List<FlowClassifierId> flowClassifierList;
- private PortChain portChain;
-
- @Override
- public Builder setId(PortChainId portChainId) {
- this.portChainId = portChainId;
- return this;
- }
-
- @Override
- public Builder setTenantId(TenantId tenantId) {
- this.tenantId = tenantId;
- return this;
- }
-
- @Override
- public Builder setName(String name) {
- this.name = name;
- return this;
- }
-
- @Override
- public Builder setDescription(String description) {
- this.description = description;
- return this;
- }
-
- @Override
- public Builder setPortPairGroups(List<PortPairGroupId> portPairGroups) {
- this.portPairGroupList = portPairGroups;
- return this;
- }
-
- @Override
- public Builder setFlowClassifiers(List<FlowClassifierId> flowClassifiers) {
- this.flowClassifierList = flowClassifiers;
- return this;
- }
-
- @Override
- public PortChain build() {
-
- checkNotNull(portChainId, "Port chain id cannot be null");
- checkNotNull(tenantId, "Tenant id cannot be null");
- checkNotNull(portPairGroupList, "Port pair groups cannot be null");
-
- return new DefaultPortChain(portChainId, tenantId, name, description,
- portPairGroupList, flowClassifierList, portChain);
- }
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortPair.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortPair.java
deleted file mode 100644
index 84dc531..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortPair.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-/**
- * Implementation of port pair.
- */
-public final class DefaultPortPair implements PortPair {
-
- private final PortPairId portPairId;
- private final TenantId tenantId;
- private final String name;
- private final String description;
- private final String ingress;
- private final String egress;
-
- /**
- * Default constructor to create Port Pair.
- *
- * @param portPairId port pair id
- * @param tenantId tenant id
- * @param name name of port pair
- * @param description description of port pair
- * @param ingress ingress port
- * @param egress egress port
- */
- private DefaultPortPair(PortPairId portPairId, TenantId tenantId,
- String name, String description,
- String ingress, String egress) {
-
- this.portPairId = portPairId;
- this.tenantId = tenantId;
- this.name = name;
- this.description = description;
- this.ingress = ingress;
- this.egress = egress;
- }
-
- @Override
- public PortPairId portPairId() {
- return portPairId;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public String description() {
- return description;
- }
-
- @Override
- public String ingress() {
- return ingress;
- }
-
- @Override
- public String egress() {
- return egress;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(portPairId, tenantId, name, description,
- ingress, egress);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultPortPair) {
- DefaultPortPair that = (DefaultPortPair) obj;
- return Objects.equals(portPairId, that.portPairId) &&
- Objects.equals(tenantId, that.tenantId) &&
- Objects.equals(name, that.name) &&
- Objects.equals(description, that.description) &&
- Objects.equals(ingress, that.ingress) &&
- Objects.equals(egress, that.egress);
- }
- return false;
- }
-
- @Override
- public boolean exactMatch(PortPair portPair) {
- return this.equals(portPair) &&
- Objects.equals(this.portPairId, portPair.portPairId()) &&
- Objects.equals(this.tenantId, portPair.tenantId());
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("id", portPairId.toString())
- .add("tenantId", tenantId.tenantId())
- .add("name", name)
- .add("description", description)
- .add("ingress", ingress)
- .add("egress", egress)
- .toString();
- }
-
- /**
- * To create an instance of the builder.
- *
- * @return instance of builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for Port pair.
- */
- public static final class Builder implements PortPair.Builder {
-
- private PortPairId portPairId;
- private TenantId tenantId;
- private String name;
- private String description;
- private String ingress;
- private String egress;
-
- @Override
- public Builder setId(PortPairId portPairId) {
- this.portPairId = portPairId;
- return this;
- }
-
- @Override
- public Builder setTenantId(TenantId tenantId) {
- this.tenantId = tenantId;
- return this;
- }
-
- @Override
- public Builder setName(String name) {
- this.name = name;
- return this;
- }
-
- @Override
- public Builder setDescription(String description) {
- this.description = description;
- return this;
- }
-
- @Override
- public Builder setIngress(String ingress) {
- this.ingress = ingress;
- return this;
- }
-
- @Override
- public Builder setEgress(String egress) {
- this.egress = egress;
- return this;
- }
-
- @Override
- public PortPair build() {
-
- checkNotNull(portPairId, "Port pair id cannot be null");
- checkNotNull(tenantId, "Tenant id cannot be null");
- checkNotNull(ingress, "Ingress of a port pair cannot be null");
- checkNotNull(egress, "Egress of a port pair cannot be null");
-
- return new DefaultPortPair(portPairId, tenantId, name, description,
- ingress, egress);
- }
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortPairGroup.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortPairGroup.java
deleted file mode 100644
index a3a5780..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortPairGroup.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Implementation of port pair group.
- */
-public final class DefaultPortPairGroup implements PortPairGroup {
-
- private final PortPairGroupId portPairGroupId;
- private final TenantId tenantId;
- private final String name;
- private final String description;
- private final List<PortPairId> portPairList;
- private final Map<PortPairId, Integer> portPairLoadMap;
-
- /**
- * Default constructor to create Port Pair Group.
- *
- * @param portPairGroupId port pair group id
- * @param tenantId tenant id
- * @param name name of port pair group
- * @param description description of port pair group
- * @param portPairList list of port pairs
- */
- private DefaultPortPairGroup(PortPairGroupId portPairGroupId, TenantId tenantId,
- String name, String description,
- List<PortPairId> portPairList) {
-
- this.portPairGroupId = portPairGroupId;
- this.tenantId = tenantId;
- this.name = name;
- this.description = description;
- this.portPairList = portPairList;
- portPairLoadMap = new ConcurrentHashMap<>();
- for (PortPairId portPairId : portPairList) {
- portPairLoadMap.put(portPairId, new Integer(0));
- }
- }
-
- @Override
- public PortPairGroupId portPairGroupId() {
- return portPairGroupId;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public String description() {
- return description;
- }
-
- @Override
- public List<PortPairId> portPairs() {
- return ImmutableList.copyOf(portPairList);
- }
-
- @Override
- public void addLoad(PortPairId portPairId) {
- int load = portPairLoadMap.get(portPairId);
- load = load + 1;
- portPairLoadMap.put(portPairId, new Integer(load));
- }
-
- @Override
- public void resetLoad() {
- for (PortPairId portPairId : portPairList) {
- portPairLoadMap.put(portPairId, new Integer(0));
- }
- }
-
- @Override
- public int getLoad(PortPairId portPairId) {
- return portPairLoadMap.get(portPairId);
- }
-
- @Override
- public Map<PortPairId, Integer> portPairLoadMap() {
- return ImmutableMap.copyOf(portPairLoadMap);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(portPairGroupId, tenantId, name, description,
- portPairList);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultPortPairGroup) {
- DefaultPortPairGroup that = (DefaultPortPairGroup) obj;
- return Objects.equals(portPairGroupId, that.portPairGroupId) &&
- Objects.equals(tenantId, that.tenantId) &&
- Objects.equals(name, that.name) &&
- Objects.equals(description, that.description) &&
- Objects.equals(portPairList, that.portPairList);
- }
- return false;
- }
-
- @Override
- public boolean exactMatch(PortPairGroup portPairGroup) {
- return this.equals(portPairGroup) &&
- Objects.equals(this.portPairGroupId, portPairGroup.portPairGroupId()) &&
- Objects.equals(this.tenantId, portPairGroup.tenantId());
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("id", portPairGroupId.toString())
- .add("tenantId", tenantId.toString())
- .add("name", name)
- .add("description", description)
- .add("portPairGroupList", portPairList)
- .toString();
- }
-
- /**
- * To create an instance of the builder.
- *
- * @return instance of builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder class for Port pair group.
- */
- public static final class Builder implements PortPairGroup.Builder {
-
- private PortPairGroupId portPairGroupId;
- private TenantId tenantId;
- private String name;
- private String description;
- private List<PortPairId> portPairList;
-
- @Override
- public Builder setId(PortPairGroupId portPairGroupId) {
- this.portPairGroupId = portPairGroupId;
- return this;
- }
-
- @Override
- public Builder setTenantId(TenantId tenantId) {
- this.tenantId = tenantId;
- return this;
- }
-
- @Override
- public Builder setName(String name) {
- this.name = name;
- return this;
- }
-
- @Override
- public Builder setDescription(String description) {
- this.description = description;
- return this;
- }
-
- @Override
- public Builder setPortPairs(List<PortPairId> portPairs) {
- this.portPairList = portPairs;
- return this;
- }
-
- @Override
- public PortPairGroup build() {
-
- checkNotNull(portPairGroupId, "Port pair group id cannot be null");
- checkNotNull(tenantId, "Tenant id cannot be null");
- checkNotNull(portPairList, "Port pairs cannot be null");
-
- return new DefaultPortPairGroup(portPairGroupId, tenantId, name, description,
- portPairList);
- }
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultRouter.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultRouter.java
deleted file mode 100644
index fc8bbe5..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultRouter.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.List;
-import java.util.Objects;
-
-/**
- * Default implementation of router interface.
- */
-public final class DefaultRouter implements Router {
- private final RouterId id;
- private final String name;
- private final boolean adminStateUp;
- private final Status status;
- private final boolean distributed;
- private final RouterGateway externalGatewayInfo;
- private final VirtualPortId gatewayPortId;
- private final TenantId tenantId;
- private final List<String> routes;
-
- /**
- * Creates router object.
- *
- * @param id router identifier
- * @param routerName the name of router
- * @param adminStateUp the status of admin state
- * @param status the status of router
- * @param distributed the status of router distributed
- * @param externalGatewayInfo the gateway info of router
- * @param gatewayPortId the port identifier of router gateway
- * @param tenantId the tenant identifier
- * @param routes the routes configure
- */
- public DefaultRouter(RouterId id, String routerName, boolean adminStateUp,
- Status status, boolean distributed,
- RouterGateway externalGatewayInfo,
- VirtualPortId gatewayPortId, TenantId tenantId,
- List<String> routes) {
- this.id = checkNotNull(id, "id cannot be null");
- this.name = routerName;
- this.adminStateUp = adminStateUp;
- this.status = checkNotNull(status, "status cannot be null");
- this.distributed = distributed;
- this.externalGatewayInfo = externalGatewayInfo;
- this.gatewayPortId = gatewayPortId;
- this.tenantId = checkNotNull(tenantId, "tenantId cannot be null");
- this.routes = routes;
- }
-
- @Override
- public RouterId id() {
- return id;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public boolean adminStateUp() {
- return adminStateUp;
- }
-
- @Override
- public Status status() {
- return status;
- }
-
- @Override
- public boolean distributed() {
- return distributed;
- }
-
- @Override
- public RouterGateway externalGatewayInfo() {
- return externalGatewayInfo;
- }
-
- @Override
- public VirtualPortId gatewayPortid() {
- return gatewayPortId;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public List<String> routes() {
- return routes;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, name, adminStateUp, status, distributed,
- externalGatewayInfo, gatewayPortId, routes);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultRouter) {
- final DefaultRouter that = (DefaultRouter) obj;
- return Objects.equals(this.id, that.id)
- && Objects.equals(this.name, that.name)
- && Objects.equals(this.adminStateUp, that.adminStateUp)
- && Objects.equals(this.status, that.status)
- && Objects.equals(this.distributed, that.distributed)
- && Objects.equals(this.externalGatewayInfo,
- that.externalGatewayInfo)
- && Objects.equals(this.gatewayPortId, that.gatewayPortId)
- && Objects.equals(this.routes, that.routes);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("id", id).add("routerName", name)
- .add("adminStateUp", adminStateUp).add("status", status)
- .add("distributed", distributed)
- .add("externalGatewayInfo", externalGatewayInfo)
- .add("gatewayPortid", gatewayPortId).add("routes", routes).toString();
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java
deleted file mode 100644
index dc0af7e..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-import java.util.Objects;
-import java.util.Set;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-
-/**
- * Default implementation of Subnet interface .
- */
-public final class DefaultSubnet implements Subnet {
- private final SubnetId id;
- private final String subnetName;
- private final TenantNetworkId networkId;
- private final TenantId tenantId;
- private final Version ipVersion;
- private final IpPrefix cidr;
- private final IpAddress gatewayIp;
- private final boolean dhcpEnabled;
- private final boolean shared;
- private final Mode ipV6AddressMode;
- private final Mode ipV6RaMode;
- private final Set<HostRoute> hostRoutes;
- private final Set<AllocationPool> allocationPools;
-
- /**
- * Creates a subnet object.
- *
- * @param id subnet identifier
- * @param subnetName the name of subnet
- * @param networkId network identifier
- * @param tenantId tenant identifier
- * @param ipVersion Version of ipv4 or ipv6
- * @param cidr the cidr
- * @param gatewayIp gateway ip
- * @param dhcpEnabled dhcp enabled or not
- * @param shared indicates whether this network is shared across all
- * tenants, By default, only administrative user can change this
- * value
- * @param hostRoutes a collection of host routes
- * @param ipV6AddressMode ipV6AddressMode
- * @param ipV6RaMode ipV6RaMode
- * @param allocationPoolsIt a collection of allocationPools
- */
- public DefaultSubnet(SubnetId id, String subnetName,
- TenantNetworkId networkId, TenantId tenantId,
- Version ipVersion, IpPrefix cidr, IpAddress gatewayIp,
- boolean dhcpEnabled, boolean shared,
- Set<HostRoute> hostRoutes, Mode ipV6AddressMode,
- Mode ipV6RaMode,
- Set<AllocationPool> allocationPoolsIt) {
- this.id = id;
- this.subnetName = subnetName;
- this.networkId = networkId;
- this.tenantId = tenantId;
- this.ipVersion = ipVersion;
- this.cidr = cidr;
- this.gatewayIp = gatewayIp;
- this.dhcpEnabled = dhcpEnabled;
- this.shared = shared;
- this.ipV6AddressMode = ipV6AddressMode;
- this.ipV6RaMode = ipV6RaMode;
- this.hostRoutes = hostRoutes;
- this.allocationPools = allocationPoolsIt;
- }
-
- @Override
- public SubnetId id() {
- return id;
- }
-
- @Override
- public String subnetName() {
- return subnetName;
- }
-
- @Override
- public TenantNetworkId networkId() {
- return networkId;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public Version ipVersion() {
- return ipVersion;
- }
-
- @Override
- public IpPrefix cidr() {
- return cidr;
- }
-
- @Override
- public IpAddress gatewayIp() {
- return gatewayIp;
- }
-
- @Override
- public boolean dhcpEnabled() {
- return dhcpEnabled;
- }
-
- @Override
- public boolean shared() {
- return shared;
- }
-
- @Override
- public Iterable<HostRoute> hostRoutes() {
- return hostRoutes;
- }
-
- @Override
- public Mode ipV6AddressMode() {
- return ipV6AddressMode;
- }
-
- @Override
- public Mode ipV6RaMode() {
- return ipV6RaMode;
- }
-
- @Override
- public Iterable<AllocationPool> allocationPools() {
- return allocationPools;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, subnetName, ipVersion, cidr, gatewayIp,
- dhcpEnabled, shared, tenantId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultSubnet) {
- final DefaultSubnet that = (DefaultSubnet) obj;
- return Objects.equals(this.id, that.id)
- && Objects.equals(this.subnetName, that.subnetName)
- && Objects.equals(this.ipVersion, that.ipVersion)
- && Objects.equals(this.cidr, that.cidr)
- && Objects.equals(this.shared, that.shared)
- && Objects.equals(this.gatewayIp, that.gatewayIp)
- && Objects.equals(this.dhcpEnabled, that.dhcpEnabled);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("id", id).add("subnetName", subnetName)
- .add("ipVersion", ipVersion).add("cidr", cidr)
- .add("shared", shared).add("gatewayIp", gatewayIp)
- .add("dhcpEnabled", dhcpEnabled).toString();
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java
deleted file mode 100644
index 8271cd8..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-import java.util.Objects;
-
-/**
- * Default implementation of TenantNetwork interface.
- */
-public final class DefaultTenantNetwork implements TenantNetwork {
- private final TenantNetworkId id;
- private final String name;
- private final boolean adminStateUp;
- private final State state;
- private final boolean shared;
- private final Type type;
- private final TenantId tenantId;
- private final boolean routerExternal;
- private final PhysicalNetwork physicalNetwork;
- private final SegmentationId segmentationId;
-
- /**
- * Creates a neutronNetwork element attributed to the specified provider.
- *
- * @param id network identifier
- * @param name the network name
- * @param adminStateUp administrative state of the network
- * @param state the network state
- * @param shared indicates whether this network is shared across all
- * tenants, By default, only administrative user can change this
- * value
- * @param tenantId tenant identifier
- * @param routerExternal network routerExternal
- * @param type the network type
- * @param physicalNetwork physicalNetwork identifier
- * @param segmentationId segmentation identifier
- */
- public DefaultTenantNetwork(TenantNetworkId id, String name,
- boolean adminStateUp, State state,
- boolean shared, TenantId tenantId,
- boolean routerExternal, Type type,
- PhysicalNetwork physicalNetwork,
- SegmentationId segmentationId) {
- this.id = id;
- this.name = name;
- this.adminStateUp = adminStateUp;
- this.state = state;
- this.shared = shared;
- this.type = type;
- this.tenantId = tenantId;
- this.routerExternal = routerExternal;
- this.physicalNetwork = physicalNetwork;
- this.segmentationId = segmentationId;
- }
-
- @Override
- public TenantNetworkId id() {
- return id;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public boolean adminStateUp() {
- return adminStateUp;
- }
-
- @Override
- public State state() {
- return state;
- }
-
- @Override
- public boolean shared() {
- return shared;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public boolean routerExternal() {
- return routerExternal;
- }
-
- @Override
- public Type type() {
- return type;
- }
-
- @Override
- public PhysicalNetwork physicalNetwork() {
- return physicalNetwork;
- }
-
- @Override
- public SegmentationId segmentationId() {
- return segmentationId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, name, adminStateUp, state, shared, tenantId,
- routerExternal, type, physicalNetwork,
- segmentationId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultTenantNetwork) {
- final DefaultTenantNetwork that = (DefaultTenantNetwork) obj;
- return Objects.equals(this.id, that.id)
- && Objects.equals(this.name, that.name)
- && Objects.equals(this.adminStateUp, that.adminStateUp)
- && Objects.equals(this.state, that.state)
- && Objects.equals(this.shared, that.shared)
- && Objects.equals(this.tenantId, that.tenantId)
- && Objects.equals(this.routerExternal, that.routerExternal)
- && Objects.equals(this.type, that.type)
- && Objects.equals(this.physicalNetwork,
- that.physicalNetwork)
- && Objects.equals(this.segmentationId, that.segmentationId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("id", id).add("name", name)
- .add("adminStateUp", adminStateUp).add("state", state)
- .add("shared", shared).add("tenantId", tenantId)
- .add("routeExternal", routerExternal).add("type", type)
- .add("physicalNetwork", physicalNetwork)
- .add("segmentationId", segmentationId).toString();
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java
deleted file mode 100644
index a034f3d..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-
-/**
- * Default implementation of VirtualPort interface .
- */
-public final class DefaultVirtualPort implements VirtualPort {
- private final VirtualPortId id;
- private final TenantNetworkId networkId;
- private final Boolean adminStateUp;
- private final String name;
- private final State state;
- private final MacAddress macAddress;
- private final TenantId tenantId;
- private final String deviceOwner;
- private final DeviceId deviceId;
- private final Set<FixedIp> fixedIps;
- private final BindingHostId bindingHostId;
- private final String bindingVnicType;
- private final String bindingVifType;
- private final String bindingVifDetails;
- private final Set<AllowedAddressPair> allowedAddressPairs;
- private final Set<SecurityGroup> securityGroups;
-
- /**
- * Creates a VirtualPort object.
- *
- * @param id the virtual port identifier
- * @param networkId the network identifier
- * @param adminStateUp adminStateup true or false
- * @param strMap the map of properties of virtual port
- * @param state virtual port state
- * @param macAddress the MAC address
- * @param tenantId the tenant identifier
- * @param deviceId the device identifier
- * @param fixedIps set of fixed IP
- * @param bindingHostId the binding host identifier
- * @param allowedAddressPairs the collection of allowdeAddressPairs
- * @param securityGroups the collection of securityGroups
- */
- public DefaultVirtualPort(VirtualPortId id,
- TenantNetworkId networkId,
- Boolean adminStateUp,
- Map<String, String> strMap,
- State state,
- MacAddress macAddress,
- TenantId tenantId,
- DeviceId deviceId,
- Set<FixedIp> fixedIps,
- BindingHostId bindingHostId,
- Set<AllowedAddressPair> allowedAddressPairs,
- Set<SecurityGroup> securityGroups) {
- this.id = id;
- this.networkId = networkId;
- this.adminStateUp = adminStateUp;
- this.name = strMap.get("name");
- this.state = state;
- this.macAddress = macAddress;
- this.tenantId = tenantId;
- this.deviceOwner = strMap.get("deviceOwner");
- this.deviceId = deviceId;
- this.fixedIps = fixedIps;
- this.bindingHostId = bindingHostId;
- this.bindingVnicType = strMap.get("bindingVnicType");
- this.bindingVifType = strMap.get("bindingVifType");
- this.bindingVifDetails = strMap.get("bindingVifDetails");
- this.allowedAddressPairs = allowedAddressPairs;
- this.securityGroups = securityGroups;
- }
-
- @Override
- public VirtualPortId portId() {
- return id;
- }
-
- @Override
- public TenantNetworkId networkId() {
- return networkId;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public boolean adminStateUp() {
- return adminStateUp;
- }
-
- @Override
- public State state() {
- return state;
- }
-
- @Override
- public MacAddress macAddress() {
- return macAddress;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public DeviceId deviceId() {
- return deviceId;
- }
-
- @Override
- public String deviceOwner() {
- return deviceOwner;
- }
-
- @Override
- public Collection<AllowedAddressPair> allowedAddressPairs() {
- return allowedAddressPairs;
- }
-
- @Override
- public Set<FixedIp> fixedIps() {
- return fixedIps;
- }
-
- @Override
- public BindingHostId bindingHostId() {
- return bindingHostId;
- }
-
- @Override
- public String bindingVnicType() {
- return bindingVifType;
- }
-
- @Override
- public String bindingVifType() {
- return bindingVifType;
- }
-
- @Override
- public String bindingVifDetails() {
- return bindingVifDetails;
- }
-
- @Override
- public Collection<SecurityGroup> securityGroups() {
- return securityGroups;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, networkId, adminStateUp, name, state,
- macAddress, tenantId, deviceId, deviceOwner,
- allowedAddressPairs, fixedIps, bindingHostId,
- bindingVnicType, bindingVifType, bindingVifDetails,
- securityGroups);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultVirtualPort) {
- final DefaultVirtualPort that = (DefaultVirtualPort) obj;
- return Objects.equals(this.id, that.id)
- && Objects.equals(this.networkId, that.networkId)
- && Objects.equals(this.adminStateUp, that.adminStateUp)
- && Objects.equals(this.state, that.state)
- && Objects.equals(this.name, that.name)
- && Objects.equals(this.tenantId, that.tenantId)
- && Objects.equals(this.macAddress, that.macAddress)
- && Objects.equals(this.deviceId, that.deviceId)
- && Objects.equals(this.deviceOwner, that.deviceOwner)
- && Objects.equals(this.allowedAddressPairs,
- that.allowedAddressPairs)
- && Objects.equals(this.fixedIps, that.fixedIps)
- && Objects.equals(this.bindingHostId, that.bindingHostId)
- && Objects.equals(this.bindingVifDetails,
- that.bindingVifDetails)
- && Objects.equals(this.bindingVifType, that.bindingVifType)
- && Objects.equals(this.bindingVnicType,
- that.bindingVnicType)
- && Objects.equals(this.securityGroups, that.securityGroups);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("id", id).add("network_id", networkId)
- .add("adminStateUp", adminStateUp).add("state", state)
- .add("name", name).add("state", state)
- .add("macAddress", macAddress).add("tenantId", tenantId)
- .add("deviced", deviceId).add("deviceOwner", deviceOwner)
- .add("allowedAddressPairs", allowedAddressPairs)
- .add("fixedIp", fixedIps).add("bindingHostId", bindingHostId)
- .add("bindingVnicType", bindingVnicType)
- .add("bindingVifDetails", bindingVifDetails)
- .add("bindingVifType", bindingVifType)
- .add("securityGroups", securityGroups).toString();
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FiveTuple.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FiveTuple.java
deleted file mode 100644
index 10d47fa..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FiveTuple.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.PortNumber;
-
-/**
- * Abstraction of an entity to provide five tuple information from packet.
- * Five tuple means source ip address, destination ip address, source port number,
- * destination port number and protocol of the packet.
- */
-public interface FiveTuple {
-
- /**
- * Returns the protocol value.
- *
- * @return protocol value IPv4.PROTOCOL_TCP(0x06), IPv4.PROTOCOL_UDP(0x11), IPv4.PROTOCOL_ICMP(0x01)
- */
- byte protocol();
-
- /**
- * Returns source ip address.
- *
- * @return ipSrc
- */
- IpAddress ipSrc();
-
- /**
- * Returns destination ip address.
- *
- * @return ipDst
- */
- IpAddress ipDst();
-
- /**
- * Returns source port.
- *
- * @return portSrc
- */
- PortNumber portSrc();
-
- /**
- * Returns destination port.
- *
- * @return portDst
- */
- PortNumber portDst();
-
- /**
- * Returns source mac.
- *
- * @return srcMac
- */
- MacAddress macSrc();
-
- /**
- * Returns destination mac.
- *
- * @return dstMac
- */
- MacAddress macDst();
-
- /**
- * Returns the tenant id.
- *
- * @return tenantId
- */
- TenantId tenantId();
-
- /**
- * Builder class for Five tuple info.
- */
- interface Builder {
-
- /**
- * Assign the source ip address to this object.
- *
- * @param ipSrc source ip address
- * @return this the builder object
- */
- Builder setIpSrc(IpAddress ipSrc);
-
- /**
- * Assign the destination ip address to this object.
- *
- * @param ipDst destination ip address
- * @return this the builder object
- */
- Builder setIpDst(IpAddress ipDst);
-
- /**
- * Assign the source port to this object.
- *
- * @param portSrc source port
- * @return this the builder object
- */
- Builder setPortSrc(PortNumber portSrc);
-
- /**
- * Assign the destination port to this object.
- *
- * @param portDst destination port
- * @return this the builder object
- */
- Builder setPortDst(PortNumber portDst);
-
- /**
- * Assign the source mac address to this object.
- *
- * @param macSrc source mac address
- * @return this the builder object
- */
- Builder setMacSrc(MacAddress macSrc);
-
- /**
- * Assign the destination mac address to this object.
- *
- * @param macDst destination mac address
- * @return this the builder object
- */
- Builder setMacDst(MacAddress macDst);
-
- /**
- * Assign the protocol to this object.
- *
- * @param protocol packet protocol
- * @return this the builder object
- */
- Builder setProtocol(byte protocol);
-
- /**
- * Assign the tenant id to this object.
- *
- * @param tenantId tenant id
- * @return this the builder object
- */
- Builder setTenantId(TenantId tenantId);
-
- /**
- * Builds a FiveTuple object.
- *
- * @return instance of FiveTuple
- */
- FiveTuple build();
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java
deleted file mode 100644
index 081e9eb..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-
-/**
- * Immutable representation of a IP address for the port, Include the IP address
- * and subnet identity.
- */
-public final class FixedIp {
- private final SubnetId subnetId;
- private final IpAddress ip;
- // Public construction is prohibited
- private FixedIp(SubnetId subnetId, IpAddress ip) {
- checkNotNull(subnetId, "SubnetId cannot be null");
- checkNotNull(ip, "IpAddress cannot be null");
- this.subnetId = subnetId;
- this.ip = ip;
- }
-
- /**
- * Returns the FixedIp subnet identifier.
- *
- * @return subnet identifier
- */
- public SubnetId subnetId() {
- return subnetId;
- }
-
- /**
- * Returns the FixedIp IP address.
- *
- * @return IP address
- */
- public IpAddress ip() {
- return ip;
- }
-
- /**
- * Creates a fixed ip using the supplied fixedIp.
- *
- * @param subnetId subnet identity
- * @param ip IP address
- * @return FixedIp
- */
- public static FixedIp fixedIp(SubnetId subnetId, IpAddress ip) {
- return new FixedIp(subnetId, ip);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(subnetId, ip);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof FixedIp) {
- final FixedIp that = (FixedIp) obj;
- return Objects.equals(this.subnetId, that.subnetId)
- && Objects.equals(this.ip, that.ip);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("subnetId", subnetId).add("ip", ip)
- .toString();
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FloatingIp.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FloatingIp.java
deleted file mode 100644
index dc38735..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FloatingIp.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.packet.IpAddress;
-
-/**
- * Representation of a floatingIp.
- */
-public interface FloatingIp {
-
- /**
- * Coarse classification of the type of the FloatingIp.
- */
- public enum Status {
- /**
- * Signifies that a floating Ip is currently active.
- */
- ACTIVE,
- /**
- * Signifies that a floating Ip is currently inactive.
- */
- INACTIVE
- }
-
- /**
- * Returns the floatingIp identifier.
- *
- * @return identifier
- */
- FloatingIpId id();
-
- /**
- * Returns the tenant identifier.
- *
- * @return the tenant identifier
- */
- TenantId tenantId();
-
- /**
- * Returns the network identifier.
- *
- * @return the network identifier
- */
- TenantNetworkId networkId();
-
- /**
- * Returns the port identifier.
- *
- * @return the port identifier
- */
- VirtualPortId portId();
-
- /**
- * Returns the router identifier.
- *
- * @return the router identifier
- */
- RouterId routerId();
-
- /**
- * Returns the floating ip address.
- *
- * @return floatingIp
- */
- IpAddress floatingIp();
-
- /**
- * Returns the fixed ip address.
- *
- * @return fixedIp
- */
- IpAddress fixedIp();
-
- /**
- * Returns the status of floating ip.
- *
- * @return floatingIpStatus
- */
- Status status();
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FloatingIpId.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FloatingIpId.java
deleted file mode 100644
index 6258df9..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FloatingIpId.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.util.Identifier;
-
-import java.util.UUID;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a floating IP identifier.
- */
-public final class FloatingIpId extends Identifier<UUID> {
- // Public construction is prohibited
- private FloatingIpId(UUID floatingIpId) {
- super(checkNotNull(floatingIpId, "floatingIpId cannot be null"));
- }
-
- /**
- * Creates a floating IP identifier.
- *
- * @param floatingIpId the UUID id of floating IP identifier
- * @return object of floating IP identifier
- */
- public static FloatingIpId of(UUID floatingIpId) {
- return new FloatingIpId(floatingIpId);
- }
-
- /**
- * Creates a floating IP identifier.
- *
- * @param floatingIpId the floating IP identifier in string
- * @return object of floating IP identifier
- */
- public static FloatingIpId of(String floatingIpId) {
- return new FloatingIpId(UUID.fromString(floatingIpId));
- }
-
- /**
- * Returns the floating IP identifier.
- *
- * @return the floating IP identifier
- */
- public UUID floatingIpId() {
- return identifier;
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifier.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifier.java
deleted file mode 100644
index f7a9bcc..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifier.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.packet.IpPrefix;
-
-/**
- * Abstraction of an entity which provides flow classifier for service function chain.
- * FlowClassifier classify the traffic based on the criteria defined in the request.
- * The classification can be based on port range or source and destination IP address or
- * other flow classifier elements.
- */
-public interface FlowClassifier {
-
- /**
- * Returns flow classifier ID.
- *
- * @return flow classifier id
- */
- FlowClassifierId flowClassifierId();
-
- /**
- * Returns Tenant ID.
- *
- * @return tenant Id
- */
- TenantId tenantId();
-
- /**
- * Returns flow classifier name.
- *
- * @return flow classifier name
- */
- String name();
-
- /**
- * Returns flow classifier description.
- *
- * @return flow classifier description
- */
- String description();
-
- /**
- * Returns EtherType.
- *
- * @return EtherType
- */
- String etherType();
-
- /**
- * Returns IP Protocol.
- *
- * @return IP protocol
- */
- String protocol();
-
- /**
- * Returns priority.
- *
- * @return priority
- */
- int priority();
-
- /**
- * Returns minimum source port range.
- *
- * @return minimum source port range
- */
- int minSrcPortRange();
-
- /**
- * Returns maximum source port range.
- *
- * @return maximum source port range
- */
- int maxSrcPortRange();
-
- /**
- * Returns minimum destination port range.
- *
- * @return minimum destination port range
- */
- int minDstPortRange();
-
- /**
- * Returns maximum destination port range.
- *
- * @return maximum destination port range.
- */
- int maxDstPortRange();
-
- /**
- * Returns Source IP prefix.
- *
- * @return Source IP prefix
- */
- IpPrefix srcIpPrefix();
-
- /**
- * Returns Destination IP prefix.
- *
- * @return Destination IP prefix
- */
- IpPrefix dstIpPrefix();
-
- /**
- * Returns Source virtual port.
- *
- * @return Source virtual port
- */
- VirtualPortId srcPort();
-
- /**
- * Returns Destination virtual port.
- *
- * @return Destination virtual port
- */
- VirtualPortId dstPort();
-
- /**
- * Returns whether this Flow classifier is an exact match to the
- * Flow classifier given in the argument.
- *
- * @param flowClassifier other flowClassifier to match against
- * @return true if the flowClassifiers are an exact match, otherwise false
- */
- boolean exactMatch(FlowClassifier flowClassifier);
-
- /**
- * Builder for flow Classifier.
- */
- interface Builder {
-
- /**
- * Returns Flow Classifier.
- *
- * @return flow classifier.
- */
- FlowClassifier build();
-
- /**
- * Sets Flow Classifier ID.
- *
- * @param flowClassifierId flow classifier id.
- * @return Builder object by setting flow classifier Id.
- */
- Builder setFlowClassifierId(FlowClassifierId flowClassifierId);
-
- /**
- * Sets Tenant ID.
- *
- * @param tenantId tenant id.
- * @return Builder object by setting Tenant ID.
- */
- Builder setTenantId(TenantId tenantId);
-
- /**
- * Sets Flow classifier name.
- *
- * @param name flow classifier name
- * @return builder object by setting flow classifier name
- */
- Builder setName(String name);
-
- /**
- * Sets flow classifier description.
- *
- * @param description flow classifier description
- * @return flow classifier description
- */
- Builder setDescription(String description);
-
- /**
- * Sets EtherType.
- *
- * @param etherType EtherType
- * @return EtherType
- */
- Builder setEtherType(String etherType);
-
- /**
- * Sets IP protocol.
- *
- * @param protocol IP protocol
- * @return builder object by setting IP protocol
- */
- Builder setProtocol(String protocol);
-
- /**
- * Sets priority.
- *
- * @param priority priority
- * @return builder object by setting priority
- */
- Builder setPriority(int priority);
-
- /**
- * Set minimum source port range.
- *
- * @param minRange minimum source port range
- * @return builder object by setting minimum source port range
- */
- Builder setMinSrcPortRange(int minRange);
-
- /**
- * Sets maximum source port range.
- *
- * @param maxRange maximum source port range
- * @return builder object by setting maximum source port range
- */
- Builder setMaxSrcPortRange(int maxRange);
-
- /**
- * Sets minimum destination port range.
- *
- * @param minRange minimum destination port range
- * @return builder object by setting minimum destination port range
- */
- Builder setMinDstPortRange(int minRange);
-
- /**
- * Sets maximum destination port range.
- *
- * @param maxRange maximum destination port range.
- * @return builder object by setting maximum destination port range.
- */
- Builder setMaxDstPortRange(int maxRange);
-
- /**
- * Sets Source IP prefix.
- *
- * @param srcIpPrefix Source IP prefix
- * @return builder object by setting Source IP prefix
- */
- Builder setSrcIpPrefix(IpPrefix srcIpPrefix);
-
- /**
- * Sets Destination IP prefix.
- *
- * @param dstIpPrefix Destination IP prefix
- * @return builder object by setting Destination IP prefix
- */
- Builder setDstIpPrefix(IpPrefix dstIpPrefix);
-
- /**
- * Sets Source virtual port.
- *
- * @param srcPort Source virtual port
- * @return builder object by setting Source virtual port
- */
- Builder setSrcPort(VirtualPortId srcPort);
-
- /**
- * Sets Destination virtual port.
- *
- * @param dstPort Destination virtual port
- * @return builder object by setting Destination virtual port
- */
- Builder setDstPort(VirtualPortId dstPort);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifierId.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifierId.java
deleted file mode 100644
index 2c74d9e..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifierId.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.util.Identifier;
-
-import java.util.UUID;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Flow classification identifier.
- */
-public final class FlowClassifierId extends Identifier<UUID> {
- /**
- * Constructor to create flow classifier id.
- *
- * @param flowClassifierId flow classifier id.
- */
- private FlowClassifierId(final UUID flowClassifierId) {
- super(checkNotNull(flowClassifierId, "Flow classifier id can not be null"));
- }
-
- /**
- * Returns new flow classifier id.
- *
- * @param flowClassifierId flow classifier id
- * @return new flow classifier id
- */
- public static FlowClassifierId of(final UUID flowClassifierId) {
- return new FlowClassifierId(flowClassifierId);
- }
-
- /**
- * Returns new flow classifier id.
- *
- * @param flowClassifierId flow classifier id
- * @return new flow classifier id
- */
- public static FlowClassifierId of(final String flowClassifierId) {
- return new FlowClassifierId(UUID.fromString(flowClassifierId));
- }
-
- /**
- * Returns the value of flow classifier id.
- *
- * @return flow classifier id.
- */
- public UUID value() {
- return identifier;
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java
deleted file mode 100644
index 3f6824d..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-
-/**
- * Host route dictionaries for the subnet.
- */
-public interface HostRoute {
-
- /**
- * Returns the next hop address.
- *
- * @return next hop address
- */
- IpAddress nexthop();
-
- /**
- * Returns the destination address.
- *
- * @return destination address
- */
- IpPrefix destination();
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/LoadBalanceId.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/LoadBalanceId.java
deleted file mode 100644
index ffd3168..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/LoadBalanceId.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-/*
- * Representation of 5 bit load balance identifier for a service function
- */
-public final class LoadBalanceId extends Identifier<Byte> {
-
- private static final byte MAX_ID = 0x1F;
-
- /**
- * Default constructor.
- *
- * @param loadBalanceId service function chain path's load balance identifier
- */
- private LoadBalanceId(byte loadBalanceId) {
- super(loadBalanceId);
- checkArgument(loadBalanceId <= MAX_ID, "Load balance id should not be more than 5 bit identifier");
- }
-
- /**
- * Returns the SfcLoadBalanceId by setting its value.
- *
- * @param loadBalanceId service function chain path's load balance identifier
- * @return LoadBalanceId
- */
- public static LoadBalanceId of(byte loadBalanceId) {
- return new LoadBalanceId(loadBalanceId);
- }
-
-
- /**
- * Returns load balance identifier for a service function.
- *
- * @return loadBalanceId
- */
- public byte loadBalanceId() {
- return identifier;
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java
deleted file mode 100644
index d2d9a0c..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a physical network identity.
- */
-public final class PhysicalNetwork {
-
- private final String physicalNetwork;
-
- // Public construction is prohibited
- private PhysicalNetwork(String physicalNetwork) {
- checkNotNull(physicalNetwork, "PhysicalNetwork cannot be null");
- this.physicalNetwork = physicalNetwork;
- }
-
- /**
- * Creates a PhysicalNetwork object.
- *
- * @param physicalNetwork physical network
- * @return physical network
- */
- public static PhysicalNetwork physicalNetwork(String physicalNetwork) {
- return new PhysicalNetwork(physicalNetwork);
- }
-
- /**
- * Returns a physicalNetwork.
- *
- * @return physical network
- */
- public String physicalNetwork() {
- return physicalNetwork;
- }
-
- @Override
- public int hashCode() {
- return physicalNetwork.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof PhysicalNetwork) {
- final PhysicalNetwork that = (PhysicalNetwork) obj;
- return this.getClass() == that.getClass()
- && Objects.equals(this.physicalNetwork,
- that.physicalNetwork);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return physicalNetwork;
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChain.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChain.java
deleted file mode 100644
index e276f43..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChain.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import java.util.List;
-import java.util.Set;
-
-import org.onosproject.net.DeviceId;
-
-/**
- * Abstraction of an entity providing Port Chain information.
- * A Port Chain (Service Function Path) consists of
- * a set of Neutron ports, to define the sequence of service functions
- * a set of flow classifiers, to specify the classified traffic flows to enter the chain
- */
-public interface PortChain {
-
- /**
- * Returns the ID of this port chain.
- *
- * @return the port chain id
- */
- PortChainId portChainId();
-
- /**
- * Returns the tenant id of this port chain.
- *
- * @return the tenant id
- */
- TenantId tenantId();
-
- /**
- * Returns the name of this port chain.
- *
- * @return name of port chain
- */
- String name();
-
- /**
- * Returns the description of this port chain.
- *
- * @return description of port chain
- */
- String description();
-
- /**
- * Returns the list of port pair groups associated with
- * this port chain.
- *
- * @return list of port pair groups
- */
- List<PortPairGroupId> portPairGroups();
-
- /**
- * Returns the list of flow classifiers associated with
- * this port chain.
- *
- * @return list of flow classifiers
- */
- List<FlowClassifierId> flowClassifiers();
-
- /**
- * Returns the old port chain.
- *
- * @return old port chain
- */
- PortChain oldPortChain();
-
- /**
- * Adds a new load balanced path.
- *
- * @param fiveTuple five tuple from the packet
- * @param id load balance path identifier
- * @param path load balanced path of list of port pairs
- */
- void addLoadBalancePath(FiveTuple fiveTuple, LoadBalanceId id,
- List<PortPairId> path);
-
- /**
- * Adds sfc classifiers to the given load balance id for a port chain.
- *
- * @param id load balance path identifier
- * @param classifierList list of classifier devices
- */
- void addSfcClassifiers(LoadBalanceId id, List<DeviceId> classifierList);
-
- /**
- * Adds sfc forwarders to the given load balance id for a port chain.
- *
- * @param id load balance path identifier
- * @param forwarderList list of forwarder devices
- */
- void addSfcForwarders(LoadBalanceId id, List<DeviceId> forwarderList);
-
- /**
- * Removes sfc classifiers to the given load balance id for a port chain.
- *
- * @param id load balance path identifier
- * @param classifierList list of classifier devices
- */
- void removeSfcClassifiers(LoadBalanceId id, List<DeviceId> classifierList);
-
- /**
- * Removes sfc forwarders to the given load balance id for a port chain.
- *
- * @param id load balance path identifier
- * @param forwarderList list of forwarder devices
- */
- void removeSfcForwarders(LoadBalanceId id, List<DeviceId> forwarderList);
-
- /**
- * Returns sfc classifiers to the given load balance id for a port chain.
- *
- * @param id load balance path identifier
- * @return list of classifier devices
- */
- List<DeviceId> getSfcClassifiers(LoadBalanceId id);
-
- /**
- * Returns sfc forwarders to the given load balance id for a port chain.
- *
- * @param id load balance path identifier
- * @return list of forwarder devices
- */
- List<DeviceId> getSfcForwarders(LoadBalanceId id);
-
- /**
- * Returns the load balance id from five tuple.
- *
- * @param fiveTuple five tuple from the packet
- * @return load balance identifier for the given packet
- */
- LoadBalanceId getLoadBalanceId(FiveTuple fiveTuple);
-
- /**
- * Returns the keys set from load balance id map.
- *
- * @return set of five tuple info
- */
- Set<FiveTuple> getLoadBalanceIdMapKeys();
-
- /**
- * Returns the keys set from load balance path map.
- *
- * @return set of load balance id's
- */
- Set<LoadBalanceId> getLoadBalancePathMapKeys();
-
- /**
- * Returns the load balanced path from load balance Id.
- *
- * @param id load balance id.
- * @return path containing list of port pairs
- */
- List<PortPairId> getLoadBalancePath(LoadBalanceId id);
-
- /**
- * Returns the load balanced path from five tuple.
- *
- * @param fiveTuple five tuple from the packet
- * @return path containing list of port pairs
- */
- List<PortPairId> getLoadBalancePath(FiveTuple fiveTuple);
-
- /**
- * Returns the no of load balance paths created.
- *
- * @return size of load balanced paths
- */
- int getLoadBalancePathSize();
-
- /**
- * Match the given path with existing load balanced paths.
- *
- * @param path load balanced path
- * @return load balance id if the path matches, null otherwise.
- */
- LoadBalanceId matchPath(List<PortPairId> path);
-
- /**
- * Returns whether this port chain is an exact match to the port chain given
- * in the argument.
- * <p>
- * Exact match means the port pair groups and flow classifiers match
- * with the given port chain. It does not consider the port chain id, name
- * and description.
- * </p>
- *
- * @param portChain other port chain to match against
- * @return true if the port chains are an exact match, otherwise false
- */
- boolean exactMatch(PortChain portChain);
-
- /**
- * A port chain builder..
- */
- interface Builder {
-
- /**
- * Assigns the port chain id to this object.
- *
- * @param portChainId the port chain id
- * @return this the builder object
- */
- Builder setId(PortChainId portChainId);
-
- /**
- * Assigns tenant id to this object.
- *
- * @param tenantId tenant id of the port chain
- * @return this the builder object
- */
- Builder setTenantId(TenantId tenantId);
-
- /**
- * Assigns the name to this object.
- *
- * @param name name of the port chain
- * @return this the builder object
- */
- Builder setName(String name);
-
- /**
- * Assigns the description to this object.
- *
- * @param description description of the port chain
- * @return this the builder object
- */
- Builder setDescription(String description);
-
- /**
- * Assigns the port pair groups associated with the port chain
- * to this object.
- *
- * @param portPairGroups list of port pair groups
- * @return this the builder object
- */
- Builder setPortPairGroups(List<PortPairGroupId> portPairGroups);
-
- /**
- * Assigns the flow classifiers associated with the port chain
- * to this object.
- *
- * @param flowClassifiers list of flow classifiers
- * @return this the builder object
- */
- Builder setFlowClassifiers(List<FlowClassifierId> flowClassifiers);
-
- /**
- * Builds a port chain object.
- *
- * @return a port chain.
- */
- PortChain build();
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java
deleted file mode 100644
index 34c2afa..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.util.Identifier;
-
-import java.util.UUID;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Representation of a Port Chain ID.
- */
-public final class PortChainId extends Identifier<UUID> {
- /**
- * Private constructor for port chain id.
- *
- * @param id UUID id of port chain
- */
- private PortChainId(UUID id) {
- super(checkNotNull(id, "Port chain id can not be null"));
- }
-
- /**
- * Returns newly created port chain id object.
- *
- * @param id UUID of port chain
- * @return object of port chain id
- */
- public static PortChainId of(UUID id) {
- return new PortChainId(id);
- }
-
- /**
- * Returns newly created port chain id object.
- *
- * @param id port chain id in string
- * @return object of port chain id
- */
- public static PortChainId of(String id) {
- return new PortChainId(UUID.fromString(id));
- }
-
- /**
- * Returns the value of port chain id.
- *
- * @return port chain id
- */
- public UUID value() {
- return identifier;
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPair.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPair.java
deleted file mode 100644
index 520c213..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPair.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-
-/**
- * Abstraction of an entity providing Port Pair information.
- * A port pair represents a service function instance.
- */
-public interface PortPair {
-
- /**
- * Returns the ID of this port Pair.
- *
- * @return the port pair id
- */
- PortPairId portPairId();
-
- /**
- * Returns the tenant id of this port pair.
- *
- * @return an tenant id
- */
- TenantId tenantId();
-
- /**
- * Returns the description of this port pair.
- *
- * @return description of port pair
- */
- String name();
-
- /**
- * Returns the description of this port pair.
- *
- * @return description of port pair
- */
- String description();
-
- /**
- * Returns the ingress port of this port pair.
- *
- * @return ingress of port pair
- */
- String ingress();
-
- /**
- * Returns the egress port of this port pair.
- *
- * @return egress of port pair
- */
- String egress();
-
- /**
- * Returns whether this port pair is an exact match to the port pair given
- * in the argument.
- * <p>
- * Exact match means the Port port pairs match with the given port pair.
- * It does not consider the port pair id, name and description.
- * </p>
- * @param portPair other port pair to match against
- * @return true if the port pairs are an exact match, otherwise false
- */
- boolean exactMatch(PortPair portPair);
-
- /**
- * A port pair builder..
- */
- interface Builder {
-
- /**
- * Assigns the port pair id to this object.
- *
- * @param portPairId the port pair id
- * @return this the builder object
- */
- Builder setId(PortPairId portPairId);
-
- /**
- * Assigns tenant id to this object.
- *
- * @param tenantId tenant id of the port pair
- * @return this the builder object
- */
- Builder setTenantId(TenantId tenantId);
-
- /**
- * Assigns the name to this object.
- *
- * @param name name of the port pair
- * @return this the builder object
- */
- Builder setName(String name);
-
- /**
- * Assigns the description to this object.
- *
- * @param description description of the port pair
- * @return this the builder object
- */
- Builder setDescription(String description);
-
- /**
- * Assigns the ingress port to this object.
- *
- * @param port ingress port of the port pair
- * @return this the builder object
- */
- Builder setIngress(String port);
-
- /**
- * Assigns the egress port to this object.
- *
- * @param port egress port of the port pair
- * @return this the builder object
- */
- Builder setEgress(String port);
-
- /**
- * Builds a port pair object.
- *
- * @return a port pair.
- */
- PortPair build();
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroup.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroup.java
deleted file mode 100644
index 64fe723..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroup.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Abstraction of an entity providing Port Pair Group information.
- * A port pair group consists of one or more port pairs.
- */
-public interface PortPairGroup {
-
- /**
- * Returns the ID of this port pair group.
- *
- * @return the port pair group id
- */
- PortPairGroupId portPairGroupId();
-
- /**
- * Returns the tenant id of this port pair group.
- *
- * @return the tenant id
- */
- TenantId tenantId();
-
- /**
- * Returns the name of this port pair group.
- *
- * @return name of port pair group
- */
- String name();
-
- /**
- * Returns the description of this port pair group.
- *
- * @return description of port pair group
- */
- String description();
-
- /**
- * Returns the list of port pairs associated with this port pair group.
- *
- * @return list of port pairs
- */
- List<PortPairId> portPairs();
-
- /**
- * Adds the load on the given port pair id.
- *
- * @param portPairId port pair id.
- */
- void addLoad(PortPairId portPairId);
-
- /**
- * Reset the load for all the port pairs in the group.
- */
- void resetLoad();
-
- /**
- * Get the load on the given port pair id.
- *
- * @param portPairId port pair id
- * @return load on the given port pair id.
- */
- int getLoad(PortPairId portPairId);
-
- /**
- * Get the map of port pair id and its load.
- *
- * @return port pair and load map
- */
- Map<PortPairId, Integer> portPairLoadMap();
-
- /**
- * Returns whether this port pair group is an exact match to the
- * port pair group given in the argument.
- * <p>
- * Exact match means the Port pairs match with the given port pair group.
- * It does not consider the port pair group id, name and description.
- * </p>
- * @param portPairGroup other port pair group to match against
- * @return true if the port pairs are an exact match, otherwise false
- */
- boolean exactMatch(PortPairGroup portPairGroup);
-
- /**
- * A port pair group builder..
- */
- interface Builder {
-
- /**
- * Assigns the port pair group id to this object.
- *
- * @param portPairGroupId the port pair group id
- * @return this the builder object
- */
- Builder setId(PortPairGroupId portPairGroupId);
-
- /**
- * Assigns tenant id to this object.
- *
- * @param tenantId tenant id of port pair group
- * @return this the builder object
- */
- Builder setTenantId(TenantId tenantId);
-
- /**
- * Assigns the name to this object.
- *
- * @param name name of the port pair group
- * @return this the builder object
- */
- Builder setName(String name);
-
- /**
- * Assigns the description to this object.
- *
- * @param description description of the port pair group
- * @return this the builder object
- */
- Builder setDescription(String description);
-
- /**
- * Assigns the port pairs associated with the port pair group
- * to this object.
- *
- * @param portPairs list of port pairs
- * @return this the builder object
- */
- Builder setPortPairs(List<PortPairId> portPairs);
-
- /**
- * Builds a port pair group object.
- *
- * @return a port pair group object.
- */
- PortPairGroup build();
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroupId.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroupId.java
deleted file mode 100644
index 0699c34..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroupId.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.util.Identifier;
-
-import java.util.UUID;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Representation of a Port Pair Group ID.
- */
-public final class PortPairGroupId extends Identifier<UUID> {
- /**
- * Private constructor for port pair group id.
- *
- * @param id UUID id of port pair group
- */
- private PortPairGroupId(UUID id) {
- super(checkNotNull(id, "Port pair group id can not be null"));
- }
-
- /**
- * Returns newly created port pair group id object.
- *
- * @param id port pair group id in UUID
- * @return object of port pair group id
- */
- public static PortPairGroupId of(UUID id) {
- return new PortPairGroupId(id);
- }
-
- /**
- * Returns newly created port pair group id object.
- *
- * @param id port pair group id in string
- * @return object of port pair group id
- */
- public static PortPairGroupId of(String id) {
- return new PortPairGroupId(UUID.fromString(id));
- }
-
- /**
- * Returns the value of port pair group id.
- *
- * @return port pair group id
- */
- public UUID value() {
- return identifier;
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairId.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairId.java
deleted file mode 100644
index 0b44761..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairId.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.util.Identifier;
-
-import java.util.UUID;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Representation of a Port Pair ID.
- */
-public final class PortPairId extends Identifier<UUID> {
- /**
- * Private constructor for port pair id.
- *
- * @param id UUID id of port pair
- */
- private PortPairId(UUID id) {
- super(checkNotNull(id, "Port chain id can not be null"));
- }
-
- /**
- * Returns newly created port pair id object.
- *
- * @param id UUID of port pair id
- * @return object of port pair id
- */
- public static PortPairId of(UUID id) {
- return new PortPairId(id);
- }
-
- /**
- * Returns newly created port pair id object.
- *
- * @param id port pair id in string
- * @return object of port pair id
- */
- public static PortPairId of(String id) {
- return new PortPairId(UUID.fromString(id));
- }
-
- /**
- * Returns the value of port pair id.
- *
- * @return port pair id
- */
- public UUID value() {
- return identifier;
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/Router.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/Router.java
deleted file mode 100644
index d821bbe..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/Router.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import java.util.List;
-
-/**
- * Representation of a Router.
- */
-public interface Router {
-
- /**
- * Coarse classification of the type of the Router.
- */
- public enum Status {
- /**
- * Signifies that a router is currently active.
- */
- ACTIVE,
- /**
- * Signifies that a router is currently inactive.
- */
- INACTIVE
- }
-
- /**
- * Returns the router identifier.
- *
- * @return identifier
- */
- RouterId id();
-
- /**
- * Returns the router Name.
- *
- * @return routerName
- */
- String name();
-
- /**
- * Returns the router admin state.
- *
- * @return true or false
- */
- boolean adminStateUp();
-
- /**
- * Returns the status of router.
- *
- * @return RouterStatus
- */
- Status status();
-
- /**
- * Returns the distributed status of this router.
- * If true, indicates a distributed router.
- *
- * @return true or false
- */
- boolean distributed();
-
- /**
- * Returns the RouterGateway of router.
- *
- * @return routerGateway
- */
- RouterGateway externalGatewayInfo();
-
- /**
- * Returns the gatewayPortid of router.
- *
- * @return virtualPortId
- */
- VirtualPortId gatewayPortid();
-
- /**
- * Returns the owner(tenant) of this router.
- *
- * @return tenantId
- */
- TenantId tenantId();
-
- /**
- * Returns the router list of router.
- *
- * @return routes
- */
- List<String> routes();
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterGateway.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterGateway.java
deleted file mode 100644
index 6aef24e..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterGateway.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Collection;
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * Representation of a Router gateway.
- */
-public final class RouterGateway {
-
- private final TenantNetworkId networkId;
- private final boolean enableSnat;
- private final Set<FixedIp> externalFixedIps;
-
- // Public construction is prohibited
- private RouterGateway(TenantNetworkId networkId, boolean enableSnat,
- Set<FixedIp> externalFixedIps) {
- this.networkId = checkNotNull(networkId, "networkId cannot be null");
- this.enableSnat = enableSnat;
- this.externalFixedIps = checkNotNull(externalFixedIps, "externalFixedIps cannot be null");
- }
-
- /**
- * Creates router gateway object.
- *
- * @param networkId network identifier
- * @param enableSnat SNAT enable or not
- * @param externalFixedIps external fixed IP
- * @return RouterGateway
- */
- public static RouterGateway routerGateway(TenantNetworkId networkId, boolean enableSnat,
- Set<FixedIp> externalFixedIps) {
- return new RouterGateway(networkId, enableSnat, externalFixedIps);
- }
-
- /**
- * Returns network identifier.
- *
- * @return networkId
- */
- public TenantNetworkId networkId() {
- return networkId;
- }
-
- /**
- * Return SNAT enable or not.
- *
- * @return enableSnat
- */
- public boolean enableSnat() {
- return enableSnat;
- }
-
- /**
- * Return external fixed Ip.
- *
- * @return externalFixedIps
- */
- public Collection<FixedIp> externalFixedIps() {
- return externalFixedIps;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(networkId, enableSnat, externalFixedIps);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof RouterGateway) {
- final RouterGateway that = (RouterGateway) obj;
- return Objects.equals(this.networkId, that.networkId)
- && Objects.equals(this.enableSnat, that.enableSnat)
- && Objects.equals(this.externalFixedIps, that.externalFixedIps);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("networkId", networkId)
- .add("enableSnat", enableSnat)
- .add("externalFixedIps", externalFixedIps)
- .toString();
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterId.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterId.java
deleted file mode 100644
index 3527f80..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterId.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a router identifier.
- */
-public final class RouterId extends Identifier<String> {
- // Public construction is prohibited
- private RouterId(String routerId) {
- super(checkNotNull(routerId, "routerId cannot be null"));
- }
-
- /**
- * Creates a router identifier.
- *
- * @param routerId the router identifier
- * @return the router identifier
- */
- public static RouterId valueOf(String routerId) {
- return new RouterId(routerId);
- }
-
- /**
- * Returns the router identifier.
- *
- * @return the router identifier
- */
- public String routerId() {
- return identifier;
- }
-}
-
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterInterface.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterInterface.java
deleted file mode 100644
index 84164b2..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterInterface.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-/**
- * Representation of a Router interface.
- */
-public final class RouterInterface {
- private final SubnetId subnetId;
- private final VirtualPortId portId;
- private final RouterId routerId;
- private final TenantId tenantId;
-
- // Public construction is prohibited
- private RouterInterface(SubnetId subnetId, VirtualPortId portId,
- RouterId routerId, TenantId tenantId) {
- this.subnetId = checkNotNull(subnetId, "subnetId cannot be null");
- this.portId = checkNotNull(portId, "portId cannot be null");
- this.routerId = checkNotNull(routerId, "routerId cannot be null");
- this.tenantId = checkNotNull(tenantId, "tenantId cannot be null");
- }
-
- /**
- * Creates router interface object.
- *
- * @param subnetId subnet identifier
- * @param portId port identifier
- * @param routerId router identifier
- * @param tenantId tenant identifier
- * @return RouterInterface
- */
- public static RouterInterface routerInterface(SubnetId subnetId,
- VirtualPortId portId,
- RouterId routerId,
- TenantId tenantId) {
- return new RouterInterface(subnetId, portId, routerId, tenantId);
- }
-
- /**
- * Returns subnet identifier.
- *
- * @return subnetId the subnet identifier
- */
- public SubnetId subnetId() {
- return subnetId;
- }
-
- /**
- * Returns port identifier.
- *
- * @return portId the port identifier
- */
- public VirtualPortId portId() {
- return portId;
- }
-
- /**
- * Returns router identifier.
- *
- * @return routerId the router identifier
- */
- public RouterId routerId() {
- return routerId;
- }
-
- /**
- * Returns tenant identifier.
- *
- * @return tenantId the tenant identifier
- */
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(subnetId, portId, routerId, tenantId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof RouterInterface) {
- final RouterInterface that = (RouterInterface) obj;
- return Objects.equals(this.subnetId, that.subnetId)
- && Objects.equals(this.portId, that.portId)
- && Objects.equals(this.routerId, that.routerId)
- && Objects.equals(this.tenantId, that.tenantId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("subnetId", subnetId)
- .add("portId", portId).add("routerId", routerId)
- .add("tenantId", tenantId).toString();
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java
deleted file mode 100644
index ee56ba9..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a security group.
- */
-public final class SecurityGroup {
- private final String securityGroup;
-
- /**
- * Returns the securityGroup.
- *
- * @return securityGroup
- */
- public String securityGroup() {
- return securityGroup;
- }
- // Public construction is prohibited
- private SecurityGroup(String securityGroup) {
- checkNotNull(securityGroup, "SecurityGroup cannot be null");
- this.securityGroup = securityGroup;
- }
-
- /**
- * Creates a securityGroup using the supplied securityGroup.
- *
- * @param securityGroup security group
- * @return securityGroup
- */
- public static SecurityGroup securityGroup(String securityGroup) {
- return new SecurityGroup(securityGroup);
- }
-
- @Override
- public int hashCode() {
- return securityGroup.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof SecurityGroup) {
- final SecurityGroup that = (SecurityGroup) obj;
- return this.getClass() == that.getClass()
- && Objects.equals(this.securityGroup, that.securityGroup);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("securityGroup", securityGroup)
- .toString();
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java
deleted file mode 100644
index 414894c..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a Segmentation identifier.
- */
-public final class SegmentationId extends Identifier<String> {
- // Public construction is prohibited
- private SegmentationId(String segmentationId) {
- super(checkNotNull(segmentationId, "SegmentationId cannot be null"));
- }
-
- /**
- * Creates a SegmentationId object.
- *
- * @param segmentationId segmentation identifier
- * @return SegmentationId
- */
- public static SegmentationId segmentationId(String segmentationId) {
- return new SegmentationId(segmentationId);
- }
-
- /**
- * Returns the segmentation identifier.
- *
- * @return segmentationId
- */
- public String segmentationId() {
- return identifier;
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/ServiceFunctionGroup.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/ServiceFunctionGroup.java
deleted file mode 100644
index 2aed223..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/ServiceFunctionGroup.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-import java.util.Map;
-import java.util.Objects;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Implementation of ServiceFunctionGroup class.
- */
-public final class ServiceFunctionGroup {
-
- private final String name;
- private final String description;
- private final Map<PortPairId, Integer> portPairLoadMap;
-
- /**
- * Creates an instance of service function group.
- *
- * @param name name of port pair
- * @param description description of port pair
- * @param portPairLoadMap map of port pair id and its load
- */
- public ServiceFunctionGroup(String name, String description,
- Map<PortPairId, Integer> portPairLoadMap) {
- this.name = name;
- this.description = description;
- this.portPairLoadMap = portPairLoadMap;
- }
-
- /**
- * Returns name of service function group.
- *
- * @return name of service function group
- */
- public String name() {
- return name;
- }
-
- /**
- * Returns description of service function group.
- *
- * @return description of service function group.
- */
- public String description() {
- return description;
- }
-
- /**
- * Returns port pair load map.
- *
- * @return port pair load map
- */
- public Map<PortPairId, Integer> portPairLoadMap() {
- return ImmutableMap.copyOf(portPairLoadMap);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name, description, portPairLoadMap);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof ServiceFunctionGroup) {
- ServiceFunctionGroup that = (ServiceFunctionGroup) obj;
- return Objects.equals(name, that.name()) &&
- Objects.equals(description, that.description()) &&
- Objects.equals(portPairLoadMap, that.portPairLoadMap());
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("name", name)
- .add("description", description)
- .add("portPairLoadMap", portPairLoadMap)
- .toString();
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java
deleted file mode 100644
index 29551f8..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-
-/**
- * Representation of a subnet.
- */
-public interface Subnet {
-
- /**
- * Coarse classification of the type of the ipV6Mode.
- */
- enum Mode {
- DHCPV6_STATEFUL, DHCPV6_STATELESS, SLAAC
- }
-
- /**
- * Returns the subnet identifier.
- *
- * @return identifier
- */
- SubnetId id();
-
- /**
- * Returns the name of the subnet.
- *
- * @return subnetName
- */
- String subnetName();
-
- /**
- * Returns the network identifier.
- *
- * @return the network identifier
- */
- TenantNetworkId networkId();
-
- /**
- * Returns tenant identifier.
- *
- * @return the tenant identifier
- */
- TenantId tenantId();
-
- /**
- * Returns the IP version, which is 4 or 6.
- *
- * @return ipVersion
- */
- Version ipVersion();
-
- /**
- * Returns the cidr.
- *
- * @return cidr
- */
- IpPrefix cidr();
-
- /**
- * Returns the gateway IP address.
- *
- * @return gatewayIp
- */
- IpAddress gatewayIp();
-
- /**
- * Returns true if DHCP is enabled and return false if DHCP is disabled.
- *
- * @return true or false
- */
- boolean dhcpEnabled();
-
- /**
- * Indicates whether this tenantNetwork is shared across all tenants. By
- * default, only administrative user can change this value.
- *
- * @return true or false
- */
- boolean shared();
-
- /**
- * Returns a collection of hostRoutes.
- *
- * @return a collection of hostRoutes
- */
- Iterable<HostRoute> hostRoutes();
-
- /**
- * Returns the ipV6AddressMode. A valid value is dhcpv6-stateful,
- * dhcpv6-stateless, or slaac.
- *
- * @return ipV6AddressMode whose value is dhcpv6-stateful, dhcpv6-stateless
- * or slaac
- */
- Mode ipV6AddressMode();
-
- /**
- * Returns the ipV6RaMode.A valid value is dhcpv6-stateful,
- * dhcpv6-stateless, or slaac.
- *
- * @return ipV6RaMode whose value is dhcpv6-stateful, dhcpv6-stateless or
- * slaac
- */
- Mode ipV6RaMode();
-
- /**
- * Returns a collection of allocation_pools.
- *
- * @return a collection of allocationPools
- */
- Iterable<AllocationPool> allocationPools();
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java
deleted file mode 100644
index 77f0a44..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a subnet identifier.
- */
-public final class SubnetId extends Identifier<String> {
- // Public construction is prohibited
- private SubnetId(String subnetId) {
- super(checkNotNull(subnetId, "SubnetId cannot be null"));
- }
-
- /**
- * Creates a Subnet identifier.
- *
- * @param subnetId the subnet identifier
- * @return the subnet identifier
- */
- public static SubnetId subnetId(String subnetId) {
- return new SubnetId(subnetId);
- }
-
- /**
- * Returns the subnet identifier.
- *
- * @return the subnet identifier
- */
- public String subnetId() {
- return identifier;
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java
deleted file mode 100644
index 120a305..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a tenant identifier.
- */
-public final class TenantId extends Identifier<String> {
- // Public construction is prohibited
- private TenantId(String tenantId) {
- super(tenantId);
- }
-
- /**
- * Creates a network id using the tenantid.
- *
- * @param tenantid network String
- * @return TenantId
- */
- public static TenantId tenantId(String tenantid) {
- checkNotNull(tenantid, "Tenant id can not be null");
- return new TenantId(tenantid);
- }
-
- /**
- * Returns the tenant identifier.
- *
- * @return the tenant identifier
- */
- public String tenantId() {
- return identifier;
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java
deleted file mode 100644
index 701b13a..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-/**
- * Representation of the tenantNetwork.
- */
-public interface TenantNetwork {
-
- /**
- * Coarse classification of the state of the tenantNetwork.
- */
- enum State {
- /**
- * Signifies that a tenantNetwork is currently active.This state means
- * that this network is available.
- */
- ACTIVE,
- /**
- * Signifies that a tenantNetwork is currently built.
- */
- BUILD,
- /**
- * Signifies that a tenantNetwork is currently unavailable.
- */
- DOWN,
- /**
- * Signifies that a tenantNetwork is currently error.
- */
- ERROR
- }
-
- /**
- * Coarse classification of the type of the tenantNetwork.
- */
- enum Type {
- /**
- * Signifies that a tenantNetwork is local.
- */
- LOCAL
- }
-
- /**
- * Returns the tenantNetwork identifier.
- *
- * @return tenantNetwork identifier
- */
- TenantNetworkId id();
-
- /**
- * Returns the tenantNetwork name.
- *
- * @return tenantNetwork name
- */
- String name();
-
- /**
- * Returns the administrative state of the tenantNetwork,which is up(true)
- * or down(false).
- *
- * @return true or false
- */
- boolean adminStateUp();
-
- /**
- * Returns the tenantNetwork state.
- *
- * @return tenant network state
- */
- State state();
-
- /**
- * Indicates whether this tenantNetwork is shared across all tenants. By
- * default,only administrative user can change this value.
- *
- * @return true or false
- */
- boolean shared();
-
- /**
- * Returns the UUID of the tenant that will own the tenantNetwork. This
- * tenant can be different from the tenant that makes the create
- * tenantNetwork request.
- *
- * @return the tenant identifier
- */
- TenantId tenantId();
-
- /**
- * Returns the routerExternal.Indicates whether this network is externally
- * accessible.
- *
- * @return true or false
- */
- boolean routerExternal();
-
- /**
- * Returns the tenantNetwork Type.
- *
- * @return tenantNetwork Type
- */
- Type type();
-
- /**
- * Returns the tenantNetwork physical network.
- *
- * @return tenantNetwork physical network
- */
- PhysicalNetwork physicalNetwork();
-
- /**
- * Returns the tenantNetwork segmentation id.
- *
- * @return tenantNetwork segmentation id
- */
- SegmentationId segmentationId();
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java
deleted file mode 100644
index 6921ba5..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a tenantNetwork identity.
- */
-public final class TenantNetworkId extends Identifier<String> {
- // Public construction is prohibited
- private TenantNetworkId(String networkId) {
- super(networkId);
- }
-
- /**
- * Creates a TenantNetwork identifier.
- *
- * @param networkId tenantNetwork identify string
- * @return the attached tenantNetwork identifier
- */
- public static TenantNetworkId networkId(String networkId) {
- checkNotNull(networkId, "Networkid cannot be null");
- return new TenantNetworkId(networkId);
- }
-
- /**
- * Returns tenantNetwork identifier.
- *
- * @return the tenantNetwork identifier
- */
- public String networkId() {
- return identifier;
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantRouter.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantRouter.java
deleted file mode 100644
index ca221c7a..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantRouter.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-public final class TenantRouter {
- private final TenantId tenantId;
- private final RouterId routerId;
-
- /**
- * Construct a TenantRouter object.
- *
- * @param tenantId the tenant identifier
- * @param routerId router identifier
- */
- private TenantRouter(TenantId tenantId, RouterId routerId) {
- this.tenantId = checkNotNull(tenantId, "tenantId cannot be null");
- this.routerId = checkNotNull(routerId, "routerId cannot be null");
- }
-
- /**
- * Create a TenantRouter object.
- *
- * @param tenantId the tenant identifier
- * @param routerId router identifier
- * @return TenantRouter
- */
- public static TenantRouter tenantRouter(TenantId tenantId, RouterId routerId) {
- return new TenantRouter(tenantId, routerId);
- }
-
- public TenantId tenantId() {
- return tenantId;
- }
-
- public RouterId routerId() {
- return routerId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(tenantId, routerId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof TenantRouter) {
- final TenantRouter that = (TenantRouter) obj;
- return this.getClass() == that.getClass()
- && Objects.equals(this.tenantId, that.tenantId)
- && Objects.equals(this.routerId, that.routerId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("tenantId", tenantId)
- .add("routerId", routerId)
- .toString();
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java
deleted file mode 100644
index 94b166f..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-
-/**
- * Representation of the VirtualPort.
- */
-public interface VirtualPort {
- /**
- * Coarse classification of the type of the virtual port.
- */
- enum State {
- /**
- * Signifies that a virtualPort is currently active,This state mean that
- * this virtualPort is available.
- */
- ACTIVE,
- /**
- * Signifies that a virtualPort is currently unavailable.
- */
- DOWN
- }
-
- /**
- * Returns the virtualPort identifier.
- *
- * @return virtualPort identifier
- */
- VirtualPortId portId();
-
- /**
- * Returns the network identifier.
- *
- * @return tenantNetwork identifier
- */
- TenantNetworkId networkId();
-
- /**
- * Returns the symbolic name for the virtualPort.
- *
- * @return virtualPort name
- */
- String name();
-
- /**
- * Returns the administrative status of the port,which is up(true) or
- * down(false).
- *
- * @return true if the administrative status of the port is up
- */
- boolean adminStateUp();
-
- /**
- * Returns the state.
- *
- * @return state
- */
- State state();
-
- /**
- * Returns the MAC address.
- *
- * @return MAC Address
- */
- MacAddress macAddress();
-
- /**
- * Returns the port tenantId.
- *
- * @return port tenantId
- */
- TenantId tenantId();
-
- /**
- * Returns the device identifier.
- *
- * @return deviceId
- */
- DeviceId deviceId();
-
- /**
- * Returns the identifier of the entity that uses this port.
- *
- * @return deviceOwner
- */
- String deviceOwner();
-
- /**
- * Returns the virtualPort allowedAddressPairs.
- *
- * @return virtualPort allowedAddressPairs
- */
- Collection<AllowedAddressPair> allowedAddressPairs();
-
- /**
- * Returns set of IP addresses for the port, include the IP addresses and subnet
- * identity.
- *
- * @return FixedIps Set of fixedIp
- */
- Set<FixedIp> fixedIps();
-
- /**
- * Returns the virtualPort bindinghostId.
- *
- * @return virtualPort bindinghostId
- */
- BindingHostId bindingHostId();
-
- /**
- * Returns the virtualPort bindingVnicType.
- *
- * @return virtualPort bindingVnicType
- */
- String bindingVnicType();
-
- /**
- * Returns the virtualPort bindingVifType.
- *
- * @return virtualPort bindingVifType
- */
- String bindingVifType();
-
- /**
- * Returns the virtualPort bindingvifDetail.
- *
- * @return virtualPort bindingvifDetail
- */
- String bindingVifDetails();
-
- /**
- * Returns the security groups.
- *
- * @return port security groups
- */
- Iterable<SecurityGroup> securityGroups();
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java
deleted file mode 100644
index 1a5594a..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.onlab.util.Identifier;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a virtual port identifier.
- */
-public final class VirtualPortId extends Identifier<String> {
- // Public construction is prohibited
- private VirtualPortId(String virtualPortId) {
- super(checkNotNull(virtualPortId, "VirtualPortId cannot be null"));
- }
-
- public String portId() {
- return identifier;
- }
-
- /**
- * Creates a virtualPort id using the supplied portId.
- *
- * @param portId virtualport identifier
- * @return VirtualPortId
- */
- public static VirtualPortId portId(String portId) {
- return new VirtualPortId(portId);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/classifier/ClassifierService.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/classifier/ClassifierService.java
deleted file mode 100644
index 9f2c354..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/classifier/ClassifierService.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.classifier;
-
-import org.onosproject.net.DeviceId;
-
-/**
- * Provides Services for Classifier.
- */
-public interface ClassifierService {
-
- /**
- * Get Classifier devices for sfc.
- *
- * @return list of device id's for classifiers
- */
- Iterable<DeviceId> getClassifiers();
-
- /**
- * Add Classifier device for sfc.
- *
- * @param deviceId device id
- */
- void addClassifier(DeviceId deviceId);
-
- /**
- * Remove Classifier device for sfc.
- *
- * @param deviceId deviceId
- */
- void removeClassifier(DeviceId deviceId);
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/classifier/impl/ClassifierManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/classifier/impl/ClassifierManager.java
deleted file mode 100644
index 74bf8b6..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/classifier/impl/ClassifierManager.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.classifier.impl;
-
-import com.google.common.collect.ImmutableList;
-import org.onosproject.net.DeviceId;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.DistributedSet;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.vtnrsc.classifier.ClassifierService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the Classifier Service.
- */
-@Component(immediate = true, service = ClassifierService.class)
-public class ClassifierManager implements ClassifierService {
-
- private final Logger log = getLogger(ClassifierManager.class);
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- private DistributedSet<DeviceId> classifierList;
-
- @Activate
- protected void activate() {
- classifierList = storageService.<DeviceId>setBuilder()
- .withName("classifier")
- .withSerializer(Serializer.using(KryoNamespaces.API))
- .build()
- .asDistributedSet();
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public void addClassifier(DeviceId deviceId) {
- classifierList.add(deviceId);
- }
-
- @Override
- public Iterable<DeviceId> getClassifiers() {
- return ImmutableList.copyOf(classifierList);
- }
-
- @Override
- public void removeClassifier(DeviceId deviceId) {
- classifierList.remove(deviceId);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/classifier/impl/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/classifier/impl/package-info.java
deleted file mode 100644
index 7fac017..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/classifier/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of the Classifier service.
- */
-package org.onosproject.vtnrsc.classifier.impl;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/classifier/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/classifier/package-info.java
deleted file mode 100644
index 520554f..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/classifier/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with Classifier of SFC.
- */
-package org.onosproject.vtnrsc.classifier;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/FloatingIpCreateCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/FloatingIpCreateCommand.java
deleted file mode 100644
index e21cbc3..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/FloatingIpCreateCommand.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.floatingip;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.DefaultFloatingIp;
-import org.onosproject.vtnrsc.FloatingIpId;
-import org.onosproject.vtnrsc.FloatingIp;
-import org.onosproject.vtnrsc.FloatingIp.Status;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.floatingip.FloatingIpService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for create a floating IP.
- */
-@Service
-@Command(scope = "onos", name = "floatingip-create",
- description = "Supports for creating a floating IP")
-public class FloatingIpCreateCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "id", description = "The floating IP identifier",
- required = true, multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "networkId", description = "The network identifier of floating IP",
- required = true, multiValued = false)
- String networkId = null;
-
- @Argument(index = 2, name = "tenantId", description = "The tenant identifier of floating IP",
- required = true, multiValued = false)
- String tenantId = null;
-
- @Argument(index = 3, name = "routerId", description = "The router identifier of floating IP",
- required = true, multiValued = false)
- String routerId = null;
-
- @Argument(index = 4, name = "fixedIp", description = "The fixed IP of floating IP",
- required = true, multiValued = false)
- String fixedIp = null;
-
- @Argument(index = 5, name = "floatingIp", description = "The floating IP of floating IP",
- required = true, multiValued = false)
- String floatingIp = null;
-
- @Option(name = "-p", aliases = "--portId", description = "The port identifier of floating IP",
- required = false, multiValued = false)
- String portId = null;
-
- @Option(name = "-s", aliases = "--status", description = "The status of floating IP",
- required = false, multiValued = false)
- String status = null;
-
- @Override
- protected void doExecute() {
- FloatingIpService service = get(FloatingIpService.class);
- try {
- FloatingIp floatingIpObj = new DefaultFloatingIp(
- FloatingIpId.of(id),
- TenantId.tenantId(tenantId),
- TenantNetworkId.networkId(networkId),
- VirtualPortId.portId(portId),
- RouterId.valueOf(routerId),
- floatingIp == null ? null : IpAddress.valueOf(floatingIp),
- fixedIp == null ? null : IpAddress.valueOf(fixedIp),
- status == null ? Status.ACTIVE
- : Status.valueOf(status));
- Set<FloatingIp> floatingIpSet = Sets.newHashSet(floatingIpObj);
- service.createFloatingIps(floatingIpSet);
- } catch (Exception e) {
- print(null, e.getMessage());
- }
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/FloatingIpQueryCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/FloatingIpQueryCommand.java
deleted file mode 100644
index d4b08a7..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/FloatingIpQueryCommand.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.floatingip;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.FloatingIpId;
-import org.onosproject.vtnrsc.FloatingIp;
-import org.onosproject.vtnrsc.floatingip.FloatingIpService;
-
-/**
- * Supports for query a floating IP.
- */
-@Service
-@Command(scope = "onos", name = "floatingips", description = "Supports for querying a floating IP")
-public class FloatingIpQueryCommand extends AbstractShellCommand {
- @Option(name = "-I", aliases = "--id", description = "The floating IP identifier",
- required = false, multiValued = false)
- String id = null;
-
- @Option(name = "-i", aliases = "--fixedIp", description = "The fixed IP of floating IP",
- required = false, multiValued = false)
- String fixedIp = null;
-
- @Option(name = "-l", aliases = "--floatingIp", description = "The floating IP of floating IP",
- required = false, multiValued = false)
- String floatingIp = null;
-
- private static final String FMT = "floatingIpId=%s, networkId=%s, tenantId=%s, portId=%s,"
- + "routerId=%s, fixedIp=%s, floatingIp=%s, status=%s";
-
- @Override
- protected void doExecute() {
- FloatingIpService service = get(FloatingIpService.class);
- if (id != null) {
- FloatingIp floatingIp = service.getFloatingIp(FloatingIpId
- .of(id));
- printFloatingIp(floatingIp);
- } else if (fixedIp != null || floatingIp != null) {
- Iterable<FloatingIp> floatingIps = service.getFloatingIps();
- if (floatingIps == null) {
- return;
- }
- if (fixedIp != null) {
- for (FloatingIp floatingIp : floatingIps) {
- if (floatingIp.fixedIp().toString().equals(fixedIp)) {
- printFloatingIp(floatingIp);
- return;
- }
- }
- print(null, "The fixedIp is not existed");
- }
- if (floatingIp != null) {
- for (FloatingIp floatingIpObj : floatingIps) {
- if (floatingIpObj.fixedIp().toString().equals(floatingIp)) {
- printFloatingIp(floatingIpObj);
- return;
- }
- }
- print(null, "The floatingIp is not existed");
- }
- } else {
- Iterable<FloatingIp> floatingIps = service.getFloatingIps();
- if (floatingIps == null) {
- return;
- }
- for (FloatingIp floatingIp : floatingIps) {
- printFloatingIp(floatingIp);
- }
- }
- }
-
- private void printFloatingIp(FloatingIp floatingIp) {
- print(FMT, floatingIp.id(), floatingIp.networkId(),
- floatingIp.tenantId(), floatingIp.portId(),
- floatingIp.routerId(), floatingIp.fixedIp(),
- floatingIp.floatingIp(), floatingIp.status());
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/FloatingIpRemoveCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/FloatingIpRemoveCommand.java
deleted file mode 100644
index 4071cd8..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/FloatingIpRemoveCommand.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.floatingip;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.FloatingIp;
-import org.onosproject.vtnrsc.FloatingIpId;
-import org.onosproject.vtnrsc.floatingip.FloatingIpService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for remove a floating IP.
- */
-@Service
-@Command(scope = "onos", name = "floatingip-remove", description = "Supports for removing a floating IP")
-public class FloatingIpRemoveCommand extends AbstractShellCommand {
- @Option(name = "-I", aliases = "--id", description = "The floating IP identifier",
- required = false, multiValued = false)
- String id = null;
-
- @Option(name = "-i", aliases = "--fixedIp", description = "The fixed IP of floating IP",
- required = false, multiValued = false)
- String fixedIp = null;
-
- @Option(name = "-l", aliases = "--floatingIp", description = "The floating IP of floating IP",
- required = false, multiValued = false)
- String floatingIp = null;
-
- @Override
- protected void doExecute() {
- FloatingIpService service = get(FloatingIpService.class);
- if (id == null && fixedIp == null && floatingIp == null) {
- print(null, "one of id, fixedIp, floatingIp should not be null");
- }
- try {
- Set<FloatingIpId> floatingIpSet = Sets.newHashSet();
- if (id != null) {
- floatingIpSet.add(FloatingIpId.of(id));
- service.removeFloatingIps(floatingIpSet);
- } else {
- Iterable<FloatingIp> floatingIps = service.getFloatingIps();
- if (floatingIps == null) {
- return;
- }
- if (fixedIp != null) {
- for (FloatingIp floatingIp : floatingIps) {
- if (floatingIp.fixedIp().toString().equals(fixedIp)) {
- floatingIpSet.add(floatingIp.id());
- service.removeFloatingIps(floatingIpSet);
- return;
- }
- }
- print(null, "The fixedIp is not existed");
- return;
- }
- if (floatingIp != null) {
- for (FloatingIp floatingIpObj : floatingIps) {
- if (floatingIpObj.fixedIp().toString()
- .equals(floatingIp)) {
- floatingIpSet.add(floatingIpObj.id());
- service.removeFloatingIps(floatingIpSet);
- return;
- }
- }
- print(null, "The floatingIp is not existed");
- return;
- }
- }
- } catch (Exception e) {
- print(null, e.getMessage());
- }
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/FloatingIpUpdateCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/FloatingIpUpdateCommand.java
deleted file mode 100644
index 5ec16c9..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/FloatingIpUpdateCommand.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.floatingip;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.DefaultFloatingIp;
-import org.onosproject.vtnrsc.FloatingIpId;
-import org.onosproject.vtnrsc.FloatingIp;
-import org.onosproject.vtnrsc.FloatingIp.Status;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.floatingip.FloatingIpService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for update a floating IP.
- */
-@Service
-@Command(scope = "onos", name = "floatingip-update",
- description = "Supports for updating a floating IP")
-public class FloatingIpUpdateCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "id", description = "The floating IP identifier",
- required = true, multiValued = false)
- String id = null;
-
- @Option(name = "-n", aliases = "--networkId", description = "The network identifier of floating IP",
- required = false, multiValued = false)
- String networkId = null;
-
- @Option(name = "-t", aliases = "--tenantId", description = "The tenant identifier of floating IP",
- required = false, multiValued = false)
- String tenantId = null;
-
- @Option(name = "-r", aliases = "--routerId", description = "The router identifier of floating IP",
- required = false, multiValued = false)
- String routerId = null;
-
- @Option(name = "-p", aliases = "--portId", description = "The port identifier of floating IP",
- required = false, multiValued = false)
- String portId = null;
-
- @Option(name = "-s", aliases = "--status", description = "The status of floating IP",
- required = false, multiValued = false)
- String status = null;
-
- @Option(name = "-i", aliases = "--fixedIp", description = "The fixed IP of floating IP",
- required = false, multiValued = false)
- String fixedIp = null;
-
- @Option(name = "-l", aliases = "--floatingIp", description = "The floating IP of floating IP",
- required = false, multiValued = false)
- String floatingIp = null;
-
- @Override
- protected void doExecute() {
- FloatingIpService service = get(FloatingIpService.class);
- FloatingIpId floatingIpId = FloatingIpId.of(id);
- FloatingIp floatingIpStore = get(FloatingIpService.class).getFloatingIp(floatingIpId);
- try {
- FloatingIp floatingIpObj = new DefaultFloatingIp(
- floatingIpId,
- tenantId == null ? floatingIpStore.tenantId()
- : TenantId.tenantId(tenantId),
- networkId == null ? floatingIpStore.networkId()
- : TenantNetworkId.networkId(networkId),
- portId == null ? floatingIpStore.portId()
- : VirtualPortId.portId(portId),
- routerId == null ? floatingIpStore.routerId()
- : RouterId.valueOf(routerId),
- floatingIp == null ? floatingIpStore.floatingIp()
- : IpAddress.valueOf(floatingIp),
- fixedIp == null ? floatingIpStore.fixedIp()
- : IpAddress.valueOf(fixedIp),
- status == null ? floatingIpStore.status()
- : Status.valueOf(status));
- Set<FloatingIp> floatingIpSet = Sets.newHashSet(floatingIpObj);
- service.updateFloatingIps(floatingIpSet);
- } catch (Exception e) {
- print(null, e.getMessage());
- }
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/package-info.java
deleted file mode 100644
index 715e4a6..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/floatingip/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Command line interface for floatingIP.
- */
-package org.onosproject.vtnrsc.cli.floatingip;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkCreateCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkCreateCommand.java
deleted file mode 100644
index 40669cb..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkCreateCommand.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.network;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.DefaultTenantNetwork;
-import org.onosproject.vtnrsc.PhysicalNetwork;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for creating a TenantNetwork.
- */
-@Service
-@Command(scope = "onos", name = "tenantnetwork-create",
- description = "Supports for creating a TenantNetwork")
-public class TenantNetworkCreateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "TenantNetwork network id", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "tenantID", description = "The tenant id of TenantNetwork",
- required = true, multiValued = false)
- String tenantID = null;
-
- @Argument(index = 2, name = "type", description = "The type of TenantNetwork", required = true,
- multiValued = false)
- String type = null;
-
- @Argument(index = 3, name = "segmentationID", description = "The segmentation id of TenantNetwork",
- required = true, multiValued = false)
- String segmentationID = "";
-
- @Option(name = "-n", aliases = "--name", description = "TenantNetwork name", required = false,
- multiValued = false)
- String name = null;
-
- @Option(name = "-a", aliases = "--adminStateUp", description = "TenantNetwork adminStateUp is true or false",
- required = false, multiValued = false)
- boolean adminStateUp = false;
-
- @Option(name = "-s", aliases = "--state", description = "The state of TenantNetwork",
- required = false, multiValued = false)
- String state = null;
-
- @Option(name = "-d", aliases = "--shared", description = "TenantNetwork is shared or not",
- required = false, multiValued = false)
- boolean shared = false;
-
- @Option(name = "-r", aliases = "--routerExternal",
- description = "TenantNetwork is routerExternal or not", required = false,
- multiValued = false)
- boolean routerExternal = false;
-
- @Option(name = "-p", aliases = "--physicalNetwork", description = "The physical network of Tenant",
- required = false, multiValued = false)
- String physicalNetwork = "";
-
- @Override
- protected void doExecute() {
- TenantNetworkService service = get(TenantNetworkService.class);
- TenantNetwork network = new DefaultTenantNetwork(TenantNetworkId.networkId(id), name,
- adminStateUp,
- TenantNetwork.State.valueOf(state),
- shared, TenantId.tenantId(tenantID),
- routerExternal,
- TenantNetwork.Type.valueOf(type),
- PhysicalNetwork.physicalNetwork(physicalNetwork),
- SegmentationId.segmentationId(segmentationID));
-
- Set<TenantNetwork> networksSet = Sets.newHashSet(network);
- service.createNetworks(networksSet);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkQueryCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkQueryCommand.java
deleted file mode 100644
index 7521eff..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkQueryCommand.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.network;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-
-/**
- * Supports for querying TenantNetworks by network id.
- */
-@Service
-@Command(scope = "onos", name = "tenantnetworks", description = "Supports for querying"
- + "tenantNetworks by networkid")
-public class TenantNetworkQueryCommand extends AbstractShellCommand {
-
- @Option(name = "-i", aliases = "--id", description = "TenantNetwork id", required = false,
- multiValued = false)
- String id = null;
-
- private static final String FMT = "networkId=%s, networkName=%s, segmentationId=%s,"
- + "tenantId=%s, type=%s, adminStateUp=%s";
-
- @Override
- protected void doExecute() {
- TenantNetworkService service = get(TenantNetworkService.class);
- if (id != null) {
- TenantNetwork network = service.getNetwork(TenantNetworkId.networkId(id));
- printNetwork(network);
- } else {
- Iterable<TenantNetwork> networks = service.getNetworks();
- for (TenantNetwork network : networks) {
- printNetwork(network);
- }
- }
- }
-
- private void printNetwork(TenantNetwork network) {
- if (network == null) {
- return;
- }
- print(FMT, network.id(), network.name(), network.segmentationId(),
- network.tenantId(), network.type(), network.adminStateUp());
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkRemoveCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkRemoveCommand.java
deleted file mode 100644
index d6a8673..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkRemoveCommand.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.network;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for removing a TenantNetwork by network id.
- */
-@Service
-@Command(scope = "onos", name = "tenantnetwork-remove", description = "Supports for removing"
- + " a tenantNetwork by tenantNetworkid")
-public class TenantNetworkRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "TenantNetwork neutronNetwork Id",
- required = true, multiValued = false)
- String id = null;
-
- @Override
- protected void doExecute() {
- TenantNetworkService service = get(TenantNetworkService.class);
- Set<TenantNetworkId> networkIds = Sets.newHashSet(TenantNetworkId.networkId(id));
- service.removeNetworks(networkIds);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkUpdateCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkUpdateCommand.java
deleted file mode 100644
index 88c342e..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkUpdateCommand.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.network;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.DefaultTenantNetwork;
-import org.onosproject.vtnrsc.PhysicalNetwork;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for updating a TenantNetwork.
- */
-@Service
-@Command(scope = "onos", name = "tenantnetwork-update",
- description = "Supports for updating a TenantNetwork")
-public class TenantNetworkUpdateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "TenantNetwork network id", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "tenantID", description = "The tenant id of TenantNetwork",
- required = true, multiValued = false)
- String tenantID = null;
-
- @Argument(index = 2, name = "type", description = "The type of TenantNetwork", required = true,
- multiValued = false)
- String type = null;
-
- @Argument(index = 3, name = "segmentationID", description = "The segmentation id of TenantNetwork",
- required = true, multiValued = false)
- String segmentationID = "";
-
- @Option(name = "-n", aliases = "--name", description = "TenantNetwork name", required = false,
- multiValued = false)
- String name = null;
-
- @Option(name = "-a", aliases = "--adminStateUp", description = "TenantNetwork adminStateUp is true or false",
- required = false, multiValued = false)
- boolean adminStateUp = false;
-
- @Option(name = "-s", aliases = "--state", description = "The state of TenantNetwork",
- required = false, multiValued = false)
- String state = null;
-
- @Option(name = "-d", aliases = "--shared", description = "TenantNetwork is shared or not",
- required = false, multiValued = false)
- boolean shared = false;
-
- @Option(name = "-r", aliases = "--routerExternal",
- description = "TenantNetwork is routerExternal or not", required = false,
- multiValued = false)
- boolean routerExternal = false;
-
- @Option(name = "-p", aliases = "--physicalNetwork", description = "The physical network of Tenant",
- required = false, multiValued = false)
- String physicalNetwork = "";
-
- @Override
- protected void doExecute() {
- TenantNetworkService service = get(TenantNetworkService.class);
- TenantNetwork network = new DefaultTenantNetwork(TenantNetworkId.networkId(id), name,
- adminStateUp,
- TenantNetwork.State.valueOf(state),
- shared, TenantId.tenantId(tenantID),
- routerExternal,
- TenantNetwork.Type.valueOf(type),
- PhysicalNetwork.physicalNetwork(physicalNetwork),
- SegmentationId.segmentationId(segmentationID));
-
- Set<TenantNetwork> networksSet = Sets.newHashSet();
- networksSet.add(network);
- service.updateNetworks(networksSet);
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java
deleted file mode 100644
index b2ecfe1..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Command line interface for tenant networks.
- */
-package org.onosproject.vtnrsc.cli.network;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/RouterCreateCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/RouterCreateCommand.java
deleted file mode 100644
index 4c0aee4..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/RouterCreateCommand.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.router;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.DefaultRouter;
-import org.onosproject.vtnrsc.Router;
-import org.onosproject.vtnrsc.Router.Status;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.router.RouterService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for create a router.
- */
-@Service
-@Command(scope = "onos", name = "router-create",
- description = "Supports for creating a router")
-public class RouterCreateCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "id", description = "The router identifier",
- required = true, multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "routerName", description = "The name of router",
- required = true, multiValued = false)
- String routerName = null;
-
- @Argument(index = 2, name = "tenantId", description = "The tenant identifier of router",
- required = true, multiValued = false)
- String tenantId = null;
-
- @Option(name = "-g", aliases = "--gatewayPortId", description = "The gatewayPort identifier of router",
- required = false, multiValued = false)
- String gatewayPortId = null;
-
- @Option(name = "-e", aliases = "--externalGatewayInfo", description = "The external gateway info of router",
- required = false, multiValued = false)
- String externalGatewayInfo = null;
-
- @Option(name = "-s", aliases = "--status", description = "The status of router",
- required = false, multiValued = false)
- String status = null;
-
- @Option(name = "-a", aliases = "--adminStateUp", description = "The boolean adminStateUp of router",
- required = false, multiValued = false)
- boolean adminStateUp = true;
-
- @Option(name = "-d", aliases = "--distributed", description = "The boolean distributed of router",
- required = false, multiValued = false)
- boolean distributed = false;
-
- @Override
- protected void doExecute() {
- RouterService service = get(RouterService.class);
- try {
- List<String> routes = new ArrayList<String>();
- Router router = new DefaultRouter(
- RouterId.valueOf(id),
- routerName,
- adminStateUp,
- status == null ? Status.ACTIVE
- : Status.valueOf(status),
- distributed,
- null,
- VirtualPortId.portId(gatewayPortId),
- TenantId.tenantId(tenantId),
- routes);
- Set<Router> routerSet = Sets.newHashSet(router);
- service.createRouters(routerSet);
- } catch (Exception e) {
- print(null, e.getMessage());
- }
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/RouterQueryCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/RouterQueryCommand.java
deleted file mode 100644
index dc447d6..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/RouterQueryCommand.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.router;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.Router;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.router.RouterService;
-
-/**
- * Supports for query a list of router.
- */
-@Service
-@Command(scope = "onos", name = "routers", description = "Supports for creating a router")
-public class RouterQueryCommand extends AbstractShellCommand {
- @Option(name = "-i", aliases = "--id", description = "The router identifier",
- required = false, multiValued = false)
- String id = null;
-
- @Option(name = "-n", aliases = "--routerName", description = "The name of router",
- required = false, multiValued = false)
- String routerName = null;
-
- private static final String FMT = "routerId=%s, routerName=%s, tenantId=%s, gatewayPortId=%s,"
- + "externalGatewayInfo=%s, status=%s, adminStateUp=%s, distributed=%s, routers=%s";
-
- @Override
- protected void doExecute() {
- RouterService service = get(RouterService.class);
- if (id != null) {
- Router router = service.getRouter(RouterId.valueOf(id));
- printFloatingIp(router);
- } else if (routerName != null) {
- Iterable<Router> routers = service.getRouters();
- if (routers == null) {
- return;
- }
- for (Router router : routers) {
- if (router.name().equals(routerName)) {
- printFloatingIp(router);
- return;
- }
- }
- print(null, "The routerName is not existed");
- } else {
- Iterable<Router> routers = service.getRouters();
- if (routers == null) {
- return;
- }
- for (Router router : routers) {
- printFloatingIp(router);
- }
- }
- }
-
- private void printFloatingIp(Router router) {
- print(FMT, router.id(), router.name(), router.tenantId(),
- router.gatewayPortid(), router.externalGatewayInfo(),
- router.status(), router.adminStateUp(), router.distributed(),
- router.routes());
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/RouterRemoveCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/RouterRemoveCommand.java
deleted file mode 100644
index 45d642c..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/RouterRemoveCommand.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.router;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.Router;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.router.RouterService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for remove a router.
- */
-@Service
-@Command(scope = "onos", name = "router-remove", description = "Supports for removing a router")
-public class RouterRemoveCommand extends AbstractShellCommand {
- @Option(name = "-i", aliases = "--id", description = "The router identifier",
- required = false, multiValued = false)
- String id = null;
-
- @Option(name = "-n", aliases = "--routerName", description = "The name of router",
- required = false, multiValued = false)
- String routerName = null;
-
- @Override
- protected void doExecute() {
- RouterService service = get(RouterService.class);
- if (id == null && routerName == null) {
- print(null, "one of id, routerName should not be null");
- }
- try {
- Set<RouterId> routerSet = Sets.newHashSet();
- if (id != null) {
- routerSet.add(RouterId.valueOf(id));
- service.removeRouters(routerSet);
- } else {
- Iterable<Router> routers = service.getRouters();
- if (routers == null) {
- return;
- }
- for (Router router : routers) {
- if (router.name().equals(routerName)) {
- routerSet.add(router.id());
- service.removeRouters(routerSet);
- return;
- }
- }
- }
- } catch (Exception e) {
- print(null, e.getMessage());
- }
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/RouterUpdateCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/RouterUpdateCommand.java
deleted file mode 100644
index 0b2d89f..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/RouterUpdateCommand.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.router;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.DefaultRouter;
-import org.onosproject.vtnrsc.Router;
-import org.onosproject.vtnrsc.Router.Status;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.router.RouterService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for update a router.
- */
-@Service
-@Command(scope = "onos", name = "router-update", description = "Supports for updating a router")
-public class RouterUpdateCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "id", description = "The router identifier",
- required = true, multiValued = false)
- String id = null;
-
- @Option(name = "-r", aliases = "--routerName", description = "The name of router",
- required = false, multiValued = false)
- String routerName = null;
-
- @Option(name = "-t", aliases = "--tenantId", description = "The tenant identifier of router",
- required = false, multiValued = false)
- String tenantId = null;
-
- @Option(name = "-g", aliases = "--gatewayPortId", description = "The gatewayPort identifier of router",
- required = false, multiValued = false)
- String gatewayPortId = null;
-
- @Option(name = "-e", aliases = "--externalGatewayInfo", description = "The externalGatewayInfo of router",
- required = false, multiValued = false)
- String externalGatewayInfo = null;
-
- @Option(name = "-s", aliases = "--status", description = "The status of router",
- required = false, multiValued = false)
- String status = null;
-
- @Option(name = "-a", aliases = "--adminStateUp", description = "The boolean adminStateUp of router",
- required = false, multiValued = false)
- boolean adminStateUp = true;
-
- @Option(name = "-d", aliases = "--distributed", description = "The boolean distributed of router",
- required = false, multiValued = false)
- boolean distributed = false;
-
- @Override
- protected void doExecute() {
- RouterService service = get(RouterService.class);
- RouterId routerId = RouterId.valueOf(id);
- Router router = get(RouterService.class).getRouter(routerId);
- try {
- List<String> routes = new ArrayList<String>();
- Router routerObj = new DefaultRouter(
- RouterId.valueOf(id),
- routerName == null ? router.name() : routerName,
- adminStateUp,
- status == null ? Status.ACTIVE
- : Status.valueOf(status),
- distributed,
- null,
- gatewayPortId == null ? router.gatewayPortid()
- : VirtualPortId.portId(gatewayPortId),
- tenantId == null ? router.tenantId()
- : TenantId.tenantId(tenantId),
- routes);
- Set<Router> routerSet = Sets.newHashSet(routerObj);
- service.createRouters(routerSet);
- } catch (Exception e) {
- print(null, e.getMessage());
- }
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/package-info.java
deleted file mode 100644
index d217bfb..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/router/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Command line interface for router.
- */
-package org.onosproject.vtnrsc.cli.router;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/routerinterface/RouterInterfaceCreateCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/routerinterface/RouterInterfaceCreateCommand.java
deleted file mode 100644
index c8c39cb..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/routerinterface/RouterInterfaceCreateCommand.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.routerinterface;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.RouterInterface;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.routerinterface.RouterInterfaceService;
-
-/**
- * Supports for create a router interface.
- */
-@Service
-@Command(scope = "onos", name = "routerinterface-create", description = "Supports for creating a router interface")
-public class RouterInterfaceCreateCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "routerId", description = "The router identifier of router interface",
- required = true, multiValued = false)
- String routerId = null;
-
- @Argument(index = 1, name = "tenantId", description = "The tenant identifier of router interface",
- required = true, multiValued = false)
- String tenantId = null;
-
- @Argument(index = 2, name = "portId", description = "The port identifier of router interface",
- required = true, multiValued = false)
- String portId = null;
-
- @Argument(index = 3, name = "subnetId", description = "The subnet identifier of router interface",
- required = true, multiValued = false)
- String subnetId = null;
-
- @Override
- protected void doExecute() {
- RouterInterfaceService service = get(RouterInterfaceService.class);
- try {
- RouterInterface routerInterface = RouterInterface.routerInterface(
- SubnetId.subnetId(subnetId),
- VirtualPortId.portId(portId),
- RouterId.valueOf(routerId),
- TenantId.tenantId(tenantId));
- service.addRouterInterface(routerInterface);
- } catch (Exception e) {
- print(null, e.getMessage());
- }
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/routerinterface/RouterInterfaceQueryCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/routerinterface/RouterInterfaceQueryCommand.java
deleted file mode 100644
index 7486c12..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/routerinterface/RouterInterfaceQueryCommand.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.routerinterface;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.RouterInterface;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.routerinterface.RouterInterfaceService;
-
-/**
- * Supports for query a router interface.
- */
-@Service
-@Command(scope = "onos", name = "routerinterfaces", description = "Supports for querying a router interface")
-public class RouterInterfaceQueryCommand extends AbstractShellCommand {
- @Option(name = "-s", aliases = "--subnetId", description = "The subnet identifier of router interface",
- required = false, multiValued = false)
- String subnetId = null;
-
- private static final String FMT = "subnetId=%s, tenantId=%s, portId=%s, routerId=%s";
-
- @Override
- protected void doExecute() {
- RouterInterfaceService service = get(RouterInterfaceService.class);
- if (subnetId != null) {
- RouterInterface routerInterface = service
- .getRouterInterface(SubnetId.subnetId(subnetId));
- printRouterInterface(routerInterface);
- } else {
- Iterable<RouterInterface> routerInterfaces = service
- .getRouterInterfaces();
- for (RouterInterface routerInterface : routerInterfaces) {
- printRouterInterface(routerInterface);
- }
- }
- }
-
- private void printRouterInterface(RouterInterface routerInterface) {
- print(FMT, routerInterface.subnetId(), routerInterface.tenantId(),
- routerInterface.portId(), routerInterface.routerId());
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/routerinterface/RouterInterfaceRemoveCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/routerinterface/RouterInterfaceRemoveCommand.java
deleted file mode 100644
index 3bfd7d2..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/routerinterface/RouterInterfaceRemoveCommand.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.routerinterface;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.RouterInterface;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.routerinterface.RouterInterfaceService;
-
-/**
- * Supports for remove a router interface.
- */
-@Service
-@Command(scope = "onos", name = "routerinterface-remove", description = "Supports for removing a router interface")
-public class RouterInterfaceRemoveCommand extends AbstractShellCommand {
- @Option(name = "-s", aliases = "--subnetId", description = "The subnet identifier of router interface",
- required = true, multiValued = false)
- String subnetId = null;
-
- @Override
- protected void doExecute() {
- RouterInterfaceService service = get(RouterInterfaceService.class);
- try {
- RouterInterface routerInterface = service
- .getRouterInterface(SubnetId.subnetId(subnetId));
- if (routerInterface == null) {
- print(null, "subnet ID of interface doesn't exist");
- return;
- }
- service.removeRouterInterface(routerInterface);
- } catch (Exception e) {
- print(null, e.getMessage());
- }
-
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/routerinterface/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/routerinterface/package-info.java
deleted file mode 100644
index e89b421..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/routerinterface/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Command line interface for router interface.
- */
-package org.onosproject.vtnrsc.cli.routerinterface;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetCreateCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetCreateCommand.java
deleted file mode 100644
index 8a0a034..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetCreateCommand.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.subnet;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.AllocationPool;
-import org.onosproject.vtnrsc.DefaultSubnet;
-import org.onosproject.vtnrsc.HostRoute;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.Subnet.Mode;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for creating a subnet.
- */
-@Service
-@Command(scope = "onos", name = "subnet-create", description = "Supports for creating a subnet")
-public class SubnetCreateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "Subnet Id", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "subnetName", description = "Subnet String name", required = true,
- multiValued = false)
- String subnetName = null;
-
- @Argument(index = 2, name = "networkId", description = "Subnet Network Id", required = true,
- multiValued = false)
- String networkId = null;
-
- @Argument(index = 3, name = "tenantId", description = "Subnet Tenant Id", required = true,
- multiValued = false)
- String tenantId = null;
-
- @Option(name = "-i", aliases = "--ipVersion", description = "Subnet Version ipVersion",
- required = false, multiValued = false)
- Version ipVersion = null;
-
- @Option(name = "-c", aliases = "--cidr", description = "Subnet IpPrefix cidr",
- required = false, multiValued = false)
- String cidr = "0.0.0.0/0";
-
- @Option(name = "-g", aliases = "--gatewayIp", description = "Subnet IpAddress gatewayIp",
- required = false, multiValued = false)
- String gatewayIp = "0.0.0.0";
-
- @Option(name = "-d", aliases = "--dhcpEnabled", description = "Subnet boolean dhcpEnabled",
- required = false, multiValued = false)
- boolean dhcpEnabled = false;
-
- @Option(name = "-s", aliases = "--shared", description = "Subnet boolean shared",
- required = false, multiValued = false)
- boolean shared = false;
-
- @Option(name = "-m", aliases = "--ipV6AddressMode",
- description = "Subnet Mode ipV6AddressMode", required = false, multiValued = false)
- String ipV6AddressMode = null;
-
- @Option(name = "-r", aliases = "--ipV6RaMode", description = "Subnet Mode ipV6RaMode",
- required = false, multiValued = false)
- String ipV6RaMode = null;
-
- @Option(name = "-h", aliases = "--hostRoutes", description = "Subnet jsonnode hostRoutes",
- required = false, multiValued = false)
- Set<HostRoute> hostRoutes = Sets.newHashSet();
-
- @Option(name = "-a", aliases = "--allocationPools",
- description = "Subnet jsonnode allocationPools", required = false, multiValued = false)
- Set<AllocationPool> allocationPools = Sets.newHashSet();
-
- @Override
- protected void doExecute() {
- SubnetService service = get(SubnetService.class);
- if (id == null || networkId == null || tenantId == null) {
- print("id,networkId,tenantId can not be null");
- return;
- }
- Subnet subnet = new DefaultSubnet(SubnetId.subnetId(id), subnetName,
- TenantNetworkId.networkId(networkId),
- TenantId.tenantId(tenantId), ipVersion,
- cidr == null ? null : IpPrefix.valueOf(cidr),
- gatewayIp == null ? null : IpAddress.valueOf(gatewayIp),
- dhcpEnabled, shared, hostRoutes,
- ipV6AddressMode == null ? null : Mode.valueOf(ipV6AddressMode),
- ipV6RaMode == null ? null : Mode.valueOf(ipV6RaMode),
- allocationPools);
-
- Set<Subnet> subnetsSet = Sets.newHashSet(subnet);
- service.createSubnets(subnetsSet);
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetQueryCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetQueryCommand.java
deleted file mode 100644
index 9cc3269..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetQueryCommand.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.subnet;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-
-/**
- * Supports for querying a subnet.
- */
-@Service
-@Command(scope = "onos", name = "subnets", description = "Supports for querying a subnet")
-public class SubnetQueryCommand extends AbstractShellCommand {
-
- @Option(name = "-i", aliases = "--id", description = "Subnet id", required = false,
- multiValued = false)
- String id = null;
-
- private static final String FMT = "subnetId=%s, networkId=%s, subnetName=%s,"
- + "tenantId=%s, cidr=%s, dhcpEnabled=%s, gatewayIp=%s," + "ipVersion=%s";
-
- @Override
- protected void doExecute() {
- SubnetService service = get(SubnetService.class);
- if (id != null) {
- Subnet subnet = service.getSubnet(SubnetId.subnetId(id));
- printSubnet(subnet);
- } else {
- Iterable<Subnet> subnets = service.getSubnets();
- if (subnets == null) {
- return;
- }
- for (Subnet subnet : subnets) {
- printSubnet(subnet);
- }
- }
- }
-
- private void printSubnet(Subnet subnet) {
- print(FMT, subnet.id(), subnet.networkId(), subnet.subnetName(),
- subnet.tenantId(), subnet.cidr(), subnet.dhcpEnabled(), subnet
- .gatewayIp(), subnet.ipVersion());
-
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetRemoveCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetRemoveCommand.java
deleted file mode 100644
index 4955bc9..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetRemoveCommand.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.subnet;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for removing a subnet.
- */
-@Service
-@Command(scope = "onos", name = "subnet-remove", description = "Supports for removing a subnet")
-public class SubnetRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "Subnet SubnetId Id", required = true,
- multiValued = false)
- String id = null;
-
- @Override
- protected void doExecute() {
- SubnetService service = get(SubnetService.class);
- Set<SubnetId> subnetsSet = Sets.newHashSet();
- subnetsSet.add(SubnetId.subnetId(id));
- service.removeSubnets(subnetsSet);
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java
deleted file mode 100644
index 50cfaa2..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.subnet;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.AllocationPool;
-import org.onosproject.vtnrsc.DefaultSubnet;
-import org.onosproject.vtnrsc.HostRoute;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.Subnet.Mode;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for updating a subnet.
- */
-@Service
-@Command(scope = "onos", name = "subnet-update", description = "Supports for updating a subnet")
-public class SubnetUpdateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "Subnet Id", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "subnetName", description = "Subnet String name", required = true,
- multiValued = false)
- String subnetName = null;
-
- @Argument(index = 2, name = "networkId", description = "Subnet Network Id", required = true,
- multiValued = false)
- String networkId = null;
-
- @Argument(index = 3, name = "tenantId", description = "Subnet Tenant Id", required = true,
- multiValued = false)
- String tenantId = null;
-
- @Option(name = "-i", aliases = "--ipVersion", description = "Subnet Version ipVersion",
- required = false, multiValued = false)
- Version ipVersion = null;
-
- @Option(name = "-c", aliases = "--cidr", description = "Subnet IpPrefix cidr", required = false,
- multiValued = false)
- String cidr = "0.0.0.0/0";
-
- @Option(name = "-g", aliases = "--gatewayIp", description = "Subnet IpAddress gatewayIp",
- required = false, multiValued = false)
- String gatewayIp = "0.0.0.0";
-
- @Option(name = "-d", aliases = "--dhcpEnabled", description = "Subnet boolean dhcpEnabled",
- required = false, multiValued = false)
- boolean dhcpEnabled = false;
-
- @Option(name = "-s", aliases = "--shared", description = "Subnet boolean shared", required = false,
- multiValued = false)
- boolean shared = false;
-
- @Option(name = "-m", aliases = "--ipV6AddressMode", description = "Subnet Mode ipV6AddressMode",
- required = false, multiValued = false)
- String ipV6AddressMode = null;
-
- @Option(name = "-r", aliases = "--ipV6RaMode", description = "Subnet Mode ipV6RaMode",
- required = false, multiValued = false)
- String ipV6RaMode = null;
-
- @Option(name = "-h", aliases = "--hostRoutes", description = "Subnet jsonnode hostRoutes",
- required = false, multiValued = false)
- Set<HostRoute> hostRoutes = Sets.newHashSet();
-
- @Option(name = "-a", aliases = "--allocationPools",
- description = "Subnet jsonnode allocationPools", required = false, multiValued = false)
- Set<AllocationPool> allocationPools = Sets.newHashSet();
-
- @Override
- protected void doExecute() {
- SubnetService service = get(SubnetService.class);
- if (id == null || networkId == null || tenantId == null) {
- print("id,networkId,tenantId can not be null");
- return;
- }
- Subnet subnet = new DefaultSubnet(SubnetId.subnetId(id), subnetName,
- TenantNetworkId.networkId(networkId),
- TenantId.tenantId(tenantId), ipVersion,
- cidr == null ? null : IpPrefix.valueOf(cidr),
- gatewayIp == null ? null : IpAddress.valueOf(gatewayIp),
- dhcpEnabled, shared, hostRoutes,
- ipV6AddressMode == null ? null : Mode.valueOf(ipV6AddressMode),
- ipV6RaMode == null ? null : Mode.valueOf(ipV6RaMode),
- allocationPools);
- Set<Subnet> subnetsSet = Sets.newHashSet();
- subnetsSet.add(subnet);
- service.updateSubnets(subnetsSet);
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java
deleted file mode 100644
index cabb4a4..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Command line interface for subnets.
- */
-package org.onosproject.vtnrsc.cli.subnet;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortCreateCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortCreateCommand.java
deleted file mode 100644
index 4bf53ff..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortCreateCommand.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.virtualport;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onlab.packet.MacAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.DefaultVirtualPort;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.SecurityGroup;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-/**
- * Supports for creating a virtualPort.
- */
-@Service
-@Command(scope = "onos", name = "virtualport-create",
- description = "Supports for creating a virtualPort.")
-public class VirtualPortCreateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "virtualPort id.", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "networkId", description = "network id.", required = true,
- multiValued = false)
- String networkId = null;
-
- @Argument(index = 2, name = "name", description = "virtualPort name.", required = true,
- multiValued = false)
- String name = null;
-
- @Argument(index = 3, name = "tenantId", description = "tenant id.", required = true,
- multiValued = false)
- String tenantId = null;
-
- @Argument(index = 4, name = "deviceId", description = "device id.", required = true,
- multiValued = false)
- String deviceId = null;
-
- @Option(name = "-a", aliases = "--adminStateUp",
- description = "administrative status of the virtualPort which is true or false.",
- required = false, multiValued = false)
- Boolean adminStateUp = false;
-
- @Option(name = "-s", aliases = "--state", description = "virtualPort state.", required = false,
- multiValued = false)
- String state = null;
-
- @Option(name = "-m", aliases = "--macAddress", description = "MAC address.", required = false,
- multiValued = false)
- String macAddress = "";
-
- @Option(name = "-d", aliases = "--deviceOwner", description = "ID of the entity that uses this "
- + "virtualPort.", required = false, multiValued = false)
- String deviceOwner = null;
-
- @Option(name = "-f", aliases = "--fixedIp",
- description = "The IP address for the port,include the IP address "
- + "and subnet identity.", required = false, multiValued = false)
- FixedIp fixedIp = null;
-
- @Option(name = "-i", aliases = "--bindingHostId", description = "virtualPort bindingHostId.",
- required = false, multiValued = false)
- String bindingHostId = null;
-
- @Option(name = "-t", aliases = "--bindingvnicType", description = "virtualPort bindingvnicType.",
- required = false, multiValued = false)
- String bindingvnicType = null;
-
- @Option(name = "-v", aliases = "--bindingvifType", description = "virtualPort bindingvifType.",
- required = false, multiValued = false)
- String bindingvifType = null;
-
- @Option(name = "-b", aliases = "--bindingvnicDetails",
- description = "virtualPort bindingvnicDetails.", required = false, multiValued = false)
- String bindingvnicDetails = null;
-
- @Option(name = "-l", aliases = "--allowedAddress", description = "virtual allowedAddressPair.",
- required = false, multiValued = false)
- Set<AllowedAddressPair> allowedAddressPairs = Sets.newHashSet();
-
- @Option(name = "-e", aliases = "--securityGroups", description = "virtualPort securityGroups.",
- required = false, multiValued = false)
- Set<SecurityGroup> securityGroups = Sets.newHashSet();
-
- @Override
- protected void doExecute() {
- Map<String, String> strMap = Maps.newHashMap();
- strMap.putIfAbsent("name", name);
- strMap.putIfAbsent("deviceOwner", deviceOwner);
- strMap.putIfAbsent("bindingvnicType", bindingvnicType);
- strMap.putIfAbsent("bindingvifType", bindingvifType);
- strMap.putIfAbsent("bindingvnicDetails", bindingvnicDetails);
- VirtualPortService service = get(VirtualPortService.class);
- VirtualPort virtualPort = new DefaultVirtualPort(VirtualPortId.portId(id),
- TenantNetworkId.networkId(networkId),
- false, strMap, VirtualPort.State.ACTIVE,
- MacAddress.valueOf(macAddress),
- TenantId.tenantId(tenantId),
- DeviceId.deviceId(deviceId), Sets.newHashSet(fixedIp),
- BindingHostId.bindingHostId(bindingHostId),
- allowedAddressPairs, securityGroups);
- Set<VirtualPort> virtualPorts = Sets.newHashSet(virtualPort);
- service.createPorts(virtualPorts);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortExGwUpdateCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortExGwUpdateCommand.java
deleted file mode 100644
index 113fd44..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortExGwUpdateCommand.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.virtualport;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.DefaultVirtualPort;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-/**
- * Supports for updating the external gateway virtualPort.
- */
-@Service
-@Command(scope = "onos", name = "externalgateway-update",
- description = "Supports for updating the external gateway virtualPort.")
-public class VirtualPortExGwUpdateCommand extends AbstractShellCommand {
-
- @Option(name = "-m", aliases = "--macAddress", description = "MAC address.", required = true,
- multiValued = false)
- String macAddress = "";
-
- @Override
- protected void doExecute() {
- VirtualPortService service = get(VirtualPortService.class);
- SubnetService subnetService = get(SubnetService.class);
- TenantNetworkService tenantNetworkService = get(TenantNetworkService.class);
- Iterable<TenantNetwork> networks = tenantNetworkService.getNetworks();
- if (networks != null) {
- for (TenantNetwork network : networks) {
- if (network.routerExternal()) {
- Iterable<Subnet> subnets = subnetService.getSubnets();
- if (subnets != null) {
- for (Subnet subnet : subnets) {
- if (network.id().networkId().equals(subnet.networkId().networkId())) {
- IpAddress exgwip = subnet.gatewayIp();
- FixedIp fixedGwIp = FixedIp.fixedIp(subnet.id(), exgwip);
- VirtualPort exgwPort = service.getPort(fixedGwIp);
- if (exgwPort == null) {
- createExGwPort(network, subnet, fixedGwIp);
- } else {
- updateExGwPort(exgwPort);
- }
- }
- }
- }
- }
- }
- }
- }
-
- private void createExGwPort(TenantNetwork network, Subnet subnet, FixedIp fixedGwIp) {
- VirtualPortService service = get(VirtualPortService.class);
- Map<String, String> strMap = Maps.newHashMap();
- VirtualPort virtualPort = new DefaultVirtualPort(VirtualPortId.portId("externalgateway-update-id"),
- network.id(),
- false, strMap,
- VirtualPort.State.DOWN,
- MacAddress.valueOf(macAddress),
- subnet.tenantId(),
- DeviceId.deviceId(""),
- Sets.newHashSet(fixedGwIp),
- BindingHostId.bindingHostId(""),
- Sets.newHashSet(),
- Sets.newHashSet());
- Set<VirtualPort> virtualPorts = Sets.newHashSet(virtualPort);
- service.createPorts(virtualPorts);
- }
-
- private void updateExGwPort(VirtualPort exgwPort) {
- VirtualPortService service = get(VirtualPortService.class);
- Map<String, String> strMap = Maps.newHashMap();
- strMap.putIfAbsent("name", exgwPort.name());
- strMap.putIfAbsent("deviceOwner", exgwPort.deviceOwner());
- strMap.putIfAbsent("bindingvnicType", exgwPort.bindingVnicType());
- strMap.putIfAbsent("bindingvifType", exgwPort.bindingVifType());
- strMap.putIfAbsent("bindingvnicDetails", exgwPort.bindingVifDetails());
- VirtualPort virtualPort = new DefaultVirtualPort(exgwPort.portId(),
- exgwPort.networkId(),
- false, strMap,
- VirtualPort.State.DOWN,
- MacAddress.valueOf(macAddress),
- exgwPort.tenantId(),
- exgwPort.deviceId(),
- exgwPort.fixedIps(),
- exgwPort.bindingHostId(),
- Sets.newHashSet(exgwPort
- .allowedAddressPairs()),
- Sets.newHashSet(exgwPort
- .securityGroups()));
- Set<VirtualPort> virtualPorts = Sets.newHashSet(virtualPort);
- service.updatePorts(virtualPorts);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortQueryCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortQueryCommand.java
deleted file mode 100644
index b667dab..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortQueryCommand.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.virtualport;
-
-import java.util.Collection;
-
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-/**
- * Supports for querying virtualPorts.
- */
-@Service
-@Command(scope = "onos", name = "virtualports", description = "Supports for querying virtualPorts.")
-public class VirtualPortQueryCommand extends AbstractShellCommand {
-
- @Option(name = "-v", aliases = "--vPortId", description = "virtualPort ID.", required = false,
- multiValued = false)
- String vPortId;
-
- @Option(name = "-n", aliases = "--networkId", description = "network ID.", required = false,
- multiValued = false)
- String networkId;
-
- @Option(name = "-d", aliases = "--deviceId", description = "device ID.", required = false,
- multiValued = false)
- String deviceId;
-
- @Option(name = "-t", aliases = "--tenantId", description = "tenant ID.", required = false,
- multiValued = false)
- String tenantId;
-
- private static final String FMT = "virtualPortId=%s, networkId=%s, name=%s,"
- + " tenantId=%s, deviceId=%s, adminStateUp=%s, state=%s,"
- + " macAddress=%s, deviceOwner=%s, fixedIp=%s, bindingHostId=%s,"
- + " bindingvnicType=%s, bindingvifType=%s, bindingvnicDetails=%s,"
- + " allowedAddress=%s, securityGroups=%s";
-
- @Override
- protected void doExecute() {
- VirtualPortService service = get(VirtualPortService.class);
- if (vPortId != null && networkId == null && deviceId == null && tenantId == null) {
- VirtualPort port = service.getPort(VirtualPortId.portId(vPortId));
- printPort(port);
- } else if (vPortId == null && networkId != null && deviceId == null && tenantId == null) {
- Collection<VirtualPort> ports = service.getPorts(TenantNetworkId.networkId(networkId));
- printPorts(ports);
- } else if (vPortId == null && networkId == null && deviceId != null && tenantId == null) {
- Collection<VirtualPort> ports = service.getPorts(DeviceId.deviceId(deviceId));
- printPorts(ports);
- } else if (vPortId == null && networkId == null && deviceId == null && tenantId != null) {
- Collection<VirtualPort> ports = service.getPorts(DeviceId.deviceId(tenantId));
- printPorts(ports);
- } else if (vPortId == null && networkId == null && deviceId == null) {
- Collection<VirtualPort> ports = service.getPorts();
- printPorts(ports);
- } else {
- print("cannot input more than one parameter");
- }
-
- }
-
- private void printPorts(Collection<VirtualPort> ports) {
- for (VirtualPort port : ports) {
- printPort(port);
- }
- }
-
- private void printPort(VirtualPort port) {
- print(FMT, port.portId(), port.networkId(), port.name(), port.tenantId(), port.deviceId(),
- port.adminStateUp(), port.state(), port.macAddress(), port.deviceOwner(), port
- .fixedIps(), port.bindingHostId(), port.bindingVnicType(),
- port.bindingVifType(), port.bindingVifDetails(), port.allowedAddressPairs(),
- port.securityGroups());
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortRemoveCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortRemoveCommand.java
deleted file mode 100644
index 4984099..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortRemoveCommand.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.virtualport;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for removing a virtualPort.
- */
-@Service
-@Command(scope = "onos", name = "virtualport-remove",
- description = "Supports for removing a virtualPort.")
-public class VirtualPortRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "virtualPort id.", required = true,
- multiValued = false)
- String id = null;
-
- @Override
- protected void doExecute() {
- VirtualPortService service = get(VirtualPortService.class);
- Set<VirtualPortId> virtualPorts = Sets.newHashSet(VirtualPortId.portId(id));
- service.removePorts(virtualPorts);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortUpdateCommand.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortUpdateCommand.java
deleted file mode 100644
index 6cd7791..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortUpdateCommand.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.virtualport;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onlab.packet.MacAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.DefaultVirtualPort;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.SecurityGroup;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-/**
- * Supports for updating a virtualPort.
- */
-@Service
-@Command(scope = "onos", name = "virtualport-update",
- description = "Supports for updating a virtualPort.")
-public class VirtualPortUpdateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "virtualPort id.", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "networkId", description = "network id.", required = true,
- multiValued = false)
- String networkId = null;
-
- @Argument(index = 2, name = "name", description = "virtualPort name.", required = true,
- multiValued = false)
- String name = null;
-
- @Argument(index = 3, name = "tenantId", description = "tenant id.", required = true,
- multiValued = false)
- String tenantId = null;
-
- @Argument(index = 4, name = "deviceId", description = "device id.", required = true,
- multiValued = false)
- String deviceId = null;
-
- @Option(name = "-a", aliases = "--adminStateUp",
- description = "administrative status of the virtualPort which is true or false.",
- required = false, multiValued = false)
- Boolean adminStateUp = false;
-
- @Option(name = "-s", aliases = "--state", description = "virtualPort state.", required = false,
- multiValued = false)
- String state = null;
-
- @Option(name = "-m", aliases = "--macAddress", description = "MAC address.", required = false,
- multiValued = false)
- String macAddress = "";
-
- @Option(name = "-d", aliases = "--deviceOwner",
- description = "ID of the entity that uses this " + "virtualPort.", required = false,
- multiValued = false)
- String deviceOwner = null;
-
- @Option(name = "-f", aliases = "--fixedIp",
- description = "The IP address for the port,include the IP address "
- + "and subnet identity.", required = false, multiValued = false)
- FixedIp fixedIp = null;
-
- @Option(name = "-i", aliases = "--bindingHostId", description = "virtualPort bindingHostId.",
- required = false, multiValued = false)
- String bindingHostId = "";
-
- @Option(name = "-t", aliases = "--bindingvnicType",
- description = "virtualPort bindingvnicType.", required = false, multiValued = false)
- String bindingvnicType = null;
-
- @Option(name = "-v", aliases = "--bindingvifType", description = "virtualPort bindingvifType.",
- required = false, multiValued = false)
- String bindingvifType = null;
-
- @Option(name = "-b", aliases = "--bindingvnicDetails",
- description = "virtualPort bindingvnicDetails.", required = false, multiValued = false)
- String bindingvnicDetails = null;
-
- @Option(name = "-l", aliases = "--allowedAddress", description = "virtual allowedAddressPair.",
- required = false, multiValued = false)
- Set<AllowedAddressPair> allowedAddressPairs = Sets.newHashSet();
-
- @Option(name = "-e", aliases = "--securityGroups", description = "virtualPort securityGroups.",
- required = false, multiValued = false)
- Set<SecurityGroup> securityGroups = Sets.newHashSet();
-
- @Override
- protected void doExecute() {
- VirtualPortService service = get(VirtualPortService.class);
- Map<String, String> strMap = Maps.newHashMap();
- strMap.putIfAbsent("name", name);
- strMap.putIfAbsent("deviceOwner", deviceOwner);
- strMap.putIfAbsent("bindingvnicType", bindingvnicType);
- strMap.putIfAbsent("bindingvifType", bindingvifType);
- strMap.putIfAbsent("bindingvnicDetails", bindingvnicDetails);
- VirtualPort virtualPort = new DefaultVirtualPort(VirtualPortId.portId(id),
- TenantNetworkId.networkId(networkId),
- false, strMap, VirtualPort.State.ACTIVE,
- MacAddress.valueOf(macAddress),
- TenantId.tenantId(tenantId),
- DeviceId.deviceId(deviceId), Sets.newHashSet(fixedIp),
- BindingHostId.bindingHostId(bindingHostId),
- allowedAddressPairs, securityGroups);
- Set<VirtualPort> virtualPorts = Sets.newHashSet(virtualPort);
- service.updatePorts(virtualPorts);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java
deleted file mode 100644
index aef5c22..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Command line interface for virtual ports.
- */
-package org.onosproject.vtnrsc.cli.virtualport;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/event/VtnRscEvent.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/event/VtnRscEvent.java
deleted file mode 100644
index 0c8dc64..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/event/VtnRscEvent.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.event;
-
-import org.onosproject.event.AbstractEvent;
-
-
-/**
- * Describes network vtnrsc event.
- */
-public class VtnRscEvent
- extends AbstractEvent<VtnRscEvent.Type, VtnRscEventFeedback> {
-
- /**
- * Type of vtnrsc events.
- */
- public enum Type {
- /**
- * Signifies that floating IP has create.
- */
- FLOATINGIP_PUT,
- /**
- * Signifies that floating IP has delete.
- */
- FLOATINGIP_DELETE,
- /**
- * Signifies that Floating IP has been bound.
- */
- FLOATINGIP_BIND,
- /**
- * Signifies that Floating IP has been unbound.
- */
- FLOATINGIP_UNBIND,
- /**
- * Signifies that router has create.
- */
- ROUTER_PUT,
- /**
- * Signifies that router has delete.
- */
- ROUTER_DELETE,
- /**
- * Signifies that router interface has add.
- */
- ROUTER_INTERFACE_PUT,
- /**
- * Signifies that router interface has remove.
- */
- ROUTER_INTERFACE_DELETE,
- /**
- * Signifies that port-pair has add.
- */
- PORT_PAIR_PUT,
- /**
- * Signifies that port-pair has remove.
- */
- PORT_PAIR_DELETE,
- /**
- * Signifies that port-pair has update.
- */
- PORT_PAIR_UPDATE,
- /**
- * Signifies that port-pair-group has add.
- */
- PORT_PAIR_GROUP_PUT,
- /**
- * Signifies that port-pair-group has remove.
- */
- PORT_PAIR_GROUP_DELETE,
- /**
- * Signifies that port-pair-group has update.
- */
- PORT_PAIR_GROUP_UPDATE,
- /**
- * Signifies that flow-classifier has add.
- */
- FLOW_CLASSIFIER_PUT,
- /**
- * Signifies that flow-classifier has remove.
- */
- FLOW_CLASSIFIER_DELETE,
- /**
- * Signifies that flow-classifier has update.
- */
- FLOW_CLASSIFIER_UPDATE,
- /**
- * Signifies that port-chain has add.
- */
- PORT_CHAIN_PUT,
- /**
- * Signifies that port-chain has remove.
- */
- PORT_CHAIN_DELETE,
- /**
- * Signifies that port-chain has update.
- */
- PORT_CHAIN_UPDATE,
- /**
- * Signifies that virtual-port has created.
- */
- VIRTUAL_PORT_PUT,
- /**
- * Signifies that virtual-port has removed.
- */
- VIRTUAL_PORT_DELETE
- }
-
- /**
- * Creates an event of a given type and for the specified vtn event feedback.
- *
- * @param type Vtnrsc event type
- * @param vtnFeedback event VtnrscEventFeedback subject
- */
- public VtnRscEvent(Type type, VtnRscEventFeedback vtnFeedback) {
- super(type, vtnFeedback);
- }
-
- /**
- * Creates an event of a given type and for the specified vtn event feedback.
- *
- * @param type Vtnrsc event type
- * @param vtnFeedback event VtnrscEventFeedback subject
- * @param time occurrence time
- */
- public VtnRscEvent(Type type, VtnRscEventFeedback vtnFeedback, long time) {
- super(type, vtnFeedback, time);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/event/VtnRscEventFeedback.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/event/VtnRscEventFeedback.java
deleted file mode 100644
index 1e3f849..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/event/VtnRscEventFeedback.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.event;
-
-import java.util.Objects;
-
-import org.onosproject.vtnrsc.FloatingIp;
-import org.onosproject.vtnrsc.Router;
-import org.onosproject.vtnrsc.RouterInterface;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.VirtualPort;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Representation of a VtnRsc event feedback.
- */
-public class VtnRscEventFeedback {
- private final FloatingIp floaingtIp;
- private final Router router;
- private final RouterInterface routerInterface;
- private final PortPair portPair;
- private final PortPairGroup portPairGroup;
- private final FlowClassifier flowClassifier;
- private final PortChain portChain;
- private final VirtualPort virtualPort;
-
- /**
- * Creates VtnRscEventFeedback object.
- *
- * @param floatingIp the floating Ip
- */
- public VtnRscEventFeedback(FloatingIp floatingIp) {
- this.floaingtIp = checkNotNull(floatingIp, "floaintIp cannot be null");
- this.router = null;
- this.routerInterface = null;
- this.portPair = null;
- this.portPairGroup = null;
- this.flowClassifier = null;
- this.portChain = null;
- this.virtualPort = null;
- }
-
- /**
- * Creates VtnRscEventFeedback object.
- *
- * @param router the router
- */
- public VtnRscEventFeedback(Router router) {
- this.floaingtIp = null;
- this.router = checkNotNull(router, "router cannot be null");
- this.routerInterface = null;
- this.portPair = null;
- this.portPairGroup = null;
- this.flowClassifier = null;
- this.portChain = null;
- this.virtualPort = null;
- }
-
- /**
- * Creates VtnRscEventFeedback object.
- *
- * @param routerInterface the router interface
- */
- public VtnRscEventFeedback(RouterInterface routerInterface) {
- this.floaingtIp = null;
- this.router = null;
- this.routerInterface = checkNotNull(routerInterface,
- "routerInterface cannot be null");
- this.portPair = null;
- this.portPairGroup = null;
- this.flowClassifier = null;
- this.portChain = null;
- this.virtualPort = null;
- }
-
- /**
- * Creates VtnRscEventFeedback object.
- *
- * @param portPair the Port-Pair
- */
- public VtnRscEventFeedback(PortPair portPair) {
- this.floaingtIp = null;
- this.router = null;
- this.routerInterface = null;
- this.portPair = checkNotNull(portPair,
- "Port-Pair cannot be null");
- this.portPairGroup = null;
- this.flowClassifier = null;
- this.portChain = null;
- this.virtualPort = null;
- }
-
- /**
- * Creates VtnRscEventFeedback object.
- *
- * @param portPairGroup the Port-Pair-Group
- */
- public VtnRscEventFeedback(PortPairGroup portPairGroup) {
- this.floaingtIp = null;
- this.router = null;
- this.routerInterface = null;
- this.portPair = null;
- this.portPairGroup = checkNotNull(portPairGroup,
- "Port-Pair-Group cannot be null");
- this.flowClassifier = null;
- this.portChain = null;
- this.virtualPort = null;
- }
-
- /**
- * Creates VtnRscEventFeedback object.
- *
- * @param flowClassifier the Flow-Classifier
- */
- public VtnRscEventFeedback(FlowClassifier flowClassifier) {
- this.floaingtIp = null;
- this.router = null;
- this.routerInterface = null;
- this.portPair = null;
- this.portPairGroup = null;
- this.flowClassifier = checkNotNull(flowClassifier,
- "Flow-Classifier cannot be null");
- this.portChain = null;
- this.virtualPort = null;
- }
-
- /**
- * Creates VtnRscEventFeedback object.
- *
- * @param portChain the Port-Chain
- */
- public VtnRscEventFeedback(PortChain portChain) {
- this.floaingtIp = null;
- this.router = null;
- this.routerInterface = null;
- this.portPair = null;
- this.portPairGroup = null;
- this.flowClassifier = null;
- this.portChain = checkNotNull(portChain,
- "Port-Chain cannot be null");
- this.virtualPort = null;
- }
-
- /**
- * Creates VtnRscEventFeedback object.
- *
- * @param virtualPort the Virtual-Port
- */
- public VtnRscEventFeedback(VirtualPort virtualPort) {
- this.floaingtIp = null;
- this.router = null;
- this.routerInterface = null;
- this.portPair = null;
- this.portPairGroup = null;
- this.flowClassifier = null;
- this.portChain = null;
- this.virtualPort = checkNotNull(virtualPort,
- "Virtual-port cannot be null");
- }
-
- /**
- * Returns floating IP.
- *
- * @return floaingtIp the floating IP
- */
- public FloatingIp floatingIp() {
- return floaingtIp;
- }
-
- /**
- * Returns router.
- *
- * @return router the router
- */
- public Router router() {
- return router;
- }
-
- /**
- * Returns router interface.
- *
- * @return routerInterface the router interface
- */
- public RouterInterface routerInterface() {
- return routerInterface;
- }
-
- /**
- * Returns Port-Pair.
- *
- * @return portPair the Port-Pair
- */
- public PortPair portPair() {
- return portPair;
- }
-
- /**
- * Returns Port-Pair-Group.
- *
- * @return portPairGroup the Port-Pair-Group
- */
- public PortPairGroup portPairGroup() {
- return portPairGroup;
- }
-
- /**
- * Returns Flow-Classifier.
- *
- * @return flowClassifier the Flow-Classifier
- */
- public FlowClassifier flowClassifier() {
- return flowClassifier;
- }
-
- /**
- * Returns Port-Chain.
- *
- * @return portChain the Port-Chain
- */
- public PortChain portChain() {
- return portChain;
- }
-
- /**
- * Returns Virtual-Port.
- *
- * @return virtualPort the Virtual-Port
- */
- public VirtualPort virtualPort() {
- return virtualPort;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(floaingtIp, router, routerInterface, portPair,
- portPairGroup, flowClassifier, portChain, virtualPort);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof VtnRscEventFeedback) {
- final VtnRscEventFeedback that = (VtnRscEventFeedback) obj;
- return Objects.equals(this.floaingtIp, that.floaingtIp)
- && Objects.equals(this.router, that.router)
- && Objects.equals(this.routerInterface, that.routerInterface)
- && Objects.equals(this.portPair, that.portPair)
- && Objects.equals(this.portPairGroup, that.portPairGroup)
- && Objects.equals(this.flowClassifier, that.flowClassifier)
- && Objects.equals(this.portChain, that.portChain)
- && Objects.equals(this.virtualPort, that.virtualPort);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("router", router)
- .add("floaingtIp", floaingtIp)
- .add("routerInterface", routerInterface)
- .add("portPair", portPair)
- .add("portPairGroup", portPairGroup)
- .add("flowClassifier", flowClassifier)
- .add("portChain", portChain)
- .add("virtualPort", virtualPort)
- .toString();
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/event/VtnRscListener.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/event/VtnRscListener.java
deleted file mode 100644
index 0ae4e31..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/event/VtnRscListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.vtnrsc.event;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Entity capable of VtnRsc related events.
- */
-public interface VtnRscListener extends EventListener<VtnRscEvent> {
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/event/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/event/package-info.java
deleted file mode 100644
index 9e7adb0..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/event/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Event of VtnRsc for VtnRsc service.
- */
-package org.onosproject.vtnrsc.event;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/FloatingIpEvent.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/FloatingIpEvent.java
deleted file mode 100644
index 2bbd329..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/FloatingIpEvent.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.floatingip;
-
-import org.onosproject.event.AbstractEvent;
-import org.onosproject.vtnrsc.FloatingIp;
-
-/**
- * Describes network Floating IP event.
- */
-public class FloatingIpEvent
- extends AbstractEvent<FloatingIpEvent.Type, FloatingIp> {
- /**
- * Type of Floating IP events.
- */
- public enum Type {
- /**
- * Signifies that Floating IP has been created.
- */
- FLOATINGIP_PUT,
- /**
- * Signifies that Floating IP has been deleted.
- */
- FLOATINGIP_DELETE,
- /**
- * Signifies that Floating IP has been bound.
- */
- FLOATINGIP_BIND,
- /**
- * Signifies that Floating IP has been unbound.
- */
- FLOATINGIP_UNBIND
- }
-
- /**
- * Creates an event of a given type and for the specified Floating IP.
- *
- * @param type Floating IP event type
- * @param floagingIp Floating IP subject
- */
- public FloatingIpEvent(Type type, FloatingIp floagingIp) {
- super(type, floagingIp);
- }
-
- /**
- * Creates an event of a given type and for the specified Floating IP.
- *
- * @param type Floating IP event type
- * @param floagingIp Floating IP subject
- * @param time occurrence time
- */
- public FloatingIpEvent(Type type, FloatingIp floagingIp, long time) {
- super(type, floagingIp, time);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/FloatingIpListener.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/FloatingIpListener.java
deleted file mode 100644
index b650f4c..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/FloatingIpListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.floatingip;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Entity capable of Floating IP related events.
- */
-public interface FloatingIpListener extends EventListener<FloatingIpEvent> {
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/FloatingIpService.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/FloatingIpService.java
deleted file mode 100644
index 307c6c4..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/FloatingIpService.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.floatingip;
-
-import java.util.Collection;
-
-import org.onlab.packet.IpAddress;
-import org.onosproject.vtnrsc.FloatingIp;
-import org.onosproject.vtnrsc.FloatingIpId;
-import org.onosproject.vtnrsc.TenantId;
-
-/**
- * Service for interacting with the inventory of floating IP.
- */
-public interface FloatingIpService {
- /**
- * Returns exists or not of specific floatingIp identifier.
- *
- * @param floatingIpId floatingIp identifier
- * @return true or false
- */
- boolean exists(FloatingIpId floatingIpId);
-
- /**
- * Returns is used or not of specific floating IP address.
- *
- * @param floatingIpAddr floatingIp address
- * @param floatingIpId floatingIp identifier
- * @return true or false
- */
- boolean floatingIpIsUsed(IpAddress floatingIpAddr, FloatingIpId floatingIpId);
-
- /**
- * Returns is used or not of specific fixed IP address.
- *
- * @param fixedIpAddr fixedIp address
- * @param tenantId the tenant identifier of floating IP
- * @param floatingIpId floatingIp identifier
- * @return true or false
- */
- boolean fixedIpIsUsed(IpAddress fixedIpAddr, TenantId tenantId, FloatingIpId floatingIpId);
-
- /**
- * Returns a collection of the currently known floating IP.
- *
- * @return collection of floating IP
- */
- Collection<FloatingIp> getFloatingIps();
-
- /**
- * Returns the floatingIp with the specified identifier.
- *
- * @param floatingIpId floatingIp identifier
- * @return floatingIp or null if one with the given identifier is not known
- */
- FloatingIp getFloatingIp(FloatingIpId floatingIpId);
-
- /**
- * Creates new floatingIps.
- *
- * @param floatingIps the collection of floatingIp
- * @return true if the identifier floatingIp has been created right
- */
- boolean createFloatingIps(Collection<FloatingIp> floatingIps);
-
- /**
- * Updates existing floatingIps.
- *
- * @param floatingIps the collection of floatingIp
- * @return true if all floatingIp were updated successfully
- */
- boolean updateFloatingIps(Collection<FloatingIp> floatingIps);
-
- /**
- * Removes the specified floatingIp from the store.
- *
- * @param floatingIpIds the collection of floatingIp identifier
- * @return true if remove identifier floatingIp successfully
- */
- boolean removeFloatingIps(Collection<FloatingIpId> floatingIpIds);
-
- /**
- * Adds the specified listener to floating Ip manager.
- *
- * @param listener floating Ip listener
- */
- void addListener(FloatingIpListener listener);
-
- /**
- * Removes the specified listener to floating Ip manager.
- *
- * @param listener floating Ip listener
- */
- void removeListener(FloatingIpListener listener);
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/impl/FloatingIpManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/impl/FloatingIpManager.java
deleted file mode 100644
index 196d889..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/impl/FloatingIpManager.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.floatingip.impl;
-
-import com.google.common.collect.Sets;
-import org.onlab.packet.IpAddress;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.EventuallyConsistentMapEvent;
-import org.onosproject.store.service.EventuallyConsistentMapListener;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.onosproject.vtnrsc.DefaultFloatingIp;
-import org.onosproject.vtnrsc.FloatingIp;
-import org.onosproject.vtnrsc.FloatingIpId;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.floatingip.FloatingIpEvent;
-import org.onosproject.vtnrsc.floatingip.FloatingIpListener;
-import org.onosproject.vtnrsc.floatingip.FloatingIpService;
-import org.onosproject.vtnrsc.router.RouterService;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-import java.util.UUID;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the FloatingIp service.
- */
-@Component(immediate = true, service = FloatingIpService.class)
-public class FloatingIpManager implements FloatingIpService {
- private static final String FLOATINGIP_ID_NOT_NULL = "Floatingip ID cannot be null";
- private static final String FLOATINGIP_NOT_NULL = "Floatingip cannot be null";
- private static final String FLOATINGIPSTORE = "vtn-floatingip-store";
- private static final String FLOATINGIPBINDSTORE = "vtn-floatingip-bind-store";
- private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
- private static final String LISTENER_NOT_NULL = "Listener cannot be null";
- private static final String EVENT_NOT_NULL = "event cannot be null";
-
- private final Logger log = getLogger(getClass());
- private final Set<FloatingIpListener> listeners = Sets
- .newCopyOnWriteArraySet();
- private EventuallyConsistentMapListener<FloatingIpId, FloatingIp> floatingIpListener =
- new InnerFloatingIpStoreListener();
- protected EventuallyConsistentMap<FloatingIpId, FloatingIp> floatingIpStore;
- protected EventuallyConsistentMap<FloatingIpId, FloatingIp> floatingIpBindStore;
- protected ApplicationId appId;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TenantNetworkService tenantNetworkService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected VirtualPortService virtualPortService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected RouterService routerService;
-
- @Activate
- public void activate() {
- appId = coreService.registerApplication(VTNRSC_APP);
- KryoNamespace.Builder serializer = KryoNamespace
- .newBuilder()
- .register(KryoNamespaces.API)
- .register(FloatingIp.class, FloatingIpId.class,
- TenantNetworkId.class, TenantId.class,
- FloatingIp.Status.class, RouterId.class,
- VirtualPortId.class, DefaultFloatingIp.class,
- UUID.class);
- floatingIpStore = storageService
- .<FloatingIpId, FloatingIp>eventuallyConsistentMapBuilder()
- .withName(FLOATINGIPSTORE).withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp())
- .build();
- floatingIpBindStore = storageService
- .<FloatingIpId, FloatingIp>eventuallyConsistentMapBuilder()
- .withName(FLOATINGIPBINDSTORE).withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp())
- .build();
- floatingIpStore.addListener(floatingIpListener);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- floatingIpStore.removeListener(floatingIpListener);
- floatingIpStore.destroy();
- floatingIpBindStore.destroy();
- listeners.clear();
- log.info("Stopped");
- }
-
- @Override
- public Collection<FloatingIp> getFloatingIps() {
- return Collections.unmodifiableCollection(floatingIpStore.values());
- }
-
- @Override
- public FloatingIp getFloatingIp(FloatingIpId floatingIpId) {
- checkNotNull(floatingIpId, FLOATINGIP_ID_NOT_NULL);
- return floatingIpStore.get(floatingIpId);
- }
-
- @Override
- public boolean exists(FloatingIpId floatingIpId) {
- checkNotNull(floatingIpId, FLOATINGIP_ID_NOT_NULL);
- return floatingIpStore.containsKey(floatingIpId);
- }
-
- @Override
- public boolean floatingIpIsUsed(IpAddress floatingIpAddr,
- FloatingIpId floatingIpId) {
- checkNotNull(floatingIpAddr, "Floating IP address cannot be null");
- checkNotNull(floatingIpId, "Floating IP Id cannot be null");
- Collection<FloatingIp> floatingIps = getFloatingIps();
- for (FloatingIp floatingIp : floatingIps) {
- if (floatingIp.floatingIp().equals(floatingIpAddr)
- && !floatingIp.id().equals(floatingIpId)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public boolean fixedIpIsUsed(IpAddress fixedIpAddr, TenantId tenantId,
- FloatingIpId floatingIpId) {
- checkNotNull(fixedIpAddr, "Fixed IP address cannot be null");
- checkNotNull(tenantId, "Tenant Id cannot be null");
- checkNotNull(floatingIpId, "Floating IP Id cannot be null");
- Collection<FloatingIp> floatingIps = getFloatingIps();
- for (FloatingIp floatingIp : floatingIps) {
- IpAddress fixedIp = floatingIp.fixedIp();
- if (fixedIp != null) {
- if (fixedIp.equals(fixedIpAddr)
- && floatingIp.tenantId().equals(tenantId)
- && !floatingIp.id().equals(floatingIpId)) {
- return true;
- }
- }
- }
- return false;
- }
-
- @Override
- public boolean createFloatingIps(Collection<FloatingIp> floatingIps) {
- checkNotNull(floatingIps, FLOATINGIP_NOT_NULL);
- boolean result = true;
- for (FloatingIp floatingIp : floatingIps) {
- verifyFloatingIpData(floatingIp);
- floatingIpStore.put(floatingIp.id(), floatingIp);
- if (!floatingIpStore.containsKey(floatingIp.id())) {
- log.debug("The floating Ip is created failed whose identifier is {}",
- floatingIp.id().toString());
- result = false;
- }
- }
- return result;
- }
-
- @Override
- public boolean updateFloatingIps(Collection<FloatingIp> floatingIps) {
- checkNotNull(floatingIps, FLOATINGIP_NOT_NULL);
- boolean result = true;
- for (FloatingIp floatingIp : floatingIps) {
- verifyFloatingIpData(floatingIp);
- FloatingIp oldFloatingIp = floatingIpStore.get(floatingIp.id());
- floatingIpBindStore.put(floatingIp.id(), oldFloatingIp);
- floatingIpStore.put(floatingIp.id(), floatingIp);
- if (!floatingIpStore.containsKey(floatingIp.id())) {
- log.debug("The floating Ip is updated failed whose identifier is {}",
- floatingIp.id().toString());
- result = false;
- }
- }
- return result;
- }
-
- @Override
- public boolean removeFloatingIps(Collection<FloatingIpId> floatingIpIds) {
- checkNotNull(floatingIpIds, FLOATINGIP_ID_NOT_NULL);
- boolean result = true;
- for (FloatingIpId floatingIpId : floatingIpIds) {
- if (!floatingIpStore.containsKey(floatingIpId)) {
- log.debug("The floatingIp is not exist whose identifier is {}",
- floatingIpId.toString());
- throw new IllegalArgumentException(
- "FloatingIP ID doesn't exist");
- }
- FloatingIp floatingIp = floatingIpStore.get(floatingIpId);
- floatingIpStore.remove(floatingIpId, floatingIp);
- floatingIpBindStore.remove(floatingIpId);
- if (floatingIpStore.containsKey(floatingIpId)) {
- log.debug("The floating Ip is deleted failed whose identifier is {}",
- floatingIpId.toString());
- result = false;
- }
- }
- return result;
- }
-
- @Override
- public void addListener(FloatingIpListener listener) {
- checkNotNull(listener, LISTENER_NOT_NULL);
- listeners.add(listener);
- }
-
- @Override
- public void removeListener(FloatingIpListener listener) {
- checkNotNull(listener, LISTENER_NOT_NULL);
- listeners.remove(listener);
- }
-
- /**
- * Verifies validity of FloatingIp data.
- *
- * @param floatingIps floatingIp instance
- */
- private void verifyFloatingIpData(FloatingIp floatingIps) {
- checkNotNull(floatingIps, FLOATINGIP_NOT_NULL);
- if (!tenantNetworkService.exists(floatingIps.networkId())) {
- log.debug("The network identifier {} that the floating Ip {} create for is not exist",
- floatingIps.networkId().toString(), floatingIps.id()
- .toString());
- throw new IllegalArgumentException(
- "Floating network ID doesn't exist");
- }
-
- VirtualPortId portId = floatingIps.portId();
- if (portId != null && !virtualPortService.exists(portId)) {
- log.debug("The port identifier {} that the floating Ip {} create for is not exist",
- floatingIps.portId().toString(), floatingIps.id()
- .toString());
- throw new IllegalArgumentException("Port ID doesn't exist");
- }
-
- RouterId routerId = floatingIps.routerId();
- if (routerId != null && !routerService.exists(routerId)) {
- log.debug("The router identifier {} that the floating Ip {} create for is not exist",
- floatingIps.routerId().toString(), floatingIps.id()
- .toString());
- throw new IllegalArgumentException("Router ID doesn't exist");
- }
-
- if (floatingIpIsUsed(floatingIps.floatingIp(), floatingIps.id())) {
- log.debug("The floaing Ip {} that the floating Ip {} create for is used",
- floatingIps.floatingIp().toString(), floatingIps.id()
- .toString());
- throw new IllegalArgumentException(
- "The floating IP address is used");
- }
-
- IpAddress fixedIp = floatingIps.fixedIp();
- if (fixedIp != null
- && fixedIpIsUsed(fixedIp, floatingIps.tenantId(),
- floatingIps.id())) {
- log.debug("The fixed Ip {} that the floating Ip {} create for is used",
- floatingIps.fixedIp().toString(), floatingIps.id()
- .toString());
- throw new IllegalArgumentException("The fixed IP address is used");
- }
- }
-
- private class InnerFloatingIpStoreListener
- implements
- EventuallyConsistentMapListener<FloatingIpId, FloatingIp> {
-
- @Override
- public void event(EventuallyConsistentMapEvent<FloatingIpId, FloatingIp> event) {
- checkNotNull(event, EVENT_NOT_NULL);
- FloatingIp floatingIp = event.value();
- if (EventuallyConsistentMapEvent.Type.PUT == event.type()) {
- notifyListeners(new FloatingIpEvent(
- FloatingIpEvent.Type.FLOATINGIP_PUT,
- floatingIp));
- if (floatingIp.portId() != null) {
- notifyListeners(new FloatingIpEvent(
- FloatingIpEvent.Type.FLOATINGIP_BIND,
- floatingIp));
- } else {
- FloatingIp oldFloatingIp = floatingIpBindStore.get(floatingIp.id());
- if (oldFloatingIp != null) {
- notifyListeners(new FloatingIpEvent(
- FloatingIpEvent.Type.FLOATINGIP_UNBIND,
- oldFloatingIp));
- }
- }
- }
- if (EventuallyConsistentMapEvent.Type.REMOVE == event.type()) {
- notifyListeners(new FloatingIpEvent(
- FloatingIpEvent.Type.FLOATINGIP_DELETE,
- floatingIp));
- if (floatingIp.portId() != null) {
- notifyListeners(new FloatingIpEvent(
- FloatingIpEvent.Type.FLOATINGIP_UNBIND,
- floatingIp));
- }
- }
- }
- }
-
- /**
- * Notifies specify event to all listeners.
- *
- * @param event Floating IP event
- */
- private void notifyListeners(FloatingIpEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- listeners.forEach(listener -> listener.event(event));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/impl/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/impl/package-info.java
deleted file mode 100644
index c632e99..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of the FloatingIp service.
- */
-package org.onosproject.vtnrsc.floatingip.impl;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/package-info.java
deleted file mode 100644
index b17b9c0..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/floatingip/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with the inventory of FloatingIp.
- */
-package org.onosproject.vtnrsc.floatingip;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierEvent.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierEvent.java
deleted file mode 100644
index 463a208..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierEvent.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.flowclassifier;
-
-import org.onosproject.event.AbstractEvent;
-import org.onosproject.vtnrsc.FlowClassifier;
-
-/**
- * Describes network Flow-Classifier event.
- */
-public class FlowClassifierEvent extends AbstractEvent<FlowClassifierEvent.Type, FlowClassifier> {
- /**
- * Type of flow-classifier events.
- */
- public enum Type {
- /**
- * Signifies that flow-classifier has been created.
- */
- FLOW_CLASSIFIER_PUT,
- /**
- * Signifies that flow-classifier has been deleted.
- */
- FLOW_CLASSIFIER_DELETE,
- /**
- * Signifies that flow-classifier has been updated.
- */
- FLOW_CLASSIFIER_UPDATE
- }
-
- /**
- * Creates an event of a given type and for the specified Flow-Classifier.
- *
- * @param type Flow-Classifier event type
- * @param flowClassifier Flow-Classifier subject
- */
- public FlowClassifierEvent(Type type, FlowClassifier flowClassifier) {
- super(type, flowClassifier);
- }
-
- /**
- * Creates an event of a given type and for the specified Flow-Classifier.
- *
- * @param type Flow-Classifier event type
- * @param flowClassifier Flow-Classifier subject
- * @param time occurrence time
- */
- public FlowClassifierEvent(Type type, FlowClassifier flowClassifier, long time) {
- super(type, flowClassifier, time);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierListener.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierListener.java
deleted file mode 100644
index eedbac1..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.flowclassifier;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Entity capable of Flow-Classifier related events.
- */
-public interface FlowClassifierListener extends EventListener<FlowClassifierEvent> {
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierService.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierService.java
deleted file mode 100644
index 0924bb9..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierService.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.flowclassifier;
-
-import org.onosproject.event.ListenerService;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifierId;
-
-/**
- * Provides Services for Flow Classifier.
- */
-public interface FlowClassifierService extends ListenerService<FlowClassifierEvent, FlowClassifierListener> {
-
- /**
- * Check whether Flow Classifier is present based on given Flow Classifier
- * Id.
- *
- * @param id flow classifier identifier
- * @return true if flow classifier is present otherwise return false
- */
- boolean exists(FlowClassifierId id);
-
- /**
- * Returns the number of flow classifiers known to the system.
- *
- * @return number of flow classifiers
- */
- int getFlowClassifierCount();
-
- /**
- * Store Flow Classifier.
- *
- * @param flowClassifier flow classifier
- * @return true if adding flow classifier into store is success otherwise
- * return false
- */
- boolean createFlowClassifier(FlowClassifier flowClassifier);
-
- /**
- * Return the existing collection of Flow Classifier.
- *
- * @return flow classifier collections
- */
- Iterable<FlowClassifier> getFlowClassifiers();
-
- /**
- * Retrieve the Flow Classifier based on given Flow Classifier id.
- *
- * @param id flow classifier identifier
- * @return flow classifier if present otherwise returns null
- */
- FlowClassifier getFlowClassifier(FlowClassifierId id);
-
- /**
- * Update Flow Classifier based on given Flow Classifier Id.
- *
- * @param flowClassifier flow classifier
- * @return true if flow classifier update is success otherwise return false
- */
- boolean updateFlowClassifier(FlowClassifier flowClassifier);
-
- /**
- * Remove Flow Classifier from store based on given Flow Classifier Id.
- *
- * @param id flow classifier identifier
- * @return true if flow classifier removal is success otherwise return
- * false
- */
- boolean removeFlowClassifier(FlowClassifierId id);
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManager.java
deleted file mode 100644
index 216a2c5..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManager.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.flowclassifier.impl;
-
-import com.google.common.collect.ImmutableList;
-import org.onlab.packet.IpPrefix;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.event.AbstractListenerManager;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.EventuallyConsistentMapEvent;
-import org.onosproject.store.service.EventuallyConsistentMapListener;
-import org.onosproject.store.service.MultiValuedTimestamp;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.onosproject.vtnrsc.DefaultFlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.flowclassifier.FlowClassifierEvent;
-import org.onosproject.vtnrsc.flowclassifier.FlowClassifierListener;
-import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.UUID;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the Flow Classifier Service.
- */
-@Component(immediate = true, service = FlowClassifierService.class)
-public class FlowClassifierManager extends AbstractListenerManager<FlowClassifierEvent, FlowClassifierListener>
- implements FlowClassifierService {
-
- private static final String FLOW_CLASSIFIER_NOT_NULL = "Flow Classifier cannot be null";
- private static final String FLOW_CLASSIFIER_ID_NOT_NULL = "Flow Classifier Id cannot be null";
- private static final String LISTENER_NOT_NULL = "Listener cannot be null";
- private static final String EVENT_NOT_NULL = "event cannot be null";
-
- private final Logger log = getLogger(FlowClassifierManager.class);
-
- private EventuallyConsistentMap<FlowClassifierId, FlowClassifier> flowClassifierStore;
-
- private EventuallyConsistentMapListener<FlowClassifierId, FlowClassifier> flowClassifierListener =
- new InnerFlowClassifierStoreListener();
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Activate
- protected void activate() {
- eventDispatcher.addSink(FlowClassifierEvent.class, listenerRegistry);
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API)
- .register(MultiValuedTimestamp.class)
- .register(FlowClassifier.class, FlowClassifierId.class, UUID.class, IpPrefix.class,
- VirtualPortId.class, DefaultFlowClassifier.class, TenantId.class);
- flowClassifierStore = storageService
- .<FlowClassifierId, FlowClassifier>eventuallyConsistentMapBuilder()
- .withName("flowclassifierstore").withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
- flowClassifierStore.addListener(flowClassifierListener);
- log.info("Flow Classifier service activated");
- }
-
- @Deactivate
- protected void deactivate() {
- eventDispatcher.removeSink(FlowClassifierEvent.class);
- flowClassifierStore.destroy();
- log.info("Flow Classifier service deactivated");
- }
-
- @Override
- public boolean exists(FlowClassifierId id) {
- checkNotNull(id, FLOW_CLASSIFIER_ID_NOT_NULL);
- return flowClassifierStore.containsKey(id);
- }
-
- @Override
- public int getFlowClassifierCount() {
- return flowClassifierStore.size();
- }
-
- @Override
- public Iterable<FlowClassifier> getFlowClassifiers() {
- return ImmutableList.copyOf(flowClassifierStore.values());
- }
-
- @Override
- public FlowClassifier getFlowClassifier(FlowClassifierId id) {
- checkNotNull(id, FLOW_CLASSIFIER_ID_NOT_NULL);
- return flowClassifierStore.get(id);
- }
-
- @Override
- public boolean createFlowClassifier(FlowClassifier flowClassifier) {
- log.debug("createFlowClassifier");
- checkNotNull(flowClassifier, FLOW_CLASSIFIER_NOT_NULL);
- FlowClassifierId id = flowClassifier.flowClassifierId();
-
- flowClassifierStore.put(id, flowClassifier);
- if (!flowClassifierStore.containsKey(id)) {
- log.debug("Flow Classifier creation is failed whose identifier is {}.", id.toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean updateFlowClassifier(FlowClassifier flowClassifier) {
- checkNotNull(flowClassifier, FLOW_CLASSIFIER_NOT_NULL);
-
- if (!flowClassifierStore.containsKey(flowClassifier.flowClassifierId())) {
- log.debug("The flowClassifier is not exist whose identifier was {} ", flowClassifier.flowClassifierId()
- .toString());
- return false;
- }
-
- flowClassifierStore.put(flowClassifier.flowClassifierId(), flowClassifier);
-
- if (!flowClassifier.equals(flowClassifierStore.get(flowClassifier.flowClassifierId()))) {
- log.debug("Updation of flowClassifier is failed whose identifier was {} ", flowClassifier
- .flowClassifierId().toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removeFlowClassifier(FlowClassifierId id) {
- checkNotNull(id, FLOW_CLASSIFIER_ID_NOT_NULL);
- flowClassifierStore.remove(id);
- if (flowClassifierStore.containsKey(id)) {
- log.debug("The Flow Classifier removal is failed whose identifier is {}", id.toString());
- return false;
- }
- return true;
- }
-
- private class InnerFlowClassifierStoreListener
- implements
- EventuallyConsistentMapListener<FlowClassifierId, FlowClassifier> {
-
- @Override
- public void event(EventuallyConsistentMapEvent<FlowClassifierId, FlowClassifier> event) {
- checkNotNull(event, EVENT_NOT_NULL);
- FlowClassifier flowClassifier = event.value();
- if (EventuallyConsistentMapEvent.Type.PUT == event.type()) {
- notifyListeners(new FlowClassifierEvent(
- FlowClassifierEvent.Type.FLOW_CLASSIFIER_PUT,
- flowClassifier));
- }
- if (EventuallyConsistentMapEvent.Type.REMOVE == event.type()) {
- notifyListeners(new FlowClassifierEvent(
- FlowClassifierEvent.Type.FLOW_CLASSIFIER_DELETE,
- flowClassifier));
- }
- }
- }
-
- /**
- * Notifies specify event to all listeners.
- *
- * @param event flow classifier event
- */
- private void notifyListeners(FlowClassifierEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- post(event);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/package-info.java
deleted file mode 100644
index abcbe8b..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of the flow Classifier service.
- */
-package org.onosproject.vtnrsc.flowclassifier.impl;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/package-info.java
deleted file mode 100644
index ea4aca2..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with flow Classifier of SFC.
- */
-package org.onosproject.vtnrsc.flowclassifier;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/package-info.java
deleted file mode 100644
index 1e663dd..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN resources that used by virtual tenant network.
- */
-package org.onosproject.vtnrsc;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/PortChainEvent.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/PortChainEvent.java
deleted file mode 100644
index bbc7c0f..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/PortChainEvent.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portchain;
-
-import org.onosproject.event.AbstractEvent;
-import org.onosproject.vtnrsc.PortChain;
-
-/**
- * Describes network Port-Chain event.
- */
-public class PortChainEvent extends AbstractEvent<PortChainEvent.Type, PortChain> {
- /**
- * Type of port-chain events.
- */
- public enum Type {
- /**
- * Signifies that port-chain has been created.
- */
- PORT_CHAIN_PUT,
- /**
- * Signifies that port-chain has been deleted.
- */
- PORT_CHAIN_DELETE,
- /**
- * Signifies that port-chain has been updated.
- */
- PORT_CHAIN_UPDATE
- }
-
- /**
- * Creates an event of a given type and for the specified Port-Chain.
- *
- * @param type Port-Chain event type
- * @param portChain Port-Chain subject
- */
- public PortChainEvent(Type type, PortChain portChain) {
- super(type, portChain);
- }
-
- /**
- * Creates an event of a given type and for the specified Port-Chain.
- *
- * @param type Port-Chain event type
- * @param portChain Port-Chain subject
- * @param time occurrence time
- */
- public PortChainEvent(Type type, PortChain portChain, long time) {
- super(type, portChain, time);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/PortChainListener.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/PortChainListener.java
deleted file mode 100644
index 9448ebd..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/PortChainListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portchain;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Entity capable of Port-Chain related events.
- */
-public interface PortChainListener extends EventListener<PortChainEvent> {
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/PortChainService.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/PortChainService.java
deleted file mode 100644
index 3b8727c..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/PortChainService.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portchain;
-
-import org.onosproject.event.ListenerService;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-
-/**
- * Service for interacting with the inventory of port chains.
- */
-public interface PortChainService extends ListenerService<PortChainEvent, PortChainListener> {
-
- /**
- * Returns if the port chain is existed.
- *
- * @param portChainId port chain identifier
- * @return true or false if one with the given identifier exists.
- */
- boolean exists(PortChainId portChainId);
-
- /**
- * Returns the number of port chains known to the system.
- *
- * @return number of port chains.
- */
- int getPortChainCount();
-
- /**
- * Returns an iterable collection of the currently known port chains.
- *
- * @return collection of port chains.
- */
- Iterable<PortChain> getPortChains();
-
- /**
- * Returns the portChain with the given identifier.
- *
- * @param portChainId port chain identifier
- * @return PortChain or null if port chain with the given identifier is not
- * known.
- */
- PortChain getPortChain(PortChainId portChainId);
-
- /**
- * Creates a PortChain in the store.
- *
- * @param portChain the port chain to create
- * @return true if given port chain is created successfully.
- */
- boolean createPortChain(PortChain portChain);
-
- /**
- * Updates the portChain in the store.
- *
- * @param portChain the port chain to update
- * @return true if given port chain is updated successfully.
- */
- boolean updatePortChain(PortChain portChain);
-
- /**
- * Deletes portChain by given portChainId.
- *
- * @param portChainId id of port chain to remove
- * @return true if the give port chain is deleted successfully.
- */
- boolean removePortChain(PortChainId portChainId);
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/impl/PortChainManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/impl/PortChainManager.java
deleted file mode 100644
index 6aa6bf3..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/impl/PortChainManager.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portchain.impl;
-
-import org.onlab.util.KryoNamespace;
-import org.onosproject.event.AbstractListenerManager;
-import org.onosproject.net.DeviceId;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.EventuallyConsistentMapEvent;
-import org.onosproject.store.service.EventuallyConsistentMapListener;
-import org.onosproject.store.service.MultiValuedTimestamp;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.onosproject.vtnrsc.DefaultPortChain;
-import org.onosproject.vtnrsc.FiveTuple;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.LoadBalanceId;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.portchain.PortChainEvent;
-import org.onosproject.vtnrsc.portchain.PortChainListener;
-import org.onosproject.vtnrsc.portchain.PortChainService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.Collections;
-import java.util.UUID;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the portChainService.
- */
-@Component(immediate = true, service = PortChainService.class)
-public class PortChainManager extends AbstractListenerManager<PortChainEvent, PortChainListener> implements
- PortChainService {
-
- private static final String PORT_CHAIN_ID_NULL = "PortChain ID cannot be null";
- private static final String PORT_CHAIN_NULL = "PortChain cannot be null";
- private static final String EVENT_NOT_NULL = "event cannot be null";
-
- private final Logger log = getLogger(getClass());
- private EventuallyConsistentMap<PortChainId, PortChain> portChainStore;
-
- private EventuallyConsistentMapListener<PortChainId, PortChain> portChainListener =
- new InnerPortChainStoreListener();
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Activate
- public void activate() {
-
- eventDispatcher.addSink(PortChainEvent.class, listenerRegistry);
-
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API)
- .register(MultiValuedTimestamp.class)
- .register(PortChain.class, PortChainId.class, UUID.class, PortPairGroupId.class,
- FlowClassifierId.class, FiveTuple.class, LoadBalanceId.class, DeviceId.class,
- DefaultPortChain.class, PortPairId.class, TenantId.class);
-
- portChainStore = storageService
- .<PortChainId, PortChain>eventuallyConsistentMapBuilder()
- .withName("portchainstore").withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
-
- portChainStore.addListener(portChainListener);
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- eventDispatcher.removeSink(PortChainEvent.class);
- portChainStore.removeListener(portChainListener);
- portChainStore.destroy();
- log.info("Stopped");
- }
-
- @Override
- public boolean exists(PortChainId portChainId) {
- checkNotNull(portChainId, PORT_CHAIN_ID_NULL);
- return portChainStore.containsKey(portChainId);
- }
-
- @Override
- public int getPortChainCount() {
- return portChainStore.size();
- }
-
- @Override
- public Iterable<PortChain> getPortChains() {
- return Collections.unmodifiableCollection(portChainStore.values());
- }
-
- @Override
- public PortChain getPortChain(PortChainId portChainId) {
- checkNotNull(portChainId, PORT_CHAIN_ID_NULL);
- return portChainStore.get(portChainId);
- }
-
- @Override
- public boolean createPortChain(PortChain portChain) {
- checkNotNull(portChain, PORT_CHAIN_NULL);
-
- portChainStore.put(portChain.portChainId(), portChain);
- if (!portChainStore.containsKey(portChain.portChainId())) {
- log.error("The portChain created is failed which identifier was {}", portChain.portChainId()
- .toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean updatePortChain(PortChain portChain) {
- checkNotNull(portChain, PORT_CHAIN_NULL);
- PortChain oldPortChain = null;
- if (!portChainStore.containsKey(portChain.portChainId())) {
- log.warn("The portChain is not exist whose identifier was {} ",
- portChain.portChainId().toString());
- return false;
- } else {
- oldPortChain = portChainStore.get(portChain.portChainId());
- }
- PortChain newPortChain = DefaultPortChain.create(portChain, oldPortChain);
- portChainStore.put(newPortChain.portChainId(), newPortChain);
-
- if (!newPortChain.equals(portChainStore.get(newPortChain.portChainId()))) {
- log.debug("The portChain is updated failed whose identifier was {} ",
- newPortChain.portChainId().toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removePortChain(PortChainId portChainId) {
- checkNotNull(portChainId, PORT_CHAIN_NULL);
-
- portChainStore.remove(portChainId);
- if (portChainStore.containsKey(portChainId)) {
- log.debug("The portChain is removed failed whose identifier was {}",
- portChainId.toString());
- return false;
- }
- return true;
- }
-
- private class InnerPortChainStoreListener
- implements
- EventuallyConsistentMapListener<PortChainId, PortChain> {
-
- @Override
- public void event(EventuallyConsistentMapEvent<PortChainId, PortChain> event) {
- checkNotNull(event, EVENT_NOT_NULL);
- PortChain portChain = event.value();
- if (EventuallyConsistentMapEvent.Type.PUT == event.type()) {
- notifyListeners(new PortChainEvent(
- PortChainEvent.Type.PORT_CHAIN_PUT,
- portChain));
- }
- if (EventuallyConsistentMapEvent.Type.REMOVE == event.type()) {
- notifyListeners(new PortChainEvent(
- PortChainEvent.Type.PORT_CHAIN_DELETE,
- portChain));
- }
- }
- }
-
- /**
- * Notifies specify event to all listeners.
- *
- * @param event port chain event
- */
- private void notifyListeners(PortChainEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- post(event);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/impl/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/impl/package-info.java
deleted file mode 100644
index 84ac7d7..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of service for interacting with the inventory of port chains.
- */
-package org.onosproject.vtnrsc.portchain.impl;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/package-info.java
deleted file mode 100644
index 896e646..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with the inventory of port chains.
- */
-package org.onosproject.vtnrsc.portchain;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchainsfmap/PortChainSfMapService.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchainsfmap/PortChainSfMapService.java
deleted file mode 100644
index 33189e0..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchainsfmap/PortChainSfMapService.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portchainsfmap;
-
-import java.util.List;
-
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.ServiceFunctionGroup;
-
-/**
- * Service for interacting with the inventory of service functions for a given port chain.
- */
-public interface PortChainSfMapService {
-
- /**
- * Returns true if the port chain exists.
- *
- * @param portChainId port chain identifier
- * @return true or false if one with the given identifier exists.
- */
- boolean exists(PortChainId portChainId);
-
- /**
- * Returns the list of service function groups available in the given port chain.
- *
- * @param portChainId port chain id
- * @return list of service functions
- */
- List<ServiceFunctionGroup> getServiceFunctions(PortChainId portChainId);
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchainsfmap/impl/PortChainSfMapManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchainsfmap/impl/PortChainSfMapManager.java
deleted file mode 100644
index 78737b3..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchainsfmap/impl/PortChainSfMapManager.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portchainsfmap.impl;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.ServiceFunctionGroup;
-import org.onosproject.vtnrsc.portchain.PortChainService;
-import org.onosproject.vtnrsc.portchainsfmap.PortChainSfMapService;
-import org.onosproject.vtnrsc.portpair.PortPairService;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the PortChainSfMapService.
- * A port pair group is nothing but group of similar service functions.
- * A port pair is nothing but a service function.
- */
-@Component(immediate = true, service = PortChainSfMapService.class)
-public class PortChainSfMapManager implements PortChainSfMapService {
-
- private static final String PORT_CHAIN_ID_NULL = "PortChain ID cannot be null";
-
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PortChainService portChainService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PortPairGroupService portPairGroupService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PortPairService portPairService;
-
- @Activate
- public void activate() {
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public boolean exists(PortChainId portChainId) {
- checkNotNull(portChainId, PORT_CHAIN_ID_NULL);
- return portChainService.exists(portChainId);
- }
-
- @Override
- public List<ServiceFunctionGroup> getServiceFunctions(PortChainId portChainId) {
- List<ServiceFunctionGroup> serviceFunctionGroupList = Lists.newArrayList();
- PortChain portChain = portChainService.getPortChain(portChainId);
- // Go through the port pair group list
- List<PortPairGroupId> portPairGrpList = portChain.portPairGroups();
- ListIterator<PortPairGroupId> listGrpIterator = portPairGrpList.listIterator();
-
- while (listGrpIterator.hasNext()) {
- PortPairGroupId portPairGroupId = listGrpIterator.next();
- PortPairGroup portPairGroup = portPairGroupService.getPortPairGroup(portPairGroupId);
- ServiceFunctionGroup sfg = new ServiceFunctionGroup(portPairGroup.name(), portPairGroup.description(),
- portPairGroup.portPairLoadMap());
- serviceFunctionGroupList.add(sfg);
- }
- return ImmutableList.copyOf(serviceFunctionGroupList);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchainsfmap/impl/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchainsfmap/impl/package-info.java
deleted file mode 100644
index dd75dbc..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchainsfmap/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with the inventory of port chains to get details of service functions and stats.
- */
-package org.onosproject.vtnrsc.portchainsfmap.impl;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchainsfmap/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchainsfmap/package-info.java
deleted file mode 100644
index 1fb4183..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchainsfmap/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with the inventory of port chains to get details of service functions and stats.
- */
-package org.onosproject.vtnrsc.portchainsfmap;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/PortPairEvent.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/PortPairEvent.java
deleted file mode 100644
index b08b0b2..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/PortPairEvent.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portpair;
-
-import org.onosproject.event.AbstractEvent;
-import org.onosproject.vtnrsc.PortPair;
-
-/**
- * Describes network Port-Pair event.
- */
-public class PortPairEvent extends AbstractEvent<PortPairEvent.Type, PortPair> {
- /**
- * Type of port-pair events.
- */
- public enum Type {
- /**
- * Signifies that port-pair has been created.
- */
- PORT_PAIR_PUT,
- /**
- * Signifies that port-pair has been deleted.
- */
- PORT_PAIR_DELETE,
- /**
- * Signifies that port-pair has been updated.
- */
- PORT_PAIR_UPDATE
- }
-
- /**
- * Creates an event of a given type and for the specified Port-Pair.
- *
- * @param type Port-Pair event type
- * @param portPair Port-Pair subject
- */
- public PortPairEvent(Type type, PortPair portPair) {
- super(type, portPair);
- }
-
- /**
- * Creates an event of a given type and for the specified Port-Pair.
- *
- * @param type Port-Pair event type
- * @param portPair Port-Pair subject
- * @param time occurrence time
- */
- public PortPairEvent(Type type, PortPair portPair, long time) {
- super(type, portPair, time);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/PortPairListener.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/PortPairListener.java
deleted file mode 100644
index 75d9dc9..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/PortPairListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portpair;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Entity capable of Port-Pair related events.
- */
-public interface PortPairListener extends EventListener<PortPairEvent> {
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/PortPairService.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/PortPairService.java
deleted file mode 100644
index add238f..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/PortPairService.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portpair;
-
-import org.onosproject.event.ListenerService;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairId;
-/**
- * Service for interacting with the inventory of port pairs.
- */
-public interface PortPairService extends ListenerService<PortPairEvent, PortPairListener> {
-
- /**
- * Returns if the port pair is existed.
- *
- * @param portPairId port pair identifier
- * @return true or false if one with the given identifier exists.
- */
- boolean exists(PortPairId portPairId);
-
- /**
- * Returns the number of port pairs known to the system.
- *
- * @return number of port pairs.
- */
- int getPortPairCount();
-
- /**
- * Returns an iterable collection of the currently known port pairs.
- *
- * @return collection of port pairs.
- */
- Iterable<PortPair> getPortPairs();
-
- /**
- * Returns the portPair with the given identifier.
- *
- * @param portPairId port pair identifier
- * @return PortPair or null if port pair with the given identifier is not
- * known.
- */
- PortPair getPortPair(PortPairId portPairId);
-
- /**
- * Creates a PortPair in the store.
- *
- * @param portPair the port pair to create
- * @return true if given port pair is created successfully.
- */
- boolean createPortPair(PortPair portPair);
-
- /**
- * Updates the portPair in the store.
- *
- * @param portPair the port pair to update
- * @return true if given port pair is updated successfully.
- */
- boolean updatePortPair(PortPair portPair);
-
- /**
- * Deletes portPair by given portPairId.
- *
- * @param portPairId id of port pair to remove
- * @return true if the give port pair is deleted successfully.
- */
- boolean removePortPair(PortPairId portPairId);
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/impl/PortPairManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/impl/PortPairManager.java
deleted file mode 100644
index 47dbe1c..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/impl/PortPairManager.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portpair.impl;
-
-import org.onlab.util.KryoNamespace;
-import org.onosproject.event.AbstractListenerManager;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.EventuallyConsistentMapEvent;
-import org.onosproject.store.service.EventuallyConsistentMapListener;
-import org.onosproject.store.service.MultiValuedTimestamp;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.onosproject.vtnrsc.DefaultPortPair;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.portpair.PortPairEvent;
-import org.onosproject.vtnrsc.portpair.PortPairListener;
-import org.onosproject.vtnrsc.portpair.PortPairService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.Collections;
-import java.util.UUID;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the portPairService.
- */
-@Component(immediate = true, service = PortPairService.class)
-public class PortPairManager extends AbstractListenerManager<PortPairEvent, PortPairListener> implements
- PortPairService {
-
- private static final String PORT_PAIR_ID_NULL = "PortPair ID cannot be null";
- private static final String PORT_PAIR_NULL = "PortPair cannot be null";
- private static final String LISTENER_NOT_NULL = "Listener cannot be null";
- private static final String EVENT_NOT_NULL = "event cannot be null";
-
- private final Logger log = getLogger(getClass());
-
- private EventuallyConsistentMap<PortPairId, PortPair> portPairStore;
-
- private EventuallyConsistentMapListener<PortPairId, PortPair> portPairListener =
- new InnerPortPairStoreListener();
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Activate
- public void activate() {
-
- eventDispatcher.addSink(PortPairEvent.class, listenerRegistry);
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API)
- .register(MultiValuedTimestamp.class)
- .register(PortPair.class, PortPairId.class, UUID.class, DefaultPortPair.class, TenantId.class);
-
- portPairStore = storageService.<PortPairId, PortPair>eventuallyConsistentMapBuilder()
- .withName("portpairstore")
- .withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp())
- .build();
-
- portPairStore.addListener(portPairListener);
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- eventDispatcher.removeSink(PortPairEvent.class);
- portPairStore.destroy();
- log.info("Stopped");
- }
-
- @Override
- public boolean exists(PortPairId portPairId) {
- checkNotNull(portPairId, PORT_PAIR_ID_NULL);
- return portPairStore.containsKey(portPairId);
- }
-
- @Override
- public int getPortPairCount() {
- return portPairStore.size();
- }
-
- @Override
- public Iterable<PortPair> getPortPairs() {
- return Collections.unmodifiableCollection(portPairStore.values());
- }
-
- @Override
- public PortPair getPortPair(PortPairId portPairId) {
- checkNotNull(portPairId, PORT_PAIR_ID_NULL);
- return portPairStore.get(portPairId);
- }
-
- @Override
- public boolean createPortPair(PortPair portPair) {
- checkNotNull(portPair, PORT_PAIR_NULL);
-
- portPairStore.put(portPair.portPairId(), portPair);
- if (!portPairStore.containsKey(portPair.portPairId())) {
- log.debug("The portPair is created failed which identifier was {}", portPair.portPairId().toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean updatePortPair(PortPair portPair) {
- checkNotNull(portPair, PORT_PAIR_NULL);
-
- if (!portPairStore.containsKey(portPair.portPairId())) {
- log.debug("The portPair is not exist whose identifier was {} ", portPair.portPairId().toString());
- return false;
- }
-
- portPairStore.put(portPair.portPairId(), portPair);
-
- if (!portPair.equals(portPairStore.get(portPair.portPairId()))) {
- log.debug("The portPair is updated failed whose identifier was {} ", portPair.portPairId().toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removePortPair(PortPairId portPairId) {
- checkNotNull(portPairId, PORT_PAIR_NULL);
-
- portPairStore.remove(portPairId);
- if (portPairStore.containsKey(portPairId)) {
- log.debug("The portPair is removed failed whose identifier was {}", portPairId.toString());
- return false;
- }
- return true;
- }
-
- private class InnerPortPairStoreListener
- implements
- EventuallyConsistentMapListener<PortPairId, PortPair> {
-
- @Override
- public void event(EventuallyConsistentMapEvent<PortPairId, PortPair> event) {
- checkNotNull(event, EVENT_NOT_NULL);
- PortPair portPair = event.value();
- if (EventuallyConsistentMapEvent.Type.PUT == event.type()) {
- notifyListeners(new PortPairEvent(
- PortPairEvent.Type.PORT_PAIR_PUT,
- portPair));
- }
- if (EventuallyConsistentMapEvent.Type.REMOVE == event.type()) {
- notifyListeners(new PortPairEvent(
- PortPairEvent.Type.PORT_PAIR_DELETE,
- portPair));
- }
- }
- }
-
- /**
- * Notifies specify event to all listeners.
- *
- * @param event port pair event
- */
- private void notifyListeners(PortPairEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- post(event);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/impl/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/impl/package-info.java
deleted file mode 100644
index f4b5583..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of service for interacting with the inventory of port pairs.
- */
-package org.onosproject.vtnrsc.portpair.impl;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/package-info.java
deleted file mode 100644
index 449c3bd..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with the inventory of port pairs.
- */
-package org.onosproject.vtnrsc.portpair;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupEvent.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupEvent.java
deleted file mode 100644
index 917e6dc..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupEvent.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portpairgroup;
-
-import org.onosproject.event.AbstractEvent;
-import org.onosproject.vtnrsc.PortPairGroup;
-
-/**
- * Describes network Port-Pair-Group event.
- */
-public class PortPairGroupEvent extends AbstractEvent<PortPairGroupEvent.Type, PortPairGroup> {
- /**
- * Type of port-pair-group events.
- */
- public enum Type {
- /**
- * Signifies that port-pair-group has been created.
- */
- PORT_PAIR_GROUP_PUT,
- /**
- * Signifies that port-pair-group has been deleted.
- */
- PORT_PAIR_GROUP_DELETE,
- /**
- * Signifies that port-pair-group has been updated.
- */
- PORT_PAIR_GROUP_UPDATE
- }
-
- /**
- * Creates an event of a given type and for the specified Port-Pair-Group.
- *
- * @param type Port-Pair-Group event type
- * @param portPairGroup Port-Pair-Group subject
- */
- public PortPairGroupEvent(Type type, PortPairGroup portPairGroup) {
- super(type, portPairGroup);
- }
-
- /**
- * Creates an event of a given type and for the specified Port-Pair-Group.
- *
- * @param type Port-Pair-Group event type
- * @param portPairGroup Port-Pair-Group subject
- * @param time occurrence time
- */
- public PortPairGroupEvent(Type type, PortPairGroup portPairGroup, long time) {
- super(type, portPairGroup, time);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupListener.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupListener.java
deleted file mode 100644
index e591be4..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portpairgroup;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Entity capable of Port-Pair-Group related events.
- */
-public interface PortPairGroupListener extends EventListener<PortPairGroupEvent> {
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupService.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupService.java
deleted file mode 100644
index f78dccf..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupService.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portpairgroup;
-
-import org.onosproject.event.ListenerService;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-
-/**
- * Service for interacting with the inventory of port pair groups.
- */
-public interface PortPairGroupService extends ListenerService<PortPairGroupEvent, PortPairGroupListener> {
-
- /**
- * Returns if the port pair group is existed.
- *
- * @param portPairGroupId port pair group identifier
- * @return true or false if one with the given identifier exists.
- */
- boolean exists(PortPairGroupId portPairGroupId);
-
- /**
- * Returns the number of port pair groups known to the system.
- *
- * @return number of port pair groups.
- */
- int getPortPairGroupCount();
-
- /**
- * Returns an iterable collection of the currently known port pair groups.
- *
- * @return collection of port pair groups.
- */
- Iterable<PortPairGroup> getPortPairGroups();
-
- /**
- * Returns the portPairGroup with the given identifier.
- *
- * @param portPairGroupId port pair group identifier
- * @return PortPairGroup or null if port pair group with the given identifier is not
- * known.
- */
- PortPairGroup getPortPairGroup(PortPairGroupId portPairGroupId);
-
- /**
- * Creates a PortPairGroup in the store.
- *
- * @param portPairGroup the port pair group to create
- * @return true if given port pair group is created successfully.
- */
- boolean createPortPairGroup(PortPairGroup portPairGroup);
-
- /**
- * Updates the portPairGroup in the store.
- *
- * @param portPairGroup the port pair group to update
- * @return true if given port pair group is updated successfully.
- */
- boolean updatePortPairGroup(PortPairGroup portPairGroup);
-
- /**
- * Deletes portPairGroup by given portPairGroupId.
- *
- * @param portPairGroupId id of port pair group to remove
- * @return true if the give port pair group is deleted successfully.
- */
- boolean removePortPairGroup(PortPairGroupId portPairGroupId);
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/impl/PortPairGroupManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/impl/PortPairGroupManager.java
deleted file mode 100644
index f5ff8e8..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/impl/PortPairGroupManager.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portpairgroup.impl;
-
-import org.onlab.util.KryoNamespace;
-import org.onosproject.event.AbstractListenerManager;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.EventuallyConsistentMapEvent;
-import org.onosproject.store.service.EventuallyConsistentMapListener;
-import org.onosproject.store.service.MultiValuedTimestamp;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.onosproject.vtnrsc.DefaultPortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupEvent;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupListener;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.Collections;
-import java.util.UUID;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the portPairGroupService.
- */
-@Component(immediate = true, service = PortPairGroupService.class)
-public class PortPairGroupManager extends AbstractListenerManager<PortPairGroupEvent, PortPairGroupListener> implements
- PortPairGroupService {
-
- private static final String PORT_PAIR_GROUP_ID_NULL = "PortPairGroup ID cannot be null";
- private static final String PORT_PAIR_GROUP_NULL = "PortPairGroup cannot be null";
- private static final String LISTENER_NOT_NULL = "Listener cannot be null";
- private static final String EVENT_NOT_NULL = "event cannot be null";
-
- private final Logger log = getLogger(getClass());
-
- private EventuallyConsistentMap<PortPairGroupId, PortPairGroup> portPairGroupStore;
-
- private EventuallyConsistentMapListener<PortPairGroupId, PortPairGroup> portPairGroupListener =
- new InnerPortPairGroupStoreListener();
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Activate
- public void activate() {
- eventDispatcher.addSink(PortPairGroupEvent.class, listenerRegistry);
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API)
- .register(MultiValuedTimestamp.class)
- .register(PortPairGroup.class, PortPairGroupId.class, UUID.class, DefaultPortPairGroup.class,
- TenantId.class, PortPairId.class);
-
- portPairGroupStore = storageService
- .<PortPairGroupId, PortPairGroup>eventuallyConsistentMapBuilder()
- .withName("portpairgroupstore").withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp()).build();
-
- portPairGroupStore.addListener(portPairGroupListener);
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- eventDispatcher.removeSink(PortPairGroupEvent.class);
- portPairGroupStore.destroy();
- log.info("Stopped");
- }
-
- @Override
- public boolean exists(PortPairGroupId portPairGroupId) {
- checkNotNull(portPairGroupId, PORT_PAIR_GROUP_ID_NULL);
- return portPairGroupStore.containsKey(portPairGroupId);
- }
-
- @Override
- public int getPortPairGroupCount() {
- return portPairGroupStore.size();
- }
-
- @Override
- public Iterable<PortPairGroup> getPortPairGroups() {
- return Collections.unmodifiableCollection(portPairGroupStore.values());
- }
-
- @Override
- public PortPairGroup getPortPairGroup(PortPairGroupId portPairGroupId) {
- checkNotNull(portPairGroupId, PORT_PAIR_GROUP_ID_NULL);
- return portPairGroupStore.get(portPairGroupId);
- }
-
- @Override
- public boolean createPortPairGroup(PortPairGroup portPairGroup) {
- checkNotNull(portPairGroup, PORT_PAIR_GROUP_NULL);
-
- portPairGroupStore.put(portPairGroup.portPairGroupId(), portPairGroup);
- if (!portPairGroupStore.containsKey(portPairGroup.portPairGroupId())) {
- log.debug("The portPairGroup is created failed which identifier was {}", portPairGroup.portPairGroupId()
- .toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean updatePortPairGroup(PortPairGroup portPairGroup) {
- checkNotNull(portPairGroup, PORT_PAIR_GROUP_NULL);
-
- if (!portPairGroupStore.containsKey(portPairGroup.portPairGroupId())) {
- log.debug("The portPairGroup is not exist whose identifier was {} ",
- portPairGroup.portPairGroupId().toString());
- return false;
- }
-
- portPairGroupStore.put(portPairGroup.portPairGroupId(), portPairGroup);
-
- if (!portPairGroup.equals(portPairGroupStore.get(portPairGroup.portPairGroupId()))) {
- log.debug("The portPairGroup is updated failed whose identifier was {} ",
- portPairGroup.portPairGroupId().toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removePortPairGroup(PortPairGroupId portPairGroupId) {
- checkNotNull(portPairGroupId, PORT_PAIR_GROUP_NULL);
-
- portPairGroupStore.remove(portPairGroupId);
- if (portPairGroupStore.containsKey(portPairGroupId)) {
- log.debug("The portPairGroup is removed failed whose identifier was {}",
- portPairGroupId.toString());
- return false;
- }
- return true;
- }
-
-
- private class InnerPortPairGroupStoreListener
- implements
- EventuallyConsistentMapListener<PortPairGroupId, PortPairGroup> {
-
- @Override
- public void event(EventuallyConsistentMapEvent<PortPairGroupId, PortPairGroup> event) {
- checkNotNull(event, EVENT_NOT_NULL);
- PortPairGroup portPairGroup = event.value();
- if (EventuallyConsistentMapEvent.Type.PUT == event.type()) {
- notifyListeners(new PortPairGroupEvent(
- PortPairGroupEvent.Type.PORT_PAIR_GROUP_PUT,
- portPairGroup));
- }
- if (EventuallyConsistentMapEvent.Type.REMOVE == event.type()) {
- notifyListeners(new PortPairGroupEvent(
- PortPairGroupEvent.Type.PORT_PAIR_GROUP_DELETE,
- portPairGroup));
- }
- }
- }
-
- /**
- * Notifies specify event to all listeners.
- *
- * @param event PortPairGroup event
- */
- private void notifyListeners(PortPairGroupEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- post(event);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/impl/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/impl/package-info.java
deleted file mode 100644
index 1286ca7..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of service for interacting with the inventory of port pair groups.
- */
-package org.onosproject.vtnrsc.portpairgroup.impl;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/package-info.java
deleted file mode 100644
index 506448e..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with the inventory of port pair groups.
- */
-package org.onosproject.vtnrsc.portpairgroup;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/RouterEvent.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/RouterEvent.java
deleted file mode 100644
index cacbf0d..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/RouterEvent.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.router;
-
-import org.onosproject.event.AbstractEvent;
-import org.onosproject.vtnrsc.Router;
-
-/**
- * Describes network Router event.
- */
-public class RouterEvent extends AbstractEvent<RouterEvent.Type, Router> {
- /**
- * Type of Router events.
- */
- public enum Type {
- /**
- * Signifies that router has been created.
- */
- ROUTER_PUT,
- /**
- * Signifies that router has been deleted.
- */
- ROUTER_DELETE
- }
-
- /**
- * Creates an event of a given type and for the specified Router.
- *
- * @param type Router event type
- * @param router Router subject
- */
- public RouterEvent(Type type, Router router) {
- super(type, router);
- }
-
- /**
- * Creates an event of a given type and for the specified Router.
- *
- * @param type Router event type
- * @param router Router subject
- * @param time occurrence time
- */
- public RouterEvent(Type type, Router router, long time) {
- super(type, router, time);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/RouterListener.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/RouterListener.java
deleted file mode 100644
index b75cef5..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/RouterListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.router;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Entity capable of Router related events.
- */
-public interface RouterListener extends EventListener<RouterEvent> {
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/RouterService.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/RouterService.java
deleted file mode 100644
index 001b01e..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/RouterService.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.router;
-
-import java.util.Collection;
-
-import org.onosproject.vtnrsc.Router;
-import org.onosproject.vtnrsc.RouterId;
-
-/**
- * Service for interacting with the inventory of Routers.
- */
-public interface RouterService {
- /**
- * Returns exists or not of specific router identifier.
- *
- * @param routerId router identifier
- * @return true or false
- */
- boolean exists(RouterId routerId);
-
- /**
- * Returns a collection of the currently known Routers.
- *
- * @return collection of Routers
- */
- Collection<Router> getRouters();
-
- /**
- * Returns the Router with the specified identifier.
- *
- * @param routerId Router identifier
- * @return Router or null if one with the given identifier is not known
- */
- Router getRouter(RouterId routerId);
-
- /**
- * Creates new Routers.
- *
- * @param routers the collection of Routers
- * @return true if the identifier Router has been created right.
- * false if the identifier Router is failed to store
- */
- boolean createRouters(Collection<Router> routers);
-
- /**
- * Updates existing Routers.
- *
- * @param routers the collection of Routers
- * @return true if Routers were updated successfully.
- * false if Routers were updated failed
- */
- boolean updateRouters(Collection<Router> routers);
-
- /**
- * Removes the specified Routers from the store.
- *
- * @param routerIds the collection of Routers identifier
- * @return true if remove identifier Routers successfully. false if remove
- * identifier Routers failed
- */
- boolean removeRouters(Collection<RouterId> routerIds);
-
- /**
- * Adds the specified listener to Router manager.
- *
- * @param listener Router listener
- */
- void addListener(RouterListener listener);
-
- /**
- * Removes the specified listener to Router manager.
- *
- * @param listener Router listener
- */
- void removeListener(RouterListener listener);
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/impl/RouterManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/impl/RouterManager.java
deleted file mode 100644
index 8954a38..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/impl/RouterManager.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.router.impl;
-
-import com.google.common.collect.Sets;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.EventuallyConsistentMapEvent;
-import org.onosproject.store.service.EventuallyConsistentMapListener;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.onosproject.vtnrsc.DefaultRouter;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.Router;
-import org.onosproject.vtnrsc.RouterGateway;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.router.RouterEvent;
-import org.onosproject.vtnrsc.router.RouterListener;
-import org.onosproject.vtnrsc.router.RouterService;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the Router service.
- */
-@Component(immediate = true, service = RouterService.class)
-public class RouterManager implements RouterService {
-
- private static final String ROUTER_ID_NULL = "Router ID cannot be null";
- private static final String ROUTER_NOT_NULL = "Router cannot be null";
- private static final String ROUTER = "vtn-router-store";
- private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
- private static final String LISTENER_NOT_NULL = "Listener cannot be null";
- private static final String EVENT_NOT_NULL = "event cannot be null";
-
- private final Logger log = getLogger(getClass());
- private final Set<RouterListener> listeners = Sets.newCopyOnWriteArraySet();
- private EventuallyConsistentMapListener<RouterId, Router> routerListener = new InnerRouterStoreListener();
- protected EventuallyConsistentMap<RouterId, Router> routerStore;
- protected ApplicationId appId;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TenantNetworkService tenantNetworkService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected VirtualPortService virtualPortService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected SubnetService subnetService;
-
- @Activate
- public void activate() {
- appId = coreService.registerApplication(VTNRSC_APP);
- KryoNamespace.Builder serializer = KryoNamespace
- .newBuilder()
- .register(KryoNamespaces.API)
- .register(Router.class, RouterId.class, DefaultRouter.class,
- TenantNetworkId.class, TenantId.class,
- VirtualPortId.class, DefaultRouter.class,
- RouterGateway.class, Router.Status.class,
- SubnetId.class, FixedIp.class);
- routerStore = storageService
- .<RouterId, Router>eventuallyConsistentMapBuilder()
- .withName(ROUTER).withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp())
- .build();
- routerStore.addListener(routerListener);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- routerStore.removeListener(routerListener);
- routerStore.destroy();
- listeners.clear();
- log.info("Stopped");
- }
-
- @Override
- public boolean exists(RouterId routerId) {
- checkNotNull(routerId, ROUTER_ID_NULL);
- return routerStore.containsKey(routerId);
- }
-
- @Override
- public Collection<Router> getRouters() {
- return Collections.unmodifiableCollection(routerStore.values());
- }
-
- @Override
- public Router getRouter(RouterId routerId) {
- checkNotNull(routerId, ROUTER_ID_NULL);
- return routerStore.get(routerId);
- }
-
- @Override
- public boolean createRouters(Collection<Router> routers) {
- checkNotNull(routers, ROUTER_NOT_NULL);
- for (Router router : routers) {
- verifyRouterData(router);
- routerStore.put(router.id(), router);
- if (!routerStore.containsKey(router.id())) {
- log.debug("The router is created failed whose identifier is {}",
- router.id().toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean updateRouters(Collection<Router> routers) {
- checkNotNull(routers, ROUTER_NOT_NULL);
- for (Router router : routers) {
- if (!routerStore.containsKey(router.id())) {
- log.debug("The routers is not exist whose identifier is {}",
- router.id().toString());
- throw new IllegalArgumentException(
- "routers ID doesn't exist");
- }
- verifyRouterData(router);
- routerStore.put(router.id(), router);
- if (!router.equals(routerStore.get(router.id()))) {
- log.debug("The router is updated failed whose identifier is {}",
- router.id().toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean removeRouters(Collection<RouterId> routerIds) {
- checkNotNull(routerIds, ROUTER_ID_NULL);
- for (RouterId routerId : routerIds) {
- if (!routerStore.containsKey(routerId)) {
- log.debug("The router is not exist whose identifier is {}",
- routerId.toString());
- throw new IllegalArgumentException(
- "router ID doesn't exist");
- }
- Router router = routerStore.get(routerId);
- routerStore.remove(routerId, router);
- if (routerStore.containsKey(routerId)) {
- log.debug("The router deleted is failed whose identifier is {}",
- routerId.toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public void addListener(RouterListener listener) {
- checkNotNull(listener, LISTENER_NOT_NULL);
- listeners.add(listener);
- }
-
- @Override
- public void removeListener(RouterListener listener) {
- checkNotNull(listener, LISTENER_NOT_NULL);
- listeners.remove(listener);
- }
-
- /**
- * Verifies validity of Router data.
- *
- * @param routers router instance
- */
- private void verifyRouterData(Router routers) {
- checkNotNull(routers, ROUTER_NOT_NULL);
- if (routers.gatewayPortid() != null
- && !virtualPortService.exists(routers.gatewayPortid())) {
- log.debug("The gateway port ID is not exist whose identifier is {}",
- routers.gatewayPortid().toString());
- throw new IllegalArgumentException("gateway port ID doesn't exist");
- }
-
- if (routers.externalGatewayInfo() != null) {
- RouterGateway routerGateway = routers.externalGatewayInfo();
- if (!tenantNetworkService.exists(routerGateway.networkId())) {
- log.debug("The network ID of gateway info is not exist whose identifier is {}",
- routers.id().toString());
- throw new IllegalArgumentException(
- "network ID of gateway info doesn't exist");
- }
- Iterable<FixedIp> fixedIps = routerGateway.externalFixedIps();
- for (FixedIp fixedIp : fixedIps) {
- if (!subnetService.exists(fixedIp.subnetId())) {
- log.debug("The subnet ID of gateway info is not exist whose identifier is {}",
- routers.id().toString());
- throw new IllegalArgumentException(
- "subnet ID of gateway info doesn't exist");
- }
- }
- }
- }
-
- private class InnerRouterStoreListener
- implements EventuallyConsistentMapListener<RouterId, Router> {
-
- @Override
- public void event(EventuallyConsistentMapEvent<RouterId, Router> event) {
- checkNotNull(event, EVENT_NOT_NULL);
- Router router = event.value();
- if (EventuallyConsistentMapEvent.Type.PUT == event.type()) {
- notifyListeners(new RouterEvent(RouterEvent.Type.ROUTER_PUT,
- router));
- }
- if (EventuallyConsistentMapEvent.Type.REMOVE == event.type()) {
- notifyListeners(new RouterEvent(RouterEvent.Type.ROUTER_DELETE,
- router));
- }
- }
- }
-
- /**
- * Notifies specify event to all listeners.
- *
- * @param event Floating IP event
- */
- private void notifyListeners(RouterEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- listeners.forEach(listener -> listener.event(event));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/impl/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/impl/package-info.java
deleted file mode 100644
index 38cbc44..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of the Router service.
- */
-package org.onosproject.vtnrsc.router.impl;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/package-info.java
deleted file mode 100644
index 4da56b8..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/router/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with the inventory of Router.
- */
-package org.onosproject.vtnrsc.router;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/RouterInterfaceEvent.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/RouterInterfaceEvent.java
deleted file mode 100644
index b6754b1..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/RouterInterfaceEvent.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.routerinterface;
-
-import org.onosproject.event.AbstractEvent;
-import org.onosproject.vtnrsc.RouterInterface;
-
-/**
- * Describes network Router Interface event.
- */
-public class RouterInterfaceEvent
- extends AbstractEvent<RouterInterfaceEvent.Type, RouterInterface> {
-
- /**
- * Type of Router Interface events.
- */
- public enum Type {
- /**
- * Signifies that router interface has been added.
- */
- ROUTER_INTERFACE_PUT,
- /**
- * Signifies that router interface has been removed.
- */
- ROUTER_INTERFACE_DELETE
- }
-
- /**
- * Creates an event of a given type and for the specified Router Interface.
- *
- * @param type Router Interface event type
- * @param routerInterface Router Interface subject
- */
- public RouterInterfaceEvent(Type type, RouterInterface routerInterface) {
- super(type, routerInterface);
- }
-
- /**
- * Creates an event of a given type and for the specified Router Interface.
- *
- * @param type Router Interface event type.
- * @param routerInterface Router Interface subject
- * @param time occurrence time
- */
- public RouterInterfaceEvent(Type type, RouterInterface routerInterface,
- long time) {
- super(type, routerInterface, time);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/RouterInterfaceListener.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/RouterInterfaceListener.java
deleted file mode 100644
index e1fdae4..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/RouterInterfaceListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.vtnrsc.routerinterface;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Entity capable of Router Interface related events.
- */
-public interface RouterInterfaceListener
- extends EventListener<RouterInterfaceEvent> {
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/RouterInterfaceService.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/RouterInterfaceService.java
deleted file mode 100644
index 76ea44b..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/RouterInterfaceService.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.routerinterface;
-
-import java.util.Collection;
-
-import org.onosproject.vtnrsc.RouterInterface;
-import org.onosproject.vtnrsc.SubnetId;
-
-/**
- * Service for interacting with the inventory of Router interface.
- */
-public interface RouterInterfaceService {
- /**
- * Returns exists or not of specific subnet identifier.
- *
- * @param subnetId subnet identifier
- * @return true or false
- */
- boolean exists(SubnetId subnetId);
-
- /**
- * Returns a collection of the currently known Router interface.
- *
- * @return collection of RouterInterface
- */
- Collection<RouterInterface> getRouterInterfaces();
-
- /**
- * Returns the Router interface with the specified subnet identifier.
- *
- * @param subnetId subnet identifier
- * @return RouterInterface or null if one with the given identifier is not
- * known
- */
- RouterInterface getRouterInterface(SubnetId subnetId);
-
- /**
- * Adds the specified RouterInterface.
- *
- * @param routerInterface the interface add to router
- * @return true if add router interface successfully
- */
- boolean addRouterInterface(RouterInterface routerInterface);
-
- /**
- * Removes the specified RouterInterface.
- *
- * @param routerInterface the interface remove from router
- * @return true if remove router interface successfully
- */
- boolean removeRouterInterface(RouterInterface routerInterface);
-
- /**
- * Adds the specified listener to Router Interface manager.
- *
- * @param listener Router Interface listener
- */
- void addListener(RouterInterfaceListener listener);
-
- /**
- * Removes the specified listener to RouterInterface manager.
- *
- * @param listener Router Interface listener
- */
- void removeListener(RouterInterfaceListener listener);
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/impl/RouterInterfaceManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/impl/RouterInterfaceManager.java
deleted file mode 100644
index 854efd9..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/impl/RouterInterfaceManager.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.routerinterface.impl;
-
-import com.google.common.collect.Sets;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.EventuallyConsistentMapEvent;
-import org.onosproject.store.service.EventuallyConsistentMapListener;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.RouterInterface;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.router.RouterService;
-import org.onosproject.vtnrsc.routerinterface.RouterInterfaceEvent;
-import org.onosproject.vtnrsc.routerinterface.RouterInterfaceListener;
-import org.onosproject.vtnrsc.routerinterface.RouterInterfaceService;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the Router interface service.
- */
-@Component(immediate = true, service = RouterInterfaceService.class)
-public class RouterInterfaceManager implements RouterInterfaceService {
- private static final String SUBNET_ID_NULL = "Subnet ID cannot be null";
- private static final String ROUTER_INTERFACE_NULL = "Router Interface cannot be null";
- private static final String ROUTER_INTERFACE = "vtn-router-interface-store";
- private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
- private static final String LISTENER_NOT_NULL = "Listener cannot be null";
- private static final String EVENT_NOT_NULL = "event cannot be null";
-
- private final Logger log = getLogger(getClass());
- private final Set<RouterInterfaceListener> listeners = Sets
- .newCopyOnWriteArraySet();
- private EventuallyConsistentMapListener<SubnetId, RouterInterface> routerInterfaceListener =
- new InnerRouterInterfaceStoreListener();
- protected EventuallyConsistentMap<SubnetId, RouterInterface> routerInterfaceStore;
- protected ApplicationId appId;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected VirtualPortService virtualPortService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected SubnetService subnetService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected RouterService routerService;
-
- @Activate
- public void activate() {
- appId = coreService.registerApplication(VTNRSC_APP);
- KryoNamespace.Builder serializer = KryoNamespace
- .newBuilder()
- .register(KryoNamespaces.API)
- .register(RouterId.class, TenantId.class, VirtualPortId.class,
- RouterInterface.class, SubnetId.class);
- routerInterfaceStore = storageService
- .<SubnetId, RouterInterface>eventuallyConsistentMapBuilder()
- .withName(ROUTER_INTERFACE).withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp())
- .build();
- routerInterfaceStore.addListener(routerInterfaceListener);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- routerInterfaceStore.removeListener(routerInterfaceListener);
- routerInterfaceStore.destroy();
- listeners.clear();
- log.info("Stopped");
- }
-
- @Override
- public boolean exists(SubnetId subnetId) {
- checkNotNull(subnetId, SUBNET_ID_NULL);
- return routerInterfaceStore.containsKey(subnetId);
- }
-
- @Override
- public Collection<RouterInterface> getRouterInterfaces() {
- return Collections
- .unmodifiableCollection(routerInterfaceStore.values());
- }
-
- @Override
- public RouterInterface getRouterInterface(SubnetId subnetId) {
- checkNotNull(subnetId, SUBNET_ID_NULL);
- return routerInterfaceStore.get(subnetId);
- }
-
- @Override
- public boolean addRouterInterface(RouterInterface routerInterface) {
- checkNotNull(routerInterface, ROUTER_INTERFACE_NULL);
- if (!virtualPortService.exists(routerInterface.portId())) {
- log.debug("The port ID of interface is not exist whose identifier is {}",
- routerInterface.portId().toString());
- throw new IllegalArgumentException(
- "port ID of interface doesn't exist");
- }
- verifyRouterInterfaceData(routerInterface);
- routerInterfaceStore.put(routerInterface.subnetId(), routerInterface);
- if (!routerInterfaceStore.containsKey(routerInterface.subnetId())) {
- log.debug("The router interface is created failed whose identifier is {}",
- routerInterface.subnetId().toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removeRouterInterface(RouterInterface routerInterface) {
- checkNotNull(routerInterface, ROUTER_INTERFACE_NULL);
- if (!routerInterfaceStore.containsKey(routerInterface.subnetId())) {
- log.debug("The router interface is not exist whose identifier is {}",
- routerInterface.subnetId().toString());
- throw new IllegalArgumentException("subnet ID doesn't exist");
- }
- verifyRouterInterfaceData(routerInterface);
- routerInterfaceStore
- .remove(routerInterface.subnetId(), routerInterface);
- if (routerInterfaceStore.containsKey(routerInterface.subnetId())) {
- log.debug("The router interface deleted is failed whose identifier is {}",
- routerInterface.subnetId().toString());
- return false;
- }
- return true;
- }
-
- @Override
- public void addListener(RouterInterfaceListener listener) {
- checkNotNull(listener, LISTENER_NOT_NULL);
- listeners.add(listener);
- }
-
- @Override
- public void removeListener(RouterInterfaceListener listener) {
- checkNotNull(listener, LISTENER_NOT_NULL);
- listeners.remove(listener);
- }
-
- /**
- * Verifies validity of Router interface data.
- *
- * @param routers router instance
- */
- private void verifyRouterInterfaceData(RouterInterface routerInterface) {
- checkNotNull(routerInterface, ROUTER_INTERFACE_NULL);
- if (!subnetService.exists(routerInterface.subnetId())) {
- log.debug("The subnet ID of interface is not exist whose identifier is {}",
- routerInterface.subnetId().toString());
- throw new IllegalArgumentException(
- "subnet ID of interface doesn't exist");
- }
- if (!routerService.exists(routerInterface.routerId())) {
- log.debug("The router ID of interface is not exist whose identifier is {}",
- routerInterface.routerId().toString());
- throw new IllegalArgumentException(
- "router ID of interface doesn't exist");
- }
- }
-
- private class InnerRouterInterfaceStoreListener
- implements
- EventuallyConsistentMapListener<SubnetId, RouterInterface> {
-
- @Override
- public void event(EventuallyConsistentMapEvent<SubnetId, RouterInterface> event) {
- checkNotNull(event, EVENT_NOT_NULL);
- RouterInterface routerInterface = event.value();
- if (EventuallyConsistentMapEvent.Type.PUT == event.type()) {
- notifyListeners(new RouterInterfaceEvent(
- RouterInterfaceEvent.Type.ROUTER_INTERFACE_PUT,
- routerInterface));
- }
- if (EventuallyConsistentMapEvent.Type.REMOVE == event.type()) {
- notifyListeners(new RouterInterfaceEvent(
- RouterInterfaceEvent.Type.ROUTER_INTERFACE_DELETE,
- routerInterface));
- }
- }
- }
-
- /**
- * Notifies specify event to all listeners.
- *
- * @param event Floating IP event
- */
- private void notifyListeners(RouterInterfaceEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- listeners.forEach(listener -> listener.event(event));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/impl/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/impl/package-info.java
deleted file mode 100644
index b7824bf..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of the RouterInterface service.
- */
-package org.onosproject.vtnrsc.routerinterface.impl;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/package-info.java
deleted file mode 100644
index 9dea3c3..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/routerinterface/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with the inventory of RouterInterface.
- */
-package org.onosproject.vtnrsc.routerinterface;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/service/VtnRscService.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/service/VtnRscService.java
deleted file mode 100644
index fd81987..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/service/VtnRscService.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.service;
-
-import org.onlab.packet.MacAddress;
-import org.onosproject.event.ListenerService;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.HostId;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantRouter;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.event.VtnRscEvent;
-import org.onosproject.vtnrsc.event.VtnRscListener;
-
-import java.util.Iterator;
-
-/**
- * Service for interacting with the inventory of Vtn resource.
- */
-public interface VtnRscService extends ListenerService<VtnRscEvent, VtnRscListener> {
- /**
- * Returns the SegmentationId of tenant.
- *
- * @param tenantId tenant identifier
- * @return SegmentationId the SegmentationId of tenant
- */
- SegmentationId getL3vni(TenantId tenantId);
-
- /**
- * Returns the SegmentationId of tenantRouter.
- *
- * @param tenantRouter TenantRouter
- * @return SegmentationId the SegmentationId of tenantRouter
- */
- SegmentationId getL3vni(TenantRouter tenantRouter);
-
- /**
- * Returns Classifier Ovs list of the specific tenant.
- *
- * @param tenantId tenant identifier
- * @return iterable collection of Device
- */
- Iterator<Device> getClassifierOfTenant(TenantId tenantId);
-
- /**
- * Returns Service function forwarders Ovs list of the specific tenant.
- *
- * @param tenantId tenant identifier
- * @return iterable collection of Device
- */
- Iterator<Device> getSffOfTenant(TenantId tenantId);
-
- /**
- * Returns gateway mac address of the specific host.
- *
- * @param hostId host identifier
- * @return MacAddress of host
- */
- MacAddress getGatewayMac(HostId hostId);
-
- /**
- * Checks if a specific port is a service function.
- *
- * @param portId port identifier
- * @return true or false
- */
- boolean isServiceFunction(VirtualPortId portId);
-
- /**
- * Returns device identifier mapping to the specific port.
- *
- * @param portId port identifier
- * @return device identifier
- */
- DeviceId getSfToSffMaping(VirtualPortId portId);
-
- /**
- * Adds specify Device identifier to Service Function Forward OvsMap
- * or Classifier OvsMap.
- *
- * @param virtualPortId the VirtualPort identifier
- * @param tenantId the tenant identifier
- * @param deviceId the device identifier
- */
- void addDeviceIdOfOvsMap(VirtualPortId virtualPortId, TenantId tenantId, DeviceId deviceId);
-
- /**
- * Removes specify Device identifier from Service Function Forward OvsMap
- * or Classifier OvsMap.
- *
- * @param host Host
- * @param tenantId the tenant identifier
- * @param deviceId the device identifier
- */
- void removeDeviceIdOfOvsMap(Host host, TenantId tenantId, DeviceId deviceId);
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/service/impl/VtnRscManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/service/impl/VtnRscManager.java
deleted file mode 100644
index 37f2de4..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/service/impl/VtnRscManager.java
+++ /dev/null
@@ -1,625 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.service.impl;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.CoreService;
-import org.onosproject.event.AbstractListenerManager;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.HostId;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.host.HostService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.LogicalClockService;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.FloatingIp;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.Router;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.RouterInterface;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantRouter;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.event.VtnRscEvent;
-import org.onosproject.vtnrsc.event.VtnRscEventFeedback;
-import org.onosproject.vtnrsc.event.VtnRscListener;
-import org.onosproject.vtnrsc.floatingip.FloatingIpEvent;
-import org.onosproject.vtnrsc.floatingip.FloatingIpListener;
-import org.onosproject.vtnrsc.floatingip.FloatingIpService;
-import org.onosproject.vtnrsc.flowclassifier.FlowClassifierEvent;
-import org.onosproject.vtnrsc.flowclassifier.FlowClassifierListener;
-import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService;
-import org.onosproject.vtnrsc.portchain.PortChainEvent;
-import org.onosproject.vtnrsc.portchain.PortChainListener;
-import org.onosproject.vtnrsc.portchain.PortChainService;
-import org.onosproject.vtnrsc.portpair.PortPairEvent;
-import org.onosproject.vtnrsc.portpair.PortPairListener;
-import org.onosproject.vtnrsc.portpair.PortPairService;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupEvent;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupListener;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
-import org.onosproject.vtnrsc.router.RouterEvent;
-import org.onosproject.vtnrsc.router.RouterListener;
-import org.onosproject.vtnrsc.router.RouterService;
-import org.onosproject.vtnrsc.routerinterface.RouterInterfaceEvent;
-import org.onosproject.vtnrsc.routerinterface.RouterInterfaceListener;
-import org.onosproject.vtnrsc.routerinterface.RouterInterfaceService;
-import org.onosproject.vtnrsc.service.VtnRscService;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortEvent;
-import org.onosproject.vtnrsc.virtualport.VirtualPortListener;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the VtnRsc service.
- */
-@Component(immediate = true, service = VtnRscService.class)
-public class VtnRscManager extends AbstractListenerManager<VtnRscEvent, VtnRscListener>
- implements VtnRscService {
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LogicalClockService clockService;
-
- private final Logger log = getLogger(getClass());
- private FloatingIpListener floatingIpListener = new InnerFloatingIpListener();
- private RouterListener routerListener = new InnerRouterListener();
- private RouterInterfaceListener routerInterfaceListener = new InnerRouterInterfaceListener();
- private PortPairListener portPairListener = new InnerPortPairListener();
- private PortPairGroupListener portPairGroupListener = new InnerPortPairGroupListener();
- private FlowClassifierListener flowClassifierListener = new InnerFlowClassifierListener();
- private PortChainListener portChainListener = new InnerPortChainListener();
- private VirtualPortListener virtualPortListener = new InnerVirtualPortListener();
-
- private EventuallyConsistentMap<TenantId, SegmentationId> l3vniTenantMap;
- private EventuallyConsistentMap<TenantRouter, SegmentationId> l3vniTenantRouterMap;
- private EventuallyConsistentMap<TenantId, Set<DeviceId>> classifierOvsMap;
- private EventuallyConsistentMap<TenantId, Set<DeviceId>> sffOvsMap;
-
- private static final String IFACEID = "ifaceid";
- private static final String RUNNELOPTOPOIC = "tunnel-ops-ids";
- private static final String EVENT_NOT_NULL = "event cannot be null";
- private static final String TENANTID_NOT_NULL = "tenantId cannot be null";
- private static final String DEVICEID_NOT_NULL = "deviceId cannot be null";
- private static final String VIRTUALPORTID_NOT_NULL = "virtualPortId cannot be null";
- private static final String HOST_NOT_NULL = "host cannot be null";
- private static final String L3VNITENANTMAP = "l3vniTenantMap";
- private static final String L3VNITENANTROUTERMAP = "l3vniTenantRouterMap";
- private static final String CLASSIFIEROVSMAP = "classifierOvsMap";
- private static final String SFFOVSMAP = "sffOvsMap";
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected RouterService routerService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected FloatingIpService floatingIpService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected RouterInterfaceService routerInterfaceService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected VirtualPortService virtualPortService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected HostService hostService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected SubnetService subnetService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TenantNetworkService tenantNetworkService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceService deviceService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PortPairService portPairService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PortPairGroupService portPairGroupService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected FlowClassifierService flowClassifierService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PortChainService portChainService;
-
- @Activate
- public void activate() {
- eventDispatcher.addSink(VtnRscEvent.class, listenerRegistry);
- floatingIpService.addListener(floatingIpListener);
- routerService.addListener(routerListener);
- routerInterfaceService.addListener(routerInterfaceListener);
- portPairService.addListener(portPairListener);
- portPairGroupService.addListener(portPairGroupListener);
- flowClassifierService.addListener(flowClassifierListener);
- portChainService.addListener(portChainListener);
- virtualPortService.addListener(virtualPortListener);
-
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API)
- .register(TenantId.class, SegmentationId.class,
- TenantRouter.class, RouterId.class);
- l3vniTenantMap = storageService
- .<TenantId, SegmentationId>eventuallyConsistentMapBuilder()
- .withName(L3VNITENANTMAP).withSerializer(serializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
-
- l3vniTenantRouterMap = storageService
- .<TenantRouter, SegmentationId>eventuallyConsistentMapBuilder()
- .withName(L3VNITENANTROUTERMAP).withSerializer(serializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
-
- classifierOvsMap = storageService
- .<TenantId, Set<DeviceId>>eventuallyConsistentMapBuilder()
- .withName(CLASSIFIEROVSMAP).withSerializer(serializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
-
- sffOvsMap = storageService
- .<TenantId, Set<DeviceId>>eventuallyConsistentMapBuilder()
- .withName(SFFOVSMAP).withSerializer(serializer)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
- .build();
- }
-
- @Deactivate
- public void deactivate() {
- eventDispatcher.removeSink(VtnRscEvent.class);
- floatingIpService.removeListener(floatingIpListener);
- routerService.removeListener(routerListener);
- routerInterfaceService.removeListener(routerInterfaceListener);
- portPairService.removeListener(portPairListener);
- portPairGroupService.removeListener(portPairGroupListener);
- flowClassifierService.removeListener(flowClassifierListener);
- portChainService.removeListener(portChainListener);
- virtualPortService.removeListener(virtualPortListener);
-
- l3vniTenantMap.destroy();
- l3vniTenantRouterMap.destroy();
- classifierOvsMap.destroy();
- sffOvsMap.destroy();
- log.info("Stopped");
- }
-
- @Override
- public SegmentationId getL3vni(TenantId tenantId) {
- checkNotNull(tenantId, "tenantId cannot be null");
- SegmentationId l3vni = l3vniTenantMap.get(tenantId);
- if (l3vni == null) {
- long segmentationId = coreService.getIdGenerator(RUNNELOPTOPOIC)
- .getNewId();
- l3vni = SegmentationId.segmentationId(String
- .valueOf(segmentationId));
- l3vniTenantMap.put(tenantId, l3vni);
- }
- return l3vni;
- }
-
- @Override
- public SegmentationId getL3vni(TenantRouter tenantRouter) {
- checkNotNull(tenantRouter, "tenantRouter cannot be null");
- SegmentationId l3vni = l3vniTenantRouterMap.get(tenantRouter);
- if (l3vni == null) {
- long segmentationId = coreService.getIdGenerator(RUNNELOPTOPOIC)
- .getNewId();
- l3vni = SegmentationId.segmentationId(String
- .valueOf(segmentationId));
- l3vniTenantRouterMap.put(tenantRouter, l3vni);
- }
- return l3vni;
- }
-
- private class InnerFloatingIpListener implements FloatingIpListener {
-
- @Override
- public void event(FloatingIpEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- FloatingIp floatingIp = event.subject();
- if (FloatingIpEvent.Type.FLOATINGIP_PUT == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.FLOATINGIP_PUT,
- new VtnRscEventFeedback(
- floatingIp)));
- }
- if (FloatingIpEvent.Type.FLOATINGIP_DELETE == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.FLOATINGIP_DELETE,
- new VtnRscEventFeedback(
- floatingIp)));
- }
- if (FloatingIpEvent.Type.FLOATINGIP_BIND == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.FLOATINGIP_BIND,
- new VtnRscEventFeedback(
- floatingIp)));
- }
- if (FloatingIpEvent.Type.FLOATINGIP_UNBIND == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.FLOATINGIP_UNBIND,
- new VtnRscEventFeedback(
- floatingIp)));
- }
- }
- }
-
- private class InnerRouterListener implements RouterListener {
-
- @Override
- public void event(RouterEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- Router router = event.subject();
- if (RouterEvent.Type.ROUTER_PUT == event.type()) {
- notifyListeners(new VtnRscEvent(VtnRscEvent.Type.ROUTER_PUT,
- new VtnRscEventFeedback(router)));
- }
- if (RouterEvent.Type.ROUTER_DELETE == event.type()) {
- notifyListeners(new VtnRscEvent(VtnRscEvent.Type.ROUTER_DELETE,
- new VtnRscEventFeedback(router)));
- }
- }
- }
-
- private class InnerRouterInterfaceListener
- implements RouterInterfaceListener {
-
- @Override
- public void event(RouterInterfaceEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- RouterInterface routerInterface = event.subject();
- if (RouterInterfaceEvent.Type.ROUTER_INTERFACE_PUT == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.ROUTER_INTERFACE_PUT,
- new VtnRscEventFeedback(
- routerInterface)));
- }
- if (RouterInterfaceEvent.Type.ROUTER_INTERFACE_DELETE == event
- .type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.ROUTER_INTERFACE_DELETE,
- new VtnRscEventFeedback(
- routerInterface)));
- }
- }
- }
-
- private class InnerPortPairListener implements PortPairListener {
-
- @Override
- public void event(PortPairEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- PortPair portPair = event.subject();
- if (PortPairEvent.Type.PORT_PAIR_PUT == event.type()) {
- notifyListeners(new VtnRscEvent(VtnRscEvent.Type.PORT_PAIR_PUT,
- new VtnRscEventFeedback(portPair)));
- } else if (PortPairEvent.Type.PORT_PAIR_DELETE == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.PORT_PAIR_DELETE,
- new VtnRscEventFeedback(portPair)));
- } else if (PortPairEvent.Type.PORT_PAIR_UPDATE == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.PORT_PAIR_UPDATE,
- new VtnRscEventFeedback(portPair)));
- }
- }
- }
-
- private class InnerPortPairGroupListener implements PortPairGroupListener {
-
- @Override
- public void event(PortPairGroupEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- PortPairGroup portPairGroup = event.subject();
- if (PortPairGroupEvent.Type.PORT_PAIR_GROUP_PUT == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.PORT_PAIR_GROUP_PUT,
- new VtnRscEventFeedback(portPairGroup)));
- } else if (PortPairGroupEvent.Type.PORT_PAIR_GROUP_DELETE == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.PORT_PAIR_GROUP_DELETE,
- new VtnRscEventFeedback(portPairGroup)));
- } else if (PortPairGroupEvent.Type.PORT_PAIR_GROUP_UPDATE == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.PORT_PAIR_GROUP_UPDATE,
- new VtnRscEventFeedback(portPairGroup)));
- }
- }
- }
-
- private class InnerFlowClassifierListener implements FlowClassifierListener {
-
- @Override
- public void event(FlowClassifierEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- FlowClassifier flowClassifier = event.subject();
- if (FlowClassifierEvent.Type.FLOW_CLASSIFIER_PUT == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.FLOW_CLASSIFIER_PUT,
- new VtnRscEventFeedback(flowClassifier)));
- } else if (FlowClassifierEvent.Type.FLOW_CLASSIFIER_DELETE == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.FLOW_CLASSIFIER_DELETE,
- new VtnRscEventFeedback(flowClassifier)));
- } else if (FlowClassifierEvent.Type.FLOW_CLASSIFIER_UPDATE == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.FLOW_CLASSIFIER_UPDATE,
- new VtnRscEventFeedback(flowClassifier)));
- }
- }
- }
-
- private class InnerPortChainListener implements PortChainListener {
-
- @Override
- public void event(PortChainEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- PortChain portChain = event.subject();
- if (PortChainEvent.Type.PORT_CHAIN_PUT == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.PORT_CHAIN_PUT,
- new VtnRscEventFeedback(portChain)));
- } else if (PortChainEvent.Type.PORT_CHAIN_DELETE == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.PORT_CHAIN_DELETE,
- new VtnRscEventFeedback(portChain)));
- } else if (PortChainEvent.Type.PORT_CHAIN_UPDATE == event.type()) {
- notifyListeners(new VtnRscEvent(
- VtnRscEvent.Type.PORT_CHAIN_UPDATE,
- new VtnRscEventFeedback(portChain)));
- }
- }
- }
-
- private class InnerVirtualPortListener implements VirtualPortListener {
-
- @Override
- public void event(VirtualPortEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- VirtualPort virtualPort = event.subject();
- if (VirtualPortEvent.Type.VIRTUAL_PORT_PUT == event.type()) {
- notifyListeners(new VtnRscEvent(VtnRscEvent.Type.VIRTUAL_PORT_PUT,
- new VtnRscEventFeedback(virtualPort)));
- } else if (VirtualPortEvent.Type.VIRTUAL_PORT_DELETE == event.type()) {
- notifyListeners(new VtnRscEvent(VtnRscEvent.Type.VIRTUAL_PORT_DELETE,
- new VtnRscEventFeedback(virtualPort)));
- }
- }
- }
-
- @Override
- public Iterator<Device> getClassifierOfTenant(TenantId tenantId) {
- checkNotNull(tenantId, TENANTID_NOT_NULL);
- Set<DeviceId> deviceIdSet = classifierOvsMap.get(tenantId);
- Set<Device> deviceSet = new HashSet<>();
- if (deviceIdSet != null) {
- for (DeviceId deviceId : deviceIdSet) {
- deviceSet.add(deviceService.getDevice(deviceId));
- }
- }
- return deviceSet.iterator();
- }
-
- @Override
- public Iterator<Device> getSffOfTenant(TenantId tenantId) {
- checkNotNull(tenantId, TENANTID_NOT_NULL);
- Set<DeviceId> deviceIdSet = sffOvsMap.get(tenantId);
- Set<Device> deviceSet = new HashSet<>();
- if (deviceIdSet != null) {
- for (DeviceId deviceId : deviceIdSet) {
- deviceSet.add(deviceService.getDevice(deviceId));
- }
- }
- return deviceSet.iterator();
- }
-
- @Override
- public MacAddress getGatewayMac(HostId hostId) {
- checkNotNull(hostId, "hostId cannot be null");
- Host host = hostService.getHost(hostId);
- String ifaceId = host.annotations().value(IFACEID);
- VirtualPortId hPortId = VirtualPortId.portId(ifaceId);
- VirtualPort hPort = virtualPortService.getPort(hPortId);
- SubnetId subnetId = hPort.fixedIps().iterator().next().subnetId();
- Subnet subnet = subnetService.getSubnet(subnetId);
- IpAddress gatewayIp = subnet.gatewayIp();
- Iterable<VirtualPort> virtualPorts = virtualPortService.getPorts();
- MacAddress macAddress = null;
- for (VirtualPort port : virtualPorts) {
- Set<FixedIp> fixedIpSet = port.fixedIps();
- for (FixedIp fixedIp : fixedIpSet) {
- if (fixedIp.ip().equals(gatewayIp)) {
- macAddress = port.macAddress();
- }
- }
- }
- return macAddress;
- }
-
- @Override
- public boolean isServiceFunction(VirtualPortId portId) {
- return portPairService.exists(PortPairId.of(portId.portId()));
- }
-
- @Override
- public DeviceId getSfToSffMaping(VirtualPortId portId) {
- checkNotNull(portId, "portId cannot be null");
- VirtualPort vmPort = virtualPortService.getPort(portId);
- Set<Host> hostSet = hostService.getHostsByMac(vmPort.macAddress());
- for (Host host : hostSet) {
- if (host.annotations().value(IFACEID).equals(vmPort.portId().portId())) {
- return host.location().deviceId();
- }
- }
- return null;
- }
-
- @Override
- public void addDeviceIdOfOvsMap(VirtualPortId virtualPortId,
- TenantId tenantId, DeviceId deviceId) {
- checkNotNull(virtualPortId, VIRTUALPORTID_NOT_NULL);
- checkNotNull(tenantId, TENANTID_NOT_NULL);
- checkNotNull(deviceId, DEVICEID_NOT_NULL);
- if (isServiceFunction(virtualPortId)) {
- addDeviceIdToSpecificMap(tenantId, deviceId, sffOvsMap);
- } else {
- addDeviceIdToSpecificMap(tenantId, deviceId, classifierOvsMap);
- }
- }
-
- @Override
- public void removeDeviceIdOfOvsMap(Host host, TenantId tenantId, DeviceId deviceId) {
- checkNotNull(host, HOST_NOT_NULL);
- checkNotNull(tenantId, TENANTID_NOT_NULL);
- checkNotNull(deviceId, DEVICEID_NOT_NULL);
- if (isLastSFHostOfTenant(host, deviceId, tenantId)) {
- removeDeviceIdToSpecificMap(tenantId, deviceId, sffOvsMap);
- }
- if (isLastClassifierHostOfTenant(host, deviceId, tenantId)) {
- removeDeviceIdToSpecificMap(tenantId, deviceId, classifierOvsMap);
- }
- }
-
- /**
- * Checks whether the last Service Function host of a specific tenant in
- * this device.
- *
- * @param host the host on device
- * @param deviceId the device identifier
- * @param tenantId the tenant identifier
- * @return true or false
- */
- private boolean isLastSFHostOfTenant(Host host, DeviceId deviceId,
- TenantId tenantId) {
- Set<Host> hostSet = hostService.getConnectedHosts(deviceId);
- if (hostSet != null) {
- for (Host h : hostSet) {
- String ifaceId = h.annotations().value(IFACEID);
- if (ifaceId != null) {
- VirtualPortId hPortId = VirtualPortId.portId(ifaceId);
- if (virtualPortService.getPort(hPortId).tenantId().tenantId()
- .equals(tenantId.tenantId())
- && isServiceFunction(hPortId)) {
- if (!h.equals(host)) {
- return false;
- }
- }
- }
- }
- }
- return true;
- }
-
- /**
- * Checks whether the last Classifier host of a specific tenant in this
- * device.
- *
- * @param host the host on device
- * @param deviceId the device identifier
- * @param tenantId the tenant identifier
- * @return true or false
- */
- private boolean isLastClassifierHostOfTenant(Host host, DeviceId deviceId,
- TenantId tenantId) {
- Set<Host> hostSet = hostService.getConnectedHosts(deviceId);
- if (hostSet != null) {
- for (Host h : hostSet) {
- String ifaceId = h.annotations().value(IFACEID);
- if (ifaceId != null) {
- VirtualPortId hPortId = VirtualPortId.portId(ifaceId);
- if (virtualPortService.getPort(hPortId).tenantId().tenantId()
- .equals(tenantId.tenantId())
- && !isServiceFunction(hPortId)) {
- if (!h.equals(host)) {
- return false;
- }
- }
- }
- }
- }
- return true;
- }
-
- /**
- * Adds specify Device identifier to OvsMap.
- *
- * @param tenantId the tenant identifier
- * @param deviceId the device identifier
- * @param ovsMap the instance of map to store device identifier
- */
- private void addDeviceIdToSpecificMap(TenantId tenantId,
- DeviceId deviceId,
- EventuallyConsistentMap<TenantId, Set<DeviceId>> ovsMap) {
- if (ovsMap.containsKey(tenantId)) {
- Set<DeviceId> deviceIdSet = ovsMap.get(tenantId);
- deviceIdSet.add(deviceId);
- ovsMap.put(tenantId, deviceIdSet);
- } else {
- Set<DeviceId> deviceIdSet = new HashSet<>();
- deviceIdSet.add(deviceId);
- ovsMap.put(tenantId, deviceIdSet);
- }
- }
-
- /**
- * Removes specify Device identifier from OvsMap.
- *
- * @param tenantId the tenant identifier
- * @param deviceId the device identifier
- * @param ovsMap the instance of map to store device identifier
- */
- private void removeDeviceIdToSpecificMap(TenantId tenantId,
- DeviceId deviceId,
- EventuallyConsistentMap<TenantId, Set<DeviceId>> ovsMap) {
- Set<DeviceId> deviceIdSet = ovsMap.get(tenantId);
- if (deviceIdSet != null && deviceIdSet.size() > 1) {
- deviceIdSet.remove(deviceId);
- ovsMap.put(tenantId, deviceIdSet);
- } else {
- ovsMap.remove(tenantId);
- }
- }
-
- /**
- * Notifies specify event to all listeners.
- *
- * @param event VtnRsc event
- */
- private void notifyListeners(VtnRscEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- post(event);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/service/impl/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/service/impl/package-info.java
deleted file mode 100644
index 687deec..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/service/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of the VtnRsc service.
- */
-package org.onosproject.vtnrsc.service.impl;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/service/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/service/package-info.java
deleted file mode 100644
index f7325ae..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/service/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with the inventory of Vtn resource.
- */
-package org.onosproject.vtnrsc.service;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java
deleted file mode 100644
index 047b244..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.subnet;
-
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-
-
-/**
- * Service for interacting with the inventory of subnets.
- */
-public interface SubnetService {
- /**
- * Returns the subnet with the specified identifier.
- *
- * @param subnetId subnet identifier
- * @return true or false
- */
- boolean exists(SubnetId subnetId);
- /**
- * Returns a collection of the currently known subnets.
- *
- * @return iterable collection of subnets
- */
- Iterable<Subnet> getSubnets();
-
- /**
- * Returns the subnet with the specified identifier.
- *
- * @param subnetId subnet identifier
- * @return subnet or null if one with the given identifier is not known
- */
- Subnet getSubnet(SubnetId subnetId);
- /**
- * Creates new subnets.
- *
- * @param subnets the iterable collection of subnets
- * @return true if the identifier subnet has been created right
- */
- boolean createSubnets(Iterable<Subnet> subnets);
-
- /**
- * Updates existing subnets.
- *
- * @param subnets the iterable collection of subnets
- * @return true if all subnets were updated successfully
- */
- boolean updateSubnets(Iterable<Subnet> subnets);
-
- /**
- * Administratively removes the specified subnets from the store.
- *
- * @param subnetIds the iterable collection of subnets identifier
- * @return true if remove identifier subnets successfully
- */
- boolean removeSubnets(Iterable<SubnetId> subnetIds);
-
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java
deleted file mode 100644
index 5d13cb1..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.subnet.impl;
-
-import org.onlab.packet.IpAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.vtnrsc.AllocationPool;
-import org.onosproject.vtnrsc.DefaultAllocationPool;
-import org.onosproject.vtnrsc.DefaultHostRoute;
-import org.onosproject.vtnrsc.DefaultSubnet;
-import org.onosproject.vtnrsc.HostRoute;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the Subnet service.
- */
-@Component(immediate = true, service = SubnetService.class)
-public class SubnetManager implements SubnetService {
-
- private static final String SUBNET_ID_NULL = "Subnet ID cannot be null";
- private static final String SUBNET_NOT_NULL = "Subnet cannot be null";
- private static final String SUBNET = "vtn-subnet-store";
- private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
-
-
- private final Logger log = getLogger(getClass());
-
- protected Map<SubnetId, Subnet> subnetStore;
- protected ApplicationId appId;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TenantNetworkService tenantNetworkService;
-
- @Activate
- public void activate() {
-
- appId = coreService.registerApplication(VTNRSC_APP);
-
- subnetStore = storageService.<SubnetId, Subnet>consistentMapBuilder()
- .withName(SUBNET)
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
- Subnet.class,
- SubnetId.class,
- TenantNetworkId.class,
- TenantId.class,
- HostRoute.class,
- DefaultHostRoute.class,
- Subnet.Mode.class,
- AllocationPool.class,
- DefaultAllocationPool.class,
- DefaultSubnet.class,
- IpAddress.Version.class))
- .build().asJavaMap();
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public Iterable<Subnet> getSubnets() {
- return Collections.unmodifiableCollection(subnetStore.values());
- }
-
- @Override
- public Subnet getSubnet(SubnetId subnetId) {
- checkNotNull(subnetId, SUBNET_ID_NULL);
- return subnetStore.get(subnetId);
- }
-
- @Override
- public boolean exists(SubnetId subnetId) {
- checkNotNull(subnetId, SUBNET_ID_NULL);
- return subnetStore.containsKey(subnetId);
- }
-
- @Override
- public boolean createSubnets(Iterable<Subnet> subnets) {
- checkNotNull(subnets, SUBNET_NOT_NULL);
- for (Subnet subnet : subnets) {
- if (!tenantNetworkService.exists(subnet.networkId())) {
- log.debug("The network identifier that the subnet {} belong to is not exist",
- subnet.networkId().toString(), subnet.id().toString());
- return false;
- }
- subnetStore.put(subnet.id(), subnet);
- if (!subnetStore.containsKey(subnet.id())) {
- log.debug("The identified subnet whose identifier is {} create failed",
- subnet.id().toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean updateSubnets(Iterable<Subnet> subnets) {
- checkNotNull(subnets, SUBNET_NOT_NULL);
- for (Subnet subnet : subnets) {
- if (!subnetStore.containsKey(subnet.id())) {
- log.debug("The subnet is not exist whose identifier is {}",
- subnet.id().toString());
- return false;
- }
-
- subnetStore.put(subnet.id(), subnet);
-
- if (!subnet.equals(subnetStore.get(subnet.id()))) {
- log.debug("The subnet is updated failed whose identifier is {}",
- subnet.id().toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean removeSubnets(Iterable<SubnetId> subnetIds) {
- checkNotNull(subnetIds, SUBNET_ID_NULL);
- for (SubnetId subnetId : subnetIds) {
- subnetStore.remove(subnetId);
- if (subnetStore.containsKey(subnetId)) {
- log.debug("The subnet created is failed whose identifier is {}",
- subnetId.toString());
- return false;
- }
- }
- return true;
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java
deleted file mode 100644
index cff1593..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of the Subnet service.
- */
-package org.onosproject.vtnrsc.subnet.impl;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java
deleted file mode 100644
index 26c27ff..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with the inventory of subnets.
- */
-package org.onosproject.vtnrsc.subnet;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java
deleted file mode 100644
index 296c0e8..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.tenantnetwork;
-
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-
-/**
- * Service for interacting with the inventory of tenantNetwork.
- */
-public interface TenantNetworkService {
-
- /**
- * Returns if the tenantNetwork is existed.
- *
- * @param networkId tenantNetwork identifier
- * @return true or false if one with the given identifier exists.
- */
- boolean exists(TenantNetworkId networkId);
-
- /**
- * Returns the number of tenantNetwork known to the system.
- *
- * @return number of tenantNetwork.
- */
- int getNetworkCount();
-
- /**
- * Returns an iterable collection of the currently known tenantNetwork.
- *
- * @return collection of tenantNetwork.
- */
- Iterable<TenantNetwork> getNetworks();
-
- /**
- * Returns the tenantNetwork with the identifier.
- *
- * @param networkId TenantNetwork identifier
- * @return TenantNetwork or null if one with the given identifier is not
- * known.
- */
- TenantNetwork getNetwork(TenantNetworkId networkId);
-
- /**
- * Creates tenantNetworks by networks.
- *
- * @param networks the collection of tenantNetworks
- * @return true if all given identifiers created successfully.
- */
- boolean createNetworks(Iterable<TenantNetwork> networks);
-
- /**
- * Updates tenantNetworks by tenantNetworks.
- *
- * @param networks the collection of tenantNetworks
- * @return true if all given identifiers updated successfully.
- */
- boolean updateNetworks(Iterable<TenantNetwork> networks);
-
- /**
- * Deletes tenantNetwork by tenantNetworkIds.
- *
- * @param networksIds the collection of tenantNetworkIds
- * @return true if the specified tenantNetworks deleted successfully.
- */
- boolean removeNetworks(Iterable<TenantNetworkId> networksIds);
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java
deleted file mode 100644
index 753e38a..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.tenantnetwork.impl;
-
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.vtnrsc.DefaultTenantNetwork;
-import org.onosproject.vtnrsc.PhysicalNetwork;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the tenantNetworkService.
- */
-@Component(immediate = true, service = TenantNetworkService.class)
-public class TenantNetworkManager implements TenantNetworkService {
-
- private static final String NETWORK_ID_NULL = "Network ID cannot be null";
- private static final String NETWORK_NOT_NULL = "Network ID cannot be null";
- private static final String TENANTNETWORK = "vtn-tenant-network-store";
- private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
-
- protected Map<TenantNetworkId, TenantNetwork> networkIdAsKeyStore;
- protected ApplicationId appId;
-
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
-
- @Activate
- public void activate() {
-
- appId = coreService.registerApplication(VTNRSC_APP);
-
- networkIdAsKeyStore = storageService.<TenantNetworkId, TenantNetwork>consistentMapBuilder()
- .withName(TENANTNETWORK)
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
- TenantNetworkId.class,
- DefaultTenantNetwork.class,
- TenantNetwork.State.class,
- TenantId.class,
- TenantNetwork.Type.class,
- PhysicalNetwork.class,
- SegmentationId.class))
- .build().asJavaMap();
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public boolean exists(TenantNetworkId networkId) {
- checkNotNull(networkId, NETWORK_ID_NULL);
- return networkIdAsKeyStore.containsKey(networkId);
- }
-
- @Override
- public int getNetworkCount() {
- return networkIdAsKeyStore.size();
- }
-
- @Override
- public Iterable<TenantNetwork> getNetworks() {
- return Collections.unmodifiableCollection(networkIdAsKeyStore.values());
- }
-
- @Override
- public TenantNetwork getNetwork(TenantNetworkId networkId) {
- checkNotNull(networkId, NETWORK_ID_NULL);
- return networkIdAsKeyStore.get(networkId);
- }
-
- @Override
- public boolean createNetworks(Iterable<TenantNetwork> networks) {
- checkNotNull(networks, NETWORK_NOT_NULL);
- for (TenantNetwork network : networks) {
- networkIdAsKeyStore.put(network.id(), network);
- if (!networkIdAsKeyStore.containsKey(network.id())) {
- log.debug("The tenantNetwork is created failed which identifier was {}", network.id()
- .toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean updateNetworks(Iterable<TenantNetwork> networks) {
- checkNotNull(networks, NETWORK_NOT_NULL);
- for (TenantNetwork network : networks) {
- if (!networkIdAsKeyStore.containsKey(network.id())) {
- log.debug("The tenantNetwork is not exist whose identifier was {} ",
- network.id().toString());
- return false;
- }
-
- networkIdAsKeyStore.put(network.id(), network);
-
- if (!network.equals(networkIdAsKeyStore.get(network.id()))) {
- log.debug("The tenantNetwork is updated failed whose identifier was {} ",
- network.id().toString());
- return false;
- }
-
- }
- return true;
- }
-
- @Override
- public boolean removeNetworks(Iterable<TenantNetworkId> networkIds) {
- checkNotNull(networkIds, NETWORK_NOT_NULL);
- for (TenantNetworkId networkId : networkIds) {
- networkIdAsKeyStore.remove(networkId);
- if (networkIdAsKeyStore.containsKey(networkId)) {
- log.debug("The tenantNetwork is removed failed whose identifier was {}",
- networkId.toString());
- return false;
- }
- }
- return true;
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java
deleted file mode 100644
index c243f26..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of service for interacting with the inventory of tenant networks.
- */
-package org.onosproject.vtnrsc.tenantnetwork.impl;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java
deleted file mode 100644
index a99d3cc..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with the inventory of tenant networks.
- */
-package org.onosproject.vtnrsc.tenantnetwork;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortEvent.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortEvent.java
deleted file mode 100644
index e991bf8..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortEvent.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.virtualport;
-
-import org.onosproject.event.AbstractEvent;
-import org.onosproject.vtnrsc.VirtualPort;
-
-/**
- * Describes virtual port event.
- */
-public class VirtualPortEvent extends AbstractEvent<VirtualPortEvent.Type, VirtualPort> {
- /**
- * Type of virtual port events.
- */
- public enum Type {
- /**
- * Signifies that virtual port has been created.
- */
- VIRTUAL_PORT_PUT,
- /**
- * Signifies that virtual port has been deleted.
- */
- VIRTUAL_PORT_DELETE,
- /**
- * Signifies that virtual port has been updated.
- */
- VIRTUAL_PORT_UPDATE
- }
-
- /**
- * Creates an event of a given type and for the specified virtual port.
- *
- * @param type virtual port event type
- * @param virtualPort virtual port subject
- */
- public VirtualPortEvent(Type type, VirtualPort virtualPort) {
- super(type, virtualPort);
- }
-
- /**
- * Creates an event of a given type and for the specified virtual port.
- *
- * @param type virtual port event type
- * @param virtualPort virtual port subject
- * @param time occurrence time
- */
- public VirtualPortEvent(Type type, VirtualPort virtualPort, long time) {
- super(type, virtualPort, time);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortListener.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortListener.java
deleted file mode 100644
index cc689cf..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.virtualport;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Entity capable of virtual port related events.
- */
-public interface VirtualPortListener extends EventListener<VirtualPortEvent> {
-
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java
deleted file mode 100644
index 8677c02..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.virtualport;
-
-import java.util.Collection;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onosproject.event.ListenerService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-
-/**
- * Service for interacting with the inventory of virtualPort.
- */
-public interface VirtualPortService extends ListenerService<VirtualPortEvent, VirtualPortListener> {
- /**
- * Returns if the virtualPort is existed.
- *
- * @param virtualPortId virtualPort identifier
- * @return true or false if one with the given identifier is not existed.
- */
- boolean exists(VirtualPortId virtualPortId);
-
- /**
- * Returns the virtualPort with the identifier.
- *
- * @param virtualPortId virtualPort ID
- * @return VirtualPort or null if one with the given ID is not know.
- */
- VirtualPort getPort(VirtualPortId virtualPortId);
-
- /**
- * Returns the virtualPort associated with the fixedIP.
- *
- * @param fixedIP the fixedIP identifier
- * @return virtualPort.
- */
- VirtualPort getPort(FixedIp fixedIP);
-
- /**
- * Returns the virtualPort associated with the mac address.
- *
- * @param mac the mac address
- * @return virtualPort.
- */
- VirtualPort getPort(MacAddress mac);
-
- /**
- * Returns the virtualPort associated with the networkId and ip.
- *
- * @param networkId the TenantNetworkId identifier
- * @param ip the ip identifier
- * @return virtualPort.
- */
- VirtualPort getPort(TenantNetworkId networkId, IpAddress ip);
-
- /**
- * Returns the collection of the currently known virtualPort.
- * @return collection of VirtualPort.
- */
- Collection<VirtualPort> getPorts();
-
- /**
- * Returns the collection of the virtualPorts associated with the networkId.
- *
- * @param networkId the network identifer
- * @return collection of virtualPort.
- */
- Collection<VirtualPort> getPorts(TenantNetworkId networkId);
-
- /**
- * Returns the collection of the virtualPorts associated with the tenantId.
- *
- * @param tenantId the tenant identifier
- * @return collection of virtualPorts.
- */
- Collection<VirtualPort> getPorts(TenantId tenantId);
-
- /**
- * Returns the collection of the virtualPorts associated with the deviceId.
- *
- * @param deviceId the device identifier
- * @return collection of virtualPort.
- */
- Collection<VirtualPort> getPorts(DeviceId deviceId);
-
- /**
- * Creates virtualPorts by virtualPorts.
- *
- * @param virtualPorts the iterable collection of virtualPorts
- * @return true if all given identifiers created successfully.
- */
- boolean createPorts(Iterable<VirtualPort> virtualPorts);
-
- /**
- * Updates virtualPorts by virtualPorts.
- *
- * @param virtualPorts the iterable collection of virtualPorts
- * @return true if all given identifiers updated successfully.
- */
- boolean updatePorts(Iterable<VirtualPort> virtualPorts);
-
- /**
- * Deletes virtualPortIds by virtualPortIds.
- *
- * @param virtualPortIds the iterable collection of virtualPort identifiers
- * @return true or false if one with the given identifier to delete is
- * successfully.
- */
- boolean removePorts(Iterable<VirtualPortId> virtualPortIds);
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
deleted file mode 100644
index 5206e3f..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.virtualport.impl;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.event.AbstractListenerManager;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.EventuallyConsistentMapEvent;
-import org.onosproject.store.service.EventuallyConsistentMapListener;
-import org.onosproject.store.service.MultiValuedTimestamp;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.DefaultFloatingIp;
-import org.onosproject.vtnrsc.DefaultVirtualPort;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.FloatingIp;
-import org.onosproject.vtnrsc.FloatingIpId;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.SecurityGroup;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.TenantRouter;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortEvent;
-import org.onosproject.vtnrsc.virtualport.VirtualPortListener;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Provides implementation of the VirtualPort APIs.
- */
-@Component(immediate = true, service = VirtualPortService.class)
-public class VirtualPortManager extends AbstractListenerManager<VirtualPortEvent, VirtualPortListener>
-implements VirtualPortService {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private static final String VIRTUALPORT = "vtn-virtual-port-store";
- private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
-
- private static final String VIRTUALPORT_ID_NULL = "VirtualPort ID cannot be null";
- private static final String VIRTUALPORT_NOT_NULL = "VirtualPort cannot be null";
- private static final String TENANTID_NOT_NULL = "TenantId cannot be null";
- private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null";
- private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null";
- private static final String FIXEDIP_NOT_NULL = "FixedIp cannot be null";
- private static final String MAC_NOT_NULL = "Mac address cannot be null";
- private static final String IP_NOT_NULL = "Ip cannot be null";
- private static final String EVENT_NOT_NULL = "event cannot be null";
-
- protected EventuallyConsistentMap<VirtualPortId, VirtualPort> vPortStore;
- protected ApplicationId appId;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TenantNetworkService networkService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- private EventuallyConsistentMapListener<VirtualPortId, VirtualPort> virtualPortListener =
- new InnerVirtualPortStoreListener();
-
- @Activate
- public void activate() {
-
- appId = coreService.registerApplication(VTNRSC_APP);
-
- eventDispatcher.addSink(VirtualPortEvent.class, listenerRegistry);
-
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API)
- .register(MultiValuedTimestamp.class)
- .register(TenantNetworkId.class)
- .register(Host.class)
- .register(TenantNetwork.class)
- .register(TenantNetworkId.class)
- .register(TenantId.class)
- .register(SubnetId.class)
- .register(VirtualPortId.class)
- .register(VirtualPort.State.class)
- .register(AllowedAddressPair.class)
- .register(FixedIp.class)
- .register(FloatingIp.class)
- .register(FloatingIpId.class)
- .register(FloatingIp.Status.class)
- .register(UUID.class)
- .register(DefaultFloatingIp.class)
- .register(BindingHostId.class)
- .register(SecurityGroup.class)
- .register(IpAddress.class)
- .register(DefaultVirtualPort.class)
- .register(RouterId.class)
- .register(TenantRouter.class)
- .register(VirtualPort.class);
- vPortStore = storageService
- .<VirtualPortId, VirtualPort>eventuallyConsistentMapBuilder()
- .withName(VIRTUALPORT).withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp())
- .build();
-
- vPortStore.addListener(virtualPortListener);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- vPortStore.removeListener(virtualPortListener);
- vPortStore.destroy();
- log.info("Stoppped");
- }
-
- @Override
- public boolean exists(VirtualPortId vPortId) {
- checkNotNull(vPortId, VIRTUALPORT_ID_NULL);
- return vPortStore.containsKey(vPortId);
- }
-
- @Override
- public VirtualPort getPort(VirtualPortId vPortId) {
- checkNotNull(vPortId, VIRTUALPORT_ID_NULL);
- return vPortStore.get(vPortId);
- }
-
- @Override
- public VirtualPort getPort(FixedIp fixedIP) {
- checkNotNull(fixedIP, FIXEDIP_NOT_NULL);
- List<VirtualPort> vPorts = new ArrayList<>();
- vPortStore.values().forEach(p -> {
- Iterator<FixedIp> fixedIps = p.fixedIps().iterator();
- while (fixedIps.hasNext()) {
- if (fixedIps.next().equals(fixedIP)) {
- vPorts.add(p);
- break;
- }
- }
- });
- if (vPorts.isEmpty()) {
- return null;
- }
- return vPorts.get(0);
- }
-
- @Override
- public VirtualPort getPort(MacAddress mac) {
- checkNotNull(mac, MAC_NOT_NULL);
- List<VirtualPort> vPorts = new ArrayList<>();
- vPortStore.values().forEach(p -> {
- if (p.macAddress().equals(mac)) {
- vPorts.add(p);
- }
- });
- if (vPorts.isEmpty()) {
- return null;
- }
- return vPorts.get(0);
- }
-
- @Override
- public VirtualPort getPort(TenantNetworkId networkId, IpAddress ip) {
- checkNotNull(networkId, NETWORKID_NOT_NULL);
- checkNotNull(ip, IP_NOT_NULL);
- List<VirtualPort> vPorts = new ArrayList<>();
- vPortStore.values().stream().filter(p -> p.networkId().equals(networkId))
- .forEach(p -> {
- Iterator<FixedIp> fixedIps = p.fixedIps().iterator();
- while (fixedIps.hasNext()) {
- if (fixedIps.next().ip().equals(ip)) {
- vPorts.add(p);
- break;
- }
- }
- });
- if (vPorts.isEmpty()) {
- return null;
- }
- return vPorts.get(0);
- }
-
- @Override
- public Collection<VirtualPort> getPorts() {
- return Collections.unmodifiableCollection(vPortStore.values());
- }
-
- @Override
- public Collection<VirtualPort> getPorts(TenantNetworkId networkId) {
- checkNotNull(networkId, NETWORKID_NOT_NULL);
- return vPortStore.values().stream().filter(d -> d.networkId().equals(networkId))
- .collect(Collectors.toList());
- }
-
- @Override
- public Collection<VirtualPort> getPorts(TenantId tenantId) {
- checkNotNull(tenantId, TENANTID_NOT_NULL);
- return vPortStore.values().stream().filter(d -> d.tenantId().equals(tenantId))
- .collect(Collectors.toList());
- }
-
- @Override
- public Collection<VirtualPort> getPorts(DeviceId deviceId) {
- checkNotNull(deviceId, DEVICEID_NOT_NULL);
- return vPortStore.values().stream().filter(d -> d.deviceId().equals(deviceId))
- .collect(Collectors.toList());
- }
-
- @Override
- public boolean createPorts(Iterable<VirtualPort> vPorts) {
- checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);
- for (VirtualPort vPort : vPorts) {
- log.debug("vPortId is {} ", vPort.portId().toString());
- vPortStore.put(vPort.portId(), vPort);
- if (!vPortStore.containsKey(vPort.portId())) {
- log.debug("The virtualPort is created failed whose identifier is {} ",
- vPort.portId().toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean updatePorts(Iterable<VirtualPort> vPorts) {
- checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);
- for (VirtualPort vPort : vPorts) {
- vPortStore.put(vPort.portId(), vPort);
- if (!vPortStore.containsKey(vPort.portId())) {
- log.debug("The virtualPort is not exist whose identifier is {}",
- vPort.portId().toString());
- return false;
- }
-
- vPortStore.put(vPort.portId(), vPort);
-
- if (!vPort.equals(vPortStore.get(vPort.portId()))) {
- log.debug("The virtualPort is updated failed whose identifier is {}",
- vPort.portId().toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean removePorts(Iterable<VirtualPortId> vPortIds) {
- checkNotNull(vPortIds, VIRTUALPORT_ID_NULL);
- for (VirtualPortId vPortId : vPortIds) {
- vPortStore.remove(vPortId);
- if (vPortStore.containsKey(vPortId)) {
- log.debug("The virtualPort is removed failed whose identifier is {}",
- vPortId.toString());
- return false;
- }
- }
- return true;
- }
-
- private class InnerVirtualPortStoreListener
- implements
- EventuallyConsistentMapListener<VirtualPortId, VirtualPort> {
-
- @Override
- public void event(EventuallyConsistentMapEvent<VirtualPortId, VirtualPort> event) {
- checkNotNull(event, EVENT_NOT_NULL);
- log.info("virtual port event raised");
- VirtualPort virtualPort = event.value();
- if (EventuallyConsistentMapEvent.Type.PUT == event.type()) {
- notifyListeners(new VirtualPortEvent(
- VirtualPortEvent.Type.VIRTUAL_PORT_PUT,
- virtualPort));
- }
- if (EventuallyConsistentMapEvent.Type.REMOVE == event.type()) {
- notifyListeners(new VirtualPortEvent(
- VirtualPortEvent.Type.VIRTUAL_PORT_DELETE,
- virtualPort));
- }
- }
- }
-
- /**
- * Notifies specify event to all listeners.
- *
- * @param event virtual port event
- */
- private void notifyListeners(VirtualPortEvent event) {
- checkNotNull(event, EVENT_NOT_NULL);
- post(event);
- }
-}
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java
deleted file mode 100644
index 4a4bee7..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of service for interacting with the inventory of virtual ports.
- */
-package org.onosproject.vtnrsc.virtualport.impl;
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java
deleted file mode 100644
index 77da017..0000000
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with the inventory of virtual ports.
- */
-package org.onosproject.vtnrsc.virtualport;
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/AllowedAddressPairTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/AllowedAddressPairTest.java
deleted file mode 100644
index 19e9a62..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/AllowedAddressPairTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for AllowedAddressPair class.
- */
-public class AllowedAddressPairTest {
-
- final IpAddress ip1 = IpAddress.valueOf("192.168.0.1");
- final IpAddress ip2 = IpAddress.valueOf("192.168.0.2");
- final MacAddress mac1 = MacAddress.valueOf("fa:16:3e:76:83:88");
- final MacAddress mac2 = MacAddress.valueOf("aa:16:3e:76:83:88");
-
- /**
- * Checks that the AllowedAddressPair class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(AllowedAddressPair.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- AllowedAddressPair p1 = AllowedAddressPair
- .allowedAddressPair(ip1, mac1);
- AllowedAddressPair p2 = AllowedAddressPair
- .allowedAddressPair(ip1, mac1);
- AllowedAddressPair p3 = AllowedAddressPair
- .allowedAddressPair(ip2, mac2);
- new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3)
- .testEquals();
- }
-
- /**
- * Checks the construction of a AllowedAddressPair object.
- */
- @Test
- public void testConstruction() {
- AllowedAddressPair allowedAddressPair = AllowedAddressPair
- .allowedAddressPair(ip1, mac1);
- assertThat(ip1, is(notNullValue()));
- assertThat(ip1, is(allowedAddressPair.ip()));
- assertThat(mac1, is(notNullValue()));
- assertThat(mac1, is(allowedAddressPair.mac()));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultAllocationPoolTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultAllocationPoolTest.java
deleted file mode 100644
index 422da00..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultAllocationPoolTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for DefaultAllocationPool class.
- */
-public class DefaultAllocationPoolTest {
-
- final IpAddress startIP1 = IpAddress.valueOf("192.168.1.1");
- final IpAddress startIP2 = IpAddress.valueOf("192.168.1.2");
- final IpAddress endIP1 = IpAddress.valueOf("192.168.1.1");
- final IpAddress endIP2 = IpAddress.valueOf("192.168.1.2");
-
- /**
- * Checks that the DefaultAllocationPool class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultAllocationPool.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- AllocationPool pool1 = new DefaultAllocationPool(startIP1, endIP1);
- AllocationPool pool2 = new DefaultAllocationPool(startIP1, endIP1);
- AllocationPool pool3 = new DefaultAllocationPool(startIP2, endIP2);
- new EqualsTester().addEqualityGroup(pool1, pool2)
- .addEqualityGroup(pool3).testEquals();
- }
-
- /**
- * Checks the construction of a DefaultAllocationPool object.
- */
- @Test
- public void testConstruction() {
- final AllocationPool apool = new DefaultAllocationPool(startIP1, endIP1);
- assertThat(startIP1, is(apool.startIp()));
- assertThat(endIP1, is(apool.endIp()));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultFiveTupleTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultFiveTupleTest.java
deleted file mode 100644
index 3015534..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultFiveTupleTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.IpAddress;
-import org.onosproject.net.PortNumber;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for FiveTuple class.
- */
-public class DefaultFiveTupleTest {
-
-
- final FiveTuple fiveTuple1 = DefaultFiveTuple.builder().setIpSrc(IpAddress.valueOf("1.1.1.1"))
- .setIpDst(IpAddress.valueOf("2.2.2.2"))
- .setPortSrc(PortNumber.portNumber(500))
- .setPortDst(PortNumber.portNumber(1000))
- .setProtocol(IPv4.PROTOCOL_TCP)
- .setTenantId(TenantId.tenantId("aaa"))
- .build();
-
- final FiveTuple sameAsFiveTuple1 = DefaultFiveTuple.builder().setIpSrc(IpAddress.valueOf("1.1.1.1"))
- .setIpDst(IpAddress.valueOf("2.2.2.2"))
- .setPortSrc(PortNumber.portNumber(500))
- .setPortDst(PortNumber.portNumber(1000))
- .setProtocol(IPv4.PROTOCOL_TCP)
- .setTenantId(TenantId.tenantId("aaa"))
- .build();
-
- final FiveTuple fiveTuple2 = DefaultFiveTuple.builder().setIpSrc(IpAddress.valueOf("3.3.3.3"))
- .setIpDst(IpAddress.valueOf("4.4.4.4"))
- .setPortSrc(PortNumber.portNumber(1500))
- .setPortDst(PortNumber.portNumber(2000))
- .setProtocol(IPv4.PROTOCOL_UDP)
- .setTenantId(TenantId.tenantId("bbb"))
- .build();
-
- /**
- * Checks that the FiveTuple class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultFiveTuple.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(fiveTuple1, sameAsFiveTuple1).addEqualityGroup(fiveTuple2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a FiveTuple object.
- */
- @Test
- public void testConstruction() {
- final FiveTuple fiveTuple1 = DefaultFiveTuple.builder().setIpSrc(IpAddress.valueOf("1.1.1.1"))
- .setIpDst(IpAddress.valueOf("2.2.2.2"))
- .setPortSrc(PortNumber.portNumber(500))
- .setPortDst(PortNumber.portNumber(1000))
- .setProtocol(IPv4.PROTOCOL_TCP)
- .setTenantId(TenantId.tenantId("aaa"))
- .build();
-
- assertThat(fiveTuple1, is(notNullValue()));
- assertThat(fiveTuple1.protocol(), is(IPv4.PROTOCOL_TCP));
- assertThat(fiveTuple1.ipSrc(), is(IpAddress.valueOf("1.1.1.1")));
- assertThat(fiveTuple1.ipDst(), is(IpAddress.valueOf("2.2.2.2")));
- assertThat(fiveTuple1.portSrc(), is(PortNumber.portNumber(500)));
- assertThat(fiveTuple1.portDst(), is(PortNumber.portNumber(1000)));
- assertThat(fiveTuple1.tenantId(), is(TenantId.tenantId("aaa")));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultFlowClassifierTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultFlowClassifierTest.java
deleted file mode 100644
index 743c5a4..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultFlowClassifierTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-import org.onlab.packet.IpPrefix;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for DefaultFlowClassifier class.
- */
-public class DefaultFlowClassifierTest {
- /**
- * Checks that the DefaultFlowClassifier class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultFlowClassifier.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- // Create same two flow classifier objects.
- final String name = "FlowClassifier1";
- final String description = "FlowClassifier1";
- final String ethType = "IPv4";
- final String protocol = "tcp";
- final int priority = 65535;
- final int minSrcPortRange = 5;
- final int maxSrcPortRange = 10;
- final int minDstPortRange = 5;
- final int maxDstPortRange = 10;
- final FlowClassifierId flowClassifierId = FlowClassifierId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final IpPrefix srcIpPrefix = IpPrefix.valueOf("0.0.0.0/0");
- final IpPrefix dstIpPrefix = IpPrefix.valueOf("10.10.10.10/0");
- final VirtualPortId virtualSrcPort = VirtualPortId.portId("1");
- final VirtualPortId virtualDstPort = VirtualPortId.portId("2");
-
- DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder();
- final FlowClassifier flowClassifier1 = flowClassifierBuilder.setFlowClassifierId(flowClassifierId)
- .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType)
- .setProtocol(protocol).setPriority(priority).setMinSrcPortRange(minSrcPortRange)
- .setMaxSrcPortRange(maxSrcPortRange).setMinDstPortRange(minDstPortRange)
- .setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix).setDstIpPrefix(dstIpPrefix)
- .setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build();
-
- flowClassifierBuilder = new DefaultFlowClassifier.Builder();
- final FlowClassifier sameAsFlowClassifier1 = flowClassifierBuilder.setFlowClassifierId(flowClassifierId)
- .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType)
- .setProtocol(protocol).setPriority(priority).setMinSrcPortRange(minSrcPortRange)
- .setMaxSrcPortRange(maxSrcPortRange).setMinDstPortRange(minDstPortRange)
- .setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix).setDstIpPrefix(dstIpPrefix)
- .setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build();
-
- // Create different classifier object.
- final String name2 = "FlowClassifier2";
- final String description2 = "FlowClassifier2";
- final String ethType2 = "IPv6";
- final String protocol2 = "udp";
- final int priority2 = 50000;
- final int minSrcPortRange2 = 5;
- final int maxSrcPortRange2 = 10;
- final int minDstPortRange2 = 5;
- final int maxDstPortRange2 = 10;
- final FlowClassifierId flowClassifierId2 = FlowClassifierId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId2 = TenantId.tenantId("2");
- final IpPrefix srcIpPrefix2 = IpPrefix.valueOf("0.0.0.0/0");
- final IpPrefix dstIpPrefix2 = IpPrefix.valueOf("10.10.10.10/0");
- final VirtualPortId virtualSrcPort2 = VirtualPortId.portId("3");
- final VirtualPortId virtualDstPort2 = VirtualPortId.portId("4");
-
- DefaultFlowClassifier.Builder flowClassifierBuilder3 = new DefaultFlowClassifier.Builder();
- final FlowClassifier flowClassifier2 = flowClassifierBuilder3.setFlowClassifierId(flowClassifierId2)
- .setTenantId(tenantId2).setName(name2).setDescription(description2).setEtherType(ethType2)
- .setProtocol(protocol2).setMinSrcPortRange(minSrcPortRange2).setMaxSrcPortRange(maxSrcPortRange2)
- .setMinDstPortRange(minDstPortRange2).setMaxDstPortRange(maxDstPortRange2).setSrcIpPrefix(srcIpPrefix2)
- .setDstIpPrefix(dstIpPrefix2).setSrcPort(virtualSrcPort2).setDstPort(virtualDstPort2)
- .setPriority(priority2).build();
-
- new EqualsTester().addEqualityGroup(flowClassifier1, sameAsFlowClassifier1).addEqualityGroup(flowClassifier2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a DefaultFlowClassifier object.
- */
- @Test
- public void testConstruction() {
- final String name = "FlowClassifier";
- final String description = "FlowClassifier";
- final String ethType = "IPv4";
- final String protocol = "tcp";
- final int priority = 30000;
- final int minSrcPortRange = 5;
- final int maxSrcPortRange = 10;
- final int minDstPortRange = 5;
- final int maxDstPortRange = 10;
- final FlowClassifierId flowClassifierId = FlowClassifierId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final IpPrefix srcIpPrefix = IpPrefix.valueOf("0.0.0.0/0");
- final IpPrefix dstIpPrefix = IpPrefix.valueOf("10.10.10.10/0");
- final VirtualPortId virtualSrcPort = VirtualPortId.portId("1");
- final VirtualPortId virtualDstPort = VirtualPortId.portId("2");
-
- DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder();
- final FlowClassifier flowClassifier = flowClassifierBuilder.setFlowClassifierId(flowClassifierId)
- .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType)
- .setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange)
- .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix)
- .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort)
- .setPriority(priority).build();
-
- assertThat(flowClassifierId, is(flowClassifier.flowClassifierId()));
- assertThat(tenantId, is(flowClassifier.tenantId()));
- assertThat(name, is(flowClassifier.name()));
- assertThat(description, is(flowClassifier.description()));
- assertThat(ethType, is(flowClassifier.etherType()));
- assertThat(protocol, is(flowClassifier.protocol()));
- assertThat(priority, is(flowClassifier.priority()));
- assertThat(minSrcPortRange, is(flowClassifier.minSrcPortRange()));
- assertThat(maxSrcPortRange, is(flowClassifier.maxSrcPortRange()));
- assertThat(minDstPortRange, is(flowClassifier.minDstPortRange()));
- assertThat(maxDstPortRange, is(flowClassifier.maxDstPortRange()));
- assertThat(srcIpPrefix, is(flowClassifier.srcIpPrefix()));
- assertThat(dstIpPrefix, is(flowClassifier.dstIpPrefix()));
- assertThat(virtualSrcPort, is(flowClassifier.srcPort()));
- assertThat(virtualDstPort, is(flowClassifier.dstPort()));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultHostRouteTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultHostRouteTest.java
deleted file mode 100644
index 8bfde9c..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultHostRouteTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for DefaultHostRoute class.
- */
-public class DefaultHostRouteTest {
- final IpAddress nexthop1 = IpAddress.valueOf("192.168.1.1");
- final IpAddress nexthop2 = IpAddress.valueOf("192.168.1.2");
- final IpPrefix destination1 = IpPrefix.valueOf("1.1.1.1/1");
- final IpPrefix destination2 = IpPrefix.valueOf("1.1.1.1/2");
-
- /**
- * Checks that the DefaultHostRoute class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultHostRoute.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- HostRoute route1 = new DefaultHostRoute(nexthop1, destination1);
- HostRoute route2 = new DefaultHostRoute(nexthop1, destination1);
- HostRoute route3 = new DefaultHostRoute(nexthop2, destination2);
- new EqualsTester().addEqualityGroup(route1, route2)
- .addEqualityGroup(route3).testEquals();
- }
-
- /**
- * Checks the construction of a DefaultHostRoute object.
- */
- @Test
- public void testConstruction() {
- final HostRoute host = new DefaultHostRoute(nexthop1, destination1);
- assertThat(nexthop1, is(host.nexthop()));
- assertThat(destination1, is(host.destination()));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultNeutronNetworkTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultNeutronNetworkTest.java
deleted file mode 100644
index 93edd8f..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultNeutronNetworkTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for DefaultNeutronNetwork class.
- */
-public class DefaultNeutronNetworkTest {
-
- private String networkIdStr1 = "123";
- private String networkIdStr2 = "234";
- private String physicalNetworkStr = "1234";
- private String tenantIdStr = "345";
- private String segmentationIdStr = "1";
- private String name = "456";
-
- /**
- * Checks that the DefaultNeutronNetwork class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultTenantNetwork.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquality() {
- TenantNetworkId networkid1 = TenantNetworkId.networkId(networkIdStr1);
- TenantNetworkId networkid2 = TenantNetworkId.networkId(networkIdStr2);
- PhysicalNetwork physicalNetwork = PhysicalNetwork
- .physicalNetwork(physicalNetworkStr);
- TenantId tenantId = TenantId.tenantId(tenantIdStr);
- SegmentationId segmentationID = SegmentationId
- .segmentationId(segmentationIdStr);
- TenantNetwork p1 = new DefaultTenantNetwork(networkid1, name, false,
- TenantNetwork.State.ACTIVE,
- false, tenantId, false,
- TenantNetwork.Type.LOCAL,
- physicalNetwork,
- segmentationID);
- TenantNetwork p2 = new DefaultTenantNetwork(networkid1, name, false,
- TenantNetwork.State.ACTIVE,
- false, tenantId, false,
- TenantNetwork.Type.LOCAL,
- physicalNetwork,
- segmentationID);
- TenantNetwork p3 = new DefaultTenantNetwork(networkid2, name, false,
- TenantNetwork.State.ACTIVE,
- false, tenantId, false,
- TenantNetwork.Type.LOCAL,
- physicalNetwork,
- segmentationID);
- new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3)
- .testEquals();
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultPortChainTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultPortChainTest.java
deleted file mode 100644
index dc1d1ac..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultPortChainTest.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import org.junit.Test;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.IpAddress;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-
-import com.google.common.collect.Lists;
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for DefaultPortChain class.
- */
-public class DefaultPortChainTest {
-
- final PortChainId portChainId = PortChainId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortChain";
- final String description = "PortChain";
- final List<PortPairGroupId> portPairGroups = new LinkedList<PortPairGroupId>();
- final List<FlowClassifierId> flowClassifiers = new LinkedList<FlowClassifierId>();
-
- private PortChain getPortChain() {
-
- portPairGroups.clear();
- flowClassifiers.clear();
- // create list of Port Pair Groups.
- PortPairGroupId portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairGroups.add(portPairGroupId);
- portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3af");
- portPairGroups.add(portPairGroupId);
- // create list of Flow classifiers.
- FlowClassifierId flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae");
- flowClassifiers.add(flowClassifierId);
- flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3af");
- flowClassifiers.add(flowClassifierId);
-
- DefaultPortChain.Builder portChainBuilder = new DefaultPortChain.Builder();
- final PortChain portChain = portChainBuilder.setId(portChainId).setTenantId(tenantId).setName(name)
- .setDescription(description).setPortPairGroups(portPairGroups).setFlowClassifiers(flowClassifiers)
- .build();
-
- return portChain;
- }
-
- /**
- * Checks that the DefaultPortChain class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultPortChain.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
-
- // Create same two port chain objects.
- final PortChain portChain1 = getPortChain();
- final PortChain samePortChain1 = getPortChain();
-
- // Create different port chain object.
- final PortChainId portChainId2 = PortChainId.of("79999999-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId2 = TenantId.tenantId("2");
- final String name2 = "PortChain2";
- final String description2 = "PortChain2";
- // create list of Port Pair Groups.
- final List<PortPairGroupId> portPairGroups2 = new LinkedList<PortPairGroupId>();
- PortPairGroupId portPairGroupId = PortPairGroupId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairGroups2.add(portPairGroupId);
- portPairGroupId = PortPairGroupId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3af");
- portPairGroups2.add(portPairGroupId);
- // create list of Flow classifiers.
- final List<FlowClassifierId> flowClassifiers2 = new LinkedList<FlowClassifierId>();
- FlowClassifierId flowClassifierId = FlowClassifierId.of("76666666-fc23-aeb6-f44b-56dc5e2fb3ae");
- flowClassifiers2.add(flowClassifierId);
- flowClassifierId = FlowClassifierId.of("76666666-fc23-aeb6-f44b-56dc5e2fb3af");
- flowClassifiers2.add(flowClassifierId);
-
- DefaultPortChain.Builder portChainBuilder = new DefaultPortChain.Builder();
- final PortChain portChain2 = portChainBuilder.setId(portChainId2).setTenantId(tenantId2).setName(name2)
- .setDescription(description2).setPortPairGroups(portPairGroups2).setFlowClassifiers(flowClassifiers2)
- .build();
-
- new EqualsTester().addEqualityGroup(portChain1, samePortChain1).addEqualityGroup(portChain2).testEquals();
- }
-
- /**
- * Checks the construction of a DefaultPortChain object.
- */
- @Test
- public void testConstruction() {
-
- final PortChain portChain = getPortChain();
-
- assertThat(portChainId, is(portChain.portChainId()));
- assertThat(tenantId, is(portChain.tenantId()));
- assertThat(name, is(portChain.name()));
- assertThat(description, is(portChain.description()));
- assertThat(portPairGroups, is(portChain.portPairGroups()));
- assertThat(flowClassifiers, is(portChain.flowClassifiers()));
- }
-
- /**
- * Verifies the load balance data structures.
- */
- @Test
- public void testLoadBalanceIdMap() {
-
- final PortChain portChain = getPortChain();
-
- final FiveTuple fiveTuple1 = DefaultFiveTuple.builder().setIpSrc(IpAddress.valueOf("1.1.1.1"))
- .setIpDst(IpAddress.valueOf("2.2.2.2"))
- .setPortSrc(PortNumber.portNumber(500))
- .setPortDst(PortNumber.portNumber(1000))
- .setProtocol(IPv4.PROTOCOL_TCP)
- .build();
-
- PortPairId portPairId = PortPairId.of("a4444444-4a56-2a6e-cd3a-9dee4e2ec345");
-
- final LoadBalanceId id1 = LoadBalanceId.of((byte) 1);
-
- List<PortPairId> tempPath = Lists.newArrayList();
- tempPath.add(portPairId);
-
- portChain.addLoadBalancePath(fiveTuple1, id1, tempPath);
- Set<FiveTuple> keys = portChain.getLoadBalanceIdMapKeys();
- List<PortPairId> path = portChain.getLoadBalancePath(fiveTuple1);
-
- assertThat(portChain.getLoadBalancePath(fiveTuple1), is(path));
- assertThat(portChain.getLoadBalancePath(id1), is(path));
- assertThat(portChain.getLoadBalanceId(fiveTuple1), is(id1));
- assertThat(keys.contains(fiveTuple1), is(true));
- assertThat(path.contains(portPairId), is(true));
- }
-
- /**
- * Verifies sfc classifiers.
- */
- @Test
- public void testSfcClassifier() {
- final PortChain portChain = getPortChain();
-
- final LoadBalanceId id1 = LoadBalanceId.of((byte) 1);
- List<DeviceId> classifierList = Lists.newArrayList();
- DeviceId deviceId1 = DeviceId.deviceId("of:000000001");
- classifierList.add(deviceId1);
- DeviceId deviceId2 = DeviceId.deviceId("of:000000002");
- classifierList.add(deviceId2);
- portChain.addSfcClassifiers(id1, classifierList);
-
- assertThat(portChain.getSfcClassifiers(id1).contains(deviceId1), is(true));
- }
-
- /**
- * Verifies sfc forwarders.
- */
- @Test
- public void testSfcForwarder() {
- final PortChain portChain = getPortChain();
-
- final LoadBalanceId id1 = LoadBalanceId.of((byte) 1);
- List<DeviceId> forwarderList = Lists.newArrayList();
- DeviceId deviceId1 = DeviceId.deviceId("of:000000001");
- forwarderList.add(deviceId1);
- DeviceId deviceId2 = DeviceId.deviceId("of:000000002");
- forwarderList.add(deviceId2);
- portChain.addSfcForwarders(id1, forwarderList);
-
- assertThat(portChain.getSfcForwarders(id1).contains(deviceId1), is(true));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultPortPairGroupTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultPortPairGroupTest.java
deleted file mode 100644
index 305ded3..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultPortPairGroupTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for DefaultPortPairGroup class.
- */
-public class DefaultPortPairGroupTest {
-
- final PortPairGroupId portPairGroupId = PortPairGroupId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortPairGroup1";
- final String description = "PortPairGroup1";
- final List<PortPairId> portPairList = new LinkedList<PortPairId>();
-
- private PortPairGroup getPortPairGroup() {
-
- portPairList.clear();
- // Create same two port-pair-group objects.
- PortPairId portPairId = PortPairId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairList.add(portPairId);
- portPairId = PortPairId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairList.add(portPairId);
-
- DefaultPortPairGroup.Builder portPairGroupBuilder = new DefaultPortPairGroup.Builder();
- PortPairGroup portPairGroup = portPairGroupBuilder.setId(portPairGroupId).setTenantId(tenantId)
- .setName(name).setDescription(description).setPortPairs(portPairList).build();
-
- return portPairGroup;
-
- }
-
- /**
- * Checks that the DefaultPortPairGroup class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultPortPairGroup.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
-
- final PortPairGroup portPairGroup1 = getPortPairGroup();
-
- DefaultPortPairGroup.Builder portPairGroupBuilder = new DefaultPortPairGroup.Builder();
- final PortPairGroup samePortPairGroup1 = getPortPairGroup();
-
- // Create different port-pair-group object.
- final PortPairGroupId portPairGroupId2 = PortPairGroupId.of("79999999-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId2 = TenantId.tenantId("2");
- final String name2 = "PortPairGroup2";
- final String description2 = "PortPairGroup2";
- // create port-pair-id list
- final List<PortPairId> portPairList2 = new LinkedList<PortPairId>();
- PortPairId portPairId = PortPairId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairList2.add(portPairId);
- portPairId = PortPairId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairList2.add(portPairId);
-
- portPairGroupBuilder = new DefaultPortPairGroup.Builder();
- final PortPairGroup portPairGroup2 = portPairGroupBuilder.setId(portPairGroupId2).setTenantId(tenantId2)
- .setName(name2).setDescription(description2).setPortPairs(portPairList2).build();
-
- new EqualsTester().addEqualityGroup(portPairGroup1, samePortPairGroup1).addEqualityGroup(portPairGroup2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a DefaultPortPairGroup object.
- */
- @Test
- public void testConstruction() {
-
- final PortPairGroup portPairGroup = getPortPairGroup();
-
- assertThat(portPairGroupId, is(portPairGroup.portPairGroupId()));
- assertThat(tenantId, is(portPairGroup.tenantId()));
- assertThat(name, is(portPairGroup.name()));
- assertThat(description, is(portPairGroup.description()));
- assertThat(portPairList, is(portPairGroup.portPairs()));
- }
-
- /**
- * Checks the port pair load map.
- */
- @Test
- public void testPortPairLod() {
-
- PortPairId portPairId = PortPairId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- final PortPairGroup portPairGroup = getPortPairGroup();
- int load1 = portPairGroup.getLoad(portPairId);
- portPairGroup.addLoad(portPairId);
- int load2 = portPairGroup.getLoad(portPairId);
-
- assertThat((load1 + 1), is(load2));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultPortPairTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultPortPairTest.java
deleted file mode 100644
index 57855f1..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultPortPairTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for DefaultPortPair class.
- */
-public class DefaultPortPairTest {
- /**
- * Checks that the DefaultPortPair class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultPortPair.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- // Create same two port pair objects.
- final PortPairId portPairId = PortPairId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortPair1";
- final String description = "PortPair1";
- final String ingress = "d3333333-24fc-4fae-af4b-321c5e2eb3d1";
- final String egress = "a4444444-4a56-2a6e-cd3a-9dee4e2ec345";
-
- DefaultPortPair.Builder portPairBuilder = new DefaultPortPair.Builder();
- final PortPair portPair1 = portPairBuilder.setId(portPairId).setTenantId(tenantId).setName(name)
- .setDescription(description).setIngress(ingress).setEgress(egress).build();
-
- portPairBuilder = new DefaultPortPair.Builder();
- final PortPair samePortPair1 = portPairBuilder.setId(portPairId).setTenantId(tenantId).setName(name)
- .setDescription(description).setIngress(ingress).setEgress(egress).build();
-
- // Create different port pair object.
- final PortPairId portPairId2 = PortPairId.of("79999999-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId2 = TenantId.tenantId("2");
- final String name2 = "PortPair2";
- final String description2 = "PortPair2";
- final String ingress2 = "d5555555-24fc-4fae-af4b-321c5e2eb3d1";
- final String egress2 = "a6666666-4a56-2a6e-cd3a-9dee4e2ec345";
-
- portPairBuilder = new DefaultPortPair.Builder();
- final PortPair portPair2 = portPairBuilder.setId(portPairId2).setTenantId(tenantId2).setName(name2)
- .setDescription(description2).setIngress(ingress2).setEgress(egress2).build();
-
- new EqualsTester().addEqualityGroup(portPair1, samePortPair1).addEqualityGroup(portPair2).testEquals();
- }
-
- /**
- * Checks the construction of a DefaultPortPair object.
- */
- @Test
- public void testConstruction() {
- final PortPairId portPairId = PortPairId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortPair";
- final String description = "PortPair";
- final String ingress = "d3333333-24fc-4fae-af4b-321c5e2eb3d1";
- final String egress = "a4444444-4a56-2a6e-cd3a-9dee4e2ec345";
-
- DefaultPortPair.Builder portPairBuilder = new DefaultPortPair.Builder();
- final PortPair portPair = portPairBuilder.setId(portPairId).setTenantId(tenantId).setName(name)
- .setDescription(description).setIngress(ingress).setEgress(egress).build();
-
- assertThat(portPairId, is(portPair.portPairId()));
- assertThat(tenantId, is(portPair.tenantId()));
- assertThat(name, is(portPair.name()));
- assertThat(description, is(portPair.description()));
- assertThat(ingress, is(portPair.ingress()));
- assertThat(egress, is(portPair.egress()));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultVirtualPortTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultVirtualPortTest.java
deleted file mode 100644
index 77f5be3..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/DefaultVirtualPortTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.vtnrsc;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import com.google.common.testing.EqualsTester;
-
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for DefaultVirtualPort class.
- */
-public class DefaultVirtualPortTest {
-
- private Set<FixedIp> fixedIps;
- private Map<String, String> propertyMap;
- private Set<AllowedAddressPair> allowedAddressPairs;
- private Set<SecurityGroup> securityGroups;
- private VirtualPortId id1;
- private VirtualPortId id2;
- private String macAddressStr = "fa:12:3e:56:ee:a2";
- private String ipAddress = "10.1.1.1";
- private String deviceStr = "of:000000000000001";
- private String tenantIdStr = "123";
- private String portId1 = "1241";
- private String portId2 = "1242";
- private String tenantNetworkId = "1234567";
- private String subnet = "1212";
- private String hostIdStr = "fa:e2:3e:56:ee:a2";
-
- private void initVirtualPortId() {
- id1 = VirtualPortId.portId(portId1);
- id2 = VirtualPortId.portId(portId2);
- }
-
- private void initFixedIpSet() {
- FixedIp fixedIp = FixedIp.fixedIp(SubnetId.subnetId(subnet),
- IpAddress.valueOf(ipAddress));
- fixedIps = Sets.newHashSet();
- fixedIps.add(fixedIp);
- }
-
- private void initPropertyMap() {
- String deviceOwner = "james";
- propertyMap = Maps.newHashMap();
- propertyMap.putIfAbsent("deviceOwner", deviceOwner);
- }
-
- private void initAddressPairSet() {
- allowedAddressPairs = Sets.newHashSet();
- AllowedAddressPair allowedAddressPair = AllowedAddressPair
- .allowedAddressPair(IpAddress.valueOf(ipAddress),
- MacAddress.valueOf(macAddressStr));
- allowedAddressPairs.add(allowedAddressPair);
- }
-
- private void initSecurityGroupSet() {
- securityGroups = Sets.newHashSet();
- }
-
- /**
- * Checks that the DefaultVirtualPort class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(SecurityGroup.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- initVirtualPortId();
- initFixedIpSet();
- initPropertyMap();
- initAddressPairSet();
- initSecurityGroupSet();
- TenantNetworkId networkId = TenantNetworkId.networkId(tenantNetworkId);
- MacAddress macAddress = MacAddress.valueOf(macAddressStr);
- TenantId tenantId = TenantId.tenantId(tenantIdStr);
- DeviceId deviceId = DeviceId.deviceId(deviceStr);
- BindingHostId bindingHostId = BindingHostId.bindingHostId(hostIdStr);
-
- VirtualPort d1 = new DefaultVirtualPort(id1, networkId, true,
- propertyMap,
- VirtualPort.State.ACTIVE,
- macAddress, tenantId, deviceId,
- fixedIps, bindingHostId,
- allowedAddressPairs,
- securityGroups);
- VirtualPort d2 = new DefaultVirtualPort(id1, networkId, true,
- propertyMap,
- VirtualPort.State.ACTIVE,
- macAddress, tenantId, deviceId,
- fixedIps, bindingHostId,
- allowedAddressPairs,
- securityGroups);
- VirtualPort d3 = new DefaultVirtualPort(id2, networkId, true,
- propertyMap,
- VirtualPort.State.ACTIVE,
- macAddress, tenantId, deviceId,
- fixedIps, bindingHostId,
- allowedAddressPairs,
- securityGroups);
- new EqualsTester().addEqualityGroup(d1, d2).addEqualityGroup(d3)
- .testEquals();
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/FixedIpTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/FixedIpTest.java
deleted file mode 100644
index b387afe..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/FixedIpTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for FixedIp class.
- */
-public class FixedIpTest {
-
- final SubnetId subnetId1 = SubnetId.subnetId("lef11-95w-4er-9c9c");
- final SubnetId subnetId2 = SubnetId.subnetId("lefaa-95w-4er-9c9c");
- final IpAddress ip1 = IpAddress.valueOf("192.168.0.1");
- final IpAddress ip2 = IpAddress.valueOf("192.168.1.1");
-
- /**
- * Checks that the FixedIp class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(FixedIp.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- FixedIp fixedIp1 = FixedIp.fixedIp(subnetId1, ip1);
- FixedIp fixedIp2 = FixedIp.fixedIp(subnetId1, ip1);
- FixedIp fixedIp3 = FixedIp.fixedIp(subnetId2, ip2);
- new EqualsTester().addEqualityGroup(fixedIp1, fixedIp2)
- .addEqualityGroup(fixedIp3).testEquals();
- }
-
- /**
- * Checks the construction of a FixedIp object.
- */
- @Test
- public void testConstruction() {
- FixedIp fixedIp = FixedIp.fixedIp(subnetId1, ip1);
- assertThat(ip1, is(notNullValue()));
- assertThat(ip1, is(fixedIp.ip()));
- assertThat(subnetId1, is(notNullValue()));
- assertThat(subnetId1, is(fixedIp.subnetId()));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/FlowClassifierIdTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/FlowClassifierIdTest.java
deleted file mode 100644
index dd247c2..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/FlowClassifierIdTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import java.util.UUID;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for FlowClassifierId class.
- */
-public class FlowClassifierIdTest {
-
- final FlowClassifierId flowClassifierId1 = FlowClassifierId
- .of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final FlowClassifierId sameAsFlowClassifierId1 = FlowClassifierId
- .of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final FlowClassifierId flowClassifierId2 = FlowClassifierId
- .of("dace4513-24fc-4fae-af4b-321c5e2eb3d1");
-
- /**
- * Checks that the FlowClassifierId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(FlowClassifierId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(flowClassifierId1, sameAsFlowClassifierId1)
- .addEqualityGroup(flowClassifierId2).testEquals();
- }
-
- /**
- * Checks the construction of a FlowClassifierId object.
- */
- @Test
- public void testConstruction() {
- final String flowClassifierIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1";
- final FlowClassifierId flowClassifierId = FlowClassifierId.of(flowClassifierIdValue);
- assertThat(flowClassifierId, is(notNullValue()));
- assertThat(flowClassifierId.value(), is(UUID.fromString(flowClassifierIdValue)));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/LoadBalanceIdTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/LoadBalanceIdTest.java
deleted file mode 100644
index 55586b81..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/LoadBalanceIdTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for LoadBalanceId class.
- */
-public class LoadBalanceIdTest {
-
- final LoadBalanceId id1 = LoadBalanceId.of((byte) 1);
- final LoadBalanceId sameAsId1 = LoadBalanceId.of((byte) 1);
- final LoadBalanceId id2 = LoadBalanceId.of((byte) 2);
-
- /**
- * Checks that the LoadBalanceId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(LoadBalanceId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(id1, sameAsId1).addEqualityGroup(id2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a LoadBalanceId object.
- */
- @Test
- public void testConstruction() {
- final LoadBalanceId id = LoadBalanceId.of((byte) 1);
- assertThat(id, is(notNullValue()));
- assertThat(id.loadBalanceId(), is((byte) 1));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/PhysicalNetworkTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/PhysicalNetworkTest.java
deleted file mode 100644
index 2da0776..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/PhysicalNetworkTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for PhysicalNetwork class.
- */
-public class PhysicalNetworkTest {
-
- final PhysicalNetwork physicalNetwork1 = PhysicalNetwork.physicalNetwork("1");
- final PhysicalNetwork sameAsPhysicalNetwork1 = PhysicalNetwork.physicalNetwork("1");
- final PhysicalNetwork physicalNetwork2 = PhysicalNetwork.physicalNetwork("2");
-
- /**
- * Checks that the PhysicalNetwork class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(PhysicalNetwork.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(physicalNetwork1, sameAsPhysicalNetwork1)
- .addEqualityGroup(physicalNetwork2).testEquals();
- }
-
- /**
- * Checks the construction of a PhysicalNetwork object.
- */
- @Test
- public void testConstruction() {
- final String physicalNetworkValue = "s";
- final PhysicalNetwork physicalNetwork = PhysicalNetwork
- .physicalNetwork(physicalNetworkValue);
- assertThat(physicalNetwork, is(notNullValue()));
- assertThat(physicalNetwork.physicalNetwork(), is(physicalNetworkValue));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/PortChainIdTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/PortChainIdTest.java
deleted file mode 100644
index ac6193e..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/PortChainIdTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import java.util.UUID;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for PortChainId class.
- */
-public class PortChainIdTest {
-
- final PortChainId portChainId1 = PortChainId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final PortChainId sameAsPortChainId1 = PortChainId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final PortChainId portChainId2 = PortChainId.of("dace4513-24fc-4fae-af4b-321c5e2eb3d1");
-
- /**
- * Checks that the PortChainId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(PortChainId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(portChainId1, sameAsPortChainId1).addEqualityGroup(portChainId2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a PortChainId object.
- */
- @Test
- public void testConstruction() {
- final String portChainIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1";
- final PortChainId portChainId = PortChainId.of(portChainIdValue);
- assertThat(portChainId, is(notNullValue()));
- assertThat(portChainId.value(), is(UUID.fromString(portChainIdValue)));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/PortPairGroupIdTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/PortPairGroupIdTest.java
deleted file mode 100644
index b9142c3..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/PortPairGroupIdTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import java.util.UUID;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for PortPairGroupId class.
- */
-public class PortPairGroupIdTest {
-
- final PortPairGroupId portPairGroupId1 = PortPairGroupId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final PortPairGroupId sameAsPortPairGroupId1 = PortPairGroupId
- .of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final PortPairGroupId portPairGroupId2 = PortPairGroupId.of("dace4513-24fc-4fae-af4b-321c5e2eb3d1");
-
- /**
- * Checks that the PortPairGroupId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(PortPairGroupId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(portPairGroupId1, sameAsPortPairGroupId1)
- .addEqualityGroup(portPairGroupId2).testEquals();
- }
-
- /**
- * Checks the construction of a PortPairGroupId object.
- */
- @Test
- public void testConstruction() {
- final String portPairGroupIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1";
- final PortPairGroupId portPairGroupId = PortPairGroupId.of(portPairGroupIdValue);
- assertThat(portPairGroupId, is(notNullValue()));
- assertThat(portPairGroupId.value(), is(UUID.fromString(portPairGroupIdValue)));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/PortPairIdTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/PortPairIdTest.java
deleted file mode 100644
index 5af357e..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/PortPairIdTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import java.util.UUID;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for PortPairId class.
- */
-public class PortPairIdTest {
-
- final PortPairId portPairId1 = PortPairId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final PortPairId sameAsPortPairId1 = PortPairId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final PortPairId portPairId2 = PortPairId.of("dace4513-24fc-4fae-af4b-321c5e2eb3d1");
-
- /**
- * Checks that the PortPairId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(PortPairId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(portPairId1, sameAsPortPairId1).addEqualityGroup(portPairId2).testEquals();
- }
-
- /**
- * Checks the construction of a PortPairId object.
- */
- @Test
- public void testConstruction() {
- final String portPairIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1";
- final PortPairId portPairId = PortPairId.of(portPairIdValue);
- assertThat(portPairId, is(notNullValue()));
- assertThat(portPairId.value(), is(UUID.fromString(portPairIdValue)));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/RouterGatewayTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/RouterGatewayTest.java
deleted file mode 100644
index eeec41e..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/RouterGatewayTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for RouterGateway class.
- */
-public class RouterGatewayTest {
- final TenantNetworkId networkId1 = TenantNetworkId.networkId("1");
- final TenantNetworkId networkId2 = TenantNetworkId.networkId("2");
- final Set<FixedIp> fixedIpSet1 = new HashSet<>();
- final Set<FixedIp> fixedIpSet2 = new HashSet<>();
-
- /**
- * Checks that the RouterGateway class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(RouterGateway.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- RouterGateway routerGateway1 = RouterGateway.routerGateway(networkId1,
- true,
- fixedIpSet1);
- RouterGateway routerGateway2 = RouterGateway.routerGateway(networkId1,
- true,
- fixedIpSet1);
- RouterGateway routerGateway3 = RouterGateway.routerGateway(networkId2,
- true,
- fixedIpSet2);
- new EqualsTester().addEqualityGroup(routerGateway1, routerGateway2)
- .addEqualityGroup(routerGateway3).testEquals();
- }
-
- /**
- * Checks the construction of a RouterGateway object.
- */
- @Test
- public void testConstruction() {
- RouterGateway routerGateway = RouterGateway.routerGateway(networkId1,
- true,
- fixedIpSet1);
- assertThat(fixedIpSet1, is(notNullValue()));
- assertThat(fixedIpSet1, is(routerGateway.externalFixedIps()));
- assertThat(networkId1, is(notNullValue()));
- assertThat(networkId1, is(routerGateway.networkId()));
- assertThat(routerGateway.enableSnat(), is(true));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/RouterIdTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/RouterIdTest.java
deleted file mode 100644
index 134577a..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/RouterIdTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for RouterId class.
- */
-public class RouterIdTest {
- final RouterId routerId1 = RouterId.valueOf("1");
- final RouterId sameAsRouterId1 = RouterId.valueOf("1");
- final RouterId routerId2 = RouterId.valueOf("2");
-
- /**
- * Checks that the RouterId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(RouterId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(routerId1, sameAsRouterId1).addEqualityGroup(routerId2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a RouterId object.
- */
- @Test
- public void testConstruction() {
- final String routerIdValue = "s";
- final RouterId routerId = RouterId.valueOf(routerIdValue);
- assertThat(routerId, is(notNullValue()));
- assertThat(routerId.routerId(), is(routerIdValue));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/SecurityGroupTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/SecurityGroupTest.java
deleted file mode 100644
index 324d8bd..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/SecurityGroupTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for SecurityGroup class.
- */
-public class SecurityGroupTest {
-
- final SecurityGroup securityGroup1 = SecurityGroup.securityGroup("1");
- final SecurityGroup sameAssecurityGroup = SecurityGroup.securityGroup("1");
- final SecurityGroup securityGroup2 = SecurityGroup.securityGroup("2");
-
- /**
- * Checks that the SecurityGroup class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(SecurityGroup.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(securityGroup1, sameAssecurityGroup)
- .addEqualityGroup(securityGroup2).testEquals();
- }
-
- /**
- * Checks the construction of a SecurityGroup object.
- */
- @Test
- public void testConstruction() {
- final String securityGroupValue = "1";
- final SecurityGroup securityGroup = SecurityGroup.securityGroup(securityGroupValue);
- assertThat(securityGroup, is(notNullValue()));
- assertThat(securityGroup.securityGroup(), is(securityGroupValue));
-
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/SegmentationIdTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/SegmentationIdTest.java
deleted file mode 100644
index 545d1d4..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/SegmentationIdTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for SegmentationId class.
- */
-public class SegmentationIdTest {
-
- final SegmentationId segmentationID1 = SegmentationId.segmentationId("1");
- final SegmentationId sameAsSegmentationID1 = SegmentationId.segmentationId("1");
- final SegmentationId segmentationID2 = SegmentationId.segmentationId("2");
-
- /**
- * Checks that the SegmentationId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(SegmentationId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(segmentationID1, sameAsSegmentationID1)
- .addEqualityGroup(segmentationID2).testEquals();
- }
-
- /**
- * Checks the construction of a segmentationId object.
- */
- @Test
- public void testConstruction() {
- final String segmentationIdValue = "s";
- final SegmentationId segmentationId = SegmentationId.segmentationId(segmentationIdValue);
- assertThat(segmentationId, is(notNullValue()));
- assertThat(segmentationId.segmentationId(), is(segmentationIdValue));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/ServiceFunctionGroupTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/ServiceFunctionGroupTest.java
deleted file mode 100644
index c34cdee..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/ServiceFunctionGroupTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for ServiceFunctionGroup class.
- */
-public class ServiceFunctionGroupTest {
-
- /**
- * Checks that the ServiceFunctionGroup class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(ServiceFunctionGroup.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- String name1 = "Firewall";
- String description1 = "Firewall service function";
- Map<PortPairId, Integer> portPairLoadMap1 = new ConcurrentHashMap<>();
- PortPairId portPairId1 = PortPairId.of("a4444444-4a56-2a6e-cd3a-9dee4e2ec345");
- portPairLoadMap1.put(portPairId1, Integer.valueOf(2));
- ServiceFunctionGroup sfg1 = new ServiceFunctionGroup(name1, description1, portPairLoadMap1);
- ServiceFunctionGroup sameAsSfg1 = new ServiceFunctionGroup(name1, description1, portPairLoadMap1);
-
- String name2 = "Dpi";
- String description2 = "Dpi service function";
- Map<PortPairId, Integer> portPairLoadMap2 = new ConcurrentHashMap<>();
- PortPairId portPairId2 = PortPairId.of("b6666666-4a56-2a6e-cd3a-9dee4e2ec345");
- portPairLoadMap2.put(portPairId2, Integer.valueOf(3));
- ServiceFunctionGroup sfg2 = new ServiceFunctionGroup(name2, description2, portPairLoadMap2);
-
- new EqualsTester().addEqualityGroup(sfg1, sameAsSfg1).addEqualityGroup(sfg2).testEquals();
- }
-
- /**
- * Checks the construction of a ServiceFunctionGroup object.
- */
- @Test
- public void testConstruction() {
-
- String name = "Firewall";
- String description = "Firewall service function";
- Map<PortPairId, Integer> portPairLoadMap = new ConcurrentHashMap<>();
- PortPairId portPairId = PortPairId.of("a4444444-4a56-2a6e-cd3a-9dee4e2ec345");
- portPairLoadMap.put(portPairId, Integer.valueOf(2));
- ServiceFunctionGroup sfg = new ServiceFunctionGroup(name, description, portPairLoadMap);
-
- assertThat(name, is(sfg.name()));
- assertThat(description, is(sfg.description()));
- assertThat(2, is(sfg.portPairLoadMap().get(portPairId)));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/SubnetIdTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/SubnetIdTest.java
deleted file mode 100644
index 2c9d6a9..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/SubnetIdTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for SubnetId class.
- */
-public class SubnetIdTest {
-
- final SubnetId subnetId1 = SubnetId.subnetId("1");
- final SubnetId sameAsSubnetId1 = SubnetId.subnetId("1");
- final SubnetId subnetId2 = SubnetId.subnetId("2");
-
- /**
- * Checks that the SubnetId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(SubnetId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(subnetId1, sameAsSubnetId1).addEqualityGroup(subnetId2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a SubnetId object.
- */
- @Test
- public void testConstruction() {
- final String subnetIdValue = "s";
- final SubnetId subnetId = SubnetId.subnetId(subnetIdValue);
- assertThat(subnetId, is(notNullValue()));
- assertThat(subnetId.subnetId(), is(subnetIdValue));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/TenantIdTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/TenantIdTest.java
deleted file mode 100644
index 265fe8c..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/TenantIdTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for TenantId class.
- */
-public class TenantIdTest {
-
- final TenantId tenantId1 = TenantId.tenantId("1");
- final TenantId sameAsTenantId1 = TenantId.tenantId("1");
- final TenantId tenantId2 = TenantId.tenantId("2");
-
- /**
- * Checks that the TenantId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(TenantId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(tenantId1, sameAsTenantId1).addEqualityGroup(tenantId2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a TenantId object.
- */
- @Test
- public void testConstruction() {
- final String tenantIdValue = "s";
- final TenantId tenantId = TenantId.tenantId(tenantIdValue);
- assertThat(tenantId, is(notNullValue()));
- assertThat(tenantId.tenantId(), is(tenantIdValue));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/TenantNetworkIdTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/TenantNetworkIdTest.java
deleted file mode 100644
index 3a11824..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/TenantNetworkIdTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for TenantNetworkId class.
- */
-public class TenantNetworkIdTest {
-
- final TenantNetworkId networkId1 = TenantNetworkId.networkId("1");
- final TenantNetworkId sameAsnetworkId1 = TenantNetworkId.networkId("1");
- final TenantNetworkId networkId2 = TenantNetworkId.networkId("2");
-
- /**
- * Checks that the TenantNetworkId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(TenantNetworkId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(networkId1, sameAsnetworkId1)
- .addEqualityGroup(networkId2).testEquals();
- }
-
- /**
- * Checks the construction of a TenantNetworkId object.
- */
- @Test
- public void testConstruction() {
- final String networkIdValue = "s";
- final TenantNetworkId networkId = TenantNetworkId.networkId(networkIdValue);
- assertThat(networkId, is(notNullValue()));
- assertThat(networkId.networkId(), is(networkIdValue));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/VirtualPortIdTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/VirtualPortIdTest.java
deleted file mode 100644
index 303723d..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/VirtualPortIdTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.vtnrsc;
-
-import org.junit.Test;
-
-import com.google.common.testing.EqualsTester;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-/**
- * Unit tests for VirtualPortId class.
- */
-public class VirtualPortIdTest {
-
- final VirtualPortId virtualPortId1 = VirtualPortId.portId("1");
- final VirtualPortId sameAsVirtualPortId1 = VirtualPortId.portId("1");
- final VirtualPortId virtualPortId2 = VirtualPortId.portId("2");
-
- /**
- * Checks that the VirtualPortId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(VirtualPortId.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(virtualPortId1, sameAsVirtualPortId1)
- .addEqualityGroup(virtualPortId2).testEquals();
- }
-
- /**
- * Checks the construction of a VirtualPortId object.
- */
- @Test
- public void testConstruction() {
- final String vPortIdValue = "aaa";
- final VirtualPortId virtualPortId = VirtualPortId.portId(vPortIdValue);
- assertThat(virtualPortId, is(notNullValue()));
- assertThat(virtualPortId.portId(), is(vPortIdValue));
-
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/floatingip/DefaultFloatingIpTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/floatingip/DefaultFloatingIpTest.java
deleted file mode 100644
index 4ae6d9c..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/floatingip/DefaultFloatingIpTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.floatingip;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onosproject.vtnrsc.DefaultFloatingIp;
-import org.onosproject.vtnrsc.FloatingIp;
-import org.onosproject.vtnrsc.FloatingIpId;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPortId;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for DefaultFloatingIp class.
- */
-public class DefaultFloatingIpTest {
-
- private String floatingIpIdStr1 = "5fb63824-4d5c-4b85-9f2f-ebb93c9ce3df";
- private String floatingIpIdStr2 = "fa44f585-fe02-40d3-afe7-d1d7e5782c99";
- private String floatingIpStr = "10.1.1.2";
- private String fixedIpStr = "192.168.1.2";
- private String tenantIdStr = "123";
- private String tenantNetworkId = "1234567";
- private String virtualPortId = "1212";
- private String routerIdStr = "123";
-
- /**
- * Checks that the DefaultFloatingIp class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultFloatingIp.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- final TenantId tenantId = TenantId.tenantId(tenantIdStr);
- final TenantNetworkId networkId = TenantNetworkId
- .networkId(tenantNetworkId);
- final VirtualPortId portId = VirtualPortId.portId(virtualPortId);
- final RouterId routerId = RouterId.valueOf(routerIdStr);
- final FloatingIpId id1 = FloatingIpId.of(floatingIpIdStr1);
- final FloatingIpId id2 = FloatingIpId.of(floatingIpIdStr2);
- final IpAddress floatingIpAddress = IpAddress.valueOf(floatingIpStr);
- final IpAddress fixedIpAddress = IpAddress.valueOf(fixedIpStr);
-
- FloatingIp fip1 = new DefaultFloatingIp(id1, tenantId, networkId,
- portId, routerId,
- floatingIpAddress,
- fixedIpAddress,
- FloatingIp.Status.ACTIVE);
- FloatingIp fip2 = new DefaultFloatingIp(id1, tenantId, networkId,
- portId, routerId,
- floatingIpAddress,
- fixedIpAddress,
- FloatingIp.Status.ACTIVE);
- FloatingIp fip3 = new DefaultFloatingIp(id2, tenantId, networkId,
- portId, routerId,
- floatingIpAddress,
- fixedIpAddress,
- FloatingIp.Status.ACTIVE);
-
- new EqualsTester().addEqualityGroup(fip1, fip2).addEqualityGroup(fip3)
- .testEquals();
- }
-
- /**
- * Checks the construction of a DefaultFloatingIp object.
- */
- @Test
- public void testConstruction() {
- final TenantId tenantId = TenantId.tenantId(tenantIdStr);
- final TenantNetworkId networkId = TenantNetworkId
- .networkId(tenantNetworkId);
- final VirtualPortId portId = VirtualPortId.portId(virtualPortId);
- final RouterId routerId = RouterId.valueOf(routerIdStr);
- final FloatingIpId id = FloatingIpId.of(floatingIpIdStr1);
- final IpAddress floatingIpAddress = IpAddress.valueOf(floatingIpStr);
- final IpAddress fixedIpAddress = IpAddress.valueOf(fixedIpStr);
-
- FloatingIp fip = new DefaultFloatingIp(id, tenantId, networkId, portId,
- routerId, floatingIpAddress,
- fixedIpAddress,
- FloatingIp.Status.ACTIVE);
- assertThat(id, is(notNullValue()));
- assertThat(id, is(fip.id()));
- assertThat(tenantId, is(notNullValue()));
- assertThat(tenantId, is(fip.tenantId()));
- assertThat(networkId, is(notNullValue()));
- assertThat(networkId, is(fip.networkId()));
- assertThat(portId, is(notNullValue()));
- assertThat(portId, is(fip.portId()));
- assertThat(routerId, is(notNullValue()));
- assertThat(routerId, is(fip.routerId()));
- assertThat(floatingIpAddress, is(notNullValue()));
- assertThat(floatingIpAddress, is(fip.floatingIp()));
- assertThat(fixedIpAddress, is(notNullValue()));
- assertThat(fixedIpAddress, is(fip.fixedIp()));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/floatingip/FloatingIpIdTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/floatingip/FloatingIpIdTest.java
deleted file mode 100644
index 22510b2..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/floatingip/FloatingIpIdTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.floatingip;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.FloatingIpId;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for FloatingIpId class.
- */
-public class FloatingIpIdTest {
- private String floatingIpIdStr1 = "5fb63824-4d5c-4b85-9f2f-ebb93c9ce3df";
- private String floatingIpIdStr2 = "fa44f585-fe02-40d3-afe7-d1d7e5782c99";
-
- /**
- * Checks that the FloatingIpId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(FloatingIpId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- FloatingIpId id1 = FloatingIpId.of(floatingIpIdStr1);
- FloatingIpId id2 = FloatingIpId.of(floatingIpIdStr1);
- FloatingIpId id3 = FloatingIpId.of(floatingIpIdStr2);
- new EqualsTester().addEqualityGroup(id1, id2).addEqualityGroup(id3)
- .testEquals();
- }
-
- /**
- * Checks the construction of a FloatingIpId object.
- */
- @Test
- public void testConstruction() {
- final FloatingIpId id = FloatingIpId.of(floatingIpIdStr1);
- assertThat(id, is(notNullValue()));
- assertThat(id.floatingIpId().toString(), is(floatingIpIdStr1));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManagerTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManagerTest.java
deleted file mode 100644
index dac4758..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManagerTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.flowclassifier.impl;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-import org.junit.Test;
-
-import org.onlab.packet.IpPrefix;
-
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.DefaultFlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.util.VtnStorageServiceTest;
-import org.onosproject.common.event.impl.TestEventDispatcher;
-
-import static org.onosproject.net.NetTestTools.injectEventDispatcher;
-
-/**
- * Unit tests for FlowClassifierManager class.
- */
-public class FlowClassifierManagerTest {
-
- final String name = "FlowClassifier";
- final String description = "FlowClassifier";
- final String ethType = "IPv4";
- final String protocol = "udp";
- final int minSrcPortRange = 1024;
- final int maxSrcPortRange = 5000;
- final int minDstPortRange = 1024;
- final int maxDstPortRange = 5000;
- final FlowClassifierId flowClassifierId = FlowClassifierId.of("71111111-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("8");
- final IpPrefix srcIpPrefix = IpPrefix.valueOf("0.0.0.0/0");
- final IpPrefix dstIpPrefix = IpPrefix.valueOf("100.100.100.100/0");
- final VirtualPortId virtualSrcPort = VirtualPortId.portId("100");
- final VirtualPortId virtualDstPort = VirtualPortId.portId("200");
- DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder();
- FlowClassifierManager flowClassifierMgr = new FlowClassifierManager();
- FlowClassifier flowClassifier = null;
- private final VtnStorageServiceTest storageService = new VtnStorageServiceTest();
-
- /**
- * Checks the operation of createFlowClassifier() method.
- */
- @Test
- public void testCreateFlowClassifier() {
- // initialize flow classifier manager
- flowClassifierMgr.storageService = storageService;
- injectEventDispatcher(flowClassifierMgr, new TestEventDispatcher());
- flowClassifierMgr.activate();
-
- // create flow classifier
- flowClassifier = flowClassifierBuilder.setFlowClassifierId(flowClassifierId).setTenantId(tenantId)
- .setName(name).setDescription(description).setEtherType(ethType).setProtocol(protocol)
- .setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange)
- .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix)
- .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build();
- assertThat(flowClassifierMgr.createFlowClassifier(flowClassifier), is(true));
- }
-
- /**
- * Checks the operation of exists() method.
- */
- @Test
- public void testExists() {
- testCreateFlowClassifier();
- assertThat(flowClassifierMgr.exists(flowClassifierId), is(true));
- }
-
- /**
- * Checks the operation of getFlowClassifierCount() method.
- */
- @Test
- public void testGetFlowClassifierCount() {
- testCreateFlowClassifier();
- assertThat(flowClassifierMgr.getFlowClassifierCount(), is(1));
- }
-
- /**
- * Checks the operation of getFlowClassifiers() method.
- */
- @Test
- public void testGetFlowClassifiers() {
- testCreateFlowClassifier();
- final Iterable<FlowClassifier> flowClassifierList = flowClassifierMgr.getFlowClassifiers();
- assertThat(flowClassifierList, is(notNullValue()));
- assertThat(flowClassifierList.iterator().hasNext(), is(true));
- }
-
- /**
- * Checks the operation of getFlowClassifier() method.
- */
- @Test
- public void testGetFlowClassifier() {
- testCreateFlowClassifier();
- assertThat(flowClassifier, is(notNullValue()));
- assertThat(flowClassifierMgr.getFlowClassifier(flowClassifierId), is(flowClassifier));
- }
-
- /**
- * Checks the operation of updateFlowClassifier() method.
- */
- @Test
- public void testUpdateFlowClassifier() {
- // create a flow classifier
- testCreateFlowClassifier();
-
- // new updates
- final String name2 = "FlowClassifier2";
- final String description2 = "FlowClassifier2";
- final String ethType2 = "IPv6";
- final String protocol2 = "tcp";
- final TenantId tenantId2 = TenantId.tenantId("10");
- final VirtualPortId virtualSrcPort2 = VirtualPortId.portId("300");
- final VirtualPortId virtualDstPort2 = VirtualPortId.portId("400");
- flowClassifier = flowClassifierBuilder.setFlowClassifierId(flowClassifierId)
- .setTenantId(tenantId2).setName(name2).setDescription(description2).setEtherType(ethType2)
- .setProtocol(protocol2).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange)
- .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix)
- .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort2).setDstPort(virtualDstPort2).build();
- assertThat(flowClassifierMgr.updateFlowClassifier(flowClassifier), is(true));
- }
-
- /**
- * Checks the operation of removeFlowClassifier() method.
- */
- @Test
- public void testRemoveFlowClassifier() {
- testCreateFlowClassifier();
- assertThat(flowClassifierMgr.removeFlowClassifier(flowClassifierId), is(true));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/impl/PortChainManagerTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/impl/PortChainManagerTest.java
deleted file mode 100644
index e79d9db..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/impl/PortChainManagerTest.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portchain.impl;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-import org.junit.Test;
-import java.util.List;
-import java.util.LinkedList;
-
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.DefaultPortChain;
-import org.onosproject.vtnrsc.DefaultFlowClassifier;
-import org.onosproject.vtnrsc.util.VtnStorageServiceTest;
-import org.onosproject.common.event.impl.TestEventDispatcher;
-
-import static org.onosproject.net.NetTestTools.injectEventDispatcher;
-
-/**
- * Unit tests for PortChainManager class.
- */
-public class PortChainManagerTest {
- final PortChainId portChainId = PortChainId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortChain";
- final String description = "PortChain";
- final List<PortPairGroupId> portPairGroupList = new LinkedList<PortPairGroupId>();
- final List<FlowClassifierId> flowClassifierList = new LinkedList<FlowClassifierId>();
- DefaultPortChain.Builder portChainBuilder = new DefaultPortChain.Builder();
- DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder();
- PortChainManager portChainMgr = new PortChainManager();
- PortChain portChain = null;
- private final VtnStorageServiceTest storageService = new VtnStorageServiceTest();
-
- /**
- * Checks the operation of createPortChain() method.
- */
- @Test
- public void testCreatePortChain() {
- // initialize port chain manager
- portChainMgr.storageService = storageService;
- injectEventDispatcher(portChainMgr, new TestEventDispatcher());
- portChainMgr.activate();
-
- // create list of Port Pair Groups.
- PortPairGroupId portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairGroupList.add(portPairGroupId);
- portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3af");
- portPairGroupList.add(portPairGroupId);
-
- // create list of Flow classifiers.
- FlowClassifierId flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae");
- flowClassifierList.add(flowClassifierId);
- flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3af");
- flowClassifierList.add(flowClassifierId);
-
- // create port chain
- portChain = portChainBuilder.setId(portChainId).setTenantId(tenantId).setName(name).setDescription(description)
- .setPortPairGroups(portPairGroupList).setFlowClassifiers(flowClassifierList).build();
- assertThat(portChainMgr.createPortChain(portChain), is(true));
- }
-
- /**
- * Checks the operation of exists() method.
- */
- @Test
- public void testExists() {
- testCreatePortChain();
- assertThat(portChainMgr.exists(portChainId), is(true));
- }
-
- /**
- * Checks the operation of getPortChainCount() method.
- */
- @Test
- public void testGetPortChainCount() {
- testCreatePortChain();
- assertThat(portChainMgr.getPortChainCount(), is(1));
- }
-
- /**
- * Checks the operation of getPortChains() method.
- */
- @Test
- public void testGetPortChains() {
- testCreatePortChain();
- final Iterable<PortChain> portChainList = portChainMgr.getPortChains();
- assertThat(portChainList, is(notNullValue()));
- assertThat(portChainList.iterator().hasNext(), is(true));
- }
-
- /**
- * Checks the operation of getPortChain() method.
- */
- @Test
- public void testGetPortChain() {
- testCreatePortChain();
- assertThat(portChain, is(notNullValue()));
- assertThat(portChainMgr.getPortChain(portChainId), is(portChain));
- }
-
- /**
- * Checks the operation of updatePortChain() method.
- */
- @Test
- public void testUpdatePortChain() {
- // create a port chain
- testCreatePortChain();
-
- // new updates
- final TenantId tenantId2 = TenantId.tenantId("2");
- final String name2 = "PortChain2";
- final String description2 = "PortChain2";
- // create list of Port Pair Groups.
- final List<PortPairGroupId> portPairGroupList = new LinkedList<PortPairGroupId>();
- PortPairGroupId portPairGroupId = PortPairGroupId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairGroupList.add(portPairGroupId);
- portPairGroupId = PortPairGroupId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3af");
- portPairGroupList.add(portPairGroupId);
- // create list of Flow classifiers.
- final List<FlowClassifierId> flowClassifierList = new LinkedList<FlowClassifierId>();
- FlowClassifierId flowClassifierId = FlowClassifierId.of("76666666-fc23-aeb6-f44b-56dc5e2fb3ae");
- flowClassifierList.add(flowClassifierId);
- flowClassifierId = FlowClassifierId.of("76666666-fc23-aeb6-f44b-56dc5e2fb3af");
- flowClassifierList.add(flowClassifierId);
- portChain = portChainBuilder.setId(portChainId).setTenantId(tenantId2).setName(name2)
- .setDescription(description2).setPortPairGroups(portPairGroupList)
- .setFlowClassifiers(flowClassifierList).build();
- assertThat(portChainMgr.updatePortChain(portChain), is(true));
- }
-
- /**
- * Checks the operation of removePortChain() method.
- */
- @Test
- public void testRemovePortChain() {
- testCreatePortChain();
- assertThat(portChainMgr.removePortChain(portChainId), is(true));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/impl/PortPairManagerTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/impl/PortPairManagerTest.java
deleted file mode 100644
index 06e3e57..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/impl/PortPairManagerTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portpair.impl;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-import org.junit.Test;
-
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.DefaultPortPair;
-import org.onosproject.vtnrsc.util.VtnStorageServiceTest;
-import org.onosproject.common.event.impl.TestEventDispatcher;
-
-import static org.onosproject.net.NetTestTools.injectEventDispatcher;
-
-/**
- * Unit tests for PortPairManager class.
- */
-public class PortPairManagerTest {
- final PortPairId portPairId = PortPairId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortPair";
- final String description = "PortPair";
- final String ingress = "d3333333-24fc-4fae-af4b-321c5e2eb3d1";
- final String egress = "a4444444-4a56-2a6e-cd3a-9dee4e2ec345";
- DefaultPortPair.Builder portPairBuilder = new DefaultPortPair.Builder();
- PortPairManager portPairMgr = new PortPairManager();
- PortPair portPair = null;
- private final VtnStorageServiceTest storageService = new VtnStorageServiceTest();
-
- /**
- * Checks the operation of createPortPair() method.
- */
- @Test
- public void testCreatePortPair() {
- // initialize port pair manager
- portPairMgr.storageService = storageService;
- injectEventDispatcher(portPairMgr, new TestEventDispatcher());
- portPairMgr.activate();
-
- // create port pair
- portPair = portPairBuilder.setId(portPairId).setTenantId(tenantId).setName(name)
- .setDescription(description).setIngress(ingress).setEgress(egress).build();
- assertThat(portPairMgr.createPortPair(portPair), is(true));
- }
-
- /**
- * Checks the operation of exists() method.
- */
- @Test
- public void testExists() {
- testCreatePortPair();
- assertThat(portPairMgr.exists(portPairId), is(true));
- }
-
- /**
- * Checks the operation of getPortPairCount() method.
- */
- @Test
- public void testGetPortPairCount() {
- testCreatePortPair();
- assertThat(portPairMgr.getPortPairCount(), is(1));
- }
-
- /**
- * Checks the operation of getPortPairs() method.
- */
- @Test
- public void testGetPortPairs() {
- testCreatePortPair();
- final Iterable<PortPair> portPairList = portPairMgr.getPortPairs();
- assertThat(portPairList, is(notNullValue()));
- assertThat(portPairList.iterator().hasNext(), is(true));
- }
-
- /**
- * Checks the operation of getPortPair() method.
- */
- @Test
- public void testGetPortPair() {
- testCreatePortPair();
- assertThat(portPair, is(notNullValue()));
- assertThat(portPairMgr.getPortPair(portPairId), is(portPair));
- }
-
- /**
- * Checks the operation of updatePortPair() method.
- */
- @Test
- public void testUpdatePortPair() {
- // create a port pair
- testCreatePortPair();
-
- // new updates
- final TenantId tenantId2 = TenantId.tenantId("2");
- final String name2 = "PortPair2";
- final String description2 = "PortPair2";
- final String ingress2 = "d5555555-24fc-4fae-af4b-321c5e2eb3d1";
- final String egress2 = "a6666666-4a56-2a6e-cd3a-9dee4e2ec345";
- portPair = portPairBuilder.setId(portPairId).setTenantId(tenantId2).setName(name2)
- .setDescription(description2).setIngress(ingress2).setEgress(egress2).build();
- assertThat(portPairMgr.updatePortPair(portPair), is(true));
- }
-
- /**
- * Checks the operation of removePortPair() method.
- */
- @Test
- public void testRemovePortPair() {
- testCreatePortPair();
- assertThat(portPairMgr.removePortPair(portPairId), is(true));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/impl/PortPairGroupManagerTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/impl/PortPairGroupManagerTest.java
deleted file mode 100644
index 6edcef6..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/impl/PortPairGroupManagerTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.portpairgroup.impl;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-import org.junit.Test;
-import java.util.List;
-import java.util.LinkedList;
-
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.DefaultPortPairGroup;
-import org.onosproject.vtnrsc.util.VtnStorageServiceTest;
-import org.onosproject.common.event.impl.TestEventDispatcher;
-
-import static org.onosproject.net.NetTestTools.injectEventDispatcher;
-
-/**
- * Unit tests for PortPairGroupManager class.
- */
-public class PortPairGroupManagerTest {
- final PortPairGroupId portPairGroupId = PortPairGroupId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortPairGroup";
- final String description = "PortPairGroup";
- final List<PortPairId> portPairIdList = new LinkedList<PortPairId>();
- DefaultPortPairGroup.Builder portPairGroupBuilder = new DefaultPortPairGroup.Builder();
- PortPairGroupManager portPairGroupMgr = new PortPairGroupManager();
- PortPairGroup portPairGroup = null;
- private final VtnStorageServiceTest storageService = new VtnStorageServiceTest();
-
- /**
- * Checks the operation of createPortPairGroup() method.
- */
- @Test
- public void testCreatePortPairGroup() {
- // initialize port pair group manager
- portPairGroupMgr.storageService = storageService;
- injectEventDispatcher(portPairGroupMgr, new TestEventDispatcher());
- portPairGroupMgr.activate();
-
- // create port-pair-id list
- PortPairId portPairId = PortPairId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairIdList.add(portPairId);
- portPairId = PortPairId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairIdList.add(portPairId);
-
- // create port pair
- portPairGroup = portPairGroupBuilder.setId(portPairGroupId).setTenantId(tenantId).setName(name)
- .setDescription(description).setPortPairs(portPairIdList).build();
- assertThat(portPairGroupMgr.createPortPairGroup(portPairGroup), is(true));
- }
-
- /**
- * Checks the operation of exists() method.
- */
- @Test
- public void testExists() {
- testCreatePortPairGroup();
- assertThat(portPairGroupMgr.exists(portPairGroupId), is(true));
- }
-
- /**
- * Checks the operation of getPortPairGroupCount() method.
- */
- @Test
- public void testGetPortPairGroupCount() {
- testCreatePortPairGroup();
- assertThat(portPairGroupMgr.getPortPairGroupCount(), is(1));
- }
-
- /**
- * Checks the operation of getPortPairGroups() method.
- */
- @Test
- public void testGetPortPairGroups() {
- testCreatePortPairGroup();
- final Iterable<PortPairGroup> portPairGroupList = portPairGroupMgr.getPortPairGroups();
- assertThat(portPairGroupList, is(notNullValue()));
- assertThat(portPairGroupList.iterator().hasNext(), is(true));
- }
-
- /**
- * Checks the operation of getPortPairGroup() method.
- */
- @Test
- public void testGetPortPairGroup() {
- testCreatePortPairGroup();
- assertThat(portPairGroup, is(notNullValue()));
- assertThat(portPairGroupMgr.getPortPairGroup(portPairGroupId), is(portPairGroup));
- }
-
- /**
- * Checks the operation of updatePortPairGroup() method.
- */
- @Test
- public void testUpdatePortPairGroup() {
- // create a port pair group
- testCreatePortPairGroup();
-
- // new updates
- // create port-pair-id list
- final TenantId tenantId2 = TenantId.tenantId("2");
- final String name2 = "PortPairGroup2";
- final String description2 = "PortPairGroup2";
- final List<PortPairId> portPairIdList = new LinkedList<PortPairId>();
- PortPairId portPairId = PortPairId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairIdList.add(portPairId);
- portPairId = PortPairId.of("76666666-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairIdList.add(portPairId);
-
- // create port pair
- portPairGroup = portPairGroupBuilder.setId(portPairGroupId).setTenantId(tenantId2).setName(name2)
- .setDescription(description2).setPortPairs(portPairIdList).build();
- assertThat(portPairGroupMgr.updatePortPairGroup(portPairGroup), is(true));
- }
-
- /**
- * Checks the operation of removePortPairGroup() method.
- */
- @Test
- public void testRemovePortPairGroup() {
- testCreatePortPairGroup();
- assertThat(portPairGroupMgr.removePortPairGroup(portPairGroupId), is(true));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/DefaultRouterTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/DefaultRouterTest.java
deleted file mode 100644
index c2ebe44..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/DefaultRouterTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.router;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import java.util.Collections;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.DefaultRouter;
-import org.onosproject.vtnrsc.Router;
-import org.onosproject.vtnrsc.RouterGateway;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPortId;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for DefaultRouter class.
- */
-public class DefaultRouterTest {
-
- private String tenantIdStr = "123";
- private String virtualPortId = "1212";
- private String routeIdStr1 = "1";
- private String routeIdStr2 = "2";
- private String routerName = "router";
- private String tenantNetworkId = "1234567";
-
- /**
- * Checks that the DefaultRouter class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultRouter.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- final TenantId tenantId = TenantId.tenantId(tenantIdStr);
- final VirtualPortId portId = VirtualPortId.portId(virtualPortId);
- final RouterId routerId1 = RouterId.valueOf(routeIdStr1);
- final RouterId routerId2 = RouterId.valueOf(routeIdStr2);
- final TenantNetworkId networkId = TenantNetworkId
- .networkId(tenantNetworkId);
- final RouterGateway routerGateway = RouterGateway.routerGateway(
- networkId,
- true,
- Collections
- .emptySet());
-
- Router r1 = new DefaultRouter(routerId1, routerName, false,
- Router.Status.ACTIVE, false,
- routerGateway, portId, tenantId, null);
- Router r2 = new DefaultRouter(routerId1, routerName, false,
- Router.Status.ACTIVE, false,
- routerGateway, portId, tenantId, null);
- Router r3 = new DefaultRouter(routerId2, routerName, false,
- Router.Status.ACTIVE, false,
- routerGateway, portId, tenantId, null);
-
- new EqualsTester().addEqualityGroup(r1, r2).addEqualityGroup(r3)
- .testEquals();
- }
-
- /**
- * Checks the construction of a DefaultRouter object.
- */
- @Test
- public void testConstruction() {
- final TenantId tenantId = TenantId.tenantId(tenantIdStr);
- final VirtualPortId portId = VirtualPortId.portId(virtualPortId);
- final RouterId routerId = RouterId.valueOf(routeIdStr1);
- final TenantNetworkId networkId = TenantNetworkId
- .networkId(tenantNetworkId);
- final RouterGateway routerGateway = RouterGateway.routerGateway(
- networkId,
- true,
- Collections
- .emptySet());
-
- Router r1 = new DefaultRouter(routerId, routerName, false,
- Router.Status.ACTIVE, false,
- routerGateway, portId, tenantId, null);
- assertThat(routerId, is(notNullValue()));
- assertThat(routerId, is(r1.id()));
- assertThat(tenantId, is(notNullValue()));
- assertThat(tenantId, is(r1.tenantId()));
- assertThat(routerGateway, is(notNullValue()));
- assertThat(routerGateway, is(r1.externalGatewayInfo()));
- }
-
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterInterfaceTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterInterfaceTest.java
deleted file mode 100644
index b937605..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterInterfaceTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.router;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.RouterInterface;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.VirtualPortId;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for RouterInterface class.
- */
-public class RouterInterfaceTest {
- private String tenantIdStr = "123";
- private String virtualPortId = "1212";
- private String routeIdStr1 = "1";
- private String routeIdStr2 = "2";
- private String subnetIdStr = "1234567";
-
- /**
- * Checks that the RouterInterface class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(RouterInterface.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- final TenantId tenantId = TenantId.tenantId(tenantIdStr);
- final VirtualPortId portId = VirtualPortId.portId(virtualPortId);
- final RouterId routerId1 = RouterId.valueOf(routeIdStr1);
- final RouterId routerId2 = RouterId.valueOf(routeIdStr2);
- final SubnetId subnet = SubnetId.subnetId(subnetIdStr);
-
- RouterInterface ri1 = RouterInterface.routerInterface(subnet, portId,
- routerId1,
- tenantId);
- RouterInterface ri2 = RouterInterface.routerInterface(subnet, portId,
- routerId1,
- tenantId);
- RouterInterface ri3 = RouterInterface.routerInterface(subnet, portId,
- routerId2,
- tenantId);
-
- new EqualsTester().addEqualityGroup(ri1, ri2).addEqualityGroup(ri3)
- .testEquals();
- }
-
- /**
- * Checks the construction of a RouterInterface object.
- */
- @Test
- public void testConstruction() {
- final TenantId tenantId = TenantId.tenantId(tenantIdStr);
- final VirtualPortId portId = VirtualPortId.portId(virtualPortId);
- final RouterId routerId1 = RouterId.valueOf(routeIdStr1);
- final SubnetId subnet = SubnetId.subnetId(subnetIdStr);
-
- RouterInterface ri1 = RouterInterface.routerInterface(subnet, portId,
- routerId1,
- tenantId);
- assertThat(portId, is(notNullValue()));
- assertThat(portId, is(ri1.portId()));
- assertThat(tenantId, is(notNullValue()));
- assertThat(tenantId, is(ri1.tenantId()));
- assertThat(routerId1, is(notNullValue()));
- assertThat(routerId1, is(ri1.routerId()));
- assertThat(subnet, is(notNullValue()));
- assertThat(subnet, is(ri1.subnetId()));
- }
-}
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/util/VtnEventuallyConsistentMapTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/util/VtnEventuallyConsistentMapTest.java
deleted file mode 100644
index 3f5e50e..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/util/VtnEventuallyConsistentMapTest.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.util;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.function.BiFunction;
-
-import org.onlab.util.KryoNamespace;
-import org.onosproject.cluster.NodeId;
-import org.onosproject.store.Timestamp;
-
-import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.*;
-
-import org.onosproject.store.service.EventuallyConsistentMapAdapter;
-import org.onosproject.store.service.EventuallyConsistentMapListener;
-import org.onosproject.store.service.EventuallyConsistentMapEvent;
-import org.onosproject.store.service.EventuallyConsistentMapBuilder;
-import org.onosproject.store.service.EventuallyConsistentMap;
-
-/**
- * Testing version of an Eventually Consistent Map.
- */
-
-public final class VtnEventuallyConsistentMapTest<K, V> extends EventuallyConsistentMapAdapter<K, V> {
-
- private final HashMap<K, V> map;
- private final String mapName;
- private final List<EventuallyConsistentMapListener<K, V>> listeners;
- private final BiFunction<K, V, Collection<NodeId>> peerUpdateFunction;
-
- private VtnEventuallyConsistentMapTest(String mapName,
- BiFunction<K, V, Collection<NodeId>> peerUpdateFunction) {
- map = new HashMap<>();
- listeners = new LinkedList<>();
- this.mapName = mapName;
- this.peerUpdateFunction = peerUpdateFunction;
- }
-
- /**
- * Notify all listeners of an event.
- */
- private void notifyListeners(EventuallyConsistentMapEvent<K, V> event) {
- listeners.forEach(
- listener -> listener.event(event)
- );
- }
-
- @Override
- public int size() {
- return map.size();
- }
-
- @Override
- public boolean isEmpty() {
- return map.isEmpty();
- }
-
- @Override
- public boolean containsKey(K key) {
- return map.containsKey(key);
- }
-
- @Override
- public boolean containsValue(V value) {
- return map.containsValue(value);
- }
-
- @Override
- public V get(K key) {
- return map.get(key);
- }
-
- @SuppressWarnings("ReturnValueIgnored")
- @Override
- public void put(K key, V value) {
- map.put(key, value);
- EventuallyConsistentMapEvent<K, V> addEvent =
- new EventuallyConsistentMapEvent<>(mapName, PUT, key, value);
- notifyListeners(addEvent);
- if (peerUpdateFunction != null) {
- peerUpdateFunction.apply(key, value);
- }
- }
-
- @Override
- public V remove(K key) {
- V result = map.remove(key);
- if (result != null) {
- EventuallyConsistentMapEvent<K, V> removeEvent =
- new EventuallyConsistentMapEvent<>(mapName, REMOVE,
- key, map.get(key));
- notifyListeners(removeEvent);
- }
- return result;
- }
-
- @Override
- public void remove(K key, V value) {
- boolean removed = map.remove(key, value);
- if (removed) {
- EventuallyConsistentMapEvent<K, V> removeEvent =
- new EventuallyConsistentMapEvent<>(mapName, REMOVE, key, value);
- notifyListeners(removeEvent);
- }
- }
-
- @Override
- public V compute(K key, BiFunction<K, V, V> recomputeFunction) {
- return map.compute(key, recomputeFunction);
- }
-
- @Override
- public void putAll(Map<? extends K, ? extends V> m) {
- map.putAll(m);
- }
-
- @Override
- public void clear() {
- map.clear();
- }
-
- @Override
- public Set<K> keySet() {
- return map.keySet();
- }
-
- @Override
- public Collection<V> values() {
- return map.values();
- }
-
- @Override
- public Set<Map.Entry<K, V>> entrySet() {
- return map.entrySet();
- }
-
- public static <K, V> Builder<K, V> builder() {
- return new Builder<>();
- }
-
- @Override
- public void addListener(EventuallyConsistentMapListener<K, V> listener) {
- listeners.add(listener);
- }
-
- @Override
- public void removeListener(EventuallyConsistentMapListener<K, V> listener) {
- listeners.remove(listener);
- }
-
- public static class Builder<K, V> implements EventuallyConsistentMapBuilder<K, V> {
- private String name;
- private BiFunction<K, V, Collection<NodeId>> peerUpdateFunction;
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withName(String name) {
- this.name = name;
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withSerializer(KryoNamespace.Builder serializerBuilder) {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withSerializer(KryoNamespace serializer) {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V>
- withTimestampProvider(BiFunction<K, V, Timestamp> timestampProvider) {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withEventExecutor(ExecutorService executor) {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withCommunicationExecutor(ExecutorService executor) {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withBackgroundExecutor(ScheduledExecutorService executor) {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V>
- withPeerUpdateFunction(BiFunction<K, V, Collection<NodeId>> peerUpdateFunction) {
- this.peerUpdateFunction = peerUpdateFunction;
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withTombstonesDisabled() {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withAntiEntropyPeriod(long period, TimeUnit unit) {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withFasterConvergence() {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withPersistence() {
- return this;
- }
-
- @Override
- public EventuallyConsistentMap<K, V> build() {
- if (name == null) {
- name = "test";
- }
- return new VtnEventuallyConsistentMapTest<>(name, peerUpdateFunction);
- }
- }
-
-}
-
diff --git a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/util/VtnStorageServiceTest.java b/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/util/VtnStorageServiceTest.java
deleted file mode 100644
index 90fad47..0000000
--- a/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/util/VtnStorageServiceTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.util;
-
-import org.onosproject.store.service.EventuallyConsistentMapBuilder;
-import org.onosproject.store.service.StorageServiceAdapter;
-
-public class VtnStorageServiceTest extends StorageServiceAdapter {
- @Override
- public <K, V> EventuallyConsistentMapBuilder<K, V> eventuallyConsistentMapBuilder() {
- return VtnEventuallyConsistentMapTest.builder();
- }
-}
diff --git a/apps/vtn/vtnweb/BUILD b/apps/vtn/vtnweb/BUILD
deleted file mode 100644
index 0142518..0000000
--- a/apps/vtn/vtnweb/BUILD
+++ /dev/null
@@ -1,16 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + JACKSON + REST + [
- "//apps/vtn/vtnrsc:onos-apps-vtn-vtnrsc",
-]
-
-TEST_DEPS = TEST_REST + [
- "@minimal_json//jar",
- "//utils/osgi:onlab-osgi-tests",
- "//web/api:onos-rest-tests",
-]
-
-osgi_jar_with_tests(
- exclude_tests = ["org.onosproject.vtnweb.resources.VtnResourceTest"],
- test_deps = TEST_DEPS,
- web_context = "/onos/vtn",
- deps = COMPILE_DEPS,
-)
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/gui/SfcUiExtensionManager.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/gui/SfcUiExtensionManager.java
deleted file mode 100644
index 7997d4a..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/gui/SfcUiExtensionManager.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.gui;
-
-import com.google.common.collect.ImmutableList;
-import org.onosproject.ui.UiExtension;
-import org.onosproject.ui.UiExtensionService;
-import org.onosproject.ui.UiMessageHandlerFactory;
-import org.onosproject.ui.UiView;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.List;
-
-import static com.google.common.collect.ImmutableList.of;
-import static org.onosproject.ui.UiView.Category.NETWORK;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * service function chain gui.
- */
-@Component(immediate = true, service = SfcUiExtensionManager.class)
-public class SfcUiExtensionManager {
- private final Logger log = getLogger(getClass());
-
- private static final ClassLoader CL =
- SfcUiExtensionManager.class.getClassLoader();
- private static final String GUI = "gui";
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected UiExtensionService uiExtensionService;
-
- // service function chain extension
- private final UiExtension sfc = createSfcExtension();
-
- // Creates service function chain UI extension
- private UiExtension createSfcExtension() {
- List<UiView> coreViews = of(
- //TODO add a new type of icon for sfc
- new UiView(NETWORK, "sfc", "SFC", "nav_sfcs")
- );
-
- UiMessageHandlerFactory messageHandlerFactory =
- () -> ImmutableList.of(
- new SfcViewMessageHandler()
- );
-
- return new UiExtension.Builder(CL, coreViews)
- .messageHandlerFactory(messageHandlerFactory)
- .resourcePath(GUI)
- .build();
- }
-
- @Activate
- public void activate() {
- uiExtensionService.register(sfc);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- uiExtensionService.unregister(sfc);
- log.info("Stopped");
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/gui/SfcViewMessageHandler.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/gui/SfcViewMessageHandler.java
deleted file mode 100644
index 3b65e8b..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/gui/SfcViewMessageHandler.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.vtnweb.gui;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.onlab.packet.IpAddress;
-import org.onosproject.ui.RequestHandler;
-import org.onosproject.ui.UiMessageHandler;
-import org.onosproject.ui.table.TableModel;
-import org.onosproject.ui.table.TableRequestHandler;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService;
-import org.onosproject.vtnrsc.portchain.PortChainService;
-import org.onosproject.vtnrsc.portpair.PortPairService;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Message handler for service function chain view related messages.
- */
-public class SfcViewMessageHandler extends UiMessageHandler {
-
- private static final String SLASH = " -> ";
- private static final String NONE = "none";
- private static final String SFCTYPE = "Service Function Chain";
-
- private static final String SFC_DATA_REQ = "sfcDataRequest";
- private static final String SFC_DATA_RESP = "sfcDataResponse";
- private static final String SFCS = "sfcs";
-
- private static final String ID = "id";
- private static final String STATE = "_iconid_state";
- private static final String PORTCHAINNAME = "portChainName";
- private static final String SFS = "sfs";
- private static final String TYPE = "type";
- private static final String SRCIP = "srcIp";
- private static final String DSTIP = "dstIp";
-
- private static final String[] COL_IDS = {
- ID, STATE, PORTCHAINNAME, SFS, TYPE, SRCIP, DSTIP
- };
-
- private static final String ICON_ID_ONLINE = "active";
- private static final String ICON_ID_OFFLINE = "inactive";
-
- @Override
- protected Collection<RequestHandler> createRequestHandlers() {
- return ImmutableSet.of(new SfcDataRequest());
- }
-
- // handler for sfc table requests
- private final class SfcDataRequest extends TableRequestHandler {
-
- private static final String NO_ROWS_MESSAGE = "No Service Function Chain found";
-
- private SfcDataRequest() {
- super(SFC_DATA_REQ, SFC_DATA_RESP, SFCS);
- }
-
- @Override
- protected String[] getColumnIds() {
- return COL_IDS;
- }
-
- @Override
- protected String defaultColumnId() {
- return PORTCHAINNAME;
- }
-
- @Override
- protected String noRowsMessage(ObjectNode payload) {
- return NO_ROWS_MESSAGE;
- }
-
- @Override
- protected void populateTable(TableModel tm, ObjectNode payload) {
- PortChainService pcs = get(PortChainService.class);
- Iterable<PortChain> portChains = pcs.getPortChains();
- portChains.forEach(pchain -> populateRow(tm.addRow(), pchain));
- }
-
- //populate the row of service function chain
- private void populateRow(TableModel.Row row, PortChain pchain) {
- PortChainIpRange portChainIpRange = portChainIpRange(pchain);
- List<VirtualPort> vpList = sfcPorts(pchain);
- row.cell(ID, pchain.portChainId().value().toString())
- .cell(STATE, sfcState(vpList))
- .cell(PORTCHAINNAME, pchain.name())
- .cell(SFS, sfcHosts(vpList))
- .cell(TYPE, SFCTYPE)
- .cell(SRCIP, portChainIpRange.srcip())
- .cell(DSTIP, portChainIpRange.dstip());
- }
-
- //PortChainIpRange
- private PortChainIpRange portChainIpRange(PortChain pchain) {
- List<FlowClassifierId> flowClassifierList = pchain.flowClassifiers();
- FlowClassifierService fcs = get(FlowClassifierService.class);
- StringBuffer srcipbuf = new StringBuffer();
- StringBuffer dstipbuf = new StringBuffer();
- if (flowClassifierList != null) {
- flowClassifierList.forEach(fcid -> {
- FlowClassifier fc = fcs.getFlowClassifier(fcid);
- String srcip = fc.srcIpPrefix().toString();
- String dstip = fc.dstIpPrefix().toString();
- srcipbuf.append(srcip).append(SLASH);
- dstipbuf.append(dstip).append(SLASH);
- });
- }
- String srcip = NONE;
- String dstip = NONE;
- if (srcipbuf.length() > 0) {
- srcip = srcipbuf.substring(0, srcipbuf.length() - SLASH.length());
- }
- if (dstipbuf.length() > 0) {
- dstip = dstipbuf.substring(0, dstipbuf.length() - SLASH.length());
- }
- PortChainIpRange portChainIpRange = new PortChainIpRange(srcip, dstip);
- return portChainIpRange;
- }
-
- //the VirtualPorts of service function chain
- private List<VirtualPort> sfcPorts(PortChain pchain) {
- List<PortPairGroupId> portPairGroupList = pchain.portPairGroups();
- PortPairGroupService ppgs = get(PortPairGroupService.class);
- PortPairService pps = get(PortPairService.class);
- VirtualPortService vps = get(VirtualPortService.class);
- List<VirtualPort> vpList = new ArrayList<VirtualPort>();
- if (portPairGroupList != null) {
- portPairGroupList.forEach(ppgid -> {
- PortPairGroup ppg = ppgs.getPortPairGroup(ppgid);
- List<PortPairId> portPairList = ppg.portPairs();
- if (portPairList != null) {
- portPairList.forEach(ppid -> {
- PortPair pp = pps.getPortPair(ppid);
- VirtualPort vp = vps.getPort(VirtualPortId.portId(pp.ingress()));
- vpList.add(vp);
- });
- }
- });
- }
- return vpList;
- }
-
- //the state of service function chain
- private String sfcState(List<VirtualPort> vpList) {
- for (VirtualPort vp : vpList) {
- if (vp.state().equals(VirtualPort.State.DOWN)) {
- return ICON_ID_OFFLINE;
- }
- }
- return ICON_ID_ONLINE;
- }
-
- //the hosts of service function chain
- private String sfcHosts(List<VirtualPort> vpList) {
- StringBuffer hostsbuf = new StringBuffer();
- for (VirtualPort vp : vpList) {
- Iterator<FixedIp> fixedIps = vp.fixedIps().iterator();
- if (fixedIps.hasNext()) {
- FixedIp fixedIp = fixedIps.next();
- IpAddress ip = fixedIp.ip();
- hostsbuf.append(ip.toString()).append(SLASH);
- }
- }
- if (hostsbuf.length() > 0) {
- return hostsbuf.substring(0, hostsbuf.length() - SLASH.length());
- }
- return hostsbuf.toString();
- }
-
- //source ip prefix and destination ip prefix
- private final class PortChainIpRange {
- private final String srcip;
- private final String dstip;
-
- private PortChainIpRange(String srcip, String dstip) {
- this.srcip = srcip;
- this.dstip = dstip;
- }
-
- public String srcip() {
- return srcip;
- }
-
- public String dstip() {
- return dstip;
- }
- }
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/gui/package-info.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/gui/package-info.java
deleted file mode 100644
index bee6e77..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/gui/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service Function Chain gui.
- */
-package org.onosproject.vtnweb.gui;
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/ClassifierWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/ClassifierWebResource.java
deleted file mode 100644
index 991f0fc..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/ClassifierWebResource.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.classifier.ClassifierService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Query and program classifiers.
- */
-@Path("classifiers")
-public class ClassifierWebResource extends AbstractWebResource {
-
- private final Logger log = LoggerFactory.getLogger(ClassifierWebResource.class);
-
- /**
- * Get the list of classifier devices.
- *
- * @return 200 OK
- */
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getClassifiers() {
-
- ObjectNode result = mapper().createObjectNode();
-
- Iterable<DeviceId> classifierDevices = get(ClassifierService.class).getClassifiers();
- ArrayNode classifier = result.putArray("classifiers");
- if (classifierDevices != null) {
- for (final DeviceId deviceId : classifierDevices) {
- ObjectNode dev = mapper().createObjectNode()
- .put("DeviceId", deviceId.toString());
- classifier.add(dev);
- }
- }
- return ok(result.toString()).build();
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FloatingIpWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FloatingIpWebResource.java
deleted file mode 100644
index 9fc25a8..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FloatingIpWebResource.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Sets;
-import org.onlab.packet.IpAddress;
-import org.onlab.util.ItemNotFoundException;
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.DefaultFloatingIp;
-import org.onosproject.vtnrsc.FloatingIp;
-import org.onosproject.vtnrsc.FloatingIp.Status;
-import org.onosproject.vtnrsc.FloatingIpId;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.floatingip.FloatingIpService;
-import org.onosproject.vtnweb.web.FloatingIpCodec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
-import static javax.ws.rs.core.Response.Status.CONFLICT;
-import static javax.ws.rs.core.Response.Status.CREATED;
-import static javax.ws.rs.core.Response.Status.NOT_FOUND;
-import static org.onlab.util.Tools.readTreeFromStream;
-
-@Path("floatingips")
-public class FloatingIpWebResource extends AbstractWebResource {
- private final Logger log = LoggerFactory
- .getLogger(FloatingIpWebResource.class);
- public static final String CREATE_FAIL = "Floating IP is failed to create!";
- public static final String UPDATE_FAIL = "Floating IP is failed to update!";
- public static final String DELETE_FAIL = "Floating IP is failed to delete!";
- public static final String GET_FAIL = "Floating IP is failed to get!";
- public static final String NOT_EXIST = "Floating IP does not exist!";
- public static final String DELETE_SUCCESS = "Floating IP delete success!";
- public static final String JSON_NOT_NULL = "JsonNode can not be null";
-
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response listFloatingIps() {
- Collection<FloatingIp> floatingIps = get(FloatingIpService.class)
- .getFloatingIps();
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("floatingips",
- new FloatingIpCodec().encode(floatingIps, this));
- return ok(result.toString()).build();
- }
-
- @GET
- @Path("{floatingIpUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getFloatingIp(@PathParam("floatingIpUUID") String id,
- @QueryParam("fields") List<String> fields) {
-
- if (!get(FloatingIpService.class).exists(FloatingIpId.of(id))) {
- return Response.status(NOT_FOUND).entity(NOT_EXIST).build();
- }
- FloatingIp sub = nullIsNotFound(get(FloatingIpService.class)
- .getFloatingIp(FloatingIpId.of(id)), GET_FAIL);
-
- ObjectNode result = new ObjectMapper().createObjectNode();
- if (!fields.isEmpty()) {
- result.set("floatingip",
- new FloatingIpCodec().extracFields(sub, this, fields));
- } else {
- result.set("floatingip", new FloatingIpCodec().encode(sub, this));
- }
- return ok(result.toString()).build();
- }
-
- @POST
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response createFloatingIp(final InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode subnode = readTreeFromStream(mapper, input);
- Collection<FloatingIp> floatingIps = createOrUpdateByInputStream(subnode);
- Boolean result = nullIsNotFound((get(FloatingIpService.class)
- .createFloatingIps(floatingIps)),
- CREATE_FAIL);
- if (!result) {
- return Response.status(CONFLICT).entity(CREATE_FAIL).build();
- }
- return Response.status(CREATED).entity(result.toString()).build();
-
- } catch (Exception e) {
- return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
- }
- }
-
- @PUT
- @Path("{floatingIpUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updateFloatingIp(@PathParam("floatingIpUUID") String id,
- final InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode subnode = readTreeFromStream(mapper, input);
- Collection<FloatingIp> floatingIps = createOrUpdateByInputStream(subnode);
- Boolean result = nullIsNotFound(get(FloatingIpService.class)
- .updateFloatingIps(floatingIps), UPDATE_FAIL);
- if (!result) {
- return Response.status(CONFLICT).entity(UPDATE_FAIL).build();
- }
- return ok(result.toString()).build();
- } catch (Exception e) {
- return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
- }
- }
-
- @DELETE
- @Path("{floatingIpUUID}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response deleteSingleFloatingIp(@PathParam("floatingIpUUID") String id)
- throws IOException {
- try {
- FloatingIpId floatingIpId = FloatingIpId.of(id);
- Set<FloatingIpId> floatingIpIds = Sets.newHashSet(floatingIpId);
- Boolean result = nullIsNotFound(get(FloatingIpService.class)
- .removeFloatingIps(floatingIpIds), DELETE_FAIL);
- if (!result) {
- return Response.status(CONFLICT).entity(DELETE_FAIL).build();
- }
- return Response.noContent().entity(DELETE_SUCCESS).build();
- } catch (Exception e) {
- return Response.status(NOT_FOUND).entity(e.getMessage()).build();
- }
- }
-
- private Collection<FloatingIp> createOrUpdateByInputStream(JsonNode subnode) {
- checkNotNull(subnode, JSON_NOT_NULL);
- Collection<FloatingIp> floatingIps = null;
- JsonNode floatingIpNodes = subnode.get("floatingips");
- if (floatingIpNodes == null) {
- floatingIpNodes = subnode.get("floatingip");
- }
- log.debug("floatingNodes is {}", floatingIpNodes.toString());
-
- if (floatingIpNodes.isArray()) {
- throw new IllegalArgumentException("only singleton requests allowed");
- } else {
- floatingIps = changeJsonToSub(floatingIpNodes);
- }
- return floatingIps;
- }
-
- /**
- * Returns a collection of floatingIps from floatingIpNodes.
- *
- * @param floatingIpNodes the floatingIp json node
- * @return floatingIps a collection of floatingIp
- */
- public Collection<FloatingIp> changeJsonToSub(JsonNode floatingIpNodes) {
- checkNotNull(floatingIpNodes, JSON_NOT_NULL);
- Map<FloatingIpId, FloatingIp> subMap = new HashMap<FloatingIpId, FloatingIp>();
- if (!floatingIpNodes.hasNonNull("id")) {
- throw new IllegalArgumentException("id should not be null");
- } else if (floatingIpNodes.get("id").asText().isEmpty()) {
- throw new IllegalArgumentException("id should not be empty");
- }
- FloatingIpId id = FloatingIpId.of(floatingIpNodes.get("id")
- .asText());
-
- if (!floatingIpNodes.hasNonNull("tenant_id")) {
- throw new IllegalArgumentException("tenant_id should not be null");
- } else if (floatingIpNodes.get("tenant_id").asText().isEmpty()) {
- throw new IllegalArgumentException("tenant_id should not be empty");
- }
- TenantId tenantId = TenantId.tenantId(floatingIpNodes.get("tenant_id")
- .asText());
-
- if (!floatingIpNodes.hasNonNull("floating_network_id")) {
- throw new IllegalArgumentException(
- "floating_network_id should not be null");
- } else if (floatingIpNodes.get("floating_network_id").asText()
- .isEmpty()) {
- throw new IllegalArgumentException(
- "floating_network_id should not be empty");
- }
- TenantNetworkId networkId = TenantNetworkId.networkId(floatingIpNodes
- .get("floating_network_id").asText());
-
- VirtualPortId portId = null;
- if (floatingIpNodes.hasNonNull("port_id")) {
- portId = VirtualPortId.portId(floatingIpNodes.get("port_id")
- .asText());
- }
-
- RouterId routerId = null;
- if (floatingIpNodes.hasNonNull("router_id")) {
- routerId = RouterId.valueOf(floatingIpNodes.get("router_id")
- .asText());
- }
-
- IpAddress fixedIp = null;
- if (floatingIpNodes.hasNonNull("fixed_ip_address")) {
- fixedIp = IpAddress.valueOf(floatingIpNodes.get("fixed_ip_address")
- .asText());
- }
-
- if (!floatingIpNodes.hasNonNull("floating_ip_address")) {
- throw new IllegalArgumentException(
- "floating_ip_address should not be null");
- } else if (floatingIpNodes.get("floating_ip_address").asText()
- .isEmpty()) {
- throw new IllegalArgumentException(
- "floating_ip_address should not be empty");
- }
- IpAddress floatingIp = IpAddress.valueOf(floatingIpNodes
- .get("floating_ip_address").asText());
-
- if (!floatingIpNodes.hasNonNull("status")) {
- throw new IllegalArgumentException("status should not be null");
- } else if (floatingIpNodes.get("status").asText().isEmpty()) {
- throw new IllegalArgumentException("status should not be empty");
- }
- Status status = Status.valueOf(floatingIpNodes.get("status").asText());
-
- DefaultFloatingIp floatingIpObj = new DefaultFloatingIp(id, tenantId,
- networkId,
- portId,
- routerId,
- floatingIp,
- fixedIp, status);
- subMap.put(id, floatingIpObj);
- return Collections.unmodifiableCollection(subMap.values());
- }
-
- /**
- * Returns the specified item if that items is null; otherwise throws not
- * found exception.
- *
- * @param item item to check
- * @param <T> item type
- * @param message not found message
- * @return item if not null
- * @throws org.onlab.util.ItemNotFoundException if item is null
- */
- protected <T> T nullIsNotFound(T item, String message) {
- if (item == null) {
- throw new ItemNotFoundException(message);
- }
- return item;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java
deleted file mode 100644
index 47e249f..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import static javax.ws.rs.core.Response.Status.OK;
-import static org.onlab.util.Tools.nullIsNotFound;
-import static org.onlab.util.Tools.readTreeFromStream;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Query and program flow classifier.
- */
-@Path("flow_classifiers")
-public class FlowClassifierWebResource extends AbstractWebResource {
-
- private final Logger log = LoggerFactory.getLogger(FlowClassifierWebResource.class);
-
- public static final String FLOW_CLASSIFIER_NOT_FOUND = "Flow classifier not found";
-
- /**
- * Get all flow classifiers created.
- *
- * @return 200 OK
- */
- @GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response getFlowClassifiers() {
- Iterable<FlowClassifier> flowClassifiers = get(FlowClassifierService.class).getFlowClassifiers();
- ObjectNode result = mapper().createObjectNode();
- ArrayNode flowClassifierEntry = result.putArray("flow_classifiers");
- if (flowClassifiers != null) {
- for (final FlowClassifier flowClassifier : flowClassifiers) {
- flowClassifierEntry.add(codec(FlowClassifier.class).encode(flowClassifier, this));
- }
- }
- return ok(result.toString()).build();
- }
-
- /**
- * Get details of a flow classifier.
- *
- * @param id
- * flow classifier id
- * @return 200 OK , 404 if given identifier does not exist
- */
- @GET
- @Path("{flow_id}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response getFlowClassifier(@PathParam("flow_id") String id) {
- FlowClassifier flowClassifier = nullIsNotFound(get(FlowClassifierService.class)
- .getFlowClassifier(FlowClassifierId.of(id)), FLOW_CLASSIFIER_NOT_FOUND);
-
- ObjectNode result = mapper().createObjectNode();
- result.set("flow_classifier", codec(FlowClassifier.class).encode(flowClassifier, this));
-
- return ok(result.toString()).build();
- }
-
- /**
- * Creates and stores a new flow classifier.
- *
- * @param stream
- * flow classifier from JSON
- * @return status of the request - CREATED if the JSON is correct,
- * BAD_REQUEST if the JSON is invalid
- */
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response createFlowClassifier(InputStream stream) {
- try {
- ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
- JsonNode flow = jsonTree.get("flow_classifier");
-
- FlowClassifier flowClassifier = codec(FlowClassifier.class).decode((ObjectNode) flow, this);
- Boolean issuccess = nullIsNotFound(get(FlowClassifierService.class).createFlowClassifier(flowClassifier),
- FLOW_CLASSIFIER_NOT_FOUND);
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (IOException ex) {
- log.error("Exception while creating flow classifier {}.", ex.toString());
- throw new IllegalArgumentException(ex);
- }
- }
-
- /**
- * Update details of a flow classifier.
- *
- * @param id
- * flow classifier id
- * @param stream
- * InputStream
- * @return 200 OK, 404 if given identifier does not exist
- */
- @PUT
- @Path("{flow_id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updateFlowClassifier(@PathParam("flow_id") String id, final InputStream stream) {
- try {
-
- JsonNode jsonTree = readTreeFromStream(mapper(), stream);
- JsonNode flow = jsonTree.get("flow_classifier");
- FlowClassifier flowClassifier = codec(FlowClassifier.class).decode((ObjectNode) flow, this);
- Boolean result = nullIsNotFound(get(FlowClassifierService.class).updateFlowClassifier(flowClassifier),
- FLOW_CLASSIFIER_NOT_FOUND);
- return Response.status(OK).entity(result.toString()).build();
- } catch (IOException e) {
- log.error("Update flow classifier failed because of exception {}.", e.toString());
- throw new IllegalArgumentException(e);
- }
- }
-
- /**
- * Delete details of a flow classifier.
- *
- * @param id flow classifier id
- * @return 204 NO CONTENT
- */
- @Path("{flow_id}")
- @DELETE
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response deleteFlowClassifier(@PathParam("flow_id") String id) {
- log.debug("Deletes flow classifier by identifier {}.", id);
- FlowClassifierId flowClassifierId = FlowClassifierId.of(id);
- Boolean issuccess = nullIsNotFound(get(FlowClassifierService.class).removeFlowClassifier(flowClassifierId),
- FLOW_CLASSIFIER_NOT_FOUND);
- return Response.noContent().build();
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainDeviceMapWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainDeviceMapWebResource.java
deleted file mode 100644
index 8a48afb..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainDeviceMapWebResource.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onlab.util.Tools.nullIsNotFound;
-
-import java.util.Set;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.LoadBalanceId;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.portchain.PortChainService;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Query and program port chain.
- */
-
-@Path("portChainDeviceMap")
-public class PortChainDeviceMapWebResource extends AbstractWebResource {
-
- public static final String PORT_CHAIN_NOT_FOUND = "Port chain not found";
- public static final String PORT_CHAIN_ID_EXIST = "Port chain exists";
- public static final String PORT_CHAIN_ID_NOT_EXIST = "Port chain does not exist with identifier";
-
- private static final String NAME = "name";
- private static final String ID = "id";
- private static final String CLASSIFIERS = "classifiers";
- private static final String FORWARDERS = "forwarders";
- private static final String LOADBALANCEID = "loadBalanceId";
-
- /**
- * Get details of a specified port chain id.
- *
- * @param id port chain id
- * @return 200 OK, 404 if given identifier does not exist
- */
- @GET
- @Path("{chain_id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getPortChainDeviceMap(@PathParam("chain_id") String id) {
-
- PortChain portChain = nullIsNotFound(get(PortChainService.class).getPortChain(PortChainId.of(id)),
- PORT_CHAIN_NOT_FOUND);
- ObjectNode result = mapper().createObjectNode();
- result.set("portChainDeviceMap", encode(portChain, this));
-
- return ok(result.toString()).build();
- }
-
- private ObjectNode encode(PortChain portChain, CodecContext context) {
- checkNotNull(portChain, "portChain cannot be null");
- ObjectNode result = context.mapper().createObjectNode();
- result.put(ID, portChain.portChainId().toString())
- .put(NAME, portChain.name());
-
- Set<LoadBalanceId> loadBalanceIds = portChain.getLoadBalancePathMapKeys();
- for (LoadBalanceId id : loadBalanceIds) {
- result.put(LOADBALANCEID, id.toString())
- .put(CLASSIFIERS, portChain.getSfcClassifiers(id).toString())
- .put(FORWARDERS, portChain.getSfcForwarders(id).toString());
- }
- return result;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainSfMapWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainSfMapWebResource.java
deleted file mode 100644
index 7d08f88..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainSfMapWebResource.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import static org.onlab.util.Tools.nullIsNotFound;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.ServiceFunctionGroup;
-import org.onosproject.vtnrsc.portchainsfmap.PortChainSfMapService;
-
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Query service function and load details by port chain.
- */
-
-@Path("portChainSfMap")
-public class PortChainSfMapWebResource extends AbstractWebResource {
-
- public static final String PORT_CHAIN_NOT_FOUND = "Port chain not found";
- public static final String PORT_CHAIN_ID_EXIST = "Port chain exists";
- public static final String PORT_CHAIN_ID_NOT_EXIST = "Port chain does not exist with identifier";
-
- /**
- * Get service function details of a specified port chain id.
- *
- * @param id port chain id
- * @return 200 OK, 404 if given identifier does not exist
- */
- @GET
- @Path("{chainId}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getPortChainSfMap(@PathParam("chainId") String id) {
-
- Iterable<ServiceFunctionGroup> serviceFunctionGroups = nullIsNotFound(get(PortChainSfMapService.class)
- .getServiceFunctions(PortChainId.of(id)),
- PORT_CHAIN_NOT_FOUND);
- ObjectNode result = mapper().createObjectNode();
- ArrayNode portChainSfMap = result.putArray("portChainSfMap");
- if (serviceFunctionGroups != null) {
- for (final ServiceFunctionGroup serviceFunctionGroup : serviceFunctionGroups) {
- portChainSfMap.add(codec(ServiceFunctionGroup.class).encode(serviceFunctionGroup, this));
- }
- }
- return ok(result.toString()).build();
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java
deleted file mode 100644
index 1bfa44f..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import static javax.ws.rs.core.Response.Status.OK;
-import static org.onlab.util.Tools.nullIsNotFound;
-import static org.onlab.util.Tools.readTreeFromStream;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.portchain.PortChainService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Query and program port chain.
- */
-
-@Path("port_chains")
-public class PortChainWebResource extends AbstractWebResource {
-
- private final Logger log = LoggerFactory.getLogger(PortChainWebResource.class);
- public static final String PORT_CHAIN_NOT_FOUND = "Port chain not found";
- public static final String PORT_CHAIN_ID_EXIST = "Port chain exists";
- public static final String PORT_CHAIN_ID_NOT_EXIST = "Port chain does not exist with identifier";
-
- /**
- * Get details of all port chains created.
- *
- * @return 200 OK
- */
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getPortChains() {
- Iterable<PortChain> portChains = get(PortChainService.class).getPortChains();
- ObjectNode result = mapper().createObjectNode();
- ArrayNode portChainEntry = result.putArray("port_chains");
- if (portChains != null) {
- for (final PortChain portChain : portChains) {
- portChainEntry.add(codec(PortChain.class).encode(portChain, this));
- }
- }
- return ok(result.toString()).build();
- }
-
- /**
- * Get details of a specified port chain id.
- *
- * @param id port chain id
- * @return 200 OK, 404 if given identifier does not exist
- */
- @GET
- @Path("{chain_id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getPortPain(@PathParam("chain_id") String id) {
-
- PortChain portChain = nullIsNotFound(get(PortChainService.class).getPortChain(PortChainId.of(id)),
- PORT_CHAIN_NOT_FOUND);
- ObjectNode result = mapper().createObjectNode();
- result.set("port_chain", codec(PortChain.class).encode(portChain, this));
- return ok(result.toString()).build();
- }
-
- /**
- * Creates a new port chain.
- *
- * @param stream port chain from JSON
- * @return status of the request - CREATED if the JSON is correct,
- * BAD_REQUEST if the JSON is invalid
- */
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response createPortChain(InputStream stream) {
- try {
- ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
- JsonNode port = jsonTree.get("port_chain");
- PortChain portChain = codec(PortChain.class).decode((ObjectNode) port, this);
- Boolean issuccess = nullIsNotFound(get(PortChainService.class).createPortChain(portChain),
- PORT_CHAIN_NOT_FOUND);
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (IOException e) {
- log.error("Exception while creating port chain {}.", e.toString());
- throw new IllegalArgumentException(e);
- }
- }
-
- /**
- * Update details of a specified port chain id.
- *
- * @param id port chain id
- * @param stream port chain json
- * @return 200 OK, 404 if given identifier does not exist
- */
- @PUT
- @Path("{chain_id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updatePortPain(@PathParam("chain_id") String id,
- final InputStream stream) {
- try {
- ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
- JsonNode port = jsonTree.get("port_chain");
- PortChain portChain = codec(PortChain.class).decode((ObjectNode) port, this);
- Boolean result = nullIsNotFound(get(PortChainService.class).updatePortChain(portChain),
- PORT_CHAIN_NOT_FOUND);
- return Response.status(OK).entity(result.toString()).build();
- } catch (IOException e) {
- log.error("Update port chain failed because of exception {}.", e.toString());
- throw new IllegalArgumentException(e);
- }
- }
-
- /**
- * Delete details of a specified port chain id.
- *
- * @param id port chain id
- * @return 204 NO CONTENT
- */
- @Path("{chain_id}")
- @DELETE
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response deletePortPain(@PathParam("chain_id") String id) {
- log.debug("Deletes port chain by identifier {}.", id);
- PortChainId portChainId = PortChainId.of(id);
-
- Boolean issuccess = nullIsNotFound(get(PortChainService.class).removePortChain(portChainId),
- PORT_CHAIN_NOT_FOUND);
- if (!issuccess) {
- log.debug("Port Chain identifier {} does not exist", id);
- }
- return Response.noContent().build();
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairGroupWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairGroupWebResource.java
deleted file mode 100644
index 91793ca..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairGroupWebResource.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.vtnweb.resources;
-
-import static javax.ws.rs.core.Response.Status.OK;
-import static org.onlab.util.Tools.nullIsNotFound;
-import static org.onlab.util.Tools.readTreeFromStream;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Query and program port pair group.
- */
-
-@Path("port_pair_groups")
-public class PortPairGroupWebResource extends AbstractWebResource {
-
- private final Logger log = LoggerFactory.getLogger(PortPairGroupWebResource.class);
- public static final String PORT_PAIR_GROUP_NOT_FOUND = "Port pair group not found";
- public static final String PORT_PAIR_GROUP_ID_EXIST = "Port pair group exists";
- public static final String PORT_PAIR_GROUP_ID_NOT_EXIST = "Port pair group does not exist with identifier";
-
- /**
- * Get details of all port pair groups created.
- *
- * @return 200 OK
- */
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getPortPairGroups() {
- Iterable<PortPairGroup> portPairGroups = get(PortPairGroupService.class).getPortPairGroups();
- ObjectNode result = mapper().createObjectNode();
- ArrayNode portPairGroupEntry = result.putArray("port_pair_groups");
- if (portPairGroups != null) {
- for (final PortPairGroup portPairGroup : portPairGroups) {
- portPairGroupEntry.add(codec(PortPairGroup.class).encode(portPairGroup, this));
- }
- }
- return ok(result.toString()).build();
- }
-
- /**
- * Get details of a specified port pair group id.
- *
- * @param id port pair group id
- * @return 200 OK, 404 if given identifier does not exist
- */
- @GET
- @Path("{group_id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getPortPairGroup(@PathParam("group_id") String id) {
- PortPairGroup portPairGroup = nullIsNotFound(get(PortPairGroupService.class)
- .getPortPairGroup(PortPairGroupId.of(id)),
- PORT_PAIR_GROUP_NOT_FOUND);
-
- ObjectNode result = mapper().createObjectNode();
- result.set("port_pair_group", codec(PortPairGroup.class).encode(portPairGroup, this));
- return ok(result.toString()).build();
- }
-
- /**
- * Creates a new port pair group.
- *
- * @param stream port pair group from JSON
- * @return status of the request - CREATED if the JSON is correct,
- * BAD_REQUEST if the JSON is invalid
- */
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response createPortPairGroup(InputStream stream) {
-
- try {
- ObjectMapper mapper = new ObjectMapper();
- ObjectNode jsonTree = readTreeFromStream(mapper, stream);
- JsonNode port = jsonTree.get("port_pair_group");
-
- PortPairGroup portPairGroup = codec(PortPairGroup.class).decode((ObjectNode) port, this);
- Boolean issuccess = nullIsNotFound(get(PortPairGroupService.class).createPortPairGroup(portPairGroup),
- PORT_PAIR_GROUP_NOT_FOUND);
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (IOException e) {
- log.error("Exception while creating port pair group {}.", e.toString());
- throw new IllegalArgumentException(e);
- }
- }
-
- /**
- * Update details of a specified port pair group id.
- *
- * @param id port pair group id
- * @param stream port pair group from json
- * @return 200 OK, 404 if given identifier does not exist
- */
- @PUT
- @Path("{group_id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updatePortPairGroup(@PathParam("group_id") String id,
- final InputStream stream) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- ObjectNode jsonTree = readTreeFromStream(mapper, stream);
- JsonNode port = jsonTree.get("port_pair_group");
- PortPairGroup portPairGroup = codec(PortPairGroup.class).decode((ObjectNode) port, this);
- Boolean isSuccess = nullIsNotFound(get(PortPairGroupService.class).updatePortPairGroup(portPairGroup),
- PORT_PAIR_GROUP_NOT_FOUND);
- return Response.status(OK).entity(isSuccess.toString()).build();
- } catch (IOException e) {
- log.error("Update port pair group failed because of exception {}.", e.toString());
- throw new IllegalArgumentException(e);
- }
- }
-
- /**
- * Delete details of a specified port pair group id.
- *
- * @param id port pair group id
- * @return 204 NO CONTENT
- */
- @Path("{group_id}")
- @DELETE
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response deletePortPairGroup(@PathParam("group_id") String id) {
- log.debug("Deletes port pair group by identifier {}.", id);
- PortPairGroupId portPairGroupId = PortPairGroupId.of(id);
- Boolean issuccess = nullIsNotFound(get(PortPairGroupService.class).removePortPairGroup(portPairGroupId),
- PORT_PAIR_GROUP_NOT_FOUND);
- if (!issuccess) {
- log.debug("Port pair group identifier {} does not exist", id);
- }
-
- return Response.noContent().build();
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java
deleted file mode 100644
index 2c88f6f..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.vtnweb.resources;
-
-import static javax.ws.rs.core.Response.Status.OK;
-import static org.onlab.util.Tools.nullIsNotFound;
-import static org.onlab.util.Tools.readTreeFromStream;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.portpair.PortPairService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Query and program port pair.
- */
-@Path("port_pairs")
-public class PortPairWebResource extends AbstractWebResource {
-
- private final Logger log = LoggerFactory.getLogger(PortPairWebResource.class);
- public static final String PORT_PAIR_NOT_FOUND = "Port pair not found";
- public static final String PORT_PAIR_ID_EXIST = "Port pair exists";
- public static final String PORT_PAIR_ID_NOT_EXIST = "Port pair does not exist with identifier";
-
- /**
- * Get details of all port pairs created.
- *
- * @return 200 OK
- */
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getPortPairs() {
- Iterable<PortPair> portPairs = get(PortPairService.class).getPortPairs();
- ObjectNode result = mapper().createObjectNode();
- ArrayNode portPairEntry = result.putArray("port_pairs");
- if (portPairs != null) {
- for (final PortPair portPair : portPairs) {
- portPairEntry.add(codec(PortPair.class).encode(portPair, this));
- }
- }
- return ok(result.toString()).build();
- }
-
- /**
- * Get details of a specified port pair id.
- *
- * @param id port pair id
- * @return 200 OK, 404 if given identifier does not exist
- */
- @GET
- @Path("{pair_id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getPortPair(@PathParam("pair_id") String id) {
- PortPair portPair = nullIsNotFound(get(PortPairService.class).getPortPair(PortPairId.of(id)),
- PORT_PAIR_NOT_FOUND);
- ObjectNode result = mapper().createObjectNode();
- result.set("port_pair", codec(PortPair.class).encode(portPair, this));
- return ok(result.toString()).build();
- }
-
- /**
- * Creates a new port pair.
- *
- * @param stream port pair from JSON
- * @return status of the request - CREATED if the JSON is correct,
- * BAD_REQUEST if the JSON is invalid
- */
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response createPortPair(InputStream stream) {
- try {
- ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
- JsonNode port = jsonTree.get("port_pair");
- PortPair portPair = codec(PortPair.class).decode((ObjectNode) port, this);
- Boolean isSuccess = nullIsNotFound(get(PortPairService.class).createPortPair(portPair),
- PORT_PAIR_NOT_FOUND);
- return Response.status(OK).entity(isSuccess.toString()).build();
- } catch (IOException e) {
- log.error("Exception while creating port pair {}.", e.toString());
- throw new IllegalArgumentException(e);
- }
- }
-
- /**
- * Update details of a specified port pair id.
- *
- * @param id port pair id
- * @param stream port pair from json
- * @return 200 OK, 404 if the given identifier does not exist
- */
- @PUT
- @Path("{pair_id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updatePortPair(@PathParam("pair_id") String id,
- final InputStream stream) {
- try {
- ObjectNode jsonTree = readTreeFromStream(mapper(), stream);
- JsonNode port = jsonTree.get("port_pair");
- PortPair portPair = codec(PortPair.class).decode((ObjectNode) port, this);
- Boolean isSuccess = nullIsNotFound(get(PortPairService.class).updatePortPair(portPair),
- PORT_PAIR_NOT_FOUND);
- return Response.status(OK).entity(isSuccess.toString()).build();
- } catch (IOException e) {
- log.error("Update port pair failed because of exception {}.", e.toString());
- throw new IllegalArgumentException(e);
- }
- }
-
- /**
- * Delete details of a specified port pair id.
- *
- * @param id port pair id
- * @return 204 NO CONTENT
- */
- @Path("{pair_id}")
- @DELETE
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response deletePortPair(@PathParam("pair_id") String id) {
-
- PortPairId portPairId = PortPairId.of(id);
- Boolean isSuccess = nullIsNotFound(get(PortPairService.class).removePortPair(portPairId), PORT_PAIR_NOT_FOUND);
- if (!isSuccess) {
- log.debug("Port pair identifier {} does not exist", id);
- }
- return Response.noContent().build();
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java
deleted file mode 100644
index 15d56cf..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java
+++ /dev/null
@@ -1,491 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import org.onlab.packet.IpAddress;
-import org.onlab.util.ItemNotFoundException;
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.DefaultRouter;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.Router;
-import org.onosproject.vtnrsc.Router.Status;
-import org.onosproject.vtnrsc.RouterGateway;
-import org.onosproject.vtnrsc.RouterId;
-import org.onosproject.vtnrsc.RouterInterface;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.router.RouterService;
-import org.onosproject.vtnrsc.routerinterface.RouterInterfaceService;
-import org.onosproject.vtnweb.web.RouterCodec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
-import static javax.ws.rs.core.Response.Status.CONFLICT;
-import static javax.ws.rs.core.Response.Status.CREATED;
-import static javax.ws.rs.core.Response.Status.NOT_FOUND;
-import static org.onlab.util.Tools.readTreeFromStream;
-
-@Path("routers")
-public class RouterWebResource extends AbstractWebResource {
- private final Logger log = LoggerFactory.getLogger(RouterWebResource.class);
- public static final String CREATE_FAIL = "Router is failed to create!";
- public static final String UPDATE_FAIL = "Router is failed to update!";
- public static final String GET_FAIL = "Router is failed to get!";
- public static final String NOT_EXIST = "Router does not exist!";
- public static final String DELETE_SUCCESS = "Router delete success!";
- public static final String JSON_NOT_NULL = "JsonNode can not be null";
- public static final String INTFACR_ADD_SUCCESS = "Interface add success";
- public static final String INTFACR_DEL_SUCCESS = "Interface delete success";
-
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response listRouters() {
- Collection<Router> routers = get(RouterService.class).getRouters();
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("routers", new RouterCodec().encode(routers, this));
- return ok(result.toString()).build();
- }
-
- @GET
- @Path("{routerUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getRouter(@PathParam("routerUUID") String id,
- @QueryParam("fields") List<String> fields) {
-
- if (!get(RouterService.class).exists(RouterId.valueOf(id))) {
- return Response.status(NOT_FOUND)
- .entity("The Router does not exists").build();
- }
- Router sub = nullIsNotFound(get(RouterService.class)
- .getRouter(RouterId.valueOf(id)), NOT_EXIST);
-
- ObjectNode result = new ObjectMapper().createObjectNode();
- if (!fields.isEmpty()) {
- result.set("router",
- new RouterCodec().extracFields(sub, this, fields));
- } else {
- result.set("router", new RouterCodec().encode(sub, this));
- }
- return ok(result.toString()).build();
- }
-
- @POST
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response createRouter(final InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode subnode = readTreeFromStream(mapper, input);
- Collection<Router> routers = createOrUpdateByInputStream(subnode);
-
- Boolean result = nullIsNotFound((get(RouterService.class)
- .createRouters(routers)), CREATE_FAIL);
- if (!result) {
- return Response.status(CONFLICT).entity(CREATE_FAIL).build();
- }
- return Response.status(CREATED).entity(result.toString()).build();
-
- } catch (IllegalArgumentException | IOException e) {
- return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
- }
- }
-
- @PUT
- @Path("{routerUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updateRouter(@PathParam("routerUUID") String id,
- final InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode subnode = readTreeFromStream(mapper, input);
- Collection<Router> routers = changeUpdateJsonToSub(subnode, id);
- Boolean result = nullIsNotFound(get(RouterService.class)
- .updateRouters(routers), UPDATE_FAIL);
- if (!result) {
- return Response.status(CONFLICT).entity(UPDATE_FAIL).build();
- }
- return ok(result.toString()).build();
- } catch (Exception e) {
- return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
- }
- }
-
- @DELETE
- @Path("{routerUUID}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response deleteSingleRouter(@PathParam("routerUUID") String id)
- throws IOException {
- try {
- RouterId routerId = RouterId.valueOf(id);
- Set<RouterId> routerIds = Sets.newHashSet(routerId);
- get(RouterService.class).removeRouters(routerIds);
- return Response.noContent().entity(DELETE_SUCCESS).build();
- } catch (Exception e) {
- return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
- }
- }
-
- @PUT
- @Path("{routerUUID}/add_router_interface")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response addRouterInterface(@PathParam("routerUUID") String id,
- final InputStream input) {
- if (!get(RouterService.class).exists(RouterId.valueOf(id))) {
- return Response.status(NOT_FOUND).entity(NOT_EXIST).build();
- }
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode subnode = readTreeFromStream(mapper, input);
- if (!subnode.hasNonNull("id")) {
- throw new IllegalArgumentException("id should not be null");
- } else if (subnode.get("id").asText().isEmpty()) {
- throw new IllegalArgumentException("id should not be empty");
- }
- RouterId routerId = RouterId.valueOf(id);
- if (!subnode.hasNonNull("subnet_id")) {
- throw new IllegalArgumentException("subnet_id should not be null");
- } else if (subnode.get("subnet_id").asText().isEmpty()) {
- throw new IllegalArgumentException("subnet_id should not be empty");
- }
- SubnetId subnetId = SubnetId
- .subnetId(subnode.get("subnet_id").asText());
- if (!subnode.hasNonNull("tenant_id")) {
- throw new IllegalArgumentException("tenant_id should not be null");
- } else if (subnode.get("tenant_id").asText().isEmpty()) {
- throw new IllegalArgumentException("tenant_id should not be empty");
- }
- TenantId tenantId = TenantId
- .tenantId(subnode.get("tenant_id").asText());
- if (!subnode.hasNonNull("port_id")) {
- throw new IllegalArgumentException("port_id should not be null");
- } else if (subnode.get("port_id").asText().isEmpty()) {
- throw new IllegalArgumentException("port_id should not be empty");
- }
- VirtualPortId portId = VirtualPortId
- .portId(subnode.get("port_id").asText());
- RouterInterface routerInterface = RouterInterface
- .routerInterface(subnetId, portId, routerId, tenantId);
- get(RouterInterfaceService.class)
- .addRouterInterface(routerInterface);
- return ok(INTFACR_ADD_SUCCESS).build();
- } catch (Exception e) {
- return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
- }
- }
-
- @PUT
- @Path("{routerUUID}/remove_router_interface")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response removeRouterInterface(@PathParam("routerUUID") String id,
- final InputStream input) {
- if (!get(RouterService.class).exists(RouterId.valueOf(id))) {
- return Response.status(NOT_FOUND).entity(NOT_EXIST).build();
- }
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode subnode = readTreeFromStream(mapper, input);
- if (!subnode.hasNonNull("id")) {
- throw new IllegalArgumentException("id should not be null");
- } else if (subnode.get("id").asText().isEmpty()) {
- throw new IllegalArgumentException("id should not be empty");
- }
- RouterId routerId = RouterId.valueOf(id);
- if (!subnode.hasNonNull("subnet_id")) {
- throw new IllegalArgumentException("subnet_id should not be null");
- } else if (subnode.get("subnet_id").asText().isEmpty()) {
- throw new IllegalArgumentException("subnet_id should not be empty");
- }
- SubnetId subnetId = SubnetId
- .subnetId(subnode.get("subnet_id").asText());
- if (!subnode.hasNonNull("port_id")) {
- throw new IllegalArgumentException("port_id should not be null");
- } else if (subnode.get("port_id").asText().isEmpty()) {
- throw new IllegalArgumentException("port_id should not be empty");
- }
- VirtualPortId portId = VirtualPortId
- .portId(subnode.get("port_id").asText());
- if (!subnode.hasNonNull("tenant_id")) {
- throw new IllegalArgumentException("tenant_id should not be null");
- } else if (subnode.get("tenant_id").asText().isEmpty()) {
- throw new IllegalArgumentException("tenant_id should not be empty");
- }
- TenantId tenantId = TenantId
- .tenantId(subnode.get("tenant_id").asText());
- RouterInterface routerInterface = RouterInterface
- .routerInterface(subnetId, portId, routerId, tenantId);
- get(RouterInterfaceService.class)
- .removeRouterInterface(routerInterface);
- return ok(INTFACR_DEL_SUCCESS).build();
- } catch (Exception e) {
- return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
- }
- }
-
- private Collection<Router> createOrUpdateByInputStream(JsonNode subnode) {
- checkNotNull(subnode, JSON_NOT_NULL);
- JsonNode routerNode = subnode.get("routers");
- if (routerNode == null) {
- routerNode = subnode.get("router");
- }
- log.debug("routerNode is {}", routerNode.toString());
-
- if (routerNode.isArray()) {
- throw new IllegalArgumentException("only singleton requests allowed");
- } else {
- return changeJsonToSub(routerNode);
- }
- }
-
- /**
- * Returns a collection of floatingIps from floatingIpNodes.
- *
- * @param routerNode the router json node
- * @return routers a collection of router
- */
- public Collection<Router> changeJsonToSub(JsonNode routerNode) {
- checkNotNull(routerNode, JSON_NOT_NULL);
- Map<RouterId, Router> subMap = new HashMap<RouterId, Router>();
- if (!routerNode.hasNonNull("id")) {
- throw new IllegalArgumentException("id should not be null");
- } else if (routerNode.get("id").asText().isEmpty()) {
- throw new IllegalArgumentException("id should not be empty");
- }
- RouterId id = RouterId.valueOf(routerNode.get("id").asText());
-
- if (!routerNode.hasNonNull("tenant_id")) {
- throw new IllegalArgumentException("tenant_id should not be null");
- } else if (routerNode.get("tenant_id").asText().isEmpty()) {
- throw new IllegalArgumentException("tenant_id should not be empty");
- }
- TenantId tenantId = TenantId
- .tenantId(routerNode.get("tenant_id").asText());
-
- VirtualPortId gwPortId = null;
- if (routerNode.hasNonNull("gw_port_id")) {
- gwPortId = VirtualPortId
- .portId(routerNode.get("gw_port_id").asText());
- }
-
- if (!routerNode.hasNonNull("status")) {
- throw new IllegalArgumentException("status should not be null");
- } else if (routerNode.get("status").asText().isEmpty()) {
- throw new IllegalArgumentException("status should not be empty");
- }
- Status status = Status.valueOf(routerNode.get("status").asText());
-
- String routerName = null;
- if (routerNode.hasNonNull("name")) {
- routerName = routerNode.get("name").asText();
- }
-
- boolean adminStateUp = true;
- checkArgument(routerNode.get("admin_state_up").isBoolean(),
- "admin_state_up should be boolean");
- if (routerNode.hasNonNull("admin_state_up")) {
- adminStateUp = routerNode.get("admin_state_up").asBoolean();
- }
- boolean distributed = false;
- if (routerNode.hasNonNull("distributed")) {
- distributed = routerNode.get("distributed").asBoolean();
- }
- RouterGateway gateway = null;
- if (routerNode.hasNonNull("external_gateway_info")) {
- gateway = jsonNodeToGateway(routerNode
- .get("external_gateway_info"));
- }
- List<String> routes = new ArrayList<String>();
- DefaultRouter routerObj = new DefaultRouter(id, routerName,
- adminStateUp, status,
- distributed, gateway,
- gwPortId, tenantId, routes);
- subMap.put(id, routerObj);
- return Collections.unmodifiableCollection(subMap.values());
- }
-
- /**
- * Returns a collection of floatingIps from floatingIpNodes.
- *
- * @param subnode the router json node
- * @param routerId the router identify
- * @return routers a collection of router
- */
- public Collection<Router> changeUpdateJsonToSub(JsonNode subnode,
- String routerId) {
- checkNotNull(subnode, JSON_NOT_NULL);
- checkNotNull(routerId, "routerId should not be null");
- Map<RouterId, Router> subMap = new HashMap<RouterId, Router>();
- JsonNode routerNode = subnode.get("router");
- RouterId id = RouterId.valueOf(routerId);
- Router sub = nullIsNotFound(get(RouterService.class).getRouter(id),
- NOT_EXIST);
- TenantId tenantId = sub.tenantId();
-
- VirtualPortId gwPortId = null;
- if (routerNode.hasNonNull("gw_port_id")) {
- gwPortId = VirtualPortId
- .portId(routerNode.get("gw_port_id").asText());
- }
- Status status = sub.status();
-
- String routerName = routerNode.get("name").asText();
-
- checkArgument(routerNode.get("admin_state_up").isBoolean(),
- "admin_state_up should be boolean");
- boolean adminStateUp = routerNode.get("admin_state_up").asBoolean();
-
- boolean distributed = sub.distributed();
- if (routerNode.hasNonNull("distributed")) {
- distributed = routerNode.get("distributed").asBoolean();
- }
- RouterGateway gateway = sub.externalGatewayInfo();
- if (routerNode.hasNonNull("external_gateway_info")) {
- gateway = jsonNodeToGateway(routerNode
- .get("external_gateway_info"));
- }
- List<String> routes = new ArrayList<String>();
- DefaultRouter routerObj = new DefaultRouter(id, routerName,
- adminStateUp, status,
- distributed, gateway,
- gwPortId, tenantId, routes);
- subMap.put(id, routerObj);
- return Collections.unmodifiableCollection(subMap.values());
- }
-
- /**
- * Changes JsonNode Gateway to the Gateway.
- *
- * @param gateway the gateway JsonNode
- * @return gateway
- */
- private RouterGateway jsonNodeToGateway(JsonNode gateway) {
- checkNotNull(gateway, JSON_NOT_NULL);
- if (!gateway.hasNonNull("network_id")) {
- throw new IllegalArgumentException("network_id should not be null");
- } else if (gateway.get("network_id").asText().isEmpty()) {
- throw new IllegalArgumentException("network_id should not be empty");
- }
- TenantNetworkId networkId = TenantNetworkId
- .networkId(gateway.get("network_id").asText());
-
- if (!gateway.hasNonNull("enable_snat")) {
- throw new IllegalArgumentException("enable_snat should not be null");
- } else if (gateway.get("enable_snat").asText().isEmpty()) {
- throw new IllegalArgumentException("enable_snat should not be empty");
- }
- checkArgument(gateway.get("enable_snat").isBoolean(),
- "enable_snat should be boolean");
- boolean enableSnat = gateway.get("enable_snat").asBoolean();
-
- if (!gateway.hasNonNull("external_fixed_ips")) {
- throw new IllegalArgumentException("external_fixed_ips should not be null");
- } else if (gateway.get("external_fixed_ips").isNull()) {
- throw new IllegalArgumentException("external_fixed_ips should not be empty");
- }
- Iterable<FixedIp> fixedIpList = jsonNodeToFixedIp(gateway
- .get("external_fixed_ips"));
- RouterGateway gatewayObj = RouterGateway
- .routerGateway(networkId, enableSnat, Sets.newHashSet(fixedIpList));
- return gatewayObj;
- }
-
- /**
- * Changes JsonNode fixedIp to a collection of the fixedIp.
- *
- * @param fixedIp the allocationPools JsonNode
- * @return a collection of fixedIp
- */
- private Iterable<FixedIp> jsonNodeToFixedIp(JsonNode fixedIp) {
- checkNotNull(fixedIp, JSON_NOT_NULL);
- ConcurrentMap<Integer, FixedIp> fixedIpMaps = Maps.newConcurrentMap();
- Integer i = 0;
- for (JsonNode node : fixedIp) {
- if (!node.hasNonNull("subnet_id")) {
- throw new IllegalArgumentException("subnet_id should not be null");
- } else if (node.get("subnet_id").asText().isEmpty()) {
- throw new IllegalArgumentException("subnet_id should not be empty");
- }
- SubnetId subnetId = SubnetId
- .subnetId(node.get("subnet_id").asText());
- if (!node.hasNonNull("ip_address")) {
- throw new IllegalArgumentException("ip_address should not be null");
- } else if (node.get("ip_address").asText().isEmpty()) {
- throw new IllegalArgumentException("ip_address should not be empty");
- }
- IpAddress ipAddress = IpAddress
- .valueOf(node.get("ip_address").asText());
- FixedIp fixedIpObj = FixedIp.fixedIp(subnetId, ipAddress);
-
- fixedIpMaps.putIfAbsent(i, fixedIpObj);
- i++;
- }
- return Collections.unmodifiableCollection(fixedIpMaps.values());
- }
-
- /**
- * Returns the specified item if that items is null; otherwise throws not
- * found exception.
- *
- * @param item item to check
- * @param <T> item type
- * @param message not found message
- * @return item if not null
- * @throws org.onlab.util.ItemNotFoundException if item is null
- */
- protected <T> T nullIsNotFound(T item, String message) {
- if (item == null) {
- throw new ItemNotFoundException(message);
- }
- return item;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java
deleted file mode 100644
index b0951f4..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
-import static javax.ws.rs.core.Response.Status.NOT_FOUND;
-import static org.onlab.util.Tools.readTreeFromStream;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-import org.onlab.util.ItemNotFoundException;
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.AllocationPool;
-import org.onosproject.vtnrsc.DefaultAllocationPool;
-import org.onosproject.vtnrsc.DefaultHostRoute;
-import org.onosproject.vtnrsc.DefaultSubnet;
-import org.onosproject.vtnrsc.HostRoute;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.Subnet.Mode;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-import org.onosproject.vtnweb.web.SubnetCodec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-@Path("subnets")
-public class SubnetWebResource extends AbstractWebResource {
- private final Logger log = LoggerFactory.getLogger(SubnetWebResource.class);
- public static final String SUBNET_NOT_CREATED = "Subnet failed to create!";
- public static final String SUBNET_NOT_FOUND = "Subnet is not found";
- public static final String JSON_NOT_NULL = "JsonNode can not be null";
-
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response listSubnets() {
- Iterable<Subnet> subnets = get(SubnetService.class).getSubnets();
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("subnets", new SubnetCodec().encode(subnets, this));
- return ok(result.toString()).build();
- }
-
- @GET
- @Path("{subnetUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getSubnet(@PathParam("subnetUUID") String id) {
-
- if (!get(SubnetService.class).exists(SubnetId.subnetId(id))) {
- return Response.status(NOT_FOUND)
- .entity(SUBNET_NOT_FOUND).build();
- }
- Subnet sub = nullIsNotFound(get(SubnetService.class)
- .getSubnet(SubnetId.subnetId(id)),
- SUBNET_NOT_FOUND);
-
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("subnet", new SubnetCodec().encode(sub, this));
- return ok(result.toString()).build();
- }
-
- @POST
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response createSubnet(final InputStream input) {
-
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode subnode = readTreeFromStream(mapper, input);
- Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
- Boolean result = nullIsNotFound((get(SubnetService.class)
- .createSubnets(subnets)),
- SUBNET_NOT_CREATED);
-
- if (!result) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(SUBNET_NOT_CREATED).build();
- }
- return Response.status(202).entity(result.toString()).build();
- } catch (Exception e) {
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @PUT
- @Path("{subnetUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updateSubnet(@PathParam("id") String id,
- final InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode subnode = readTreeFromStream(mapper, input);
- Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
- Boolean result = nullIsNotFound(get(SubnetService.class)
- .updateSubnets(subnets), SUBNET_NOT_FOUND);
- if (!result) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(SUBNET_NOT_FOUND).build();
- }
- return Response.status(203).entity(result.toString()).build();
- } catch (Exception e) {
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @DELETE
- @Path("{subnetUUID}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response deleteSingleSubnet(@PathParam("subnetUUID") String id)
- throws IOException {
- try {
- SubnetId subId = SubnetId.subnetId(id);
- Set<SubnetId> subIds = new HashSet<>();
- subIds.add(subId);
- get(SubnetService.class).removeSubnets(subIds);
- return Response.noContent().entity("SUCCESS").build();
- } catch (Exception e) {
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- private Iterable<Subnet> createOrUpdateByInputStream(JsonNode subnode) {
- checkNotNull(subnode, JSON_NOT_NULL);
- Iterable<Subnet> subnets = null;
- JsonNode subnetNodes = subnode.get("subnets");
- if (subnetNodes == null) {
- subnetNodes = subnode.get("subnet");
- }
- log.debug("subnetNodes is {}", subnetNodes.toString());
- if (subnetNodes.isArray()) {
- subnets = changeJsonToSubs(subnetNodes);
- } else {
- subnets = changeJsonToSub(subnetNodes);
- }
- return subnets;
- }
-
- /**
- * Returns a collection of subnets from subnetNodes.
- *
- * @param subnetNodes the subnet json node
- * @return subnets a collection of subnets
- */
- public Iterable<Subnet> changeJsonToSubs(JsonNode subnetNodes) {
- checkNotNull(subnetNodes, JSON_NOT_NULL);
- Map<SubnetId, Subnet> subMap = new HashMap<>();
- for (JsonNode subnetNode : subnetNodes) {
- if (!subnetNode.hasNonNull("id")) {
- return null;
- }
- SubnetId id = SubnetId.subnetId(subnetNode.get("id").asText());
- String subnetName = subnetNode.get("name").asText();
- TenantId tenantId = TenantId
- .tenantId(subnetNode.get("tenant_id").asText());
- TenantNetworkId networkId = TenantNetworkId
- .networkId(subnetNode.get("network_id").asText());
- String version = subnetNode.get("ip_version").asText();
- Version ipVersion;
- switch (version) {
- case "4":
- ipVersion = Version.INET;
- break;
- case "6":
- ipVersion = Version.INET;
- break;
- default:
- throw new IllegalArgumentException("ipVersion should be 4 or 6.");
- }
- IpPrefix cidr = IpPrefix.valueOf(subnetNode.get("cidr").asText());
- IpAddress gatewayIp = IpAddress
- .valueOf(subnetNode.get("gateway_ip").asText());
- Boolean dhcpEnabled = subnetNode.get("enable_dhcp").asBoolean();
- Boolean shared = subnetNode.get("shared").asBoolean();
- JsonNode hostRoutes = subnetNode.get("host_routes");
- Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
- JsonNode allocationPools = subnetNode.get("allocation_pools");
- Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
- Mode ipV6AddressMode = Mode
- .valueOf(subnetNode.get("ipv6_address_mode").asText());
- Mode ipV6RaMode = Mode
- .valueOf(subnetNode.get("ipv6_ra_mode").asText());
- Subnet subnet = new DefaultSubnet(id, subnetName, networkId,
- tenantId, ipVersion, cidr,
- gatewayIp, dhcpEnabled, shared,
- Sets.newHashSet(hostRoutesIt), ipV6AddressMode,
- ipV6RaMode, Sets.newHashSet(allocationPoolsIt));
- subMap.put(id, subnet);
- }
- return Collections.unmodifiableCollection(subMap.values());
- }
-
- /**
- * Returns a collection of subnets from subnetNodes.
- *
- * @param subnetNodes the subnet json node
- * @return subnets a collection of subnets
- */
- public Iterable<Subnet> changeJsonToSub(JsonNode subnetNodes) {
- checkNotNull(subnetNodes, JSON_NOT_NULL);
- checkArgument(subnetNodes.get("enable_dhcp").isBoolean(), "enable_dhcp should be boolean");
- checkArgument(subnetNodes.get("shared").isBoolean(), "shared should be boolean");
- Map<SubnetId, Subnet> subMap = new HashMap<>();
- if (!subnetNodes.hasNonNull("id")) {
- return null;
- }
- SubnetId id = SubnetId.subnetId(subnetNodes.get("id").asText());
- String subnetName = subnetNodes.get("name").asText();
- TenantId tenantId = TenantId
- .tenantId(subnetNodes.get("tenant_id").asText());
- TenantNetworkId networkId = TenantNetworkId
- .networkId(subnetNodes.get("network_id").asText());
- String version = subnetNodes.get("ip_version").asText();
- Version ipVersion;
- switch (version) {
- case "4":
- ipVersion = Version.INET;
- break;
- case "6":
- ipVersion = Version.INET;
- break;
- default:
- throw new IllegalArgumentException("ipVersion should be 4 or 6.");
- }
-
- IpPrefix cidr = IpPrefix.valueOf(subnetNodes.get("cidr").asText());
- IpAddress gatewayIp = IpAddress
- .valueOf(subnetNodes.get("gateway_ip").asText());
- Boolean dhcpEnabled = subnetNodes.get("enable_dhcp").asBoolean();
- Boolean shared = subnetNodes.get("shared").asBoolean();
- JsonNode hostRoutes = subnetNodes.get("host_routes");
- Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
- JsonNode allocationPools = subnetNodes.get("allocation_pools");
- Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
-
- Mode ipV6AddressMode = getMode(subnetNodes.get("ipv6_address_mode")
- .asText());
- Mode ipV6RaMode = getMode(subnetNodes.get("ipv6_ra_mode").asText());
-
- Subnet subnet = new DefaultSubnet(id, subnetName, networkId, tenantId,
- ipVersion, cidr, gatewayIp,
- dhcpEnabled, shared, Sets.newHashSet(hostRoutesIt),
- ipV6AddressMode, ipV6RaMode,
- Sets.newHashSet(allocationPoolsIt));
- subMap.put(id, subnet);
- return Collections.unmodifiableCollection(subMap.values());
- }
-
- /**
- * Gets ipv6_address_mode or ipv6_ra_mode type.
- *
- * @param mode the String value in JsonNode
- * @return ipV6Mode Mode of the ipV6Mode
- */
- private Mode getMode(String mode) {
- Mode ipV6Mode;
- if (mode == null) {
- return null;
- }
- switch (mode) {
- case "dhcpv6-stateful":
- ipV6Mode = Mode.DHCPV6_STATEFUL;
- break;
- case "dhcpv6-stateless":
- ipV6Mode = Mode.DHCPV6_STATELESS;
- break;
- case "slaac":
- ipV6Mode = Mode.SLAAC;
- break;
- default:
- ipV6Mode = null;
- }
- return ipV6Mode;
- }
-
- /**
- * Changes JsonNode alocPools to a collection of the alocPools.
- *
- * @param allocationPools the allocationPools JsonNode
- * @return a collection of allocationPools
- */
- public Iterable<AllocationPool> jsonNodeToAllocationPools(JsonNode allocationPools) {
- checkNotNull(allocationPools, JSON_NOT_NULL);
- ConcurrentMap<Integer, AllocationPool> alocplMaps = Maps
- .newConcurrentMap();
- Integer i = 0;
- for (JsonNode node : allocationPools) {
- IpAddress startIp = IpAddress.valueOf(node.get("start").asText());
- IpAddress endIp = IpAddress.valueOf(node.get("end").asText());
- AllocationPool alocPls = new DefaultAllocationPool(startIp, endIp);
- alocplMaps.putIfAbsent(i, alocPls);
- i++;
- }
- return Collections.unmodifiableCollection(alocplMaps.values());
- }
-
- /**
- * Changes hostRoutes JsonNode to a collection of the hostRoutes.
- *
- * @param hostRoutes the hostRoutes json node
- * @return a collection of hostRoutes
- */
- public Iterable<HostRoute> jsonNodeToHostRoutes(JsonNode hostRoutes) {
- checkNotNull(hostRoutes, JSON_NOT_NULL);
- ConcurrentMap<Integer, HostRoute> hostRouteMaps = Maps
- .newConcurrentMap();
- Integer i = 0;
- for (JsonNode node : hostRoutes) {
- IpAddress nexthop = IpAddress.valueOf(node.get("nexthop").asText());
- IpPrefix destination = IpPrefix.valueOf(node.get("destination")
- .asText());
- HostRoute hostRoute = new DefaultHostRoute(nexthop, destination);
- hostRouteMaps.putIfAbsent(i, hostRoute);
- i++;
- }
- return Collections.unmodifiableCollection(hostRouteMaps.values());
- }
-
- /**
- * Returns the specified item if that items is null; otherwise throws not
- * found exception.
- *
- * @param item item to check
- * @param <T> item type
- * @param message not found message
- * @return item if not null
- * @throws org.onlab.util.ItemNotFoundException if item is null
- */
- protected <T> T nullIsNotFound(T item, String message) {
- if (item == null) {
- throw new ItemNotFoundException(message);
- }
- return item;
- }
-
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java
deleted file mode 100644
index a18682c..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Maps;
-import org.onlab.util.ItemNotFoundException;
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.DefaultTenantNetwork;
-import org.onosproject.vtnrsc.PhysicalNetwork;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetwork.State;
-import org.onosproject.vtnrsc.TenantNetwork.Type;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.service.VtnRscService;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnweb.web.TenantNetworkCodec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
-import static javax.ws.rs.core.Response.Status.NOT_FOUND;
-import static javax.ws.rs.core.Response.Status.OK;
-import static org.onlab.util.Tools.readTreeFromStream;
-
-/**
- * REST resource for interacting with the inventory of networks.
- */
-@Path("networks")
-public class TenantNetworkWebResource extends AbstractWebResource {
- public static final String NETWORK_NOT_FOUND = "Network is not found";
- public static final String NETWORK_ID_EXIST = "Network id is existed";
- public static final String NETWORK_ID_NOT_EXIST = "Network id is not existed";
- public static final String CREATE_NETWORK = "create network";
- public static final String UPDATE_NETWORK = "update network";
- public static final String DELETE_NETWORK = "delete network";
- public static final String JSON_NOT_NULL = "JsonNode can not be null";
-
- private static final Logger log = LoggerFactory
- .getLogger(TenantNetworkWebResource.class);
- private final ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
- .newConcurrentMap();
-
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getNetworks(@QueryParam("id") String queryId,
- @QueryParam("name") String queryName,
- @QueryParam("admin_state_up") String queryadminStateUp,
- @QueryParam("status") String querystate,
- @QueryParam("shared") String queryshared,
- @QueryParam("tenant_id") String querytenantId,
- @QueryParam("router:external") String routerExternal,
- @QueryParam("provider:network_type") String type,
- @QueryParam("provider:physical_network") String physicalNetwork,
- @QueryParam("provider:segmentation_id") String segmentationId) {
- Iterable<TenantNetwork> networks = get(TenantNetworkService.class)
- .getNetworks();
- Iterator<TenantNetwork> networkors = networks.iterator();
- while (networkors.hasNext()) {
- TenantNetwork network = networkors.next();
- if ((queryId == null || queryId.equals(network.id().toString()))
- && (queryName == null || queryName.equals(network.name()))
- && (queryadminStateUp == null || queryadminStateUp
- .equals(Boolean.toString(network.adminStateUp())))
- && (querystate == null || querystate.equals(network.state()
- .toString()))
- && (queryshared == null || queryshared.equals(Boolean.toString(network
- .shared())))
- && (querytenantId == null || querytenantId.equals(network
- .tenantId().toString()))
- && (routerExternal == null || routerExternal.equals(Boolean.toString(network
- .routerExternal())))
- && (type == null || type.equals(network.type().toString()))
- && (physicalNetwork == null || physicalNetwork
- .equals(network.physicalNetwork().toString()))
- && (segmentationId == null || segmentationId.equals(network
- .segmentationId().toString()))) {
- networksMap.putIfAbsent(network.id(), network);
- }
- }
- networks = Collections.unmodifiableCollection(networksMap.values());
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("networks", new TenantNetworkCodec().encode(networks, this));
-
- return ok(result.toString()).build();
- }
-
- private State isState(String state) {
- if ("ACTIVE".equals(state)) {
- return TenantNetwork.State.ACTIVE;
- } else if ("BUILD".equals(state)) {
- return TenantNetwork.State.BUILD;
- } else if ("DOWN".equals(state)) {
- return TenantNetwork.State.DOWN;
- } else if ("ERROR".equals(state)) {
- return TenantNetwork.State.ERROR;
- } else {
- return null;
- }
- }
-
- private Type isType(String type) {
- if ("LOCAL".equals(type)) {
- return TenantNetwork.Type.LOCAL;
- } else {
- return null;
- }
- }
-
- @GET
- @Path("{id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getNetwork(@PathParam("id") String id) {
-
- if (!get(TenantNetworkService.class).exists(TenantNetworkId
- .networkId(id))) {
- return Response.status(NOT_FOUND)
- .entity(NETWORK_NOT_FOUND).build();
- }
- TenantNetwork network = nullIsNotFound(get(TenantNetworkService.class)
- .getNetwork(TenantNetworkId.networkId(id)), NETWORK_NOT_FOUND);
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("network", new TenantNetworkCodec().encode(network, this));
-
- return ok(result.toString()).build();
-
- }
-
- @POST
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response createNetworks(InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode cfg = readTreeFromStream(mapper, input);
- JsonNode nodes = null;
- Iterable<TenantNetwork> networks = null;
- if (cfg.get("network") != null) {
- nodes = cfg.get("network");
- if (nodes.isArray()) {
- networks = changeJson2objs(nodes);
- } else {
- networks = changeJson2obj(CREATE_NETWORK, null, nodes);
- }
- } else if (cfg.get("networks") != null) {
- nodes = cfg.get("networks");
- networks = changeJson2objs(nodes);
- }
- Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class)
- .createNetworks(networks)),
- NETWORK_NOT_FOUND);
-
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(NETWORK_ID_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Creates tenantNetwork exception {}.", e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @PUT
- @Path("{id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updateNetworks(@PathParam("id") String id, InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode cfg = readTreeFromStream(mapper, input);
- JsonNode nodes = null;
- Iterable<TenantNetwork> networks = null;
- if (cfg.get("network") != null) {
- nodes = cfg.get("network");
- if (nodes.isArray()) {
- networks = changeJson2objs(nodes);
- } else {
- networks = changeJson2obj(UPDATE_NETWORK,
- TenantNetworkId.networkId(id),
- nodes);
- }
- } else if (cfg.get("networks") != null) {
- nodes = cfg.get("networks");
- networks = changeJson2objs(nodes);
- }
- Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class)
- .updateNetworks(networks)),
- NETWORK_NOT_FOUND);
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(NETWORK_ID_NOT_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Updates tenantNetwork failed because of exception {}.",
- e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @DELETE
- @Path("{id}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response deleteNetworks(@PathParam("id") String id) {
- log.debug("Deletes network by identifier {}.", id);
- Set<TenantNetworkId> networkSet = new HashSet<>();
- networkSet.add(TenantNetworkId.networkId(id));
- Boolean issuccess = nullIsNotFound(get(TenantNetworkService.class)
- .removeNetworks(networkSet), NETWORK_NOT_FOUND);
- if (!issuccess) {
- log.debug("Network identifier {} is not existed", id);
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(NETWORK_ID_NOT_EXIST).build();
- }
- return ok(issuccess.toString()).build();
- }
-
- /**
- * Returns a collection of tenantNetworks.
- *
- * @param flag the flag
- * @param networkId network identifier
- * @param node the network json node
- * @return a collection of tenantNetworks
- */
- public Iterable<TenantNetwork> changeJson2obj(String flag,
- TenantNetworkId networkId,
- JsonNode node) {
- checkNotNull(node, JSON_NOT_NULL);
- TenantNetwork network = null;
- ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
- .newConcurrentMap();
- checkArgument(node.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");
- checkArgument(node.get("shared").isBoolean(), "shared should be boolean");
- checkArgument(node.get("router:external").isBoolean(), "router:external should be boolean");
- String name = node.get("name").asText();
- boolean adminStateUp = node.get("admin_state_up").asBoolean();
- String state = node.get("status").asText();
- boolean shared = node.get("shared").asBoolean();
- String tenantIdStr = node.get("tenant_id").asText();
- boolean routerExternal = node.get("router:external").asBoolean();
- String type = node.get("provider:network_type").asText();
- String physicalNetwork = node.get("provider:physical_network").asText();
- String segmentationIdStr = node.get("provider:segmentation_id").asText();
- SegmentationId segmentationId = SegmentationId.segmentationId(segmentationIdStr);
- TenantId tenantId = TenantId.tenantId(tenantIdStr);
- if (segmentationIdStr == null || "null".equals(segmentationIdStr)) {
- segmentationId = get(VtnRscService.class).getL3vni(tenantId);
- }
- TenantNetworkId id = null;
- if (flag.equals(CREATE_NETWORK)) {
- id = TenantNetworkId.networkId(node.get("id").asText());
- } else if (flag.equals(UPDATE_NETWORK)) {
- id = networkId;
- }
- network = new DefaultTenantNetwork(
- id,
- name,
- adminStateUp,
- isState(state),
- shared,
- tenantId,
- routerExternal,
- isType(type),
- PhysicalNetwork
- .physicalNetwork(physicalNetwork),
- segmentationId);
- networksMap.putIfAbsent(id, network);
-
- return Collections.unmodifiableCollection(networksMap.values());
- }
-
- /**
- * Returns a collection of tenantNetworks.
- *
- * @param nodes the network jsonnodes
- * @return a collection of tenantNetworks
- */
- public Iterable<TenantNetwork> changeJson2objs(JsonNode nodes) {
- checkNotNull(nodes, JSON_NOT_NULL);
- TenantNetwork network = null;
- ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
- .newConcurrentMap();
- for (JsonNode node : nodes) {
- String id = node.get("id").asText();
- String name = node.get("name").asText();
- boolean adminStateUp = node.get("admin_state_up").asBoolean();
- String state = node.get("status").asText();
- boolean shared = node.get("shared").asBoolean();
- String tenantIdStr = node.get("tenant_id").asText();
- boolean routerExternal = node.get("router:external")
- .asBoolean();
- String type = node.get("provider:network_type").asText();
- String physicalNetwork = node.get("provider:physical_network").asText();
- String segmentationIdStr = node.get("provider:segmentation_id").asText();
- SegmentationId segmentationId = SegmentationId.segmentationId(segmentationIdStr);
- TenantId tenantId = TenantId.tenantId(tenantIdStr);
- if (segmentationIdStr == null || "null".equals(segmentationIdStr)) {
- segmentationId = get(VtnRscService.class).getL3vni(tenantId);
- }
- network = new DefaultTenantNetwork(
- TenantNetworkId.networkId(id),
- name,
- adminStateUp,
- isState(state),
- shared,
- tenantId,
- routerExternal,
- isType(type),
- PhysicalNetwork.physicalNetwork(physicalNetwork),
- segmentationId);
- networksMap.putIfAbsent(TenantNetworkId.networkId(id), network);
- }
-
- return Collections.unmodifiableCollection(networksMap.values());
- }
-
- /**
- * Returns the specified item if that items is null; otherwise throws not
- * found exception.
- *
- * @param item item to check
- * @param <T> item type
- * @param message not found message
- * @return item if not null
- * @throws org.onlab.util.ItemNotFoundException if item is null
- */
- protected <T> T nullIsNotFound(T item, String message) {
- if (item == null) {
- throw new ItemNotFoundException(message);
- }
- return item;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java
deleted file mode 100644
index 014b563..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.util.ItemNotFoundException;
-import org.onosproject.net.DeviceId;
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.DefaultVirtualPort;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.SecurityGroup;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPort.State;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.onosproject.vtnweb.web.VirtualPortCodec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
-import static javax.ws.rs.core.Response.Status.NOT_FOUND;
-import static javax.ws.rs.core.Response.Status.OK;
-import static org.onlab.util.Tools.readTreeFromStream;
-
-/**
- * REST resource for interacting with the inventory of infrastructure
- * virtualPort.
- */
-@Path("ports")
-public class VirtualPortWebResource extends AbstractWebResource {
- public static final String VPORT_NOT_FOUND = "VirtualPort is not found";
- public static final String VPORT_ID_EXIST = "VirtualPort id is exist";
- public static final String VPORT_ID_NOT_EXIST = "VirtualPort id is not exist";
- public static final String JSON_NOT_NULL = "JsonNode can not be null";
- private static final Logger log = LoggerFactory
- .getLogger(VirtualPortService.class);
-
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getPorts() {
- Iterable<VirtualPort> virtualPorts = get(VirtualPortService.class)
- .getPorts();
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("ports", new VirtualPortCodec().encode(virtualPorts, this));
- return ok(result.toString()).build();
- }
-
- @GET
- @Path("{id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response getportsById(@PathParam("id") String id) {
-
- if (!get(VirtualPortService.class).exists(VirtualPortId.portId(id))) {
- return Response.status(NOT_FOUND)
- .entity(VPORT_NOT_FOUND).build();
- }
- VirtualPort virtualPort = nullIsNotFound(get(VirtualPortService.class)
- .getPort(VirtualPortId.portId(id)), VPORT_NOT_FOUND);
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("port", new VirtualPortCodec().encode(virtualPort, this));
- return ok(result.toString()).build();
- }
-
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response createPorts(InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode cfg = readTreeFromStream(mapper, input);
- Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);
- Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
- .createPorts(vPorts), VPORT_NOT_FOUND);
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(VPORT_ID_NOT_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Creates VirtualPort failed because of exception {}",
- e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @DELETE
- @Path("{portUUID}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response deletePorts(@PathParam("portUUID") String id) {
- Set<VirtualPortId> vPortIds = new HashSet<>();
- try {
- if (id != null) {
- vPortIds.add(VirtualPortId.portId(id));
- }
- Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
- .removePorts(vPortIds), VPORT_NOT_FOUND);
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(VPORT_ID_NOT_EXIST).build();
- }
- return ok(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Deletes VirtualPort failed because of exception {}",
- e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @PUT
- @Path("{id}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response updatePorts(@PathParam("id") String id, InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode cfg = readTreeFromStream(mapper, input);
- Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);
- Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
- .updatePorts(vPorts), VPORT_NOT_FOUND);
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(VPORT_ID_NOT_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Updates failed because of exception {}", e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- /**
- * Returns a Object of the currently known infrastructure virtualPort.
- *
- * @param vPortNode the virtualPort json node
- * @return a collection of virtualPorts
- */
- public Iterable<VirtualPort> createOrUpdateByInputStream(JsonNode vPortNode) {
- checkNotNull(vPortNode, JSON_NOT_NULL);
- JsonNode vPortNodes = vPortNode.get("ports");
- if (vPortNodes == null) {
- vPortNodes = vPortNode.get("port");
- }
- if (vPortNodes.isArray()) {
- return changeJsonToPorts(vPortNodes);
- } else {
- return changeJsonToPort(vPortNodes);
- }
- }
-
- /**
- * Returns the iterable collection of virtualports from subnetNodes.
- *
- * @param vPortNodes the virtualPort json node
- * @return virtualPorts a collection of virtualPorts
- */
- public Iterable<VirtualPort> changeJsonToPorts(JsonNode vPortNodes) {
- checkNotNull(vPortNodes, JSON_NOT_NULL);
- Map<VirtualPortId, VirtualPort> portMap = new HashMap<>();
- Map<String, String> strMap = new HashMap<>();
- for (JsonNode vPortnode : vPortNodes) {
- VirtualPortId id = VirtualPortId.portId(vPortnode.get("id")
- .asText());
- String name = vPortnode.get("name").asText();
- TenantId tenantId = TenantId.tenantId(vPortnode.get("tenant_id")
- .asText());
- TenantNetworkId networkId = TenantNetworkId.networkId(vPortnode
- .get("network_id").asText());
- checkArgument(vPortnode.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");
- Boolean adminStateUp = vPortnode.get("admin_state_up").asBoolean();
- String state = vPortnode.get("status").asText();
- MacAddress macAddress = MacAddress.valueOf(vPortnode
- .get("mac_address").asText());
- DeviceId deviceId = DeviceId.deviceId(vPortnode.get("device_id")
- .asText());
- String deviceOwner = vPortnode.get("device_owner").asText();
- JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
- Set<FixedIp> fixedIps = new HashSet<>();
- for (JsonNode fixedIpNode : fixedIpNodes) {
- FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
- fixedIps.add(fixedIp);
- }
-
- BindingHostId bindingHostId = BindingHostId
- .bindingHostId(vPortnode.get("binding:host_id").asText());
- String bindingVnicType = vPortnode.get("binding:vnic_type")
- .asText();
- String bindingVifType = vPortnode.get("binding:vif_type").asText();
- String bindingVifDetails = vPortnode.get("binding:vif_details")
- .asText();
- JsonNode allowedAddressPairJsonNode = vPortnode
- .get("allowed_address_pairs");
- Collection<AllowedAddressPair> allowedAddressPairs =
- jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);
- JsonNode securityGroupNode = vPortnode.get("security_groups");
- Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);
- strMap.put("name", name);
- strMap.put("deviceOwner", deviceOwner);
- strMap.put("bindingVnicType", bindingVnicType);
- strMap.put("bindingVifType", bindingVifType);
- strMap.put("bindingVifDetails", bindingVifDetails);
- VirtualPort vPort = new DefaultVirtualPort(id, networkId,
- adminStateUp, strMap,
- isState(state),
- macAddress, tenantId,
- deviceId, fixedIps,
- bindingHostId,
- Sets.newHashSet(allowedAddressPairs),
- Sets.newHashSet(securityGroups));
- portMap.put(id, vPort);
- }
- return Collections.unmodifiableCollection(portMap.values());
- }
-
- /**
- * Returns a collection of virtualPorts from subnetNodes.
- *
- * @param vPortNodes the virtualPort json node
- * @return virtualPorts a collection of virtualPorts
- */
- public Iterable<VirtualPort> changeJsonToPort(JsonNode vPortNodes) {
- checkNotNull(vPortNodes, JSON_NOT_NULL);
- Map<VirtualPortId, VirtualPort> vportMap = new HashMap<>();
- Map<String, String> strMap = new HashMap<>();
- VirtualPortId id = VirtualPortId.portId(vPortNodes.get("id").asText());
- String name = vPortNodes.get("name").asText();
- TenantId tenantId = TenantId.tenantId(vPortNodes.get("tenant_id")
- .asText());
- TenantNetworkId networkId = TenantNetworkId.networkId(vPortNodes
- .get("network_id").asText());
- Boolean adminStateUp = vPortNodes.get("admin_state_up").asBoolean();
- String state = vPortNodes.get("status").asText();
- MacAddress macAddress = MacAddress.valueOf(vPortNodes
- .get("mac_address").asText());
- DeviceId deviceId = DeviceId.deviceId(vPortNodes.get("device_id")
- .asText());
- String deviceOwner = vPortNodes.get("device_owner").asText();
- JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
- Set<FixedIp> fixedIps = new HashSet<>();
- for (JsonNode fixedIpNode : fixedIpNodes) {
- FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
- fixedIps.add(fixedIp);
- }
-
- BindingHostId bindingHostId = BindingHostId
- .bindingHostId(vPortNodes.get("binding:host_id").asText());
- String bindingVnicType = vPortNodes.get("binding:vnic_type").asText();
- String bindingVifType = vPortNodes.get("binding:vif_type").asText();
- String bindingVifDetails = vPortNodes.get("binding:vif_details")
- .asText();
- JsonNode allowedAddressPairJsonNode = vPortNodes
- .get("allowed_address_pairs");
- Collection<AllowedAddressPair> allowedAddressPairs =
- jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);
- JsonNode securityGroupNode = vPortNodes.get("security_groups");
- Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);
- strMap.put("name", name);
- strMap.put("deviceOwner", deviceOwner);
- strMap.put("bindingVnicType", bindingVnicType);
- strMap.put("bindingVifType", bindingVifType);
- strMap.put("bindingVifDetails", bindingVifDetails);
- VirtualPort vPort = new DefaultVirtualPort(id, networkId, adminStateUp,
- strMap, isState(state),
- macAddress, tenantId,
- deviceId, fixedIps,
- bindingHostId,
- Sets.newHashSet(allowedAddressPairs),
- Sets.newHashSet(securityGroups));
- vportMap.put(id, vPort);
-
- return Collections.unmodifiableCollection(vportMap.values());
- }
-
- /**
- * Returns a Object of the currently known infrastructure virtualPort.
- *
- * @param allowedAddressPairs the allowedAddressPairs json node
- * @return a collection of allowedAddressPair
- */
- public Collection<AllowedAddressPair> jsonNodeToAllowedAddressPair(JsonNode allowedAddressPairs) {
- checkNotNull(allowedAddressPairs, JSON_NOT_NULL);
- ConcurrentMap<Integer, AllowedAddressPair> allowMaps = Maps
- .newConcurrentMap();
- int i = 0;
- for (JsonNode node : allowedAddressPairs) {
- IpAddress ip = IpAddress.valueOf(node.get("ip_address").asText());
- MacAddress mac = MacAddress.valueOf(node.get("mac_address")
- .asText());
- AllowedAddressPair allows = AllowedAddressPair
- .allowedAddressPair(ip, mac);
- allowMaps.put(i, allows);
- i++;
- }
- log.debug("The jsonNode of allowedAddressPairallow is {}"
- + allowedAddressPairs.toString());
- return Collections.unmodifiableCollection(allowMaps.values());
- }
-
- /**
- * Returns a collection of virtualPorts.
- *
- * @param securityGroups the virtualPort jsonnode
- * @return a collection of securityGroups
- */
- public Collection<SecurityGroup> jsonNodeToSecurityGroup(JsonNode securityGroups) {
- checkNotNull(securityGroups, JSON_NOT_NULL);
- ConcurrentMap<Integer, SecurityGroup> securMaps = Maps
- .newConcurrentMap();
- int i = 0;
- for (JsonNode node : securityGroups) {
- SecurityGroup securityGroup = SecurityGroup
- .securityGroup(node.asText());
- securMaps.put(i, securityGroup);
- i++;
- }
- return Collections.unmodifiableCollection(securMaps.values());
- }
-
- /**
- * Returns a collection of fixedIps.
- *
- * @param fixedIpNode the fixedIp jsonnode
- * @return a collection of SecurityGroup
- */
- public FixedIp jsonNodeToFixedIps(JsonNode fixedIpNode) {
- SubnetId subnetId = SubnetId.subnetId(fixedIpNode.get("subnet_id")
- .asText());
- IpAddress ipAddress = IpAddress.valueOf(fixedIpNode.get("ip_address")
- .asText());
- FixedIp fixedIps = FixedIp.fixedIp(subnetId, ipAddress);
- return fixedIps;
- }
-
- /**
- * Returns VirtualPort State.
- *
- * @param state the virtualport state
- * @return the virtualPort state
- */
- private State isState(String state) {
- if ("ACTIVE".equals(state)) {
- return VirtualPort.State.ACTIVE;
- } else {
- return VirtualPort.State.DOWN;
- }
-
- }
-
- /**
- * Returns the specified item if that items is null; otherwise throws not
- * found exception.
- *
- * @param item item to check
- * @param <T> item type
- * @param message not found message
- * @return item if not null
- * @throws org.onlab.util.ItemNotFoundException if item is null
- */
- protected <T> T nullIsNotFound(T item, String message) {
- if (item == null) {
- throw new ItemNotFoundException(message);
- }
- return item;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VtnWebApplication.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VtnWebApplication.java
deleted file mode 100644
index 64d5060..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VtnWebApplication.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.vtnweb.resources;
-
-import org.onlab.rest.AbstractWebApplication;
-
-import java.util.Set;
-
-/**
- * VTN REST API web application.
- */
-public class VtnWebApplication extends AbstractWebApplication {
- @Override
- public Set<Class<?>> getClasses() {
- return getClasses(TenantNetworkWebResource.class,
- SubnetWebResource.class,
- VirtualPortWebResource.class,
- FlowClassifierWebResource.class,
- PortChainWebResource.class,
- PortPairGroupWebResource.class,
- PortPairWebResource.class,
- FloatingIpWebResource.class,
- RouterWebResource.class,
- ClassifierWebResource.class,
- PortChainSfMapWebResource.class,
- PortChainDeviceMapWebResource.class);
- }
-}
-
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/package-info.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/package-info.java
deleted file mode 100644
index 473ba7e..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN web that used rest to creat vtn resources.
- */
-package org.onosproject.vtnweb.resources;
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllocationPoolsCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllocationPoolsCodec.java
deleted file mode 100644
index e0e1b3f..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllocationPoolsCodec.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.AllocationPool;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Subnet AllocationPool codec.
- */
-public final class AllocationPoolsCodec extends JsonCodec<AllocationPool> {
-
- @Override
- public ObjectNode encode(AllocationPool alocPool, CodecContext context) {
- checkNotNull(alocPool, "AllocationPools cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("start", alocPool.startIp().toString())
- .put("end", alocPool.endIp().toString());
- return result;
- }
-
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllowedAddressPairCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllowedAddressPairCodec.java
deleted file mode 100644
index a6a12be..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/AllowedAddressPairCodec.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * VirtualPort AllowedAddressPair codec.
- */
-public final class AllowedAddressPairCodec extends JsonCodec<AllowedAddressPair> {
-
- @Override
- public ObjectNode encode(AllowedAddressPair alocAddPair, CodecContext context) {
- checkNotNull(alocAddPair, "AllowedAddressPair cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("ip_address", alocAddPair.ip().toString())
- .put("mac_address", alocAddPair.mac().toString());
- return result;
- }
-
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FixedIpCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FixedIpCodec.java
deleted file mode 100644
index cdfdb42..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FixedIpCodec.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.FixedIp;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * VirtualPort FixedIp codec.
- */
-public final class FixedIpCodec extends JsonCodec<FixedIp> {
-
- @Override
- public ObjectNode encode(FixedIp fixIp, CodecContext context) {
- checkNotNull(fixIp, "FixedIp cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("subnet_id", fixIp.subnetId().toString())
- .put("ip_address", fixIp.ip().toString());
- return result;
- }
-
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FloatingIpCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FloatingIpCodec.java
deleted file mode 100644
index 804f424..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FloatingIpCodec.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.FloatingIp;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * FloatingIp JSON codec.
- */
-public final class FloatingIpCodec extends JsonCodec<FloatingIp> {
- @Override
- public ObjectNode encode(FloatingIp floatingIp, CodecContext context) {
- checkNotNull(floatingIp, "floatingIp cannot be null");
- ObjectNode result = context
- .mapper()
- .createObjectNode()
- .put("id", floatingIp.id().floatingIpId().toString())
- .put("floating_network_id", floatingIp.networkId().toString())
- .put("router_id",
- floatingIp.routerId() == null ? null : floatingIp
- .routerId().routerId())
- .put("tenant_id", floatingIp.tenantId().toString())
- .put("port_id",
- floatingIp.portId() == null ? null : floatingIp.portId()
- .toString())
- .put("fixed_ip_address",
- floatingIp.fixedIp() == null ? null : floatingIp.fixedIp()
- .toString())
- .put("floating_ip_address", floatingIp.floatingIp().toString())
- .put("status", floatingIp.status().toString());
- return result;
- }
-
- public ObjectNode extracFields(FloatingIp floatingIp, CodecContext context,
- List<String> fields) {
- checkNotNull(floatingIp, "floatingIp cannot be null");
- ObjectNode result = context.mapper().createObjectNode();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if ("floating_network_id".equals(s)) {
- result.put("floating_network_id", floatingIp.networkId()
- .toString());
- }
- if ("router_id".equals(s)) {
- result.put("router_id",
- floatingIp.routerId() == null ? null : floatingIp
- .routerId().routerId());
- }
- if ("tenant_id".equals(s)) {
- result.put("tenant_id", floatingIp.tenantId().toString());
- }
- if ("port_id".equals(s)) {
- result.put("port_id",
- floatingIp.portId() == null ? null : floatingIp
- .portId().toString());
- }
- if ("id".equals(s)) {
- result.put("id", floatingIp.id().floatingIpId().toString());
- }
- if ("fixed_ip_address".equals(s)) {
- result.put("fixed_ip_address",
- floatingIp.fixedIp() == null ? null : floatingIp
- .fixedIp().toString());
- }
- if ("floating_ip_address".equals(s)) {
- result.put("floating_ip_address", floatingIp.floatingIp()
- .toString());
- }
- if ("status".equals(s)) {
- result.put("status", floatingIp.status().toString());
- }
- }
- return result;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java
deleted file mode 100644
index 491904a..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onlab.util.Tools.nullIsIllegal;
-
-import org.onlab.packet.IpPrefix;
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.DefaultFlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.VirtualPortId;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Flow Classifier JSON codec.
- */
-public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> {
-
- private static final String FLOW_CLASSIFIER_ID = "id";
- private static final String TENANT_ID = "tenant_id";
- private static final String NAME = "name";
- private static final String DESCRIPTION = "description";
- private static final String ETHER_TYPE = "ethertype";
- private static final String PROTOCOL = "protocol";
- private static final String PRIORITY = "priority";
- private static final String MIN_SRC_PORT_RANGE = "source_port_range_min";
- private static final String MAX_SRC_PORT_RANGE = "source_port_range_max";
- private static final String MIN_DST_PORT_RANGE = "destination_port_range_min";
- private static final String MAX_DST_PORT_RANGE = "destination_port_range_max";
- private static final String SRC_IP_PREFIX = "source_ip_prefix";
- private static final String DST_IP_PREFIX = "destination_ip_prefix";
- private static final String SRC_PORT = "logical_source_port";
- private static final String DST_PORT = "logical_destination_port";
- private static final String MISSING_MEMBER_MESSAGE = " member is required in Flow Classifier.";
-
- @Override
- public FlowClassifier decode(ObjectNode json, CodecContext context) {
- if (json == null || !json.isObject()) {
- return null;
- }
-
- FlowClassifier.Builder resultBuilder = new DefaultFlowClassifier.Builder();
-
- String flowClassifierId = nullIsIllegal(json.get(FLOW_CLASSIFIER_ID),
- FLOW_CLASSIFIER_ID + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setFlowClassifierId(FlowClassifierId.of(flowClassifierId));
-
- String tenantId = nullIsIllegal(json.get(TENANT_ID), TENANT_ID + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setTenantId(TenantId.tenantId(tenantId));
-
- String flowClassiferName = nullIsIllegal(json.get(NAME), NAME + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setName(flowClassiferName);
-
- String flowClassiferDescription = (json.get(DESCRIPTION)).asText();
- resultBuilder.setDescription(flowClassiferDescription);
-
- String etherType = nullIsIllegal(json.get(ETHER_TYPE), ETHER_TYPE + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setEtherType(etherType);
-
- if (json.get(PROTOCOL) != null && !"null".equals((json.get(PROTOCOL)).asText())) {
- String protocol = (json.get(PROTOCOL)).asText();
- resultBuilder.setProtocol(protocol);
- }
-
- if (json.get(PRIORITY) != null && !"null".equals((json.get(PRIORITY)).asText())) {
- int priority = (json.get(PRIORITY)).asInt();
- resultBuilder.setPriority(priority);
- }
-
- int minSrcPortRange = (json.get(MIN_SRC_PORT_RANGE)).asInt();
- resultBuilder.setMinSrcPortRange(minSrcPortRange);
-
- int maxSrcPortRange = (json.get(MAX_SRC_PORT_RANGE)).asInt();
- resultBuilder.setMaxSrcPortRange(maxSrcPortRange);
-
- int minDstPortRange = (json.get(MIN_DST_PORT_RANGE)).asInt();
- resultBuilder.setMinDstPortRange(minDstPortRange);
-
- int maxDstPortRange = (json.get(MAX_DST_PORT_RANGE)).asInt();
- resultBuilder.setMaxDstPortRange(maxDstPortRange);
-
- if (json.get(SRC_IP_PREFIX) != null && !"null".equals((json.get(SRC_IP_PREFIX)).asText())) {
- String srcIpPrefix = (json.get(SRC_IP_PREFIX)).asText();
- resultBuilder.setSrcIpPrefix(IpPrefix.valueOf(srcIpPrefix));
- }
-
- if (json.get(DST_IP_PREFIX) != null && !"null".equals((json.get(DST_IP_PREFIX)).asText())) {
- String dstIpPrefix = (json.get(DST_IP_PREFIX)).asText();
- resultBuilder.setDstIpPrefix(IpPrefix.valueOf(dstIpPrefix));
- }
-
- if (json.get(SRC_PORT) != null && !"null".equals((json.get(SRC_PORT)).asText())) {
- String srcPort = (json.get(SRC_PORT)).asText();
- resultBuilder.setSrcPort(VirtualPortId.portId(srcPort));
- }
-
- if (json.get(DST_PORT) != null && !"null".equals((json.get(DST_PORT)).asText())) {
- String dstPort = (json.get(DST_PORT)).asText();
- resultBuilder.setDstPort(VirtualPortId.portId(dstPort));
- }
- return resultBuilder.build();
- }
-
- @Override
- public ObjectNode encode(FlowClassifier flowClassifier, CodecContext context) {
- checkNotNull(flowClassifier, "flowClassifier cannot be null");
- ObjectNode result = context.mapper().createObjectNode();
- result.put(FLOW_CLASSIFIER_ID, flowClassifier.flowClassifierId().toString())
- .put(TENANT_ID, flowClassifier.tenantId().toString())
- .put(NAME, flowClassifier.name())
- .put(DESCRIPTION, flowClassifier.description())
- .put(ETHER_TYPE, flowClassifier.etherType())
- .put(PROTOCOL, flowClassifier.protocol())
- .put(PRIORITY, flowClassifier.priority())
- .put(MIN_SRC_PORT_RANGE, flowClassifier.minSrcPortRange())
- .put(MAX_SRC_PORT_RANGE, flowClassifier.maxSrcPortRange())
- .put(MIN_DST_PORT_RANGE, flowClassifier.minDstPortRange())
- .put(MAX_DST_PORT_RANGE, flowClassifier.maxDstPortRange());
-
- if (flowClassifier.srcIpPrefix() != null) {
- result.put(SRC_IP_PREFIX, flowClassifier.srcIpPrefix().toString());
- } else {
- result.put(SRC_IP_PREFIX, "null");
- }
- if (flowClassifier.dstIpPrefix() != null) {
- result.put(DST_IP_PREFIX, flowClassifier.dstIpPrefix().toString());
- } else {
- result.put(DST_IP_PREFIX, "null");
- }
-
- if (flowClassifier.srcPort() != null) {
- result.put(SRC_PORT, flowClassifier.srcPort().toString());
- } else {
- result.put(SRC_PORT, "null");
- }
- if (flowClassifier.dstPort() != null) {
- result.put(DST_PORT, flowClassifier.dstPort().toString());
- } else {
- result.put(DST_PORT, "null");
- }
- return result;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/HostRoutesCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/HostRoutesCodec.java
deleted file mode 100644
index 8a0a9a1..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/HostRoutesCodec.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.HostRoute;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Subnet HostRoute codec.
- */
-public final class HostRoutesCodec extends JsonCodec<HostRoute> {
-
- @Override
- public ObjectNode encode(HostRoute hostRoute, CodecContext context) {
- checkNotNull(hostRoute, "HostRoute cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("nexthop", hostRoute.nexthop().toString())
- .put("destination", hostRoute.destination().toString());
- return result;
- }
-
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortChainCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortChainCodec.java
deleted file mode 100644
index 8478a76..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortChainCodec.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onlab.util.Tools.nullIsIllegal;
-
-import java.util.List;
-import java.util.UUID;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.DefaultPortChain;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.PortPairGroupId;
-
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Lists;
-
-/**
- * Port chain JSON codec.
- */
-public final class PortChainCodec extends JsonCodec<PortChain> {
-
- private static final String ID = "id";
- private static final String TENANT_ID = "tenant_id";
- private static final String NAME = "name";
- private static final String DESCRIPTION = "description";
- private static final String PORT_PAIR_GROUPS = "port_pair_groups";
- private static final String FLOW_CLASSIFIERS = "flow_classifiers";
- private static final String MISSING_MEMBER_MESSAGE =
- " member is required in PortChain";
-
- @Override
- public PortChain decode(ObjectNode json, CodecContext context) {
- if (json == null || !json.isObject()) {
- return null;
- }
-
- PortChain.Builder resultBuilder = new DefaultPortChain.Builder();
-
- String id = nullIsIllegal(json.get(ID),
- ID + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setId(PortChainId.of(id));
-
- String tenantId = nullIsIllegal(json.get(TENANT_ID),
- TENANT_ID + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setTenantId(TenantId.tenantId(tenantId));
-
- String name = nullIsIllegal(json.get(NAME),
- NAME + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setName(name);
-
- String description = nullIsIllegal(json.get(DESCRIPTION),
- DESCRIPTION + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setDescription(description);
-
- ArrayNode arrayNode = (ArrayNode) json.path(PORT_PAIR_GROUPS);
- if (arrayNode != null) {
- List<PortPairGroupId> list = Lists.newArrayList();
- arrayNode.forEach(i -> list.add(PortPairGroupId.of(i.asText())));
- resultBuilder.setPortPairGroups(list);
- }
-
- arrayNode = (ArrayNode) json.path(FLOW_CLASSIFIERS);
- if (arrayNode != null) {
- List<FlowClassifierId> list = Lists.newArrayList();
- arrayNode.forEach(i -> list.add(FlowClassifierId.of(UUID.fromString(i.asText()))));
- resultBuilder.setFlowClassifiers(list);
- }
-
- return resultBuilder.build();
- }
-
- @Override
- public ObjectNode encode(PortChain portChain, CodecContext context) {
- checkNotNull(portChain, "port pair cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put(ID, portChain.portChainId().toString())
- .put(TENANT_ID, portChain.tenantId().toString())
- .put(NAME, portChain.name())
- .put(DESCRIPTION, portChain.description())
- .put(PORT_PAIR_GROUPS, portChain.portPairGroups().toString())
- .put(FLOW_CLASSIFIERS, portChain.flowClassifiers().toString());
- return result;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairCodec.java
deleted file mode 100644
index 2b63bfe..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairCodec.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onlab.util.Tools.nullIsIllegal;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.core.CoreService;
-import org.onosproject.vtnrsc.DefaultPortPair;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Port Pair JSON codec.
- */
-public final class PortPairCodec extends JsonCodec<PortPair> {
-
- private static final String ID = "id";
- private static final String TENANT_ID = "tenant_id";
- private static final String NAME = "name";
- private static final String DESCRIPTION = "description";
- private static final String INGRESS = "ingress";
- private static final String EGRESS = "egress";
- private static final String MISSING_MEMBER_MESSAGE =
- " member is required in PortPair";
-
- @Override
- public PortPair decode(ObjectNode json, CodecContext context) {
- if (json == null || !json.isObject()) {
- return null;
- }
-
- PortPair.Builder resultBuilder = new DefaultPortPair.Builder();
-
- CoreService coreService = context.getService(CoreService.class);
-
- String id = nullIsIllegal(json.get(ID),
- ID + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setId(PortPairId.of(id));
-
- String tenantId = nullIsIllegal(json.get(TENANT_ID),
- TENANT_ID + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setTenantId(TenantId.tenantId(tenantId));
-
- String name = nullIsIllegal(json.get(NAME),
- NAME + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setName(name);
-
- String description = nullIsIllegal(json.get(DESCRIPTION),
- DESCRIPTION + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setDescription(description);
-
- String ingressPort = nullIsIllegal(json.get(INGRESS),
- INGRESS + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setIngress(ingressPort);
-
- String egressPort = nullIsIllegal(json.get(EGRESS),
- EGRESS + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setEgress(egressPort);
-
- return resultBuilder.build();
- }
-
- @Override
- public ObjectNode encode(PortPair portPair, CodecContext context) {
- checkNotNull(portPair, "port pair cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put(ID, portPair.portPairId().toString())
- .put(TENANT_ID, portPair.tenantId().toString())
- .put(NAME, portPair.name())
- .put(DESCRIPTION, portPair.description())
- .put(INGRESS, portPair.ingress())
- .put(EGRESS, portPair.egress());
- return result;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairGroupCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairGroupCodec.java
deleted file mode 100644
index 76c5d43..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairGroupCodec.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.vtnweb.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onlab.util.Tools.nullIsIllegal;
-
-import java.util.List;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.core.CoreService;
-import org.onosproject.vtnrsc.DefaultPortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Lists;
-
-/**
- * Port Pair Group JSON codec.
- */
-public final class PortPairGroupCodec extends JsonCodec<PortPairGroup> {
-
- private static final String ID = "id";
- private static final String TENANT_ID = "tenant_id";
- private static final String NAME = "name";
- private static final String DESCRIPTION = "description";
- private static final String PORT_PAIRS = "port_pairs";
- private static final String MISSING_MEMBER_MESSAGE =
- " member is required in PortPairGroup";
-
- @Override
- public PortPairGroup decode(ObjectNode json, CodecContext context) {
- if (json == null || !json.isObject()) {
- return null;
- }
-
- PortPairGroup.Builder resultBuilder = new DefaultPortPairGroup.Builder();
-
- CoreService coreService = context.getService(CoreService.class);
-
- String id = nullIsIllegal(json.get(ID),
- ID + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setId(PortPairGroupId.of(id));
-
- String tenantId = nullIsIllegal(json.get(TENANT_ID),
- TENANT_ID + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setTenantId(TenantId.tenantId(tenantId));
-
- String name = nullIsIllegal(json.get(NAME),
- NAME + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setName(name);
-
- String description = nullIsIllegal(json.get(DESCRIPTION),
- DESCRIPTION + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setDescription(description);
-
- List<PortPairId> list = Lists.newArrayList();
- ArrayNode arrayNode = (ArrayNode) json.path(PORT_PAIRS);
- arrayNode.forEach(i -> list.add(PortPairId.of(i.asText())));
- resultBuilder.setPortPairs(list);
-
- return resultBuilder.build();
- }
-
- @Override
- public ObjectNode encode(PortPairGroup portPairGroup, CodecContext context) {
- checkNotNull(portPairGroup, "port pair group cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put(ID, portPairGroup.portPairGroupId().toString())
- .put(TENANT_ID, portPairGroup.tenantId().toString())
- .put(NAME, portPairGroup.name())
- .put(DESCRIPTION, portPairGroup.description())
- .put(PORT_PAIRS, portPairGroup.portPairs().toString());
- return result;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterCodec.java
deleted file mode 100644
index 1b650ad..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterCodec.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.Router;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Router JSON codec.
- */
-public class RouterCodec extends JsonCodec<Router> {
- @Override
- public ObjectNode encode(Router router, CodecContext context) {
- checkNotNull(router, "router cannot be null");
- ObjectNode result = context
- .mapper()
- .createObjectNode()
- .put("id", router.id().routerId())
- .put("status", router.status().toString())
- .put("name", router.name().toString())
- .put("admin_state_up", router.adminStateUp())
- .put("tenant_id", router.tenantId().toString())
- .put("routes",
- router.routes() == null ? null : router.routes()
- .toString());
- result.set("external_gateway_info",
- router.externalGatewayInfo() == null ? null
- : new RouterGatewayInfoCodec()
- .encode(router.externalGatewayInfo(), context));
-
- return result;
- }
-
- public ObjectNode extracFields(Router router, CodecContext context,
- List<String> fields) {
- checkNotNull(router, "router cannot be null");
- ObjectNode result = context.mapper().createObjectNode();
- Iterator<String> i = fields.iterator();
- while (i.hasNext()) {
- String s = i.next();
- if ("id".equals(s)) {
- result.put("id", router.id().routerId());
- }
- if ("status".equals(s)) {
- result.put("status", router.status().toString());
- }
- if ("name".equals(s)) {
- result.put("name", router.name().toString());
- }
- if ("admin_state_up".equals(s)) {
- result.put("admin_state_up", router.adminStateUp());
- }
- if ("tenant_id".equals(s)) {
- result.put("tenant_id", router.tenantId().toString());
- }
- if ("routes".equals(s)) {
- result.put("routes", router.routes() == null ? null : router
- .routes().toString());
- }
- if ("external_gateway_info".equals(s)) {
- result.set("external_gateway_info",
- router.externalGatewayInfo() == null ? null
- : new RouterGatewayInfoCodec()
- .encode(router.externalGatewayInfo(),
- context));
- }
- }
- return result;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterGatewayInfoCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterGatewayInfoCodec.java
deleted file mode 100644
index 260c873..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/RouterGatewayInfoCodec.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.RouterGateway;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Subnet Router Gateway Info codec.
- */
-public class RouterGatewayInfoCodec extends JsonCodec<RouterGateway> {
- @Override
- public ObjectNode encode(RouterGateway routerGateway, CodecContext context) {
- checkNotNull(routerGateway, "routerGateway cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("network_id", routerGateway.networkId().toString());
- result.set("external_fixed_ips", new FixedIpCodec()
- .encode(routerGateway.externalFixedIps(), context));
- return result;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SecurityGroupCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SecurityGroupCodec.java
deleted file mode 100644
index 6089e3f..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SecurityGroupCodec.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.SecurityGroup;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Virtualport SecurityGroup codec.
- */
-public final class SecurityGroupCodec extends JsonCodec<SecurityGroup> {
-
- @Override
- public ObjectNode encode(SecurityGroup securGroup, CodecContext context) {
- checkNotNull(securGroup, "SecurityGroup cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("security_group", securGroup.securityGroup());
- return result;
- }
-
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/ServiceFunctionCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/ServiceFunctionCodec.java
deleted file mode 100644
index 394c6b4..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/ServiceFunctionCodec.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.ServiceFunctionGroup;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Service function JSON codec.
- */
-public final class ServiceFunctionCodec extends JsonCodec<ServiceFunctionGroup> {
-
- private static final String NAME = "name";
- private static final String DESCRIPTION = "description";
- private static final String PORT_PAIR_LOAD = "port_pair_load";
- @Override
- public ObjectNode encode(ServiceFunctionGroup serviceFunction, CodecContext context) {
- checkNotNull(serviceFunction, "service cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put(NAME, serviceFunction.name())
- .put(DESCRIPTION, serviceFunction.description())
- .put(PORT_PAIR_LOAD, serviceFunction.portPairLoadMap().toString());
- return result;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SubnetCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SubnetCodec.java
deleted file mode 100644
index a97ab8b..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/SubnetCodec.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.Subnet;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Subnet JSON codec.
- */
-public final class SubnetCodec extends JsonCodec<Subnet> {
- @Override
- public ObjectNode encode(Subnet subnet, CodecContext context) {
- checkNotNull(subnet, "Subnet cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("id", subnet.id().toString())
- .put("gateway_ip", subnet.gatewayIp().toString())
- .put("network_id", subnet.networkId().toString())
- .put("name", subnet.subnetName())
- .put("ip_version", subnet.ipVersion().toString())
- .put("cidr", subnet.cidr().toString())
- .put("shared", subnet.shared())
- .put("enabled_dchp", subnet.dhcpEnabled())
- .put("tenant_id", subnet.tenantId().toString())
- .put("ipv6_address_mode", subnet.ipV6AddressMode() == null ? null
- : subnet.ipV6AddressMode().toString())
- .put("ipv6_ra_mode", subnet.ipV6RaMode() == null ? null
- : subnet.ipV6RaMode().toString());
- result.set("allocation_pools", new AllocationPoolsCodec().encode(subnet
- .allocationPools(), context));
- result.set("host_routes",
- new HostRoutesCodec().encode(subnet.hostRoutes(), context));
- return result;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/TenantNetworkCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/TenantNetworkCodec.java
deleted file mode 100644
index 7a23d4c..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/TenantNetworkCodec.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.TenantNetwork;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * TenantNetwork JSON codec.
- */
-public final class TenantNetworkCodec extends JsonCodec<TenantNetwork> {
-
- @Override
- public ObjectNode encode(TenantNetwork network, CodecContext context) {
- checkNotNull(network, "Network cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("id", network.id().toString())
- .put("name", network.name())
- .put("admin_state_up", network.adminStateUp())
- .put("status", "" + network.state())
- .put("shared", network.shared())
- .put("tenant_id", network.tenantId().toString())
- .put("router:external", network.routerExternal())
- .put("provider:network_type", "" + network.type())
- .put("provider:physical_network", network.physicalNetwork().toString())
- .put("provider:segmentation_id", network.segmentationId().toString());
- return result;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VirtualPortCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VirtualPortCodec.java
deleted file mode 100644
index 8cf7823..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VirtualPortCodec.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.VirtualPort;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * VirtualPort JSON codec.
- */
-public final class VirtualPortCodec extends JsonCodec<VirtualPort> {
- @Override
- public ObjectNode encode(VirtualPort vPort, CodecContext context) {
- checkNotNull(vPort, "VPort cannot be null");
- ObjectNode result = context
- .mapper()
- .createObjectNode()
- .put("id", vPort.portId().toString())
- .put("network_id", vPort.networkId().toString())
- .put("admin_state_up", vPort.adminStateUp())
- .put("name", vPort.name())
- .put("status", vPort.state().toString())
- .put("mac_address", vPort.macAddress().toString())
- .put("tenant_id", vPort.tenantId().toString())
- .put("device_id", vPort.deviceId().toString())
- .put("device_owner", vPort.deviceOwner())
- .put("binding:vnic_type", vPort.bindingVnicType())
- .put("binding:Vif_type", vPort.bindingVifType())
- .put("binding:host_id", vPort.bindingHostId().toString())
- .put("binding:vif_details", vPort.bindingVifDetails());
- result.set("allowed_address_pairs", new AllowedAddressPairCodec().encode(
- vPort.allowedAddressPairs(), context));
- result.set("fixed_ips", new FixedIpCodec().encode(
- vPort.fixedIps(), context));
- result.set("security_groups", new SecurityGroupCodec().encode(
- vPort.securityGroups(), context));
- return result;
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VtnCodecRegistrator.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VtnCodecRegistrator.java
deleted file mode 100644
index 33581eb..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/VtnCodecRegistrator.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onosproject.codec.CodecService;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.ServiceFunctionGroup;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of the JSON codec brokering service for VTN app.
- */
-@Component(immediate = true)
-public class VtnCodecRegistrator {
-
- private static Logger log = LoggerFactory.getLogger(VtnCodecRegistrator.class);
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CodecService codecService;
-
- @Activate
- public void activate() {
- codecService.registerCodec(PortPair.class, new PortPairCodec());
- codecService.registerCodec(PortPairGroup.class, new PortPairGroupCodec());
- codecService.registerCodec(FlowClassifier.class, new FlowClassifierCodec());
- codecService.registerCodec(PortChain.class, new PortChainCodec());
- codecService.registerCodec(ServiceFunctionGroup.class, new ServiceFunctionCodec());
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/package-info.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/package-info.java
deleted file mode 100644
index 84cdade..0000000
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Codecs for virtual tenant objects.
- */
-package org.onosproject.vtnweb.web;
diff --git a/apps/vtn/vtnweb/src/main/resources/app/view/sfc/sfc.css b/apps/vtn/vtnweb/src/main/resources/app/view/sfc/sfc.css
deleted file mode 100644
index 8db5b70..0000000
--- a/apps/vtn/vtnweb/src/main/resources/app/view/sfc/sfc.css
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- ONOS GUI -- SFC View -- CSS file
- */
-
-#ov-sfc h2 {
- display: inline-block;
-}
-
-#ov-sfc div.ctrl-btns {
- width: 45px;
-}
\ No newline at end of file
diff --git a/apps/vtn/vtnweb/src/main/resources/app/view/sfc/sfc.html b/apps/vtn/vtnweb/src/main/resources/app/view/sfc/sfc.html
deleted file mode 100644
index adf9e3c..0000000
--- a/apps/vtn/vtnweb/src/main/resources/app/view/sfc/sfc.html
+++ /dev/null
@@ -1,67 +0,0 @@
-<!--
- ~ Copyright 2016-present Open Networking Foundation
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<!-- SFC partial HTML -->
-<div id="ov-sfc">
- <div class="tabular-header">
- <h2>service function chains ({{tableData.length}} total)</h2>
- <div class="ctrl-btns">
- <div class="refresh" ng-class="{active: autoRefresh}"
- icon icon-size="36" icon-id="refresh"
- tooltip tt-msg="autoRefreshTip"
- ng-click="toggleRefresh()"></div>
- </div>
- </div>
-
- <div class="summary-list" onos-table-resize>
- <div class="table-header" onos-sortable-header>
- <table>
- <tr>
- <td colId="_iconid_state" class="table-icon" sortable></td>
- <td colId="portChainName" sortable>PortChainName </td>
- <td colId="sfs" sortable>Sfs </td>
- <td colId="type" sortable>Type </td>
- <td colId="srcIp" sortable>Source IP Prefix </td>
- <td colId="dstIp" sortable>Destination IP Prefix </td>
- </tr>
- </table>
- </div>
-
- <div class="table-body">
- <table onos-flash-changes id-prop="one">
- <tr ng-if="!tableData.length" class="no-data">
- <td colspan="6">
- No Service Function Chain found
- </td>
- </tr>
-
- <tr ng-repeat="sfc in tableData track by $index"
- ng-repeat-complete row-id="{{sfc.id}}">
- <td class="table-icon">
- <div icon icon-id="{{sfc._iconid_state}}"></div>
- </td>
- <td>{{sfc.portChainName}}</td>
- <td>{{sfc.sfs}}</td>
- <td>{{sfc.type}}</td>
- <td>{{sfc.srcIp}}</td>
- <td>{{sfc.dstIp}}</td>
- </tr>
- </table>
- </div>
-
- </div>
-
-</div>
diff --git a/apps/vtn/vtnweb/src/main/resources/app/view/sfc/sfc.js b/apps/vtn/vtnweb/src/main/resources/app/view/sfc/sfc.js
deleted file mode 100644
index 60a5cf0..0000000
--- a/apps/vtn/vtnweb/src/main/resources/app/view/sfc/sfc.js
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- ONOS GUI -- SFC View Module
- */
-
-(function () {
- 'use strict';
-
- angular.module('ovSfc', [])
- .controller('OvSfcCtrl',
- ['$log', '$scope', '$sce', 'FnService', 'TableBuilderService',
-
- function ($log, $scope, $sce, fs, tbs) {
- tbs.buildTable({
- scope: $scope,
- tag: 'sfc'
- });
-
- $log.log('OvSfcCtrl has been created');
- }]);
-}());
diff --git a/apps/vtn/vtnweb/src/main/resources/gui/css.html b/apps/vtn/vtnweb/src/main/resources/gui/css.html
deleted file mode 100644
index eced4a3..0000000
--- a/apps/vtn/vtnweb/src/main/resources/gui/css.html
+++ /dev/null
@@ -1 +0,0 @@
-<link rel="stylesheet" href="app/view/sfc/sfc.css">
\ No newline at end of file
diff --git a/apps/vtn/vtnweb/src/main/resources/gui/js.html b/apps/vtn/vtnweb/src/main/resources/gui/js.html
deleted file mode 100644
index b6dcf44..0000000
--- a/apps/vtn/vtnweb/src/main/resources/gui/js.html
+++ /dev/null
@@ -1 +0,0 @@
-<script src="app/view/sfc/sfc.js"></script>
\ No newline at end of file
diff --git a/apps/vtn/vtnweb/src/main/webapp/WEB-INF/web.xml b/apps/vtn/vtnweb/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 8c368d9..0000000
--- a/apps/vtn/vtnweb/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright 2015-present Open Networking Foundation
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- id="ONOS" version="2.5">
- <display-name>VTNRSC REST API v1.0</display-name>
-
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>Secured</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>admin</role-name>
- <role-name>viewer</role-name>
- </auth-constraint>
- </security-constraint>
-
- <security-role>
- <role-name>admin</role-name>
- <role-name>viewer</role-name>
- </security-role>
-
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>karaf</realm-name>
- </login-config>
-
- <servlet>
- <servlet-name>JAX-RS Service</servlet-name>
- <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
- <init-param>
- <param-name>javax.ws.rs.Application</param-name>
- <param-value>org.onosproject.vtnweb.resources.VtnWebApplication</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>JAX-RS Service</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-</web-app>
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/ClassifierResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/ClassifierResourceTest.java
deleted file mode 100644
index 5fa977c..0000000
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/ClassifierResourceTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonObject;
-import com.google.common.collect.ImmutableList;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.osgi.TestServiceDirectory;
-import org.onosproject.codec.CodecService;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.classifier.ClassifierService;
-import org.onosproject.vtnweb.web.SfcCodecContext;
-
-import javax.ws.rs.client.WebTarget;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertThat;
-import static org.onosproject.net.NetTestTools.device;
-import static org.onosproject.net.NetTestTools.did;
-
-/**
- * Unit tests for classifier REST APIs.
- */
-public class ClassifierResourceTest extends VtnResourceTest {
-
- final ClassifierService classifierService = createMock(ClassifierService.class);
-
- /**
- * Sets up the global values for all the tests.
- */
- @Before
- public void setUpTest() {
-
- SfcCodecContext context = new SfcCodecContext();
- ServiceDirectory testDirectory = new TestServiceDirectory().add(ClassifierService.class, classifierService)
- .add(CodecService.class, context.codecManager());
- setServiceDirectory(testDirectory);
-
- }
-
- /**
- * Cleans up.
- */
- @After
- public void tearDownTest() {
- }
-
- /**
- * Tests the result of the rest api GET when there are no classifiers.
- */
- @Test
- public void testClassifiersEmpty() {
-
- expect(classifierService.getClassifiers()).andReturn(null).anyTimes();
- replay(classifierService);
- final WebTarget wt = target();
- final String response = wt.path("classifiers").request().get(String.class);
- assertThat(response, is("{\"classifiers\":[]}"));
- }
-
- /**
- * Tests the result of a rest api GET for classifiers.
- */
- @Test
- public void testClassifiers() {
-
- DeviceId devId1 = did("dev1");
- Device device1 = device("dev1");
-
- expect(classifierService.getClassifiers()).andReturn(ImmutableList.of(devId1)).anyTimes();
- replay(classifierService);
-
- final WebTarget wt = target();
- final String response = wt.path("classifiers").request().get(String.class);
- final JsonObject result = Json.parse(response).asObject();
- assertThat(result, notNullValue());
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/FlowClassifierResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/FlowClassifierResourceTest.java
deleted file mode 100644
index da9d6d8..0000000
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/FlowClassifierResourceTest.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonObject;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.osgi.TestServiceDirectory;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.codec.CodecService;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService;
-import org.onosproject.vtnweb.web.SfcCodecContext;
-
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Set;
-
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-/**
- * Unit tests for flow classifier REST APIs.
- */
-public class FlowClassifierResourceTest extends VtnResourceTest {
-
- final FlowClassifierService flowClassifierService = createMock(FlowClassifierService.class);
-
- FlowClassifierId flowClassifierId1 = FlowClassifierId.of("4a334cd4-fe9c-4fae-af4b-321c5e2eb051");
- TenantId tenantId1 = TenantId.tenantId("1814726e2d22407b8ca76db5e567dcf1");
- VirtualPortId srcPortId1 = VirtualPortId.portId("dace4513-24fc-4fae-af4b-321c5e2eb3d1");
- VirtualPortId dstPortId1 = VirtualPortId.portId("aef3478a-4a56-2a6e-cd3a-9dee4e2ec345");
-
- final MockFlowClassifier flowClassifier1 = new MockFlowClassifier(flowClassifierId1, tenantId1, "flowClassifier1",
- "Mock flow classifier", "IPv4", "IP", 10000,
- 1001, 1500, 5001, 6000,
- IpPrefix.valueOf("1.1.1.1/16"),
- IpPrefix.valueOf("22.12.34.45/16"),
- srcPortId1, dstPortId1);
-
- /**
- * Mock class for a flow classifier.
- */
- private static class MockFlowClassifier implements FlowClassifier {
-
- private final FlowClassifierId flowClassifierId;
- private final TenantId tenantId;
- private final String name;
- private final String description;
- private final String etherType;
- private final String protocol;
- private final int priority;
- private final int minSrcPortRange;
- private final int maxSrcPortRange;
- private final int minDstPortRange;
- private final int maxDstPortRange;
- private final IpPrefix srcIpPrefix;
- private final IpPrefix dstIpPrefix;
- private final VirtualPortId srcPort;
- private final VirtualPortId dstPort;
-
- public MockFlowClassifier(FlowClassifierId flowClassifierId, TenantId tenantId, String name,
- String description, String etherType, String protocol, int priority,
- int minSrcPortRange, int maxSrcPortRange, int minDstPortRange, int maxDstPortRange,
- IpPrefix srcIpPrefix, IpPrefix dstIpPrefix, VirtualPortId srcPort,
- VirtualPortId dstPort) {
- this.flowClassifierId = flowClassifierId;
- this.tenantId = tenantId;
- this.name = name;
- this.description = description;
- this.etherType = etherType;
- this.protocol = protocol;
- this.priority = priority;
- this.minSrcPortRange = minSrcPortRange;
- this.maxSrcPortRange = maxSrcPortRange;
- this.minDstPortRange = minDstPortRange;
- this.maxDstPortRange = maxDstPortRange;
- this.srcIpPrefix = srcIpPrefix;
- this.dstIpPrefix = dstIpPrefix;
- this.srcPort = srcPort;
- this.dstPort = dstPort;
- }
-
-
- @Override
- public FlowClassifierId flowClassifierId() {
- return flowClassifierId;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public String description() {
- return description;
- }
-
- @Override
- public String etherType() {
- return etherType;
- }
-
- @Override
- public String protocol() {
- return protocol;
- }
-
- @Override
- public int priority() {
- return priority;
- }
-
- @Override
- public int minSrcPortRange() {
- return minSrcPortRange;
- }
-
- @Override
- public int maxSrcPortRange() {
- return maxSrcPortRange;
- }
-
- @Override
- public int minDstPortRange() {
- return minDstPortRange;
- }
-
- @Override
- public int maxDstPortRange() {
- return maxDstPortRange;
- }
-
- @Override
- public IpPrefix srcIpPrefix() {
- return srcIpPrefix;
- }
-
- @Override
- public IpPrefix dstIpPrefix() {
- return dstIpPrefix;
- }
-
- @Override
- public VirtualPortId srcPort() {
- return srcPort;
- }
-
- @Override
- public VirtualPortId dstPort() {
- return dstPort;
- }
-
- @Override
- public boolean exactMatch(FlowClassifier flowClassifier) {
- return this.equals(flowClassifier) &&
- Objects.equals(this.flowClassifierId, flowClassifier.flowClassifierId()) &&
- Objects.equals(this.tenantId, flowClassifier.tenantId());
- }
- }
-
- /**
- * Sets up the global values for all the tests.
- */
- @Before
- public void setUpTest() {
- SfcCodecContext context = new SfcCodecContext();
-
- ServiceDirectory testDirectory = new TestServiceDirectory()
- .add(FlowClassifierService.class, flowClassifierService)
- .add(CodecService.class, context.codecManager());
- setServiceDirectory(testDirectory);
-
- }
-
- /**
- * Cleans up.
- */
- @After
- public void tearDownTest() {
- }
-
- /**
- * Tests the result of the rest api GET when there are no flow classifiers.
- */
- @Test
- public void testFlowClassifiersEmpty() {
-
- expect(flowClassifierService.getFlowClassifiers()).andReturn(null).anyTimes();
- replay(flowClassifierService);
- final WebTarget wt = target();
- final String response = wt.path("flow_classifiers").request().get(String.class);
- assertThat(response, is("{\"flow_classifiers\":[]}"));
- }
-
- /**
- * Tests the result of a rest api GET for flow classifier id.
- */
- @Test
- public void testGetFlowClassifierId() {
-
- final Set<FlowClassifier> flowClassifiers = new HashSet<>();
- flowClassifiers.add(flowClassifier1);
-
- expect(flowClassifierService.exists(anyObject())).andReturn(true).anyTimes();
- expect(flowClassifierService.getFlowClassifier(anyObject())).andReturn(flowClassifier1).anyTimes();
- replay(flowClassifierService);
-
- final WebTarget wt = target();
- final String response = wt.path("flow_classifiers/4a334cd4-fe9c-4fae-af4b-321c5e2eb051")
- .request().get(String.class);
- final JsonObject result = Json.parse(response).asObject();
- assertThat(result, notNullValue());
- }
-
- /**
- * Tests that a fetch of a non-existent flow classifier object throws an exception.
- */
- @Test
- public void testBadGet() {
- expect(flowClassifierService.getFlowClassifier(anyObject()))
- .andReturn(null).anyTimes();
- replay(flowClassifierService);
- WebTarget wt = target();
- try {
- wt.path("flow_classifiers/78dcd363-fc23-aeb6-f44b-56dc5aafb3ae")
- .request().get(String.class);
- fail("Fetch of non-existent flow classifier did not throw an exception");
- } catch (NotFoundException ex) {
- assertThat(ex.getMessage(),
- containsString("HTTP 404 Not Found"));
- }
- }
-
- /**
- * Tests creating a flow classifier with POST.
- */
- @Test
- public void testPost() {
-
- expect(flowClassifierService.createFlowClassifier(anyObject()))
- .andReturn(true).anyTimes();
- replay(flowClassifierService);
-
- WebTarget wt = target();
- InputStream jsonStream = FlowClassifierResourceTest.class.getResourceAsStream("post-FlowClassifier.json");
-
- Response response = wt.path("flow_classifiers")
- .request(MediaType.APPLICATION_JSON_TYPE)
- .post(Entity.json(jsonStream));
- assertThat(response.getStatus(), is(HttpURLConnection.HTTP_OK));
- }
-
- /**
- * Tests deleting a flow classifier.
- */
- @Test
- public void testDelete() {
- expect(flowClassifierService.removeFlowClassifier(anyObject()))
- .andReturn(true).anyTimes();
- replay(flowClassifierService);
-
- WebTarget wt = target();
-
- String location = "flow_classifiers/4a334cd4-fe9c-4fae-af4b-321c5e2eb051";
-
- Response deleteResponse = wt.path(location)
- .request(MediaType.APPLICATION_JSON_TYPE, MediaType.TEXT_PLAIN_TYPE)
- .delete();
- assertThat(deleteResponse.getStatus(),
- is(HttpURLConnection.HTTP_NO_CONTENT));
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainDeviceMapResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainDeviceMapResourceTest.java
deleted file mode 100644
index 15c2104..0000000
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainDeviceMapResourceTest.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonObject;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.osgi.TestServiceDirectory;
-import org.onosproject.codec.CodecService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.FiveTuple;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.LoadBalanceId;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.portchain.PortChainService;
-import org.onosproject.vtnweb.web.SfcCodecContext;
-
-import javax.ws.rs.client.WebTarget;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit tests for port chain device map REST APIs.
- */
-public class PortChainDeviceMapResourceTest extends VtnResourceTest {
-
- final PortChainService portChainService = createMock(PortChainService.class);
-
- PortChainId portChainId1 = PortChainId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- TenantId tenantId1 = TenantId.tenantId("d382007aa9904763a801f68ecf065cf5");
- private final List<PortPairGroupId> portPairGroupList1 = Lists.newArrayList();
- private final List<FlowClassifierId> flowClassifierList1 = Lists.newArrayList();
-
- final MockPortChain portChain1 = new MockPortChain(portChainId1, tenantId1, "portChain1",
- "Mock port chain", portPairGroupList1,
- flowClassifierList1);
-
- /**
- * Mock class for a port chain.
- */
- private static class MockPortChain implements PortChain {
-
- private final PortChainId portChainId;
- private final TenantId tenantId;
- private final String name;
- private final String description;
- private final List<PortPairGroupId> portPairGroupList;
- private final List<FlowClassifierId> flowClassifierList;
-
- public MockPortChain(PortChainId portChainId, TenantId tenantId,
- String name, String description,
- List<PortPairGroupId> portPairGroupList,
- List<FlowClassifierId> flowClassifierList) {
-
- this.portChainId = portChainId;
- this.tenantId = tenantId;
- this.name = name;
- this.description = description;
- this.portPairGroupList = portPairGroupList;
- this.flowClassifierList = flowClassifierList;
- }
-
- @Override
- public PortChainId portChainId() {
- return portChainId;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public String description() {
- return description;
- }
-
- @Override
- public List<PortPairGroupId> portPairGroups() {
- return ImmutableList.copyOf(portPairGroupList);
- }
-
- @Override
- public List<FlowClassifierId> flowClassifiers() {
- return ImmutableList.copyOf(flowClassifierList);
- }
-
- @Override
- public boolean exactMatch(PortChain portChain) {
- return this.equals(portChain) &&
- Objects.equals(this.portChainId, portChain.portChainId()) &&
- Objects.equals(this.tenantId, portChain.tenantId());
- }
-
- @Override
- public void addLoadBalancePath(FiveTuple fiveTuple, LoadBalanceId id, List<PortPairId> path) {
- }
-
- @Override
- public LoadBalanceId getLoadBalanceId(FiveTuple fiveTuple) {
- return null;
- }
-
- @Override
- public Set<FiveTuple> getLoadBalanceIdMapKeys() {
- return null;
- }
-
- @Override
- public List<PortPairId> getLoadBalancePath(LoadBalanceId id) {
- return null;
- }
-
- @Override
- public List<PortPairId> getLoadBalancePath(FiveTuple fiveTuple) {
- return null;
- }
-
- @Override
- public LoadBalanceId matchPath(List<PortPairId> path) {
- return null;
- }
-
- @Override
- public int getLoadBalancePathSize() {
- return 0;
- }
-
- @Override
- public void addSfcClassifiers(LoadBalanceId id, List<DeviceId> classifierList) {
- }
-
- @Override
- public void addSfcForwarders(LoadBalanceId id, List<DeviceId> forwarderList) {
- }
-
- @Override
- public void removeSfcClassifiers(LoadBalanceId id, List<DeviceId> classifierList) {
- }
-
- @Override
- public void removeSfcForwarders(LoadBalanceId id, List<DeviceId> forwarderList) {
- }
-
- @Override
- public List<DeviceId> getSfcClassifiers(LoadBalanceId id) {
- DeviceId deviceId1 = DeviceId.deviceId("of:000000000000001");
- List<DeviceId> classifierList = Lists.newArrayList();
- classifierList.add(deviceId1);
- return classifierList;
- }
-
- @Override
- public List<DeviceId> getSfcForwarders(LoadBalanceId id) {
- DeviceId deviceId1 = DeviceId.deviceId("of:000000000000002");
- DeviceId deviceId2 = DeviceId.deviceId("of:000000000000003");
- List<DeviceId> forwarderList = Lists.newArrayList();
- forwarderList.add(deviceId1);
- forwarderList.add(deviceId2);
- return forwarderList;
- }
-
- @Override
- public Set<LoadBalanceId> getLoadBalancePathMapKeys() {
- LoadBalanceId id = LoadBalanceId.of((byte) 1);
- Set<LoadBalanceId> set = new HashSet<LoadBalanceId>();
- set.add(id);
- return set;
- }
-
- @Override
- public PortChain oldPortChain() {
- return null;
- }
- }
-
- /**
- * Sets up the global values for all the tests.
- */
- @Before
- public void setUpTest() {
- SfcCodecContext context = new SfcCodecContext();
- ServiceDirectory testDirectory = new TestServiceDirectory()
- .add(PortChainService.class, portChainService)
- .add(CodecService.class, context.codecManager());
- setServiceDirectory(testDirectory);
- }
-
- /**
- * Cleans up.
- */
- @After
- public void tearDownTest() {
- }
-
- /**
- * Tests the result of a rest api GET for port chain id.
- */
- @Test
- public void testGetPortChainDeviceMap() {
-
- expect(portChainService.getPortChain(anyObject())).andReturn(portChain1).anyTimes();
- replay(portChainService);
-
- final WebTarget wt = target();
- final String response = wt.path("portChainDeviceMap/1278dcd4-459f-62ed-754b-87fc5e4a6751").request()
- .get(String.class);
- final JsonObject result = Json.parse(response).asObject();
- assertThat(result, notNullValue());
- assertThat(result.names().get(0), is("portChainDeviceMap"));
-
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainResourceTest.java
deleted file mode 100644
index dd81814..0000000
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainResourceTest.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonObject;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.osgi.TestServiceDirectory;
-import org.onosproject.codec.CodecService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.FiveTuple;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.LoadBalanceId;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.portchain.PortChainService;
-import org.onosproject.vtnweb.web.SfcCodecContext;
-
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-/**
- * Unit tests for port chain REST APIs.
- */
-public class PortChainResourceTest extends VtnResourceTest {
-
- final PortChainService portChainService = createMock(PortChainService.class);
-
- PortChainId portChainId1 = PortChainId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- TenantId tenantId1 = TenantId.tenantId("d382007aa9904763a801f68ecf065cf5");
- private final List<PortPairGroupId> portPairGroupList1 = Lists.newArrayList();
- private final List<FlowClassifierId> flowClassifierList1 = Lists.newArrayList();
-
-
- final MockPortChain portChain1 = new MockPortChain(portChainId1, tenantId1, "portChain1",
- "Mock port chain", portPairGroupList1,
- flowClassifierList1);
-
- /**
- * Mock class for a port chain.
- */
- private static class MockPortChain implements PortChain {
-
- private final PortChainId portChainId;
- private final TenantId tenantId;
- private final String name;
- private final String description;
- private final List<PortPairGroupId> portPairGroupList;
- private final List<FlowClassifierId> flowClassifierList;
-
- public MockPortChain(PortChainId portChainId, TenantId tenantId,
- String name, String description,
- List<PortPairGroupId> portPairGroupList,
- List<FlowClassifierId> flowClassifierList) {
-
- this.portChainId = portChainId;
- this.tenantId = tenantId;
- this.name = name;
- this.description = description;
- this.portPairGroupList = portPairGroupList;
- this.flowClassifierList = flowClassifierList;
- }
-
- @Override
- public PortChainId portChainId() {
- return portChainId;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public String description() {
- return description;
- }
-
- @Override
- public List<PortPairGroupId> portPairGroups() {
- return ImmutableList.copyOf(portPairGroupList);
- }
-
- @Override
- public List<FlowClassifierId> flowClassifiers() {
- return ImmutableList.copyOf(flowClassifierList);
- }
-
- @Override
- public boolean exactMatch(PortChain portChain) {
- return this.equals(portChain) &&
- Objects.equals(this.portChainId, portChain.portChainId()) &&
- Objects.equals(this.tenantId, portChain.tenantId());
- }
-
- @Override
- public void addLoadBalancePath(FiveTuple fiveTuple, LoadBalanceId id, List<PortPairId> path) {
- }
-
- @Override
- public LoadBalanceId getLoadBalanceId(FiveTuple fiveTuple) {
- return null;
- }
-
- @Override
- public Set<FiveTuple> getLoadBalanceIdMapKeys() {
- return null;
- }
-
- @Override
- public List<PortPairId> getLoadBalancePath(LoadBalanceId id) {
- return null;
- }
-
- @Override
- public List<PortPairId> getLoadBalancePath(FiveTuple fiveTuple) {
- return null;
- }
-
- @Override
- public LoadBalanceId matchPath(List<PortPairId> path) {
- return null;
- }
-
- @Override
- public int getLoadBalancePathSize() {
- return 0;
- }
-
- @Override
- public void addSfcClassifiers(LoadBalanceId id, List<DeviceId> classifierList) {
- }
-
- @Override
- public void addSfcForwarders(LoadBalanceId id, List<DeviceId> forwarderList) {
- }
-
- @Override
- public void removeSfcClassifiers(LoadBalanceId id, List<DeviceId> classifierList) {
- }
-
- @Override
- public void removeSfcForwarders(LoadBalanceId id, List<DeviceId> forwarderList) {
- }
-
- @Override
- public List<DeviceId> getSfcClassifiers(LoadBalanceId id) {
- return null;
- }
-
- @Override
- public List<DeviceId> getSfcForwarders(LoadBalanceId id) {
- return null;
- }
-
- @Override
- public Set<LoadBalanceId> getLoadBalancePathMapKeys() {
- return null;
- }
-
- @Override
- public PortChain oldPortChain() {
- return null;
- }
- }
-
- /**
- * Sets up the global values for all the tests.
- */
- @Before
- public void setUpTest() {
- SfcCodecContext context = new SfcCodecContext();
- ServiceDirectory testDirectory = new TestServiceDirectory()
- .add(PortChainService.class, portChainService)
- .add(CodecService.class, context.codecManager());
- setServiceDirectory(testDirectory);
-
- }
-
- /**
- * Cleans up.
- */
- @After
- public void tearDownTest() {
- }
-
- /**
- * Tests the result of the rest api GET when there are no port chains.
- */
- @Test
- public void testPortChainsEmpty() {
-
- expect(portChainService.getPortChains()).andReturn(null).anyTimes();
- replay(portChainService);
- final WebTarget wt = target();
- final String response = wt.path("port_chains").request().get(String.class);
- assertThat(response, is("{\"port_chains\":[]}"));
- }
-
- /**
- * Tests the result of a rest api GET for port chain id.
- */
- @Test
- public void testGetPortChainId() {
-
- final Set<PortChain> portChains = new HashSet<>();
- portChains.add(portChain1);
-
- expect(portChainService.exists(anyObject())).andReturn(true).anyTimes();
- expect(portChainService.getPortChain(anyObject())).andReturn(portChain1).anyTimes();
- replay(portChainService);
-
- final WebTarget wt = target();
- final String response = wt.path("port_chains/1278dcd4-459f-62ed-754b-87fc5e4a6751")
- .request().get(String.class);
- final JsonObject result = Json.parse(response).asObject();
- assertThat(result, notNullValue());
- }
-
- /**
- * Tests that a fetch of a non-existent port chain object throws an exception.
- */
- @Test
- public void testBadGet() {
- expect(portChainService.getPortChain(anyObject()))
- .andReturn(null).anyTimes();
- replay(portChainService);
- WebTarget wt = target();
- try {
- wt.path("port_chains/78dcd363-fc23-aeb6-f44b-56dc5aafb3ae")
- .request().get(String.class);
- fail("Fetch of non-existent port chain did not throw an exception");
- } catch (NotFoundException ex) {
- assertThat(ex.getMessage(),
- containsString("HTTP 404 Not Found"));
- }
- }
-
- /**
- * Tests creating a port chain with POST.
- */
- @Test
- public void testPost() {
-
- expect(portChainService.createPortChain(anyObject()))
- .andReturn(true).anyTimes();
- replay(portChainService);
-
- WebTarget wt = target();
- InputStream jsonStream = PortChainResourceTest.class.getResourceAsStream("post-PortChain.json");
-
- Response response = wt.path("port_chains")
- .request(MediaType.APPLICATION_JSON_TYPE)
- .post(Entity.json(jsonStream));
- assertThat(response.getStatus(), is(HttpURLConnection.HTTP_OK));
- }
-
- /**
- * Tests deleting a port chain.
- */
- @Test
- public void testDelete() {
- expect(portChainService.removePortChain(anyObject()))
- .andReturn(true).anyTimes();
- replay(portChainService);
-
- WebTarget wt = target();
-
- String location = "port_chains/1278dcd4-459f-62ed-754b-87fc5e4a6751";
-
- Response deleteResponse = wt.path(location)
- .request(MediaType.APPLICATION_JSON_TYPE, MediaType.TEXT_PLAIN_TYPE)
- .delete();
- assertThat(deleteResponse.getStatus(),
- is(HttpURLConnection.HTTP_NO_CONTENT));
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainSfMapResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainSfMapResourceTest.java
deleted file mode 100644
index e3866ce..0000000
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortChainSfMapResourceTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonObject;
-import com.google.common.collect.Lists;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.osgi.TestServiceDirectory;
-import org.onosproject.codec.CodecService;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.ServiceFunctionGroup;
-import org.onosproject.vtnrsc.portchainsfmap.PortChainSfMapService;
-import org.onosproject.vtnweb.web.SfcCodecContext;
-
-import javax.ws.rs.client.WebTarget;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit tests for port chain sf map REST APIs.
- */
-public class PortChainSfMapResourceTest extends VtnResourceTest {
-
- final PortChainSfMapService portChainSfMapService = createMock(PortChainSfMapService.class);
-
- String name1 = "Firewall";
- String description1 = "Firewall service function";
- Map<PortPairId, Integer> portPairLoadMap1 = new ConcurrentHashMap<>();
-
- ServiceFunctionGroup serviceFunction1 = new ServiceFunctionGroup(name1, description1,
- portPairLoadMap1);
-
- /**
- * Sets up the global values for all the tests.
- */
- @Before
- public void setUpTest() {
- SfcCodecContext context = new SfcCodecContext();
- ServiceDirectory testDirectory = new TestServiceDirectory()
- .add(PortChainSfMapService.class, portChainSfMapService)
- .add(CodecService.class, context.codecManager());
- setServiceDirectory(testDirectory);
- }
-
- /**
- * Cleans up.
- */
- @After
- public void tearDownTest() {
- }
-
- /**
- * Tests the result of a rest api GET for port chain id.
- */
- @Test
- public void testGetPortChainId() {
-
- final List<ServiceFunctionGroup> serviceFunctions = Lists.newArrayList();
- serviceFunctions.add(serviceFunction1);
-
- expect(portChainSfMapService.getServiceFunctions(anyObject())).andReturn(serviceFunctions).anyTimes();
- replay(portChainSfMapService);
-
- final WebTarget wt = target();
- final String response = wt.path("portChainSfMap/1278dcd4-459f-62ed-754b-87fc5e4a6751").request()
- .get(String.class);
- final JsonObject result = Json.parse(response).asObject();
- assertThat(result, notNullValue());
- assertThat(result.names().get(0), is("portChainSfMap"));
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortPairGroupResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortPairGroupResourceTest.java
deleted file mode 100644
index a5f2150..0000000
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortPairGroupResourceTest.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonObject;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.osgi.TestServiceDirectory;
-import org.onosproject.codec.CodecService;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService;
-import org.onosproject.vtnweb.web.SfcCodecContext;
-
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-/**
- * Unit tests for port pair group REST APIs.
- */
-public class PortPairGroupResourceTest extends VtnResourceTest {
-
- final PortPairGroupService portPairGroupService = createMock(PortPairGroupService.class);
-
- PortPairGroupId portPairGroupId1 = PortPairGroupId.of("4512d643-24fc-4fae-af4b-321c5e2eb3d1");
- TenantId tenantId1 = TenantId.tenantId("d382007aa9904763a801f68ecf065cf5");
- private final List<PortPairId> portPairList1 = Lists.newArrayList();
-
- final MockPortPairGroup portPairGroup1 = new MockPortPairGroup(portPairGroupId1, tenantId1, "portPairGroup1",
- "Mock port pair group", portPairList1);
-
- /**
- * Mock class for a port pair group.
- */
- private static class MockPortPairGroup implements PortPairGroup {
-
- private final PortPairGroupId portPairGroupId;
- private final TenantId tenantId;
- private final String name;
- private final String description;
- private final List<PortPairId> portPairList;
-
- public MockPortPairGroup(PortPairGroupId portPairGroupId, TenantId tenantId,
- String name, String description,
- List<PortPairId> portPairList) {
-
- this.portPairGroupId = portPairGroupId;
- this.tenantId = tenantId;
- this.name = name;
- this.description = description;
- this.portPairList = portPairList;
- }
-
- @Override
- public PortPairGroupId portPairGroupId() {
- return portPairGroupId;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public String description() {
- return description;
- }
-
- @Override
- public List<PortPairId> portPairs() {
- return ImmutableList.copyOf(portPairList);
- }
-
- @Override
- public void addLoad(PortPairId portPairId) {
- }
-
- @Override
- public int getLoad(PortPairId portPairId) {
- return 0;
- }
-
- @Override
- public Map<PortPairId, Integer> portPairLoadMap() {
- return null;
- }
-
- @Override
- public boolean exactMatch(PortPairGroup portPairGroup) {
- return this.equals(portPairGroup) &&
- Objects.equals(this.portPairGroupId, portPairGroup.portPairGroupId()) &&
- Objects.equals(this.tenantId, portPairGroup.tenantId());
- }
-
- @Override
- public void resetLoad() {
- }
- }
-
- /**
- * Sets up the global values for all the tests.
- */
- @Before
- public void setUpTest() {
- SfcCodecContext context = new SfcCodecContext();
- ServiceDirectory testDirectory = new TestServiceDirectory()
- .add(PortPairGroupService.class, portPairGroupService)
- .add(CodecService.class, context.codecManager());
- setServiceDirectory(testDirectory);
-
- }
-
- /**
- * Cleans up.
- */
- @After
- public void tearDownTest() {
- }
-
- /**
- * Tests the result of the rest api GET when there are no port pair groups.
- */
- @Test
- public void testPortPairGroupsEmpty() {
-
- expect(portPairGroupService.getPortPairGroups()).andReturn(null).anyTimes();
- replay(portPairGroupService);
- final WebTarget wt = target();
- final String response = wt.path("port_pair_groups").request().get(String.class);
- assertThat(response, is("{\"port_pair_groups\":[]}"));
- }
-
- /**
- * Tests the result of a rest api GET for port pair group id.
- */
- @Test
- public void testGetPortPairGroupId() {
-
- final Set<PortPairGroup> portPairGroups = new HashSet<>();
- portPairGroups.add(portPairGroup1);
-
- expect(portPairGroupService.exists(anyObject())).andReturn(true).anyTimes();
- expect(portPairGroupService.getPortPairGroup(anyObject())).andReturn(portPairGroup1).anyTimes();
- replay(portPairGroupService);
-
- final WebTarget wt = target();
- final String response = wt.path("port_pair_groups/4512d643-24fc-4fae-af4b-321c5e2eb3d1")
- .request().get(String.class);
- final JsonObject result = Json.parse(response).asObject();
- assertThat(result, notNullValue());
- }
-
- /**
- * Tests that a fetch of a non-existent port pair group object throws an exception.
- */
- @Test
- public void testBadGet() {
- expect(portPairGroupService.getPortPairGroup(anyObject()))
- .andReturn(null).anyTimes();
- replay(portPairGroupService);
- WebTarget wt = target();
- try {
- wt.path("port_pair_groups/78dcd363-fc23-aeb6-f44b-56dc5aafb3ae")
- .request().get(String.class);
- fail("Fetch of non-existent port pair group did not throw an exception");
- } catch (NotFoundException ex) {
- assertThat(ex.getMessage(),
- containsString("HTTP 404 Not Found"));
- }
- }
-
- /**
- * Tests creating a port pair group with POST.
- */
- @Test
- public void testPost() {
-
- expect(portPairGroupService.createPortPairGroup(anyObject()))
- .andReturn(true).anyTimes();
- replay(portPairGroupService);
-
- WebTarget wt = target();
- InputStream jsonStream = PortPairGroupResourceTest.class.getResourceAsStream("post-PortPairGroup.json");
-
- Response response = wt.path("port_pair_groups")
- .request(MediaType.APPLICATION_JSON_TYPE)
- .post(Entity.json(jsonStream));
- assertThat(response.getStatus(), is(HttpURLConnection.HTTP_OK));
- }
-
- /**
- * Tests deleting a port pair group.
- */
- @Test
- public void testDelete() {
- expect(portPairGroupService.removePortPairGroup(anyObject()))
- .andReturn(true).anyTimes();
- replay(portPairGroupService);
-
- WebTarget wt = target();
-
- String location = "port_pair_groups/4512d643-24fc-4fae-af4b-321c5e2eb3d1";
-
- Response deleteResponse = wt.path(location)
- .request(MediaType.APPLICATION_JSON_TYPE, MediaType.TEXT_PLAIN_TYPE)
- .delete();
- assertThat(deleteResponse.getStatus(),
- is(HttpURLConnection.HTTP_NO_CONTENT));
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortPairResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortPairResourceTest.java
deleted file mode 100644
index 63e89b9..0000000
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/PortPairResourceTest.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonObject;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.osgi.TestServiceDirectory;
-import org.onosproject.codec.CodecService;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.portpair.PortPairService;
-import org.onosproject.vtnweb.web.SfcCodecContext;
-
-import javax.ws.rs.NotFoundException;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Set;
-
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-/**
- * Unit tests for port pair REST APIs.
- */
-public class PortPairResourceTest extends VtnResourceTest {
-
- final PortPairService portPairService = createMock(PortPairService.class);
-
- PortPairId portPairId1 = PortPairId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- TenantId tenantId1 = TenantId.tenantId("d382007aa9904763a801f68ecf065cf5");
-
- final MockPortPair portPair1 = new MockPortPair(portPairId1, tenantId1, "portPair1",
- "Mock port pair", "dace4513-24fc-4fae-af4b-321c5e2eb3d1",
- "aef3478a-4a56-2a6e-cd3a-9dee4e2ec345");
-
- /**
- * Mock class for a port pair.
- */
- private static class MockPortPair implements PortPair {
-
- private final PortPairId portPairId;
- private final TenantId tenantId;
- private final String name;
- private final String description;
- private final String ingress;
- private final String egress;
-
- public MockPortPair(PortPairId portPairId, TenantId tenantId,
- String name, String description,
- String ingress, String egress) {
-
- this.portPairId = portPairId;
- this.tenantId = tenantId;
- this.name = name;
- this.description = description;
- this.ingress = ingress;
- this.egress = egress;
- }
-
- @Override
- public PortPairId portPairId() {
- return portPairId;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public String description() {
- return description;
- }
-
- @Override
- public String ingress() {
- return ingress;
- }
-
- @Override
- public String egress() {
- return egress;
- }
-
- @Override
- public boolean exactMatch(PortPair portPair) {
- return this.equals(portPair) &&
- Objects.equals(this.portPairId, portPair.portPairId()) &&
- Objects.equals(this.tenantId, portPair.tenantId());
- }
- }
-
- /**
- * Sets up the global values for all the tests.
- */
- @Before
- public void setUpTest() {
-
- SfcCodecContext context = new SfcCodecContext();
- ServiceDirectory testDirectory = new TestServiceDirectory().add(PortPairService.class, portPairService)
- .add(CodecService.class, context.codecManager());
- setServiceDirectory(testDirectory);
-
- }
-
- /**
- * Cleans up.
- */
- @After
- public void tearDownTest() {
- }
-
- /**
- * Tests the result of the rest api GET when there are no port pairs.
- */
- @Test
- public void testPortPairsEmpty() {
-
- expect(portPairService.getPortPairs()).andReturn(null).anyTimes();
- replay(portPairService);
- final WebTarget wt = target();
- final String response = wt.path("port_pairs").request().get(String.class);
- assertThat(response, is("{\"port_pairs\":[]}"));
- }
-
- /**
- * Tests the result of a rest api GET for port pair id.
- */
- @Test
- public void testGetPortPairId() {
-
- final Set<PortPair> portPairs = new HashSet<>();
- portPairs.add(portPair1);
-
- expect(portPairService.exists(anyObject())).andReturn(true).anyTimes();
- expect(portPairService.getPortPair(anyObject())).andReturn(portPair1).anyTimes();
- replay(portPairService);
-
- final WebTarget wt = target();
- final String response = wt.path("port_pairs/78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae")
- .request().get(String.class);
- final JsonObject result = Json.parse(response).asObject();
- assertThat(result, notNullValue());
- }
-
- /**
- * Tests that a fetch of a non-existent port pair object throws an exception.
- */
- @Test
- public void testBadGet() {
- expect(portPairService.getPortPair(anyObject()))
- .andReturn(null).anyTimes();
- replay(portPairService);
- WebTarget wt = target();
- try {
- wt.path("port_pairs/78dcd363-fc23-aeb6-f44b-56dc5aafb3ae")
- .request().get(String.class);
- fail("Fetch of non-existent port pair did not throw an exception");
- } catch (NotFoundException ex) {
- assertThat(ex.getMessage(),
- containsString("HTTP 404 Not Found"));
- }
- }
-
- /**
- * Tests creating a port pair with POST.
- */
- @Test
- public void testPost() {
-
- expect(portPairService.createPortPair(anyObject()))
- .andReturn(true).anyTimes();
- replay(portPairService);
-
- WebTarget wt = target();
- InputStream jsonStream = PortPairResourceTest.class.getResourceAsStream("post-PortPair.json");
-
- Response response = wt.path("port_pairs")
- .request(MediaType.APPLICATION_JSON_TYPE)
- .post(Entity.json(jsonStream));
- assertThat(response.getStatus(), is(HttpURLConnection.HTTP_OK));
- }
-
- /**
- * Tests deleting a port pair.
- */
- @Test
- public void testDelete() {
- expect(portPairService.removePortPair(anyObject()))
- .andReturn(true).anyTimes();
- replay(portPairService);
-
- WebTarget wt = target();
-
- String location = "port_pairs/78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae";
-
- Response deleteResponse = wt.path(location)
- .request(MediaType.APPLICATION_JSON_TYPE, MediaType.TEXT_PLAIN_TYPE)
- .delete();
- assertThat(deleteResponse.getStatus(),
- is(HttpURLConnection.HTTP_NO_CONTENT));
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/VtnResourceTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/VtnResourceTest.java
deleted file mode 100644
index 2f7d759..0000000
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/resources/VtnResourceTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.resources;
-
-import org.glassfish.jersey.server.ResourceConfig;
-import org.onosproject.rest.resources.ResourceTest;
-
-/**
- * Base class for VTN REST API tests. Performs common configuration operations.
- */
-public class VtnResourceTest extends ResourceTest {
-
- /**
- * Creates a new web-resource test.
- */
- public VtnResourceTest() {
- super(ResourceConfig.forApplicationClass(VtnWebApplication.class));
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/FlowClassifierCodecTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/FlowClassifierCodecTest.java
deleted file mode 100644
index 6b55fcf..0000000
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/FlowClassifierCodecTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.FlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.TenantId;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Flow classifier codec unit tests.
- */
-public class FlowClassifierCodecTest {
-
- SfcCodecContext context;
- JsonCodec<FlowClassifier> flowClassifierCodec;
- /**
- * Sets up for each test. Creates a context and fetches the flow classifier
- * codec.
- */
- @Before
- public void setUp() {
- context = new SfcCodecContext();
- flowClassifierCodec = context.codec(FlowClassifier.class);
- assertThat(flowClassifierCodec, notNullValue());
- }
-
- /**
- * Reads in a flow classifier from the given resource and decodes it.
- *
- * @param resourceName resource to use to read the JSON for the flow classifier
- * @return decoded flow classifier
- * @throws IOException if processing the resource fails
- */
- private FlowClassifier getFlowClassifier(String resourceName) throws IOException {
- InputStream jsonStream = FlowClassifierCodecTest.class
- .getResourceAsStream(resourceName);
- ObjectMapper mapper = new ObjectMapper();
- JsonNode json = mapper.readTree(jsonStream);
- assertThat(json, notNullValue());
- FlowClassifier flowClassifier = flowClassifierCodec.decode((ObjectNode) json, context);
- assertThat(flowClassifier, notNullValue());
- return flowClassifier;
- }
-
- /**
- * Checks that a simple flow classifier decodes properly.
- *
- * @throws IOException if the resource cannot be processed
- */
- @Test
- public void codecFlowClassifierTest() throws IOException {
-
- FlowClassifier flowClassifier = getFlowClassifier("flowClassifier.json");
-
- assertThat(flowClassifier, notNullValue());
-
- FlowClassifierId flowClassifierId = FlowClassifierId.of("4a334cd4-fe9c-4fae-af4b-321c5e2eb051");
- TenantId tenantId = TenantId.tenantId("1814726e2d22407b8ca76db5e567dcf1");
-
- assertThat(flowClassifier.flowClassifierId().toString(), is(flowClassifierId.toString()));
- assertThat(flowClassifier.name(), is("flow1"));
- assertThat(flowClassifier.tenantId().toString(), is(tenantId.toString()));
- assertThat(flowClassifier.description(), is("flow classifier"));
- assertThat(flowClassifier.protocol(), is("tcp"));
- assertThat(flowClassifier.priority(), is(65535));
- assertThat(flowClassifier.minSrcPortRange(), is(22));
- assertThat(flowClassifier.maxSrcPortRange(), is(4000));
- assertThat(flowClassifier.minDstPortRange(), is(80));
- assertThat(flowClassifier.maxDstPortRange(), is(80));
-
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortChainCodecTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortChainCodecTest.java
deleted file mode 100644
index 36d036b..0000000
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortChainCodecTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.TenantId;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Flow rule codec unit tests.
- */
-public class PortChainCodecTest {
-
- SfcCodecContext context;
- JsonCodec<PortChain> portChainCodec;
- /**
- * Sets up for each test. Creates a context and fetches the flow rule
- * codec.
- */
- @Before
- public void setUp() {
- context = new SfcCodecContext();
- portChainCodec = context.codec(PortChain.class);
- assertThat(portChainCodec, notNullValue());
- }
-
- /**
- * Reads in a rule from the given resource and decodes it.
- *
- * @param resourceName resource to use to read the JSON for the rule
- * @return decoded flow rule
- * @throws IOException if processing the resource fails
- */
- private PortChain getPortChain(String resourceName) throws IOException {
- InputStream jsonStream = PortChainCodecTest.class
- .getResourceAsStream(resourceName);
- ObjectMapper mapper = new ObjectMapper();
- JsonNode json = mapper.readTree(jsonStream);
- assertThat(json, notNullValue());
- PortChain portChain = portChainCodec.decode((ObjectNode) json, context);
- assertThat(portChain, notNullValue());
- return portChain;
- }
-
- /**
- * Checks that a simple rule decodes properly.
- *
- * @throws IOException if the resource cannot be processed
- */
- @Test
- public void codecPortChainTest() throws IOException {
-
- PortChain portChain = getPortChain("portChain.json");
-
- assertThat(portChain, notNullValue());
-
- PortChainId portChainId = PortChainId.of("1278dcd4-459f-62ed-754b-87fc5e4a6751");
- TenantId tenantId = TenantId.tenantId("d382007aa9904763a801f68ecf065cf5");
-
- assertThat(portChain.portChainId().toString(), is(portChainId.toString()));
- assertThat(portChain.name(), is("PC2"));
- assertThat(portChain.tenantId().toString(), is(tenantId.toString()));
- assertThat(portChain.description(), is("Two flows and two port-pair-groups"));
-
- assertThat(portChain.flowClassifiers(), notNullValue());
- assertThat(portChain.portPairGroups(), notNullValue());
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairCodecTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairCodecTest.java
deleted file mode 100644
index 059df24..0000000
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairCodecTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Port pair codec unit tests.
- */
-public class PortPairCodecTest {
-
- SfcCodecContext context;
- JsonCodec<PortPair> portPairCodec;
- /**
- * Sets up for each test. Creates a context and fetches the port pair
- * codec.
- */
- @Before
- public void setUp() {
- context = new SfcCodecContext();
- portPairCodec = context.codec(PortPair.class);
- assertThat(portPairCodec, notNullValue());
- }
-
- /**
- * Reads in a port pair from the given resource and decodes it.
- *
- * @param resourceName resource to use to read the JSON for the port pair
- * @return decoded port pair
- * @throws IOException if processing the resource fails
- */
- private PortPair getPortPair(String resourceName) throws IOException {
- InputStream jsonStream = PortPairCodecTest.class
- .getResourceAsStream(resourceName);
- ObjectMapper mapper = new ObjectMapper();
- JsonNode json = mapper.readTree(jsonStream);
- assertThat(json, notNullValue());
- PortPair portPair = portPairCodec.decode((ObjectNode) json, context);
- assertThat(portPair, notNullValue());
- return portPair;
- }
-
- /**
- * Checks that a simple port pair decodes properly.
- *
- * @throws IOException if the resource cannot be processed
- */
- @Test
- public void codecPortPairTest() throws IOException {
-
- PortPair portPair = getPortPair("portPair.json");
-
- assertThat(portPair, notNullValue());
-
- PortPairId portPairId = PortPairId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- TenantId tenantId = TenantId.tenantId("d382007aa9904763a801f68ecf065cf5");
-
- assertThat(portPair.portPairId().toString(), is(portPairId.toString()));
- assertThat(portPair.name(), is("PP1"));
- assertThat(portPair.tenantId().toString(), is(tenantId.toString()));
- assertThat(portPair.description(), is("SF-A"));
- assertThat(portPair.ingress().toString(), is("dace4513-24fc-4fae-af4b-321c5e2eb3d1"));
- assertThat(portPair.egress().toString(), is("aef3478a-4a56-2a6e-cd3a-9dee4e2ec345"));
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairGroupCodecTest.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairGroupCodecTest.java
deleted file mode 100644
index 5fdaf86..0000000
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairGroupCodecTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.TenantId;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Flow rule codec unit tests.
- */
-public class PortPairGroupCodecTest {
-
- SfcCodecContext context;
- JsonCodec<PortPairGroup> portPairGroupCodec;
- /**
- * Sets up for each test. Creates a context and fetches the flow rule
- * codec.
- */
- @Before
- public void setUp() {
- context = new SfcCodecContext();
- portPairGroupCodec = context.codec(PortPairGroup.class);
- assertThat(portPairGroupCodec, notNullValue());
- }
-
- /**
- * Reads in a rule from the given resource and decodes it.
- *
- * @param resourceName resource to use to read the JSON for the rule
- * @return decoded flow rule
- * @throws IOException if processing the resource fails
- */
- private PortPairGroup getPortPairGroup(String resourceName) throws IOException {
- InputStream jsonStream = PortPairGroupCodecTest.class
- .getResourceAsStream(resourceName);
- ObjectMapper mapper = new ObjectMapper();
- JsonNode json = mapper.readTree(jsonStream);
- assertThat(json, notNullValue());
- PortPairGroup portPairGroup = portPairGroupCodec.decode((ObjectNode) json, context);
- assertThat(portPairGroup, notNullValue());
- return portPairGroup;
- }
-
- /**
- * Checks that a simple rule decodes properly.
- *
- * @throws IOException if the resource cannot be processed
- */
- @Test
- public void codecPortPairGroupTest() throws IOException {
-
- PortPairGroup portPairGroup = getPortPairGroup("portPairGroup.json");
-
- assertThat(portPairGroup, notNullValue());
-
- PortPairGroupId portPairGroupId = PortPairGroupId.of("4512d643-24fc-4fae-af4b-321c5e2eb3d1");
- TenantId tenantId = TenantId.tenantId("d382007aa9904763a801f68ecf065cf5");
-
- assertThat(portPairGroup.portPairGroupId().toString(), is(portPairGroupId.toString()));
- assertThat(portPairGroup.name(), is("PG1"));
- assertThat(portPairGroup.tenantId().toString(), is(tenantId.toString()));
- assertThat(portPairGroup.description(), is("Two port-pairs"));
- assertThat(portPairGroup.portPairs(), notNullValue());
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/SfcCodecContext.java b/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/SfcCodecContext.java
deleted file mode 100644
index 1a4965b..0000000
--- a/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/SfcCodecContext.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnweb.web;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.CodecService;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.codec.impl.CodecManager;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * Mock codec context for use in codec unit tests.
- */
-public class SfcCodecContext implements CodecContext {
-
- private final ObjectMapper mapper = new ObjectMapper();
- private final CodecManager codecManager = new CodecManager();
- private final VtnCodecRegistrator manager = new VtnCodecRegistrator();
-
- /**
- * Constructs a new mock codec context.
- */
- public SfcCodecContext() {
- codecManager.activate();
- manager.codecService = codecManager;
- manager.activate();
- }
-
- @Override
- public ObjectMapper mapper() {
- return mapper;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getService(Class<T> serviceClass) {
- // TODO
- return null;
- }
-
- @Override
- public <T> JsonCodec<T> codec(Class<T> entityClass) {
- return codecManager.getCodec(entityClass);
- }
-
- /**
- * Get the codec manager.
- *
- * @return instance of codec manager
- */
- public CodecService codecManager() {
- return codecManager;
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/resources/post-FlowClassifier.json b/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/resources/post-FlowClassifier.json
deleted file mode 100644
index 5ed095d..0000000
--- a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/resources/post-FlowClassifier.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{"flow_classifier": {
- "id": "4a334cd4-fe9c-4fae-af4b-321c5e2eb051",
- "name": "flow1",
- "tenant_id": "1814726e2d22407b8ca76db5e567dcf1",
- "description": "flow classifier",
- "ethertype": "IPv4",
- "protocol": "tcp",
- "priority": 10000,
- "source_port_range_min": 22, "source_port_range_max": 4000,
- "destination_port_range_min": 80, "destination_port_range_max": 80,
- "source_ip_prefix": "1.1.1.1/16" , "destination_ip_prefix": "22.12.34.45/16",
- "logical_destination_port": "dace4513-24fc-4fae-af4b-321c5e2eb3d1",
- "logical_source_port": "aef3478a-4a56-2a6e-cd3a-9dee4e2ec345"
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/resources/post-PortChain.json b/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/resources/post-PortChain.json
deleted file mode 100644
index 488e290..0000000
--- a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/resources/post-PortChain.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{"port_pair": {
- "id": "1278dcd4-459f-62ed-754b-87fc5e4a6751",
- "name": "PC2",
- "tenant_id": "d382007aa9904763a801f68ecf065cf5",
- "description": "Two flows and two port-pair-groups",
- "flow_classifiers": [
- "456a4a34-2e9c-14ae-37fb-765feae2eb05",
- "4a334cd4-fe9c-4fae-af4b-321c5e2eb051"
- ],
- "port_pair_groups": [
- "4512d643-24fc-4fae-af4b-321c5e2eb3d1",
- "4a634d49-76dc-4fae-af4b-321c5e23d651"
- ]
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/resources/post-PortPair.json b/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/resources/post-PortPair.json
deleted file mode 100644
index 2a774e3..0000000
--- a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/resources/post-PortPair.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{"port_pair": {
- "id": "78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae",
- "name": "PP1",
- "tenant_id": "d382007aa9904763a801f68ecf065cf5",
- "description": "SF-A",
- "ingress": "dace4513-24fc-4fae-af4b-321c5e2eb3d1",
- "egress": "aef3478a-4a56-2a6e-cd3a-9dee4e2ec345"
- }
-}
diff --git a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/resources/post-PortPairGroup.json b/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/resources/post-PortPairGroup.json
deleted file mode 100644
index f6a888d..0000000
--- a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/resources/post-PortPairGroup.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{"port_pair_group": {
- "id": "4512d643-24fc-4fae-af4b-321c5e2eb3d1",
- "name": "portPairGroup1",
- "tenant_id": "d382007aa9904763a801f68ecf065cf5",
- "description": "Mock port pair group",
- "port_pairs": [
- "875dfeda-43ed-23fe-454b-764feab2c342",
- "78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"
- ]
-}
-}
diff --git a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/flowClassifier.json b/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/flowClassifier.json
deleted file mode 100644
index 3fd5ac9..0000000
--- a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/flowClassifier.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "id": "4a334cd4-fe9c-4fae-af4b-321c5e2eb051",
- "name": "flow1",
- "tenant_id": "1814726e2d22407b8ca76db5e567dcf1",
- "description": "flow classifier",
- "ethertype": "IPv4",
- "protocol": "tcp",
- "priority": 65535,
- "source_port_range_min": 22, "source_port_range_max": 4000,
- "destination_port_range_min": 80, "destination_port_range_max": 80,
- "source_ip_prefix": "1.1.1.1/16" , "destination_ip_prefix": "22.12.34.45/16"
- }
diff --git a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/portChain.json b/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/portChain.json
deleted file mode 100644
index 07a1bc2..0000000
--- a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/portChain.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "id": "1278dcd4-459f-62ed-754b-87fc5e4a6751",
- "name": "PC2",
- "tenant_id": "d382007aa9904763a801f68ecf065cf5",
- "description": "Two flows and two port-pair-groups",
- "flow_classifiers": [
- "456a4a34-2e9c-14ae-37fb-765feae2eb05",
- "4a334cd4-fe9c-4fae-af4b-321c5e2eb051"
- ],
- "port_pair_groups": [
- "4512d643-24fc-4fae-af4b-321c5e2eb3d1",
- "4a634d49-76dc-4fae-af4b-321c5e23d651"
- ]
-}
diff --git a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/portPair.json b/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/portPair.json
deleted file mode 100644
index f858c88..0000000
--- a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/portPair.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "id": "78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae",
- "name": "PP1",
- "tenant_id": "d382007aa9904763a801f68ecf065cf5",
- "description": "SF-A",
- "ingress": "dace4513-24fc-4fae-af4b-321c5e2eb3d1",
- "egress": "aef3478a-4a56-2a6e-cd3a-9dee4e2ec345"
-}
-
diff --git a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/portPairGroup.json b/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/portPairGroup.json
deleted file mode 100644
index e19a66f..0000000
--- a/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/portPairGroup.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "id": "4512d643-24fc-4fae-af4b-321c5e2eb3d1",
- "name": "PG1",
- "tenant_id": "d382007aa9904763a801f68ecf065cf5",
- "description": "Two port-pairs",
- "port_pairs": [
- "875dfeda-43ed-23fe-454b-764feab2c342",
- "78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"
- ]
-}
diff --git a/apps/yms/BUCK.deprecated b/apps/yms/BUCK.deprecated
deleted file mode 100644
index aae4279..0000000
--- a/apps/yms/BUCK.deprecated
+++ /dev/null
@@ -1,14 +0,0 @@
-BUNDLES = [
- '//apps/yms/api:onos-apps-yms-api',
- '//apps/yms/app:onos-apps-yms-app',
- '//lib:onos-yang-datamodel',
- '//lib:onos-yang-utils-generator',
- '//lib:org.apache.servicemix.bundles.dom4j',
-]
-
-onos_app(
- title = 'YANG Management System',
- category = 'Utility',
- url = 'http://onosproject.org',
- included_bundles = BUNDLES,
-)
diff --git a/apps/yms/api/BUCK.deprecated b/apps/yms/api/BUCK.deprecated
deleted file mode 100644
index b8b02d6..0000000
--- a/apps/yms/api/BUCK.deprecated
+++ /dev/null
@@ -1,8 +0,0 @@
-COMPILE_DEPS = [
- '//lib:CORE_DEPS',
- '//lib:onos-yang-datamodel',
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/package-info.java b/apps/yms/api/src/main/java/org/onosproject/yms/package-info.java
deleted file mode 100644
index f22e1fa..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/package-info.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides interfaces to YANG management system. YANG management system
- * is a core of YANG in ONOS.
- *
- * In NBI, it acts as a broker in between the protocol and application,
- * here there is a separate protocol implementation, which does the conversion
- * of protocol representation to abstract data tree. The protocol
- * implementation takes care of the protocol specific actions for
- * e.g. RESTCONF handling the entity-tag / timestamp related operations.
- *
- * In SBI, driver or provider uses YANG codec handler as a utility to translate
- * the request information in java(YANG utils generated) to protocol specific
- * format and vice versa.
- */
-package org.onosproject.yms;
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangCodecHandler.java b/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangCodecHandler.java
deleted file mode 100644
index 47e6c66..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangCodecHandler.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ych;
-
-import org.onosproject.yms.ydt.YmsOperationType;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Abstraction of an entity which provides interfaces to YANG codec handler.
- * <p>
- * In SBI, the provider or driver uses YANG management system as a CODEC
- * utility. Providers/drivers register the device schema with YANG management
- * system. YANG utils is used to generate the java files corresponding to the
- * device schema. Provider or driver use these classes to seamlessly manage
- * the device as java objects. While sending the request to device, drivers
- * use the utility to translate the objects to protocol specific data
- * representation and then send to the device. Protocol or driver use the
- * same instance of the codec utility across multiple translation request.
- * Protocol or driver should not use the same instance of utility concurrently.
- */
-public interface YangCodecHandler {
- /**
- * Provider / driver needs to register the device schema with code handler.
- * Then the provider / driver can use the codec handler to perform the
- * codec operation. When the codec operation is being performed, the
- * codec utility finds the mapping registered device model and perform the
- * translation against the device schema.
- *
- * @param yangModule YANG utils generated class corresponding to SBI
- * device schema module
- */
- void addDeviceSchema(Class<?> yangModule);
-
-
- /**
- * When the drivers / providers need to encode a protocol operation
- * requests, which is in a single block, this encode API is used.
- * A single protocol operation can span across multiple application, then
- * the driver / provider need to provide the list of application(s) module
- * object. Each module object contains the request information
- * corresponding to that application.
- * <p>
- * The protocols can have a logical root node which acts as a container
- * of applications module node. For example in NETCONF, it could be
- * data/filter/config, etc. Protocols needs to pass this parameter in the
- * encode request, so that it is part of the encoded protocol packet.
- * There is no validation done on the value of this parameter. It is up to
- * the protocol to use it. It is a mandatory parameter and protocols must
- * pass this parameter. In protocols like NETCONF, these logical root
- * node may be in a specific name space, in such cases, it needs to be
- * passed to encode it as part of the request. There could be additional
- * tags that can be attached to the root node, for example in NETCONF,
- * the tag type="subtree" can be specified. In such scenarios the
- * required tags should be sent as a parameter.
- * <p>
- * The provider / driver would require to operate on multiple schema
- * nodes in a single request, for example it may be require to configure
- * a tunnel and associate a QOS to this tunnel, in this scenario, it
- * needs to have the tunnel related information in the tunnel module's
- * Java object and and QOS related information in QOS modules Java
- * object. So in a single request, it can send the list of Java objects
- * corresponding to the modules which need to participate in the operation.
- * If the request to be generated needs to be a wild card for no
- * application(s), then this parameter needs to be null. For example a
- * "empty filter" request in NETCONF get request.
- * <p>
- * If the request to be generated needs to be a wild card for all
- * application(s), then the driver / provider should not invoke this API,
- * as there is no encoding of application related information for the
- * operation, it is only limited to the protocol operation. For example a
- * "no filter" request in NETCONF get request.
- *
- * @param rootName name of logical root node as required by
- * the protocol
- * @param rootNamespace namespace of logical root node as
- * required by the protocol encoding. It is
- * an optional parameter.
- * @param tagAttributeLinkedMap Specifies the list of attributes that
- * needs to be tagged with the logical root
- * node. It is an optional parameter
- * if not required for the protocol.
- * @param yangModuleList list of YANG module's object(s)
- * participating in the operation.
- * @param dataFormat data format to which encoding to be done.
- * @param protocolOperation protocol operation being performed
- * @return string containing the requested applications object
- * information encoded in protocol format.
- */
- String encodeOperation(String rootName, String rootNamespace,
- Map<String, String> tagAttributeLinkedMap,
- List<Object> yangModuleList,
- YangProtocolEncodingFormat dataFormat,
- YmsOperationType protocolOperation);
-
- /**
- * When the drivers / providers need to encode protocol composite
- * operation requests, which is split in a composite blocks, this encode
- * composite operation API is used. The application module object
- * containing the request information has both the resource identifier
- * part and the resource information part.
- * <p>
- * The protocols can have a logical root node which acts as a container
- * of applications module node. For example in RESTCONF, it could be
- * RootResource/data, etc. There is no validation done on the value
- * of this parameter. It is up to the protocol to use it. It is a
- * mandatory parameter and protocols must pass this parameter.
- * <p>
- * The resource to be operated upon in the device is identified in a
- * module's schema object. This modules object should contain the
- * information about the resource on which the operation needs to be
- * performed. The resource is identified by initial chain of objects for
- * which operation type is none. Once the resource is reached using none
- * operations, the actual information about the operation on the device
- * is encoded.
- *
- * @param rootName name of logical root node as required by the
- * protocol
- * @param rootNamespace namespace of logical root node as required by
- * the
- * protocol encoding. It is optional, and there
- * is no
- * namespace set to the logical root node
- * @param appModuleObject object containing the information about the
- * resource on which the operation is being
- * performed
- * @param dataFormat data format to which request needs to
- * be encoded
- * @param protocolOperation protocol operation being performed
- * @return the composite protocol operation request.
- */
- YangCompositeEncoding encodeCompositeOperation(String rootName,
- String rootNamespace,
- Object appModuleObject,
- YangProtocolEncodingFormat
- dataFormat,
- YmsOperationType
- protocolOperation);
-
- /**
- * When the driver or provider receive the data from the SBI protocol, It
- * will be in the protocol specific data representation. Drivers /
- * provider need to interact with the device using native JAVA objects.
- * Drivers use this decode method to translate the received
- * protocol specific simple data to YANG modeled Java objects.
- * If the response received is not in line with the schema, for example,
- * there is some error info, etc, then the decode operation will throw an
- * exception and decode operation will fail.
- *
- * @param protocolData input string containing the resource information
- * in protocol format
- * @param dataFormat data format from which decoding has to be done
- * @param protocolOperation protocol operation being performed
- * @return list of applications module/notification objects corresponding
- * to the protocol data input
- */
- List<Object> decode(String protocolData,
- YangProtocolEncodingFormat dataFormat,
- YmsOperationType protocolOperation);
-
- /**
- * When the driver or provider receive the composite data from the SBI
- * protocol, It will be in the protocol specific data representation.
- * Drivers / provider need to interact with the device
- * using native JAVA objects. Drivers use this Decode method to translate
- * the received protocol specific composite data to YANG modeled Java
- * objects.
- * <p>
- * If the response received is not in line with the schema, for example,
- * there is some error info, etc, then the decode operation will throw an
- * exception and decode operation will fail.
- *
- * @param protocolData composite protocol data containing the resource
- * information
- * @param dataFormat data format from which decoding has to be done
- * @param protocolOperation protocol operation being performed
- * @return application module/notification object corresponding to the
- * protocol data infput
- */
- Object decode(YangCompositeEncoding protocolData,
- YangProtocolEncodingFormat dataFormat,
- YmsOperationType protocolOperation);
-
- /**
- * Register the provider / driver specific overridden codec. This is can
- * be used by provider to support any protocol specific extension or
- * vendor specific implementation. This framework can also be used
- * by providers / drivers to support any new protocol data format which
- * is not supported by default in YANG codec utility.
- *
- * @param overriddenCodec provider / driver specific overridden instance
- * of the codec
- * @param dataFormat data format to which encoding to be done.
- */
- void registerOverriddenCodec(YangDataTreeCodec overriddenCodec,
- YangProtocolEncodingFormat dataFormat);
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangCompositeEncoding.java b/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangCompositeEncoding.java
deleted file mode 100644
index 05694ac..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangCompositeEncoding.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ych;
-
-/**
- * Abstraction of an entity which has the composite protocol request.
- * <p>
- * Protocols like RESTCONF, have split the schema specific information across
- * different components in the protocol encoding.
- * <p>
- * There is a resource identifier, which is part of the RESTCONF request URL.
- * and there is the information about the resource being operated on in the
- * request, this is part of the request body.
- */
-public interface YangCompositeEncoding {
-
- /**
- * Retrieves the resource identifier on which the operation is being
- * performed.
- *
- * @return the string representation of the resource being identified
- */
- String getResourceIdentifier();
-
- /**
- * Retrieves the representation format of the resource identifier.
- *
- * @return the type of the resource identifier
- */
- YangResourceIdentifierType getResourceIdentifierType();
-
- /**
- * Retrieves the resource information in the protocol encoding format.
- *
- * @return the resource information in the protocol encoding format
- */
- String getResourceInformation();
-
- /**
- * Sets resource identifier.
- *
- * @param resourceId resource identifier
- */
- void setResourceIdentifier(String resourceId);
-
- /**
- * Sets the resource information.
- *
- * @param resourceInfo resource information
- */
- void setResourceInformation(String resourceInfo);
-
- /**
- * Sets the resource identifier type.
- *
- * @param idType resource identifier
- */
- void setResourceIdentifierType(YangResourceIdentifierType idType);
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangDataTreeCodec.java b/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangDataTreeCodec.java
deleted file mode 100644
index bb52d96..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangDataTreeCodec.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ych;
-
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YmsOperationType;
-
-/**
- * Abstraction of an entity which overrides the default codec.
- * <p>
- * YANG has it extension framework which allows vendor / implementation
- * specific operation or extensions. The default CODECs will fail to handle
- * such protocol requests. In such scenarios, the providers can register
- * their specific CODEC's with the YANG codec utility to translate the protocol
- * specific data to abstract YANG data tree, from which it can be translate into
- * the YANG modelled java objects for the provider / driver to operate on the
- * device.
- */
-
-public interface YangDataTreeCodec {
- /**
- * When the YMS need to encode simple protocol operation request,
- * it will translate the YANG objects into an abstract YANG data tree and
- * invoke this registered encode method. Protocol CODEC implementation
- * needs to ensure the overridden method can handle any specific
- * extension or representation of protocol data.
- * The operation type will be set in YANG data tree builder.
- *
- * @param ydtBuilder Abstract YANG data tree contains the operation
- * request
- * @return protocol specific string representation.
- */
- String encodeYdtToProtocolFormat(YdtBuilder ydtBuilder);
-
- /**
- * When the YMS need to encode composite protocol operation request, it
- * will translate the YANG objects into an abstract YANG data
- * tree and invoke this registered encode method. Protocol CODEC
- * implementation needs to ensure the overridden method can handle any
- * specific extension or representation of protocol data.
- * <p>
- * The Initial chain of node in the YDT will have the operation type set
- * to NONE to specify it is a resource identifier. The Resource
- * information is maintained as a subtree to the resource identifier node.
- *
- * @param ydtBuilder Abstract YANG data tree contains the operation
- * request
- * @return composite response containing the requested operation
- * information
- */
- YangCompositeEncoding encodeYdtToCompositeProtocolFormat(
- YdtBuilder ydtBuilder);
-
- /**
- * When YMS decode simple protocol operation request it uses the
- * registered decode method to translate the protocol data into a
- * abstract YANG data tree. Then translate the abstract YANG data
- * tree into the YANG modeled Java objects.
- * <p>
- * The CODEC implementation are unaware of the schema against which they
- * are performing the codec operation, so YMS will send the schema
- * registry on which the YANG data tree needs to operate, so the code
- * implementation needs to pass this schema registry to the get a YDT
- * builder.
- *
- * @param protocolData input string containing the simple
- * protocol data which needs to be decoded
- * @param schemaRegistryForYdt Schema registry based on which the YANG
- * data tree will be built
- * @param protocolOperation protocol operation being performed
- * @return decoded operation request in YANG data tree
- */
- YdtBuilder decodeProtocolDataToYdt(String protocolData,
- Object schemaRegistryForYdt,
- YmsOperationType protocolOperation);
-
- /**
- * When YMS decode composite protocol operation request it uses the
- * registered decode method to translate the protocol data into a
- * abstract YANG data tree. Then translate the abstract YANG data
- * tree into the YANG modeled Java objects.
- * <p>
- * The CODEC implementation are unaware of the schema against which they
- * are performing the codec operation, so YMS will send the schema
- * registry on which the YANG data tree needs to operate, so the code
- * implementation needs to pass this schema registry to the get a YDT
- * builder.
- *
- * @param protocolData composite input string containing the
- * protocol data which needs to be decoded
- * @param schemaRegistryForYdt Schema registry based on which the YANG
- * data tree will be built
- * @param protocolOperation protocol operation being performed
- * @return decoded operation request in YANG data tree
- */
- YdtBuilder decodeCompositeProtocolDataToYdt(
- YangCompositeEncoding protocolData, Object schemaRegistryForYdt,
- YmsOperationType protocolOperation);
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangProtocolEncodingFormat.java b/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangProtocolEncodingFormat.java
deleted file mode 100644
index 970a642..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangProtocolEncodingFormat.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ych;
-
-/**
- * Represents the protocol data representation.
- */
-public enum YangProtocolEncodingFormat {
- /**
- * XML protocol encoding.
- */
- XML,
-
- /**
- * JSON protocol encoding.
- */
- JSON
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangResourceIdentifierType.java b/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangResourceIdentifierType.java
deleted file mode 100644
index 6b99401..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ych/YangResourceIdentifierType.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ych;
-
-/**
- * Represents the protocol data representation.
- */
-public enum YangResourceIdentifierType {
- /**
- * Uniform Resource Identifier.
- */
- URI
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ych/package-info.java b/apps/yms/api/src/main/java/org/onosproject/yms/ych/package-info.java
deleted file mode 100644
index 81fd788..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ych/package-info.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * In SBI, the provider or driver uses YANG management system as a CODEC
- * utility. These providers/drivers use the YANG codec utility to register
- * the device schema. YANG utils is used to generate the java files
- * corresponding to the device schema. Provider or driver use these classes
- * to seamlessly manage the device as java objects. While sending the request
- * to device, drivers use the utility to translate the objects to protocol
- * specific data representation and then send to the device.
- * Protocol or driver use the same instance of the codec utility across multiple
- * translation request.
- * Protocol or driver should not use the same instance of utility concurrently.
- */
-package org.onosproject.yms.ych;
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/Ydt.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/Ydt.java
deleted file mode 100644
index b185066..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/Ydt.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ydt;
-
-/**
- * Abstraction of an entity which represent YANG data tree. This is used
- * for exchanging information between YANG management system and NBI protocol.
- */
-public interface Ydt {
-
- /**
- * Returns the root context information available in YDT node. This root
- * node is a logical container of a protocol which holds the complete data
- * tree. After building YANG data tree, root node can be obtained from this.
- *
- * @return root YDT context which is logical container of a protocol which
- * is holder of the complete tree
- */
- YdtContext getRootNode();
-
- /**
- * Returns YANG management system operation type. It represents type of
- * root level operation for the request. This is used by protocols to
- * specify the root level operation associated with the request.
- *
- * @return YANG management system operation type
- */
- YmsOperationType getYmsOperationType();
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtBuilder.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtBuilder.java
deleted file mode 100644
index 9cfc695..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtBuilder.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ydt;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Abstraction of an entity which provides interfaces to build and obtain YANG
- * data tree which is data (sub)instance representation, abstract of protocol.
- * <p>
- * NBI protocols need to translate the protocol operation request, into a
- * protocol independent abstract tree called the YANG data tree (YDT). In order
- * to enable the protocol in building these abstract data tree, YANG
- * management system provides a utility called the YANG data tree builder.
- */
-public interface YdtBuilder extends Ydt {
-
- /**
- * Sets root node tag attributes. This is used by protocol
- * to specify tag attributes associated with root resource.
- *
- * @param attributeTag map of root tags attribute values indexed by root
- * tag name
- */
- void setRootTagAttributeMap(Map<String, String> attributeTag);
-
- /**
- * Returns map of tag attribute list associated with root resource.
- *
- * @return linked hash map of tag name with value
- */
- Map<String, String> getRootTagAttributeMap();
-
- /**
- * Adds a last child to YANG data tree; this method is to be used by
- * protocols which are unaware of the nature (single/multiple) of node and
- * also unaware of the operation type at every node (Example: RESTCONF).
- * <p>
- * Add child is used to add module/sub-module nodes also. Request may
- * contain revision number corresponding to Module/sub-module in that
- * case YMS expect revision number to be appended to module/sub-module
- * name in the below mentioned format.
- * <p>
- * module-or-submodule-name ['@' date-arg]
- * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT
- * Example: testModule@2016-10-27.
- * <p>
- * If the revision date is not specified YMS first search for
- * registered module/sub-module without revision date, if still can't obtain
- * then uses registered module/sub-module with latest revision date.
- *
- * @param name name of child to be added
- * @param namespace namespace of child to be added, if it's null, parent's
- * namespace will be applied to child
- * @throws IllegalArgumentException when method has been passed an illegal
- * or inappropriate argument.
- */
- void addChild(String name, String namespace)
- throws IllegalArgumentException;
-
- /**
- * Adds a last child to YANG data tree, this method is to be used by
- * protocols which are aware of the nature (single/multiple) of node.
- * <p>
- * Add child is used to add module/sub-module nodes also. Request may
- * contain revision number corresponding to Module/sub-module in that
- * case YMS expect revision number to be appended to module/sub-module
- * name in the below mentioned format.
- * <p>
- * module-or-submodule-name ['@' date-arg]
- * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT
- * Example: testModule@2016-10-27.
- * <p>
- * If the revision date is not specified YMS first search for
- * registered module/sub-module without revision date, if still can't obtain
- * then uses registered module/sub-module with latest revision date.
- *
- * @param name name of child to be added
- * @param namespace namespace of child to be added, if it's null, parent's
- * namespace will be applied to child
- * @param ydtType type of YDT node to be added
- * @throws IllegalArgumentException when method has been passed an illegal
- * or inappropriate argument.
- */
- void addChild(String name, String namespace, YdtType ydtType)
- throws IllegalArgumentException;
-
- /**
- * Adds a last child to YANG data tree; this method is to be used by
- * protocols which are unaware of the nature (single/multiple) of node.
- * This is an overloaded method with operation type. This method can
- * optionally be used when protocol doesn't want to specify operation type
- * by keeping it null.
- * <p>
- * Add child is used to add module/sub-module nodes also. Request may
- * contain revision number corresponding to Module/sub-module in that
- * case YMS expect revision number to be appended to module/sub-module
- * name in the below mentioned format.
- * <p>
- * module-or-submodule-name ['@' date-arg]
- * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT
- * Example: testModule@2016-10-27.
- * <p>
- * If the revision date is not specified YMS first search for
- * registered module/sub-module without revision date, if still can't obtain
- * then uses registered module/sub-module with latest revision date.
- *
- * @param name name of child to be added
- * @param namespace namespace of child to be added, if it's null, parent's
- * namespace will be applied to child
- * @param opType type of requested operation over a node
- * @throws IllegalArgumentException when method has been passed an illegal
- * or inappropriate argument.
- */
- void addChild(String name, String namespace, YdtContextOperationType opType)
- throws IllegalArgumentException;
-
- /**
- * Adds a last child to YANG data tree; this method is to be used by
- * protocols which are aware of the nature (single/multiple) of node.
- * This is an overloaded method with operation type. This method can
- * optionally be used when protocol doesn't want to specify operation type
- * by keeping it null.
- * <p>
- * Add child is used to add module/sub-module nodes also. Request may
- * contain revision number corresponding to Module/sub-module in that
- * case YMS expect revision number to be appended to module/sub-module
- * name in the below mentioned format.
- * <p>
- * module-or-submodule-name ['@' date-arg]
- * date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT
- * Example: testModule@2016-10-27.
- * <p>
- * If the revision date is not specified YMS first search for
- * registered module/sub-module without revision date, if still can't obtain
- * then uses registered module/sub-module with latest revision date.
- *
- * @param name name of child to be added
- * @param namespace namespace of child to be added, if it's null, parent's
- * namespace will be applied to child
- * @param ydtType type of YDT node to be added
- * @param opType type of requested operation over a node
- * @throws IllegalArgumentException when method has been passed an illegal
- * or inappropriate argument.
- */
- void addChild(String name, String namespace, YdtType ydtType,
- YdtContextOperationType opType)
- throws IllegalArgumentException;
-
- /**
- * Adds a last leaf with value to YANG data tree. Protocols unaware of
- * nature of leaf (single/multiple) will use it to add both single instance
- * and multi instance node. Protocols aware of nature of node will use it
- * for single instance value node addition.
- * Value of leaf can be null which indicates selection node in get
- * operation.
- *
- * @param name name of child to be added
- * @param namespace namespace of child to be added, if it's null, parent's
- * namespace will be applied to child
- * @param value value of the child
- * @throws IllegalArgumentException when method has been passed an illegal
- * or inappropriate argument.
- */
- void addLeaf(String name, String namespace, String value)
- throws IllegalArgumentException;
-
- /**
- * Adds a last leaf with list of values to YANG data tree. This method is
- * used by protocols which knows the nature (single/multiple) of node for
- * multi instance node addition.
- * Value of leaf can be null which indicates selection node in get
- * operation.
- *
- * @param name name of child to be added
- * @param namespace namespace of child to be added, if it's null, parent's
- * namespace will be applied to child
- * @param valueSet list of value of the child
- * @throws IllegalArgumentException when method has been passed an illegal
- * or inappropriate argument.
- */
- void addLeaf(String name, String namespace, Set<String> valueSet)
- throws IllegalArgumentException;
-
- /**
- * Adds a child node or leaf node based on schema.
- *
- * @param name name of child/leaf to be added
- * @param namespace namespace of child/leaf to be added, if it's null, parent's
- * namespace will be applied to child
- * @throws IllegalArgumentException when method has been passed an illegal
- * or inappropriate argument.
- */
- void addNode(String name, String namespace)
- throws IllegalArgumentException;
-
- /**
- * Adds an instance of a child list node, or adds a child leaf list with
- * multiple instance.
- * In case the name and namespace identifies the child list node, then
- * the values for all the key leaves must be passed in the same order of
- * schema. Then the effective YANG data tree will be like adding a list
- * node, followed by adding the key leaves as the child to the list node.
- * After this operation, the call to getCurNode will return the list node.
- * In case the name and namespace identifies the child leaf-list, then
- * the values identifies the instance of leaf list.
- * After this operation, the call to getCurNode will return the leaf-list
- * node.
- *
- * @param name name of child to be added
- * @param namespace namespace of child to be added, if it's null, parent's
- * namespace will be applied to child
- * @param valueList values of the keys in URI in the same order
- * as defined in YANG file
- * @param opType type of requested operation over a node
- * @throws IllegalArgumentException when method has been passed an illegal
- * or inappropriate argument.
- */
- void addMultiInstanceChild(String name, String namespace,
- List<String> valueList,
- YdtContextOperationType opType)
- throws IllegalArgumentException;
-
- /**
- * Traverses up in YANG data tree to the parent node, it is to be used when
- * protocol is using context type "current" and wanted to traverse up the
- * tree.
- *
- * @throws IllegalStateException when application is not in an appropriate
- * state for the requested operation.
- */
- void traverseToParent() throws IllegalStateException;
-
- /**
- * Returns the current context information available in YDT node.
- *
- * @return current YDT context
- */
- YdtContext getCurNode();
-
- /**
- * Sets default operation type. This operation type is taken if operation
- * type is not explicitly specified in request. If default operation type
- * is not set, merge will be taken as default operation type.
- *
- * @param ydtContextOperationType default edit operation type
- */
- void setDefaultEditOperationType(
- YdtContextOperationType ydtContextOperationType);
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtContext.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtContext.java
deleted file mode 100644
index d2cdead..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtContext.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ydt;
-
-import java.util.Set;
-
-/**
- * Abstraction of an entity which represents YANG data tree context
- * information. This context information will be used protocol to obtain
- * the information associated with YDT node. This is used when protocol is
- * walking the data tree in both visitor and listener mechanism.
- */
-public interface YdtContext {
-
- /**
- * Returns the node name.
- *
- * @return node name
- */
- String getName();
-
- /**
- * Returns the node namespace.
- *
- * @return node namespace
- */
- String getNamespace();
-
- /**
- * Returns module name as namespace.
- *
- * @return module name
- */
- String getModuleNameAsNameSpace();
-
- /**
- * Returns the YDT node extended context information corresponding to YDT
- * node.
- *
- * @param <T> specifies YMS operation specific extended information
- * associated with YDT context. It will be
- * YdtContextOperationType in case extended information type
- * is EDIT_REQUEST and will be YdtContextResponseInfo in case
- * extended information type is RESPONSE.
- * @return YdtContextOperationType YDT node operation type
- */
- <T> T getYdtContextExtendedInfo();
-
- /**
- * Returns YANG data tree extended information type. This is used to
- * identify the type of extended information applicable for YDT node.
- *
- * @return type of extended information
- */
- YdtExtendedInfoType getYdtExtendedInfoType();
-
- /**
- * Returns the type of YDT entity. This type will be used by protocols to
- * identify the nature of node and can implement it accordingly.
- *
- * @return YDT entity type
- */
- YdtType getYdtType();
-
- /**
- * Returns the context of parent node.
- *
- * @return context of parent node
- */
- YdtContext getParent();
-
- /**
- * Returns the context of first child.
- *
- * @return context of first child
- */
- YdtContext getFirstChild();
-
- /**
- * Returns the context of last child.
- *
- * @return context of last child
- */
- YdtContext getLastChild();
-
- /**
- * Returns the context of next sibling.
- *
- * @return context of next sibling
- */
- YdtContext getNextSibling();
-
- /**
- * Returns the context of previous sibling.
- *
- * @return context of previous sibling
- */
- YdtContext getPreviousSibling();
-
- /**
- * Returns value of node, this is only valid for single instance leaf
- * node, to obtain the nature of the node protocols need to use
- * getYdtType().
- *
- * @return value of node
- */
- String getValue();
-
- /**
- * Returns set of values of a node, this is only valid for multi instance
- * leaf node, to obtain the nature of the node protocols need to use
- * getYdtType().
- *
- * @return value of YDT leaf
- */
- Set<String> getValueSet();
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtContextOperationType.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtContextOperationType.java
deleted file mode 100644
index 8445d3c..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtContextOperationType.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ydt;
-
-/**
- * Represents type of YANG data tree node operation.
- *
- * This is used by protocols to specify edit operation associate with the node.
- * YMS data validation and data handling will vary based on the edit operation
- * type, for an instance, default leafs if not present in data should be added
- * if edit operation type is create and shouldn't be added if operation type is
- * delete.
- * Edit operation type is mapped to "operation type" of YANG utils generated
- * classes by YMS.
- *
- * In case of SBI driver/provider creates JAVA object (of YANG utils generated
- * classes) and specifies the edit operation type in "operation type" field.
- * YMS map this operation type to "edit operation type" of YDT, which will be
- * further encoded in corresponding data format.
- *
- * This is only applicable if YANG root level interaction type is EDIT_CONFIG.
- * If edit operation type is not specified when root interaction type is
- * EDIT_CONFIG then default operation type will be selected.
- * By default "default operation type" is "merge" unless explicitly specified
- * by protocol.
- */
-
-/*
- * Edit operation type mapping with RESTCONF and NETCONF as example:
- * +----------+----------------------------+------------+
- * | RESTCONF | NETCONF | EditOpType |
- * +----------+----------------------------+------------+
- * | OPTIONS | none | NA |
- * | HEAD | none | NA |
- * | GET | <get-config>, <get> | NA |
- * | POST | (operation="create") | CREATE |
- * | PUT | (operation="replace") | REPLACE |
- * | PATCH | (operation="merge") | MERGE |
- * | DELETE | (operation="delete") | DELETE |
- * | none | (operation="remove") | REMOVE |
- * +----------+----------------------------+------------+
- * Note: Additionally RESTCONF must use API resource to figure out whether
- * request contains data resource or it's for data model specific operation.
- * +--rw restconf
- * +--rw data
- * +--rw operations
- * Edit operation type is only applicable for data resource.
- *
- * Additionally protocols has to use operation type NONE to specify the URI
- * path.
- */
-public enum YdtContextOperationType {
-
- /**
- * Type of YANG data tree action for below action:
- * The configuration data identified by the element
- * containing this attribute is added to the configuration if
- * and only if the configuration data does not already exist in
- * the configuration datastore. If the configuration data
- * exists, an error is returned.
- */
- CREATE,
-
- /**
- * Type of YANG data tree action for below action:
- * The configuration data identified by the element
- * containing this attribute is deleted from the configuration
- * if and only if the configuration data currently exists in
- * the configuration datastore. If the configuration data does
- * not exist, an error is returned".
- */
- DELETE,
-
- /**
- * Type of YANG data tree action for below action:
- * The configuration data identified by the element
- * containing this attribute is merged with the configuration
- * at the corresponding level in the configuration datastore.
- */
- MERGE,
-
- /**
- * Type of YANG data tree action for below action:
- * The configuration data identified by the element
- * containing this attribute replaces any related configuration
- * in the configuration datastore. If no such configuration
- * data exists in the configuration datastore, it is created.
- */
- REPLACE,
-
- /**
- * Type of YANG data tree action for below action:
- * The configuration data identified by the element
- * containing this attribute is deleted from the configuration
- * if the configuration data currently exists in the
- * configuration datastore. If the configuration data does not
- * exist, the "remove" operation is silently ignored by the
- * server.
- */
- REMOVE,
-
- /**
- * The node is used as a containment node to reach the child node,
- * There is no change in the data store for the values of this node in the
- * edit request.
- */
- NONE
-}
-
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtContextResponseInfo.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtContextResponseInfo.java
deleted file mode 100644
index e90fe43..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtContextResponseInfo.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ydt;
-
-/**
- * Represents YANG context response information. It contains YDT node specific
- * information for operation response like error information, particular node
- * operation result etc.
- */
-public interface YdtContextResponseInfo {
-
- /**
- * Retrieve the context specific error information.
- *
- * @return context specific error information
- */
- YdtErrorInfo getYdtErrorInfo();
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtErrorInfo.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtErrorInfo.java
deleted file mode 100644
index e814d8e..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtErrorInfo.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ydt;
-
-/**
- * Abstraction of an entity which contains context specific error info.
- */
-public interface YdtErrorInfo {
- /**
- * Retrieves the application specific error tag corresponding to the
- * error context in operation.
- *
- * @return application specific error tag corresponding to the error
- * context in operation
- */
- String getErrorAppTag();
-
- /**
- * Retrieves the error message corresponding to the error context in
- * operation.
- *
- * @return the error message corresponding to the error context in operation
- */
- String getErrorMessage();
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtExtendedInfoType.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtExtendedInfoType.java
deleted file mode 100644
index ceb556c..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtExtendedInfoType.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ydt;
-
-/**
- * Represents type of YANG data tree node operation.
- */
-public enum YdtExtendedInfoType {
-
- /**
- * It specifies operation type edit request for YDT node. It is used to
- * identify the YMS operation specific extended information associated
- * with YDT context.
- */
- EDIT_REQUEST,
-
- /**
- * It specifies operation type RESPONSE for YDT node. It is used to
- * identify the YMS operation specific extended information associated
- * with YDT context.
- */
- RESPONSE
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtListener.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtListener.java
deleted file mode 100644
index 33c1a52..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtListener.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ydt;
-
-/**
- * Abstraction of an entity which provide call back methods which are called
- * by YDT walker while walking the YANG data tree.
- * <p>
- * In a response to execute operation YMS returns the YMS operation results
- * with root YDT node. Now, protocols needs to walk through the YDT node and
- * constructs the corresponding data format string. Protocol can opt to use
- * listener or visitor based walking mechanism.
- * <p>
- * This interface needs to be implemented by protocol implementing listener's
- * based call backs while YDT walk.
- */
-public interface YdtListener {
-
- /**
- * YANG data tree node's entry, it will be called during a node entry.
- * All the related information about the node can be obtain from the YDT
- * context.
- *
- * @param ydtContext YANG data tree context
- */
- void enterYdtNode(YdtContext ydtContext);
-
- /**
- * YANG data tree node's exit, it will be called during a node exit.
- * All the related information about the node can be obtain from the YDT
- * context.
- *
- * @param ydtContext YANG data tree context
- */
- void exitYdtNode(YdtContext ydtContext);
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtResponse.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtResponse.java
deleted file mode 100644
index 308cdf3..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtResponse.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ydt;
-
-/**
- * Represents YANG management system results. Protocols sends request to
- * YANG management system for execution. YMS returns response in form of
- * YANG data tree response
- */
-public interface YdtResponse extends Ydt {
-
- /**
- * Returns YANG management system operation result. This status of the
- * operation execution is returned
- *
- * @return YMS operation result
- */
- YmsOperationExecutionStatus getYmsOperationResult();
-
- /*
- * TODO: Applications layer error reporting to protocols.
- */
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtType.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtType.java
deleted file mode 100644
index 5efd67f..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtType.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ydt;
-
-/**
- * Represents type of node in YANG data tree. Protocols based on input data
- * format provide this information to YMS during YDT building. YMS use this
- * information to carry out the validation against the schema information
- * obtained as a part of application registration. Also as a part of response
- * YMS encode this information in YDT node, protocol may use this information
- * while construction the data format string.
- *
- * Protocols unaware of node type like NETCONF, may opt not to provide this
- * information.
- */
-public enum YdtType {
-
- /**
- * Single instance node.
- */
- SINGLE_INSTANCE_NODE,
-
- /**
- * Multi instance node.
- */
- MULTI_INSTANCE_NODE,
-
- /**
- * Single instance leaf node.
- */
- SINGLE_INSTANCE_LEAF_VALUE_NODE,
-
- /**
- * Multi instance leaf node.
- */
- MULTI_INSTANCE_LEAF_VALUE_NODE,
-
- /**
- * Logical root node.
- */
- LOGICAL_ROOT_NODE
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtWalker.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtWalker.java
deleted file mode 100644
index e17d790..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YdtWalker.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ydt;
-
-/**
- * Abstraction of an entity which provides interfaces for YDT walk.
- *
- * When YANG management system gets data from application to be returned
- * to protocol for any protocol operation or as a part of notification, YANG
- * management system encodes this data in a YANG data tree and sends the same
- * to protocol.
- * Protocols can use the YANG data tree walker utility to have their
- * callbacks to be invoked as per the YANG data tree walking.
- * By this way protocols can encode the data from abstract YANG data tree
- * into a protocol specific representation.
- *
- * YDT walker provides entry and exit callbacks for each node in YANG data
- * tree.
- */
-public interface YdtWalker {
-
- /**
- * Walks the YANG data tree. Protocols implements YDT listener service
- * and walks YDT tree with input as implemented object. YDT walker provides
- * call backs to implemented methods.
- *
- * @param ydtListener YDT listener implemented by the protocol
- * @param rootNode root node of YDT
- */
- void walk(YdtListener ydtListener, YdtContext rootNode);
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YmsOperationExecutionStatus.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YmsOperationExecutionStatus.java
deleted file mode 100644
index 14f4ba4..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YmsOperationExecutionStatus.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ydt;
-
-/**
- * Abstraction of an entity which represents YANG management system operation
- * result. Once the protocol translates the request information into a abstract
- * YANG data tree, it uses YANG management system as a broker to get the
- * operation executed in ONOS. Protocols uses a request Yang management
- * system to delegate the operation request.
- *
- * YANG management system is responsible to split the protocol operation
- * across application(s) which needs to participate, and collate the
- * response(s) from application(s) and return an effective result of the
- * operation request. The status of the operation execution is returned.
- */
-public enum YmsOperationExecutionStatus {
-
- /**
- * Successful execution of the operation.
- */
- EXECUTION_SUCCESS,
-
- /**
- * Exception in execution of the operation.
- */
- EXECUTION_EXCEPTION,
-
- /**
- * Error in execution of the operation.
- */
- ERROR_EXCEPTION
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YmsOperationType.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YmsOperationType.java
deleted file mode 100644
index bfbee0c..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/YmsOperationType.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ydt;
-
-/**
- * Represents type of root level operation for the request.
- *
- * This is used by protocols to specify the root level operation associated
- * with the request. YMS data validation and data handling will vary based
- * on the edit operation type, for an instance YANG specified "mandatory"
- * leafs needn't be present for QUERY_CONFIG and QUERY, but they may be
- * mandatory to be present in request for EDIT_CONFIG type. The validation
- * and handling is further dependent on edit operation type.
- *
- * In SBI, driver/provider must provide this information to YMS which needs
- * to encode this information in corresponding data format.
- *
- * YmsOperationType MUST be specified by protocol.
- */
-
-/*
- * Yang interaction type with RESTCONF and NETCONF as example:
- * +--------------+-------------------+-------------+
- * | RESTCONF | NETCONF | EditOpType |
- * +--------------+-------------------+-------------+
- * | OPTIONS | NA | NA |
- * | HEAD | NA | NA |
- * | GET | <get> | QUERY |
- * | none | <get-config> | QUERY_CONFIG|
- * | POST (data) | <edit-config> | EDIT_CONFIG |
- * | PUT | <edit-config> | EDIT_CONFIG |
- * | PATCH | <edit-config> | EDIT_CONFIG |
- * | DELETE | <edit-config> | EDIT_CONFIG |
- * | POST (op) | <rpc> | RPC |
- * +--------------+-------------------+-------------+
- *
- * Note: Additionally RESTCONF must use API resource to figure out whether
- * request contains data resource or it's for data model specific operation.
- * +--rw restconf
- * +--rw data
- * +--rw operations
- */
-public enum YmsOperationType {
- /**
- * The YANG based request is to edit a config node / subtree in the data
- * store.
- */
- EDIT_CONFIG_REQUEST,
-
- /**
- * The YANG based request is to query a config node / subtree in the data
- * store.
- */
- QUERY_CONFIG_REQUEST,
-
- /**
- * The YANG based request is to query a node / subtree in the data store.
- */
- QUERY_REQUEST,
-
- /**
- * The YANG based request is to execute an RPC defined in YANG.
- */
- RPC_REQUEST,
-
- /**
- * The YANG based response is for edit operation.
- */
- EDIT_CONFIG_REPLY,
-
- /**
- * The YANG based response is for query config operation.
- */
- QUERY_CONFIG_REPLY,
-
- /**
- * The YANG based response is for query operation.
- */
- QUERY_REPLY,
-
- /**
- * The YANG based response is for a RPC operation.
- */
- RPC_REPLY,
-
- /**
- * The YANG based request is to execute an RPC defined in YANG.
- */
- NOTIFICATION
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/package-info.java b/apps/yms/api/src/main/java/org/onosproject/yms/ydt/package-info.java
deleted file mode 100644
index 2c60fd8..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ydt/package-info.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides interfaces to build and obtain YANG data tree which is data
- * (sub)instance representation, abstract of protocol.
- *
- * NBI protocol implementation takes care of the protocol specific
- * operations. They are abstracted from the intricacies of understanding
- * the application identification or handling the interaction with
- * applications.
- *
- * NBI protocols need to handle the encoding and decoding of data to the
- * protocol specific format. They are unaware of the YANG of applications,
- * i.e. protocols are unaware of the data structure / organization in
- * applications.
- *
- * They need to translate the protocol operation request, into a protocol
- * independent abstract tree called the YANG data tree (YDT). In order to
- * enable the protocol in building these abstract data tree, YANG
- * management system provides a utility called the YANG data tree builder.
- *
- * Using the YANG data tree utility API's protocols are expected to walk
- * the data received in request and pass the information during the walk.
- * YANG data tree builder, identifies the application which supports the
- * request and validates it against the schema defined in YANG, and
- * constructs the abstract YANG data tree.
- */
-package org.onosproject.yms.ydt;
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ymsm/YmsService.java b/apps/yms/api/src/main/java/org/onosproject/yms/ymsm/YmsService.java
deleted file mode 100644
index 72eb8ff..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ymsm/YmsService.java
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ymsm;
-
-import java.util.List;
-
-import org.onosproject.yms.ych.YangCodecHandler;
-import org.onosproject.yms.ych.YangDataTreeCodec;
-import org.onosproject.yms.ych.YangProtocolEncodingFormat;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtResponse;
-import org.onosproject.yms.ydt.YdtWalker;
-import org.onosproject.yms.ydt.YmsOperationType;
-import org.onosproject.yms.ynh.YangNotificationService;
-import org.onosproject.yms.ysr.YangModuleIdentifier;
-import org.onosproject.yms.ysr.YangModuleLibrary;
-
-/**
- * Abstraction of an entity which provides interfaces to YANG management
- * system. YMS is a core of YANG in ONOS.
- *
- * In NBI, it acts as a broker in between the protocol and application,
- * here there is a separate protocol implementation, which does the conversion
- * of protocol representation to abstract data tree. The protocol
- * implementation takes care of the protocol specific actions for
- * e.g. RESTCONF handling the entity-tag / timestamp related operations.
- *
- * In SBI, driver or provider uses YANG codec handler as a utility to translate
- * the request information in java(YANG utils generated) to protocol specific
- * format and vice versa.
- */
-public interface YmsService {
-
- /**
- * Returns YANG data tree builder.
- *
- * NBI protocol implementation takes care of the protocol specific
- * operations. They are abstracted from the intricacies of understanding
- * the application identification or handling the interaction with
- * applications.
- *
- * NBI protocols need to handle the encoding and decoding of data to the
- * protocol specific format. They are unaware of the YANG of applications,
- * i.e. protocols are unaware of the data structure / organization in
- * applications.
- *
- * They need to translate the protocol operation request, into a protocol
- * independent abstract tree called the YANG data tree (YDT). In order to
- * enable the protocol in building these abstract data tree, YANG
- * management system provides a utility called the YANG data tree builder.
- *
- * Using the YANG data tree utility API's protocols are expected to walk
- * the data received in request and pass the information during the walk.
- * YANG data tree builder, identifies the application which supports the
- * request and validates it against the schema defined in YANG, and
- * constructs the abstract YANG data tree.
- *
- * Interaction type is a MANDATORY parameter which is used by YANG
- * management system to perform the required operation in ONOS.
- *
- * NOTE: Same YDT builder instance cannot be reused across different
- * operation request. A new instance needs to be used for every operation.
- *
- * Returns YANG data tree builder logical root container node.
- * Protocol use this to logical root container to hold schema specific data
- * that spans across different modules schema.
- *
- * @param logicalRootName name of a protocol specific logical container
- * node to group data across multiple applications.
- * This is only a logical container to group more
- * than one application's root node. It is not
- * validated against any YANG definition
- * @param rootNamespace namespace of logical root container, if any,
- * otherwise it can be sent as null
- * @param operationType maps the request type to a corresponding
- * operation request type to YANG management system
- * @return YANG data tree builder, using which the abstract tree can be
- * built corresponding to the data exchanged between protocol and YANG
- * management system.
- */
- YdtBuilder getYdtBuilder(String logicalRootName, String rootNamespace,
- YmsOperationType operationType);
-
- /**
- * Returns YANG data tree builder attached with a given schema registry.
- *
- * YMS provides a framework where-in protocols can register their protocol
- * data format specific CODECS with YMS. These registered CODEC will be
- * used by YMS to perform translations from data format to YDT and YDT to
- * data format. YMS may intend to use these CODECS both for NBI and SBI.
- *
- * To perform decode i.e. generate YDT for given data format string, these
- * CODECS implementation needs to call the API's of YDT. YDT referred the
- * registered schema information while building tree. In case of NBI their
- * is a single schema registry, but for SBI schema registry is per
- * driver/provider.
- *
- * Now this schema registry information is provided to protocols
- * CODECS while invoking "decodeProtocolDataToYdt" and
- * "decodeCompositeProtocolDataToYdt", protocol CODECS needs to provide
- * the schema registry while getting instance of YDT builder.
- * The schemaRegistry may be null when the YMS is performing decode for NBI
- * protocols.
- *
- * Validations for NBI and SBI will vary, schemaRegistry value will also
- * indicate the usage scenario and will be used by YdtBuilder to carry out
- * necessary validations.
- *
- * This is an overloaded method to YdtBuilder which MUST be used by the
- * overridden protocols CODECS.
- *
- * @param logicalRootName name of a protocol specific logical container
- * node to group data across multiple
- * applications.
- * This is only a logical container to group
- * more
- * than one application's root node. It is not
- * validated against any YANG definition
- * @param rootNamespace namespace of logical root container, if any,
- * otherwise it can be sent as null
- * @param operationType maps the request type to a corresponding
- * operation request type to YANG management
- * system
- * @param schemaRegistryForYdt schema registry for Ydt, protocol CODECS get
- * this value from YMS in
- * "decodeProtocolDataToYdt" and
- * "decodeCompositeProtocolDataToYdt" and
- * provide it while obtaining YdtBuilder
- * @return YANG data tree builder, using which the abstract tree can be
- * built corresponding to the data exchanged between protocol and YANG
- * management system.
- */
- YdtBuilder getYdtBuilder(String logicalRootName, String rootNamespace,
- YmsOperationType operationType,
- Object schemaRegistryForYdt);
-
- /**
- * Returns YANG data tree walker.
- *
- * YANG management system gets data from application to be returned
- * in protocol operation or to notify to protocol(s) clients, YANG
- * management system encodes the data in a YANG data tree and informs the
- * protocol.
- * Protocols can use the YANG data tree walker utility to have their
- * callbacks to be invoked as per the YANG data tree walking.
- * By this way protocols can encode the data from abstract YANG data tree
- * into a protocol specific representation.
- *
- * @return YANG data tree walker utility
- */
- YdtWalker getYdtWalker();
-
- /**
- * Once the NBI protocol translates the request information into an abstract
- * YANG data tree, it uses YANG management system as a broker to get the
- * operation executed in ONOS.
- *
- * YANG management system is responsible to split the protocol operation
- * across application(s) which needs to participate, and collate the
- * response(s) from application(s) and return an effective result of the
- * operation request.
- *
- * YMS identifies the type of operation to be performed using the
- * operation type in YANG builder data tree and process the corresponding
- * operation request on the applicable application(s).
- * The response information maintained in response YANG data tree and
- * given to NBI protocol's to encode it using a YANG data tree walker.
- *
- * Depending on the operation type set in the YANG builder tree, the
- * application(s) get / set / operation interface is invoked.
- * These interface are part to the YANG modelled service interface.
- * Depending on the operation type, the YANG response data tree can have
- * the following information.
- *
- * In case of EDIT_CONFIG operation, it will have the status of the
- * operation execution. If there is any applications schema specific
- * error, then the schema error information will be encoded in the
- * corresponding context node. In case the edit operation is successful
- * there is no YANG response data tree created, hence getRootNode will
- * return null.
- *
- * In case of query operation, it will have the status of the operation
- * execution. If there is any application schema specific error, then
- * schema error information will be encoded in the corresponding YANG
- * context. In case the query operation is successful, YANG data tree
- * contains the application data that matched the filter in the
- * operation request. NBI protocol to use a Yang data tree walker to
- * construct the protocol specific reply.
- *
- * In case of RPC operation, it will have the status of the operation
- * execution. If there is any application schema specific error, then
- * schema error information will be encoded in the corresponding YANG
- * context. In case the RPC operation is successful, and the RPC
- * does not have any RPC reply in YANG, then the YANG data tree will
- * be null.
- * In case the RPC has a RPC reply in YANG, then the YANG data tree
- * will contain the application's RPC reply schema specific .
- * NBI protocol to use a Yang data tree walker to construct the
- * protocol specific reply.
- *
- * @param operationRequest operation request that was constructed
- * by NBI protocol using YANG data tree
- * builder. This operation request contains
- * operation request that needs to be
- * executed on the applicable application(s)
- * @return returns the result of the operation execution.
- */
- YdtResponse executeOperation(YdtBuilder operationRequest);
-
- /* TODO add execute operation which directly take data format string as
- input.*/
-
- /**
- * Returns YANG notification service.
- *
- * NBI Protocols which can support notification delivery for application(s)
- * needs to add themselves as a listeners with YANG notification service.
- * Also protocols can use YANG notification service to check if a received
- * notification should be filtered against any of their protocol specific
- * filtering mechanism.
- *
- * @return YANG notification service instance
- */
- YangNotificationService getYangNotificationService();
-
- /**
- * Registers service with YANG management system.
- *
- * Applications model their exposed interface in YANG, and register with
- * YANG management system, so that it can be configured / managed by the
- * set of protocols supported in ONOS.
- *
- * ONOS YANG tools generate the applications service interface
- * corresponding to the application's interface designed in YANG.
- *
- * The Application which implements this service registers the generated
- * service with YANG management system. The generated service interfaces
- * have all the information modeled by applications in YANG.
- *
- * Registers application's YANG model with YANG management system. This
- * is used by applications/core to register their service with YMS.
- *
- * @param appManager application manager instance which is
- * implementing the service defined in YANG.
- * @param yangService service interface generated by ONOS YANG
- * tools corresponding to the interface modeled
- * in YANG.
- * @param supportedFeatureList mentions the list of YANG features supported
- * by the application implementation.
- * If it is null, then the application
- * implementation supports all the features
- * defined in the registered YANG module.
- */
- void registerService(Object appManager, Class<?> yangService,
- List<String> supportedFeatureList);
-
- /**
- * Unregisters service which is registered in YANG management system.
- *
- * Applications model their exposed interface in YANG, and register with
- * YANG management system, so that it can be configured / managed by the
- * set of protocols supported in ONOS.
- *
- * ONOS YANG tools generate the applications service interface
- * corresponding to the application's interface designed in YANG.
- *
- * The Application which implements this service registers the generated
- * service with YANG management system. The generated service interfaces
- * have all the information modeled by applications in YANG.
- *
- * Registers application's YANG model with YANG management system. This
- * is used by applications/core to register their service with YMS.
- *
- * @param appManager application manager instance which is implementing
- * the service defined in YANG.
- * @param yangService service interface generated by ONOS YANG tools
- * corresponding to the interface modeled in YANG.
- */
- void unRegisterService(Object appManager, Class<?> yangService);
-
- /**
- * Protocols like RESTCONF, share the list of YANG modules it support.
- * using ietf-yang-library
- *
- * Retrieves the YANG module library supported by the server.
- *
- * @return YANG module library supported by the server
- */
- YangModuleLibrary getYangModuleLibrary();
-
- /**
- * Protocols like RESTCONF, use the definitions within the YANG modules
- * advertised by the server are used to construct an RPC operation or
- * data resource identifier.
- *
- * Schema Resource:
- * The server can optionally support retrieval of the YANG modules it
- * supports.
- *
- *
- * @param moduleIdentifier module's identifier
- * @return YANG file contents of the requested YANG module.
- */
- String getYangFile(YangModuleIdentifier moduleIdentifier);
-
- /**
- * Register protocol specific default CODEC. This is can be used by 1st
- * protocol
- * to support a protocol format CODEC. This CODEC will be used in both
- * NBI and SBI.
- *
- * @param defaultCodec default codec to be used for a particular protocol
- * data format
- * @param dataFormat data format to which encoding to be done.
- * Currently XML and
- * JSON formats are supported.
- */
- void registerDefaultCodec(YangDataTreeCodec defaultCodec,
- YangProtocolEncodingFormat dataFormat);
-
- /**
- * Returns YANG codec handler utility.
- *
- * In SBI, the provider or driver uses YANG management system as a CODEC
- * utility. These providers/drivers use the YANG codec utility to register
- * the device schema. YANG utils is used to generate the java files
- * corresponding to the device schema. Provider or driver use these classes
- * to seamlessly manage the device as java objects. While sending the
- * request
- * to device, drivers use the utility to translate the objects to protocol
- * specific data representation and then send to the device.
- * Protocol or driver use the same instance of the codec utility across
- * multiple
- * translation request.
- * Protocol or driver should not use the same instance of utility
- * concurrently.
- *
- * @return YANG codec utility
- */
- YangCodecHandler getYangCodecHandler();
-
- // TODO exceptions handling and sending.
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ymsm/package-info.java b/apps/yms/api/src/main/java/org/onosproject/yms/ymsm/package-info.java
deleted file mode 100644
index 1639b3b..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ymsm/package-info.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides interfaces to YANG application management system manager. YMSM is
- * manager of the YANG Core.
- *
- * In NBI, it acts as a broker in between the protocol and application,
- * here there is a separate protocol implementation, which does the conversion
- * of protocol representation to abstract data tree. The protocol
- * implementation takes care of the protocol specific actions for
- * e.g. RESTCONF handling the entity-tag / timestamp related operations.
- *
- * In SBI, driver or provider uses YANG codec handler as a utility to translate
- * the request information in java(YANG utils generated) to protocol specific
- * format and vice versa.
- */
-package org.onosproject.yms.ymsm;
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ynh/YangNotification.java b/apps/yms/api/src/main/java/org/onosproject/yms/ynh/YangNotification.java
deleted file mode 100644
index 3ae2571..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ynh/YangNotification.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ynh;
-
-import org.onosproject.yms.ydt.YdtContext;
-
-/**
- * Represents YANG notification which is a subject of YANG based event.
- *
- * YMS add themselves as a listener to applications. Application sends
- * their notification in YANG utils generated notification. YMS obtains
- * the module/sub-module schema tree in which this notification is contained
- * and then convert this data to an abstract tree notation (YDT) with root
- * node as the logical node with name "yangnotification" it contains
- * module/sub-module node in which notification is contained.
- * It sends the same to all the protocol who has added them as a listener
- * as a YANG notification.
- *
- * This class represents YANG notification which contains the
- * notification context in abstract tree notation.
- */
-public class YangNotification {
-
- /**
- * YANG notification in form of abstract tree notation (YDT)
- * Root node of notification root context will be logical node with
- * name as "yangnotification", it contains module/sub-module node
- * in which notification is contained.
- */
- YdtContext notificationRootContext;
-
- /**
- * Creates an instance of YANG notification subject.
- *
- * @param notificationContext logical root node with name as
- * "yangnotification"
- */
- public YangNotification(YdtContext notificationContext) {
- this.notificationRootContext = notificationContext;
- }
-
- /**
- * Assign the YANG modeled notification data.
- *
- * @param notificationRootContext YANG data tree containing the data for
- * the notification
- */
- public void setNotificationRootContext(YdtContext notificationRootContext) {
- this.notificationRootContext = notificationRootContext;
- }
-
- /**
- * Returns YANG notification data.
- *
- * @return YANG data tree containing the data for the notification
- */
- public YdtContext getNotificationRootContext() {
- return notificationRootContext;
- }
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ynh/YangNotificationEvent.java b/apps/yms/api/src/main/java/org/onosproject/yms/ynh/YangNotificationEvent.java
deleted file mode 100644
index 6009fc9..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ynh/YangNotificationEvent.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.yms.ynh;
-
-import org.onosproject.event.AbstractEvent;
-
-/**
- * Represents YANG notification event.
- *
- * YANG notification handler listens for the notification from the application.
- * It convert the received notification in YANG notification events.
- *
- * YangNotificationEvent represents event generated by YANG management system
- * in response to the YANG defined application notification. The applications
- * notification information is in abstract YANG data tree.
- */
-public class YangNotificationEvent
- extends AbstractEvent<YangNotificationEvent.Type, YangNotification> {
-
- /**
- * Event type is the notification as defined in the YANG file.
- */
- public enum Type {
- /**
- * Indicates a YANG notification.
- */
- YANG_NOTIFICATION
- }
-
- /**
- * YANG notification information shared to NBI protocol in YANG data tree
- * using the registered callback.
- *
- * @param subject notification information in YANG data tree.
- */
- public YangNotificationEvent(YangNotification subject) {
- super(Type.YANG_NOTIFICATION, subject);
- }
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ynh/YangNotificationListener.java b/apps/yms/api/src/main/java/org/onosproject/yms/ynh/YangNotificationListener.java
deleted file mode 100644
index fa47eac..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ynh/YangNotificationListener.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.yms.ynh;
-
-import org.onosproject.event.EventListener;
-
-/**
- * Abstraction of listener for YANG notification handler events.
- * NBI protocols/interfaces supporting YANG notification needs to implement
- * YANG notification listener and add themselves as a listener to YANG
- * notification event.
- */
-public interface YangNotificationListener
- extends EventListener<YangNotificationEvent> {
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ynh/YangNotificationService.java b/apps/yms/api/src/main/java/org/onosproject/yms/ynh/YangNotificationService.java
deleted file mode 100644
index f1f68a5..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ynh/YangNotificationService.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ynh;
-
-import org.onosproject.event.ListenerService;
-
-/**
- * Abstraction of an entity which provides interfaces to YANG notification
- * service. YANG notification handler receives the event notifications from
- * application/core and provide it to the protocols.
- *
- * NBI Protocols which can support notification delivery for application(s)
- * needs to add themselves as a listeners with YANG notification service.
- * Also based on registered schema YMS add themselves as a listener to
- * applications. Application sends their notification in YANG utils generated
- * notification. YMS obtains the module/sub-module schema tree in which this
- * notification is contained and then convert this data to an abstract tree
- * notation (YDT) with root node as the module/sub-module node in which
- * notification is contained. It sends the same to all the protocol who has
- * added them as a listener as a YANG notification.
- *
- * Also Protocols can use YANG notification service to check if a received
- * notification should be filtered against any of their protocol specific
- * filtering mechanism.
- */
-public interface YangNotificationService
- extends ListenerService<YangNotificationEvent,
- YangNotificationListener> {
-
- /*
- * Example of a use case of notification filtering.
- * The following example illustrates how to select fault events which
- * have severities of critical, major, or minor. The filtering criteria
- * evaluation is as follows:
- *
- * ((fault & severity=critical) | (fault & severity=major) | (fault &
- * severity=minor))
- *
- * <netconf:rpc netconf:message-id="101"
- * xmlns:netconf="urn:ietf:params:xml:ns:netconf:base:1.0">
- * <create-subscription
- * xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
- * <filter netconf:type="subtree">
- * <event xmlns="http://example.com/event/1.0">
- * <eventClass>fault</eventClass>
- * <severity>critical</severity>
- * </event>
- * <event xmlns="http://example.com/event/1.0">
- * <eventClass>fault</eventClass>
- * <severity>major</severity>
- * </event>
- * <event xmlns="http://example.com/event/1.0">
- * <eventClass>fault</eventClass>
- * <severity>minor</severity>
- * </event>
- * </filter>
- * </create-subscription>
- * </netconf:rpc>
- */
-
- /**
- * Protocols have their own mechanism to support notification filtering
- * or notification subscription. Depending on the protocol specification,
- * the filtering is implemented in the protocol.
- * The Protocol implementations are abstracted of the Schema, there are
- * scenarios in which they need to check if the received notification
- * is of interest as per the schema filtering / subscription.
- * In such scenario, protocols can create a filtering / subscription YANG
- * data tree and use the notification service to filter the notification
- * subject against their filter.
- *
- * Filters the notification subject YANG data tree, with the specified
- * filter of the NBI protocol. If the filter does not match for the
- * passed notification subject, null will be returned.
- * Otherwise, the part of the subject matching the filter will be returned.
- *
- * @param notificationSubject YANG notification subject reported by YANG
- * notification service.
- * @param notificationFilter Protocols data model specific notification
- * filter represented in YANG data tree.
- * @return filtered notification which passes the data model specific
- * notification filter.
- */
- YangNotification getFilteredSubject(YangNotification notificationSubject,
- YangNotification notificationFilter);
-
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ynh/package-info.java b/apps/yms/api/src/main/java/org/onosproject/yms/ynh/package-info.java
deleted file mode 100644
index a0620c3..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ynh/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides interfaces to YANG notification handler. YNH handles notification
- * from the application and provide it to the protocols.
- *
- * NBI Protocols which can support notification delivery for application(s)
- * need to add themselves as a listeners with YANG notification service.
- *
- * Also protocols can use YANG notification service to check if a received
- * notification should be filtered against any of their protocol specific
- * filtering mechanism.
- */
-package org.onosproject.yms.ynh;
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ypm/DefaultYpmNode.java b/apps/yms/api/src/main/java/org/onosproject/yms/ypm/DefaultYpmNode.java
deleted file mode 100644
index 846b443..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ypm/DefaultYpmNode.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ypm;
-
-/**
- * Represents implementation of interfaces to build and obtain YANG protocol metadata tree node.
- */
-public class DefaultYpmNode implements YpmContext {
-
- /**
- * Name of the node.
- */
- private String name;
-
- /**
- * Parent reference.
- */
- private DefaultYpmNode parent;
-
- /**
- * First child reference.
- */
- private DefaultYpmNode child;
-
- /**
- * Next sibling reference.
- */
- private DefaultYpmNode nextSibling;
-
- /**
- * Previous sibling reference.
- */
- private DefaultYpmNode previousSibling;
-
- /**
- * Protocol metadata object.
- */
- private Object metaData;
-
- /**
- * Creates a specific type of node.
- *
- * @param name of ypm node
- */
- public DefaultYpmNode(String name) {
- setName(name);
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public DefaultYpmNode getParent() {
- return parent;
- }
-
- @Override
- public void setParent(YpmContext parent) {
- this.parent = (DefaultYpmNode) parent;
- }
-
- @Override
- public YpmContext getFirstChild() {
- return child;
- }
-
- @Override
- public YpmContext getChild(String ypmName) {
- if (ypmName == null) {
- // Input is null. So, will not proceed.
- return null;
- }
-
- if (child == null) {
- // No children
- return null;
- }
-
- // Check the first child
- if (child.name.equals(ypmName)) {
- return child;
- }
-
- // Check its siblings
- YpmContext currentChild = child;
- while (currentChild.getNextSibling() != null) {
- currentChild = currentChild.getNextSibling();
- if (currentChild.getName().equals(ypmName)) {
- return currentChild;
- }
- }
-
- return null;
- }
-
- @Override
- public void addChild(String ypmName) {
- if (ypmName == null) {
- // Input is null. So, will not proceed.
- return;
- }
-
- if (getChild(ypmName) != null) {
- // Already available with the same name. So, no need to add
- return;
- }
-
- // Create new ypm node and attach to its parent
- DefaultYpmNode newNode = new DefaultYpmNode(ypmName);
- newNode.setParent(this);
-
- // Check the first child
- if (child == null) {
- child = newNode;
- return;
- }
-
- // Add it to its siblings
- YpmContext currentChild = child;
- // Go to the last child
- while (currentChild.getNextSibling() != null) {
- currentChild = currentChild.getNextSibling();
- }
- currentChild.setNextSibling(newNode);
- newNode.setPreviousSibling((DefaultYpmNode) currentChild);
- }
-
- @Override
- public YpmContext getSibling(String ypmName) {
- if (ypmName == null) {
- // Input is null. So, will not proceed.
- return null;
- }
-
- YpmContext sibling = getNextSibling();
- while (sibling != null) {
- if (sibling.getName().equals(ypmName)) {
- return sibling;
- }
- sibling = sibling.getNextSibling();
- }
- return null;
- }
-
- @Override
- public void addSibling(String ypmName) {
- if (ypmName == null) {
- // Input is null. So, will not proceed.
- return;
- }
-
- if (getSibling(ypmName) != null) {
- // Already available with the same name. So, no need to add
- return;
- }
-
- // Create new ypm node and attach to its parent
- DefaultYpmNode newSibling = new DefaultYpmNode(ypmName);
- newSibling.setParent(this.getParent());
-
- // Add it as its sibling
- YpmContext sibling = getNextSibling();
- if (sibling == null) {
- setNextSibling(newSibling);
- newSibling.setPreviousSibling(this);
- } else {
- // Go to the last sibling
- while (sibling.getNextSibling() != null) {
- sibling = sibling.getNextSibling();
- }
- sibling.setNextSibling(newSibling);
- newSibling.setPreviousSibling((DefaultYpmNode) sibling);
- }
- }
-
- @Override
- public DefaultYpmNode getNextSibling() {
- return nextSibling;
- }
-
- @Override
- public void setNextSibling(DefaultYpmNode sibling) {
- nextSibling = sibling;
- }
-
- @Override
- public DefaultYpmNode getPreviousSibling() {
- return previousSibling;
- }
-
- @Override
- public void setPreviousSibling(DefaultYpmNode sibling) {
- this.previousSibling = sibling;
- }
-
- @Override
- public Object getMetaData() {
- return this.metaData;
- }
-
- @Override
- public void setMetaData(Object data) {
- this.metaData = data;
- }
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ypm/YpmContext.java b/apps/yms/api/src/main/java/org/onosproject/yms/ypm/YpmContext.java
deleted file mode 100644
index 18ac0e7..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ypm/YpmContext.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ypm;
-
-/**
- * Abstraction of an entity which represents YANG protocol metadata context
- * information.
- */
-public interface YpmContext {
-
- /**
- * Returns the node name.
- *
- * @return node name
- */
- String getName();
-
- /**
- * Sets the nodes name.
- *
- * @param name nodes name
- */
- void setName(String name);
-
- /**
- * Returns the context of parent node.
- *
- * @return context of parent node
- */
- YpmContext getParent();
-
- /**
- * Sets the context of parent node.
- *
- * @param parent node parent
- */
- void setParent(YpmContext parent);
-
- /**
- * Retrieves the first child of a node.
- *
- * @return first child of a node
- */
- YpmContext getFirstChild();
-
- /**
- * Retrieves the child of a node for corresponding ydt node.
- *
- * @param name ypm node
- * @return child of a node
- */
- YpmContext getChild(String name);
-
- /**
- * Adds child to a node by ydt name.
- *
- * @param name ypm name
- */
- void addChild(String name);
-
- /**
- * Retrieves sibling of a child by (ydt) name.
- *
- * @param name ypm name
- * @return sibling of a child
- */
- YpmContext getSibling(String name);
-
- /**
- * Adds new sibling to a child.
- *
- * @param name ypm name
- */
- void addSibling(String name);
-
- /**
- * Returns the context of next sibling.
- *
- * @return context of next sibling
- */
- YpmContext getNextSibling();
-
- /**
- * Sets the next sibling of node.
- *
- * @param sibling ypm node
- */
- void setNextSibling(DefaultYpmNode sibling);
-
- /**
- * Returns the previous sibling of a node.
- *
- * @return previous sibling of a node
- */
- DefaultYpmNode getPreviousSibling();
-
- /**
- * Sets the previous sibling.
- *
- * @param previousSibling points to predecessor sibling
- */
- void setPreviousSibling(DefaultYpmNode previousSibling);
-
- /**
- * Retrieves protocol metadata.
- *
- * @return metadata
- */
- Object getMetaData();
-
- /**
- * Sets the protocol metadata.
- *
- * @param data metadata
- */
- void setMetaData(Object data);
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ypm/YpmService.java b/apps/yms/api/src/main/java/org/onosproject/yms/ypm/YpmService.java
deleted file mode 100644
index f23e9c6..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ypm/YpmService.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ypm;
-
-import org.onosproject.yms.ydt.YdtContext;
-
-/**
- * Abstraction of an entity which provides interfaces to YANG Protocol Metadata Manager.
- */
-public interface YpmService {
-
- /**
- * Returns the protocol data stored in sepecific data model path.
- *
- * @param rootNode YANG data tree
- * @return YANG protocol metadata
- */
- YpmContext getProtocolData(YdtContext rootNode);
-
- /**
- * Sets the YANG protocol metadata in specific ydt path in ypm tree.
- *
- * @param rootNode YANG data tree
- * @param data YANG protocol metadata
- */
- void setProtocolData(YdtContext rootNode, Object data);
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ypm/package-info.java b/apps/yms/api/src/main/java/org/onosproject/yms/ypm/package-info.java
deleted file mode 100644
index 485707d..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ypm/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides interfaces to YANG protocol metadata manager. YPM maintains protocol specific information
- * (like timestamp, entity tag, etc.) for YANG modeled data.
- */
-package org.onosproject.yms.ypm;
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ysr/YangModuleIdentifier.java b/apps/yms/api/src/main/java/org/onosproject/yms/ysr/YangModuleIdentifier.java
deleted file mode 100644
index 74836e0..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ysr/YangModuleIdentifier.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.ysr;
-
-/**
- * Abstraction of an entity which provides YANG module identifiers.
- * Reference RFC 7895
- * YANG library provides information about all the YANG modules
- * used by a network management server
- */
-public interface YangModuleIdentifier {
- /**
- * retrieves the name of the YANG module.
- *
- * @return the name of the YANG module
- */
- String moduleName();
-
- /**
- * Retrieves revision of the YANG module.
- * <p>
- * Reference RFC 7895
- * Each YANG module and submodule within the library has a
- * revision. This is derived from the most recent revision statement
- * within the module or submodule. If no such revision statement
- * exists, the module's or submodule's revision is the zero-length
- * string.
- *
- * @return revision of the YANG module
- */
- String revision();
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ysr/YangModuleInformation.java b/apps/yms/api/src/main/java/org/onosproject/yms/ysr/YangModuleInformation.java
deleted file mode 100644
index a64ea32..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ysr/YangModuleInformation.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.yms.ysr;
-
-import org.onosproject.yangutils.datamodel.YangNamespace;
-
-import java.util.List;
-
-/**
- * Abstraction of an entity which provides YANG module information.
- *
- * Reference RFC 7895
- * The following information is needed by a client application (for each
- * YANG module in the library) to fully utilize the YANG data modeling
- * language:
- *
- * o name: The name of the YANG module.
- *
- * o revision: Each YANG module and submodule within the library has a
- * revision. This is derived from the most recent revision statement
- * within the module or submodule. If no such revision statement
- * exists, the module's or submodule's revision is the zero-length
- * string.
- *
- * o submodule list: The name and revision of each submodule used by
- * the module MUST be identified.
- *
- * o feature list: The name of each YANG feature supported by the
- * server MUST be identified.
- *
- * o deviation list: The name of each YANG module used for deviation
- * statements MUST be identified.
- */
-public interface YangModuleInformation {
- /**
- * Retrieves the YANG modules identifier.
- *
- * @return YANG modules identifier
- */
- YangModuleIdentifier moduleIdentifier();
-
- /**
- * Retrieves the YANG modules namespace.
- * The XML namespace identifier for this module.
- *
- * @return YANG modules namespace
- */
- YangNamespace namespace();
-
- /**
- * Reference RFC 7895
- * Retrieves the list of YANG feature names from this module that are
- * supported by the server, regardless of whether they are
- * defined in the module or any included submodule.
- *
- * @return list of YANG features
- */
- List<String> featureList();
-
- /**
- * Retrieves the list of submodules in the module.
- * The name and revision of each submodule used by
- * the module MUST be identified.
- *
- * Each entry represents one submodule within the
- * parent module.
- *
- * @return list of submodules in the module
- */
- List<YangModuleIdentifier> subModuleIdentifiers();
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ysr/YangModuleLibrary.java b/apps/yms/api/src/main/java/org/onosproject/yms/ysr/YangModuleLibrary.java
deleted file mode 100644
index b66f887..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ysr/YangModuleLibrary.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.yms.ysr;
-
-/*-
- * Abstraction of an entity which provides the servers YANG library information.
- *
- * Reference RFC 7895
- * The "ietf-yang-library" module provides information about the YANG
- * library used by a server. This module is defined using YANG version
- * 1, but it supports the description of YANG modules written in any
- * revision of YANG.
- *
- * Following is the YANG Tree Diagram for the "ietf-yang-library"
- * module:
- *
- * +--ro modules-state
- * +--ro module-set-id string
- * +--ro module* [name revision]
- * +--ro name yang:yang-identifier
- * +--ro revision union
- * +--ro schema? inet:uri
- * +--ro namespace inet:uri
- * +--ro feature* yang:yang-identifier
- * +--ro deviation* [name revision]
- * | +--ro name yang:yang-identifier
- * | +--ro revision union
- * +--ro conformance-type enumeration
- * +--ro submodule* [name revision]
- * +--ro name yang:yang-identifier
- * +--ro revision union
- * +--ro schema? inet:uri
- */
-
-import java.util.List;
-
-public interface YangModuleLibrary {
- /**
- * Retrieves the current module set id of the YANG library.
- *
- * Reference RFC7895.
- * modules-state/module-set-id
- *
- * This mandatory leaf contains a unique implementation-specific
- * identifier representing the current set of modules and submodules on
- * a specific server. The value of this leaf MUST change whenever the
- * set of modules and submodules in the YANG library changes. There is
- * no requirement that the same set always results in the same "module-
- * set-id" value.
- *
- * @return module set id of the YANG library
- */
- String moduleSetId();
-
- /**
- * Retrieves the current list of YANG modules supported in the server.
- *
- * Reference RFC 7895.
- * modules-state/module
- *
- * This mandatory list contains one entry for each YANG data model
- * module supported by the server. There MUST be an entry in this list
- * for each revision of each YANG module that is used by the server. It
- * is possible for multiple revisions of the same module to be imported,
- * in addition to an entry for the revision that is implemented by the
- * server.
- *
- * @return the current list of YANG modules supported in the server
- */
- List<YangModuleInformation> yangModuleList();
-}
diff --git a/apps/yms/api/src/main/java/org/onosproject/yms/ysr/package-info.java b/apps/yms/api/src/main/java/org/onosproject/yms/ysr/package-info.java
deleted file mode 100644
index b36d6f2..0000000
--- a/apps/yms/api/src/main/java/org/onosproject/yms/ysr/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * YANG schema registry (YSR) is responsible to maintain all the applications
- * schemas defined in YANG. The YANG data tree builder depends on the schema
- * registry to validate the tree building according to schema.
- * YANG codec handler using the schema registry to maintain device schema.
- */
-package org.onosproject.yms.ysr;
diff --git a/apps/yms/app/BUCK.deprecated b/apps/yms/app/BUCK.deprecated
deleted file mode 100644
index be5b01b..0000000
--- a/apps/yms/app/BUCK.deprecated
+++ /dev/null
@@ -1,13 +0,0 @@
-COMPILE_DEPS = [
- '//lib:CORE_DEPS',
- '//apps/yms/api:onos-apps-yms-api',
- '//lib:onos-yang-datamodel',
- '//lib:onos-yang-utils-generator',
- '//lib:org.apache.servicemix.bundles.dom4j',
-]
-
-osgi_jar_with_tests(
- name = 'onos-apps-yms-app',
- deps = COMPILE_DEPS,
- #private_packages = 'org.onosproject.yangutils.datamodel.*,org.onosproject.yangutils.translator.*,org.onosproject.yangutils.linker.*,org.onosproject.yangutils.utils.*',
-)
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/utils/TraversalType.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/utils/TraversalType.java
deleted file mode 100644
index 83dc008..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/utils/TraversalType.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.utils;
-
-/**
- * Represents traversal type of the YANG node tree.
- */
-public enum TraversalType {
-
- /*
- * Start of traversal at the tree root.
- */
- ROOT,
-
- /*
- * Child node traversal.
- */
- CHILD,
-
- /*
- * Sibling node traversal.
- */
- SIBLING,
-
- /*
- * Parent node traversal.
- */
- PARENT
-}
-
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/utils/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/utils/package-info.java
deleted file mode 100644
index f1f9af6..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/utils/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of build and obtain YANG data tree which is data
- * (sub)instance representation, abstract of protocol.
- */
-package org.onosproject.yms.app.utils;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yab/YangApplicationBroker.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yab/YangApplicationBroker.java
deleted file mode 100644
index 5d53331..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yab/YangApplicationBroker.java
+++ /dev/null
@@ -1,903 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yab;
-
-import org.onosproject.yangutils.datamodel.YangAugment;
-import org.onosproject.yangutils.datamodel.YangAugmentableNode;
-import org.onosproject.yangutils.datamodel.YangInput;
-import org.onosproject.yangutils.datamodel.YangModule;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangRpc;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yms.app.utils.TraversalType;
-import org.onosproject.yms.app.yab.exceptions.YabException;
-import org.onosproject.yms.app.ydt.DefaultYdtAppContext;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YangResponseWorkBench;
-import org.onosproject.yms.app.ydt.YdtAppContext;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtMultiInstanceNode;
-import org.onosproject.yms.app.ydt.YdtNode;
-import org.onosproject.yms.app.yob.DefaultYobBuilder;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.app.ytb.DefaultYangTreeBuilder;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtResponse;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.yms.app.utils.TraversalType.CHILD;
-import static org.onosproject.yms.app.utils.TraversalType.PARENT;
-import static org.onosproject.yms.app.utils.TraversalType.ROOT;
-import static org.onosproject.yms.app.utils.TraversalType.SIBLING;
-import static org.onosproject.yms.app.ydt.AppNodeFactory.getAppContext;
-import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.DELETE_ONLY;
-import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.OTHER_EDIT;
-import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE;
-import static org.onosproject.yms.ydt.YmsOperationExecutionStatus.EXECUTION_SUCCESS;
-
-/**
- * Represents YANG application broker. It acts as a broker between Protocol and
- * YANG based application.
- */
-public class YangApplicationBroker {
-
- private static final String GET = "get";
- private static final String SET = "set";
- private static final String AUGMENTED = "Augmented";
- private static final String VOID = "void";
- private final YangSchemaRegistry schemaRegistry;
- private Set<String> augGenMethodSet;
-
- /**
- * Creates a new YANG application broker.
- *
- * @param schemaRegistry YANG schema registry
- */
- public YangApplicationBroker(YangSchemaRegistry schemaRegistry) {
- this.schemaRegistry = schemaRegistry;
- }
-
- /**
- * Processes query request of a NBI protocol.
- *
- * @param ydtWorkBench YANG request work bench
- * @return YANG response data tree node context
- * @throws YabException violation in execution of YAB
- */
- public YdtResponse processQuery(YdtBuilder ydtWorkBench)
- throws YabException {
- List<Object> responseObjects = new LinkedList<>();
- YangRequestWorkBench workBench = (YangRequestWorkBench) ydtWorkBench;
- augGenMethodSet = ((YangRequestWorkBench) ydtWorkBench).getAugGenMethodSet();
-
- for (YdtAppContext appContext = workBench.getAppRootNode().getFirstChild();
- appContext != null; appContext = appContext.getNextSibling()) {
- Object responseObject = processQueryOfApplication(appContext);
- if (responseObject != null) {
- responseObjects.add(responseObject);
- }
- }
-
- YdtContext rootYdtContext = workBench.getRootNode();
- YdtBuilder responseYdt = buildResponseYdt(responseObjects,
- rootYdtContext.getName(),
- rootYdtContext.getNamespace());
-
- return new YangResponseWorkBench(responseYdt.getRootNode(),
- EXECUTION_SUCCESS,
- ydtWorkBench.getYmsOperationType());
- }
-
- /**
- * Processes edit request of a NBI protocol.
- *
- * @param ydtWorkBench YANG request work bench
- * @return YANG response data tree node context
- * @throws YabException violation in execution of YAB
- * @throws CloneNotSupportedException clone is not supported
- */
- public YdtResponse processEdit(YdtBuilder ydtWorkBench)
- throws CloneNotSupportedException, YabException {
- YangRequestWorkBench workBench = (YangRequestWorkBench) ydtWorkBench;
- augGenMethodSet = ((YangRequestWorkBench) ydtWorkBench).getAugGenMethodSet();
- for (YdtAppContext appContext = workBench.getAppRootNode().getFirstChild();
- appContext != null; appContext = appContext.getNextSibling()) {
- processEditOfApplication(appContext);
- }
-
- /*
- * Since for set operation return type is void, there will not be
- * response ydt tree so returning null.
- */
- return new YangResponseWorkBench(null, EXECUTION_SUCCESS,
- workBench.getYmsOperationType());
- }
-
- /**
- * Processes operation request of a NBI protocol.
- *
- * @param ydtWorkBench YANG request work bench
- * @return YANG response data tree node context
- * @throws YabException violation in execution of YAB
- */
- public YdtResponse processOperation(YdtBuilder ydtWorkBench)
- throws YabException {
- YangRequestWorkBench workBench = (YangRequestWorkBench) ydtWorkBench;
- YdtAppContext appContext = workBench.getAppRootNode().getFirstChild();
- YdtContext ydtNode = appContext.getModuleContext();
- while (ydtNode != null) {
- YdtContext childYdtNode = ydtNode.getFirstChild();
- YangSchemaNode yangNode = ((YdtNode) childYdtNode).getYangSchemaNode();
- if (yangNode instanceof YangRpc) {
- return processRpcOperationOfApplication(childYdtNode,
- appContext, yangNode,
- workBench);
- }
- ydtNode = ydtNode.getNextSibling();
- }
- return new YangResponseWorkBench(null, EXECUTION_SUCCESS,
- ydtWorkBench.getYmsOperationType());
- }
-
- /**
- * Processes rpc request of an application.
- *
- * @param appContext application context
- * @return response object from application
- */
- private YdtResponse processRpcOperationOfApplication(YdtContext rpcYdt,
- YdtAppContext appContext,
- YangSchemaNode yangRpc,
- YangRequestWorkBench workBench)
- throws YabException {
- Object inputObject = null;
- YdtContext inputYdtNode = getInputYdtNode(rpcYdt);
- if (inputYdtNode != null) {
- inputObject = getYangObject(inputYdtNode);
- }
-
- Object appObject = getApplicationObjectForRpc(appContext);
-
- String methodName = yangRpc.getJavaClassNameOrBuiltInType();
- Object outputObject = invokeRpcApplicationsMethod(appObject,
- inputObject,
- methodName);
-
- String returnType = getReturnTypeOfRpcResponse(appObject,
- inputObject, yangRpc);
-
- if (!returnType.equals(VOID)) {
- YdtBuilder responseYdt = buildRpcResponseYdt(outputObject,
- workBench);
- return new YangResponseWorkBench(responseYdt.getRootNode(),
- EXECUTION_SUCCESS,
- workBench.getYmsOperationType());
- }
-
- return new YangResponseWorkBench(null, EXECUTION_SUCCESS,
- workBench.getYmsOperationType());
- }
-
- /**
- * Processes query request of an application.
- *
- * @param appContext application context
- * @return response object from application
- */
- private Object processQueryOfApplication(YdtAppContext appContext)
- throws YabException {
- YdtContext ydtNode = appContext.getModuleContext();
-
- // Update application context tree if any node is augmented
- YangNode yangNode = (YangNode) appContext.getYangSchemaNode();
- if (yangNode.isDescendantNodeAugmented()) {
- processAugmentForChildNode(appContext, yangNode);
- }
-
- String appName = getCapitalCase(((YdtNode) appContext.getModuleContext())
- .getYangSchemaNode()
- .getJavaClassNameOrBuiltInType());
-
- // get YangObject of YdtContext from YOB
- Object outputObject = getYangObject(ydtNode);
-
- TraversalType curTraversal = ROOT;
- do {
- if (curTraversal != PARENT) {
-
- // find application and get application's object using YSR
- Object appManagerObject = getApplicationObject(appContext);
-
- // find which method to invoke
- String methodName = getApplicationMethodName(appContext,
- appName, GET);
-
- String moduleName = appContext.getAppData()
- .getRootSchemaNode().getName();
-
- // invoke application's getter method
- outputObject = invokeApplicationsMethod(appManagerObject,
- outputObject,
- methodName, moduleName);
- }
-
- /*
- * AppContext may contain other nodes if it is augmented, so
- * traverse the appContext tree
- */
- if (curTraversal != PARENT && appContext.getFirstChild() != null) {
- curTraversal = CHILD;
- appContext = appContext.getFirstChild();
- } else if (appContext.getNextSibling() != null) {
- curTraversal = SIBLING;
- appContext = appContext.getNextSibling();
- } else {
- curTraversal = PARENT;
- if (appContext.getParent().getParent() != null) {
- appContext = appContext.getParent();
- }
- }
- // no need to do any operation for logical root node
- } while (appContext.getParent().getParent() != null);
- return outputObject;
- }
-
- /**
- * Processes edit request of an application.
- *
- * @param appContext application context
- * @throws YabException violation in execution of YAB
- * @throws CloneNotSupportedException clone is not supported
- */
- private void processEditOfApplication(YdtAppContext appContext)
- throws CloneNotSupportedException, YabException {
-
- // process delete request if operation type is delete and both
- if (appContext.getOperationType() != OTHER_EDIT) {
- processDeleteRequestOfApplication(appContext);
- }
-
- // process edit request if operation type is other edit and both
- if (appContext.getOperationType() != DELETE_ONLY) {
- YdtContext ydtNode = appContext.getModuleContext();
-
- String appName = getCapitalCase(((YdtNode) appContext.getModuleContext())
- .getYangSchemaNode()
- .getJavaClassNameOrBuiltInType());
-
- // get YO from YOB
- Object outputObject = getYangObject(ydtNode);
-
- TraversalType curTraversal = ROOT;
- do {
- if (curTraversal != PARENT) {
-
- // find application and get application's object using YSR
- Object appManagerObject = getApplicationObject(appContext);
-
- // find which method to invoke
- String methodName = getApplicationMethodName(appContext,
- appName, SET);
-
- String moduleName = appContext.getAppData()
- .getRootSchemaNode().getName();
-
- // invoke application's setter method
- invokeApplicationsMethod(appManagerObject, outputObject,
- methodName, moduleName);
- }
-
- /*
- * AppContext may contain other nodes if it is augmented,
- * so traverse the appContext tree
- */
- if (curTraversal != PARENT && appContext.getFirstChild() != null) {
- curTraversal = CHILD;
- appContext = appContext.getFirstChild();
- } else if (appContext.getNextSibling() != null) {
- curTraversal = SIBLING;
- appContext = appContext.getNextSibling();
- } else {
- curTraversal = PARENT;
- if (appContext.getParent().getParent() != null) {
- appContext = appContext.getParent();
- }
- }
- // no need to do any operation for logical root node
- } while (appContext.getParent().getParent() != null);
- }
- }
-
- /**
- * Processes delete request of an application.
- *
- * @param appContext application context
- * @throws YabException violation in execution of YAB
- * @throws CloneNotSupportedException clone is not supported
- */
- private void processDeleteRequestOfApplication(YdtAppContext appContext)
- throws CloneNotSupportedException, YabException {
- TraversalType curTraversal = ROOT;
- List<YdtContext> deleteNodes = appContext.getDeleteNodes();
-
- if (deleteNodes != null && !deleteNodes.isEmpty()) {
-
- /*
- * Split the current Ydt tree into two trees.
- * Delete Tree with all nodes with delete operation and other
- * tree with other edit operation
- */
- YdtContext deleteTree = buildDeleteTree(deleteNodes);
-
- /*
- * If any of nodes in ydt delete tree is augmented then add
- * augmented nodes to current ydt tree
- */
- processAugmentedNodesForDelete(deleteTree.getFirstChild(), appContext);
-
- Object inputObject = getYangObject(deleteTree.getFirstChild());
-
- String appName = getCapitalCase(((YdtNode) appContext.getModuleContext())
- .getYangSchemaNode()
- .getJavaClassNameOrBuiltInType());
-
- do {
- if (curTraversal == ROOT || curTraversal == SIBLING) {
- while (appContext.getLastChild() != null) {
- appContext = appContext.getLastChild();
- }
- }
-
- // getAugmentApplication manager object
- Object appManagerObject = getApplicationObject(appContext);
-
- // find which method to invoke
- String methodName = getApplicationMethodName(appContext,
- appName, SET);
-
- String moduleName = appContext.getAppData().getRootSchemaNode()
- .getName();
-
- // invoke application's setter method
- invokeApplicationsMethod(appManagerObject, inputObject,
- methodName, moduleName);
-
- if (appContext.getPreviousSibling() != null) {
- curTraversal = SIBLING;
- appContext = appContext.getPreviousSibling();
- } else if (appContext.getParent() != null) {
- curTraversal = PARENT;
- appContext = appContext.getParent();
- }
- } while (appContext.getParent() != null);
- }
- }
-
- /**
- * Traverses data model tree and if any node is augmented, then
- * adds child to current application context.
- *
- * @param curAppContext current application context
- * @param schemaNode YANG data model node, either module or augment
- */
- protected void processAugmentForChildNode(YdtAppContext curAppContext,
- YangNode schemaNode) {
- YangNode yangNode = schemaNode.getChild();
- if (yangNode == null) {
- return;
- }
-
- TraversalType curTraversal = CHILD;
- while (!yangNode.equals(schemaNode)) {
- if (curTraversal != PARENT && yangNode instanceof YangAugmentableNode
- && !((YangAugmentableNode) yangNode).getAugmentedInfoList()
- .isEmpty()) {
- updateAppTreeWithAugmentNodes(yangNode, curAppContext);
- }
-
- if (curTraversal != PARENT && yangNode.getChild() != null
- && yangNode.isDescendantNodeAugmented()) {
- curTraversal = CHILD;
- yangNode = yangNode.getChild();
- } else if (yangNode.getNextSibling() != null) {
- curTraversal = SIBLING;
- yangNode = yangNode.getNextSibling();
- } else {
- curTraversal = PARENT;
- yangNode = yangNode.getParent();
- }
- }
- }
-
- /**
- * Traverses YDT delete tree and if any YDT node is augmented then
- * updates the YDT delete tree with augment nodes.
- *
- * @param deleteTree YDT delete tree
- * @param appContext application context
- */
- protected void processAugmentedNodesForDelete(YdtContext deleteTree,
- YdtAppContext appContext) {
- TraversalType curTraversal = ROOT;
- YdtContext ydtContext = deleteTree.getFirstChild();
-
- if (ydtContext == null) {
- /*
- * Delete request is for module, so check all the nodes under
- * module whether it is augmented.
- */
- YangNode yangNode = ((YangNode) ((YdtNode) deleteTree)
- .getYangSchemaNode());
- if (yangNode.isDescendantNodeAugmented()) {
- processAugmentForChildNode(appContext, yangNode);
- }
- return;
- }
-
- while (!ydtContext.equals(deleteTree)) {
- if (curTraversal != PARENT && ((YdtNode) ydtContext)
- .getYdtContextOperationType() == DELETE) {
- YangNode yangNode = ((YangNode) ((YdtNode) ydtContext)
- .getYangSchemaNode());
- if (yangNode instanceof YangAugmentableNode) {
- updateAppTreeWithAugmentNodes(yangNode, appContext);
- }
- if (yangNode.isDescendantNodeAugmented()) {
- processAugmentForChildNode(appContext, yangNode);
- }
- }
-
- if (curTraversal != PARENT && ydtContext.getFirstChild() != null) {
- curTraversal = CHILD;
- ydtContext = ydtContext.getFirstChild();
- } else if (ydtContext.getNextSibling() != null) {
- curTraversal = SIBLING;
- ydtContext = ydtContext.getNextSibling();
- } else {
- curTraversal = PARENT;
- ydtContext = ydtContext.getParent();
- }
- }
- }
-
- /**
- * Returns response YANG data tree using YTB.
- *
- * @param responseObjects list of application's response objects
- * @param name application YANG name
- * @param namespace application YANG namespace
- * @return response YANG data tree
- */
- private YdtBuilder buildResponseYdt(List<Object> responseObjects,
- String name, String namespace) {
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- return treeBuilder.getYdtBuilderForYo(responseObjects,
- name, namespace, null, schemaRegistry);
- }
-
- private YdtBuilder buildRpcResponseYdt(Object responseObject,
- YangRequestWorkBench requestWorkBench) {
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- return treeBuilder.getYdtForRpcResponse(responseObject, requestWorkBench);
- }
-
- /**
- * Builds delete tree for list of delete nodes.
- *
- * @param deleteNodes list of delete nodes
- * @return deleteTree YANG data tree for delete operation
- * @throws CloneNotSupportedException clone is not supported
- */
- protected YdtContext buildDeleteTree(List<YdtContext> deleteNodes) throws
- CloneNotSupportedException {
- Iterator<YdtContext> iterator = deleteNodes.iterator();
- YdtContext deleteTree = null;
- while (iterator.hasNext()) {
- YdtContext deleteNode = iterator.next();
- if (((YdtExtendedContext) deleteNode.getParent())
- .getYdtContextOperationType() != DELETE) {
- cloneAncestorsOfDeleteNode(deleteNode);
- deleteTree = unlinkDeleteNodeFromCurrentTree((YdtNode) deleteNode);
- }
- }
-
- if (deleteTree != null) {
- while (deleteTree.getParent() != null) {
- deleteTree = deleteTree.getParent();
- }
- }
- return deleteTree;
- }
-
- /**
- * Clones ancestor nodes of delete node.
- *
- * @param deleteNode node to be deleted
- * @throws CloneNotSupportedException clone not supported
- */
- private void cloneAncestorsOfDeleteNode(YdtContext deleteNode)
- throws CloneNotSupportedException {
- YdtNode clonedNode;
- YdtNode previousNode = null;
-
- // Clone the parents of delete node to form delete tree
- YdtNode nodeToClone = (YdtNode) deleteNode.getParent();
- while (nodeToClone != null) {
- // If node is not cloned yet
- if (nodeToClone.getClonedNode() == null) {
- clonedNode = nodeToClone.clone();
- unlinkCurrentYdtNode(clonedNode);
- if (nodeToClone instanceof YdtMultiInstanceNode) {
- addKeyLeavesToClonedNode(nodeToClone, clonedNode);
- }
- nodeToClone.setClonedNode(clonedNode);
- } else {
- // already node is cloned
- clonedNode = (YdtNode) nodeToClone.getClonedNode();
- }
-
- if (previousNode != null) {
- /*
- * add previous cloned node as child of current cloned node
- * so that tree will be formed from delete node parent to
- * logical root node.
- */
- clonedNode.addChild(previousNode, false);
- }
- previousNode = clonedNode;
- nodeToClone = nodeToClone.getParent();
- }
- }
-
- /**
- * Unlinks delete node from current YANG data tree of application
- * and links it to cloned delete tree.
- *
- * @param deleteNode node to be unlinked
- * @return deleteNode delete node linked to cloned delete tree
- */
- private YdtNode unlinkDeleteNodeFromCurrentTree(YdtNode deleteNode) {
- YdtNode parentClonedNode = (YdtNode) deleteNode.getParent().getClonedNode();
- unlinkNodeFromParent(deleteNode);
- unlinkNodeFromSibling(deleteNode);
-
- /*
- * Set all the pointers of node to null before adding as child
- * to parent's cloned node.
- */
- deleteNode.setParent(null);
- deleteNode.setPreviousSibling(null);
- deleteNode.setNextSibling(null);
-
- parentClonedNode.addChild(deleteNode, false);
- return deleteNode;
- }
-
- /**
- * Adds key leaf nodes to cloned YDT node from current Ydt node.
- *
- * @param curNode current YDT node
- * @param clonedNode cloned YDT node
- */
- private void addKeyLeavesToClonedNode(YdtNode curNode, YdtNode clonedNode)
- throws CloneNotSupportedException {
- YdtNode keyClonedLeaf;
- List<YdtContext> keyList = ((YdtMultiInstanceNode) curNode)
- .getKeyNodeList();
- if (keyList != null && !keyList.isEmpty()) {
- for (YdtContext keyLeaf : keyList) {
- keyClonedLeaf = ((YdtNode) keyLeaf).clone();
- unlinkCurrentYdtNode(keyClonedLeaf);
- clonedNode.addChild(keyClonedLeaf, true);
- }
- }
- }
-
- /**
- * Updates application context tree if any of the nodes in current
- * application context tree is augmented.
- *
- * @param yangNode YANG schema node which is augmented
- * @param curAppContext current application context tree
- */
- private void updateAppTreeWithAugmentNodes(YangNode yangNode,
- YdtAppContext curAppContext) {
- YdtAppContext childAppContext;
- for (YangAugment yangAugment : ((YangAugmentableNode) yangNode)
- .getAugmentedInfoList()) {
- Object appManagerObject = schemaRegistry
- .getRegisteredApplication(yangAugment.getParent());
- if (appManagerObject != null
- && augGenMethodSet.add(yangAugment.getSetterMethodName())) {
- childAppContext = addChildToYdtAppTree(curAppContext,
- yangAugment);
- processAugmentForChildNode(childAppContext, yangAugment);
- }
- }
- }
-
- /**
- * Adds child node to current application context tree.
- *
- * @param curAppContext current application context
- * @param augment augment data model node
- * @return childAppContext child node added
- */
- private YdtAppContext addChildToYdtAppTree(YdtAppContext curAppContext,
- YangNode augment) {
- DefaultYdtAppContext childAppContext = getAppContext(true);
- childAppContext.setParent(curAppContext);
- childAppContext.setOperationType(curAppContext.getOperationType());
- childAppContext.setAugmentingSchemaNode(augment);
- curAppContext.addChild(childAppContext);
- return childAppContext;
- }
-
- /**
- * Unlinks the current node from its parent.
- *
- * @param deleteNode node which should be unlinked from YDT tree
- */
- private void unlinkNodeFromParent(YdtNode deleteNode) {
- YdtNode parentNode = deleteNode.getParent();
- if (parentNode.getFirstChild().equals(deleteNode)
- && parentNode.getLastChild().equals(deleteNode)) {
- parentNode.setChild(null);
- parentNode.setLastChild(null);
- } else if (parentNode.getFirstChild().equals(deleteNode)) {
- parentNode.setChild(deleteNode.getNextSibling());
- } else if (parentNode.getLastChild().equals(deleteNode)) {
- parentNode.setLastChild(deleteNode.getPreviousSibling());
- }
- }
-
- /**
- * Unlinks the current node from its sibling.
- *
- * @param deleteNode node which should be unlinked from YDT tree
- */
- private void unlinkNodeFromSibling(YdtNode deleteNode) {
- YdtNode previousSibling = deleteNode.getPreviousSibling();
- YdtNode nextSibling = deleteNode.getNextSibling();
- if (nextSibling != null && previousSibling != null) {
- previousSibling.setNextSibling(nextSibling);
- nextSibling.setPreviousSibling(previousSibling);
- } else if (nextSibling != null) {
- nextSibling.setPreviousSibling(null);
- } else if (previousSibling != null) {
- previousSibling.setNextSibling(null);
- }
- }
-
- /**
- * Unlinks current Ydt node from parent, sibling and child.
- *
- * @param ydtNode YANG data tree node
- */
- private void unlinkCurrentYdtNode(YdtNode ydtNode) {
- ydtNode.setParent(null);
- ydtNode.setNextSibling(null);
- ydtNode.setPreviousSibling(null);
- ydtNode.setChild(null);
- ydtNode.setLastChild(null);
- }
-
- /**
- * Returns YANG object for YDT node.
- *
- * @param ydtNode YANG data node
- * @return YANG object for YDT node
- */
- private Object getYangObject(YdtContext ydtNode) {
- checkNotNull(ydtNode);
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- return yobBuilder.getYangObject((YdtExtendedContext) ydtNode,
- schemaRegistry);
- }
-
- /**
- * Returns application manager object for YDT node.
- *
- * @param appContext YDT application context
- * @return application manager object
- */
- private Object getApplicationObjectForRpc(YdtAppContext appContext) {
- checkNotNull(appContext);
- while (appContext.getFirstChild() != null) {
- appContext = appContext.getFirstChild();
- }
- return schemaRegistry.getRegisteredApplication(appContext.getAppData()
- .getRootSchemaNode());
- }
-
- /**
- * Returns application manager object of application.
- *
- * @param appContext application context
- * @return application manager object
- */
- private Object getApplicationObject(YdtAppContext appContext) {
- return schemaRegistry.getRegisteredApplication(appContext.getAppData()
- .getRootSchemaNode());
- }
-
- /**
- * Converts name to capital case.
- *
- * @param yangIdentifier identifier
- * @return name to capital case
- */
- private String getCapitalCase(String yangIdentifier) {
- return yangIdentifier.substring(0, 1).toUpperCase() +
- yangIdentifier.substring(1);
- }
-
- /**
- * Returns get/set method name for application's request.
- *
- * @param appContext application context
- * @return get/set method name for application's query request
- */
- private String getApplicationMethodName(YdtAppContext appContext,
- String appName,
- String operation) {
- if (appContext.getYangSchemaNode() instanceof YangModule) {
- return operation + appName;
- }
-
- String augment = ((YangAugment) appContext
- .getAugmentingSchemaNode()).getTargetNode().get(0)
- .getResolvedNode().getJavaClassNameOrBuiltInType();
- return new StringBuilder().append(operation).append(AUGMENTED)
- .append(appName).append(getCapitalCase(augment)).toString();
- }
-
- /**
- * Returns rpc's input schema node.
- *
- * @param rpcNode rpc schema node
- * @return rpc's input YDT node
- */
- private YdtContext getInputYdtNode(YdtContext rpcNode) {
- YdtContext inputNode = rpcNode.getFirstChild();
- while (inputNode != null) {
- YangSchemaNode yangInputNode = ((YdtNode) inputNode)
- .getYangSchemaNode();
- if (yangInputNode instanceof YangInput) {
- return inputNode;
- }
- inputNode = rpcNode.getNextSibling();
- }
- return null;
- }
-
- /**
- * Invokes application method for RPC request.
- *
- * @param appManagerObject application manager object
- * @param inputObject input parameter object of method
- * @param methodName method name which should be invoked
- * @return response object from application
- * @throws YabException violation in execution of YAB
- */
- private Object invokeApplicationsMethod(Object appManagerObject,
- Object inputObject,
- String methodName, String appName)
- throws YabException {
- checkNotNull(appManagerObject);
- Class<?> appClass = appManagerObject.getClass();
- try {
- Method methodObject = appClass.getDeclaredMethod(methodName,
- inputObject.getClass());
- if (methodObject != null) {
- return methodObject.invoke(appManagerObject, inputObject);
- }
- throw new YabException("No such method in application");
- } catch (IllegalAccessException | NoSuchMethodException e) {
- throw new YabException(e);
- } catch (InvocationTargetException e) {
- throw new YabException("Invocation exception in service " + appName,
- e.getCause());
- }
- }
-
- /**
- * Invokes application method for RPC request.
- *
- * @param appObject application manager object
- * @param inputObject input parameter object of method
- * @param yangNode method name which should be invoked
- * @return response object from application
- * @throws YabException violation in execution of YAB
- */
- private String getReturnTypeOfRpcResponse(Object appObject,
- Object inputObject, YangSchemaNode
- yangNode) throws YabException {
- Method methodObject = null;
- try {
- if (inputObject == null) {
- methodObject = appObject.getClass()
- .getDeclaredMethod(yangNode.getJavaClassNameOrBuiltInType(),
- null);
- } else {
- methodObject = appObject.getClass()
- .getDeclaredMethod(yangNode.getJavaClassNameOrBuiltInType(),
- inputObject.getClass().getInterfaces());
- }
- if (methodObject != null) {
- return methodObject.getReturnType().getSimpleName();
- }
- throw new YabException("No such method in application");
- } catch (NoSuchMethodException e) {
- throw new YabException(e);
- }
- }
-
- /**
- * Invokes application method for RPC request.
- *
- * @param appManagerObject application manager object
- * @param inputParamObject input parameter object of method
- * @param methodName method name which should be invoked
- * @return response object from application
- * @throws YabException violation in execution of YAB
- */
- private Object invokeRpcApplicationsMethod(Object appManagerObject,
- Object inputParamObject,
- String methodName) throws YabException {
- checkNotNull(appManagerObject);
- Class<?> appClass = appManagerObject.getClass();
- try {
- Method methodObject;
- if (inputParamObject == null) {
- methodObject = appClass.getDeclaredMethod(methodName, null);
- if (methodObject != null) {
- return methodObject.invoke(appManagerObject);
- }
- } else {
- methodObject = appClass.getDeclaredMethod(methodName,
- inputParamObject
- .getClass()
- .getInterfaces());
- if (methodObject != null) {
- return methodObject.invoke(appManagerObject, inputParamObject);
- }
- }
- throw new YabException("No such method in application");
- } catch (IllegalAccessException | NoSuchMethodException |
- InvocationTargetException e) {
- throw new YabException(e);
- }
- }
-
- /**
- * Sets the augment setter method name.
- *
- * @param augGenMethodSet augment setter method name
- */
- public void setAugGenMethodSet(Set<String> augGenMethodSet) {
- this.augGenMethodSet = augGenMethodSet;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yab/exceptions/YabException.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yab/exceptions/YabException.java
deleted file mode 100644
index 9057843..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yab/exceptions/YabException.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yab.exceptions;
-
-/**
- * Represents base class for exceptions in YDT operations.
- */
-public class YabException extends RuntimeException {
-
- private static final long serialVersionUID = 20160211L;
-
- /**
- * Creates a new YDT exception.
- */
- public YabException() {
- }
-
- /**
- * Creates a new YDT exception with given message.
- *
- * @param message the detail of exception in string
- */
- public YabException(String message) {
- super(message);
- }
-
- /**
- * Creates a new YDT exception from given message and cause.
- *
- * @param message the detail of exception in string
- * @param cause underlying cause of the error
- */
- public YabException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Creates a new YDT exception from cause.
- *
- * @param cause underlying cause of the error
- */
- public YabException(final Throwable cause) {
- super(cause);
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yab/exceptions/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yab/exceptions/package-info.java
deleted file mode 100644
index 5dcc22d..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yab/exceptions/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-/**
- * YANG application broker exception.
- */
-package org.onosproject.yms.app.yab.exceptions;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yab/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yab/package-info.java
deleted file mode 100644
index c73f4ad..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yab/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides interfaces to YANG request broker. YRB is responsible for
- * interaction with applications in YANG modeled objects.
- */
-package org.onosproject.yms.app.yab;
\ No newline at end of file
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/DefaultYangCodecHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/DefaultYangCodecHandler.java
deleted file mode 100644
index b2f197c..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/DefaultYangCodecHandler.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeContextInfo;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
-import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yms.app.ych.defaultcodecs.YangCodecRegistry;
-import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.yob.DefaultYobBuilder;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.app.ytb.DefaultYangTreeBuilder;
-import org.onosproject.yms.app.ytb.YtbException;
-import org.onosproject.yms.ych.YangCodecHandler;
-import org.onosproject.yms.ych.YangCompositeEncoding;
-import org.onosproject.yms.ych.YangDataTreeCodec;
-import org.onosproject.yms.ych.YangProtocolEncodingFormat;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YmsOperationType;
-import org.onosproject.yms.ysr.YangModuleLibrary;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.onosproject.yms.app.yob.YobUtils.createAndSetInEventInstance;
-import static org.onosproject.yms.app.yob.YobUtils.createAndSetInEventSubjectInstance;
-
-/**
- * Represents implementation of YANG SBI broker interfaces.
- * YCH acts as a broker between YMS and driver/provider.
- */
-public class DefaultYangCodecHandler implements YangCodecHandler {
-
- private static final String E_MODULE_LIST = "The input module or " +
- "sub-module object list cannot be null.";
- private static final String E_DATA_TREE_CODEC = "data tree codec handler" +
- " is null.";
- private static final String E_DATA_MODEL_CHILD = "Unable to find the " +
- "child node";
- private static final String E_NOTIFICATION_NODE = "Notification node " +
- "should be the first child of module in YDT";
-
- /**
- * Schema registry for driver.
- */
- private final YangSchemaRegistry schemaRegistry;
- private YangModuleLibrary library;
-
- /**
- * Default codecs.
- */
- private final Map<YangProtocolEncodingFormat, YangDataTreeCodec>
- defaultCodecs = new HashMap<>();
-
- /**
- * Override codec handler.
- */
- private final Map<YangProtocolEncodingFormat, YangDataTreeCodec>
- overrideCodecs = new HashMap<>();
-
- /**
- * Creates a new YANG codec handler.
- *
- * @param registry YANG schema registry
- */
- public DefaultYangCodecHandler(YangSchemaRegistry registry) {
- schemaRegistry = registry;
-
- // update the default codecs from codec registry
- Map<YangProtocolEncodingFormat, YangDataTreeCodec> recvCodec =
- YangCodecRegistry.getDefaultCodecs();
- if (!recvCodec.isEmpty()) {
- for (Map.Entry<YangProtocolEncodingFormat, YangDataTreeCodec>
- codecEntry : recvCodec.entrySet()) {
- defaultCodecs.put(codecEntry.getKey(), codecEntry.getValue());
- }
- }
- }
-
- private YangDataTreeCodec getAppropriateCodec(
- YangProtocolEncodingFormat dataFormat) {
- YangDataTreeCodec codec = defaultCodecs.get(dataFormat);
-
- int size = overrideCodecs.size();
- // Check over ridden codec handler is exist or not.
- if (size != 0) {
- YangDataTreeCodec overrideCodec = overrideCodecs.get(dataFormat);
- if (overrideCodec != null) {
- codec = overrideCodec;
- }
- }
- return codec;
- }
-
- @Override
- public void addDeviceSchema(Class<?> yangModule) {
- schemaRegistry.registerApplication(null, yangModule);
- schemaRegistry.processModuleLibrary(yangModule.getName(), library);
- }
-
- @Override
- public String encodeOperation(String rootName,
- String rootNamespace,
- Map<String, String> tagAttrMap,
- List<Object> moduleList,
- YangProtocolEncodingFormat dataFormat,
- YmsOperationType opType) {
-
- if (moduleList == null || moduleList.isEmpty()) {
- throw new YchException(E_MODULE_LIST);
- }
-
- // Get the default codec handler.
- YangDataTreeCodec codec = getAppropriateCodec(dataFormat);
- if (codec == null) {
- throw new YchException(E_DATA_TREE_CODEC);
- }
-
- // Get yang data tree from YTB for the received objects.
- DefaultYangTreeBuilder builder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder encodedYdt =
- builder.getYdtBuilderForYo(moduleList, rootName,
- rootNamespace, opType,
- schemaRegistry);
-
- encodedYdt.setRootTagAttributeMap(tagAttrMap);
-
- // Get the xml string form codec handler.
- return codec.encodeYdtToProtocolFormat(encodedYdt);
- }
-
- @Override
- public YangCompositeEncoding encodeCompositeOperation(
- String rootName,
- String rootNamespace,
- Object moduleObject,
- YangProtocolEncodingFormat dataFormat,
- YmsOperationType opType) {
-
- if (moduleObject == null) {
- throw new YtbException(E_MODULE_LIST);
- }
-
- // Get the default codec handler.
- YangDataTreeCodec codec = getAppropriateCodec(dataFormat);
- if (codec == null) {
- throw new YchException(E_DATA_TREE_CODEC);
- }
-
- List<Object> yangModuleList = new ArrayList<>();
- yangModuleList.add(moduleObject);
-
- // Get yang data tree from YTB for the received objects.
- DefaultYangTreeBuilder builder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder extBuilder =
- builder.getYdtBuilderForYo(yangModuleList,
- rootName,
- rootNamespace,
- opType,
- schemaRegistry);
-
- // Get the composite response from codec handler.
- return codec.encodeYdtToCompositeProtocolFormat(extBuilder);
- }
-
- @Override
- public List<Object> decode(String inputString,
- YangProtocolEncodingFormat dataFormat,
- YmsOperationType opType) {
-
- YdtBuilder ydtBuilder;
- YangDataTreeCodec codec = getAppropriateCodec(dataFormat);
- if (codec == null) {
- throw new YchException(E_DATA_TREE_CODEC);
- }
-
- try {
- // Get the YANG data tree
- ydtBuilder = codec.decodeProtocolDataToYdt(inputString,
- schemaRegistry,
- opType);
- } catch (Exception e) {
- throw new YchException(e.getLocalizedMessage());
- }
-
- if (ydtBuilder != null) {
- return getObjectList(ydtBuilder.getRootNode());
- }
- return null;
- }
-
- @Override
- public Object decode(YangCompositeEncoding protoData,
- YangProtocolEncodingFormat dataFormat,
- YmsOperationType opType) {
-
- YangDataTreeCodec codec = getAppropriateCodec(dataFormat);
- if (codec == null) {
- throw new YchException(E_DATA_TREE_CODEC);
- }
-
- YdtBuilder ydtBuilder =
- codec.decodeCompositeProtocolDataToYdt(protoData,
- schemaRegistry,
- opType);
-
- if (ydtBuilder == null) {
- return null;
- }
-
- YdtExtendedContext rootNode = ((YdtExtendedContext) ydtBuilder
- .getRootNode());
-
- if (opType == YmsOperationType.NOTIFICATION) {
- return getNotificationObject(((YdtExtendedContext) rootNode
- .getFirstChild()));
- }
-
- // Return the module object by using YANG data tree
- return getObjectList(rootNode);
- }
-
- //returns notification event object
- private Object getNotificationObject(YdtExtendedContext rootNode) {
- YangSchemaNode module = rootNode.getYangSchemaNode();
- YangSchemaNode childSchema = ((YdtExtendedContext) rootNode
- .getFirstChild()).getYangSchemaNode();
-
- YangSchemaNodeIdentifier id = new YangSchemaNodeIdentifier();
- id.setNameSpace(childSchema.getNameSpace());
- id.setName(childSchema.getName());
-
- YangSchemaNodeContextInfo contextInfo;
- try {
- contextInfo = module.getChildSchema(id);
- } catch (DataModelException e) {
- throw new YchException(E_DATA_MODEL_CHILD);
- }
-
- if (contextInfo == null) {
- throw new YchException(E_NOTIFICATION_NODE);
- }
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object object = builder.getYangObject(((YdtExtendedContext) rootNode
- .getFirstChild()),
- schemaRegistry);
-
- Object eventSubObj = createAndSetInEventSubjectInstance(object,
- rootNode,
- schemaRegistry);
- return createAndSetInEventInstance(eventSubObj, rootNode,
- schemaRegistry);
- }
-
- @Override
- public void registerOverriddenCodec(YangDataTreeCodec overrideCodec,
- YangProtocolEncodingFormat dataFormat) {
- overrideCodecs.put(dataFormat, overrideCodec);
- }
-
- /**
- * Returns the list of objects from YDT data tree.
- *
- * @param rootNode YDT root node
- * @return returns list of objects
- */
- private List<Object> getObjectList(YdtContext rootNode) {
-
- if (rootNode == null) {
- // TODO
- return null;
- }
-
- if (rootNode.getFirstChild() == null) {
- // TODO
- return null;
- }
-
- YdtContext curNode = rootNode.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object object = builder.getYangObject((YdtExtendedContext) curNode,
- schemaRegistry);
- List<Object> objectList = new ArrayList<>();
- objectList.add(object);
-
- // Check next module is exit or not. If exist get the object for that.
- while (curNode.getNextSibling() != null) {
- curNode = curNode.getNextSibling();
- object = builder.getYangObject((YdtExtendedContext) curNode,
- schemaRegistry);
- objectList.add(object);
- }
-
- return objectList;
- }
-
- /**
- * Returns module library for YSR.
- *
- * @return module library for YSR
- */
- public YangModuleLibrary getLibrary() {
- return library;
- }
-
- /**
- * Sets module library for YSR.
- *
- * @param library module library for YSR
- */
- public void setLibrary(YangModuleLibrary library) {
- this.library = library;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/YchException.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/YchException.java
deleted file mode 100644
index fbc51e4..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/YchException.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych;
-
-/**
- * Represents base class for exceptions in YCH operations.
- */
-public class YchException extends RuntimeException {
- private static final long serialVersionUID = 20160211L;
-
- /**
- * Creates a new YCH exception.
- */
- public YchException() {
- }
-
- /**
- * Creates a new YCH exception with given message.
- *
- * @param message the detail of exception in string
- */
- public YchException(String message) {
- super(message);
- }
-
- /**
- * Creates a new YCH exception from given message and cause.
- *
- * @param message the detail of exception in string
- * @param cause underlying cause of the error
- */
- public YchException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Creates a new YCH exception from cause.
- *
- * @param cause underlying cause of the error
- */
- public YchException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/CodecHandlerFactory.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/CodecHandlerFactory.java
deleted file mode 100644
index c17d3fa..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/CodecHandlerFactory.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs;
-
-
-import org.onosproject.yms.app.ych.YchException;
-import org.onosproject.yms.app.ych.defaultcodecs.xml.XmlCodecHandler;
-import org.onosproject.yms.app.ych.defaultcodecs.xml.XmlCodecMultiInstanceHandler;
-import org.onosproject.yms.app.ych.defaultcodecs.xml.XmlCodecMultiInstanceLeafHandler;
-import org.onosproject.yms.app.ych.defaultcodecs.xml.XmlCodecSingleInstanceHandler;
-import org.onosproject.yms.app.ych.defaultcodecs.xml.XmlCodecSingleInstanceLeafHandler;
-import org.onosproject.yms.ych.YangProtocolEncodingFormat;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
-import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_LEAF_VALUE_NODE;
-import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_NODE;
-import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_LEAF_VALUE_NODE;
-import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_NODE;
-
-/**
- * Represents an YCH handle factory to create different types of YANG data tree
- * node.
- */
-public final class CodecHandlerFactory {
-
- private static final Logger log =
- LoggerFactory.getLogger(CodecHandlerFactory.class);
- private static final String YDT_TYPE_ERROR = "YDT type is not supported.";
-
- /**
- * Map of xml codec handler.
- */
- private final Map<YdtType, XmlCodecHandler> handlerMap;
-
- /**
- * Creates a new codec handler factory.
- */
- private CodecHandlerFactory() {
- handlerMap = new HashMap<>();
- handlerMap.put(SINGLE_INSTANCE_NODE,
- new XmlCodecSingleInstanceHandler());
- handlerMap.put(MULTI_INSTANCE_NODE,
- new XmlCodecMultiInstanceHandler());
- handlerMap.put(SINGLE_INSTANCE_LEAF_VALUE_NODE,
- new XmlCodecSingleInstanceLeafHandler());
- handlerMap.put(MULTI_INSTANCE_LEAF_VALUE_NODE,
- new XmlCodecMultiInstanceLeafHandler());
- }
-
- /**
- * Returns YCH instance handler node instance.
- *
- * @param node YDT context node
- * @param format data format type expected from driver
- * @return returns YCH handler node instance
- */
- public XmlCodecHandler getCodecHandlerForContext(
- YdtContext node,
- YangProtocolEncodingFormat format) {
- if (format == XML) {
- XmlCodecHandler handler = handlerMap.get(node.getYdtType());
- if (handler == null) {
- throw new YchException(YDT_TYPE_ERROR + node.getYdtType());
- }
- return handler;
- }
- log.error("{} data format is not supported.", format);
- return null;
- }
-
- /*
- * Bill Pugh Singleton pattern. INSTANCE won't be instantiated until the
- * LazyHolder class is loaded via a call to the instance() method below.
- */
- private static class LazyHolder {
- private static final CodecHandlerFactory INSTANCE =
- new CodecHandlerFactory();
- }
-
- /**
- * Returns a reference to the Singleton Codec Handler factory.
- *
- * @return the singleton codec handler factory
- */
- public static CodecHandlerFactory instance() {
- return LazyHolder.INSTANCE;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/YangCodecRegistry.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/YangCodecRegistry.java
deleted file mode 100644
index 8b7badd..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/YangCodecRegistry.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs;
-
-import org.onosproject.yms.app.ych.defaultcodecs.xml.DefaultXmlCodec;
-import org.onosproject.yms.ych.YangDataTreeCodec;
-import org.onosproject.yms.ych.YangProtocolEncodingFormat;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
-
-/**
- * Default implementation of YANG codec registry.
- */
-public final class YangCodecRegistry {
-
- // no instantiation
- private YangCodecRegistry() {
- }
-
- /**
- * Default codec map.
- */
- private static final Map<YangProtocolEncodingFormat, YangDataTreeCodec>
- DEFAULT_CODECS = new HashMap<>();
-
- /**
- * Initialise the default codec map.
- */
- public static void initializeDefaultCodec() {
- DEFAULT_CODECS.put(XML, new DefaultXmlCodec());
- }
-
- /**
- * Returns the default codec map.
- *
- * @return the default codec map
- */
- public static Map<YangProtocolEncodingFormat, YangDataTreeCodec> getDefaultCodecs() {
- return Collections.unmodifiableMap(DEFAULT_CODECS);
- }
-
- /**
- * Registers a default codec for the specified data format.
- *
- * @param defaultCodec registered data tree codec
- * @param dataFormat protocol encoding data format
- */
- public static void registerDefaultCodec(
- YangDataTreeCodec defaultCodec,
- YangProtocolEncodingFormat dataFormat) {
- DEFAULT_CODECS.put(dataFormat, defaultCodec);
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/NetconfCodec.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/NetconfCodec.java
deleted file mode 100644
index a1138ce..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/NetconfCodec.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.netconf;
-
-import com.google.common.collect.ImmutableSet;
-import org.dom4j.Element;
-import org.onosproject.yms.app.ych.YchException;
-import org.onosproject.yms.ydt.YmsOperationType;
-
-import java.util.Iterator;
-import java.util.Set;
-
-import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.CONFIG;
-import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.DATA;
-import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.EDIT_CONFIG;
-import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.FILTER;
-import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.GET;
-import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.GET_CONFIG;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_REQUEST;
-
-/**
- * Represents an YCH netconf codec to find the root element in the xml string.
- */
-public class NetconfCodec {
-
- private static final String PROTO_OPER_ERROR = "Received protocol " +
- "operation is not same as in the XML string: ";
- private static final Set<String> ALLOWABLE_NAMES =
- ImmutableSet.of(CONFIG, DATA, FILTER);
-
- /**
- * Validate the operation type.
- *
- * @param elementName tag name in the xml string
- * @param opType operation type
- */
- private void validateOpType(String elementName, YmsOperationType opType) {
- switch (elementName) {
- // edit-config tag name is found in xml then check the
- // interaction type.
- case EDIT_CONFIG: {
- if (opType != EDIT_CONFIG_REQUEST) {
- throw new YchException(PROTO_OPER_ERROR + opType);
- }
- break;
- }
-
- // get-config tag name is found in xml then check the
- // interaction type.
- case GET_CONFIG: {
- if (opType != QUERY_CONFIG_REQUEST) {
- throw new YchException(PROTO_OPER_ERROR + opType);
- }
- break;
- }
-
- // get tag name is found in xml then check the interaction type.
- case GET: {
- if (opType != QUERY_REQUEST) {
- throw new YchException(PROTO_OPER_ERROR + opType);
- }
- break;
- }
-
- default: {
- //TODO
- }
- }
- }
-
- /**
- * Returns the data root element based on the NETCONF operation parameter.
- *
- * @param rootElement root element of document tree to find the root node
- * @param opType protocol operation being performed
- * @return the data root node element
- */
- public Element getDataRootElement(Element rootElement,
- YmsOperationType opType) {
-
- Element retElement = null;
- String elementName = rootElement.getName();
- try {
- validateOpType(elementName, opType);
- // If config tag name is found then set the root element node.
- if (DATA.equals(elementName)
- || CONFIG.equals(elementName)
- || FILTER.equals(elementName)) {
- return rootElement;
- }
-
- // If element has child node then traverse through the child node
- // by recursively calling getDataRootElement method.
- if (rootElement.hasContent() && !rootElement.isTextOnly()) {
- for (Iterator i = rootElement.elementIterator();
- i.hasNext();) {
- Element childElement = (Element) i.next();
- retElement = getDataRootElement(childElement, opType);
- }
- }
- } catch (Exception e) {
- // TODO
- }
-
- return retElement;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/NetconfCodecConstants.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/NetconfCodecConstants.java
deleted file mode 100644
index 2d0705b..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/NetconfCodecConstants.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.netconf;
-
-/**
- * Represents utilities constants which are used while codec encoding
- * and decoding.
- */
-public final class NetconfCodecConstants {
-
- // no instantiation
- private NetconfCodecConstants() {
- }
-
- /**
- * Static attribute for edit config string.
- */
- static final String EDIT_CONFIG = "edit-config";
-
- /**
- * Static attribute for edit config string.
- */
- static final String GET_CONFIG = "get-config";
-
- /**
- * Static attribute for edit config string.
- */
- static final String GET = "get";
-
- /**
- * Static attribute for edit config string.
- */
- static final String CONFIG = "config";
-
- /**
- * Static attribute for edit config string.
- */
- static final String DATA = "data";
-
- /**
- * Static attribute for edit config string.
- */
- static final String FILTER = "filter";
-
- /**
- * Static attribute for edit config string.
- */
- public static final String OPERATION = "operation";
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/package-info.java
deleted file mode 100644
index ca782ae..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/netconf/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of default codec handler for netconf related
- * operation.
- */
-package org.onosproject.yms.app.ych.defaultcodecs.netconf;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/package-info.java
deleted file mode 100644
index e344394..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Default codec to support protocol data format encoding and decoding of the YANG objects.
- */
-package org.onosproject.yms.app.ych.defaultcodecs;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/utils/DefaultCodecUtils.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/utils/DefaultCodecUtils.java
deleted file mode 100644
index c027dd1..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/utils/DefaultCodecUtils.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.utils;
-
-import com.google.common.base.Splitter;
-import com.google.common.collect.Lists;
-import org.onosproject.yms.app.ych.YchException;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.List;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_NODE;
-
-/**
- * Utils to complete the conversion between JSON and YDT(YANG DATA MODEL).
- */
-public final class DefaultCodecUtils {
-
- private static final Splitter SLASH_SPLITTER = Splitter.on('/');
- private static final Splitter COMMA_SPLITTER = Splitter.on(',');
- private static final String EQUAL = "=";
- private static final String COMMA = ",";
- private static final String COLON = ":";
- private static final String URI_ENCODING_CHAR_SET = "ISO-8859-1";
- private static final String URI_NULL_CHECK_ERROR = "uri identifier " +
- "should not be null";
- private static final String URI_MODULE_FORMAT = "Illegal URI, First " +
- "node should be in format \"moduleName:nodeName\"";
-
- private static final String URI_LEAF_FORMAT = "Illegal URI, List or " +
- "Leaf-list node should be in format \"nodeName=key\"or " +
- "\"nodeName=instance-value\"";
-
- // no instantiation
- private DefaultCodecUtils() {
- }
-
- /**
- * Converts URI identifier to YDT builder.
- *
- * @param identifier the uri identifier from web request
- * @param builder the base YDT builder
- * @param ydtOpType the YDT context operation type
- * @return the YDT builder with the tree info of identifier
- */
- public static YdtBuilder convertUriToYdt(
- String identifier,
- YdtBuilder builder,
- YdtContextOperationType ydtOpType) {
- checkNotNull(identifier, URI_NULL_CHECK_ERROR);
- List<String> segmentPaths =
- urlPathArgsDecode(SLASH_SPLITTER.split(identifier));
- if (segmentPaths.isEmpty()) {
- return null;
- }
- processPathSegments(segmentPaths, builder, ydtOpType);
- return builder;
- }
-
- /**
- * Converts a list of path segments to a YDT builder tree.
- *
- * @param paths the list of path segments split from URI
- * @param builder the base YDT builder
- * @param ydtOpType the YDT context operation type
- * @return the YDT builder with the tree info of paths
- */
- private static YdtBuilder processPathSegments(
- List<String> paths,
- YdtBuilder builder,
- YdtContextOperationType ydtOpType) {
- if (paths.isEmpty()) {
- return builder;
- }
- boolean isLastNode = paths.size() == 1;
- YdtContextOperationType thisOpType = isLastNode ? ydtOpType : NONE;
-
- final String path = paths.iterator().next();
- if (path.contains(COLON)) {
- addModule(builder, path);
- addNode(path, builder, thisOpType);
- } else if (path.contains(EQUAL)) {
- addListOrLeafList(path, builder, thisOpType);
- } else {
- addLeaf(path, builder, thisOpType);
- }
-
- if (isLastNode) {
- return builder;
- }
- List<String> remainPaths = paths.subList(1, paths.size());
- processPathSegments(remainPaths, builder, ydtOpType);
-
- return builder;
- }
-
- /**
- * Returns YDT builder after adding module node.
- *
- * @param builder YDT builder
- * @param path path segment
- * @return the YDT builder
- */
- private static YdtBuilder addModule(YdtBuilder builder, String path) {
- String moduleName = getPreSegment(path, COLON);
- if (moduleName == null) {
- throw new YchException(URI_MODULE_FORMAT);
- }
- builder.addChild(moduleName, null, SINGLE_INSTANCE_NODE);
- return builder;
- }
-
- /**
- * Returns YDT builder after adding single instance node.
- *
- * @param path path segments
- * @param builder YDT builder
- * @param ydtOpType YDT context operation type
- * @return the YDT builder
- */
- private static YdtBuilder addNode(String path, YdtBuilder builder,
- YdtContextOperationType ydtOpType) {
- String nodeName = getPostSegment(path, COLON);
- builder.addChild(nodeName, null, SINGLE_INSTANCE_NODE, ydtOpType);
- return builder;
- }
-
- /**
- * Returns YDT builder after adding multi instance node.
- *
- * @param path path segments
- * @param builder YDT builder
- * @param opType the YDT context operation type
- * @return the YDT builder
- */
- private static YdtBuilder addListOrLeafList(
- String path,
- YdtBuilder builder,
- YdtContextOperationType opType) {
- String nodeName = getPreSegment(path, EQUAL);
- String keyStr = getPostSegment(path, EQUAL);
- if (keyStr == null) {
- throw new YchException(URI_LEAF_FORMAT);
- }
- builder.setDefaultEditOperationType(opType);
- if (keyStr.contains(COMMA)) {
- List<String> keys = Lists.newArrayList(
- COMMA_SPLITTER.split(keyStr));
- builder.addMultiInstanceChild(nodeName, null, keys, null);
- } else {
- builder.addMultiInstanceChild(nodeName, null,
- Lists.newArrayList(keyStr), null);
- }
- return builder;
- }
-
- /**
- * Returns YDT builder after adding leaf.
- *
- * @param path path segments
- * @param builder YDT builder
- * @param ydtOpType YDT context operation type
- * @return the YDT builder
- */
- private static YdtBuilder addLeaf(String path, YdtBuilder builder,
- YdtContextOperationType ydtOpType) {
- checkNotNull(path);
- builder.addChild(path, null, ydtOpType);
- return builder;
- }
-
- /**
- * Returns the node name before the specified character in the string.
- *
- * @param path path segment
- * @param splitChar character in the string
- * @return the node name string
- */
- private static String getPreSegment(String path, String splitChar) {
- int idx = path.indexOf(splitChar);
- if (idx == -1) {
- return null;
- }
-
- if (path.indexOf(':', idx + 1) != -1) {
- return null;
- }
-
- return path.substring(0, idx);
- }
-
- /**
- * Returns the string after the specified character in the string.
- *
- * @param path path segment
- * @param splitChar character in the string
- * @return the substring after specified character
- */
- private static String getPostSegment(String path, String splitChar) {
- int idx = path.indexOf(splitChar);
- if (idx == -1) {
- return path;
- }
-
- if (path.indexOf(splitChar, idx + 1) != -1) {
- return null;
- }
-
- return path.substring(idx + 1);
- }
-
- /**
- * Converts a list of path from the original format to ISO-8859-1 code.
- *
- * @param paths the original paths
- * @return list of decoded paths
- */
- private static List<String> urlPathArgsDecode(Iterable<String> paths) {
- try {
- List<String> decodedPathArgs = new ArrayList<>();
- for (String pathArg : paths) {
- String decode = URLDecoder.decode(pathArg,
- URI_ENCODING_CHAR_SET);
- decodedPathArgs.add(decode);
- }
- return decodedPathArgs;
- } catch (UnsupportedEncodingException e) {
- throw new YchException("Invalid URL path arg '" + paths + "': ", e);
- }
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/utils/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/utils/package-info.java
deleted file mode 100644
index dea920f..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/utils/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of default codec utilities.
- */
-package org.onosproject.yms.app.ych.defaultcodecs.utils;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/DefaultXmlCodec.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/DefaultXmlCodec.java
deleted file mode 100644
index 4fd5613..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/DefaultXmlCodec.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.xml;
-
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.DocumentHelper;
-import org.dom4j.Element;
-import org.dom4j.Namespace;
-import org.onosproject.yms.app.ych.YchException;
-import org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodec;
-import org.onosproject.yms.app.ych.defaultcodecs.utils.DefaultCodecUtils;
-import org.onosproject.yms.app.ydt.DefaultYdtWalker;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtExtendedWalker;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.ych.YangCompositeEncoding;
-import org.onosproject.yms.ych.YangDataTreeCodec;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YmsOperationType;
-
-import java.util.Map;
-
-import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
-import static org.onosproject.yms.ydt.YdtContextOperationType.CREATE;
-
-/**
- * Represents an implementation of YCH data tree codec interface.
- */
-public class DefaultXmlCodec implements YangDataTreeCodec {
-
- private static final String E_RESTCONF_ROOT = "/onos/restconf";
- private static final String E_YDT_ROOT_NODE = "YDT extended root node " +
- "is null.";
- private static final String E_ROOT_ELEMENT = "Root element in XML " +
- "input string is not well-formed.";
- private static final String E_ROOT_KEY_ELEMENT = "Root element " +
- "(filter, config, data) in XML input string is not found.";
-
-
- /**
- * Creates a new YANG xml codec.
- */
- public DefaultXmlCodec() {
- }
-
- /**
- * Returns the xml string from YDT.
- *
- * @param ydtBuilder YDT builder
- * @return the xml string from YDT
- */
- private String buildXmlForYdt(YdtBuilder ydtBuilder) {
-
- YdtExtendedBuilder extBuilder = (YdtExtendedBuilder) ydtBuilder;
- YdtExtendedContext rootNode = extBuilder.getRootNode();
-
- if (rootNode == null) {
- throw new YchException(E_YDT_ROOT_NODE);
- }
-
- // Creating the root element for xml.
- Element rootElement =
- DocumentHelper.createDocument().addElement(rootNode.getName());
-
- // Adding the name space if exist for root name.
- if (rootNode.getNamespace() != null) {
- rootElement.add(Namespace.get(rootNode.getNamespace()));
- }
-
- if ("config".equals(rootElement.getName())) {
- rootElement.add(new Namespace("nc", "urn:ietf:params:xml:ns:netconf:base:1.0"));
- }
-
- // Adding the attribute if exist
- Map<String, String> tagAttrMap = extBuilder.getRootTagAttributeMap();
- if (tagAttrMap != null && !tagAttrMap.isEmpty()) {
- for (Map.Entry<String, String> attr : tagAttrMap.entrySet()) {
- rootElement.addAttribute(attr.getKey(), attr.getValue());
- }
- }
-
- XmlCodecYdtListener listener = new XmlCodecYdtListener(XML, rootNode);
- listener.getElementStack().push(rootElement);
-
- // Walk through YDT and build the xml.
- YdtExtendedWalker extWalker = new DefaultYdtWalker();
- extWalker.walk(listener, rootNode);
-
- return rootElement.asXML();
- }
-
- @Override
- public String encodeYdtToProtocolFormat(YdtBuilder ydtBuilder) {
- return buildXmlForYdt(ydtBuilder);
- }
-
- @Override
- public YangCompositeEncoding encodeYdtToCompositeProtocolFormat(
- YdtBuilder ydtBuilder) {
-
- YangCompositeEncodingImpl encoding = new YangCompositeEncodingImpl();
- encoding.setResourceIdentifier(null);
- encoding.setResourceInformation(buildXmlForYdt(ydtBuilder));
- return encoding;
- }
-
- @Override
- public YdtBuilder decodeCompositeProtocolDataToYdt(
- YangCompositeEncoding protoData,
- Object schemaReg,
- YmsOperationType opType) {
-
- YdtExtendedBuilder extBuilder =
- new YangRequestWorkBench(E_RESTCONF_ROOT, null,
- opType,
- (YangSchemaRegistry) schemaReg,
- false);
-
- DefaultCodecUtils.convertUriToYdt(protoData.getResourceIdentifier(),
- extBuilder,
- CREATE);
- Document document;
-
- try {
- document = DocumentHelper
- .parseText(protoData.getResourceInformation());
- } catch (DocumentException e) {
- throw new YchException(E_ROOT_ELEMENT);
- }
-
- XmlCodecListener listener = new XmlCodecListener();
- listener.setYdtExtBuilder(extBuilder);
-
- // Walk through xml and build the yang data tree.
- XmlWalker walker = new DefaultXmlCodecWalker();
- walker.walk(listener, document.getRootElement(),
- document.getRootElement());
- return extBuilder;
- }
-
- @Override
- public YdtBuilder decodeProtocolDataToYdt(String protoData,
- Object schemaReg,
- YmsOperationType opType) {
- Document document;
-
- try {
- document = DocumentHelper.parseText(protoData);
- } catch (DocumentException e) {
- throw new YchException(E_ROOT_ELEMENT);
- }
-
- NetconfCodec codec = new NetconfCodec();
- // Find the root element in xml string
- Element rootElement =
- codec.getDataRootElement(document.getRootElement(), opType);
-
- if (rootElement == null) {
- throw new YchException(E_ROOT_KEY_ELEMENT);
- }
-
- // Get the YDT builder for the logical root name.
- YdtExtendedBuilder extBuilder =
- new YangRequestWorkBench(rootElement.getName(),
- rootElement.getNamespaceURI(),
- opType,
- (YangSchemaRegistry) schemaReg,
- false);
-
- XmlCodecListener listener = new XmlCodecListener();
- listener.setYdtExtBuilder(extBuilder);
- // Walk through xml and build the yang data tree.
- XmlWalker walker = new DefaultXmlCodecWalker();
- walker.walk(listener, rootElement, rootElement);
- return extBuilder;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/DefaultXmlCodecWalker.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/DefaultXmlCodecWalker.java
deleted file mode 100644
index 290d4c3..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/DefaultXmlCodecWalker.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.xml;
-
-import org.dom4j.Element;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Iterator;
-
-import static org.onosproject.yms.app.ych.defaultcodecs.xml.XmlNodeType.OBJECT_NODE;
-import static org.onosproject.yms.app.ych.defaultcodecs.xml.XmlNodeType.TEXT_NODE;
-
-/**
- * Represents implementation of codec xml walker.
- */
-class DefaultXmlCodecWalker implements XmlWalker {
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Override
- public void walk(XmlListener listener, Element element,
- Element rootElement) {
- try {
- Element newElement = element.createCopy();
- newElement.remove(element.getNamespace());
-
- listener.enterXmlElement(element, getElementType(newElement),
- rootElement);
-
- if (element.hasContent() && !element.isTextOnly()) {
- for (Iterator i = element.elementIterator(); i.hasNext();) {
- Element childElement = (Element) i.next();
- walk(listener, childElement, rootElement);
- }
- }
-
- listener.exitXmlElement(element, getElementType(element),
- rootElement);
- } catch (Exception e) {
- log.error("Exception occurred when walk xml element: {}", element);
- }
- }
-
- /**
- * Determine the type of an element.
- *
- * @param element to be analysed
- * @return type of the element
- */
- private XmlNodeType getElementType(Element element) {
- return element.hasContent() && element.isTextOnly() ?
- TEXT_NODE : OBJECT_NODE;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecHandler.java
deleted file mode 100644
index cd9fc4f..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecHandler.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.xml;
-
-import org.dom4j.Element;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-
-import java.util.Stack;
-
-import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.OPERATION;
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-
-/**
- * Represents an codec handler to process the xml content and add
- * element to the stack.
- */
-public abstract class XmlCodecHandler {
-
- /**
- * Sets the namespace and tag name in element tree maintained in stack.
- *
- * @param ydtContext YDT context
- * @param elementStack element tree stack
- */
- void processXmlContext(YdtContext ydtContext,
- Stack<Element> elementStack) {
-
- Element newElement = updateNameAndNamespace(ydtContext,
- elementStack.peek());
- elementStack.push(newElement);
- }
-
- /**
- * Returns the new element name by updating tag name and namespace.
- *
- * @param ydtContext YDT context node
- * @param xmlElement element in the stack used for adding new element
- * @return new element name by updating tag name and namespace
- */
- Element updateNameAndNamespace(YdtContext ydtContext,
- Element xmlElement) {
- String nameSpace = null;
- if (ydtContext.getNamespace() != null) {
- nameSpace = ydtContext.getNamespace();
- }
-
- String parentNameSpace = null;
- if (ydtContext.getParent() != null) {
- parentNameSpace = ydtContext.getParent().getNamespace();
- }
-
- Element newElement;
- if (nameSpace != null) {
- newElement = xmlElement.addElement(ydtContext.getName(),
- nameSpace);
- } else {
- if (parentNameSpace != null) {
- newElement = xmlElement.addElement(ydtContext.getName(),
- parentNameSpace);
- } else {
- newElement = xmlElement.addElement(ydtContext.getName());
- }
- }
-
- YdtContextOperationType opType = ((YdtExtendedContext) ydtContext)
- .getYdtContextOperationType();
- if (opType != null && opType != NONE) {
- newElement.addAttribute("nc:" + OPERATION,
- opType.toString().toLowerCase());
- }
-
- return newElement;
- }
-
- /**
- * Sets the leaf value in the current element maintained in stack.
- * Default behaviour is to do nothing.
- *
- * @param ydtContext YDT context node
- * @param domElementStack current element node in the stack
- */
- public void setXmlValue(YdtContext ydtContext,
- Stack<Element> domElementStack) {
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecListener.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecListener.java
deleted file mode 100644
index 513785a..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecListener.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.xml;
-
-import org.dom4j.Attribute;
-import org.dom4j.Element;
-import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-
-import java.util.Iterator;
-
-import static org.onosproject.yms.app.ych.defaultcodecs.netconf.NetconfCodecConstants.OPERATION;
-import static org.onosproject.yms.app.ych.defaultcodecs.xml.XmlNodeType.OBJECT_NODE;
-import static org.onosproject.yms.app.ych.defaultcodecs.xml.XmlNodeType.TEXT_NODE;
-
-/**
- * Default implementation of codec xml listener.
- */
-class XmlCodecListener implements XmlListener {
-
- /**
- * YANG data tree builder object.
- */
- private YdtExtendedBuilder ydtExtBuilder;
-
- private String prevNodeNamespace;
-
- /**
- * Sets the YANG data tree builder object.
- *
- * @param ydtBuilder YANG data tree builder object
- */
- void setYdtExtBuilder(YdtExtendedBuilder ydtBuilder) {
- ydtExtBuilder = ydtBuilder;
- }
-
- @Override
- public void enterXmlElement(Element element, XmlNodeType nodeType,
- Element rootElement) {
- if (element.equals(rootElement)) {
- return;
- }
-
- YdtContextOperationType opType = null;
-
- for (Iterator iter = element.attributeIterator(); iter.hasNext();) {
- Attribute attr = (Attribute) iter.next();
- if (attr.getName().equals(OPERATION)) {
- opType =
- YdtContextOperationType.valueOf(attr.getValue()
- .toUpperCase());
- }
- }
-
- String nameSpace = null;
- if (element.getNamespace() != null) {
- nameSpace = element.getNamespace().getURI();
- }
-
- /*
- * When new module has to be added, and if curnode has reference of
- * previous module, then we need to traverse back to parent(logical
- * root node).
- */
- if (ydtExtBuilder.getRootNode() == ydtExtBuilder.getCurNode()
- .getParent() && prevNodeNamespace != null &&
- !prevNodeNamespace.equals(nameSpace)) {
- ydtExtBuilder.traverseToParent();
- }
-
- if (nodeType == OBJECT_NODE &&
- (element.content() == null || element.content().isEmpty())) {
- if (ydtExtBuilder != null) {
- if (ydtExtBuilder.getCurNode() == ydtExtBuilder.getRootNode()) {
- ydtExtBuilder.addChild(null, nameSpace, opType);
- }
- ydtExtBuilder.addNode(element.getName(), nameSpace);
- }
- } else if (nodeType == OBJECT_NODE) {
- if (ydtExtBuilder != null) {
- if (ydtExtBuilder.getCurNode() == ydtExtBuilder.getRootNode()) {
- ydtExtBuilder.addChild(null, nameSpace, opType);
- }
- ydtExtBuilder.addChild(element.getName(), nameSpace, opType);
- }
- } else if (nodeType == TEXT_NODE) {
- if (ydtExtBuilder != null) {
- if (ydtExtBuilder.getCurNode() == ydtExtBuilder.getRootNode()) {
- ydtExtBuilder.addChild(null, nameSpace, opType);
- }
- ydtExtBuilder.addLeaf(element.getName(), nameSpace,
- element.getText());
- }
- }
-
- if (nameSpace != null) {
- prevNodeNamespace = nameSpace;
- }
- }
-
- @Override
- public void exitXmlElement(Element element, XmlNodeType nodeType,
- Element rootElement) {
- if (element.equals(rootElement)) {
- return;
- }
-
- if (ydtExtBuilder != null) {
- ydtExtBuilder.traverseToParent();
- }
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecMultiInstanceHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecMultiInstanceHandler.java
deleted file mode 100644
index a123932..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecMultiInstanceHandler.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.xml;
-
-/**
- * Represents a multi instance node handler in YCH.
- */
-public class XmlCodecMultiInstanceHandler extends XmlCodecHandler {
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecMultiInstanceLeafHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecMultiInstanceLeafHandler.java
deleted file mode 100644
index 53f8230..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecMultiInstanceLeafHandler.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.xml;
-
-import org.dom4j.Element;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.util.Iterator;
-import java.util.Stack;
-
-/**
- * Represents a multi instance leaf node handler in YCH.
- */
-public class XmlCodecMultiInstanceLeafHandler extends XmlCodecHandler {
-
- @Override
- public void setXmlValue(YdtContext ydtContext,
- Stack<Element> elementStack) {
-
- if (ydtContext.getValueSet().isEmpty()) {
- return;
- }
-
- Iterator<String> iterator = ydtContext.getValueSet().iterator();
- elementStack.peek().setText(iterator.next());
- Element topOfStack = elementStack.pop();
- Element parent = elementStack.peek();
-
- while (iterator.hasNext()) {
- Element newElement = updateNameAndNamespace(ydtContext, parent);
- newElement.setText(iterator.next());
- }
- elementStack.push(topOfStack);
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecSingleInstanceHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecSingleInstanceHandler.java
deleted file mode 100644
index 252fbd0..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecSingleInstanceHandler.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.xml;
-
-/**
- * Represents a single instance node handler in YCH.
- */
-public class XmlCodecSingleInstanceHandler extends XmlCodecHandler {
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecSingleInstanceLeafHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecSingleInstanceLeafHandler.java
deleted file mode 100644
index 8217cda..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecSingleInstanceLeafHandler.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.xml;
-
-import org.dom4j.Element;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.util.Stack;
-
-/**
- * Represents a single instance leaf node handler in YCH.
- */
-public class XmlCodecSingleInstanceLeafHandler extends XmlCodecHandler {
-
- @Override
- public void setXmlValue(YdtContext ydtContext,
- Stack<Element> elementStack) {
-
- if (ydtContext.getValue() != null) {
- elementStack.peek().setText(ydtContext.getValue());
- }
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecYdtListener.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecYdtListener.java
deleted file mode 100644
index 6a26a6e..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlCodecYdtListener.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.xml;
-
-import org.dom4j.Element;
-import org.onosproject.yms.app.ych.defaultcodecs.CodecHandlerFactory;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtExtendedListener;
-import org.onosproject.yms.ych.YangProtocolEncodingFormat;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.util.Objects;
-import java.util.Stack;
-
-import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
-
-/**
- * Represents implementation of codec YANG data object listener.
- */
-class XmlCodecYdtListener implements YdtExtendedListener {
-
- /**
- * Data format type requested from driver.
- */
- private YangProtocolEncodingFormat dataFormat;
-
- /**
- * Stack for element is maintained for hierarchical references, this is
- * used during YDT walker and preparation of xml/json.
- */
- private final Stack<Element> elementStack = new Stack<>();
-
- /**
- * Root name received from driver.
- */
- private YdtExtendedContext rootYdtNode;
-
- /**
- * Module YDT node.
- */
- private YdtExtendedContext currentModule;
-
- /**
- * Creates a new codec listener.
- *
- * @param format protocol data format
- * @param rootNode extended YDT root node
- */
- XmlCodecYdtListener(YangProtocolEncodingFormat format,
- YdtExtendedContext rootNode) {
- dataFormat = format;
- rootYdtNode = rootNode;
- currentModule = ((YdtExtendedContext) rootNode.getFirstChild());
- }
-
- /**
- * Returns the stack for the element.
- *
- * @return the stack for the element
- */
- Stack<Element> getElementStack() {
- return elementStack;
- }
-
- /**
- * Returns true, if YDT node is module node; false otherwise.
- *
- * @param ydtContext YDT node
- * @return true if YDT node is module; false otherwise
- */
- private boolean isModuleNode(YdtExtendedContext ydtContext,
- boolean isExit) {
- if (Objects.equals(currentModule, ydtContext)) {
- if (isExit) {
- currentModule = (YdtExtendedContext) currentModule
- .getNextSibling();
- }
- return true;
- }
- return false;
- }
-
- @Override
- public void enterYdtNode(YdtExtendedContext ydtContext) {
-
- if (!Objects.equals(rootYdtNode, ydtContext) &&
- !isModuleNode(ydtContext, false)) {
-
- CodecHandlerFactory factory = CodecHandlerFactory.instance();
- XmlCodecHandler handler =
- factory.getCodecHandlerForContext(ydtContext, dataFormat);
- try {
- if (dataFormat == XML && handler != null) {
- handler.processXmlContext(ydtContext, elementStack);
- }
- } catch (Exception e) {
- // TODO
- }
-
- if (dataFormat == XML && handler != null) {
- handler.setXmlValue(ydtContext, elementStack);
- }
- }
- }
-
- @Override
- public void exitYdtNode(YdtExtendedContext ydtExtendedContext) {
- if (!Objects.equals(rootYdtNode, ydtExtendedContext) &&
- !isModuleNode(ydtExtendedContext, true)) {
- elementStack.pop();
- }
- }
-
- @Override
- public void enterYdtNode(YdtContext ydtContext) {
- }
-
- @Override
- public void exitYdtNode(YdtContext ydtContext) {
- }
-
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlListener.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlListener.java
deleted file mode 100644
index db64dea..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlListener.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.xml;
-
-import org.dom4j.Element;
-
-/**
- * Abstraction of an entity which provide call back methods which are called
- * by xml walker while walking the xml data tree. This interface needs to be
- * implemented by protocol implementing listener's based call backs while
- * xml walk.
- */
-interface XmlListener {
-
- /**
- * Callback invoked during a node entry. All the related information
- * about the node can be obtained from the element.
- *
- * @param element current xml node(element)
- * @param nodeType xml node type
- * @param rootElement root element
- */
- void enterXmlElement(Element element, XmlNodeType nodeType,
- Element rootElement);
-
- /**
- * Callback invoked during a node exit. All the related information
- * about the node can be obtained from the element.
- *
- * @param element current xml node(element)
- * @param nodeType xml node type
- * @param rootElement root element
- */
- void exitXmlElement(Element element, XmlNodeType nodeType,
- Element rootElement);
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlNodeType.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlNodeType.java
deleted file mode 100644
index 9d92b0b..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlNodeType.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.xml;
-
-/**
- * Represents type of node in xml data tree.
- */
-enum XmlNodeType {
- /**
- * An object node has at least one child node.
- */
- OBJECT_NODE,
-
- /**
- * A text node has no child node, and has a text value.
- */
- TEXT_NODE
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlWalker.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlWalker.java
deleted file mode 100644
index 1a3078d..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/XmlWalker.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.xml;
-
-import org.dom4j.Element;
-
-/**
- * Abstraction of an entity which provides interfaces for xml walk.
- * This interface serve as common tools for anyone who needs to parse the xml
- * node with depth-first algorithm.
- */
-interface XmlWalker {
- /**
- * Walks the xml data tree. Protocols implements xml listener service
- * and walks xml tree with input as implemented object. xml walker provides
- * call backs to implemented methods.
- *
- * @param listener xml listener implemented by the protocol
- * @param walkElement root node(element) of the xml data tree
- * @param rootElement logical root node(element) of the xml data tree
- */
- void walk(XmlListener listener, Element walkElement, Element rootElement);
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/YangCompositeEncodingImpl.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/YangCompositeEncodingImpl.java
deleted file mode 100644
index 7ffc91e..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/YangCompositeEncodingImpl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych.defaultcodecs.xml;
-
-import org.onosproject.yms.ych.YangCompositeEncoding;
-import org.onosproject.yms.ych.YangResourceIdentifierType;
-
-/**
- * Represents implementation of YangCompositeEncoding interfaces.
- */
-class YangCompositeEncodingImpl implements YangCompositeEncoding {
-
- /**
- * Resource identifier for composite encoding.
- */
- private String resourceIdentifier;
-
- /**
- * Resource information for composite encoding.
- */
- private String resourceInformation;
-
- /**
- * Resource identifier type.
- */
- private YangResourceIdentifierType resourceIdentifierType;
-
- @Override
- public void setResourceIdentifier(String resourceId) {
- resourceIdentifier = resourceId;
- }
-
- @Override
- public void setResourceInformation(String resourceInfo) {
- resourceInformation = resourceInfo;
- }
-
- @Override
- public void setResourceIdentifierType(YangResourceIdentifierType idType) {
- resourceIdentifierType = idType;
- }
-
- @Override
- public String getResourceIdentifier() {
- return resourceIdentifier;
- }
-
- @Override
- public YangResourceIdentifierType getResourceIdentifierType() {
- return resourceIdentifierType;
- }
-
- @Override
- public String getResourceInformation() {
- return resourceInformation;
- }
-}
-
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/package-info.java
deleted file mode 100644
index b9fbb7c..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/defaultcodecs/xml/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of default codec handler for xml related
- * operation.
- */
-package org.onosproject.yms.app.ych.defaultcodecs.xml;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/package-info.java
deleted file mode 100644
index 97bd542..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ych/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides interfaces to YANG codec utility.
- * YANG codec utility provides interfaces which can be used by the driver / provider to
- * translate protocol specific data representation to YANG modeled objects.
- */
-package org.onosproject.yms.app.ych;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppData.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppData.java
deleted file mode 100644
index bc1021a..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppData.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-
-/**
- * Maintains application data, which will be used by Application broker to
- * interact with applications.
- */
-public interface AppData {
-
- /**
- * Returns the schema node current context.
- *
- * @return schema node
- */
- YangSchemaNode getSchemaNode();
-
- /**
- * Returns the root/module schema node current application.
- *
- * @return schema node
- */
- YangSchemaNode getRootSchemaNode();
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppNodeFactory.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppNodeFactory.java
deleted file mode 100644
index 8917b52..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppNodeFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-/**
- * Represents an application tree node factory to create different types of
- * application tree node.
- */
-public final class AppNodeFactory {
-
- // No instantiation
- private AppNodeFactory() {
- }
-
- /**
- * Returns the appropriate application context on the basis of provided
- * isAugmented flag for given request.
- *
- * @param flag true for augmented context; false for module context
- * @return appContext application context
- */
- public static DefaultYdtAppContext getAppContext(boolean flag) {
- return flag ? new DefaultYdtAppContext(new AugmentedSchemaData()) :
- new DefaultYdtAppContext(new ModuleSchemaData());
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppType.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppType.java
deleted file mode 100644
index 3b49ec2..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AppType.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-/**
- * Represents type of application, which is intended to maintain additional
- * information in YDT node.
- */
-public enum AppType {
-
- /**
- * YANG tree builder application.
- */
- YTB,
-
- /**
- * YANG object builder application.
- */
- YOB
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AugmentAppData.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AugmentAppData.java
deleted file mode 100644
index 88d1bb3..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AugmentAppData.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-
-/**
- * Represents an augmented node in application tree.
- */
-interface AugmentAppData extends AppData {
-
- /**
- * Returns the YangSchemaNode of augmenting application.
- *
- * @return YangSchemaNode of augmenting application
- */
- YangSchemaNode getAugmentingSchemaNode();
-
- /**
- * Sets the YangSchemaNode of augmenting application root node.
- *
- * @param schemaNode YangSchemaNode of augmenting application module
- */
- void setAugmentingSchemaNode(YangSchemaNode schemaNode);
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AugmentedSchemaData.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AugmentedSchemaData.java
deleted file mode 100644
index 221e564..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/AugmentedSchemaData.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-
-/**
- * Manages the application information required for schema nodes defined in
- * the module (sub-module).
- */
-public class AugmentedSchemaData implements AugmentAppData {
-
- /*
- * Reference for schema node of augmenting application.
- */
- private YangSchemaNode augModSchema;
-
- @Override
- public YangSchemaNode getAugmentingSchemaNode() {
- return augModSchema;
- }
-
- @Override
- public void setAugmentingSchemaNode(YangSchemaNode schemaNode) {
- augModSchema = schemaNode;
- }
-
- @Override
- public YangSchemaNode getSchemaNode() {
- return augModSchema;
- }
-
- @Override
- public YangSchemaNode getRootSchemaNode() {
- return ((YangNode) getSchemaNode()).getParent();
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/DefaultYdtAppContext.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/DefaultYdtAppContext.java
deleted file mode 100644
index 6f9dbeb..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/DefaultYdtAppContext.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-
-import java.util.List;
-
-import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.BOTH;
-import static org.onosproject.yms.app.ydt.YdtUtils.getAppOpTypeFromYdtOpType;
-
-/**
- * Abstraction of an entity which represents YDT application context
- * information. This context information will be used by protocol to obtain
- * the information associated with YDT application tree node.
- */
-public final class DefaultYdtAppContext<T extends AppData>
- implements YdtAppContext {
-
- /*
- * Parent reference.
- */
- private YdtAppContext parent;
-
- /*
- * First child reference.
- */
- private YdtAppContext child;
-
- /*
- * Next sibling reference.
- */
- private YdtAppContext nextSibling;
-
- /*
- * Previous sibling reference.
- */
- private YdtAppContext previousSibling;
-
- /*
- * Last child reference.
- */
- private YdtAppContext lastChild;
-
- /*
- * YDT application tree extended information.
- */
- private final T appData;
-
- /*
- * Reference for operation type for application root node.
- */
- private YdtAppNodeOperationType operationType;
-
- /**
- * Creates an instance of YANG application tree which is used by all node
- * needs delete list.
- *
- * @param data application data
- */
- DefaultYdtAppContext(T data) {
- appData = data;
- }
-
- @Override
- public void updateAppOperationType(YdtContextOperationType ydtOpType) {
- if (parent == null) {
- return;
- }
- YdtAppNodeOperationType opType = getAppOpTypeFromYdtOpType(ydtOpType);
- YdtAppContext curNode = this;
- YdtAppNodeOperationType parentOpType = operationType;
- if (opType != parentOpType) {
- if (parentOpType != null) {
- while (curNode.getOperationType() != BOTH &&
- curNode.getParent() != null) {
- curNode.setOperationType(BOTH);
- curNode = curNode.getParent();
- }
- } else {
- // If operation type for ydt node is "NONE" then in that
- // case operation type for module node in app tree set as null.
- // Once the target node operation type received by ydt then
- // operation type for module node will be updated with the
- // same target node operation type in app tree.
- while (curNode.getParent() != null && curNode
- .getOperationType() == null) {
- curNode.setOperationType(opType);
- curNode = curNode.getParent();
- }
- }
- }
- }
-
- @Override
- public void setAppData(YdtNode moduleNode, YangSchemaNode augmentNode) {
- if (augmentNode != null) {
- ((AugmentAppData) appData).setAugmentingSchemaNode(augmentNode);
- } else {
- ((ModuleAppData) appData).setModuleContext(moduleNode);
- }
- }
-
- @Override
- public AppData getAppData() {
- return appData;
- }
-
- @Override
- public YdtAppContext getParent() {
- return parent;
- }
-
- @Override
- public void setParent(YdtAppContext parent) {
- this.parent = parent;
- }
-
- @Override
- public YdtAppContext getFirstChild() {
- return child;
- }
-
- /**
- * Sets the context of first child.
- *
- * @param child node
- */
- private void setChild(YdtAppContext child) {
- this.child = child;
- }
-
- @Override
- public YdtAppContext getNextSibling() {
- return nextSibling;
- }
-
- @Override
- public void setNextSibling(YdtAppContext context) {
- this.nextSibling = context;
- }
-
- @Override
- public YdtAppContext getPreviousSibling() {
- return previousSibling;
- }
-
- @Override
- public void setPreviousSibling(YdtAppContext context) {
- this.previousSibling = context;
- }
-
- @Override
- public YdtAppNodeOperationType getOperationType() {
- return operationType;
- }
-
- @Override
- public void setOperationType(YdtAppNodeOperationType opType) {
- operationType = opType;
- }
-
- @Override
- public List<YdtContext> getDeleteNodes() {
- return ((ModuleAppData) appData).getDeleteNodes();
- }
-
- @Override
- public void addDeleteNode(YdtNode node) {
- DefaultYdtAppContext<?> curNode = this;
- while (curNode.getParent().getParent() != null) {
- curNode = (DefaultYdtAppContext<?>) curNode.getParent();
- }
- ((ModuleAppData) curNode.appData).addDeleteNodes(node);
- }
-
- @Override
- public YdtContext getModuleContext() {
- return ((ModuleAppData) appData).getModuleContext();
- }
-
- @Override
- public YangSchemaNode getAugmentingSchemaNode() {
- return ((AugmentAppData) appData).getAugmentingSchemaNode();
- }
-
- @Override
- public void setAugmentingSchemaNode(YangSchemaNode schemaNode) {
- ((AugmentAppData) appData).setAugmentingSchemaNode(schemaNode);
- }
-
- @Override
- public YdtAppContext getLastChild() {
- return lastChild;
- }
-
- /**
- * Sets the context of last child.
- *
- * @param child node
- */
- private void setLastChild(YdtAppContext child) {
- lastChild = child;
- }
-
- @Override
- public void addChild(YdtAppContext newChild) {
-
- if (newChild.getParent() == null) {
- newChild.setParent(this);
- }
-
- // First child to be added.
- if (getFirstChild() == null) {
- setChild(newChild);
- // Update last child.
- setLastChild(newChild);
- return;
- }
-
- // If the new node needs to be add as last child.
- YdtAppContext curNode = getLastChild();
- curNode.setNextSibling(newChild);
- newChild.setPreviousSibling(curNode);
- setLastChild(newChild);
- }
-
- @Override
- public YangSchemaNode getYangSchemaNode() {
- return appData.getSchemaNode();
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/DefaultYdtWalker.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/DefaultYdtWalker.java
deleted file mode 100644
index ab67d28..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/DefaultYdtWalker.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-
-import org.onosproject.yms.app.utils.TraversalType;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtListener;
-
-import static org.onosproject.yms.app.utils.TraversalType.CHILD;
-import static org.onosproject.yms.app.utils.TraversalType.PARENT;
-import static org.onosproject.yms.app.utils.TraversalType.ROOT;
-import static org.onosproject.yms.app.utils.TraversalType.SIBLING;
-
-/**
- * Represents implementation of YDT walker, which walks the YDT.
- */
-public class DefaultYdtWalker implements YdtExtendedWalker {
-
- @Override
- public void walk(YdtListener ydtListener, YdtContext rootNode) {
- walkTree(ydtListener, rootNode, false);
- }
-
- /**
- * Walks the YANG data tree till the node provided by the user.
- * Protocols implements YDT listener and YDT Extended Listener and
- * walks YDT tree with input as implemented object.
- * YDT walker provides call backs to implemented methods.
- *
- * @param ydtListener YDT listener implemented by the protocol
- * @param rootNode root node of YDT
- * @param isExtended flag denotes the call type
- */
- private void walkTree(YdtListener ydtListener, YdtContext rootNode,
- boolean isExtended) {
- YdtContext curNode = rootNode;
- TraversalType curTraversal = ROOT;
-
- while (curNode != null) {
- if (curTraversal != PARENT) {
-
- // Visit (curNode) for entry callback
- if (isExtended) {
- ((YdtExtendedListener) ydtListener)
- .enterYdtNode((YdtExtendedContext) curNode);
- } else {
- ydtListener.enterYdtNode(curNode);
- }
- }
- if (curTraversal != PARENT &&
- curNode.getFirstChild() != null) {
- curTraversal = CHILD;
- curNode = curNode.getFirstChild();
- } else if (curNode.getNextSibling() != null) {
- // Revisit (curNode) for exit callback
- exitCallBack(ydtListener, curNode, isExtended);
-
- /*
- *Stop traversing the tree , tree need to be traversed
- * till user requested node
- */
- if (curNode.equals(rootNode)) {
- return;
- }
- curTraversal = SIBLING;
- curNode = curNode.getNextSibling();
- } else {
- // Revisit (curNode) for exit callback
- exitCallBack(ydtListener, curNode, isExtended);
-
- /*
- *Stop traversing the tree , tree need to be traversed
- * till user requested node
- */
- if (curNode.equals(rootNode)) {
- return;
- }
-
- curTraversal = PARENT;
- curNode = curNode.getParent();
- }
- }
- }
-
- /**
- * Provides exit call back per node on the basis of extended flag,
- * If isExtended set then YdtExtendedListener exit node call back will
- * be provided else YdtListener with respective type of context
- * (YdtContext/YdtExtendedContext).
- *
- * @param ydtListener YDT listener implemented by the protocol
- * @param curNode current node of YDT
- * @param isExtended flag denotes the call type
- */
- private void exitCallBack(YdtListener ydtListener, YdtContext curNode,
- boolean isExtended) {
- if (isExtended) {
- ((YdtExtendedListener) ydtListener)
- .exitYdtNode((YdtExtendedContext) curNode);
- } else {
- ydtListener.exitYdtNode(curNode);
- }
- }
-
- @Override
- public void walk(YdtExtendedListener ydtExtendedListener,
- YdtExtendedContext rootNode) {
- walkTree(ydtExtendedListener, rootNode, true);
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/ModuleAppData.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/ModuleAppData.java
deleted file mode 100644
index ff680ab..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/ModuleAppData.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.util.List;
-
-/**
- * Represents a module/sub-module node in application tree.
- */
-interface ModuleAppData extends AppData {
-
- /**
- * Returns the list of nodes with operation type delete.
- *
- * @return list of nodes with operation type delete
- */
- List<YdtContext> getDeleteNodes();
-
- /**
- * Adds the ydt node with operation type delete in module delete node list.
- *
- * @param node ydt node with operation type delete/remove
- */
- void addDeleteNodes(YdtContext node);
-
- /**
- * Returns application's root ydtContext.
- *
- * @return YdtContext of application root node
- */
- YdtContext getModuleContext();
-
- /**
- * Sets the application's ydtContext.
- *
- * @param moduleNode application's ydtContext
- */
- void setModuleContext(YdtExtendedContext moduleNode);
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/ModuleSchemaData.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/ModuleSchemaData.java
deleted file mode 100644
index f980bfda..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/ModuleSchemaData.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Manages the application information required for schema nodes defined in
- * the module (sub-module).
- */
-public class ModuleSchemaData implements ModuleAppData {
-
- /*
- * Reference for application's root ydtContext.
- */
- private YdtExtendedContext moduleContext;
-
- /*
- * Reference for list of nodes with operation type delete.
- */
- private final List<YdtContext> deleteNodes = new ArrayList<>();
-
- @Override
- public List<YdtContext> getDeleteNodes() {
- // This suppose to be mutable for YAB
- return deleteNodes;
- }
-
- @Override
- public void addDeleteNodes(YdtContext deletedNode) {
- deleteNodes.add(deletedNode);
- }
-
- @Override
- public YdtContext getModuleContext() {
- return moduleContext;
- }
-
- @Override
- public void setModuleContext(YdtExtendedContext moduleContext) {
- this.moduleContext = moduleContext;
- }
-
- @Override
- public YangSchemaNode getSchemaNode() {
- return moduleContext.getYangSchemaNode();
- }
-
- @Override
- public YangSchemaNode getRootSchemaNode() {
- return moduleContext.getYangSchemaNode();
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/NameSpace.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/NameSpace.java
deleted file mode 100644
index 3ae9686..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/NameSpace.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yangutils.datamodel.YangNamespace;
-
-class NameSpace implements YangNamespace {
-
- /*
- * Reference for namespace.
- */
- private final String nameSpace;
-
- /**
- * Creates an instance of namespace which is used to initialize the
- * nameSpace for requested YDT node.
- *
- * @param nameSpace namespace of the requested node
- */
- public NameSpace(String nameSpace) {
- this.nameSpace = nameSpace;
- }
-
- @Override
- public String getModuleNamespace() {
- return nameSpace;
- }
-
- @Override
- public String getModuleName() {
- return nameSpace;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/RequestedCallType.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/RequestedCallType.java
deleted file mode 100644
index a54d946..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/RequestedCallType.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-/**
- * Represents type of YANG data tree creation method caller type.
- */
-enum RequestedCallType {
-
- /**
- * Requested Node is of type single/multi instance leaf.
- */
- LEAF,
-
- /**
- * Requested Node is of type single/multi instance non leaf node.
- */
- NON_LEAF,
-
- /**
- * Requested Node is of type multi instance leaf/node.
- */
- MULTI_INSTANCE,
-
- /**
- * Requested Node is of type container but is empty.
- */
- EMPTY_CONTAINER,
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/RequestedCardinality.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/RequestedCardinality.java
deleted file mode 100644
index 4e4f637..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/RequestedCardinality.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-/**
- * Represents type of YANG data tree node operation.
- */
-enum RequestedCardinality {
-
- /**
- * Single instance of requested node.
- */
- SINGLE_INSTANCE,
-
- /**
- * Multi instance of requested node.
- */
- MULTI_INSTANCE,
-
- /**
- * Instance of requested node/leaf is unknown.
- */
- UNKNOWN,
-
- /**
- * Single instance of requested leaf.
- */
- SINGLE_INSTANCE_LEAF,
-
- /**
- * Multi instance of requested leaf.
- */
- MULTI_INSTANCE_LEAF
-}
-
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YangRequestWorkBench.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YangRequestWorkBench.java
deleted file mode 100644
index 2159de5..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YangRequestWorkBench.java
+++ /dev/null
@@ -1,785 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import com.google.common.collect.ImmutableMap;
-import org.onosproject.yangutils.datamodel.YangAugment;
-import org.onosproject.yangutils.datamodel.YangLeaf;
-import org.onosproject.yangutils.datamodel.YangList;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeContextInfo;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-import org.onosproject.yms.ydt.YdtType;
-import org.onosproject.yms.ydt.YmsOperationType;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.onosproject.yms.app.ydt.AppNodeFactory.getAppContext;
-import static org.onosproject.yms.app.ydt.RequestedCallType.LEAF;
-import static org.onosproject.yms.app.ydt.RequestedCallType.NON_LEAF;
-import static org.onosproject.yms.app.ydt.RequestedCardinality.MULTI_INSTANCE;
-import static org.onosproject.yms.app.ydt.RequestedCardinality.MULTI_INSTANCE_LEAF;
-import static org.onosproject.yms.app.ydt.RequestedCardinality.SINGLE_INSTANCE;
-import static org.onosproject.yms.app.ydt.RequestedCardinality.UNKNOWN;
-import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
-import static org.onosproject.yms.app.ydt.YdtNodeFactory.getNode;
-import static org.onosproject.yms.app.ydt.YdtNodeFactory.getYangSchemaNodeTypeSpecificContext;
-import static org.onosproject.yms.app.ydt.YdtUtils.checkElementCount;
-import static org.onosproject.yms.app.ydt.YdtUtils.freeRestResources;
-import static org.onosproject.yms.app.ydt.YdtUtils.getAppOpTypeFromYdtOpType;
-import static org.onosproject.yms.app.ydt.YdtUtils.getAugmentingSchemaNode;
-import static org.onosproject.yms.app.ydt.YdtUtils.getNodeIdentifier;
-import static org.onosproject.yms.app.ydt.YdtUtils.getValidOpType;
-import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.REMOVE;
-import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_LEAF_VALUE_NODE;
-import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_NODE;
-
-/**
- * Represents YANG request work bench which contains all parameters for
- * request handling and methods to build and obtain YANG data tree
- * which is data (sub)instance representation, abstract of protocol.
- */
-public class YangRequestWorkBench implements YdtExtendedBuilder {
-
- // Ydt formatted error string
- private static final String FMT_NOT_EXIST =
- "Application with name \"%s\" doesn't exist.";
-
- // Ydt error strings.
- private static final String E_USE_ADD_LEAF =
- "Requested Node should be created using addLeaf interface.";
-
- private static final String E_INVOKE_PARENT =
- "Can't invoke get parent at logical root node.";
-
- /*
- * Reference for the current context node in YANG data tree.
- */
- private YdtNode curNode;
-
- /*
- * Reference for the logical root node in YANG data tree.
- */
- private YdtNode rootNode;
-
- /*
- * Reference for the current context in ydt application tree.
- */
- private YdtAppContext appCurNode;
-
- /*
- * Reference for the logical root node context in ydt application tree.
- */
- private YdtAppContext appRootNode;
-
- /**
- * Root Node Tag attribute in YANG data tree, kept to maintain the root
- * tag attributes in YDT.
- * <p>
- * First key param of map represent tagName name of tag attribute.
- * Second param of map represent tagValue value of tag attribute
- */
- private Map<String, String> rootTagAttributeMap;
-
- /*
- * YANG schema registry reference.
- */
- private YangSchemaRegistry registry = null;
-
- /*
- * YMS operation type.
- */
- private final YmsOperationType ymsOperationType;
-
- /*
- * YDT default operation type.
- */
- private YdtContextOperationType ydtDefaultOpType;
-
- /*
- * Flag to identify data validation need to be done by YDT or not.
- */
- private boolean validate = false;
- // TODO validate need to be handle later with interaction type basis in
- // future when it will be supported
-
- /*
- * Reference for application tree node set.
- * This set contains the method name's generated for an augmented
- * target node to avoid the duplicate entries in YDT application tree for
- * multiple augmented nodes under a single XPATH.
- */
- private Set<String> augGenMethodSet;
-
- /**
- * Creates an instance of YANG request work bench which is use to initialize
- * logical rootNode and and schema registry.
- *
- * @param name name of logical container of a protocol
- * which is a holder of the complete tree
- * @param namespace namespace of logical container
- * @param opType type of operation done by using YANG
- * interface
- * @param reg Yang schema registry
- * @param isValidate Flag to identify data validation need to be
- * done by YDT or not
- */
- public YangRequestWorkBench(String name, String namespace,
- YmsOperationType opType,
- YangSchemaRegistry reg,
- boolean isValidate) {
-
- setRootNode(new YdtLogicalNode(name, namespace));
- registry = reg;
- ymsOperationType = opType;
- validate = isValidate;
-
- setAppRootNode(getAppContext(true));
- }
-
- /**
- * Sets the logical root node for ydt.
- *
- * @param node ydt logical root node
- */
- private void setRootNode(YdtNode node) {
- rootNode = node;
- curNode = node;
- }
-
- /**
- * Sets the logical root node for ydt application tree.
- *
- * @param node ydt application context logical root node
- */
- private void setAppRootNode(YdtAppContext node) {
- appRootNode = node;
- appCurNode = node;
- }
-
- /**
- * Returns the YANG schema registry of Ydt.
- * This method will be used by ytb.
- *
- * @return YANG schema registry
- */
- public YangSchemaRegistry getYangSchemaRegistry() {
- return registry;
- }
-
- /**
- * Returns the ydt app context tree logical root node.
- * This method will be used by yab and ytb.
- *
- * @return YdtAppContext app tree logical root node
- */
- public YdtAppContext getAppRootNode() {
- return appRootNode;
- }
-
- /**
- * Returns the ydt module node with requested node identifier.
- *
- * @param id module/application node identifier
- * @return YANG data tree node
- * @throws YdtException when user requested node schema doesn't exist or
- * requested node is already part of the tree
- */
- private YdtNode moduleHandler(YangSchemaNodeIdentifier id)
- throws YdtException {
-
- YangSchemaNode node =
- registry.getYangSchemaNodeUsingSchemaName(id.getName());
-
- String namespace = id.getNameSpace().getModuleNamespace();
-
- /*
- * Checking received schema node is having same namespace as
- * requested by user or not.
- */
- if (node == null || namespace != null &&
- !namespace.equals(node.getYangSchemaNodeIdentifier()
- .getNameSpace()
- .getModuleNamespace())) {
- throw new YdtException(errorMsg(FMT_NOT_EXIST, id.getName()));
- }
-
- /*
- * If yms operation is for query then no validation need to be
- * performed.
- */
- if (ymsOperationType != YmsOperationType.QUERY_REQUEST) {
- // Checking whether module node is already exits in YDT or not.
- try {
- curNode.getCollidingChild(id);
- } catch (YdtException e) {
- throw new YdtException(e.getLocalizedMessage());
- }
- }
-
- YdtNode newNode = new YdtSingleInstanceNode(node);
- newNode.setYangSchemaNode(node);
- return newNode;
- }
-
- @Override
- public void setRootTagAttributeMap(Map<String, String> attributeTag) {
- rootTagAttributeMap = attributeTag;
- }
-
- @Override
- public Map<String, String> getRootTagAttributeMap() {
- if (rootTagAttributeMap != null) {
- return ImmutableMap.copyOf(rootTagAttributeMap);
- }
- return null;
- }
-
- @Override
- public void addChild(String name, String namespace)
- throws IllegalArgumentException {
- addChild(name, namespace, UNKNOWN, null, NON_LEAF);
- }
-
- @Override
- public void addChild(String name, String namespace, YdtType ydtType)
- throws IllegalArgumentException {
- addChild(name, namespace, ydtType, null);
- }
-
- @Override
- public void addChild(String name, String namespace,
- YdtContextOperationType opType)
- throws IllegalArgumentException {
- addChild(name, namespace, UNKNOWN, opType, NON_LEAF);
- }
-
- @Override
- public void addChild(String name, String namespace, YdtType ydtType,
- YdtContextOperationType opType)
- throws IllegalArgumentException {
- RequestedCardinality cardinality;
- switch (ydtType) {
- case MULTI_INSTANCE_NODE:
- cardinality = MULTI_INSTANCE;
- break;
- case SINGLE_INSTANCE_NODE:
- cardinality = SINGLE_INSTANCE;
- break;
- default:
- throw new IllegalArgumentException(E_USE_ADD_LEAF);
- }
- addChild(name, namespace, cardinality, opType, NON_LEAF);
- }
-
- /**
- * Adds a last child to YANG data tree; this method is to be used by all
- * protocols internally which are aware or unaware of the nature
- * (single/multiple) of node.
- *
- * @param name name of child to be added
- * @param namespace namespace of child to be added
- * @param cardinality type of YANG data tree node operation
- * @param opType type of requested operation over a node
- * @param callType to identify the whether its a leaf or other node
- * @throws IllegalArgumentException when method has been passed an illegal
- * or inappropriate argument.
- */
- private void addChild(String name, String namespace,
- RequestedCardinality cardinality,
- YdtContextOperationType opType,
- RequestedCallType callType)
- throws IllegalArgumentException {
-
- YdtNode newNode;
- boolean contextSwitch = false;
- YangSchemaNode augmentingSchema = null;
- YangSchemaNodeIdentifier id = getNodeIdentifier(name, namespace);
- if (name == null) {
- if (!curNode.equals(rootNode)) {
- throw new YdtException("Name is null for node other than module");
- }
-
- /*
- * Since XML will not have module name, id.name will be null. In
- * that case get schema node by using namespace. In NBI flow,
- * name will never be null.
- */
- YangSchemaNode node = registry
- .getSchemaWrtNameSpace(id.getNameSpace().getModuleNamespace());
- id.setName(node.getName());
- }
-
- try {
- // Module/sub-module node handler.
- if (curNode.equals(rootNode)) {
- newNode = moduleHandler(id);
- } else {
-
- YangSchemaNode schemaNode;
- YangSchemaNodeContextInfo contextInfo;
-
- // If namespace given by user null, then take namespace from parent.
- if (namespace == null) {
- id.setNameSpace(curNode.getYangSchemaNode().getNameSpace());
- }
-
- /*
- * Get the already exiting YDT node in YDT tree with same
- * nodeIdentifier
- */
- newNode = curNode.getCollidingChild(id);
-
- /*
- * If colliding child doesn't exist ,
- * then query yang data model for schema of given node.
- */
- if (newNode == null) {
- /*
- * Get Yang Schema node context info which is having
- * YangSchemaNode and ContextSwitchedNode.
- */
- contextInfo = curNode.getSchemaNodeContextInfo(id);
-
- if (contextInfo.getContextSwitchedNode() != null) {
- augmentingSchema = getAugmentingSchemaNode(
- id, contextInfo);
- if (augmentingSchema != null) {
- /*
- * As two tree(YDT and YDT Application Tree) are getting
- * prepared in parallel, So setting context switch
- * flag it will help ydt to keep the track whether
- * ydtApp tree also need to be traversed back to parent
- * or not with YDT tree traverse to parent call.
- */
- contextSwitch = true;
- }
- }
- schemaNode = contextInfo.getSchemaNode();
- } else {
- /*
- * If colliding child exist , then it will be leaf-list or list.
- * If its leaf-list then return and add new requested
- * value/valueSet in same node else take yang data model
- * information from colliding child.
- */
- if (newNode.getYdtType() == MULTI_INSTANCE_LEAF_VALUE_NODE) {
- curNode = newNode;
- return;
- }
- schemaNode = newNode.getYangSchemaNode();
- }
-
- /*
- * For yms query request node specific validation are not
- * required as rest-conf can call addChild api for leaf/leaf-list
- * node addition also in ydt.
- */
- if (ymsOperationType == YmsOperationType.QUERY_REQUEST) {
- newNode = getYangSchemaNodeTypeSpecificContext(schemaNode);
- } else {
- newNode = getNode(schemaNode, cardinality, callType);
- }
- }
-
- opType = getValidOpType(opType, ydtDefaultOpType, newNode, curNode);
-
- newNode.setYdtContextOperationType(opType);
-
- curNode.addChild(newNode, true);
- } catch (YdtException e) {
- freeRestResources(rootNode);
- throw new IllegalArgumentException(e.getLocalizedMessage());
- }
-
- // Update parent ydt node map.
- curNode.updateYdtMap(newNode);
-
- processAppTree(opType, newNode, augmentingSchema, contextSwitch);
-
- curNode = newNode;
- }
-
- /**
- * Processes application tree on the bases of requested ydt node.
- *
- * @param opType user requested operation type
- * @param childNode requested ydt node
- * @param augmentingSchema schema of last augmenting node
- * @param contextSwitch true, for module node call; false for modules
- * sub-node calls
- */
- private void processAppTree(
- YdtContextOperationType opType, YdtNode childNode,
- YangSchemaNode augmentingSchema, boolean contextSwitch) {
-
- if (curNode == rootNode) {
- augGenMethodSet = new HashSet<>();
- }
-
- if (opType == null) {
- opType = curNode.getYdtContextOperationType();
- } else {
- // Updating operation type for parent nodes
- appCurNode.updateAppOperationType(opType);
- }
-
- /*
- * This is to avoid multiple entries of single augmented target.
- */
- if (augmentingSchema != null) {
- if (!augGenMethodSet.add(((YangAugment) augmentingSchema)
- .getSetterMethodName())) {
- return;
- }
- }
-
- /*
- * Create entry of module node in ydt app tree.
- * Or if context switch happened then also add entry for same
- * augmented ydt node in the ydt application tree.
- */
- if (curNode.equals(rootNode) || contextSwitch) {
- addChildInAppTree(childNode, augmentingSchema, opType,
- contextSwitch);
-
- // Setting app tree node operation.
- appCurNode.setOperationType(getAppOpTypeFromYdtOpType(opType));
- }
-
- // Updating the delete operation list in app tree.
- if (opType == DELETE || opType == REMOVE) {
- appCurNode.addDeleteNode(childNode);
- }
- }
-
-
- /**
- * Adds a last child to YANG app data tree.this method is to be used
- * internally by other ydt interfaces.
- *
- * @param childNode node to be added in tree
- * @param schemaNode last augmenting module node
- * @param childOpType operation type of node
- * @param isContextSwitch true, for module node call; false for modules
- * sub-node calls
- */
- private void addChildInAppTree(YdtNode childNode,
- YangSchemaNode schemaNode,
- YdtContextOperationType childOpType,
- boolean isContextSwitch) {
-
- YdtAppNodeOperationType opType;
-
- DefaultYdtAppContext appContext = getAppContext(isContextSwitch);
-
- // Add context switched child in ydt App tree.
- appCurNode.addChild(appContext);
-
- appCurNode = appContext;
-
- opType = getAppOpTypeFromYdtOpType(childOpType);
-
- appCurNode.setAppData(childNode, schemaNode);
-
- appCurNode.setOperationType(opType);
-
- childNode.setAppContextSwitch();
- }
-
- @Override
- public void addLeaf(String name, String namespace, String value)
- throws IllegalArgumentException {
- addLeaf(name, namespace, value, null, UNKNOWN);
- }
-
- @Override
- public void addLeaf(String name, String namespace, Set<String> valueSet)
- throws IllegalArgumentException {
- addLeaf(name, namespace, null, valueSet, MULTI_INSTANCE_LEAF);
- }
-
- @Override
- public void addNode(String name, String namespace)
- throws IllegalArgumentException {
- addChild(name, namespace, RequestedCardinality.UNKNOWN,
- null, RequestedCallType.EMPTY_CONTAINER);
- }
-
-
- /**
- * Adds a last leaf with list of values/single value to YANG data tree.
- * This method is used by all protocols which knows the nature
- * (single/multiple) or not.
- * Value of leaf can be null which indicates selection node in get
- * operation.
- *
- * @param name name of child to be added
- * @param namespace namespace of child to be added, if it's
- * null, parent's
- * namespace will be applied to child
- * @param value value of the child
- * @param valueSet list of value of the child
- * @param cardinality type of YANG data tree node operation
- * @throws IllegalArgumentException when method has been passed an illegal
- * or inappropriate argument.
- */
- private void addLeaf(String name, String namespace, String value,
- Set<String> valueSet,
- RequestedCardinality cardinality)
- throws IllegalArgumentException {
- try {
- addChild(name, namespace, cardinality, null, LEAF);
-
- // After successful addition of child node updating the values in same.
- if (value != null) {
- curNode.addValue(value);
- } else if (valueSet != null) {
- curNode.addValueSet(valueSet);
- }
- } catch (YdtException e) {
- freeRestResources(rootNode);
- throw new IllegalArgumentException(e.getLocalizedMessage());
- }
- }
-
- @Override
- public void traverseToParent() throws IllegalStateException {
- // If traverse back to parent for logical root node comes
- if (curNode.equals(rootNode)) {
- freeRestResources(rootNode);
- throw new IllegalStateException(E_INVOKE_PARENT);
- }
-
- try {
-
- // If node is of multiInstanceNode type then check key uniqueness.
- if (curNode.getYdtType() == MULTI_INSTANCE_NODE) {
- List<YdtContext> keyList = ((YdtMultiInstanceNode) curNode).getKeyNodeList();
- if (keyList == null || keyList.isEmpty()) {
- curNode.createKeyNodeList();
- }
- }
-
- /*
- * Check application switch for curNode if set,
- * then traverseToParent in YDT application tree.
- */
- if (curNode.getParent().equals(rootNode) ||
- curNode.getAppContextSwitch()) {
- traverseToAppTreeParent();
- }
-
- /*
- * Validate all multi Instance inside current context,
- * This is not valid for leaf and leaf-list node.
- */
- if (curNode instanceof YdtMultiInstanceNode ||
- curNode instanceof YdtSingleInstanceNode) {
- curNode.validateMultiInstanceNode();
- }
-
- curNode = curNode.getParent();
- } catch (YdtException e) {
- freeRestResources(rootNode);
- throw new IllegalStateException(e.getLocalizedMessage());
- }
- }
-
- /**
- * Traverses up in YANG application tree to the parent node,
- * This will be used when Ydt current context switch flag is set.
- */
- private void traverseToAppTreeParent() {
- appCurNode = appCurNode.getParent();
- }
-
- @Override
- public YdtExtendedContext getCurNode() {
- return curNode;
- }
-
- @Override
- public void setDefaultEditOperationType(
- YdtContextOperationType opType) {
- ydtDefaultOpType = opType;
- }
-
- @Override
- public YdtExtendedContext getRootNode() {
- return rootNode;
- }
-
- @Override
- public YmsOperationType getYmsOperationType() {
- return ymsOperationType;
- }
-
- @Override
- public void addMultiInstanceChild(String name, String namespace,
- List<String> keysValueList,
- YdtContextOperationType opType)
- throws IllegalArgumentException {
-
- addChild(name, namespace, UNKNOWN, opType,
- RequestedCallType.MULTI_INSTANCE);
- int inputCount = keysValueList.size();
-
- try {
- if (curNode.getYdtType() == MULTI_INSTANCE_LEAF_VALUE_NODE) {
-
- /*
- * Calculating the current leaf-list node array size by adding
- * existing elements count and new supplied elements by user for
- * the same.
- */
- // TODO instance count for leaf list need to be handled.
-// if (curNode.getValueSet().size() + inputCount > expectedCount) {
-// curNode.errorHandler(
-// errorMsg(FMT_MANY_INS, name, expectedCount), rootNode);
-// }
-
- /*
- * After successful addition of child node updating
- * the values in same.
- */
- for (String value : keysValueList) {
- curNode.addValue(value);
- }
- } else if (curNode.getYdtType() == MULTI_INSTANCE_NODE) {
-
- YangList yangListHolder = (YangList) curNode.getYangSchemaNode();
- List<String> schemaKeyList = yangListHolder.getKeyList();
- int expectedCount = schemaKeyList.size();
- checkElementCount(name, expectedCount, inputCount);
-
- //After validation adding the key nodes under the list node.
- Iterator<String> sklIter = schemaKeyList.iterator();
- Iterator<String> kvlIter = keysValueList.iterator();
- String keyEleName;
-
- while (kvlIter.hasNext()) {
- String value = kvlIter.next();
- keyEleName = sklIter.next();
- addLeaf(keyEleName, namespace, value);
- if (kvlIter.hasNext()) {
- traverseToParentWithoutValidation();
- }
- }
-
- curNode = curNode.getParent();
- curNode.createKeyNodeList();
- }
- } catch (YdtException e) {
- freeRestResources(rootNode);
- throw new IllegalArgumentException(e.getLocalizedMessage());
- }
- }
-
- /**
- * Adds a last child to YANG data tree, this method is to be used by
- * YANG object builder sub-calls internally.
- *
- * @param opType type of requested operation over a node
- * @return returns added ydt node in YDT tree
- */
- private YdtNode addExtendedChildNode(YdtContextOperationType opType,
- YangSchemaNode schemaNode) {
-
- YdtNode childNode = getYangSchemaNodeTypeSpecificContext(schemaNode);
-
- childNode.setYangSchemaNode(schemaNode);
-
- childNode.setYdtContextOperationType(opType);
-
- curNode.addChild(childNode, true);
-
- curNode = childNode;
-
- return childNode;
- }
-
- @Override
- public YdtExtendedContext addChild(YdtContextOperationType opType,
- YangSchemaNode schemaNode) {
- return addExtendedChildNode(opType, schemaNode);
- }
-
- @Override
- public YdtExtendedContext addLeafList(Set<String> valueSet,
- YangSchemaNode schemaNode) {
- YdtNode childNode = addExtendedChildNode(null, schemaNode);
-
- /*
- * After successful addition of child node updating the values in
- * valueSet.
- */
- childNode.addValueSetWithoutValidation(valueSet);
- return childNode;
- }
-
- @Override
- public YdtExtendedContext addLeaf(String value, YangSchemaNode schemaNode) {
-
- YdtNode childNode = addExtendedChildNode(null, schemaNode);
-
- // After successful addition of child node updating the values in same.
- childNode.addValueWithoutValidation(value, ((YangLeaf) schemaNode)
- .isKeyLeaf());
- return childNode;
- }
-
- @Override
- public void traverseToParentWithoutValidation()
- throws IllegalStateException {
- // If traverse back to parent for logical root node comes.
- if (curNode.equals(rootNode)) {
- freeRestResources(rootNode);
- throw new IllegalStateException(E_INVOKE_PARENT);
- }
- curNode = curNode.getParent();
- }
-
- /**
- * Returns the method name's set for an augmented target node in an
- * application tree.
- *
- * @return augGenMethodSet set of method name's
- */
- public Set<String> getAugGenMethodSet() {
- return augGenMethodSet;
- }
-
- /**
- * Sets the method name's set for an augmented target node in an
- * application tree.
- *
- * @param augGenMethodSet set of method name's
- */
- public void setAugGenMethodSet(Set<String> augGenMethodSet) {
- this.augGenMethodSet = augGenMethodSet;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YangResponseWorkBench.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YangResponseWorkBench.java
deleted file mode 100644
index 062fe77..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YangResponseWorkBench.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtResponse;
-import org.onosproject.yms.ydt.YmsOperationExecutionStatus;
-import org.onosproject.yms.ydt.YmsOperationType;
-
-public class YangResponseWorkBench implements YdtResponse {
-
- /*
- * YDT root node context.
- */
- private YdtContext rootNode;
-
- /*
- * YMS operation execution status.
- */
- private YmsOperationExecutionStatus status;
-
- /*
- * YMS operation type.
- */
- private YmsOperationType ymsOperationType;
-
- /**
- * Creates an instance of YangResponseWorkBench which is use to
- * initialize rootNode and childNode.
- *
- * @param ydtContext root node context
- * @param exeStatus YMS operation execution status
- * @param opType YMS operation type
- */
- public YangResponseWorkBench(YdtContext ydtContext,
- YmsOperationExecutionStatus exeStatus,
- YmsOperationType opType) {
- rootNode = ydtContext;
- status = exeStatus;
- ymsOperationType = opType;
- }
-
- @Override
- public YmsOperationExecutionStatus getYmsOperationResult() {
- return status;
- }
-
- @Override
- public YdtContext getRootNode() {
- return rootNode;
- }
-
- @Override
- public YmsOperationType getYmsOperationType() {
- return ymsOperationType;
- }
-
- /**
- * Sets root node.
- *
- * @param rootNode root node
- */
- public void setRootNode(YdtContext rootNode) {
- this.rootNode = rootNode;
- }
-
- /**
- * Sets YMS operation execution status.
- *
- * @param status YMS operation execution status
- */
- public void setStatus(YmsOperationExecutionStatus status) {
- this.status = status;
- }
-
- /**
- * Sets YMS operation type.
- *
- * @param ymsOperationType YMS operation type
- */
- public void setYmsOperationType(YmsOperationType ymsOperationType) {
- this.ymsOperationType = ymsOperationType;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtAppContext.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtAppContext.java
deleted file mode 100644
index fa0d882..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtAppContext.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-
-import java.util.List;
-
-/**
- * Abstraction of an entity which represents YANG application data tree context
- * information. This context information will be used by protocol to obtain
- * the information associated with YDT application node. This is used when
- * protocol is walking the application data tree in both visitor and listener
- * mechanism.
- */
-public interface YdtAppContext {
-
- /**
- * Returns the context of parent node.
- *
- * @return context of parent node
- */
- YdtAppContext getParent();
-
- /**
- * Sets the context of parent node.
- *
- * @param parent node
- */
- void setParent(YdtAppContext parent);
-
- /**
- * Returns the context of first child.
- *
- * @return context of first child
- */
- YdtAppContext getFirstChild();
-
- /**
- * Returns the context of last child.
- *
- * @return context of last child
- */
- YdtAppContext getLastChild();
-
- /**
- * Returns the context of next sibling.
- *
- * @return context of next sibling
- */
- YdtAppContext getNextSibling();
-
- /**
- * Sets the context of next sibling.
- *
- * @param nextSibling node
- */
- void setNextSibling(YdtAppContext nextSibling);
-
- /**
- * Returns the context of previous sibling.
- *
- * @return context of previous sibling
- */
- YdtAppContext getPreviousSibling();
-
- /**
- * Sets the context of previous sibling.
- *
- * @param preSibling node
- */
- void setPreviousSibling(YdtAppContext preSibling);
-
- /**
- * Returns the app tree operation type.
- *
- * @return app tree operation type
- */
- YdtAppNodeOperationType getOperationType();
-
- /**
- * Set the app tree operation type.
- *
- * @param opType app tree operation type
- */
- void setOperationType(YdtAppNodeOperationType opType);
-
- /**
- * Returns the list of nodes with operation type delete.
- *
- * @return list of nodes with operation type delete
- */
- List<YdtContext> getDeleteNodes();
-
- /**
- * Adds the ydt node with operation type delete in module delete node list.
- *
- * @param node ydt node with operation type delete/remove
- */
- void addDeleteNode(YdtNode node);
-
- /**
- * Returns application's root ydtContext.
- *
- * @return YdtContext of application root node
- */
- YdtContext getModuleContext();
-
- /**
- * Returns the YangSchemaNode of augmenting application.
- *
- * @return YangSchemaNode of augmenting application
- */
- YangSchemaNode getAugmentingSchemaNode();
-
- /**
- * Sets the YangSchemaNode of augmenting application root node.
- *
- * @param schemaNode YangSchemaNode of augmenting application module
- */
- void setAugmentingSchemaNode(YangSchemaNode schemaNode);
-
- /**
- * Adds a last child to ydt application data tree.
- *
- * @param newChild name of child to be added
- */
- void addChild(YdtAppContext newChild);
-
- /**
- * Updates the app tree operation type.
- * <p>
- * If earlier operation type was OTHER_EDIT and now operation type came as
- * DELETE_ONLY or vice-versa, then update operation type to BOTH.
- *
- * @param opType ydt current context operation type
- */
- void updateAppOperationType(YdtContextOperationType opType);
-
- /**
- * Sets the application data for given request. If in requested parameters
- * schemaNode is not null then appData will be set with
- * augmentedSchemaData else with moduleSchemaData object.
- *
- * @param moduleNode module node of requested app
- * @param schemaNode augmented schema node of requested context
- */
- void setAppData(YdtNode moduleNode, YangSchemaNode schemaNode);
-
- /**
- * Returns the app data for current context.
- *
- * @return app data
- */
- AppData getAppData();
-
- /**
- * Returns the yang schema for requested node.
- *
- * @return schema node
- */
- YangSchemaNode getYangSchemaNode();
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtAppNodeOperationType.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtAppNodeOperationType.java
deleted file mode 100644
index 15b80e2..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtAppNodeOperationType.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-/**
- * Represents type of YANG data tree node operation.
- */
-public enum YdtAppNodeOperationType {
-
- /**
- * Type of YANG application node operation for below action:
- * The application containing this attribute has edit operation
- * type as delete/remove in its complete ydtTree.
- */
- DELETE_ONLY,
-
- /**
- * Type of YANG application node operation for below action:
- * The application containing this attribute has edit operation
- * type other than delete/remove in its complete ydtTree.
- */
- OTHER_EDIT,
-
- /**
- * Type of YANG application node operation for below action:
- * The application containing this attribute has edit operation
- * type of combination of any edit operation type in its complete ydtTree.
- */
- BOTH
-}
-
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtConstants.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtConstants.java
deleted file mode 100644
index 8fcded1..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtConstants.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-/**
- * Represents common constant utility for YANG data tree.
- */
-final class YdtConstants {
-
- //No instantiation.
- private YdtConstants() {
- }
-
- /**
- * Error formatting string for duplicate entries found in ydt.
- */
- public static final String FMT_DUP_ENTRY = "Duplicate entry with name %s.";
-
- /**
- * Returns the error string by filling the parameters in the given
- * formatted error string.
- *
- * @param fmt error format string
- * @param params parameters to be filled in formatted string
- * @return error string
- */
- public static String errorMsg(String fmt, Object... params) {
- return String.format(fmt, params);
- }
-}
\ No newline at end of file
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedBuilder.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedBuilder.java
deleted file mode 100644
index 0844858..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedBuilder.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-
-import java.util.Set;
-
-/**
- * Abstraction of an entity which represents extension of YDT builder
- * required by internal sub modules.
- */
-public interface YdtExtendedBuilder extends YdtBuilder {
-
- /**
- * Adds a last child to YANG data tree; this method is to be used by
- * YANG object builder.
- *
- * @param yangSchemaNode schema node from YANG metadata
- * @param opType type of requested operation over a node
- * @return YDT context
- */
- YdtExtendedContext addChild(YdtContextOperationType opType,
- YangSchemaNode yangSchemaNode);
-
- /**
- * Adds a last leaf list to YANG data tree; this method is to be used by
- * YANG object builder.
- *
- * @param valueSet list of value of the child
- * @param yangSchemaNode schema node from YANG metadata
- * @return YDT context
- */
- YdtExtendedContext addLeafList(Set<String> valueSet,
- YangSchemaNode yangSchemaNode);
-
- /**
- * Adds a last leaf to YANG data tree; this method is to be used by
- * YANG object builder.
- *
- * @param value value of the child
- * @param yangSchemaNode schema node from YANG metadata
- * @return YDT context
- */
- YdtExtendedContext addLeaf(String value, YangSchemaNode yangSchemaNode);
-
- /**
- * Traverses up in YANG data tree to the parent node, it is to be used when
- * protocol is using extended context type and wanted to traverse
- * up the tree without doing any validation.
- *
- * @throws IllegalStateException when user request for traverse to logical
- * root node parent
- */
- void traverseToParentWithoutValidation() throws IllegalStateException;
-
- @Override
- YdtExtendedContext getRootNode();
-
- @Override
- YdtExtendedContext getCurNode();
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedContext.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedContext.java
deleted file mode 100644
index 3462d40..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedContext.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-
-/**
- * Abstraction of an entity which represents application related information
- * maintained in YDT.
- */
-public interface YdtExtendedContext extends YdtContext {
-
- /**
- * Returns the application stored information. Application type is used to
- * identify application.
- *
- * @param appType application type
- * @return application information
- */
- Object getAppInfo(AppType appType);
-
- /**
- * Sets application stored information. Application type is used to
- * identify application.
- *
- * @param appType application type
- * @param object application information object
- */
- void addAppInfo(AppType appType, Object object);
-
- /**
- * Returns schema node from data model for curNode.
- *
- * @return yang schema node
- */
- YangSchemaNode getYangSchemaNode();
-
- /**
- * Returns YDT current extended context operation type.
- *
- * @return operation type
- */
- YdtContextOperationType getYdtContextOperationType();
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedListener.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedListener.java
deleted file mode 100644
index 4c55aa3..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedListener.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-
-import org.onosproject.yms.ydt.YdtListener;
-
-/**
- * Abstraction of an entity which provide call back methods which are called
- * by YDT extended walker while walking the YANG data tree.
- * <p>
- * This interface needs to be implemented by protocol implementing listener's
- * based call backs while YDT walk, and update application specific information
- * in data node.
- */
-public interface YdtExtendedListener extends YdtListener {
-
- /**
- * YANG data tree node's entry, it will be called during a node entry.
- * <p>
- * All the related information about the node can be obtain from the YDT
- * context. Also it can be used to maintain / query application specific
- * information.
- *
- * @param ydtExtendedContext YANG data tree context
- */
- void enterYdtNode(YdtExtendedContext ydtExtendedContext);
-
- /**
- * YANG data tree node's exit, it will be called during a node exit.
- * <p>
- * All the related information about the node can be obtain from the YDT
- * context. Also it can be used to maintain / query application specific
- * information.
- *
- * @param ydtExtendedContext YANG data tree context
- */
- void exitYdtNode(YdtExtendedContext ydtExtendedContext);
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedWalker.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedWalker.java
deleted file mode 100644
index 386b579..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtExtendedWalker.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yms.ydt.YdtWalker;
-
-/**
- * Abstraction of an entity which provides interfaces for YDT extended walker.
- */
-public interface YdtExtendedWalker extends YdtWalker {
-
- /**
- * Walks the YANG data tree. Protocols implements YDT listener service and
- * walks YDT tree with input as implemented object.
- * YDT walker provides call backs to implemented methods.
- *
- * @param ydtListener YDT listener implemented by the protocol
- * @param rootNode root node of YDT
- */
- void walk(YdtExtendedListener ydtListener, YdtExtendedContext rootNode);
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtLogicalNode.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtLogicalNode.java
deleted file mode 100644
index 1456887..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtLogicalNode.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-
-import static org.onosproject.yms.app.ydt.YdtConstants.FMT_DUP_ENTRY;
-import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
-import static org.onosproject.yms.ydt.YdtType.LOGICAL_ROOT_NODE;
-
-/**
- * Represents a logical YANG data tree node.
- */
-class YdtLogicalNode extends YdtNode {
-
- private final String name;
- private final String namespace;
-
- /**
- * Creates an instance of YANG logical node object.
- *
- * @param name logical root name
- * @param namespace YANG namespace
- */
- public YdtLogicalNode(String name, String namespace) {
- super(LOGICAL_ROOT_NODE);
- this.name = name;
- this.namespace = namespace;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public String getNamespace() {
- return namespace;
- }
-
- @Override
- public String getModuleNameAsNameSpace() {
- return namespace;
- }
-
- @Override
- public void validDuplicateEntryProcessing() throws YdtException {
- throw new YdtException(errorMsg(FMT_DUP_ENTRY, getName()));
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtMultiInstanceLeafNode.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtMultiInstanceLeafNode.java
deleted file mode 100644
index 39db56a..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtMultiInstanceLeafNode.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import com.google.common.collect.ImmutableSet;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
-import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_LEAF_VALUE_NODE;
-
-/**
- * Represents YDT multi instance leaf node which can hold multiple values, it
- * is atomic element and doesn't have any child.
- */
-class YdtMultiInstanceLeafNode extends YdtNode {
-
- // ydt formatted error string
- private static final String FMT_DUP_ENTRY =
- "Duplicate entry found under %s leaf-list node.";
-
- /**
- * Set of values.
- */
- private final Set<String> valueSet = new LinkedHashSet<>();
-
- /**
- * Creates a YANG multi instance leaf node.
- *
- * @param node schema of YDT multi instance node
- */
- YdtMultiInstanceLeafNode(YangSchemaNode node) {
- super(MULTI_INSTANCE_LEAF_VALUE_NODE, node);
- }
-
- @Override
- public Set<String> getValueSet() {
- return ImmutableSet.copyOf(valueSet);
- }
-
- @Override
- public void addValue(String value) throws YdtException {
- // check the value against corresponding data-type.
- //TODO validation need to be decided
-// try {
-// getYangSchemaNode().isValueValid(value);
-// } catch (Exception e) {
-// throw new YdtException(e.getLocalizedMessage());
-// }
- addValueToValueSet(value);
- }
-
- /**
- * Adds value in the current node valueSet, after successful validation of
- * the value.
- *
- * @param value value to be added
- * @throws YdtException when the duplicate entry found in leaf-list node
- */
- private void addValueToValueSet(String value) throws YdtException {
- if (!valueSet.add(value)) {
- throw new YdtException(errorMsg(FMT_DUP_ENTRY, getName()));
- }
- }
-
- @Override
- public void addValueSet(Set valueSet) throws YdtException {
- String value;
- // Check the value against corresponding data-type.
- for (Object aValueSet : valueSet) {
- value = String.valueOf(aValueSet);
- //TODO validation need to be decided
-// try {
-// value = String.valueOf(aValueSet);
-// getYangSchemaNode().isValueValid(value);
-// } catch (DataModelException e) {
-// throw new YdtException(e.getLocalizedMessage());
-// }
- addValueToValueSet(value);
- }
- }
-
- @Override
- public void addValueWithoutValidation(String value, boolean isKeyLeaf) {
- valueSet.add(value);
- }
-
- @Override
- public void addValueSetWithoutValidation(Set valueSet) {
- this.valueSet.clear();
- this.valueSet.addAll(valueSet);
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtMultiInstanceNode.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtMultiInstanceNode.java
deleted file mode 100644
index 1691d2a..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtMultiInstanceNode.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import com.google.common.collect.ImmutableList;
-import org.onosproject.yangutils.datamodel.YangList;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
-import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_NODE;
-
-
-/**
- * Represents a multi instance node in YANG data tree.
- */
-public class YdtMultiInstanceNode extends YdtNode {
-
- // YDT formatted error string
- private static final String FMT_MISSING_KEY =
- "%s is missing some of the keys of %s.";
- private static final String FMT_UNI_KEY =
- "Some of the key elements are not unique in %s.";
- private static final String FMT_MANY_INS =
- "Too many instances of %s. Expected maximum instances %d.";
- private static final String FMT_FEW_INS =
- "Too few instances of %s. Expected minimum instances %d.";
-
- /*
- * Reference for list of key element's ydtContext.
- */
- private List<YdtContext> keyNodeList = new ArrayList<>();
-
- /*
- * Reference for composite key string for multi Instance Node..
- */
- private String compositeKey;
-
- /**
- * Creates a YANG multi instance node object.
- *
- * @param node schema of YDT multi instance node .
- */
- YdtMultiInstanceNode(YangSchemaNode node) {
- super(MULTI_INSTANCE_NODE, node);
- }
-
- /**
- * Returns the composite key string for current multi instance node.
- *
- * @return composite key string
- */
- private String getCompositeKey() {
- return compositeKey;
- }
-
- /**
- * Returns the list of key element's ydtContext.
- *
- * @return list of key element's ydtContext
- */
- public List<YdtContext> getKeyNodeList() {
- return ImmutableList.copyOf(keyNodeList);
- }
-
- @Override
- public void createKeyNodeList() throws YdtException {
- YangList yangListHolder = (YangList) getYangSchemaNode();
- List<String> schemaKeyList = yangListHolder.getKeyList();
-
- /*
- * If key element not defined in schema or config is false then
- * return no need to do create key list.
- */
- if (schemaKeyList == null || !yangListHolder.isConfig()) {
- return;
- }
-
- StringBuilder ksb = new StringBuilder();
-
- // Iterator for schema key name list.
- Iterator<String> sklItr = schemaKeyList.iterator();
-
- List<YdtContext> nodeList = new ArrayList<>();
-
- YangSchemaNodeIdentifier id = new YangSchemaNodeIdentifier();
- id.setNameSpace(new NameSpace(getNamespace()));
- // This loop should run while schema key list is not finished
- while (sklItr.hasNext()) {
- String name = sklItr.next();
- id.setName(name);
- YdtNode<YdtSingleInstanceLeafNode> collidingChild =
- (YdtNode<YdtSingleInstanceLeafNode>) ydtNodeMap.get(id);
-
- if (collidingChild == null) {
- throw new YdtException(
- errorMsg(FMT_MISSING_KEY, yangListHolder.getParent()
- .getName(), yangListHolder.getName()));
- }
-
- /*
- * Preparing composite key string by concatenating values of
- * all the key leaf.
- */
- ksb.append(collidingChild.getValue());
- nodeList.add(collidingChild);
- }
- //Setting te key object in List.
- keyNodeList = nodeList;
- compositeKey = ksb.toString();
- }
-
- /**
- * Validates the given list of instances by verifying the allowed
- * instance count and key element uniqueness.
- *
- * @param keyStringSet set to validate the key element uniqueness
- * @param list list of instance's of same list
- * @throws YdtException when user requested multi instance node instance's
- * count doesn't fit into the allowed instance's limit
- * or doesn't have unique key's
- */
- public void validateInstances(Set keyStringSet, List list)
- throws YdtException {
-
- // Clearing the set.
- keyStringSet.clear();
-
- /*
- * Storing the number of multiInstance node for number
- * if instance validation.
- */
- int instanceCount = list.size();
-
- YangList listSchema = (YangList) ((YdtMultiInstanceNode) list.get(0))
- .getYangSchemaNode();
- validateInstanceCount(instanceCount, listSchema);
- if (listSchema.isConfig() && instanceCount > 1) {
-
- /*
- * Iterating over values in ydtNodeList of
- * multiInstanceNode and compare the key string.
- */
- for (YdtNode ydtNode : (List<YdtNode<YdtMultiInstanceNode>>) list) {
- if (!keyStringSet.add(((YdtMultiInstanceNode) ydtNode)
- .getCompositeKey())) {
- throw new YdtException(
- errorMsg(FMT_UNI_KEY, ydtNode.getName()));
- }
- }
- }
- }
-
- /**
- * Validates the instance count for given list entry.
- *
- * @param instanceCount actual count
- * @param list list entry for which instance count need
- * to be validated
- * @throws YdtException when user requested multi instance node instance's
- * count doesn't fit into the allowed instance's limit
- */
- private void validateInstanceCount(int instanceCount, YangList list)
- throws YdtException {
-
- if (list.getMinElements() != null) {
- int minElement = list.getMinElements().getMinElement();
- if (instanceCount < minElement) {
- throw new YdtException(errorMsg(FMT_FEW_INS, list.getName(),
- minElement));
- }
- }
-
- if (list.getMaxElements() != null) {
- int maxElement = list.getMaxElements().getMaxElement();
- if (instanceCount > maxElement) {
- throw new YdtException(errorMsg(FMT_MANY_INS, list.getName(),
- maxElement));
- }
- }
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtNode.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtNode.java
deleted file mode 100644
index 41d86e8..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtNode.java
+++ /dev/null
@@ -1,639 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeContextInfo;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
-import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-import org.onosproject.yms.ydt.YdtExtendedInfoType;
-import org.onosproject.yms.ydt.YdtType;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
-
-/**
- * Represents implementation of interfaces to build and obtain YANG data tree
- * which is data (sub)instance representation, abstract of protocol.
- */
-public abstract class YdtNode<T> implements YdtExtendedContext, Cloneable {
-
- // YDT formatted error string
- private static final String FMT_NON_LIST_STR =
- "List of key cannot be created for leaf and leaf-list %s node.";
- private static final String FMT_VAL_N =
- "Value cannot be set in non leaf %s node.";
- private static final String FMT_VAL_NS =
- "ValueSet cannot be set in non leaf-list %s node.";
- private static final String FMT_VAL_IN =
- "Value cannot be invoke from non leaf %s node.";
- private static final String FMT_VAL_INS =
- "ValueSet cannot be invoke from non leaf-list %s node";
-
- // YDT error string
- private static final String E_EXIST = "Node is already part of a tree";
- private static final String E_ATOMIC =
- "Child to be added is not atomic, it already has a child";
- private static final String E_SIB =
- "Child to be added is not atomic, it already has a next sibling";
- private static final String E_PRE =
- "Child to be added is not atomic, it already has a previous " +
- "sibling";
- private static final String E_SUPPORT = "Requested node type not supported";
-
- /*
- * Parent reference.
- */
- private YdtNode parent;
-
- /*
- * First child reference.
- */
- private YdtNode child;
-
- /*
- * Next sibling reference.
- */
- private YdtNode nextSibling;
-
- /*
- * Previous sibling reference.
- */
- private YdtNode previousSibling;
-
- /*
- * Last child reference.
- */
- private YdtNode lastChild;
-
- /*
- * Type of node.
- */
- private final YdtType ydtType;
-
- /*
- * Flag to keep the track of context switch,
- * if set then traverse back to parent in YDT app tree else no need.
- */
- private boolean isContextSwitch;
-
- /*
- * YDT extended information.
- */
- private T ydtExtendedInfo;
-
- /*
- * YDT extended information type.
- */
- private YdtExtendedInfoType ydtExtendedInfoType;
-
- /*
- * Ydt map to keep the track of node added under current parent node.
- */
- final Map<YangSchemaNodeIdentifier, YdtNode<T>> ydtNodeMap =
- new HashMap<>();
-
- /*
- * Ydt map to keep the track of multi instance node added under current
- * parent node.
- */
- private final Map<YangSchemaNodeIdentifier,
- List<YdtNode<YdtMultiInstanceNode>>> ydtMultiInsMap =
- new HashMap<>();
-
- /*
- * Reference for data-model schema node.
- */
- private YangSchemaNode yangSchemaNode;
-
- /*
- * Reference for ydt node operation type.
- */
- private YdtContextOperationType ydtContextOperationType;
-
- /*
- * Ydt map to keep the track of application information object
- * with respective type.
- */
- private final Map<AppType, Object> ydtAppInfoMap = new HashMap<>();
-
- private YdtContext clonedNode;
-
- /**
- * Creates a specific type of node.
- *
- * @param type of YDT node
- * @param node schema node
- */
- YdtNode(YdtType type, YangSchemaNode node) {
- ydtType = type;
- yangSchemaNode = node;
- }
-
- /**
- * Creates a specific type of node.
- *
- * @param type of YDT node
- */
- YdtNode(YdtType type) {
- ydtType = type;
- }
-
- /**
- * Returns the cloned ydt node.
- *
- * @return clonedNode cloned ydt node
- */
- public YdtContext getClonedNode() {
- return clonedNode;
- }
-
- /**
- * Sets the cloned node.
- *
- * @param clonedNode cloned ydt node
- */
- public void setClonedNode(YdtContext clonedNode) {
- this.clonedNode = clonedNode;
- }
-
- @Override
- public String getName() {
- return yangSchemaNode.getName();
- }
-
- @Override
- public String getNamespace() {
- return yangSchemaNode.getNameSpace().getModuleNamespace();
- }
-
- @Override
- public String getModuleNameAsNameSpace() {
- return yangSchemaNode.getNameSpace().getModuleName();
- }
-
- @Override
- public <T> T getYdtContextExtendedInfo() {
- return (T) ydtExtendedInfo;
- }
-
- @Override
- public YdtExtendedInfoType getYdtExtendedInfoType() {
- return ydtExtendedInfoType;
- }
-
- @Override
- public YdtType getYdtType() {
- return ydtType;
- }
-
- @Override
- public YdtNode getParent() {
- return parent;
- }
-
- @Override
- public YdtNode getFirstChild() {
- return child;
- }
-
- @Override
- public YdtNode getNextSibling() {
- return nextSibling;
- }
-
- public YangSchemaNode getYangSchemaNode() {
- return yangSchemaNode;
- }
-
- @Override
- public YdtNode getLastChild() {
- return lastChild;
- }
-
- @Override
- public Object getAppInfo(AppType appType) {
- return ydtAppInfoMap.get(appType);
- }
-
- @Override
- public void addAppInfo(AppType appType, Object object) {
- ydtAppInfoMap.put(appType, object);
- }
-
- /**
- * Returns child schema node context information. It is used by YMS to
- * obtain the child schema corresponding to data node identifier.
- *
- * @param id represents a identifier of YANG data tree node
- * @return YANG data node context information
- * @throws YdtException when user requested node schema doesn't exist
- */
- public YangSchemaNodeContextInfo getSchemaNodeContextInfo(
- YangSchemaNodeIdentifier id) throws YdtException {
- try {
- return getYangSchemaNode().getChildSchema(id);
- } catch (DataModelException e) {
- throw new YdtException(e.getLocalizedMessage());
- }
- }
-
- /**
- * Adds the given value to the non single instance leaf node.
- * <p>
- * This default implementation throws an exception stating that
- * the value cannot be added. Subclasses may override this method
- * to provide the correct behavior for their specific implementation.
- *
- * @param value value in a single instance node
- * @throws YdtException when fails to add value for non single instance
- * leaf node
- */
- public void addValue(String value) throws YdtException {
- throw new YdtException(errorMsg(FMT_VAL_N, getName()));
- }
-
- /**
- * Creates the list of key element's of multi instance node.
- * This will not be applicable on leaf and leaf-list node.
- *
- * @throws YdtException when user requested multi instance node is missing
- * any of the key element in request or requested
- * node is of type other then multi instance node
- */
- public void createKeyNodeList() throws YdtException {
- throw new YdtException(errorMsg(FMT_NON_LIST_STR, getName()));
- }
-
- /**
- * Adds the given value to the non single instance leaf node.
- * <p>
- * This default implementation throws an exception stating that
- * the value cannot be added. Subclasses may override this method
- * to provide the correct behavior for their specific implementation.
- * This will be applicable in case of call from SBI so no need
- * to validate the value.
- *
- * @param value value in a single instance leaf node
- * @param isKeyLeaf true, for key leaf; false non key leaf
- * @throws YdtException when fails to add value for non single instance
- * leaf node
- */
- public void addValueWithoutValidation(String value, boolean isKeyLeaf)
- throws YdtException {
- throw new YdtException(errorMsg(FMT_VAL_N, getName()));
- }
-
- /**
- * Adds the given valueSet to the non multi instance leaf node.
- * <p>
- * This default implementation throws an exception stating that
- * the value cannot be added. Subclasses may override this method
- * to provide the correct behavior for their specific implementation.
- *
- * @param valueSet valueSet in a multi instance leaf node
- * @throws YdtException when fails to add value set for non multi instance
- * leaf node
- */
- public void addValueSet(Set<String> valueSet) throws YdtException {
- throw new YdtException(errorMsg(FMT_VAL_NS, getName()));
- }
-
- /**
- * Adds the given valueSet to the non multi instance leaf node.
- * <p>
- * This default implementation throws an exception stating that
- * the value cannot be added. Subclasses may override this method
- * to provide the correct behavior for their specific implementation.
- * This will be applicable in case of call from SBI so no need
- * to validate the value.
- *
- * @param valueSet valueSet in a multi instance leaf node
- * @throws YdtException when fails to add value set for non multi instance
- * leaf node
- */
- public void addValueSetWithoutValidation(Set<String> valueSet)
- throws YdtException {
- throw new YdtException(errorMsg(FMT_VAL_NS, getName()));
- }
-
- /**
- * Validates requested node allowed to have duplicate entry or not.
- * <p>
- * This default implementation throws an exception stating that
- * the duplicate entry found. Subclasses may override this method
- * to provide the correct behavior for their specific implementation.
- *
- * @throws YdtException when fails to process valid duplicate entry in YDT
- */
- void validDuplicateEntryProcessing() throws YdtException {
- }
-
- /**
- * Returns already existing YdtNode in Ydt tree with same nodeIdentifier.
- *
- * @param id represents a identifier of YANG data tree node
- * @return YDT node
- * @throws YdtException when user requested node already part of YDT tree.
- */
- public YdtNode getCollidingChild(YangSchemaNodeIdentifier id)
- throws YdtException {
-
- // Find the key in YDT map for getting the colliding node.
- YdtNode collidingChild = ydtNodeMap.get(id);
-
- /*
- * If colliding child exist then process colliding node in respective
- * YDT node type.
- */
- if (collidingChild != null) {
- collidingChild.validDuplicateEntryProcessing();
- return collidingChild;
- }
-
- return null;
- }
-
- /**
- * Sets the parent of node.
- *
- * @param parent node
- */
- public void setParent(YdtNode parent) {
- this.parent = parent;
- }
-
- /**
- * Sets the first instance of a child node.
- *
- * @param child is only child to be set
- */
- public void setChild(YdtNode child) {
- this.child = child;
- }
-
- /**
- * Sets the next sibling of node.
- *
- * @param sibling YANG node
- */
- public void setNextSibling(YdtNode sibling) {
- nextSibling = sibling;
- }
-
- /**
- * Returns the previous sibling of a node.
- *
- * @return previous sibling of a node
- */
- public YdtNode getPreviousSibling() {
- return previousSibling;
- }
-
- /**
- * Sets the previous sibling.
- *
- * @param previousSibling points to predecessor sibling
- */
- public void setPreviousSibling(YdtNode previousSibling) {
- this.previousSibling = previousSibling;
- }
-
- @Override
- public String getValue() throws YdtException {
- throw new YdtException(errorMsg(FMT_VAL_IN, getName()));
- }
-
- @Override
- public Set<String> getValueSet() throws YdtException {
- throw new YdtException(errorMsg(FMT_VAL_INS, getName()));
- }
-
- /**
- * Sets the data-model node reference for of a given node.
- *
- * @param yangSchemaNode YANG data node
- */
- public void setYangSchemaNode(YangSchemaNode yangSchemaNode) {
- this.yangSchemaNode = yangSchemaNode;
- }
-
- /**
- * Sets the last instance of a child node.
- *
- * @param child is last child to be set
- */
- public void setLastChild(YdtNode child) {
- lastChild = child;
- }
-
-
- /**
- * Adds a child node.
- * The children sibling list will be sorted based on node
- * type. This will add single child or sub-tree based on isAtomic flag.
- *
- * @param newChild refers to a new child to be added
- * @param isAtomic boolean flag to maintain atomicity of the current node
- * @throws YdtException in case of violation of any YDT rule
- */
- public void addChild(YdtContext newChild, boolean isAtomic)
- throws YdtException {
-
- if (!(newChild instanceof YdtNode)) {
- throw new YdtException(errorMsg(E_SUPPORT));
- }
-
- YdtNode node = (YdtNode) newChild;
-
- if (node.getParent() == null) {
- node.setParent(this);
- } else if (!node.getParent().equals(this)) {
- throw new YdtException(E_EXIST);
- }
-
- if (node.getFirstChild() != null && isAtomic) {
- throw new YdtException(E_ATOMIC);
- }
-
- if (node.getNextSibling() != null) {
- throw new YdtException(E_SIB);
- }
-
- if (node.getPreviousSibling() != null) {
- throw new YdtException(E_PRE);
- }
-
- // If new node needs to be added as first child.
- if (getFirstChild() == null) {
- setChild(node);
- setLastChild(node);
- return;
- }
-
- // If new node needs to be added as last child.
- YdtNode curNode = getLastChild();
- curNode.setNextSibling(node);
- node.setPreviousSibling(curNode);
- setLastChild(node);
- }
-
- @Override
- public YdtContextOperationType getYdtContextOperationType() {
- return ydtContextOperationType;
- }
-
- /**
- * Sets type of yang data tree node operation.
- *
- * @param opType type of yang data tree node operation
- */
- public void setYdtContextOperationType(YdtContextOperationType opType) {
- ydtContextOperationType = opType;
- }
-
- /**
- * Updates ydt maps of current context parent node.
- *
- * @param node ydt node for which map need to be updated
- */
- void updateYdtMap(YdtNode node) {
-
- YangSchemaNodeIdentifier id = node.getYangSchemaNode()
- .getYangSchemaNodeIdentifier();
- /*
- * If node to be added is of type multi instance node(list) then multi
- * instance node to be updated
- */
- if (node.getYdtType() == YdtType.MULTI_INSTANCE_NODE) {
- updateMultiInsMap(id, node);
- }
-
- /*
- * If entry for multi instance node is already there with same id then
- * existing entry will be overwritten by the new entry.
- */
- ydtNodeMap.put(id, node);
- }
-
- /**
- * Updates ydt multi instance map of current context parent node.
- *
- * @param id object node identifier
- * @param node ydt node for which map need to be updated
- */
- private void updateMultiInsMap(YangSchemaNodeIdentifier id, YdtNode node) {
-
- List<YdtNode<YdtMultiInstanceNode>> list = ydtMultiInsMap.get(id);
- if (list == null) {
- list = new ArrayList<>();
- ydtMultiInsMap.put(id, list);
- }
- list.add(node);
- }
-
- /**
- * Returns the flag for node if context switch.
- *
- * @return isContextSwitch flag of a node
- */
- public boolean getAppContextSwitch() {
- return isContextSwitch;
- }
-
- /**
- * Sets the flag to keep the track of context switch.
- * If it is set then when YDT get traverToParent then
- * traverse back to parent in YDT application tree.
- */
- public void setAppContextSwitch() {
- isContextSwitch = true;
- }
-
- /**
- * Validates all multi Instance nodes inside current context.
- *
- * @throws YdtException when fails to validate multi instance node
- */
- public void validateMultiInstanceNode() throws YdtException {
-
- // Set for checking whether input string is unique or not.
- Set<String> keyStringSet = new HashSet<>();
-
- if (ydtMultiInsMap.size() != 0) {
- /*
- * Iterating over values in map and find multi instance node list
- * only.
- */
- for (List<YdtNode<YdtMultiInstanceNode>> ydtNodeList :
- ydtMultiInsMap.values()) {
- try {
- ydtNodeList.get(0).validateInstances(keyStringSet,
- ydtNodeList);
- } catch (YdtException e) {
- throw new YdtException(e.getLocalizedMessage());
- }
- }
- }
- }
-
- /**
- * Validates the given list of instances by verifying the allowed
- * instance count and key element uniqueness.
- * <p>
- * This default implementation do nothing if requested node is of type
- * other then multiInstanceNode. Subclasses may override this method
- * to provide the correct behavior for their specific implementation.
- *
- * @param keyStringSet set to validate the key element uniqueness
- * @param ydtNodeList list of instance's of same list
- * @throws YdtException when user requested multi instance node instance's
- * count doesn't fit into the allowed instance's limit
- * or doesn't have unique key's
- */
- void validateInstances(Set<String> keyStringSet,
- List<YdtNode<YdtMultiInstanceNode>>
- ydtNodeList) throws YdtException {
-
- }
-
- /**
- * Clones the current node contents and create a new node.
- *
- * @return cloned node
- * @throws CloneNotSupportedException clone is not supported
- * by the referred node
- */
- public YdtNode clone() throws CloneNotSupportedException {
- YdtNode clonedNode = (YdtNode) super.clone();
- clonedNode.setPreviousSibling(null);
- clonedNode.setNextSibling(null);
- clonedNode.setParent(null);
- clonedNode.setChild(null);
- clonedNode.setLastChild(null);
- return clonedNode;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtNodeFactory.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtNodeFactory.java
deleted file mode 100644
index 9101c97..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtNodeFactory.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeType;
-import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-
-import static org.onosproject.yangutils.datamodel.YangSchemaNodeType.YANG_MULTI_INSTANCE_LEAF_NODE;
-import static org.onosproject.yangutils.datamodel.YangSchemaNodeType.YANG_MULTI_INSTANCE_NODE;
-import static org.onosproject.yangutils.datamodel.YangSchemaNodeType.YANG_SINGLE_INSTANCE_LEAF_NODE;
-import static org.onosproject.yangutils.datamodel.YangSchemaNodeType.YANG_SINGLE_INSTANCE_NODE;
-import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
-
-/**
- * Represents an YANG node factory to create different types of YANG data tree
- * node.
- */
-final class YdtNodeFactory {
-
- // YDT formatted error string
- private static final String FMT_NOT_EXIST =
- "Schema node with name %s doesn't exist.";
- //TODO need to handle later
- private static final String E_MULTI_INS =
- "Requested interface adds an instance of type list or " +
- "leaf-list node only.";
-
- // No instantiation
- private YdtNodeFactory() {
- }
-
- /**
- * Returns a YANG data tree node for a given name, set of values and
- * instance type.
- *
- * @param node data node as per YANG schema metadata
- * @param cardinality requested cardinality of node
- * @param callType identify the call type
- * @return YANG data tree node
- * @throws YdtException when user requested node type doesn't exist
- */
- static YdtNode getNode(
- YangSchemaNode node, RequestedCardinality cardinality,
- RequestedCallType callType) throws YdtException {
-
- YdtNode newNode;
- YangSchemaNodeType type = node.getYangSchemaNodeType();
-
- try {
- switch (cardinality) {
-
- case UNKNOWN:
- /*
- * if requested node type is UNKNOWN, check corresponding
- * yang data node type and create respective type node.
- */
- newNode = getYangSchemaNodeTypeSpecificContext(node, type,
- callType);
- break;
-
- /*
- * if requested node type is specified and it exist as node of
- * some other type in data model then throw exception
- */
- case SINGLE_INSTANCE:
- validateNodeType(node, type, YANG_SINGLE_INSTANCE_NODE);
- newNode = new YdtSingleInstanceNode(node);
- break;
-
- case MULTI_INSTANCE:
-
- validateNodeType(node, type, YANG_MULTI_INSTANCE_NODE);
- newNode = new YdtMultiInstanceNode(node);
- break;
-
- case SINGLE_INSTANCE_LEAF:
-
- validateNodeType(node, type, YANG_SINGLE_INSTANCE_LEAF_NODE);
- newNode = new YdtSingleInstanceLeafNode(node);
- break;
-
- case MULTI_INSTANCE_LEAF:
-
- validateNodeType(node, type, YANG_MULTI_INSTANCE_LEAF_NODE);
- newNode = new YdtMultiInstanceLeafNode(node);
- break;
-
- default:
- newNode = null;
- }
- } catch (DataModelException | YdtException e) {
- throw new YdtException(e.getLocalizedMessage());
- }
-
- if (newNode == null) {
- throw new YdtException(errorMsg(FMT_NOT_EXIST, node.getName()));
- }
-
- return newNode;
- }
-
- /**
- * Validates the requested ydt node type against the schema node type,
- * if it is not equal then it will throw warning.
- *
- * @param node schema node
- * @param nodeType actual node type
- * @param requestedType user requested node type
- * @throws YdtException when user requested node type doesn't exist
- */
- private static void validateNodeType(
- YangSchemaNode node, YangSchemaNodeType nodeType,
- YangSchemaNodeType requestedType) throws YdtException {
-
- if (nodeType != requestedType) {
- throw new YdtException(errorMsg(FMT_NOT_EXIST, node.getName()));
- }
- }
-
- /**
- * Creates Yang data tree node of YangSchemaNode type specific for
- * requestedCardinality of type UNKNOWN and returns the same.
- *
- * @param node schema node
- * @param nodeType schema node type as per YANG schema metadata
- * @param callType identify the call type
- * @return YANG data tree node
- * @throws YdtException when user requested node type doesn't exist
- */
- private static YdtNode getYangSchemaNodeTypeSpecificContext(
- YangSchemaNode node, YangSchemaNodeType nodeType,
- RequestedCallType callType) throws YdtException, DataModelException {
- switch (callType) {
- case LEAF:
- switch (nodeType) {
-
- case YANG_SINGLE_INSTANCE_LEAF_NODE:
- return new YdtSingleInstanceLeafNode(node);
-
- case YANG_MULTI_INSTANCE_LEAF_NODE:
- return new YdtMultiInstanceLeafNode(node);
-
- default:
- return null;
- }
-
- case NON_LEAF:
- switch (nodeType) {
-
- case YANG_SINGLE_INSTANCE_NODE:
- return new YdtSingleInstanceNode(node);
-
- case YANG_MULTI_INSTANCE_NODE:
- return new YdtMultiInstanceNode(node);
-
- default:
- return null;
- }
-
- case MULTI_INSTANCE:
- switch (nodeType) {
-
- case YANG_MULTI_INSTANCE_LEAF_NODE:
- return new YdtMultiInstanceLeafNode(node);
-
- case YANG_MULTI_INSTANCE_NODE:
- return new YdtMultiInstanceNode(node);
-
- default:
- throw new YdtException(E_MULTI_INS);
- }
-
- case EMPTY_CONTAINER:
- switch (nodeType) {
-
- case YANG_SINGLE_INSTANCE_NODE:
- return new YdtSingleInstanceNode(node);
-
- case YANG_SINGLE_INSTANCE_LEAF_NODE:
- return new YdtSingleInstanceLeafNode(node);
-
- default:
- return null;
- }
-
- default:
- return null;
- }
- }
-
- /**
- * Create Yang data tree node of YangSchemaNode type specific and
- * returns the same.
- *
- * @param node schema node
- * @return YANG data tree node
- * @throws YdtException when user requested node type doesn't exist
- */
- static YdtNode getYangSchemaNodeTypeSpecificContext(YangSchemaNode node)
- throws YdtException {
-
- switch (node.getYangSchemaNodeType()) {
-
- case YANG_SINGLE_INSTANCE_LEAF_NODE:
- return new YdtSingleInstanceLeafNode(node);
-
- case YANG_MULTI_INSTANCE_LEAF_NODE:
- return new YdtMultiInstanceLeafNode(node);
-
- case YANG_SINGLE_INSTANCE_NODE:
- return new YdtSingleInstanceNode(node);
-
- case YANG_MULTI_INSTANCE_NODE:
- return new YdtMultiInstanceNode(node);
-
- default:
- throw new YdtException(errorMsg(FMT_NOT_EXIST, node.getName()));
- }
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtSingleInstanceLeafNode.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtSingleInstanceLeafNode.java
deleted file mode 100644
index cc2a223..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtSingleInstanceLeafNode.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-
-import static org.onosproject.yms.app.ydt.YdtConstants.FMT_DUP_ENTRY;
-import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
-import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_LEAF_VALUE_NODE;
-
-/**
- * Represents YDT single instance leaf node which is an atomic element
- * and doesn't have any child.
- */
-public class YdtSingleInstanceLeafNode extends YdtNode {
-
- /*
- * Value of the leaf.
- */
- private String value;
-
- /*
- * Value of the leaf.
- */
- private Boolean isKeyLeaf = false;
-
- /**
- * Creates a YANG single instance leaf node.
- *
- * @param node schema of YDT single instance leaf node
- */
- YdtSingleInstanceLeafNode(YangSchemaNode node) {
- super(SINGLE_INSTANCE_LEAF_VALUE_NODE, node);
- }
-
- /**
- * Returns the flag indicating that requested leaf is key-leaf or not.
- *
- * @return isKeyLeaf true, for key leaf; false non key leaf
- */
- public Boolean isKeyLeaf() {
- return isKeyLeaf;
- }
-
- @Override
- public String getValue() {
- return value;
- }
-
- @Override
- public void addValue(String value) throws YdtException {
- // Check the value against corresponding data-type.
- //TODO validation need to be decided
-// try {
-// getYangSchemaNode().isValueValid(value);
-// } catch (Exception e) {
-// throw new YdtException(e.getLocalizedMessage());
-// }
-
- // After validation is successful then add value to node.
- this.value = value;
- }
-
-
- @Override
- public void addValueWithoutValidation(String value, boolean isKeyLeaf) {
- this.value = value;
- this.isKeyLeaf = isKeyLeaf;
- }
-
- @Override
- public void validDuplicateEntryProcessing() throws YdtException {
- throw new YdtException(errorMsg(FMT_DUP_ENTRY, getName()));
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtSingleInstanceNode.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtSingleInstanceNode.java
deleted file mode 100644
index 83d1d81..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtSingleInstanceNode.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-
-import static org.onosproject.yms.app.ydt.YdtConstants.FMT_DUP_ENTRY;
-import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
-import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_NODE;
-
-/**
- * Represents a single instance YANG data tree node.
- */
-class YdtSingleInstanceNode extends YdtNode {
-
- /**
- * Creates a YANG single instance node object.
- *
- * @param node schema of YDT single instance node
- */
- YdtSingleInstanceNode(YangSchemaNode node) {
- super(SINGLE_INSTANCE_NODE, node);
- }
-
- @Override
- public void validDuplicateEntryProcessing() throws YdtException {
- throw new YdtException(errorMsg(FMT_DUP_ENTRY, getName()));
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtUtils.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtUtils.java
deleted file mode 100644
index 9846ab3..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/YdtUtils.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package org.onosproject.yms.app.ydt;
-
-import org.onosproject.yangutils.datamodel.YangAugment;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeContextInfo;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
-import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-
-import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.DELETE_ONLY;
-import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.OTHER_EDIT;
-import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg;
-import static org.onosproject.yms.ydt.YdtContextOperationType.CREATE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-/**
- * Utils to support yang data tree node creation.
- */
-final class YdtUtils {
-
- // YDT formatted error string
- private static final String E_CREATE_OP =
- "Create request is not allowed under delete operation.";
- private static final String E_DELETE_OP =
- "Delete request is not allowed under create operation.";
- private static final String FMT_TOO_FEW =
- "Too few key parameters in %s. Expected %d; actual %d.";
- private static final String FMT_TOO_MANY =
- "Too many key parameters in %s. Expected %d; actual %d.";
-
- //No instantiation.
- private YdtUtils() {
- }
-
- /**
- * Returns the app tree operation type with the help of YdtOperation type.
- *
- * @param opType ydt operation type
- * @return app tree operation type
- */
- static YdtAppNodeOperationType getAppOpTypeFromYdtOpType(
- YdtContextOperationType opType) {
- // Get the app tree operation type.
- switch (opType) {
- case CREATE:
- case MERGE:
- case REPLACE:
- return OTHER_EDIT;
-
- case DELETE:
- case REMOVE:
- return DELETE_ONLY;
-
- default:
- return null;
- //TODO handle the default data type.
- }
- }
-
- /**
- * Validates the various combination of operation type.
- *
- * @param parentOpType Reference for parent node operation type
- * @param childOpType type of YANG data tree node operation
- * @throws YdtException when user requested node operation type is
- * not valid as per parent node operation type
- */
- private static void validateOperationType(YdtContextOperationType parentOpType,
- YdtContextOperationType childOpType)
- throws YdtException {
-
- switch (parentOpType) {
- case CREATE:
- // Inside the create operation delete operation should not come.
- if (childOpType == DELETE) {
- throw new YdtException(E_CREATE_OP);
- }
- break;
- case DELETE:
- // Inside the delete operation create operation should not come.
- if (childOpType == CREATE) {
- throw new YdtException(E_DELETE_OP);
- }
- break;
- default:
- //TODO check all possible scenario.
- }
- }
-
- /**
- * Returns the operation type for non leaf node.
- * When "operation" attribute for current node is not specified or null,
- * then the operation applied to the parent data node of the
- * configuration is used. If no parent data node is available,
- * then the default-operation'value is used.
- * If default operation type is not set, merge will be taken as default
- * operation type.
- *
- * @param type operation type of parent node
- * @param defType YDT default operation type
- * @return operation type for current non leaf node
- */
- private static YdtContextOperationType getOperationType(
- YdtContextOperationType type, YdtContextOperationType defType) {
- return type != null ? type : (defType != null ? defType : MERGE);
- }
-
- /**
- * Returns the yang node identifier with requested name and namespace.
- *
- * @param name name of the node
- * @param namespace namespace of the node
- * @return yang node identifier
- */
- static YangSchemaNodeIdentifier getNodeIdentifier(String name,
- String namespace) {
- YangSchemaNodeIdentifier id = new YangSchemaNodeIdentifier();
- id.setName(name);
- id.setNameSpace(new NameSpace(namespace));
- return id;
- }
-
- /**
- * Checks the user supplied list of argument match's the expected value
- * or not.
- *
- * @param name name of the parent list/leaf-list node
- * @param expected count suppose to be
- * @param actual user supplied values count
- * @throws YdtException when user requested multi instance node instance's
- * count doesn't fit into the allowed instance limit
- */
- static void checkElementCount(String name, int expected,
- int actual) throws YdtException {
- if (expected < actual) {
- throw new YdtException(
- errorMsg(FMT_TOO_MANY, name, expected, actual));
- } else if (expected > actual) {
- throw new YdtException(
- errorMsg(FMT_TOO_FEW, name, expected, actual));
- }
- }
-
- /**
- * Returns the valid operation type for requested ydt node after performing
- * validation.
- *
- * @param opType user requested operation type
- * @param newNode new requested ydt node
- * @param parentNode parent node under which new node to be added
- * @param defOpType YDT context operation type
- * @return operation type
- * @throws YdtException when user requested node operation type is
- * not valid as per parent node operation type
- */
- static YdtContextOperationType getValidOpType(
- YdtContextOperationType opType, YdtContextOperationType defOpType,
- YdtNode newNode, YdtNode parentNode)
- throws YdtException {
-
- switch (newNode.getYdtType()) {
-
- case SINGLE_INSTANCE_NODE:
- case MULTI_INSTANCE_NODE:
-
- // Reference for parent node operation type.
- YdtContextOperationType parentOpType =
- parentNode.getYdtContextOperationType();
-
- if (opType == null) {
- opType = getOperationType(parentOpType, defOpType);
- } else if (parentOpType != null) {
- validateOperationType(parentOpType, opType);
- }
-
- return opType;
-
- /*
- * Nodes other then single/multi instance node does not support
- * operation type so no need of validation for those.
- */
- default:
- return null;
- }
- }
-
- /**
- * Returns augmenting node module yang schema node.
- *
- * @param id schema node identifier
- * @param contextInfo Yang Schema node context info
- * which is having YangSchemaNode and
- * ContextSwitchedNode
- * @return augmenting node module yang schema node
- * @throws YdtException when user requested node schema doesn't exist
- */
- public static YangSchemaNode getAugmentingSchemaNode(
- YangSchemaNodeIdentifier id,
- YangSchemaNodeContextInfo contextInfo) throws YdtException {
- YangSchemaNode lastAugMod = null;
- YangSchemaNode switchedNode =
- contextInfo.getContextSwitchedNode();
-
- // Finding the last augmenting schema for case/choice scenario.
- while (switchedNode != null) {
- if (switchedNode instanceof YangAugment) {
- lastAugMod = switchedNode;
- }
- try {
- switchedNode = switchedNode.getChildSchema(id)
- .getContextSwitchedNode();
- } catch (DataModelException e) {
- throw new YdtException(e.getMessage());
- }
- }
- return lastAugMod;
- }
-
- /**
- * De-reference all the tree node by walking the whole YDT from logical
- * root node.
- * This will be called only when any exception occurs while processing
- * the node in Ydt tree.
- *
- * @param rootNode ydt logical root node
- */
- public static void freeRestResources(YdtNode rootNode) {
-
- YdtNode currentNode = rootNode;
- while (currentNode != null) {
-
- // Move down to first child
- YdtNode nextNode = currentNode.getFirstChild();
- if (nextNode != null) {
- currentNode = nextNode;
- continue;
- }
-
- // No child nodes, so walk tree
- while (currentNode != null) {
- // To keep the track of last sibling.
- YdtNode lastSibling = currentNode;
-
- // Move to sibling if possible.
- nextNode = currentNode.getNextSibling();
-
- // free currentNode resources
- free(lastSibling);
-
- lastSibling.getNamespace();
- if (nextNode != null) {
- currentNode = nextNode;
- break;
- }
-
- // Move up
- if (currentNode.equals(rootNode)) {
- currentNode = null;
- } else {
- currentNode = currentNode.getParent();
- lastSibling.setParent(null);
- }
- }
- }
- }
-
- /**
- * Free the give YDT node by de-referencing it to null.
- *
- * @param node node to be freed
- */
- private static void free(YdtNode node) {
- if (node.getParent() != null) {
- YdtNode parent = node.getParent();
- parent.setChild(null);
- parent.setLastChild(null);
- if (node.getNextSibling() != null) {
- parent.setChild(node.getNextSibling());
- }
- }
- YdtNode parentRef = node.getParent();
- node = new YdtLogicalNode(null, null);
- node.setParent(parentRef);
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/exceptions/YdtException.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/exceptions/YdtException.java
deleted file mode 100644
index 15243e8..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/exceptions/YdtException.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt.exceptions;
-
-/**
- * Represents base class for exceptions in YDT operations.
- */
-public class YdtException extends RuntimeException {
-
- private static final long serialVersionUID = 20160211L;
-
- /**
- * Creates a new YDT exception with given message.
- *
- * @param message the detail of exception in string
- */
- public YdtException(String message) {
- super(message);
- }
-
- /**
- * Creates a new YDT exception from given message and cause.
- *
- * @param message the detail of exception in string
- * @param cause underlying cause of the error
- */
- public YdtException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Creates a new YDT exception from cause.
- *
- * @param cause underlying cause of the error
- */
- public YdtException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/exceptions/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/exceptions/package-info.java
deleted file mode 100644
index b9e32c6..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/exceptions/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-/**
- * YANG data tree exceptions.
- */
-package org.onosproject.yms.app.ydt.exceptions;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/package-info.java
deleted file mode 100644
index 6ba98a6..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ydt/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of build and obtain YANG data tree which is data
- * (sub)instance representation, abstract of protocol.
- */
-package org.onosproject.yms.app.ydt;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ymsm/YmsManager.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ymsm/YmsManager.java
deleted file mode 100644
index b3e37c1..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ymsm/YmsManager.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ymsm;
-
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.core.IdGenerator;
-import org.onosproject.event.ListenerService;
-import org.onosproject.yms.app.yab.YangApplicationBroker;
-import org.onosproject.yms.app.ych.DefaultYangCodecHandler;
-import org.onosproject.yms.app.ych.defaultcodecs.YangCodecRegistry;
-import org.onosproject.yms.app.ydt.DefaultYdtWalker;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ynh.YangNotificationExtendedService;
-import org.onosproject.yms.app.ynh.YangNotificationManager;
-import org.onosproject.yms.app.ysr.DefaultYangModuleLibrary;
-import org.onosproject.yms.app.ysr.DefaultYangSchemaRegistry;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.ych.YangCodecHandler;
-import org.onosproject.yms.ych.YangDataTreeCodec;
-import org.onosproject.yms.ych.YangProtocolEncodingFormat;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtResponse;
-import org.onosproject.yms.ydt.YdtWalker;
-import org.onosproject.yms.ydt.YmsOperationType;
-import org.onosproject.yms.ymsm.YmsService;
-import org.onosproject.yms.ynh.YangNotificationService;
-import org.onosproject.yms.ysr.YangModuleIdentifier;
-import org.onosproject.yms.ysr.YangModuleLibrary;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-
-import static java.lang.String.valueOf;
-import static java.util.concurrent.Executors.newSingleThreadExecutor;
-import static org.onlab.util.Tools.groupedThreads;
-import static org.onosproject.yms.app.ych.defaultcodecs.YangCodecRegistry.initializeDefaultCodec;
-
-/**
- * Represents implementation of YANG management system manager.
- */
-@Component(immediate = true, service = YmsService.class)
-public class YmsManager
- implements YmsService {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private static final String APP_ID = "org.onosproject.app.yms";
- private static final String MODULE_ID = "module-id";
- private ApplicationId appId;
- private YangSchemaRegistry schemaRegistry;
- //module id generator should be used to generate a new module id for
- //each YSR instance. So YCH also should generate it.
- private IdGenerator moduleIdGenerator;
- private ExecutorService executor;
- private YangNotificationExtendedService ynhExtendedService;
- private YangModuleLibrary library;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Activate
- public void activate() {
- appId = coreService.registerApplication(APP_ID);
- moduleIdGenerator = coreService.getIdGenerator(MODULE_ID);
- schemaRegistry = new DefaultYangSchemaRegistry();
- library = new DefaultYangModuleLibrary(getNewModuleId());
- executor = newSingleThreadExecutor(groupedThreads(
- "onos/apps/yang-management-system/schema-registry",
- "schema-registry-handler", log));
- ynhExtendedService = new YangNotificationManager(schemaRegistry);
- //Initialize the default codec
- initializeDefaultCodec();
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- schemaRegistry.flushYsrData();
- executor.shutdown();
-
- // TODO implementation for other components.
- log.info("Stopped");
- }
-
- @Override
- public YdtBuilder getYdtBuilder(String logicalRootName,
- String rootNamespace,
- YmsOperationType opType) {
- return new YangRequestWorkBench(logicalRootName, rootNamespace,
- opType, schemaRegistry, true);
- }
-
- @Override
- public YdtBuilder getYdtBuilder(String logicalRootName,
- String rootNamespace,
- YmsOperationType opType,
- Object schemaRegistryForYdt) {
- if (schemaRegistryForYdt != null) {
- return new YangRequestWorkBench(
- logicalRootName, rootNamespace, opType,
- (YangSchemaRegistry) schemaRegistryForYdt, false);
- }
- return new YangRequestWorkBench(logicalRootName, rootNamespace,
- opType, schemaRegistry, true);
- }
-
- @Override
- public YdtWalker getYdtWalker() {
- return new DefaultYdtWalker();
- }
-
- @Override
- public YdtResponse executeOperation(YdtBuilder operationRequest) {
- YangApplicationBroker requestBroker =
- new YangApplicationBroker(schemaRegistry);
- switch (operationRequest.getYmsOperationType()) {
- case EDIT_CONFIG_REQUEST:
- try {
- return requestBroker.processEdit(operationRequest);
- } catch (CloneNotSupportedException e) {
- log.error("YAB: failed to process edit request.");
- }
- case QUERY_CONFIG_REQUEST:
- // TODO : to be implemented
- case QUERY_REQUEST:
- return requestBroker.processQuery(operationRequest);
- case RPC_REQUEST:
- return requestBroker.processOperation(operationRequest);
- default:
- // TODO : throw exception
- }
- return null;
- }
-
- @Override
- public YangNotificationService getYangNotificationService() {
- return ynhExtendedService;
- }
-
- @Override
- public YangModuleLibrary getYangModuleLibrary() {
- //TODO: get for YCH should be handled.
- return library;
- }
-
- @Override
- public String getYangFile(YangModuleIdentifier moduleIdentifier) {
- return schemaRegistry.getYangFile(moduleIdentifier);
- }
-
- @Override
- public void registerDefaultCodec(YangDataTreeCodec defaultCodec,
- YangProtocolEncodingFormat dataFormat) {
- YangCodecRegistry.registerDefaultCodec(defaultCodec, dataFormat);
- }
-
- @Override
- public void registerService(Object manager, Class<?> service,
- List<String> features) {
- //perform registration of service
- executor.execute(() -> {
-
- schemaRegistry.registerApplication(manager, service);
- //process notification registration.
- processNotificationRegistration(manager, service);
-
- schemaRegistry.processModuleLibrary(service.getName(), library);
- });
- // TODO implementation based on supported features.
- }
-
- /**
- * Process notification registration for manager class object.
- *
- * @param manager yang manager
- * @param service service class
- */
- private void processNotificationRegistration(Object manager, Class<?> service) {
- synchronized (service) {
- if (manager != null && manager instanceof ListenerService) {
- if (schemaRegistry.verifyNotificationObject(manager, service)) {
- ynhExtendedService.registerAsListener((ListenerService) manager);
- }
- }
- }
- }
-
- @Override
- public void unRegisterService(Object appManager, Class<?> yangService) {
- schemaRegistry.unRegisterApplication(appManager, yangService);
- }
-
- @Override
- public YangCodecHandler getYangCodecHandler() {
- YangSchemaRegistry registry = new DefaultYangSchemaRegistry();
- DefaultYangCodecHandler handler = new DefaultYangCodecHandler(registry);
- handler.setLibrary(new DefaultYangModuleLibrary(getNewModuleId()));
- return handler;
- }
-
- /**
- * Returns schema registry.
- *
- * @return schema registry
- */
- public YangSchemaRegistry getSchemaRegistry() {
- return schemaRegistry;
- }
-
- /**
- * Returns new generated module id.
- *
- * @return new module id
- */
- private String getNewModuleId() {
- return valueOf(moduleIdGenerator.getNewId());
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ymsm/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ymsm/package-info.java
deleted file mode 100644
index 19734da..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ymsm/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of YANG application management system manager. YMSM is manager
- * of the YANG Core, it manages interaction between application and protocols.
- */
-package org.onosproject.yms.app.ymsm;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ynh/YangNotificationExtendedService.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ynh/YangNotificationExtendedService.java
deleted file mode 100644
index bb012c0..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ynh/YangNotificationExtendedService.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ynh;
-
-import org.onosproject.event.ListenerService;
-import org.onosproject.yms.ynh.YangNotificationService;
-
-/**
- * Abstraction of an entity which provides interfaces to YANG extended notification
- * service. It provides extended interfaces required by YMS internal modules.
- * Application registers their schema with YMSM, YMSM delegates the registration
- * request to YSR. YSR then looks for the presence of notification in application
- * schema, presence of notification will trigger YSR to ask YANG extended notification
- * service to register it as a listener to that application events.
- */
-public interface YangNotificationExtendedService extends YangNotificationService {
-
- /**
- * Registers as listener with application. This is called by YSR when it
- * detects notification presence in application YANG file at the time when
- * application registers it's schema with YMS.
- *
- * @param appObject application object
- */
- void registerAsListener(ListenerService appObject);
-
- // TODO handle scenario when multiple services are implemented by single manager.
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ynh/YangNotificationManager.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ynh/YangNotificationManager.java
deleted file mode 100644
index 131dcb8..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ynh/YangNotificationManager.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ynh;
-
-import org.onosproject.event.Event;
-import org.onosproject.event.EventListener;
-import org.onosproject.event.ListenerRegistry;
-import org.onosproject.event.ListenerService;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.app.ytb.DefaultYangTreeBuilder;
-import org.onosproject.yms.app.ytb.YangTreeBuilder;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ynh.YangNotification;
-import org.onosproject.yms.ynh.YangNotificationEvent;
-import org.onosproject.yms.ynh.YangNotificationListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import static org.onlab.util.Tools.groupedThreads;
-
-/**
- * Representation of YANG notification manager.
- */
-public class YangNotificationManager
- extends ListenerRegistry<YangNotificationEvent, YangNotificationListener>
- implements YangNotificationExtendedService {
-
- private static final String YANG_NOTIFICATION = "yangnotification";
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private ExecutorService executor;
-
- /**
- * YANG notification abstract listener. This listener will listens
- * abstractly to all the notification from the application to which it
- * has subscribed.
- */
- private YnhAbstractListener listener;
-
- /**
- * Maintains schema registry.
- */
- private YangSchemaRegistry schemaRegistry;
-
- /**
- * Creates an instance of YANG notification manager.
- *
- * @param registry YANG schema registry
- */
- public YangNotificationManager(YangSchemaRegistry registry) {
- listener = new YnhAbstractListener();
- executor = Executors.newSingleThreadExecutor(groupedThreads(
- "onos/yms", "event-handler-%d", log));
- schemaRegistry = registry;
- }
-
- @Override
- public void registerAsListener(ListenerService manager) {
- manager.addListener(listener);
- }
-
- @Override
- public YangNotification getFilteredSubject(YangNotification subject,
- YangNotification filter) {
- return null;
- // TODO
- }
-
- /**
- * Representation of YANG notification handler's abstract listener. It
- * listens for events from application(s).
- */
- private class YnhAbstractListener<E extends Event> implements
- EventListener<E> {
-
- @Override
- public void event(Event event) {
- executor.execute(() -> {
- try {
- log.info("Event received in ynh " + event.type());
- /*
- * Obtain YANG data tree corresponding to notification with
- * logical root node as yangnotification, followed by
- * module/sub-module, followed by notification.
- */
- YangTreeBuilder builder = new DefaultYangTreeBuilder();
- YdtContext context = builder.getYdtForNotification(
- event, YANG_NOTIFICATION, schemaRegistry);
- /*
- * Create YANG notification from obtained data tree and
- * send it to registered protocols.
- */
- YangNotification notification =
- new YangNotification(context);
- process(new YangNotificationEvent(notification));
- } catch (Exception e) {
- log.warn("Failed to process {}", event, e);
- }
- });
- }
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ynh/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ynh/package-info.java
deleted file mode 100644
index 56e65d2..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ynh/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of YANG notification handler. YNH handles notification
- * from the application and provide it to the protocols.
- */
-package org.onosproject.yms.app.ynh;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/DefaultYobBuilder.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/DefaultYobBuilder.java
deleted file mode 100644
index a90137a..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/DefaultYobBuilder.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.onosproject.yms.app.ydt.DefaultYdtWalker;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtExtendedListener;
-import org.onosproject.yms.app.ydt.YdtExtendedWalker;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-
-import static org.onosproject.yms.app.ydt.AppType.YOB;
-
-/**
- * Represents implementation of interfaces to build and obtain YANG objects
- * from YDT.
- */
-public class DefaultYobBuilder implements YobBuilder {
-
- /**
- * Creates an instance of DefaultYobBuilder.
- */
- public DefaultYobBuilder() {
- }
-
- @Override
- public Object getYangObject(YdtExtendedContext ydtRootNode,
- YangSchemaRegistry schemaRegistry) {
- YdtExtendedWalker ydtExtendedWalker = new DefaultYdtWalker();
- YdtExtendedListener yobListener =
- new YobListener(ydtRootNode, schemaRegistry);
- if (ydtRootNode != null) {
- ydtExtendedWalker.walk(yobListener, ydtRootNode);
- YobWorkBench yobWorkBench =
- (YobWorkBench) ydtRootNode.getAppInfo(YOB);
- return yobWorkBench.getBuilderOrBuiltObject().getBuiltObject();
- }
- return null;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobBuilder.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobBuilder.java
deleted file mode 100644
index fc8af30..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobBuilder.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-
-/**
- * Abstraction of an entity which provides interfaces to YANG object
- * builder.
- */
-interface YobBuilder {
-
- /**
- * Returns the YANG object. This will be called by NBI broker.
- *
- * @param ydtExtendedContext ydtExtendedContext is used to get application
- * related information maintained in YDT
- * @param schemaRegistry schema registry
- * @return YANG builder object
- */
- Object getYangObject(YdtExtendedContext ydtExtendedContext,
- YangSchemaRegistry schemaRegistry);
-}
-
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobBuilderOrBuiltObject.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobBuilderOrBuiltObject.java
deleted file mode 100644
index 71900c2..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobBuilderOrBuiltObject.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.onosproject.yms.app.yob.exception.YobException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.onosproject.yms.app.yob.YobConstants.E_BUILDER_IS_NOT_ALREADY_SET;
-import static org.onosproject.yms.app.yob.YobConstants.E_BUILDER_IS_NOT_SET;
-import static org.onosproject.yms.app.yob.YobConstants.E_BUILT_OBJ_IS_NOT_SET;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_CREATE_OBJ;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_LOAD_CLASS;
-import static org.onosproject.yms.app.yob.YobConstants.E_OBJ_BUILDING_WITHOUT_BUILDER;
-import static org.onosproject.yms.app.yob.YobConstants.E_OBJ_IS_ALREADY_BUILT_NOT_BUILD;
-import static org.onosproject.yms.app.yob.YobConstants.E_OBJ_IS_ALREADY_BUILT_NOT_FETCH;
-import static org.onosproject.yms.app.yob.YobConstants.E_OBJ_IS_ALREADY_BUILT_NOT_SET;
-import static org.onosproject.yms.app.yob.YobConstants.E_OBJ_IS_NOT_SET_NOT_FETCH;
-import static org.onosproject.yms.app.yob.YobConstants.E_REFLECTION_FAIL_TO_CREATE_OBJ;
-import static org.onosproject.yms.app.yob.YobConstants.L_FAIL_TO_CREATE_OBJ;
-import static org.onosproject.yms.app.yob.YobConstants.L_FAIL_TO_LOAD_CLASS;
-import static org.onosproject.yms.app.yob.YobConstants.L_REFLECTION_FAIL_TO_CREATE_OBJ;
-
-/**
- * Represents the container of YANG object being built or the builder.
- */
-class YobBuilderOrBuiltObject {
- private static final Logger log =
- LoggerFactory.getLogger(YobWorkBench.class);
-
- /**
- * Is the contained object a built object.
- */
- private boolean isBuilt;
-
- /**
- * Builder or built object.
- */
- private Object builderOrBuiltObject;
-
- /**
- * Default / op param builder class.
- */
- Class<?> yangBuilderClass;
-
- /**
- * Default Class.
- */
- Class<?> yangDefaultClass;
-
- /**
- * Create Node Object holder.
- *
- * @param qualifiedClassName name of the class
- * @param registeredAppClassLoader class loader to be used
- * @throws YobException if failed to create the node object
- */
- YobBuilderOrBuiltObject(String qualifiedClassName,
- ClassLoader registeredAppClassLoader) {
- try {
- yangDefaultClass =
- registeredAppClassLoader.loadClass(qualifiedClassName);
- yangBuilderClass = yangDefaultClass.getDeclaredClasses()[0];
- setBuilderObject(yangBuilderClass.newInstance());
- } catch (ClassNotFoundException e) {
- log.error(L_FAIL_TO_LOAD_CLASS, qualifiedClassName);
- throw new YobException(E_FAIL_TO_LOAD_CLASS + qualifiedClassName);
- } catch (InstantiationException | IllegalAccessException e) {
- log.error(L_FAIL_TO_CREATE_OBJ, qualifiedClassName);
- throw new YobException(E_FAIL_TO_CREATE_OBJ + qualifiedClassName);
- } catch (NullPointerException e) {
- log.error(L_REFLECTION_FAIL_TO_CREATE_OBJ, qualifiedClassName);
- throw new YobException(E_REFLECTION_FAIL_TO_CREATE_OBJ +
- qualifiedClassName);
- }
- }
-
- /**
- * Returns the builder object if it is set.
- *
- * @return builder object
- * @throws YobException if builder is not available
- */
- Object getBuilderObject() {
- if (isBuilt) {
- throw new YobException(E_OBJ_IS_ALREADY_BUILT_NOT_FETCH);
- }
-
- if (builderOrBuiltObject == null) {
- throw new YobException(E_BUILDER_IS_NOT_SET);
- }
-
- return builderOrBuiltObject;
- }
-
- /**
- * Check if the builder object is being initialized for the first time and
- * set it.
- *
- * @param builderObject new builder object
- * @throws YobException if built object is not available
- */
- private void setBuilderObject(Object builderObject) {
- if (isBuilt) {
- throw new YobException(E_OBJ_IS_ALREADY_BUILT_NOT_SET);
- }
-
- if (builderOrBuiltObject != null) {
- throw new YobException(E_BUILDER_IS_NOT_ALREADY_SET);
- }
-
- builderOrBuiltObject = builderObject;
- }
-
- /**
- * Returns the built object.
- *
- * @return built object
- * @throws YobException if built object is not available or if it is not
- * built
- */
- Object getBuiltObject() {
- if (!isBuilt) {
- throw new YobException(E_OBJ_IS_NOT_SET_NOT_FETCH);
- }
-
- if (builderOrBuiltObject == null) {
- throw new YobException(E_BUILT_OBJ_IS_NOT_SET);
- }
-
- return builderOrBuiltObject;
- }
-
- /**
- * Check if the built object is being initialized for the 1st time and
- * set it.
- *
- * @param builtObject new built object
- * @throws YobException if builder object is not available or if it is
- * already built
- */
- void setBuiltObject(Object builtObject) {
- if (isBuilt) {
- throw new YobException(E_OBJ_IS_ALREADY_BUILT_NOT_BUILD);
- }
-
- if (builderOrBuiltObject == null) {
- throw new YobException(E_OBJ_BUILDING_WITHOUT_BUILDER);
- }
-
- isBuilt = true;
- builderOrBuiltObject = builtObject;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobConstants.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobConstants.java
deleted file mode 100644
index 84ccf38..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobConstants.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-/**
- * Represents common constant utility for YANG object builder.
- */
-final class YobConstants {
-
- private YobConstants() {
- }
-
- static final String FROM_STRING = "fromString";
- static final String BUILD = "build";
- static final String OP_PARAM = "OpParam";
- static final String DEFAULT = "Default";
- static final String ADD_TO = "addTo";
- static final String VALUE_OF = "valueOf";
- static final String OP_TYPE = "OpType";
- static final String ONOS_YANG_OP_TYPE = "OnosYangOpType";
- static final String OF = "of";
- static final String PERIOD = ".";
- static final String SPACE = " ";
- static final String ADD_AUGMENT_METHOD = "addYangAugmentedInfo";
- static final String YANG = "yang";
- static final String JAVA_LANG = "java.lang";
- static final String LEAF_IDENTIFIER = "LeafIdentifier";
- static final String SELECT_LEAF = "selectLeaf";
- static final String EVENT_SUBJECT = "EventSubject";
- static final String EVENT = "Event";
- static final String TYPE = "Type";
-
- //Error strings
- static final String E_NO_HANDLE_FOR_YDT = "No handler for YDT node";
- static final String E_HAS_NO_CHILD = " does not have child ";
- static final String E_SET_OP_TYPE_FAIL = "Failed to set Operation Type";
- static final String E_FAIL_TO_BUILD = "Failed to build the object: ";
- static final String L_FAIL_TO_BUILD = "Failed to build the object: {}";
- static final String E_FAIL_TO_GET_FIELD = "Failed to get field for class: ";
- static final String L_FAIL_TO_GET_FIELD =
- "Failed to get field for class: {}";
- static final String E_FAIL_TO_GET_METHOD =
- "Failed to get method for class: ";
- static final String L_FAIL_TO_GET_METHOD =
- "Failed to get method for class: {}";
- static final String E_FAIL_TO_LOAD_CLASS =
- "Failed to load class for class: ";
- static final String L_FAIL_TO_LOAD_CLASS =
- "Failed to load class for class: {}";
- static final String E_YDT_TYPE_IS_NOT_SUPPORT =
- "Given YDT type is not supported.";
- static final String E_FAIL_TO_CREATE_OBJ =
- "Failed to create an object for class: ";
- static final String L_FAIL_TO_CREATE_OBJ =
- "Failed to create an object for class: {}";
- static final String E_REFLECTION_FAIL_TO_CREATE_OBJ =
- "Reflection failed to create an object for class: ";
- static final String L_REFLECTION_FAIL_TO_CREATE_OBJ =
- "Reflection failed to create an object for class: {}";
- static final String E_FAIL_TO_LOAD_CONSTRUCTOR =
- "Failed to load constructor for class: {}";
- static final String E_FAIL_TO_INVOKE_METHOD =
- "Failed to invoke method for class: ";
- static final String L_FAIL_TO_INVOKE_METHOD =
- "Failed to invoke method for class: {}";
- static final String E_DATA_TYPE_NOT_SUPPORT =
- "Given data type is not supported.";
- static final String E_OBJ_IS_ALREADY_BUILT_NOT_FETCH =
- "Object is already built, cannot fetch builder";
- static final String E_BUILDER_IS_NOT_SET =
- "Builder is not yet set, cannot fetch it";
- static final String E_BUILT_OBJ_IS_NOT_SET =
- "Built object is not set";
- static final String E_OBJ_IS_ALREADY_BUILT_NOT_SET =
- "Object is already built, cannot set builder";
- static final String E_BUILDER_IS_NOT_ALREADY_SET =
- "Builder is not already set";
- static final String E_OBJ_IS_NOT_SET_NOT_FETCH =
- "Builder is not yet set, cannot fetch it";
- static final String E_OBJ_IS_ALREADY_BUILT_NOT_BUILD =
- "Object is already built, cannot build again";
- static final String E_OBJ_BUILDING_WITHOUT_BUILDER =
- "Object building without builder";
- static final String E_MISSING_DATA_IN_NODE =
- "YANG data tree is missing the data required for YOB";
- static final String E_INVALID_DATA_TREE =
- "YANG tree does not have a application root";
- static final String E_INVALID_EMPTY_DATA =
- "Value for empty data type is invalid";
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobHandler.java
deleted file mode 100644
index 1f5fc08..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobHandler.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.onosproject.yms.app.ydt.AppType.YOB;
-import static org.onosproject.yms.app.yob.YobUtils.getQualifiedDefaultClass;
-
-/**
- * Represents a YANG object builder handler to process the ydt content and
- * build yang object.
- */
-abstract class YobHandler {
-
- private static final Logger log = LoggerFactory.getLogger(YobHandler.class);
-
- /**
- * Creates a YANG builder object.
- *
- * @param curNode ydtExtendedContext is used to get
- * application related information maintained
- * in YDT
- * @param rootNode ydtRootNode is refers to module node
- * @param registry registry
- */
- public void createBuilder(YdtExtendedContext curNode,
- YdtExtendedContext rootNode,
- YangSchemaRegistry registry) {
- String setterName = null;
- YangSchemaNode node = curNode.getYangSchemaNode();
- while (node.getReferredSchema() != null) {
- node = node.getReferredSchema();
- }
-
- String qualName = getQualifiedDefaultClass(node);
- ClassLoader classLoader = YobUtils.getClassLoader(registry, qualName,
- curNode, rootNode);
-
- if (curNode != rootNode) {
- setterName = node.getJavaAttributeName();
- }
-
- Object workBench = new YobWorkBench(curNode.getYangSchemaNode(), classLoader, qualName,
- setterName);
-
- curNode.addAppInfo(YOB, workBench);
- }
-
- /**
- * Sets the YANG built object in corresponding parent class method.
- *
- * @param ydtNode ydtExtendedContext is used to get application
- * related information maintained in YDT
- * @param schemaRegistry YANG schema registry
- */
- public void setInParent(YdtExtendedContext ydtNode,
- YangSchemaRegistry schemaRegistry) {
- YdtExtendedContext parentNode = (YdtExtendedContext) ydtNode.getParent();
- YobWorkBench parentWorkbench = (YobWorkBench) parentNode.getAppInfo(YOB);
- parentWorkbench.setObject(ydtNode, schemaRegistry);
- }
-
- /**
- * Builds the object.
- *
- * @param ydtNode ydtExtendedContext is used to get
- * application related
- * information maintained in YDT
- * @param ydtRootNode ydtRootNode
- * @param schemaRegistry YANG schema registry
- */
- public void buildObject(YdtExtendedContext ydtNode,
- YdtExtendedContext ydtRootNode,
- YangSchemaRegistry schemaRegistry) {
- YobWorkBench yobWorkBench = (YobWorkBench) ydtNode.getAppInfo(YOB);
- yobWorkBench.buildObject(ydtNode.getYdtContextOperationType(), schemaRegistry);
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobHandlerFactory.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobHandlerFactory.java
deleted file mode 100644
index e91d0cf..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobHandlerFactory.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.yob.exception.YobException;
-import org.onosproject.yms.ydt.YdtType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.onosproject.yms.app.yob.YobConstants.E_YDT_TYPE_IS_NOT_SUPPORT;
-import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_LEAF_VALUE_NODE;
-import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_NODE;
-import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_LEAF_VALUE_NODE;
-import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_NODE;
-
-/**
- * Represents an YANG object builder factory to create different types
- * of YANG data tree node.
- */
-final class YobHandlerFactory {
-
- private static final Logger log =
- LoggerFactory.getLogger(YobHandlerFactory.class);
-
- /**
- * Map of YANG object builder handler.
- */
- private static final Map<YdtType, YobHandler> HANDLER_MAP = new HashMap<>();
-
- /**
- * Create instance of YobHandlerFactory.
- */
- private YobHandlerFactory() {
- HANDLER_MAP.put(SINGLE_INSTANCE_NODE, new YobSingleInstanceHandler());
- HANDLER_MAP.put(MULTI_INSTANCE_NODE, new YobMultiInstanceHandler());
- HANDLER_MAP.put(SINGLE_INSTANCE_LEAF_VALUE_NODE,
- new YobSingleInstanceLeafHandler());
- HANDLER_MAP.put(MULTI_INSTANCE_LEAF_VALUE_NODE,
- new YobMultiInstanceLeafHandler());
- }
-
- /**
- * Returns the corresponding YOB handler for current context.
- *
- * @param currentNode current YDT node for which object needs to be created
- * @return handler to create the object
- * @throws YobException if the YDT node type is not supported in YOB
- */
- YobHandler getYobHandlerForContext(YdtExtendedContext currentNode) {
- YobHandler yobHandler = HANDLER_MAP.get(currentNode.getYdtType());
- if (yobHandler == null) {
- log.error(E_YDT_TYPE_IS_NOT_SUPPORT);
- throw new YobException(E_YDT_TYPE_IS_NOT_SUPPORT);
- }
- return yobHandler;
- }
-
- /**
- * Returns the YANG object builder factory instance.
- *
- * @return YANG object builder factory instance
- */
- public static YobHandlerFactory instance() {
- return LazyHolder.INSTANCE;
- }
-
- /*
- * Bill Pugh Singleton pattern. INSTANCE won't be instantiated until the
- * LazyHolder class is loaded via a call to the instance() method below.
- */
- private static class LazyHolder {
- private static final YobHandlerFactory INSTANCE =
- new YobHandlerFactory();
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobListener.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobListener.java
deleted file mode 100644
index f0411cc..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobListener.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtExtendedListener;
-import org.onosproject.yms.app.yob.exception.YobException;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.ydt.YdtContext;
-
-import static org.onosproject.yms.app.yob.YobConstants.E_MISSING_DATA_IN_NODE;
-import static org.onosproject.yms.app.yob.YobHandlerFactory.instance;
-
-/**
- * Represents implementation of YANG object builder listener.
- */
-class YobListener implements YdtExtendedListener {
-
- /**
- * Reference to the ydt root node.
- */
- private YdtExtendedContext rootNode;
-
- /**
- * Reference to YANG schema registry.
- */
- private YangSchemaRegistry schemaRegistry;
-
- /**
- * Reference to YOB handler.
- */
- private YobHandlerFactory handlerFactory;
-
- /**
- * Creates an instance of YANG object builder listener.
- *
- * @param rootNode refers to YDT context
- * @param schemaRegistry refers to YANG schema registry
- */
- YobListener(YdtExtendedContext rootNode,
- YangSchemaRegistry schemaRegistry) {
- this.rootNode = rootNode;
- this.schemaRegistry = schemaRegistry;
- this.handlerFactory = instance();
- }
-
- @Override
- public void enterYdtNode(YdtExtendedContext node) {
-
- YobHandler nodeHandler =
- handlerFactory.getYobHandlerForContext(node);
-
- nodeHandler.createBuilder(node, rootNode, schemaRegistry);
-
- }
-
- @Override
- public void exitYdtNode(YdtExtendedContext node) {
- YobHandler nodeHandler =
- handlerFactory.getYobHandlerForContext(node);
-
- nodeHandler.buildObject(node, rootNode, schemaRegistry);
-
- // The current ydt context node and root node are same then built
- // object needs to be returned.
- if (!node.equals(rootNode)) {
- nodeHandler.setInParent(node, schemaRegistry);
- }
-
- }
-
- /**
- * Does not support walking of non extended context YDT.
- *
- * @param ydtContext YANG data tree context
- * @throws YobException if YDT walker is not using extended context walker
- */
- @Override
- public void enterYdtNode(YdtContext ydtContext) {
- throw new YobException(E_MISSING_DATA_IN_NODE);
- }
-
- /**
- * Does not support walking of non extended context YDT.
- *
- * @param ydtContext YANG data tree context
- * @throws YobException if YDT walker is not using extended context walker
- */
- @Override
- public void exitYdtNode(YdtContext ydtContext) {
- throw new YobException(E_MISSING_DATA_IN_NODE);
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobMultiInstanceHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobMultiInstanceHandler.java
deleted file mode 100644
index 4e9e3e5..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobMultiInstanceHandler.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-/**
- * Represents a multi instance node handler in YANG object builder.
- */
-class YobMultiInstanceHandler extends YobHandler {
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobMultiInstanceLeafHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobMultiInstanceLeafHandler.java
deleted file mode 100644
index 19c39d7..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobMultiInstanceLeafHandler.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-
-import org.onosproject.yangutils.datamodel.YangLeafList;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yangutils.datamodel.YangType;
-import org.onosproject.yangutils.datamodel.javadatamodel.JavaQualifiedTypeInfoContainer;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.yob.exception.YobException;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.util.Set;
-
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.IDENTITYREF;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
-import static org.onosproject.yms.app.ydt.AppType.YOB;
-import static org.onosproject.yms.app.yob.YobConstants.ADD_TO;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_INVOKE_METHOD;
-import static org.onosproject.yms.app.yob.YobConstants.L_FAIL_TO_INVOKE_METHOD;
-
-/**
- * Represents a multi instance leaf node handler in YANG object builder.
- */
-class YobMultiInstanceLeafHandler
- extends YobHandler {
-
- private static final Logger log =
- LoggerFactory.getLogger(YobMultiInstanceLeafHandler.class);
-
- @Override
- public void createBuilder(YdtExtendedContext curNode,
- YdtExtendedContext rootNode,
- YangSchemaRegistry registry) {
- // For multi instance leaf no need to create an object.
- }
-
- @Override
- public void buildObject(YdtExtendedContext ydtNode,
- YdtExtendedContext ydtRootNode,
- YangSchemaRegistry schemaRegistry) {
- // For multi instance leaf no need to build object.
- }
-
- /**
- * Set the leaf list values in the YANG object.
- *
- * @param leafListNode leaf list YDT node
- * @param schemaRegistry YANG schema registry
- * @throws YobException if failed to invoke the leaf list's setter
- */
- @Override
- public void setInParent(YdtExtendedContext leafListNode,
- YangSchemaRegistry schemaRegistry) {
- Class<?> parentBuilderClass = null;
- YangSchemaNode yangSchemaNode = leafListNode.getYangSchemaNode();
- while (yangSchemaNode.getReferredSchema() != null) {
- yangSchemaNode = yangSchemaNode.getReferredSchema();
- }
-
- YdtExtendedContext parentYdtNode =
- (YdtExtendedContext) leafListNode.getParent();
- YobWorkBench parentYobWorkBench =
- (YobWorkBench) parentYdtNode.getAppInfo(YOB);
- Set<String> valueSet = leafListNode.getValueSet();
-
- for (String value : valueSet) {
- try {
- String setterInParent = yangSchemaNode.getJavaAttributeName();
- Object builderObject = parentYobWorkBench
- .getParentBuilder(leafListNode, schemaRegistry);
- parentBuilderClass = builderObject.getClass();
- Field leafName = parentBuilderClass
- .getDeclaredField(setterInParent);
- ParameterizedType genericListType =
- (ParameterizedType) leafName.getGenericType();
- Class<?> genericListClass;
- if (((YangLeafList) leafListNode.getYangSchemaNode())
- .getDataType().getDataType() == IDENTITYREF) {
- ParameterizedType type = (ParameterizedType)
- genericListType.getActualTypeArguments()[0];
- genericListClass = type.getClass().getClass();
- } else {
- genericListClass = (Class<?>) genericListType.getActualTypeArguments()[0];
- }
-
- Method setterMethod = parentBuilderClass.getDeclaredMethod(
- ADD_TO + getCapitalCase(setterInParent), genericListClass);
-
- JavaQualifiedTypeInfoContainer javaQualifiedType =
- (JavaQualifiedTypeInfoContainer) yangSchemaNode;
- YangType<?> yangType =
- ((YangLeafList) javaQualifiedType).getDataType();
- YobUtils.setDataFromStringValue(yangType.getDataType(), value,
- setterMethod,
- builderObject, leafListNode);
- } catch (NoSuchMethodException | InvocationTargetException
- | IllegalAccessException | NoSuchFieldException e) {
- log.error(L_FAIL_TO_INVOKE_METHOD,
- parentBuilderClass.getName());
- throw new YobException(E_FAIL_TO_INVOKE_METHOD +
- parentBuilderClass.getName());
- }
- }
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobSingleInstanceHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobSingleInstanceHandler.java
deleted file mode 100644
index eaa098d..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobSingleInstanceHandler.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-/**
- * Represents a single instance node handler in YANG object builder.
- */
-class YobSingleInstanceHandler extends YobHandler {
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobSingleInstanceLeafHandler.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobSingleInstanceLeafHandler.java
deleted file mode 100644
index bf323ba..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobSingleInstanceLeafHandler.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.onosproject.yangutils.datamodel.YangLeaf;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yangutils.datamodel.YangType;
-import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.yob.exception.YobException;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import static org.onosproject.yms.app.ydt.AppType.YOB;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_INVOKE_METHOD;
-import static org.onosproject.yms.app.yob.YobConstants.L_FAIL_TO_INVOKE_METHOD;
-
-/**
- * Represents a single instance leaf node handler in YANG object builder.
- */
-class YobSingleInstanceLeafHandler extends YobHandler {
-
- private static final Logger log =
- LoggerFactory.getLogger(YobSingleInstanceLeafHandler.class);
-
- @Override
- public void createBuilder(YdtExtendedContext curNode,
- YdtExtendedContext rootNode,
- YangSchemaRegistry registry) {
- // For single instance leaf no need to create an object.
- }
-
- @Override
- public void buildObject(YdtExtendedContext ydtNode,
- YdtExtendedContext ydtRootNode,
- YangSchemaRegistry schemaRegistry) {
- // For single instance leaf no need to build an object.
- }
-
- /**
- * Set the leaf's value in the YANG object.
- *
- * @param leafNode leaf YDT node
- * @param schemaRegistry YANG schema registry
- * @throws YobException if failed to invoke the leaf's setter
- */
- @Override
- public void setInParent(YdtExtendedContext leafNode,
- YangSchemaRegistry schemaRegistry) {
- Class<?> builderClass = null;
-
- try {
- YangSchemaNode schemaNode = leafNode.getYangSchemaNode();
- while (schemaNode.getReferredSchema() != null) {
- schemaNode = schemaNode.getReferredSchema();
- }
-
- String setterInParent = schemaNode.getJavaAttributeName();
- YdtExtendedContext parentNode =
- (YdtExtendedContext) leafNode.getParent();
- YobWorkBench workBench = (YobWorkBench) parentNode.getAppInfo(YOB);
- Object builderObject = workBench
- .getParentBuilder(leafNode, schemaRegistry);
- builderClass = builderObject.getClass();
- if (leafNode.getValue() != null || ((YangLeaf) schemaNode)
- .getDataType().getDataType() == YangDataTypes.EMPTY) {
- Field leafName = builderClass.getDeclaredField(setterInParent);
- Method setterMethod = builderClass
- .getDeclaredMethod(setterInParent, leafName.getType());
- YangType<?> yangType = ((YangLeaf) schemaNode).getDataType();
- YobUtils.setDataFromStringValue(yangType.getDataType(), leafNode
- .getValue(),
- setterMethod, builderObject,
- leafNode);
- } else {
- YobUtils.setSelectLeaf(builderClass, leafNode,
- schemaRegistry, builderObject);
- }
- } catch (NoSuchMethodException | InvocationTargetException |
- IllegalAccessException | NoSuchFieldException e) {
- log.error(L_FAIL_TO_INVOKE_METHOD, builderClass.getName());
- throw new YobException(E_FAIL_TO_INVOKE_METHOD +
- builderClass.getName());
- }
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobUtils.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobUtils.java
deleted file mode 100644
index eff2f28..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobUtils.java
+++ /dev/null
@@ -1,785 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.onosproject.yangutils.datamodel.RpcNotificationContainer;
-import org.onosproject.yangutils.datamodel.YangDerivedInfo;
-import org.onosproject.yangutils.datamodel.YangIdentity;
-import org.onosproject.yangutils.datamodel.YangIdentityRef;
-import org.onosproject.yangutils.datamodel.YangLeaf;
-import org.onosproject.yangutils.datamodel.YangLeafList;
-import org.onosproject.yangutils.datamodel.YangLeafRef;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeContextInfo;
-import org.onosproject.yangutils.datamodel.YangType;
-import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.yob.exception.YobException;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Base64;
-
-import static org.onosproject.yangutils.datamodel.YangSchemaNodeType.YANG_AUGMENT_NODE;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getEnumJavaAttribute;
-import static org.onosproject.yms.app.ydt.AppType.YOB;
-import static org.onosproject.yms.app.yob.YobConstants.DEFAULT;
-import static org.onosproject.yms.app.yob.YobConstants.EVENT;
-import static org.onosproject.yms.app.yob.YobConstants.EVENT_SUBJECT;
-import static org.onosproject.yms.app.yob.YobConstants.E_DATA_TYPE_NOT_SUPPORT;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_CREATE_OBJ;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_GET_FIELD;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_GET_METHOD;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_INVOKE_METHOD;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_LOAD_CLASS;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_LOAD_CONSTRUCTOR;
-import static org.onosproject.yms.app.yob.YobConstants.E_INVALID_DATA_TREE;
-import static org.onosproject.yms.app.yob.YobConstants.E_INVALID_EMPTY_DATA;
-import static org.onosproject.yms.app.yob.YobConstants.FROM_STRING;
-import static org.onosproject.yms.app.yob.YobConstants.LEAF_IDENTIFIER;
-import static org.onosproject.yms.app.yob.YobConstants.L_FAIL_TO_GET_FIELD;
-import static org.onosproject.yms.app.yob.YobConstants.L_FAIL_TO_GET_METHOD;
-import static org.onosproject.yms.app.yob.YobConstants.L_FAIL_TO_INVOKE_METHOD;
-import static org.onosproject.yms.app.yob.YobConstants.L_FAIL_TO_LOAD_CLASS;
-import static org.onosproject.yms.app.yob.YobConstants.OF;
-import static org.onosproject.yms.app.yob.YobConstants.OP_PARAM;
-import static org.onosproject.yms.app.yob.YobConstants.PERIOD;
-import static org.onosproject.yms.app.yob.YobConstants.SELECT_LEAF;
-import static org.onosproject.yms.app.yob.YobConstants.TYPE;
-import static org.onosproject.yms.app.yob.YobConstants.VALUE_OF;
-
-/**
- * Utils to support object creation.
- */
-public final class YobUtils {
-
- private static final Logger log = LoggerFactory.getLogger(YobUtils.class);
-
- // no instantiation
- private YobUtils() {
- }
-
- /**
- * Sets data from string value in parent method.
- *
- * @param type refers to YANG type
- * @param leafValue leafValue argument is used to set the value
- * in method
- * @param parentSetterMethod Invokes the underlying method represented
- * by this parentSetterMethod
- * @param parentBuilderObject the parentBuilderObject is to invoke the
- * underlying method
- * @param ydtExtendedContext ydtExtendedContext is used to get
- * application related
- * information maintained in YDT
- * @throws InvocationTargetException if failed to invoke method
- * @throws IllegalAccessException if member cannot be accessed
- * @throws NoSuchMethodException if method is not found
- */
- static void setDataFromStringValue(YangDataTypes type, String leafValue,
- Method parentSetterMethod,
- Object parentBuilderObject,
- YdtExtendedContext ydtExtendedContext)
- throws InvocationTargetException, IllegalAccessException,
- NoSuchMethodException {
- switch (type) {
- case INT8:
- parentSetterMethod.invoke(parentBuilderObject,
- Byte.parseByte(leafValue));
- break;
-
- case UINT8:
- case INT16:
- parentSetterMethod.invoke(parentBuilderObject,
- Short.parseShort(leafValue));
- break;
-
- case UINT16:
- case INT32:
- parentSetterMethod.invoke(parentBuilderObject,
- Integer.parseInt(leafValue));
- break;
-
- case UINT32:
- case INT64:
- parentSetterMethod.invoke(parentBuilderObject,
- Long.parseLong(leafValue));
- break;
-
- case UINT64:
- parentSetterMethod.invoke(parentBuilderObject,
- new BigInteger(leafValue));
- break;
-
- case EMPTY:
- if (leafValue == null || "".equals(leafValue)) {
- parentSetterMethod.invoke(parentBuilderObject, true);
- } else {
- log.info(E_INVALID_EMPTY_DATA);
- }
- break;
-
- case BOOLEAN:
- parentSetterMethod.invoke(parentBuilderObject,
- Boolean.parseBoolean(leafValue));
- break;
-
- case STRING:
- parentSetterMethod.invoke(parentBuilderObject, leafValue);
- break;
-
- case BINARY:
- byte[] value = Base64.getDecoder().decode(leafValue);
- parentSetterMethod.invoke(parentBuilderObject, value);
- break;
-
- case BITS:
- parseBitSetTypeInfo(ydtExtendedContext, parentSetterMethod,
- parentBuilderObject, leafValue);
- break;
-
- case DECIMAL64:
- parentSetterMethod.invoke(parentBuilderObject,
- new BigDecimal(leafValue));
- break;
-
- case DERIVED:
- parseDerivedTypeInfo(ydtExtendedContext, parentSetterMethod,
- parentBuilderObject, leafValue, false);
- break;
-
- case IDENTITYREF:
- parseIdentityRefInfo(ydtExtendedContext, parentSetterMethod,
- parentBuilderObject, leafValue);
- break;
-
- case UNION:
- parseDerivedTypeInfo(ydtExtendedContext, parentSetterMethod,
- parentBuilderObject, leafValue, false);
- break;
-
- case LEAFREF:
- parseLeafRefTypeInfo(ydtExtendedContext, parentSetterMethod,
- parentBuilderObject, leafValue);
- break;
-
- case ENUMERATION:
- parseDerivedTypeInfo(ydtExtendedContext, parentSetterMethod,
- parentBuilderObject, leafValue, true);
- break;
-
- default:
- log.error(E_DATA_TYPE_NOT_SUPPORT);
- }
- }
-
- /**
- * Sets the select leaf flag for leaf.
- *
- * @param builderClass builder in which the select leaf flag needs to be
- * set
- * @param leafNode YANG data tree leaf node
- * @param schemaRegistry YANG schema registry
- * @param builderObject the parent build object on which to invoke
- * the method
- * @throws InvocationTargetException if method could not be invoked
- * @throws IllegalAccessException if method could not be accessed
- * @throws NoSuchMethodException if method does not exist
- */
- static void setSelectLeaf(Class builderClass,
- YdtExtendedContext leafNode,
- YangSchemaRegistry schemaRegistry,
- Object builderObject) throws NoSuchMethodException,
- InvocationTargetException, IllegalAccessException {
-
- YangSchemaNode parentSchema = ((YdtExtendedContext) leafNode
- .getParent()).getYangSchemaNode();
- while (parentSchema.getReferredSchema() != null) {
- parentSchema = parentSchema.getReferredSchema();
- }
-
- while (((YangNode) parentSchema).getParent() != null) {
- parentSchema = ((YangNode) parentSchema).getParent();
- }
-
- String qualName = getQualifiedinterface(parentSchema);
- Class<?> regClass = schemaRegistry.getRegisteredClass(parentSchema);
- if (regClass == null) {
- throw new YobException(E_FAIL_TO_LOAD_CLASS + qualName);
- }
-
- Class<?> interfaceClass = null;
- try {
- interfaceClass = regClass.getClassLoader().loadClass(qualName);
- } catch (ClassNotFoundException e) {
- log.info(E_FAIL_TO_LOAD_CLASS, qualName);
- return;
- }
-
- Class<?>[] innerClasses = interfaceClass.getClasses();
- for (Class<?> innerEnumClass : innerClasses) {
- if (innerEnumClass.getSimpleName().equals(LEAF_IDENTIFIER)) {
- Method valueOfMethod = innerEnumClass
- .getDeclaredMethod(VALUE_OF, String.class);
- String leafName = leafNode.getYangSchemaNode()
- .getJavaAttributeName().toUpperCase();
- Object obj = valueOfMethod.invoke(null, leafName);
- Method selectLeafMethod = builderClass
- .getDeclaredMethod(SELECT_LEAF, innerEnumClass);
- selectLeafMethod.invoke(builderObject, obj);
- break;
- }
- }
- }
-
- /**
- * To set data into parent setter method from string value for derived type.
- *
- * @param leafValue value to be set in method
- * @param parentSetterMethod the parent setter method to be invoked
- * @param parentBuilderObject the parent build object on which to invoke the
- * method
- * @param ydtExtendedContext application context
- * @param isEnum flag to check whether type is enum or derived
- * @throws InvocationTargetException if failed to invoke method
- * @throws IllegalAccessException if member cannot be accessed
- * @throws NoSuchMethodException if the required method is not found
- */
- private static void parseDerivedTypeInfo(YdtExtendedContext ydtExtendedContext,
- Method parentSetterMethod,
- Object parentBuilderObject,
- String leafValue, boolean isEnum)
- throws InvocationTargetException, IllegalAccessException,
- NoSuchMethodException {
- Class<?> childSetClass = null;
- Constructor<?> childConstructor = null;
- Object childValue = null;
- Object childObject = null;
- Method childMethod = null;
-
- YangSchemaNode yangJavaModule = ydtExtendedContext.getYangSchemaNode();
- while (yangJavaModule.getReferredSchema() != null) {
- yangJavaModule = yangJavaModule.getReferredSchema();
- }
-
- String qualifiedClassName = yangJavaModule.getJavaPackage() + PERIOD +
- getCapitalCase(yangJavaModule.getJavaClassNameOrBuiltInType());
- ClassLoader classLoader = getClassLoader(null, qualifiedClassName,
- ydtExtendedContext, null);
- try {
- childSetClass = classLoader.loadClass(qualifiedClassName);
- } catch (ClassNotFoundException e) {
- log.error(L_FAIL_TO_LOAD_CLASS, qualifiedClassName);
- }
-
- if (!isEnum) {
- if (childSetClass != null) {
- childConstructor = childSetClass.getDeclaredConstructor();
- }
-
- if (childConstructor != null) {
- childConstructor.setAccessible(true);
- }
-
- try {
- if (childConstructor != null) {
- childObject = childConstructor.newInstance();
- }
- } catch (InstantiationException e) {
- log.error(E_FAIL_TO_LOAD_CONSTRUCTOR, qualifiedClassName);
- }
- if (childSetClass != null) {
- childMethod = childSetClass
- .getDeclaredMethod(FROM_STRING, String.class);
- }
- } else {
- if (childSetClass != null) {
- childMethod = childSetClass.getDeclaredMethod(OF, String.class);
- }
- }
- if (childMethod != null) {
- childValue = childMethod.invoke(childObject, leafValue);
- }
-
- parentSetterMethod.invoke(parentBuilderObject, childValue);
- }
-
- /**
- * To set data into parent setter method from string value for bits type.
- *
- * @param leafValue value to be set in method
- * @param parentSetterMethod the parent setter method to be invoked
- * @param parentBuilderObject the parent build object on which to invoke the
- * method
- * @param ydtExtendedContext application context
- * @throws InvocationTargetException if failed to invoke method
- * @throws IllegalAccessException if member cannot be accessed
- * @throws NoSuchMethodException if the required method is not found
- */
- private static void parseBitSetTypeInfo(YdtExtendedContext ydtExtendedContext,
- Method parentSetterMethod,
- Object parentBuilderObject,
- String leafValue)
- throws InvocationTargetException, IllegalAccessException,
- NoSuchMethodException {
- Class<?> childSetClass = null;
- Object childValue = null;
- Object childObject = null;
- Method childMethod = null;
-
- YangSchemaNode schemaNode = ydtExtendedContext.getYangSchemaNode();
- while (schemaNode.getReferredSchema() != null) {
- schemaNode = schemaNode.getReferredSchema();
- }
-
- YangSchemaNode parentSchema = ((YdtExtendedContext) ydtExtendedContext
- .getParent()).getYangSchemaNode();
- String qualifiedClassName = parentSchema.getJavaPackage() + PERIOD +
- parentSchema.getJavaAttributeName().toLowerCase() +
- PERIOD + getCapitalCase(schemaNode.getJavaAttributeName());
-
- ClassLoader classLoader = getClassLoader(null, qualifiedClassName,
- ydtExtendedContext, null);
-
- try {
- childSetClass = classLoader.loadClass(qualifiedClassName);
- } catch (ClassNotFoundException e) {
- log.error(L_FAIL_TO_LOAD_CLASS, qualifiedClassName);
- }
-
- if (childSetClass != null) {
- childMethod = childSetClass.getDeclaredMethod(FROM_STRING, String.class);
- }
- if (childMethod != null) {
- childValue = childMethod.invoke(childObject, leafValue);
- }
-
- parentSetterMethod.invoke(parentBuilderObject, childValue);
- }
-
- /**
- * To set data into parent setter method from string value for leafref type.
- *
- * @param leafValue leaf value to be set
- * @param parentSetterMethod the parent setter method to be invoked
- * @param parentBuilderObject the parent build object on which to invoke
- * the method
- * @param ydtExtendedContext application context
- * @throws InvocationTargetException if method could not be invoked
- * @throws IllegalAccessException if method could not be accessed
- * @throws NoSuchMethodException if method does not exist
- */
- private static void parseLeafRefTypeInfo(YdtExtendedContext ydtExtendedContext,
- Method parentSetterMethod,
- Object parentBuilderObject,
- String leafValue)
- throws InvocationTargetException, IllegalAccessException,
- NoSuchMethodException {
-
- YangSchemaNode schemaNode = ydtExtendedContext.getYangSchemaNode();
- while (schemaNode.getReferredSchema() != null) {
- schemaNode = schemaNode.getReferredSchema();
- }
-
- YangLeafRef leafRef;
- if (schemaNode instanceof YangLeaf) {
- leafRef = (YangLeafRef) ((YangLeaf) schemaNode)
- .getDataType().getDataTypeExtendedInfo();
- } else {
- leafRef = (YangLeafRef) ((YangLeafList) schemaNode)
- .getDataType().getDataTypeExtendedInfo();
- }
-
- YangType type = leafRef.getEffectiveDataType();
- if (type.getDataType() == YangDataTypes.DERIVED &&
- schemaNode.getJavaPackage().equals(YobConstants.JAVA_LANG)) {
- /*
- * If leaf is inside grouping, then its return type will be of type
- * Object and if its actual type is derived type then get the
- * effective built-in type and set the value.
- */
- YangDerivedInfo derivedInfo = (YangDerivedInfo) leafRef
- .getEffectiveDataType()
- .getDataTypeExtendedInfo();
- YobUtils.setDataFromStringValue(derivedInfo.getEffectiveBuiltInType(),
- leafValue, parentSetterMethod,
- parentBuilderObject,
- ydtExtendedContext);
- } else {
- YobUtils.setDataFromStringValue(type.getDataType(),
- leafValue, parentSetterMethod,
- parentBuilderObject,
- ydtExtendedContext);
- }
- }
-
- /**
- * Updates class loader for all the classes.
- *
- * @param registry YANG schema registry
- * @param qualifiedClassName qualified class name
- * @param curNode YDT context
- * @param rootNode application root node
- * @return current class loader
- */
- static ClassLoader getClassLoader(YangSchemaRegistry registry,
- String qualifiedClassName,
- YdtExtendedContext curNode,
- YdtExtendedContext rootNode) {
-
- if (rootNode != null && curNode == rootNode) {
- YangSchemaNode curSchemaNode = curNode.getYangSchemaNode();
- while (!(curSchemaNode instanceof RpcNotificationContainer)) {
- curNode = (YdtExtendedContext) curNode.getParent();
- if (curNode == null) {
- throw new YobException(E_INVALID_DATA_TREE);
- }
- curSchemaNode = curNode.getYangSchemaNode();
- }
-
- Class<?> regClass = registry.getRegisteredClass(curSchemaNode);
- return regClass.getClassLoader();
- }
-
- YdtExtendedContext parent = (YdtExtendedContext) curNode.getParent();
- YobWorkBench parentBuilderContainer = (YobWorkBench) parent.getAppInfo(YOB);
- Object parentObj = parentBuilderContainer.getParentBuilder(curNode,
- registry);
- return parentObj.getClass().getClassLoader();
- }
-
- /**
- * Returns the class loader to be used for the switched context schema node.
- *
- * @param curLoader current context class loader
- * @param context switched context
- * @param registry schema registry
- * @return class loader to be used for the switched context schema node
- */
- static ClassLoader getTargetClassLoader(ClassLoader curLoader,
- YangSchemaNodeContextInfo context,
- YangSchemaRegistry registry) {
- YangSchemaNode augmentSchemaNode = context.getContextSwitchedNode();
- if (augmentSchemaNode.getYangSchemaNodeType() == YANG_AUGMENT_NODE) {
- YangSchemaNode moduleNode = ((YangNode) augmentSchemaNode).getParent();
-
- Class<?> moduleClass = registry.getRegisteredClass(moduleNode);
- if (moduleClass == null) {
- throw new YobException(E_FAIL_TO_LOAD_CLASS + moduleNode
- .getJavaClassNameOrBuiltInType());
- }
- return moduleClass.getClassLoader();
- }
- return curLoader;
- }
-
- /**
- * Returns the schema node's module interface.
- *
- * @param schemaNode YANG schema node
- * @param schemaRegistry YANG schema registry
- * @return schema node's module interface
- */
- public static Class<?> getModuleInterface(YangSchemaNode schemaNode,
- YangSchemaRegistry schemaRegistry) {
-
- YangNode yangNode = (YangNode) schemaNode;
- while (yangNode.getReferredSchema() != null) {
- yangNode = (YangNode) yangNode.getReferredSchema();
- }
-
- while (yangNode.getParent() != null) {
- yangNode = yangNode.getParent();
- }
-
- String qualName = getQualifiedinterface(yangNode);
- Class<?> regClass = schemaRegistry.getRegisteredClass(yangNode);
- if (regClass == null) {
- throw new YobException(E_FAIL_TO_LOAD_CLASS + qualName);
- }
-
- try {
- return regClass.getClassLoader().loadClass(qualName);
- } catch (ClassNotFoundException e) {
- log.error(L_FAIL_TO_LOAD_CLASS, qualName);
- }
-
- return null;
- }
-
- /**
- * Returns the qualified default / op param class.
- *
- * @param schemaNode schema node of the required class
- * @return qualified default / op param class name
- */
- static String getQualifiedDefaultClass(YangSchemaNode schemaNode) {
- String packageName = schemaNode.getJavaPackage();
- String className = getCapitalCase(
- schemaNode.getJavaClassNameOrBuiltInType());
-
- if (schemaNode instanceof RpcNotificationContainer) {
- return packageName + PERIOD + className + OP_PARAM;
- }
-
- return packageName + PERIOD + DEFAULT + className;
- }
-
- /**
- * Returns the qualified interface name.
- *
- * @param schemaNode schema node of the required class
- * @return qualified interface name
- */
- static String getQualifiedinterface(YangSchemaNode schemaNode) {
- String packageName = schemaNode.getJavaPackage();
- String className = getCapitalCase(
- schemaNode.getJavaClassNameOrBuiltInType());
-
- return packageName + PERIOD + className;
- }
-
- /**
- * Returns the capital cased first letter of the given string.
- *
- * @param name string to be capital cased
- * @return capital cased string
- */
- public static String getCapitalCase(String name) {
- // TODO: It will be removed if common util is committed.
- return name.substring(0, 1).toUpperCase() +
- name.substring(1);
- }
-
- /**
- * To set data into parent setter method from string value for identity ref.
- *
- * @param leafValue leaf value to be set
- * @param parentSetterMethod the parent setter method to be invoked
- * @param parentBuilderObject the parent build object on which to invoke
- * the method
- * @param ydtExtendedContext application context
- * @throws InvocationTargetException if method could not be invoked
- * @throws IllegalAccessException if method could not be accessed
- * @throws NoSuchMethodException if method does not exist
- */
- private static void parseIdentityRefInfo(YdtExtendedContext
- ydtExtendedContext,
- Method parentSetterMethod,
- Object parentBuilderObject,
- String leafValue)
- throws InvocationTargetException, IllegalAccessException,
- NoSuchMethodException {
- Class<?> childSetClass = null;
- Object childValue = null;
- Method childMethod = null;
-
- YangSchemaNode yangJavaModule = ydtExtendedContext.getYangSchemaNode();
- while (yangJavaModule.getReferredSchema() != null) {
- yangJavaModule = yangJavaModule.getReferredSchema();
- }
-
- String qualifiedClassName = null;
- YangType type;
- if (yangJavaModule instanceof YangLeaf) {
- type = ((YangLeaf) yangJavaModule).getDataType();
- } else {
- type = ((YangLeafList) yangJavaModule).getDataType();
- }
-
- if (type.getDataType() == YangDataTypes.LEAFREF && yangJavaModule
- .getJavaPackage().equals(YobConstants.JAVA_LANG)) {
- YangLeafRef leafref = ((YangLeafRef) type.getDataTypeExtendedInfo());
- YangType effectiveType = leafref.getEffectiveDataType();
- if (effectiveType.getDataType() == YangDataTypes.IDENTITYREF) {
- YangIdentityRef identityref = ((YangIdentityRef) effectiveType
- .getDataTypeExtendedInfo());
- YangIdentity identity = identityref.getReferredIdentity();
- qualifiedClassName = identity.getJavaPackage() + PERIOD +
- getCapitalCase(identity.getJavaClassNameOrBuiltInType());
- }
- } else {
- qualifiedClassName = yangJavaModule.getJavaPackage() + PERIOD +
- getCapitalCase(yangJavaModule.getJavaClassNameOrBuiltInType());
- }
-
- ClassLoader classLoader = getClassLoader(null, qualifiedClassName,
- ydtExtendedContext, null);
- try {
- childSetClass = classLoader.loadClass(qualifiedClassName);
- } catch (ClassNotFoundException e) {
- log.error(L_FAIL_TO_LOAD_CLASS, qualifiedClassName);
- }
-
- if (childSetClass != null) {
- childMethod = childSetClass
- .getDeclaredMethod(FROM_STRING, String.class);
- }
-
- if (childMethod != null) {
- childValue = childMethod.invoke(null, leafValue);
- }
-
- parentSetterMethod.invoke(parentBuilderObject, childValue);
- }
-
- /**
- * Creates and sets default notification object in event subject object.
- *
- * @param defaultObj default notification object
- * @param curNode application context
- * @param registry YANG schema registry
- * @return notification event subject object
- */
- public static Object createAndSetInEventSubjectInstance(Object defaultObj,
- YdtExtendedContext curNode,
- YangSchemaRegistry registry) {
- YangSchemaNode childSchema = ((YdtExtendedContext) curNode
- .getFirstChild()).getYangSchemaNode();
- String packageName = childSchema.getJavaPackage();
- String className = getCapitalCase(curNode.getYangSchemaNode()
- .getJavaClassNameOrBuiltInType());
- String qualName = packageName + PERIOD + className + EVENT_SUBJECT;
-
- ClassLoader classLoader = YobUtils.getClassLoader(registry, qualName,
- curNode, curNode);
-
- Object eventSubObj;
- Class<?> eventSubjectClass = null;
- try {
- eventSubjectClass = classLoader.loadClass(qualName);
- eventSubObj = eventSubjectClass.newInstance();
- } catch (ClassNotFoundException e) {
- log.error(E_FAIL_TO_LOAD_CLASS, className);
- throw new YobException(E_FAIL_TO_LOAD_CLASS +
- qualName);
- } catch (InstantiationException e) {
- log.error(E_FAIL_TO_CREATE_OBJ, className);
- throw new YobException(E_FAIL_TO_CREATE_OBJ +
- eventSubjectClass.getName());
- } catch (IllegalAccessException e) {
- log.error(L_FAIL_TO_INVOKE_METHOD, className);
- throw new YobException(E_FAIL_TO_INVOKE_METHOD +
- eventSubjectClass.getName());
- }
-
- setInEventSubject(((YdtExtendedContext) curNode.getFirstChild()),
- eventSubObj, defaultObj);
- return eventSubObj;
- }
-
- /**
- * Sets the default notification object in event subject class.
- *
- * @param ydtNode application context
- * @param eventSubObj notification event subject instance
- * @param defaultObj default notification instance
- */
- public static void setInEventSubject(YdtExtendedContext ydtNode,
- Object eventSubObj,
- Object defaultObj) {
-
- Class<?> eventSubjectClass = eventSubObj.getClass();
- String className = eventSubjectClass.getName();
- String setter = ydtNode.getYangSchemaNode().getJavaAttributeName();
-
- try {
- Class<?> type = null;
- Field fieldName = eventSubjectClass.getDeclaredField(setter);
- if (fieldName != null) {
- type = fieldName.getType();
- }
-
- Method method;
- method = eventSubjectClass.getDeclaredMethod(setter, type);
- method.invoke(eventSubObj, defaultObj);
- } catch (NoSuchFieldException e) {
- log.error(L_FAIL_TO_GET_FIELD, className);
- throw new YobException(E_FAIL_TO_GET_FIELD + className);
- } catch (NoSuchMethodException e) {
- log.error(L_FAIL_TO_GET_METHOD, className);
- throw new YobException(E_FAIL_TO_GET_METHOD + className);
- } catch (InvocationTargetException | IllegalAccessException e) {
- log.error(L_FAIL_TO_INVOKE_METHOD, className);
- throw new YobException(E_FAIL_TO_INVOKE_METHOD + className);
- }
- }
-
- /**
- * Creates an object of notification event class and sets event subject
- * in event class.
- *
- * @param eventSubObj instance of event subject class
- * @param curNode current YDT node
- * @param registry YANG schema registry
- * @return notification event object
- */
- public static Object createAndSetInEventInstance(Object eventSubObj,
- YdtExtendedContext curNode,
- YangSchemaRegistry registry) {
- YangSchemaNode childSchema = ((YdtExtendedContext) curNode
- .getFirstChild()).getYangSchemaNode();
- String packageName = childSchema.getJavaPackage();
- String className = getCapitalCase(curNode.getYangSchemaNode()
- .getJavaClassNameOrBuiltInType());
- String qualName = packageName + PERIOD + className + EVENT;
-
- try {
- ClassLoader classLoader = YobUtils.getClassLoader(registry, qualName,
- curNode, curNode);
- Class<?> eventClass = classLoader.loadClass(qualName);
- Class<?>[] innerClasses = eventClass.getClasses();
- Object typeObj = null;
- for (Class<?> innerEnumClass : innerClasses) {
- if (innerEnumClass.getSimpleName().equals(TYPE)) {
- Method valueOfMethod = innerEnumClass
- .getDeclaredMethod(VALUE_OF, String.class);
- String eventType = getEnumJavaAttribute(childSchema.getName())
- .toUpperCase();
- typeObj = valueOfMethod.invoke(null, eventType);
- break;
- }
- }
-
- Constructor constructor = eventClass
- .getDeclaredConstructor(typeObj.getClass(),
- eventSubObj.getClass());
- constructor.setAccessible(true);
- return constructor.newInstance(typeObj, eventSubObj);
- } catch (ClassNotFoundException e) {
- log.error(L_FAIL_TO_INVOKE_METHOD, className);
- throw new YobException(E_FAIL_TO_INVOKE_METHOD + className);
- } catch (InstantiationException e) {
- log.error(E_FAIL_TO_CREATE_OBJ, className);
- throw new YobException(E_FAIL_TO_CREATE_OBJ + className);
- } catch (NoSuchMethodException e) {
- log.error(L_FAIL_TO_GET_METHOD, className);
- throw new YobException(E_FAIL_TO_GET_METHOD + className);
- } catch (InvocationTargetException | IllegalAccessException e) {
- log.error(L_FAIL_TO_INVOKE_METHOD, className);
- throw new YobException(E_FAIL_TO_INVOKE_METHOD + className);
- }
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobWorkBench.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobWorkBench.java
deleted file mode 100644
index 36ce736..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/YobWorkBench.java
+++ /dev/null
@@ -1,463 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeContextInfo;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
-import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.yob.exception.YobException;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-import org.onosproject.yms.ydt.YdtType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.onosproject.yangutils.datamodel.YangSchemaNodeType.YANG_AUGMENT_NODE;
-import static org.onosproject.yangutils.datamodel.YangSchemaNodeType.YANG_CHOICE_NODE;
-import static org.onosproject.yms.app.ydt.AppType.YOB;
-import static org.onosproject.yms.app.yob.YobConstants.ADD_AUGMENT_METHOD;
-import static org.onosproject.yms.app.yob.YobConstants.ADD_TO;
-import static org.onosproject.yms.app.yob.YobConstants.BUILD;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_BUILD;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_GET_FIELD;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_GET_METHOD;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_INVOKE_METHOD;
-import static org.onosproject.yms.app.yob.YobConstants.E_FAIL_TO_LOAD_CLASS;
-import static org.onosproject.yms.app.yob.YobConstants.E_HAS_NO_CHILD;
-import static org.onosproject.yms.app.yob.YobConstants.E_SET_OP_TYPE_FAIL;
-import static org.onosproject.yms.app.yob.YobConstants.L_FAIL_TO_BUILD;
-import static org.onosproject.yms.app.yob.YobConstants.L_FAIL_TO_GET_FIELD;
-import static org.onosproject.yms.app.yob.YobConstants.L_FAIL_TO_GET_METHOD;
-import static org.onosproject.yms.app.yob.YobConstants.L_FAIL_TO_INVOKE_METHOD;
-import static org.onosproject.yms.app.yob.YobConstants.ONOS_YANG_OP_TYPE;
-import static org.onosproject.yms.app.yob.YobConstants.OP_TYPE;
-import static org.onosproject.yms.app.yob.YobConstants.VALUE_OF;
-import static org.onosproject.yms.app.yob.YobConstants.YANG;
-import static org.onosproject.yms.app.yob.YobUtils.getCapitalCase;
-import static org.onosproject.yms.app.yob.YobUtils.getModuleInterface;
-import static org.onosproject.yms.app.yob.YobUtils.getQualifiedDefaultClass;
-import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_NODE;
-import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_NODE;
-
-/**
- * Represents the YANG object builder's work bench corresponding to a YANG data
- * tree node.
- */
-class YobWorkBench {
-
- private static final Logger log =
- LoggerFactory.getLogger(YobWorkBench.class);
-
- /**
- * Class loader to be used to load the class.
- */
- private ClassLoader classLoader;
-
- /**
- * Map of the non schema descendant objects.
- */
- private Map<YangSchemaNodeIdentifier, YobWorkBench> attributeMap =
- new HashMap<>();
-
- /**
- * Reference for data-model schema node.
- */
- private YangSchemaNode yangSchemaNode;
-
- /**
- * builder object or the built object corresponding to the current schema
- * node.
- */
- private YobBuilderOrBuiltObject builderOrBuiltObject;
-
- /**
- * Setter method to be used in parent builder.
- */
- private String setterInParent;
-
- /**
- * Returns the builder container with the mapping schema being initialized.
- *
- * @param yangSchemaNode mapping schema node
- * @param classLoader class loader
- * @param qualifiedClassName qualified class name
- * @param setterInParent setter method in parent
- */
- YobWorkBench(YangSchemaNode yangSchemaNode, ClassLoader classLoader,
- String qualifiedClassName, String setterInParent) {
- this.yangSchemaNode = yangSchemaNode;
- this.classLoader = classLoader;
- this.setterInParent = setterInParent;
- this.builderOrBuiltObject =
- new YobBuilderOrBuiltObject(qualifiedClassName, classLoader);
- }
-
- /**
- * Set the attribute in a builder object.
- *
- * @param builder builder object in which the attribute needs to be set
- * @param setter setter method in parent
- * @param nodeType type of node to set
- * @param attribute attribute to set in the builder
- */
- private static void setObjectInBuilder(Object builder, String setter,
- YdtType nodeType, Object attribute) {
- Class<?> builderClass = builder.getClass();
- String builderClassName = builderClass.getName();
- try {
- Class<?> type = null;
- Field fieldName = builderClass.getDeclaredField(setter);
- if (fieldName != null) {
- type = fieldName.getType();
- }
-
- Method method;
- if (nodeType == MULTI_INSTANCE_NODE) {
- if (fieldName != null) {
- ParameterizedType genericTypes =
- (ParameterizedType) fieldName.getGenericType();
- type = (Class<?>) genericTypes.getActualTypeArguments()[0];
- }
- method = builderClass.getDeclaredMethod(
- ADD_TO + getCapitalCase(setter), type);
- } else {
- method = builderClass.getDeclaredMethod(setter, type);
- }
-
- method.invoke(builder, attribute);
- } catch (NoSuchFieldException e) {
- log.error(L_FAIL_TO_GET_FIELD, builderClassName);
- throw new YobException(E_FAIL_TO_GET_FIELD + builderClassName);
- } catch (NoSuchMethodException e) {
- log.error(L_FAIL_TO_GET_METHOD, builderClassName);
- throw new YobException(E_FAIL_TO_GET_METHOD + builderClassName);
- } catch (InvocationTargetException | IllegalAccessException e) {
- log.error(L_FAIL_TO_INVOKE_METHOD, builderClassName);
- throw new YobException(E_FAIL_TO_INVOKE_METHOD + builderClassName);
- }
- }
-
- private static void addInAugmentation(Object builder, String className,
- Object instance) {
- Class<?>[] interfaces = instance.getClass().getInterfaces();
- if (interfaces == null) {
- throw new YobException(E_FAIL_TO_LOAD_CLASS + className);
- }
-
- int i;
- for (i = 0; i < interfaces.length; i++) {
- if (interfaces[i].getName().equals(className)) {
- break;
- }
- }
- if (i == interfaces.length) {
- throw new YobException(E_FAIL_TO_LOAD_CLASS + className);
- }
-
- Class<?> builderClass = builder.getClass();
- String builderClassName = builderClass.getName();
- try {
-
- Method method = builderClass.getDeclaredMethod(ADD_AUGMENT_METHOD,
- Object.class,
- Class.class);
- method.invoke(builder, instance, interfaces[i]);
- } catch (NoSuchMethodException e) {
- log.error(L_FAIL_TO_GET_METHOD, builderClassName);
- throw new YobException(E_FAIL_TO_GET_METHOD + builderClassName);
- } catch (InvocationTargetException | IllegalAccessException e) {
- log.error(L_FAIL_TO_INVOKE_METHOD, builderClassName);
- throw new YobException(E_FAIL_TO_INVOKE_METHOD + builderClassName);
- }
-
- }
-
- /**
- * Creates a new builder container object corresponding to a context
- * switch schema node.
- *
- * @param childContext schema context of immediate child
- * @param targetNode final node whose parent builder is
- * required
- * @param curWorkBench current context builder container
- * @param registry schema registry
- * @return new builder container object corresponding to a context
- * switch schema node
- */
- private static YobWorkBench getNewChildWorkBench(
- YangSchemaNodeContextInfo childContext,
- YangSchemaNodeIdentifier targetNode, YobWorkBench curWorkBench,
- YangSchemaRegistry registry) {
-
- YangSchemaNode ctxSwitchedNode = childContext.getContextSwitchedNode();
- String name;
-
- /* This is the first child trying to set its object in the
- current context. */
- String setterInParent = ctxSwitchedNode.getJavaAttributeName();
-
- /* If current switched context is choice, then case class needs to be
- used. */
- if (ctxSwitchedNode.getYangSchemaNodeType() == YANG_CHOICE_NODE) {
- try {
- childContext = ctxSwitchedNode.getChildSchema(targetNode);
- ctxSwitchedNode = childContext.getContextSwitchedNode();
- name = getQualifiedDefaultClass(
- childContext.getContextSwitchedNode());
-
- } catch (DataModelException e) {
- throw new YobException(ctxSwitchedNode.getName() +
- E_HAS_NO_CHILD +
- targetNode.getName());
- }
- } else if (ctxSwitchedNode.getYangSchemaNodeType() ==
- YANG_AUGMENT_NODE) {
- name = getQualifiedDefaultClass(ctxSwitchedNode);
- setterInParent = YobUtils.getQualifiedinterface(ctxSwitchedNode);
- } else {
- name = getQualifiedDefaultClass(childContext.getSchemaNode());
- }
-
- ClassLoader newClassesLoader = YobUtils.getTargetClassLoader(
- curWorkBench.classLoader, childContext, registry);
-
- return new YobWorkBench(ctxSwitchedNode, newClassesLoader, name,
- setterInParent);
- }
-
- /**
- * Returns the builder object or the built object corresponding to the
- * current schema node.
- *
- * @return builder or built object
- */
- YobBuilderOrBuiltObject getBuilderOrBuiltObject() {
- return builderOrBuiltObject;
- }
-
- /**
- * Returns the parent builder object in which the child object can be set.
- *
- * @param node child YDT node
- * @param registry schema registry
- * @return parent builder object
- */
- Object getParentBuilder(YdtExtendedContext node,
- YangSchemaRegistry registry) {
-
- // Descendant schema node for whom the builder is required.
- YangSchemaNodeIdentifier targetNode =
- node.getYangSchemaNode().getYangSchemaNodeIdentifier();
-
- //Current builder container
- YobWorkBench curWorkBench = this;
-
- YangSchemaNode nonSchemaHolder;
- do {
-
- //Current Schema node context
- YangSchemaNodeContextInfo schemaContext;
- try {
- //Find the new schema context node.
- schemaContext = curWorkBench.yangSchemaNode
- .getChildSchema(targetNode);
-
- } catch (DataModelException e) {
- throw new YobException(yangSchemaNode.getName() +
- E_HAS_NO_CHILD +
- targetNode.getName());
- }
-
- nonSchemaHolder = schemaContext.getContextSwitchedNode();
-
- //If the descendant schema node is in switched context
- if (nonSchemaHolder != null) {
-
- YangSchemaNodeIdentifier nonSchemaIdentifier =
- nonSchemaHolder.getYangSchemaNodeIdentifier();
-
- //check if the descendant builder container is already available
- YobWorkBench childWorkBench =
- curWorkBench.attributeMap.get(nonSchemaIdentifier);
-
- if (childWorkBench == null) {
- YobWorkBench newWorkBench = getNewChildWorkBench(
- schemaContext, targetNode, curWorkBench, registry);
-
- curWorkBench.attributeMap.put(nonSchemaIdentifier,
- newWorkBench);
- curWorkBench = newWorkBench;
- } else {
- curWorkBench = childWorkBench;
- }
- }
-
- } while (nonSchemaHolder != null);
-
- return curWorkBench.builderOrBuiltObject.getBuilderObject();
- }
-
- /**
- * Set the operation type attribute and build the object from the builder
- * object, by invoking the build method.
- *
- * @param operationType data tree node
- * @param schemaRegistry YANG schema registry
- */
- void buildObject(YdtContextOperationType operationType,
- YangSchemaRegistry schemaRegistry) {
-
- buildNonSchemaAttributes(operationType, schemaRegistry);
-
- Object builderObject = builderOrBuiltObject.getBuilderObject();
- Class<?> defaultBuilderClass = builderOrBuiltObject.yangBuilderClass;
-
- //set the operation type
- setOperationType(operationType, schemaRegistry);
-
- // Invoking the build method to get built object from build method.
- try {
- Method method = defaultBuilderClass.getDeclaredMethod(BUILD);
- if (method == null) {
- log.error(L_FAIL_TO_GET_METHOD, defaultBuilderClass.getName());
- throw new YobException(E_FAIL_TO_GET_METHOD +
- defaultBuilderClass.getName());
- }
- Object builtObject = method.invoke(builderObject);
- // The built object will be maintained in ydt context and same will
- // be used while setting into parent method.
- builderOrBuiltObject.setBuiltObject(builtObject);
-
- } catch (NoSuchMethodException | InvocationTargetException |
- IllegalAccessException e) {
- log.error(L_FAIL_TO_BUILD, defaultBuilderClass.getName());
- throw new YobException(E_FAIL_TO_BUILD +
- defaultBuilderClass.getName());
- }
- }
-
- /**
- * Set the operation type in the built object from the YDT node.
- * <p>
- * It needs to be invoked only for the workbench corresponding to the
- * schema YDT nodes, non schema node without the YDT node should not
- * invoke this, as it is not applicable to it.
- *
- * @param ydtoperation schema data tree node
- * @param schemaRegistry YANG schema registry
- */
- private void setOperationType(YdtContextOperationType ydtoperation,
- YangSchemaRegistry schemaRegistry) {
-
- if (ydtoperation == null) {
- return;
- }
-
- Object builderObject = builderOrBuiltObject.getBuilderObject();
- Class<?> defaultBuilderClass = builderOrBuiltObject.yangBuilderClass;
- Class<?>[] intfClass = builderOrBuiltObject.yangDefaultClass
- .getInterfaces();
- String setterName = YANG + intfClass[0].getSimpleName() + OP_TYPE;
-
- // Setting the value into YANG node operation type from ydtContext
- // operation type.
- try {
- Class<?> interfaceClass;
- interfaceClass = getModuleInterface(yangSchemaNode,
- schemaRegistry);
- Object operationType;
- Class<?>[] innerClasses = interfaceClass.getClasses();
- for (Class<?> innerEnumClass : innerClasses) {
- if (innerEnumClass.getSimpleName().equals(ONOS_YANG_OP_TYPE)) {
- Method valueOfMethod = innerEnumClass
- .getDeclaredMethod(VALUE_OF, String.class);
- operationType = valueOfMethod.invoke(null, ydtoperation.
- toString());
- Field operationTypeField = defaultBuilderClass
- .getDeclaredField(setterName);
- operationTypeField.setAccessible(true);
- operationTypeField.set(builderObject, operationType);
- break;
- }
- }
- } catch (NoSuchMethodException |
- InvocationTargetException | IllegalAccessException |
- IllegalArgumentException e) {
- log.error(E_SET_OP_TYPE_FAIL);
- throw new YobException(E_SET_OP_TYPE_FAIL);
- } catch (NoSuchFieldException e) {
- log.error(E_SET_OP_TYPE_FAIL);
- }
- }
-
- /**
- * build the non schema objects and maintain it in the contained schema
- * node.
- *
- * @param operationType contained schema node
- * @param schemaRegistry YANG schema registry
- */
- private void buildNonSchemaAttributes(YdtContextOperationType operationType,
- YangSchemaRegistry schemaRegistry) {
- for (Map.Entry<YangSchemaNodeIdentifier, YobWorkBench> entry :
- attributeMap.entrySet()) {
- YobWorkBench childWorkBench = entry.getValue();
- childWorkBench.buildObject(operationType, schemaRegistry);
-
- if (childWorkBench.yangSchemaNode.getYangSchemaNodeType() ==
- YANG_AUGMENT_NODE) {
- addInAugmentation(builderOrBuiltObject.getBuilderObject(),
- childWorkBench.setterInParent,
- childWorkBench.getBuilderOrBuiltObject()
- .getBuiltObject());
- continue;
- }
-
- setObjectInBuilder(
- builderOrBuiltObject.getBuilderObject(),
- childWorkBench.setterInParent,
- SINGLE_INSTANCE_NODE,
- childWorkBench.getBuilderOrBuiltObject().getBuiltObject());
- }
- }
-
- /**
- * Sets the YANG built object in corresponding parent class method.
- *
- * @param childnode ydtExtendedContext is used to get application
- * related information maintained in YDT
- * @param schemaRegistry YANG schema registry
- */
- public void setObject(YdtExtendedContext childnode,
- YangSchemaRegistry schemaRegistry) {
- Object builder = getParentBuilder(childnode, schemaRegistry);
- YobWorkBench childWorkBench = (YobWorkBench) childnode.getAppInfo(YOB);
-
- setObjectInBuilder(builder, childWorkBench.setterInParent,
- childnode.getYdtType(), childWorkBench
- .builderOrBuiltObject.getBuiltObject());
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/exception/YobException.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/exception/YobException.java
deleted file mode 100644
index 8da4ff1..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/exception/YobException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob.exception;
-
-/**
- * Represents base class for exceptions in YOB operations.
- */
-public class YobException
- extends RuntimeException {
-
- private static final long serialVersionUID = 20160211L;
-
- /**
- * Creates a new YOB exception with given message.
- *
- * @param message the detail of exception in string
- */
- public YobException(String message) {
- super(message);
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/exception/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/exception/package-info.java
deleted file mode 100644
index 1f6c7fb..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/exception/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-/**
- * YANG object builder exceptions.
- */
-package org.onosproject.yms.app.yob.exception;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/package-info.java
deleted file mode 100644
index 1cd3508..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/yob/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of YANG object builder. YOB handles creation of YANG
- * modeled objects from YDT.
- */
-package org.onosproject.yms.app.yob;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ypm/YpmManager.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ypm/YpmManager.java
deleted file mode 100644
index 8e6238f..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ypm/YpmManager.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ypm;
-
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ypm.DefaultYpmNode;
-import org.onosproject.yms.ypm.YpmContext;
-import org.onosproject.yms.ypm.YpmService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Represents implementation of YANG protocol metadata manager.
- */
-@Component(immediate = true, service = YpmService.class)
-public class YpmManager implements YpmService {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
- private YpmContext rootYpmNode;
-
- @Activate
- public void activate() {
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public YpmContext getProtocolData(YdtContext rootYdtNode) {
- if (rootYdtNode == null) {
- log.debug("Input data is null. So, will not proceed.");
- return null;
- }
-
- // Iterate through YDT and search the path in YPM tree and create new YPM tree equivalent to given YDT
- // and return it.
- if (rootYpmNode == null) {
- log.debug("YPM tree has no data.");
- return null;
- }
-
- YdtContext currentYdtNode = rootYdtNode;
- YpmContext currentYpmNode = rootYpmNode;
- YpmContext rootRetYpmNode = new DefaultYpmNode(currentYdtNode.getName());
- YpmContext currRetYpmNode = rootRetYpmNode;
- while (currentYdtNode != null) {
- // Each ypm node can have children. So, create new corresponding ypm child
- // and add it to new returning ypm tree, otherwise return new ypm tree.
- YdtContext nextNode = currentYdtNode.getFirstChild();
- if (nextNode != null) {
- YpmContext ypmChild = currentYpmNode.getChild(nextNode.getName());
- if (ypmChild != null) {
- currRetYpmNode.addChild(ypmChild.getName());
- } else {
- return rootRetYpmNode;
- }
- currentYdtNode = nextNode;
- currentYpmNode = currentYpmNode.getChild(nextNode.getName());
- currRetYpmNode = currRetYpmNode.getChild(nextNode.getName());
- currRetYpmNode.setMetaData(currentYpmNode.getMetaData());
- continue;
- }
-
- // No child nodes, so walk tree
- while (currentYdtNode != null) {
- // Each ypm node can have sibling. So, create new corresponding ypm sibling node
- // and add it to new returning ypm tree, otherwise return new ypm tree.
- nextNode = currentYdtNode.getNextSibling();
- if (nextNode != null) {
- YpmContext ypmSibling = currentYpmNode.getSibling(nextNode.getName());
- if (ypmSibling != null) {
- currRetYpmNode.addSibling(ypmSibling.getName());
- } else {
- return rootRetYpmNode;
- }
- currentYdtNode = nextNode;
- currentYpmNode = currentYpmNode.getSibling(nextNode.getName());
- currRetYpmNode = currRetYpmNode.getSibling(nextNode.getName());
- currRetYpmNode.setMetaData(currentYpmNode.getMetaData());
- break;
- }
-
- // Move up
- if (currentYdtNode == rootYdtNode) {
- currentYdtNode = null;
- } else {
- currentYdtNode = currentYdtNode.getParent();
- currentYpmNode = currentYpmNode.getParent();
- currRetYpmNode = currRetYpmNode.getParent();
- }
- }
- }
-
- return rootRetYpmNode;
- }
-
- @Override
- public void setProtocolData(YdtContext rootYdtNode, Object data) {
- if (rootYdtNode == null || data == null) {
- log.debug("Input data is null. So, will not proceed.");
- return;
- }
-
- // Iterate through YDT and add each node of this path to ypm tree if it is not exists
- YdtContext currentYdtNode = rootYdtNode;
- YpmContext currentYpmNode = rootYpmNode;
- while (currentYdtNode != null) {
- // Check the ypm root node first
- if (rootYpmNode == null) {
- rootYpmNode = new DefaultYpmNode(currentYdtNode.getName());
- currentYpmNode = rootYpmNode;
- // In logical node, should not set protocol metadata
- }
-
- // Move down to first child
- YdtContext nextNode = currentYdtNode.getFirstChild();
- if (nextNode != null) {
- // Each ypm node can have sibling. So, get corresponding sibling node, otherwise create it.
- if (currentYpmNode.getChild(nextNode.getName()) == null) {
- currentYpmNode.addChild(nextNode.getName());
- }
- currentYpmNode = currentYpmNode.getChild(nextNode.getName());
- // Set/update protocol metadata
- currentYpmNode.setMetaData(data);
- currentYdtNode = nextNode;
- continue;
- }
-
- // No child nodes, so walk tree
- while (currentYdtNode != null) {
- // Move to sibling if possible.
- nextNode = currentYdtNode.getNextSibling();
- if (nextNode != null) {
- // Each ypm node can have children (sibling). So, get corresponding ypm child, otherwise create it.
- if (currentYpmNode.getSibling(nextNode.getName()) == null) {
- currentYpmNode.addSibling(nextNode.getName());
- }
- currentYpmNode = currentYpmNode.getSibling(nextNode.getName());
- // Set/update protocol metadata
- currentYpmNode.setMetaData(data);
- currentYdtNode = nextNode;
- break;
- }
-
- // Move up
- if (currentYdtNode == rootYdtNode) {
- currentYdtNode = null;
- } else {
- currentYdtNode = currentYdtNode.getParent();
- currentYpmNode = currentYpmNode.getParent();
- }
- }
- }
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ypm/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ypm/package-info.java
deleted file mode 100644
index 1faafe0..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ypm/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of YANG protocol metadata. YPM maintains protocol
- * specific information for YANG modeled data.
- */
-package org.onosproject.yms.app.ypm;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleIdentifier.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleIdentifier.java
deleted file mode 100644
index 94295b2..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleIdentifier.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ysr;
-
-import org.onosproject.yms.ysr.YangModuleIdentifier;
-
-import java.util.Comparator;
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Representation of default YANG module identifier.
- */
-public class DefaultYangModuleIdentifier implements YangModuleIdentifier,
- Comparator<YangModuleIdentifier> {
-
- private final String moduleName;
- private final String revision;
-
- /**
- * Creates an instance of YANG module identifier.
- *
- * @param moduleName module's name
- * @param revision module's revision
- */
- DefaultYangModuleIdentifier(String moduleName, String revision) {
- this.moduleName = moduleName;
- this.revision = revision;
- }
-
- @Override
- public String moduleName() {
- return moduleName;
- }
-
- @Override
- public String revision() {
- return revision;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(moduleName, revision);
- }
-
- @Override
- public int compare(YangModuleIdentifier id1, YangModuleIdentifier id2) {
- int compare = id1.moduleName().compareTo(id2.moduleName());
- if (compare != 0) {
- return compare;
- }
- return id1.revision().compareTo(id2.revision());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultYangModuleIdentifier) {
- DefaultYangModuleIdentifier that = (DefaultYangModuleIdentifier) obj;
- return Objects.equals(moduleName, that.moduleName) &&
- Objects.equals(revision, that.revision);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("moduleName", moduleName)
- .add("revision", revision)
- .toString();
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleInformation.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleInformation.java
deleted file mode 100644
index f2213a8..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleInformation.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ysr;
-
-import com.google.common.collect.ImmutableList;
-import org.onosproject.yangutils.datamodel.YangNamespace;
-import org.onosproject.yms.ysr.YangModuleIdentifier;
-import org.onosproject.yms.ysr.YangModuleInformation;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Representation of default YANG module information.
- */
-class DefaultYangModuleInformation implements YangModuleInformation {
-
- private final YangModuleIdentifier moduleIdentifier;
- private final YangNamespace nameSpace;
- private final List<String> features;
- private final List<YangModuleIdentifier> subModuleIdentifiers;
-
- /**
- * Creates an instance of YANG module information.
- *
- * @param moduleIdentifier module identifier
- * @param nameSpace name space of module
- */
- DefaultYangModuleInformation(YangModuleIdentifier moduleIdentifier,
- YangNamespace nameSpace) {
- this.moduleIdentifier = moduleIdentifier;
- this.nameSpace = nameSpace;
- subModuleIdentifiers = new ArrayList<>();
- features = new ArrayList<>();
- }
-
- @Override
- public YangModuleIdentifier moduleIdentifier() {
- return moduleIdentifier;
- }
-
- public YangNamespace namespace() {
- return nameSpace;
- }
-
- @Override
- public List<String> featureList() {
- return ImmutableList.copyOf(features);
- }
-
- @Override
- public List<YangModuleIdentifier> subModuleIdentifiers() {
- return ImmutableList.copyOf(subModuleIdentifiers);
- }
-
- /**
- * Adds to YANG sub module identifier list.
- *
- * @param subModuleIdentifier YANG sub module identifier
- */
- void addSubModuleIdentifiers(YangModuleIdentifier subModuleIdentifier) {
- subModuleIdentifiers.add(subModuleIdentifier);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(moduleIdentifier, subModuleIdentifiers, nameSpace, features);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultYangModuleInformation) {
- DefaultYangModuleInformation that = (DefaultYangModuleInformation) obj;
- return Objects.equals(moduleIdentifier, that.moduleIdentifier) &&
- Objects.equals(nameSpace, that.nameSpace) &&
- Objects.equals(features, that.features) &&
- Objects.equals(subModuleIdentifiers, that.subModuleIdentifiers);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("yangModuleIdentifier", moduleIdentifier)
- .add("nameSpace", nameSpace)
- .add("features", features)
- .add("yangModuleIdentifiers", subModuleIdentifiers)
- .toString();
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleLibrary.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleLibrary.java
deleted file mode 100644
index 35d8606..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangModuleLibrary.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ysr;
-
-import com.google.common.collect.ImmutableList;
-import org.onosproject.yms.ysr.YangModuleInformation;
-import org.onosproject.yms.ysr.YangModuleLibrary;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Representation of default YANG module library.
- */
-public class DefaultYangModuleLibrary implements YangModuleLibrary {
-
- private final String moduleSetId;
- private final List<YangModuleInformation> moduleInformation;
-
- /**
- * Creates an instance of YANG module library.
- *
- * @param moduleSetId module id
- */
- public DefaultYangModuleLibrary(String moduleSetId) {
- this.moduleSetId = moduleSetId;
- moduleInformation = new ArrayList<>();
- }
-
- @Override
- public String moduleSetId() {
- return moduleSetId;
- }
-
- @Override
- public List<YangModuleInformation> yangModuleList() {
- return ImmutableList.copyOf(moduleInformation);
- }
-
- /**
- * Adds module information.
- *
- * @param information module information
- */
- void addModuleInformation(YangModuleInformation information) {
- moduleInformation.add(information);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(moduleInformation, moduleSetId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultYangModuleLibrary) {
- DefaultYangModuleLibrary that = (DefaultYangModuleLibrary) obj;
- return Objects.equals(moduleInformation, that.moduleInformation) &&
- Objects.equals(moduleSetId, that.moduleSetId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("moduleInformation", moduleInformation)
- .add("moduleId", moduleSetId)
- .toString();
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangSchemaRegistry.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangSchemaRegistry.java
deleted file mode 100644
index fbd6c86..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/DefaultYangSchemaRegistry.java
+++ /dev/null
@@ -1,761 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ysr;
-
-import org.onosproject.yangutils.datamodel.YangInclude;
-import org.onosproject.yangutils.datamodel.YangModule;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yangutils.datamodel.YangSubModule;
-import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yms.ysr.YangModuleIdentifier;
-import org.onosproject.yms.ysr.YangModuleInformation;
-import org.onosproject.yms.ysr.YangModuleLibrary;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.regex.Pattern;
-
-import static java.util.Collections.sort;
-import static org.apache.commons.io.FileUtils.deleteDirectory;
-import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.parseJarFile;
-import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING;
-import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN;
-import static org.onosproject.yangutils.utils.UtilConstants.OP_PARAM;
-import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
-import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
-import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
-import static org.osgi.framework.FrameworkUtil.getBundle;
-import static org.slf4j.LoggerFactory.getLogger;
-
-
-/**
- * Representation of default YANG schema registry. Yang schema registry
- * provides interface to an application to register its YANG schema
- * with YMS. It provides YANG schema nodes to YDT, YNB and YSB.
- */
-public class DefaultYangSchemaRegistry implements YangSchemaRegistry {
-
- private static final String SYSTEM = SLASH + "system" + SLASH;
- private static final String MAVEN = "mvn:";
- private static final String JAR = ".jar";
- private static final String USER_DIRECTORY = "user.dir";
- private static final String AT = "@";
- private static final String DATE_FORMAT = "yyyy-mm-dd";
- private static final String ONOS = "org.onosproject";
- private static final Logger log = getLogger(DefaultYangSchemaRegistry.class);
-
- /*
- * Map for storing app objects.
- */
- private final ConcurrentMap<String, Object> appObjectStore;
-
- /*
- * Map for storing YANG schema nodes.
- */
- private final ConcurrentMap<String, ConcurrentMap<String, YangSchemaNode>>
- yangSchemaStore;
-
- /*
- * Map for storing YANG schema nodes with respect to root's generated
- * interface file name.
- */
- private final ConcurrentMap<String, YangSchemaNode> interfaceNameKeyStore;
-
- /*
- * Map for storing YANG schema nodes root's generated op param file name.
- */
- private final ConcurrentMap<String, YangSchemaNode> opParamNameKeyStore;
-
- /*
- * Map for storing YANG schema nodes with respect to notifications.
- */
- private final ConcurrentMap<String, YangSchemaNode> eventNameKeyStore;
-
- /*
- * Map for storing YANG schema nodes with respect to app name.
- */
- private final ConcurrentMap<String, YangSchemaNode> appNameKeyStore;
-
- /*
- * Map for storing registered classes.
- */
- private final ConcurrentMap<String, Class<?>> registerClassStore;
-
- /*
- * Map for storing YANG file details.
- */
- private final ConcurrentMap<YangModuleIdentifier, String> yangFileStore;
-
- /**
- * Map for storing schema nodes with respect to namespace.
- */
- private final ConcurrentMap<String, YangSchemaNode> nameSpaceSchemaStore;
-
- private final ConcurrentMap<Object, Boolean> ynhRegistrationStore;
- private final ConcurrentMap<String, String> jarPathStore;
-
- /**
- * Creates an instance of default YANG schema registry.
- */
- public DefaultYangSchemaRegistry() {
- appObjectStore = new ConcurrentHashMap<>();
- yangSchemaStore = new ConcurrentHashMap<>();
- interfaceNameKeyStore = new ConcurrentHashMap<>();
- opParamNameKeyStore = new ConcurrentHashMap<>();
- eventNameKeyStore = new ConcurrentHashMap<>();
- registerClassStore = new ConcurrentHashMap<>();
- yangFileStore = new ConcurrentHashMap<>();
- appNameKeyStore = new ConcurrentHashMap<>();
- ynhRegistrationStore = new ConcurrentHashMap<>();
- jarPathStore = new ConcurrentHashMap<>();
- nameSpaceSchemaStore = new ConcurrentHashMap<>();
- }
-
-
- @Override
- public void registerApplication(Object appObject, Class<?> serviceClass) {
- synchronized (DefaultYangSchemaRegistry.class) {
- doPreProcessing(serviceClass, appObject);
- if (!verifyIfApplicationAlreadyRegistered(serviceClass)) {
- BundleContext context = getBundle(serviceClass).getBundleContext();
- if (context != null) {
- Bundle[] bundles = context.getBundles();
- Bundle bundle;
- int len = bundles.length;
- List<YangNode> curNodes;
- String jarPath;
- for (int i = len - 1; i >= 0; i--) {
- bundle = bundles[i];
- if (bundle.getSymbolicName().contains(ONOS)) {
- jarPath = getJarPathFromBundleLocation(
- bundle.getLocation(), context.getProperty(USER_DIRECTORY));
- curNodes = processJarParsingOperations(jarPath);
- // process application registration.
- if (curNodes != null && !curNodes.isEmpty()) {
- jarPathStore.put(serviceClass.getName(), jarPath);
- processRegistration(serviceClass, jarPath,
- curNodes, appObject, false);
- }
- }
- }
- }
- }
- }
- }
-
- @Override
- public void unRegisterApplication(Object managerObject,
- Class<?> serviceClass) {
- synchronized (DefaultYangSchemaRegistry.class) {
- YangSchemaNode curNode;
- String serviceName = serviceClass.getName();
-
- //Check if service should be unregistered?
- if (managerObject != null) {
- verifyApplicationRegistration(managerObject, serviceClass);
- }
- //Remove registered class from store.
- registerClassStore.remove(serviceName);
- //check if service is in app store.
- curNode = appNameKeyStore.get(serviceName);
- if (curNode == null) {
- curNode = interfaceNameKeyStore.get(serviceName);
- }
-
- if (curNode != null) {
- removeSchemaNode(curNode);
- eventNameKeyStore.remove(getEventClassName(curNode));
- appObjectStore.remove(serviceName);
- interfaceNameKeyStore.remove(getInterfaceClassName(curNode));
- opParamNameKeyStore.remove(getOpParamClassName(curNode));
- yangFileStore.remove(getModuleIdentifier(curNode));
- appNameKeyStore.remove(serviceName);
- nameSpaceSchemaStore.remove(curNode.getNameSpace()
- .getModuleNamespace());
- removeYsrGeneratedTemporaryResources(jarPathStore.get(serviceName),
- serviceName);
- log.info(" service {} is unregistered.",
- serviceClass.getSimpleName());
- } else {
- throw new RuntimeException(serviceClass.getSimpleName() +
- " service was not registered.");
- }
- }
- }
-
- @Override
- public Object getRegisteredApplication(YangSchemaNode schemaNode) {
- Object obj = null;
- if (schemaNode != null) {
- String name = getServiceName(schemaNode);
- obj = appObjectStore.get(name);
- if (obj == null) {
- log.error("{} not found.", name);
- }
- }
- return obj;
- }
-
- @Override
- public YangSchemaNode getYangSchemaNodeUsingSchemaName(String schemaName) {
- return getSchemaNodeUsingSchemaNameWithRev(schemaName);
- }
-
- @Override
- public YangSchemaNode getYangSchemaNodeUsingAppName(String appName) {
- YangSchemaNode node = appNameKeyStore.get(appName);
- if (node == null) {
- log.error("{} not found.", appName);
- }
- return node;
- }
-
- @Override
- public YangSchemaNode
- getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(String name) {
- YangSchemaNode node = interfaceNameKeyStore.get(name);
- if (node == null) {
- log.error("{} not found.", name);
- }
- return node;
- }
-
- @Override
- public YangSchemaNode getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- String name) {
- YangSchemaNode node = opParamNameKeyStore.get(name);
- if (node == null) {
- log.error("{} not found.", name);
- }
- return node;
- }
-
- @Override
- public YangSchemaNode getRootYangSchemaNodeForNotification(String name) {
- YangSchemaNode node = eventNameKeyStore.get(name);
- if (node == null) {
- log.error("{} not found.", name);
- }
- return node;
- }
-
- @Override
- public Class<?> getRegisteredClass(YangSchemaNode schemaNode) {
- String interfaceName = getInterfaceClassName(schemaNode);
- String serviceName = getServiceName(schemaNode);
- Class<?> regClass = registerClassStore.get(serviceName);
- if (regClass == null) {
- regClass = registerClassStore.get(interfaceName);
- }
- return regClass;
- }
-
- @Override
- public YangSchemaNode getSchemaWrtNameSpace(String nameSpace) {
-
- YangSchemaNode node = nameSpaceSchemaStore.get(nameSpace);
- if (node == null) {
- log.error("node with {} namespace not found.", nameSpace);
- }
- return node;
- }
-
- @Override
- public String getYangFile(YangModuleIdentifier moduleIdentifier) {
- String file = yangFileStore.get(moduleIdentifier);
- if (file == null) {
- log.error("YANG files for corresponding module identifier {} not " +
- "found", moduleIdentifier);
- }
- return file;
- }
-
- @Override
- public boolean verifyNotificationObject(Object appObj, Class<?> service) {
- synchronized (DefaultYangSchemaRegistry.class) {
- YangSchemaNode node = appNameKeyStore.get(service.getName());
- if (node == null) {
- log.error("application is not registered with YMS {}",
- service.getName());
- return false;
- }
- try {
- if (node.isNotificationPresent()) {
- if (appObj != null) {
- Boolean ifPresent = ynhRegistrationStore.get(appObj);
- if (ifPresent == null) {
- ynhRegistrationStore.put(appObj, true);
- return true;
- }
- }
- }
- } catch (DataModelException e) {
- log.error("notification registration error: {} {}", e
- .getLocalizedMessage(), e);
- }
- return false;
- }
- }
-
- @Override
- public void flushYsrData() {
- appObjectStore.clear();
- yangSchemaStore.clear();
- eventNameKeyStore.clear();
- opParamNameKeyStore.clear();
- interfaceNameKeyStore.clear();
- registerClassStore.clear();
- yangFileStore.clear();
- nameSpaceSchemaStore.clear();
- }
-
- @Override
- public void processModuleLibrary(String serviceName,
- YangModuleLibrary library) {
- synchronized (DefaultYangSchemaRegistry.class) {
- YangSchemaNode node = appNameKeyStore.get(serviceName);
- if (node != null) {
- YangModuleInformation moduleInformation =
- new DefaultYangModuleInformation(getModuleIdentifier(node),
- node.getNameSpace());
- addSubModuleIdentifier(node, (
- DefaultYangModuleInformation) moduleInformation);
- //TODO: add feature list to module information.
- ((DefaultYangModuleLibrary) library)
- .addModuleInformation(moduleInformation);
- }
- }
- }
-
- /**
- * Process service class.
- *
- * @param serviceClass service class
- * @param appObject application object
- */
-
- void doPreProcessing(Class<?> serviceClass, Object appObject) {
-
- //Check if service should be registered?
- if (appObject != null) {
- verifyApplicationRegistration(appObject, serviceClass);
- }
- String name = serviceClass.getName();
- //Add app class to registered service store.
- if (!registerClassStore.containsKey(name)) {
- registerClassStore.put(name, serviceClass);
- }
- }
-
- void updateServiceClass(Class<?> service) {
- registerClassStore.put(service.getName(), service);
- }
-
- /**
- * Process application registration.
- *
- * @param service service class
- * @param jarPath jar path
- * @param nodes YANG nodes
- * @param appObj application object
- * @param isFromUt if registration is being called form unit test
- */
- void processRegistration(Class<?> service, String jarPath,
- List<YangNode> nodes,
- Object appObj, boolean isFromUt) {
-
- // process storing operations.
- YangNode schemaNode = findNodeWhichShouldBeReg(service.getName(), nodes);
- if (schemaNode != null) {
- if (appObj != null) {
- appObjectStore.put(service.getName(), appObj);
- }
- //Process application context for registrations.
- processApplicationContext(schemaNode, service.getName(), isFromUt);
- //Update YANG file store.
- updateYangFileStore(schemaNode, jarPath);
- }
- }
-
- /**
- * Returns the node for which corresponding class is generated.
- *
- * @param name generated class name
- * @param nodes list of yang nodes
- * @return node for which corresponding class is generated
- */
- private YangNode findNodeWhichShouldBeReg(String name, List<YangNode> nodes) {
- for (YangNode node : nodes) {
- if (name.equals(getServiceName(node)) ||
- name.equals(getInterfaceClassName(node))) {
- return node;
- }
- }
- return null;
- }
-
- /**
- * Verifies if service class should be registered or not.
- *
- * @param appObject application object
- * @param appClass application class
- */
- private void verifyApplicationRegistration(Object appObject,
- Class<?> appClass) {
- Class<?> managerClass = appObject.getClass();
- Class<?>[] services = managerClass.getInterfaces();
- List<Class<?>> classes = new ArrayList<>();
- Collections.addAll(classes, services);
- if (!classes.contains(appClass)) {
- throw new RuntimeException("service class " + appClass.getName() +
- "is not being implemented by " +
- managerClass.getName());
- }
- }
-
- /**
- * Verifies if application is already registered with YMS.
- *
- * @param appClass application class
- * @return true if application already registered
- */
- private boolean verifyIfApplicationAlreadyRegistered(Class<?> appClass) {
- String appName = appClass.getName();
- return appObjectStore.containsKey(appName) ||
- interfaceNameKeyStore.containsKey(appName);
- }
-
- /**
- * Updates yang file store for YANG node.
- *
- * @param node YANG node
- * @param jarPath jar file path
- */
- private void updateYangFileStore(YangNode node, String jarPath) {
- yangFileStore.put(getModuleIdentifier(node),
- getYangFilePath(jarPath, node.getFileName()));
- }
-
- /**
- * Returns yang file path.
- *
- * @param jarPath jar path
- * @param metaDataFileName name of yang file from metadata
- * @return yang file path
- */
- private String getYangFilePath(String jarPath, String metaDataFileName) {
- String[] metaData = metaDataFileName.split(SLASH);
- return jarPath + SLASH + metaData[metaData.length - 1];
- }
-
- /**
- * Process jar file for fetching YANG nodes.
- *
- * @param path jar file path
- * @return YANG schema nodes
- */
- private List<YangNode> processJarParsingOperations(String path) {
- //Deserialize data model and get the YANG node set.
- String jar = path + JAR;
- try {
- File file = new File(jar);
- if (file.exists()) {
- return parseJarFile(path + JAR, path);
- }
- } catch (IOException e) {
- log.error(" failed to parse the jar file in path {} : {} ", path,
- e.getMessage());
- }
- return null;
- }
-
- /**
- * Process an application an updates the maps for YANG schema registry.
- *
- * @param appNode application YANG schema nodes
- * @param name class name
- * @param isFormUt if method is being called from unit tests
- */
- private void processApplicationContext(YangSchemaNode appNode, String name,
- boolean isFormUt) {
-
- //Update map for which registrations is being called.
- appNameKeyStore.put(name, appNode);
-
- // Updates schema store.
- addToSchemaStore(appNode);
- // update interface store.
- interfaceNameKeyStore.put(getInterfaceClassName(appNode), appNode);
-
- //update op param store.
- opParamNameKeyStore.put(getOpParamClassName(appNode), appNode);
-
- //update namespaceSchema store.
- nameSpaceSchemaStore.put(appNode.getNameSpace().getModuleNamespace(), appNode);
-
- //Checks if notification is present then update notification store map.
- String eventSubject = null;
- try {
- if (appNode.isNotificationPresent()) {
- eventSubject = getEventClassName(appNode);
- }
- } catch (DataModelException e) {
- log.error("failed to search notification from schema map : {}",
- e.getLocalizedMessage());
- }
- if (eventSubject != null) {
- eventNameKeyStore.put(eventSubject, appNode);
- }
- if (!isFormUt) {
- log.info("successfully registered this application {}", name);
- }
- }
-
- /**
- * Returns jar path from bundle mvnLocationPath.
- *
- * @param mvnLocationPath mvnLocationPath of bundle
- * @return path of jar
- */
- private String getJarPathFromBundleLocation(String mvnLocationPath,
- String currentDirectory) {
- String path = currentDirectory + SYSTEM;
- if (mvnLocationPath.contains(MAVEN)) {
- String[] strArray = mvnLocationPath.split(MAVEN);
- if (strArray[1].contains(File.separator)) {
- String[] split = strArray[1].split(File.separator);
- if (split[0].contains(PERIOD)) {
- String[] groupId = split[0].split(Pattern.quote(PERIOD));
- return path + groupId[0] + SLASH + groupId[1] + SLASH + split[1] +
- SLASH + split[2] + SLASH + split[1] + HYPHEN + split[2];
- }
- }
- }
- return null;
- }
-
- /**
- * Returns schema node based on the revision.
- *
- * @param name name of the schema node
- * @return schema node based on the revision
- */
- private YangSchemaNode getSchemaNodeUsingSchemaNameWithRev(String name) {
- ConcurrentMap<String, YangSchemaNode> revMap;
- YangSchemaNode schemaNode;
- if (name.contains(AT)) {
- String[] revArray = name.split(AT);
- revMap = yangSchemaStore.get(revArray[0]);
- schemaNode = revMap.get(name);
- if (schemaNode == null) {
- log.error("{} not found.", name);
- }
- return schemaNode;
- }
- if (yangSchemaStore.containsKey(name)) {
- revMap = yangSchemaStore.get(name);
- if (revMap != null && !revMap.isEmpty()) {
- YangSchemaNode node = revMap.get(name);
- if (node != null) {
- return node;
- }
- String revName = getLatestVersion(revMap);
- return revMap.get(revName);
- }
- }
- log.error("{} not found.", name);
- return null;
- }
-
- private String getLatestVersion(ConcurrentMap<String, YangSchemaNode> revMap) {
- List<String> keys = new ArrayList<>();
- for (Map.Entry<String, YangSchemaNode> entry : revMap.entrySet()) {
- keys.add(entry.getKey());
- }
- sort(keys);
- return keys.get(keys.size() - 1);
- }
-
- /**
- * Adds schema node when different revision of node has received.
- *
- * @param schemaNode schema node
- */
- private void addToSchemaStore(YangSchemaNode schemaNode) {
-
- String date = getDateInStringFormat(schemaNode);
- String name = schemaNode.getName();
- String revName = name;
- if (date != null) {
- revName = name + AT + date;
- }
- //check if already present.
- if (!yangSchemaStore.containsKey(name)) {
- ConcurrentMap<String, YangSchemaNode> revStore =
- new ConcurrentHashMap<>();
- revStore.put(revName, schemaNode);
- yangSchemaStore.put(name, revStore);
- } else {
- yangSchemaStore.get(name).put(revName, schemaNode);
- }
- }
-
- /**
- * Returns date in string format.
- *
- * @param schemaNode schema node
- * @return date in string format
- */
- String getDateInStringFormat(YangSchemaNode schemaNode) {
- if (schemaNode != null) {
- if (((YangNode) schemaNode).getRevision() != null) {
- return new SimpleDateFormat(DATE_FORMAT)
- .format(((YangNode) schemaNode).getRevision()
- .getRevDate());
- }
- }
- return null;
- }
-
- /**
- * Removes schema node from schema map.
- *
- * @param removableNode schema node which needs to be removed
- */
- private void removeSchemaNode(YangSchemaNode removableNode) {
- String name = removableNode.getName();
- String revName = name;
- String date = getDateInStringFormat(removableNode);
- if (date != null) {
- revName = name + AT + date;
- }
- ConcurrentMap<String, YangSchemaNode> revMap = yangSchemaStore.get(name);
- if (revMap != null && !revMap.isEmpty() && revMap.size() != 1) {
- revMap.remove(revName);
- } else {
- yangSchemaStore.remove(removableNode.getName());
- }
- }
-
- /**
- * Adds sub module identifier.
- *
- * @param node schema node
- * @param information module information
- */
- private void addSubModuleIdentifier(
- YangSchemaNode node, DefaultYangModuleInformation information) {
- List<YangInclude> includeList = new ArrayList<>();
- if (node instanceof YangModule) {
- includeList = ((YangModule) node).getIncludeList();
- } else if (node instanceof YangSubModule) {
- includeList = ((YangSubModule) node).getIncludeList();
- }
- for (YangInclude include : includeList) {
- information.addSubModuleIdentifiers(getModuleIdentifier(
- include.getIncludedNode()));
- }
- }
-
- /**
- * Returns module identifier for schema node.
- *
- * @param schemaNode schema node
- * @return module identifier for schema node
- */
- private YangModuleIdentifier getModuleIdentifier(
- YangSchemaNode schemaNode) {
- return new DefaultYangModuleIdentifier(
- schemaNode.getName(), getDateInStringFormat(schemaNode));
- }
-
- /**
- * Returns schema node's generated interface class name.
- *
- * @param schemaNode schema node
- * @return schema node's generated interface class name
- */
- String getInterfaceClassName(YangSchemaNode schemaNode) {
- return schemaNode.getJavaPackage() + PERIOD +
- getCapitalCase(schemaNode.getJavaClassNameOrBuiltInType());
- }
-
- /**
- * Returns schema node's generated op param class name.
- *
- * @param schemaNode schema node
- * @return schema node's generated op param class name
- */
- private String getOpParamClassName(YangSchemaNode schemaNode) {
- return getInterfaceClassName(schemaNode) + OP_PARAM;
- }
-
- /**
- * Returns schema node's generated event class name.
- *
- * @param schemaNode schema node
- * @return schema node's generated event class name
- */
- private String getEventClassName(YangSchemaNode schemaNode) {
- return getInterfaceClassName(schemaNode).toLowerCase() + PERIOD +
- getCapitalCase(schemaNode.getJavaClassNameOrBuiltInType()) +
- EVENT_STRING;
- }
-
- /**
- * Returns schema node's generated service class name.
- *
- * @param schemaNode schema node
- * @return schema node's generated service class name
- */
- String getServiceName(YangSchemaNode schemaNode) {
- return getInterfaceClassName(schemaNode) + SERVICE;
- }
-
- /**
- * Removes YSR generated temporary resources.
- *
- * @param rscPath resource path
- * @param appName application name
- */
- private void removeYsrGeneratedTemporaryResources(String rscPath,
- String appName) {
- if (rscPath != null) {
- File jarPath = new File(rscPath);
- if (jarPath.exists()) {
- try {
- deleteDirectory(jarPath);
- } catch (IOException e) {
- log.error("failed to delete ysr resources for {} : {}",
- appName, e.getLocalizedMessage());
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/YangSchemaRegistry.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/YangSchemaRegistry.java
deleted file mode 100644
index 3b9eb1e..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/YangSchemaRegistry.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ysr;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yms.ysr.YangModuleIdentifier;
-import org.onosproject.yms.ysr.YangModuleLibrary;
-
-/**
- * Abstraction of entity which provides interfaces to YANG schema registry.
- */
-public interface YangSchemaRegistry {
-
- /**
- * Registers applications to YMS.
- *
- * @param managerObject application's object
- * @param serviceClass service class which needs to be
- * registered
- */
- void registerApplication(Object managerObject, Class<?> serviceClass);
-
- /**
- * Unregisters applications to YMS.
- *
- * @param managerObject application's object
- * @param serviceClass service class which needs to be unregistered
- */
- void unRegisterApplication(Object managerObject, Class<?> serviceClass);
-
- /**
- * Returns application's implementation's class object.
- *
- * @param yangSchemaNode application's schema node
- * @return application's implementation's class object
- */
- Object getRegisteredApplication(YangSchemaNode yangSchemaNode);
-
- /**
- * Returns YANG schema node using schema name.
- *
- * @param schemaName module name.
- * @return YANG schema node using schema name
- */
- YangSchemaNode getYangSchemaNodeUsingSchemaName(String schemaName);
-
- /**
- * Returns YANG schema nodes using application name.
- *
- * @param appName application's service name
- * @return YANG schema nodes using application name
- */
- YangSchemaNode getYangSchemaNodeUsingAppName(String appName);
-
- /**
- * Returns YANG schema nodes using root interface file name.
- *
- * @param rootInterfaceFileName name of generated interface file
- * for root node
- * @return YANG schema nodes using root interface file name
- */
- YangSchemaNode
- getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- String rootInterfaceFileName);
-
- /**
- * Returns YANG schema nodes using root op param file name.
- *
- * @param rootOpParamFileName name of generated op param file for root node
- * @return YANG schema nodes using root op param file name
- */
- YangSchemaNode
- getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- String rootOpParamFileName);
-
- /**
- * Returns YANG schema node of root for notifications.
- *
- * @param eventSubject event subject
- * @return YANG schema node of root for notifications
- */
- YangSchemaNode getRootYangSchemaNodeForNotification(String eventSubject);
-
- /**
- * Returns registered service class.
- *
- * @param schemaNode YANG schema node
- * @return registered service class
- */
- Class<?> getRegisteredClass(YangSchemaNode schemaNode);
-
- /**
- * Verifies if the manager object is already registered with notification
- * handler.
- *
- * @param appObj application object
- * @param service service class
- * @return true if the manager object is already registered with
- * notification handler
- */
- boolean verifyNotificationObject(Object appObj, Class<?> service);
-
- /**
- * Clears database for YSR.
- */
- void flushYsrData();
-
- /**
- * Protocols like RESTCONF, use the definitions within the YANG modules
- * advertised by the server are used to construct an RPC operation or
- * data resource identifier.
- * <p>
- * Schema Resource:
- * The server can optionally support retrieval of the YANG modules it
- * supports.
- *
- * @param moduleIdentifier module's identifier
- * @return YANG file contents of the requested YANG module.
- */
- String getYangFile(YangModuleIdentifier moduleIdentifier);
-
- /**
- * Process module library for a registered service.
- *
- * @param serviceName service class name
- * @param library YANG module library
- */
- void processModuleLibrary(String serviceName, YangModuleLibrary library);
-
- /**
- * Returns YANG schema node for a given namespace while xml decoding.
- * <p>
- * According to rfc 6020 Xml should not have module name in it but when
- * decoder wants to convert xml to YANG object it will need module schema
- * which it can get only by using module name from YSR. So if YCH sends
- * namespace of a module we can given it the schema node of module. In
- * this case namespace should be unique.
- * </p>
- *
- * @param nameSpace name space of module
- * @return module schema node
- */
- YangSchemaNode getSchemaWrtNameSpace(String nameSpace);
-
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/package-info.java
deleted file mode 100644
index 1a15e1f..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ysr/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of YANG Schema Registry. YSR maintains the schema
- * information registry corresponding to registered app.
- */
-package org.onosproject.yms.app.ysr;
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/DefaultYangTreeBuilder.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/DefaultYangTreeBuilder.java
deleted file mode 100644
index 9ea03f0..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/DefaultYangTreeBuilder.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ytb;
-
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.ydt.YmsOperationType;
-
-import java.util.List;
-
-import static org.onosproject.yms.app.ytb.YtbUtil.emptyObjErrMsg;
-import static org.onosproject.yms.ydt.YmsOperationType.NOTIFICATION;
-import static org.onosproject.yms.ydt.YmsOperationType.RPC_REPLY;
-
-/**
- * Representation of YANG tree builder which generates YANG data tree from the
- * class objects which are provided from the applications and return it to the
- * protocol(s).
- */
-public class DefaultYangTreeBuilder implements YangTreeBuilder {
-
- private static final String OBJ_LIST = "object list";
- private static final String EVENT_OBJ = "event object";
- private static final String OUTPUT_OBJ = "output object";
-
- /**
- * Creates the YANG tree builder.
- */
- public DefaultYangTreeBuilder() {
- }
-
- @Override
- public YdtExtendedBuilder getYdtBuilderForYo(List<Object> moduleObj, String rootName,
- String rootNameSpace, YmsOperationType opType,
- YangSchemaRegistry registry) {
-
- if (moduleObj == null) {
- throw new YtbException(emptyObjErrMsg(OBJ_LIST));
- }
-
- YdtExtendedBuilder ydtBuilder = new YangRequestWorkBench(
- rootName, rootNameSpace, opType, registry, false);
-
- for (Object yangObj : moduleObj) {
- YdtBuilderFromYo moduleBuilder = new YdtBuilderFromYo(
- ydtBuilder, yangObj, registry);
-
- moduleBuilder.getModuleNodeFromYsr(yangObj);
- moduleBuilder.createYdtFromRootObject();
- }
- return ydtBuilder;
- }
-
- @Override
- public YdtExtendedContext getYdtForNotification(Object object, String rootName,
- YangSchemaRegistry registry) {
-
- if (object == null) {
- throw new YtbException(emptyObjErrMsg(EVENT_OBJ));
- }
-
- YdtExtendedBuilder extBuilder = new YangRequestWorkBench(
- rootName, null, NOTIFICATION, registry, false);
- YdtBuilderFromYo moduleBuilder = new YdtBuilderFromYo(
- extBuilder, object, registry);
-
- moduleBuilder.getRootNodeWithNotificationFromYsr(object);
- /*
- * Adds module to YDT, so that notification can further enhance the
- * tree.
- */
- moduleBuilder.createModuleInYdt();
- moduleBuilder.createYdtFromRootObject();
- return extBuilder.getRootNode();
- }
-
- @Override
- public YdtExtendedBuilder getYdtForRpcResponse(Object outputObj,
- YdtExtendedBuilder reqBuilder) {
-
- if (outputObj == null) {
- throw new YtbException(emptyObjErrMsg(OUTPUT_OBJ));
- }
-
- YangRequestWorkBench workBench = (YangRequestWorkBench) reqBuilder;
-
- // Gets the logical root node from RPC request work bench.
- YdtExtendedContext rootNode = workBench.getRootNode();
-
- /*
- * Creates a new work bench for RPC reply from the contents of the
- * request work bench
- */
- YdtExtendedBuilder ydtBuilder =
- new YangRequestWorkBench(null, null, RPC_REPLY,
- workBench.getYangSchemaRegistry(),
- false);
- YdtBuilderFromYo moduleBuilder =
- new YdtBuilderFromYo(ydtBuilder, outputObj,
- workBench.getYangSchemaRegistry());
-
- // Forms YDT till RPC, so that output can further enhance the tree.
- moduleBuilder.createModuleAndRpcInYdt(rootNode);
- moduleBuilder.createYdtFromRootObject();
- return ydtBuilder;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YangTreeBuilder.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YangTreeBuilder.java
deleted file mode 100644
index 8df19c7..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YangTreeBuilder.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ytb;
-
-import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.ydt.YmsOperationType;
-
-import java.util.List;
-
-/**
- * Abstraction of an entity which provides interfaces to build YANG data tree
- * from the object received from YNH, YAB or YCH.
- */
-public interface YangTreeBuilder {
-
- /**
- * Returns the YDT builder after building the tree corresponding to the
- * response YANG object received from any of the protocol such as YAB or
- * YCH.
- *
- * @param moduleObj application module object
- * @param rootName logical root node name
- * @param rootNameSpace logical root node namespace
- * @param opType root node operation type
- * @param registry application schema registry
- * @return YDT builder from the tree
- */
- YdtExtendedBuilder getYdtBuilderForYo(List<Object> moduleObj,
- String rootName,
- String rootNameSpace,
- YmsOperationType opType,
- YangSchemaRegistry registry);
-
- /**
- * Returns the YDT context after building the tree received from the
- * protocol YNH.
- *
- * @param object application notification object
- * @param rootName logical root node name
- * @param registry application schema registry
- * @return YDT context from the tree
- */
- YdtExtendedContext getYdtForNotification(Object object, String rootName,
- YangSchemaRegistry registry);
-
- /**
- * Returns the YDT context after building the RPC response tree. The input
- * for building the tree is RPC request builder, RPC output java object.
- * These are received from the YSB protocol.
- *
- * @param outputObj application output object
- * @param reqBuilder RPC request builder from YDT
- * @return YDT builder where RPC response tree is created
- */
- YdtExtendedBuilder getYdtForRpcResponse(Object outputObj,
- YdtExtendedBuilder reqBuilder);
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YdtBuilderFromYo.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YdtBuilderFromYo.java
deleted file mode 100644
index 96d3950..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YdtBuilderFromYo.java
+++ /dev/null
@@ -1,1034 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ytb;
-
-import org.onosproject.yangutils.datamodel.YangAugment;
-import org.onosproject.yangutils.datamodel.YangAugmentableNode;
-import org.onosproject.yangutils.datamodel.YangCase;
-import org.onosproject.yangutils.datamodel.YangChoice;
-import org.onosproject.yangutils.datamodel.YangDerivedInfo;
-import org.onosproject.yangutils.datamodel.YangLeaf;
-import org.onosproject.yangutils.datamodel.YangLeafList;
-import org.onosproject.yangutils.datamodel.YangLeafRef;
-import org.onosproject.yangutils.datamodel.YangLeavesHolder;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
-import org.onosproject.yangutils.datamodel.YangType;
-import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
-import org.onosproject.yms.app.utils.TraversalType;
-import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.EMPTY;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
-import static org.onosproject.yms.app.utils.TraversalType.CHILD;
-import static org.onosproject.yms.app.utils.TraversalType.PARENT;
-import static org.onosproject.yms.app.utils.TraversalType.ROOT;
-import static org.onosproject.yms.app.utils.TraversalType.SIBLING;
-import static org.onosproject.yms.app.ydt.AppType.YTB;
-import static org.onosproject.yms.app.ytb.YtbUtil.PERIOD;
-import static org.onosproject.yms.app.ytb.YtbUtil.STR_NULL;
-import static org.onosproject.yms.app.ytb.YtbUtil.getAttributeFromInheritance;
-import static org.onosproject.yms.app.ytb.YtbUtil.getAttributeOfObject;
-import static org.onosproject.yms.app.ytb.YtbUtil.getClassLoaderForAugment;
-import static org.onosproject.yms.app.ytb.YtbUtil.getInterfaceClassFromImplClass;
-import static org.onosproject.yms.app.ytb.YtbUtil.getJavaName;
-import static org.onosproject.yms.app.ytb.YtbUtil.getNodeOpType;
-import static org.onosproject.yms.app.ytb.YtbUtil.getOpTypeName;
-import static org.onosproject.yms.app.ytb.YtbUtil.getParentObjectOfNode;
-import static org.onosproject.yms.app.ytb.YtbUtil.getStringFromType;
-import static org.onosproject.yms.app.ytb.YtbUtil.isAugmentNode;
-import static org.onosproject.yms.app.ytb.YtbUtil.isMultiInstanceNode;
-import static org.onosproject.yms.app.ytb.YtbUtil.isNodeProcessCompleted;
-import static org.onosproject.yms.app.ytb.YtbUtil.isNonProcessableNode;
-import static org.onosproject.yms.app.ytb.YtbUtil.isTypePrimitive;
-import static org.onosproject.yms.app.ytb.YtbUtil.isValueOrSelectLeafSet;
-import static org.onosproject.yms.app.ytb.YtbUtil.nonEmpty;
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-
-/**
- * Implements traversal of YANG node and its corresponding object, resulting
- * in building of the YDT tree.
- */
-public class YdtBuilderFromYo {
-
- private static final String STR_TYPE = "type";
- private static final String STR_SUBJECT = "subject";
- private static final String TRUE = "true";
- private static final String IS_LEAF_VALUE_SET_METHOD = "isLeafValueSet";
- private static final String IS_SELECT_LEAF_SET_METHOD = "isSelectLeaf";
- private static final String OUTPUT = "output";
- private static final String YANG_AUGMENTED_INFO_MAP =
- "yangAugmentedInfoMap";
- private static final String FALSE = "false";
-
- /**
- * Application YANG schema registry.
- */
- private final YangSchemaRegistry registry;
-
- /**
- * Current instance of the YDT builder where the tree is built.
- */
- private final YdtExtendedBuilder extBuilder;
-
- /**
- * YANG root object that is required for walking along with the YANG node.
- */
- private Object rootObj;
-
- /**
- * YANG root node that is required for walking along with the YANG object.
- */
- private YangSchemaNode rootSchema;
-
- /**
- * Creates YDT builder from YANG object by assigning the mandatory values.
- *
- * @param rootBuilder root node builder
- * @param rootObj root node object
- * @param registry application schema registry
- */
- public YdtBuilderFromYo(YdtExtendedBuilder rootBuilder, Object rootObj,
- YangSchemaRegistry registry) {
- extBuilder = rootBuilder;
- this.rootObj = rootObj;
- this.registry = registry;
- }
-
- /**
- * Returns schema root node, received from YSR, which searches based on
- * the object received from YAB or YCH.
- *
- * @param object root node object
- */
- public void getModuleNodeFromYsr(Object object) {
- Class interfaceClass = getInterfaceClassFromImplClass(object);
- rootSchema = registry
- .getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- interfaceClass.getName());
- }
-
- /**
- * Returns schema root node, received from YSR, which searches based on
- * the object received from YNH.
- *
- * @param object notification event object
- */
- public void getRootNodeWithNotificationFromYsr(Object object) {
- rootSchema = registry.getRootYangSchemaNodeForNotification(
- object.getClass().getName());
- }
-
- /**
- * Creates the module node for in YDT before beginning with notification
- * root node traversal. Collects sufficient information to fill YDT with
- * notification root node in the traversal.
- */
- public void createModuleInYdt() {
- extBuilder.addChild(NONE, rootSchema);
- rootSchema = getSchemaNodeOfNotification();
- rootObj = getObjOfNotification();
- }
-
- /**
- * Creates the module and RPC node, in YDT tree, from the logical root
- * node received from request workbench. The output schema node is taken
- * from the child schema of RPC YANG node.
- *
- * @param rootNode logical root node
- */
- public void createModuleAndRpcInYdt(YdtExtendedContext rootNode) {
-
- YdtExtendedContext moduleNode =
- (YdtExtendedContext) rootNode.getFirstChild();
- extBuilder.addChild(NONE, moduleNode.getYangSchemaNode());
-
- YdtExtendedContext rpcNode =
- (YdtExtendedContext) moduleNode.getFirstChild();
- YangSchemaNode rpcSchemaNode = rpcNode.getYangSchemaNode();
- extBuilder.addChild(NONE, rpcSchemaNode);
-
- // Defines a schema identifier for output node.
- YangSchemaNodeIdentifier schemaId = new YangSchemaNodeIdentifier();
- schemaId.setName(OUTPUT);
- schemaId.setNameSpace(rpcSchemaNode.getNameSpace());
- try {
- // Gets the output schema node from RPC child schema.
- rootSchema = rpcSchemaNode.getChildSchema(schemaId).getSchemaNode();
- } catch (DataModelException e) {
- throw new YtbException(e);
- }
- }
-
- /**
- * Creates YDT tree from the root object, by traversing through YANG data
- * model node, and simultaneously checking the object nodes presence and
- * walking the object.
- */
- public void createYdtFromRootObject() {
- YangNode curNode = (YangNode) rootSchema;
- TraversalType curTraversal = ROOT;
- YtbNodeInfo listNodeInfo = null;
- YtbNodeInfo augmentNodeInfo = null;
-
- while (curNode != null) {
- /*
- * Processes the node, if it is being visited for the first time in
- * the schema, also if the schema node is being retraced in a multi
- * instance node.
- */
- if (curTraversal != PARENT || isMultiInstanceNode(curNode)) {
-
- if (curTraversal == PARENT && isMultiInstanceNode(curNode)) {
- /*
- * If the schema is being retraced for a multi-instance
- * node, it has already entered for this multi-instance
- * node. Now this re-processes the same schema node for
- * any additional list object.
- */
- listNodeInfo = getCurNodeInfoAndTraverseBack();
- }
-
- if (curTraversal == ROOT && !isAugmentNode(curNode)) {
- /*
- * In case of RPC output, the root node is augmentative,
- * so when the root traversal is coming for augment this
- * flow is skipped. This adds only the root node in the YDT.
- */
- processApplicationRootNode();
- } else {
- /*
- * Gets the object corresponding to current schema node.
- * If object exists, this adds the corresponding YDT node
- * to the tree and returns the object. Else returns null.
- */
- Object processedObject = processCurSchemaNodeAndAddToYdt(
- curNode, listNodeInfo);
- /*
- * Clears the list info of processed node. The next time
- * list info is taken newly and accordingly.
- */
- listNodeInfo = null;
- if (processedObject == null && !isAugmentNode(curNode)) {
- /*
- * Checks the presence of next sibling of the node, by
- * breaking the complete chain of the current node,
- * when the object value is not present, or when the
- * list entries are completely retraced. The augment
- * may have sibling, so this doesn't process for
- * augment.
- */
- YtbTraversalInfo traverseInfo =
- getProcessableInfo(curNode);
- curNode = traverseInfo.getYangNode();
- curTraversal = traverseInfo.getTraverseType();
- continue;
- /*
- * Irrespective of root or parent, sets the traversal
- * type as parent, when augment node doesn't have any
- * value. So, the other sibling augments can be
- * processed, if present.
- */
- } else if (processedObject == null &&
- isAugmentNode(curNode)) {
- curTraversal = PARENT;
- /*
- * The second content in the list will be having
- * parent traversal, in such case it cannot go to its
- * child in the flow, so it is made as child
- * traversal and proceeded to continue.
- */
- } else if (curTraversal == PARENT &&
- isMultiInstanceNode(curNode)) {
- curTraversal = CHILD;
- }
- }
- }
- /*
- * Checks for the sibling augment when the first augment node is
- * getting completed. From the current augment node the previous
- * node info is taken for augment and the traversal is changed to
- * child, so as to check for the presence of sibling augment.
- */
- if (curTraversal == PARENT && isAugmentNode(curNode)) {
- curNode = ((YangAugment) curNode).getAugmentedNode();
- augmentNodeInfo = getParentYtbInfo();
- curTraversal = CHILD;
- }
- /*
- * Creates an augment iterator for the first time or takes the
- * previous augment iterator for more than one time, whenever an
- * augmentative node arrives. If augment is present it goes back
- * for processing. If its null, the augmentative nodes process is
- * continued.
- */
- if (curTraversal != PARENT &&
- curNode instanceof YangAugmentableNode) {
- YangNode augmentNode = getAugmentInsideSchemaNode(
- curNode, augmentNodeInfo);
- if (augmentNode != null) {
- curNode = augmentNode;
- continue;
- }
- }
- /*
- * Processes the child, after processing the node. If complete
- * child depth is over, it takes up sibling and processes it.
- * Once child and sibling is over, it is traversed back to the
- * parent, without processing. In multi instance case, before
- * going to parent or schema sibling, its own list sibling is
- * processed. Skips the processing of RPC,notification and
- * augment, as these nodes are dealt in a different flow.
- */
- if (curTraversal != PARENT && curNode.getChild() != null) {
- augmentNodeInfo = null;
- listNodeInfo = null;
- curTraversal = CHILD;
- curNode = curNode.getChild();
- if (isNonProcessableNode(curNode)) {
- YtbTraversalInfo traverseInfo = getProcessableInfo(curNode);
- curNode = traverseInfo.getYangNode();
- curTraversal = traverseInfo.getTraverseType();
- }
- } else if (curNode.getNextSibling() != null) {
- if (isNodeProcessCompleted(curNode, curTraversal)) {
- break;
- }
- if (isMultiInstanceNode(curNode)) {
- listNodeInfo = getCurNodeInfoAndTraverseBack();
- augmentNodeInfo = null;
- continue;
- }
- curTraversal = SIBLING;
- augmentNodeInfo = null;
- traverseToParent(curNode);
- curNode = curNode.getNextSibling();
- if (isNonProcessableNode(curNode)) {
- YtbTraversalInfo traverseInfo = getProcessableInfo(curNode);
- curNode = traverseInfo.getYangNode();
- curTraversal = traverseInfo.getTraverseType();
- }
- } else {
- if (isNodeProcessCompleted(curNode, curTraversal)) {
- break;
- }
- if (isMultiInstanceNode(curNode)) {
- listNodeInfo = getCurNodeInfoAndTraverseBack();
- augmentNodeInfo = null;
- continue;
- }
- curTraversal = PARENT;
- traverseToParent(curNode);
- curNode = getParentSchemaNode(curNode);
- }
- }
- }
-
- /**
- * Returns parent schema node of current node.
- *
- * @param curNode current schema node
- * @return parent schema node
- */
- private YangNode getParentSchemaNode(YangNode curNode) {
- if (curNode instanceof YangAugment) {
- /*
- * If curNode is augment, either next augment or augmented node
- * has to be processed. So traversal type is changed to parent,
- * but node is not changed.
- */
- return curNode;
- }
- return curNode.getParent();
- }
-
- /**
- * Processes root YANG node and adds it as a child to the YDT
- * extended builder which is created earlier.
- */
- private void processApplicationRootNode() {
-
- YtbNodeInfo nodeInfo = new YtbNodeInfo();
- YangNode rootYang = (YangNode) rootSchema;
- addChildNodeInYdt(rootObj, rootYang, nodeInfo);
- // If root node has leaf or leaf-list those will be processed.
- processLeaves(rootYang);
- processLeavesList(rootYang);
- }
-
- /**
- * Traverses to parent, based on the schema node that requires to be
- * traversed. Skips traversal of parent for choice and case node, as they
- * don't get added to the YDT tree.
- *
- * @param curNode current YANG node
- */
- private void traverseToParent(YangNode curNode) {
- if (curNode instanceof YangCase || curNode instanceof YangChoice
- || curNode instanceof YangAugment) {
- return;
- }
- extBuilder.traverseToParentWithoutValidation();
- }
-
- /**
- * Returns the current YTB info of the YDT builder, and then traverses back
- * to parent. In case of multi instance node the previous node info is
- * used for iterating through the list.
- *
- * @return current YTB app info
- */
- private YtbNodeInfo getCurNodeInfoAndTraverseBack() {
- YtbNodeInfo appInfo = getParentYtbInfo();
- extBuilder.traverseToParentWithoutValidation();
- return appInfo;
- }
-
- /**
- * Returns augment node for an augmented node. From the list of augment
- * nodes it has, one of the nodes is taken and provided linearly. If the
- * node is not augmented or the all the augment nodes are processed, then
- * it returns null.
- *
- * @param curNode current YANG node
- * @param augmentNodeInfo previous augment node info
- * @return YANG augment node
- */
- private YangNode getAugmentInsideSchemaNode(YangNode curNode,
- YtbNodeInfo augmentNodeInfo) {
- if (augmentNodeInfo == null) {
- List<YangAugment> augmentList = ((YangAugmentableNode) curNode)
- .getAugmentedInfoList();
- if (nonEmpty(augmentList)) {
- YtbNodeInfo parentNodeInfo = getParentYtbInfo();
- Iterator<YangAugment> augmentItr = augmentList.listIterator();
- parentNodeInfo.setAugmentIterator(augmentItr);
- return augmentItr.next();
- }
- } else if (augmentNodeInfo.getAugmentIterator() != null) {
- if (augmentNodeInfo.getAugmentIterator().hasNext()) {
- return augmentNodeInfo.getAugmentIterator().next();
- }
- }
- return null;
- }
-
- /**
- * Processes the current YANG node and if necessary adds it to the YDT
- * builder tree by extracting the information from the corresponding
- * class object.
- *
- * @param curNode current YANG node
- * @param listNodeInfo previous node info for list
- * @return object of the schema node
- */
- private Object processCurSchemaNodeAndAddToYdt(YangNode curNode,
- YtbNodeInfo listNodeInfo) {
- YtbNodeInfo curNodeInfo = new YtbNodeInfo();
- Object nodeObj = null;
- YtbNodeInfo parentNodeInfo = getParentYtbInfo();
-
- switch (curNode.getYangSchemaNodeType()) {
- case YANG_SINGLE_INSTANCE_NODE:
- nodeObj = processSingleInstanceNode(curNode, curNodeInfo,
- parentNodeInfo);
- break;
- case YANG_MULTI_INSTANCE_NODE:
- nodeObj = processMultiInstanceNode(
- curNode, curNodeInfo, listNodeInfo, parentNodeInfo);
- break;
- case YANG_CHOICE_NODE:
- nodeObj = processChoiceNode(curNode, parentNodeInfo);
- break;
- case YANG_NON_DATA_NODE:
- if (curNode instanceof YangCase) {
- nodeObj = processCaseNode(curNode, parentNodeInfo);
- }
- break;
- case YANG_AUGMENT_NODE:
- nodeObj = processAugmentNode(curNode, parentNodeInfo);
- break;
- default:
- throw new YtbException(
- "Non processable schema node has arrived for adding " +
- "it in YDT tree");
- }
- // Processes leaf/leaf-list only when object has value, else it skips.
- if (nodeObj != null) {
- processLeaves(curNode);
- processLeavesList(curNode);
- }
- return nodeObj;
- }
-
- /**
- * Processes single instance node which is added to the YDT tree.
- *
- * @param curNode current YANG node
- * @param curNodeInfo current YDT node info
- * @param parentNodeInfo parent YDT node info
- * @return object of the current node
- */
- private Object processSingleInstanceNode(YangNode curNode,
- YtbNodeInfo curNodeInfo,
- YtbNodeInfo parentNodeInfo) {
- Object childObj = getChildObject(curNode, parentNodeInfo);
- if (childObj != null) {
- addChildNodeInYdt(childObj, curNode, curNodeInfo);
- }
- return childObj;
- }
-
- /**
- * Processes multi instance node which has to be added to the YDT tree.
- * For the first instance in the list, iterator is created and added to
- * the list. For second instance or more the iterator from first instance
- * is taken and iterated through to get the object of parent.
- *
- * @param curNode current list node
- * @param curNodeInfo current node info for list
- * @param listNodeInfo previous instance node info of list
- * @param parentNodeInfo parent node info of list
- * @return object of the current instance
- */
- private Object processMultiInstanceNode(YangNode curNode,
- YtbNodeInfo curNodeInfo,
- YtbNodeInfo listNodeInfo,
- YtbNodeInfo parentNodeInfo) {
- Object childObj = null;
- /*
- * When YANG list comes to this flow for first time, its YTB node
- * will be null. When it comes for the second or more content, then
- * the list would have been already set for that node. According to
- * set or not set this flow will be proceeded.
- */
- if (listNodeInfo == null) {
- List<Object> childObjList = (List<Object>) getChildObject(
- curNode, parentNodeInfo);
- if (nonEmpty(childObjList)) {
- Iterator<Object> listItr = childObjList.iterator();
- if (!listItr.hasNext()) {
- return null;
- //TODO: Handle the subtree filtering with no list entries.
- }
- childObj = listItr.next();
- /*
- * For that node the iterator is set. So the next time for
- * the list this iterator will be taken.
- */
- curNodeInfo.setListIterator(listItr);
- }
- } else {
- /*
- * If the list value comes for second or more time, that list
- * node will be having YTB node info, where iterator can be
- * retrieved and check if any more contents are present. If
- * present those will be processed.
- */
- curNodeInfo.setListIterator(listNodeInfo.getListIterator());
- if (listNodeInfo.getListIterator().hasNext()) {
- childObj = listNodeInfo.getListIterator().next();
- }
- }
- if (childObj != null) {
- addChildNodeInYdt(childObj, curNode, curNodeInfo);
- }
- return childObj;
- }
-
- /**
- * Processes choice node which adds a map to the parent node info of
- * choice name and the case object. The object taken for choice node is
- * of case object with choice name. Also, this Skips the addition of choice
- * to YDT.
- *
- * @param curNode current choice node
- * @param parentNodeInfo parent YTB node info
- * @return object of the choice node
- */
- private Object processChoiceNode(YangNode curNode,
- YtbNodeInfo parentNodeInfo) {
- /*
- * Retrieves the parent YTB info, to take the object of parent, so as
- * to check the child attribute from the object.
- */
- Object childObj = getChildObject(curNode, parentNodeInfo);
- if (childObj != null) {
- Map<String, Object> choiceCaseMap = parentNodeInfo
- .getChoiceCaseMap();
- if (choiceCaseMap == null) {
- choiceCaseMap = new HashMap<>();
- parentNodeInfo.setChoiceCaseMap(choiceCaseMap);
- }
- choiceCaseMap.put(curNode.getName(), childObj);
- }
- return childObj;
- }
-
- /**
- * Processes case node from the map contents that is filled by choice
- * nodes. Object of choice is taken when choice name and case class name
- * matches. When the case node is not present in the map it returns null.
- *
- * @param curNode current case node
- * @param parentNodeInfo choice parent node info
- * @return object of the case node
- */
- private Object processCaseNode(YangNode curNode,
- YtbNodeInfo parentNodeInfo) {
- Object childObj = null;
- if (parentNodeInfo.getChoiceCaseMap() != null) {
- childObj = getCaseObjectFromChoice(parentNodeInfo,
- curNode);
- }
- if (childObj != null) {
- /*
- * Sets the case object in parent info, so that rest of the case
- * children can use it as parent. Case is not added in YDT.
- */
- parentNodeInfo.setCaseObject(childObj);
- }
- return childObj;
- }
-
- /**
- * Processes augment node, which is not added in the YDT, but binds
- * itself to the parent YTB info, so rest of its child nodes can use for
- * adding themselves to the YDT tree. If there is no augment node added
- * in map or if the augment module is not registered, then it returns null.
- *
- * @param curNode current augment node
- * @param parentNodeInfo augment parent node info
- * @return object of the augment node
- */
- private Object processAugmentNode(YangNode curNode,
- YtbNodeInfo parentNodeInfo) {
- String className = curNode.getJavaClassNameOrBuiltInType();
- String pkgName = curNode.getJavaPackage();
- Object parentObj = getParentObjectOfNode(parentNodeInfo,
- curNode.getParent());
- Map augmentMap;
- try {
- augmentMap = (Map) getAttributeOfObject(parentObj,
- YANG_AUGMENTED_INFO_MAP);
- /*
- * Gets the registered module class. Loads the class and gets the
- * augment class.
- */
- Class moduleClass = getClassLoaderForAugment(curNode, registry);
- if (moduleClass == null) {
- return null;
- }
- Class augmentClass = moduleClass.getClassLoader().loadClass(
- pkgName + PERIOD + className);
- Object childObj = augmentMap.get(augmentClass);
- parentNodeInfo.setAugmentObject(childObj);
- return childObj;
- } catch (ClassNotFoundException | NoSuchMethodException e) {
- throw new YtbException(e);
- }
- }
-
- /**
- * Returns the YTB info from the parent node, so that its own bounded
- * object can be taken out.
- *
- * @return parent node YTB node info
- */
- private YtbNodeInfo getParentYtbInfo() {
- YdtExtendedContext parentExtContext = extBuilder.getCurNode();
- return (YtbNodeInfo) parentExtContext.getAppInfo(YTB);
- }
-
- /**
- * Returns the child object from the parent object. Uses java name of the
- * current node to search the attribute in the parent object.
- *
- * @param curNode current YANG node
- * @param parentNodeInfo parent YTB node info
- * @return object of the child node
- */
- private Object getChildObject(YangNode curNode,
- YtbNodeInfo parentNodeInfo) {
- String nodeJavaName = curNode.getJavaAttributeName();
- Object parentObj = getParentObjectOfNode(parentNodeInfo,
- curNode.getParent());
- try {
- return getAttributeOfObject(parentObj, nodeJavaName);
- } catch (NoSuchMethodException e) {
- throw new YtbException(e);
- }
- }
-
- /**
- * Adds the child node to the YDT by taking operation type from the
- * object. Also, binds the object to the YDT node through YTB node info.
- *
- * @param childObj node object
- * @param curNode current YANG node
- * @param curNodeInfo current YTB info
- */
- private void addChildNodeInYdt(Object childObj, YangNode curNode,
- YtbNodeInfo curNodeInfo) {
- YdtContextOperationType opType =
- getNodeOpType(childObj, getOpTypeName(curNode));
- extBuilder.addChild(opType, curNode);
- YdtExtendedContext curExtContext = extBuilder.getCurNode();
- curNodeInfo.setYangObject(childObj);
- curExtContext.addAppInfo(YTB, curNodeInfo);
- }
-
- /**
- * Processes every leaf in a YANG node. Iterates through the leaf, takes
- * value from the leaf and adds it to the YDT with value. If value is not
- * present, and select leaf is set, adds it to the YDT without value.
- *
- * @param yangNode leaves holder node
- */
- private void processLeaves(YangNode yangNode) {
- if (yangNode instanceof YangLeavesHolder) {
- List<YangLeaf> leavesList = ((YangLeavesHolder) yangNode)
- .getListOfLeaf();
- if (leavesList != null) {
- for (YangLeaf yangLeaf : leavesList) {
- YtbNodeInfo parentYtbInfo = getParentYtbInfo();
- Object parentObj = getParentObjectOfNode(parentYtbInfo,
- yangNode);
- Object leafType;
- try {
- leafType = getAttributeOfObject(parentObj,
- getJavaName(yangLeaf));
- } catch (NoSuchMethodException e) {
- throw new YtbException(e);
- }
-
- addLeafWithValue(yangNode, yangLeaf, parentObj, leafType);
- addLeafWithoutValue(yangNode, yangLeaf, parentObj);
- }
- }
- }
- }
-
- /**
- * Processes every leaf-list in a YANG node for adding the value in YDT.
- *
- * @param yangNode list of leaf-list holder node
- */
- private void processLeavesList(YangNode yangNode) {
- if (yangNode instanceof YangLeavesHolder) {
- List<YangLeafList> listOfLeafList =
- ((YangLeavesHolder) yangNode).getListOfLeafList();
-
- if (listOfLeafList != null) {
- for (YangLeafList yangLeafList : listOfLeafList) {
- addToBuilder(yangNode, yangLeafList);
- }
- }
- }
- }
-
- /**
- * Processes the list of objects of the leaf list and adds the leaf list
- * value to the builder.
- *
- * @param yangNode YANG node
- * @param leafList YANG leaf list
- */
- private void addToBuilder(YangNode yangNode, YangLeafList leafList) {
- YtbNodeInfo ytbNodeInfo = getParentYtbInfo();
- Object parentObj = getParentObjectOfNode(ytbNodeInfo, yangNode);
- List<Object> obj;
- try {
- obj = (List<Object>) getAttributeOfObject(parentObj,
- getJavaName(leafList));
- } catch (NoSuchMethodException e) {
- throw new YtbException(e);
- }
- if (obj != null) {
- addLeafListValue(yangNode, parentObj, leafList, obj);
- }
- }
-
- /**
- * Adds the leaf list value to the YDT builder by taking the string value
- * from the data type.
- *
- * @param yangNode YANG node
- * @param parentObj parent object
- * @param leafList YANG leaf list
- * @param obj list of objects
- */
- private void addLeafListValue(YangNode yangNode, Object parentObj,
- YangLeafList leafList, List<Object> obj) {
-
- Set<String> leafListVal = new LinkedHashSet<>();
- boolean isEmpty = false;
- for (Object object : obj) {
- String val = getStringFromType(yangNode, parentObj,
- getJavaName(leafList), object,
- leafList.getDataType());
- isEmpty = isTypeEmpty(val, leafList.getDataType());
- if (isEmpty) {
- if (val.equals(TRUE)) {
- addLeafList(leafListVal, leafList);
- }
- break;
- }
- if (!"".equals(val)) {
- leafListVal.add(val);
- }
- }
- if (!isEmpty && !leafListVal.isEmpty()) {
- addLeafList(leafListVal, leafList);
- }
- }
-
- /**
- * Adds set of leaf list values in the builder and traverses back to the
- * holder.
- *
- * @param leafListVal set of values
- * @param leafList YANG leaf list
- */
- private void addLeafList(Set<String> leafListVal, YangLeafList leafList) {
- extBuilder.addLeafList(leafListVal, leafList);
- extBuilder.traverseToParentWithoutValidation();
- }
-
- /**
- * Returns the schema node of notification from the root node. Gets the
- * enum value from event object and gives it to the root schema node for
- * getting back the notification schema node.
- *
- * @return YANG schema node of notification
- */
- private YangSchemaNode getSchemaNodeOfNotification() {
-
- Object eventObjType = getAttributeFromInheritance(rootObj, STR_TYPE);
- String opTypeValue = String.valueOf(eventObjType);
-
- if (opTypeValue.equals(STR_NULL) || opTypeValue.isEmpty()) {
- throw new YtbException(
- "There is no notification present for the event. Invalid " +
- "input for notification.");
- }
- try {
- return rootSchema.getNotificationSchemaNode(opTypeValue);
- } catch (DataModelException e) {
- throw new YtbException(e);
- }
- }
-
- /**
- * Returns the object of the notification by retrieving the attributes
- * from the event class object.
- *
- * @return notification YANG object
- */
- private Object getObjOfNotification() {
-
- Object eventSubjectObj =
- getAttributeFromInheritance(rootObj, STR_SUBJECT);
- String notificationName = rootSchema.getJavaAttributeName();
- try {
- return getAttributeOfObject(eventSubjectObj, notificationName);
- } catch (NoSuchMethodException e) {
- throw new YtbException(e);
- }
- }
-
- /**
- * Returns case object from the map that is bound to the parent node
- * info. For any case node, only when the key and value is matched the
- * object of the case is provided. If a match is not found, null is
- * returned.
- *
- * @param parentNodeInfo parent YTB node info
- * @param caseNode case schema node
- * @return object of the case node
- */
- private Object getCaseObjectFromChoice(YtbNodeInfo parentNodeInfo,
- YangSchemaNode caseNode) {
- String javaName = getCapitalCase(
- caseNode.getJavaClassNameOrBuiltInType());
- String choiceName = ((YangNode) caseNode).getParent().getName();
- Map<String, Object> mapObj = parentNodeInfo.getChoiceCaseMap();
- Object caseObj = mapObj.get(choiceName);
- Class<?> interfaceClass = getInterfaceClassFromImplClass(caseObj);
- return interfaceClass.getSimpleName().equals(javaName) ? caseObj : null;
- }
-
- /**
- * Adds leaf to YDT when value is present. For primitive types, in order
- * to avoid default values, the value select is set or not is checked and
- * then added.
- *
- * @param holder leaf holder
- * @param yangLeaf YANG leaf node
- * @param parentObj leaf holder object
- * @param leafType object of leaf type
- */
- private void addLeafWithValue(YangSchemaNode holder, YangLeaf yangLeaf,
- Object parentObj, Object leafType) {
- String fieldValue = null;
- if (isTypePrimitive(yangLeaf.getDataType())) {
- fieldValue = getLeafValueFromValueSetFlag(holder, parentObj,
- yangLeaf, leafType);
- /*
- * Checks the object is present or not, when type is
- * non-primitive. And adds the value from the respective data type.
- */
- } else if (leafType != null) {
- fieldValue = getStringFromType(holder, parentObj,
- getJavaName(yangLeaf), leafType,
- yangLeaf.getDataType());
- }
-
- if (nonEmpty(fieldValue)) {
- boolean isEmpty = isTypeEmpty(fieldValue,
- yangLeaf.getDataType());
- if (isEmpty) {
- if (!fieldValue.equals(TRUE)) {
- return;
- }
- fieldValue = null;
- }
- extBuilder.addLeaf(fieldValue, yangLeaf);
- extBuilder.traverseToParentWithoutValidation();
- }
- }
-
- /**
- * Returns the value as true if direct or referred type from leafref or
- * derived points to empty data type; false otherwise.
- *
- * @param fieldValue value of the leaf
- * @param dataType type of the leaf
- * @return true if type is empty; false otherwise.
- */
- private boolean isTypeEmpty(String fieldValue, YangType<?> dataType) {
- if (fieldValue.equals(TRUE) || fieldValue.equals(FALSE)) {
- switch (dataType.getDataType()) {
- case EMPTY:
- return true;
-
- case LEAFREF:
- YangLeafRef leafRef =
- (YangLeafRef) dataType.getDataTypeExtendedInfo();
- return isTypeEmpty(fieldValue,
- leafRef.getEffectiveDataType());
- case DERIVED:
- YangDerivedInfo info =
- (YangDerivedInfo) dataType
- .getDataTypeExtendedInfo();
- YangDataTypes type = info.getEffectiveBuiltInType();
- return type == EMPTY;
-
- default:
- return false;
- }
- }
- return false;
- }
-
- /**
- * Adds leaf without value, when the select leaf bit is set.
- *
- * @param holder leaf holder
- * @param yangLeaf YANG leaf node
- * @param parentObj leaf holder object
- */
- private void addLeafWithoutValue(YangSchemaNode holder, YangLeaf yangLeaf,
- Object parentObj) {
-
- String selectLeaf;
- try {
- selectLeaf = isValueOrSelectLeafSet(holder, parentObj,
- getJavaName(yangLeaf),
- IS_SELECT_LEAF_SET_METHOD);
- } catch (NoSuchMethodException e) {
- selectLeaf = FALSE;
- }
- if (selectLeaf.equals(TRUE)) {
- extBuilder.addLeaf(null, yangLeaf);
- extBuilder.traverseToParentWithoutValidation();
- }
- }
-
- /**
- * Returns the value of type, after checking the value leaf flag. If the
- * flag is set, then it takes the value else returns null.
- *
- * @param holder leaf holder
- * @param parentObj parent object
- * @param yangLeaf YANG leaf node
- * @param leafType object of leaf type
- * @return value of type
- */
- private String getLeafValueFromValueSetFlag(YangSchemaNode holder, Object parentObj,
- YangLeaf yangLeaf, Object leafType) {
-
- String valueOfLeaf;
- try {
- valueOfLeaf = isValueOrSelectLeafSet(holder, parentObj,
- getJavaName(yangLeaf),
- IS_LEAF_VALUE_SET_METHOD);
- } catch (NoSuchMethodException e) {
- throw new YtbException(e);
- }
- if (valueOfLeaf.equals(TRUE)) {
- return getStringFromType(holder, parentObj,
- getJavaName(yangLeaf), leafType,
- yangLeaf.getDataType());
- }
- return null;
- }
-
- /**
- * Returns the node info which can be processed, by eliminating the nodes
- * which need not to be processed at normal conditions such as RPC,
- * notification and augment.
- *
- * @param curNode current node
- * @return info of node which needs processing
- */
- private YtbTraversalInfo getProcessableInfo(YangNode curNode) {
- if (curNode.getNextSibling() != null) {
- YangNode sibling = curNode.getNextSibling();
- while (isNonProcessableNode(sibling)) {
- sibling = sibling.getNextSibling();
- }
- if (sibling != null) {
- return new YtbTraversalInfo(sibling, SIBLING);
- }
- }
- return new YtbTraversalInfo(curNode.getParent(), PARENT);
- }
-
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbException.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbException.java
deleted file mode 100644
index 1023ca9..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ytb;
-
-/**
- * Represents exception that needs to be handled by YTB.
- */
-public class YtbException extends RuntimeException {
-
- /**
- * Creates YTB exception with an exception message.
- *
- * @param exceptionMessage message with which exception must be thrown
- */
- public YtbException(String exceptionMessage) {
- super(exceptionMessage);
- }
-
- /**
- * Creates YTB exception with the cause for it.
- *
- * @param cause cause of the exception
- */
- public YtbException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbNodeInfo.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbNodeInfo.java
deleted file mode 100644
index 045192d..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbNodeInfo.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ytb;
-
-import org.onosproject.yangutils.datamodel.YangAugment;
-
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Represents YTB node info for all the nodes that are added to the YDT
- * builder tree.Contains the information which can be attached and retrieved
- * back from YDT while walking.
- */
-public class YtbNodeInfo {
-
- /**
- * Object of the corresponding YANG construct. This object is bound to
- * each and every YDT node. So, whenever walk of parent and sibling
- * happens, object can be retrieved from its YDT node.
- */
- private Object yangObject;
-
- /**
- * The list iterator since first content of the multi instance node is
- * faced. With this iterator the node can be walked multiple times till
- * it becomes empty.
- */
- private Iterator<Object> listIterator;
-
- /**
- * The current YTB node's, list of augments are iterated through this
- * iterator. Every time an augment is built completely, this iterator
- * gives the next augment node until it becomes empty.
- */
- private Iterator<YangAugment> augmentNodeItr;
-
- /**
- * The map with case object as value and choice node name as key is added
- * for the current YTB info. Every time a case schema node comes, it takes
- * this map and checks if it is present.
- */
- private Map<String, Object> choiceCaseMap;
-
- /**
- * When the case finds its object in map, it assigns it to case object of
- * the YTB info, so when its child wants to take the parent object, they
- * can take from the YTB info's case object.
- */
- private Object caseObject;
-
- /**
- * When the augment object is present, it assigns it to augment object of
- * the YTB info, so when its child wants to take the parent object, they
- * can take from the YTB info's augment object.
- */
- private Object augmentObject;
-
- /**
- * Constructs a default YTB node info.
- */
- public YtbNodeInfo() {
- }
-
- /**
- * Returns the object of the YANG schema node.
- *
- * @return YANG node object
- */
- public Object getYangObject() {
- return yangObject;
- }
-
- /**
- * Sets the object of the YANG schema node.
- *
- * @param yangObject YANG node object
- */
- public void setYangObject(Object yangObject) {
- this.yangObject = yangObject;
- }
-
- /**
- * Returns the current list iterator of the YANG schema node.
- *
- * @return current list iterator for the schema node
- */
- public Iterator<Object> getListIterator() {
- return listIterator;
- }
-
- /**
- * Sets the current list iterator of the YANG schema node.
- *
- * @param listIterator current list iterator for the schema node
- */
- public void setListIterator(Iterator<Object> listIterator) {
- this.listIterator = listIterator;
- }
-
- /**
- * Returns the map of choice schema name and case object.
- *
- * @return choice name and case object map
- */
- public Map<String, Object> getChoiceCaseMap() {
- return choiceCaseMap;
- }
-
- /**
- * Sets the map of choice schema name and case object.
- *
- * @param choiceCaseMap choice name and case object map
- */
- public void setChoiceCaseMap(Map<String, Object> choiceCaseMap) {
- this.choiceCaseMap = choiceCaseMap;
- }
-
- /**
- * Returns the case object.
- *
- * @return case object
- */
- public Object getCaseObject() {
- return caseObject;
- }
-
- /**
- * Sets the case node object.
- *
- * @param caseObject case node object
- */
- public void setCaseObject(Object caseObject) {
- this.caseObject = caseObject;
- }
-
- /**
- * Returns the augment node object.
- *
- * @return augment node object
- */
- public Object getAugmentObject() {
- return augmentObject;
- }
-
- /**
- * Sets the augment node object.
- *
- * @param augmentObject augment node object
- */
- public void setAugmentObject(Object augmentObject) {
- this.augmentObject = augmentObject;
- }
-
- /**
- * Returns the current list iterator of the YANG augment node.
- *
- * @return augment node iterator
- */
- public Iterator<YangAugment> getAugmentIterator() {
- return augmentNodeItr;
- }
-
- /**
- * Sets the current list iterator of the YANG augment node.
- *
- * @param augmentNodeItr augment node iterator
- */
- public void setAugmentIterator(Iterator<YangAugment> augmentNodeItr) {
- this.augmentNodeItr = augmentNodeItr;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbTraversalInfo.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbTraversalInfo.java
deleted file mode 100644
index a1ea640..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbTraversalInfo.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ytb;
-
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yms.app.utils.TraversalType;
-
-/**
- * Represents YTB Traversal info which is needed every time the traversal of
- * a YANG node happens. This contains YANG node and its corresponding traversal
- * type information.
- */
-public class YtbTraversalInfo {
-
- /**
- * YANG node of the current traversal.
- */
- private YangNode yangNode;
-
- /**
- * Traverse type of the current traversal.
- */
- private TraversalType traverseType;
-
- /**
- * Creates YTB traversal info by taking the traversal type and the YANG
- * node.
- *
- * @param yangNode YANG node
- * @param traverseType traversal type
- */
- public YtbTraversalInfo(YangNode yangNode, TraversalType traverseType) {
- this.yangNode = yangNode;
- this.traverseType = traverseType;
- }
-
- /**
- * Returns the YANG node of the current traversal.
- *
- * @return YANG node
- */
- public YangNode getYangNode() {
- return yangNode;
- }
-
- /**
- * Returns the traversal type of the current traversal.
- *
- * @return traversal type
- */
- public TraversalType getTraverseType() {
- return traverseType;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbUtil.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbUtil.java
deleted file mode 100644
index e9cdd57..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/YtbUtil.java
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ytb;
-
-import org.onosproject.yangutils.datamodel.YangAugment;
-import org.onosproject.yangutils.datamodel.YangCase;
-import org.onosproject.yangutils.datamodel.YangIdentity;
-import org.onosproject.yangutils.datamodel.YangIdentityRef;
-import org.onosproject.yangutils.datamodel.YangLeafRef;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangNotification;
-import org.onosproject.yangutils.datamodel.YangOutput;
-import org.onosproject.yangutils.datamodel.YangRpc;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yangutils.datamodel.YangType;
-import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
-import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer;
-import org.onosproject.yms.app.utils.TraversalType;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Base64;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.onosproject.yangutils.datamodel.YangSchemaNodeType.YANG_AUGMENT_NODE;
-import static org.onosproject.yangutils.datamodel.YangSchemaNodeType.YANG_MULTI_INSTANCE_NODE;
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BOOLEAN;
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.EMPTY;
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT16;
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT32;
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT64;
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT8;
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.LEAFREF;
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT16;
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT32;
-import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT8;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
-import static org.onosproject.yms.app.utils.TraversalType.PARENT;
-
-/**
- * Representation of utility for YANG tree builder.
- */
-public final class YtbUtil {
-
- /**
- * Static attribute for string value having null.
- */
- public static final String STR_NULL = "null";
-
- /**
- * Static attribute for a dot string.
- */
- public static final String PERIOD = ".";
-
- private static final int ONE = 1;
- private static final String YANG = "yang";
- private static final String OP_TYPE = "OpType";
- private static final String STR_NONE = "NONE";
- private static final String ENUM_LEAF_IDENTIFIER = "$LeafIdentifier";
- private static final Set<YangDataTypes> PRIMITIVE_TYPES =
- new HashSet<>(Arrays.asList(INT8, INT16, INT32, INT64, UINT8,
- UINT16, UINT32, BOOLEAN, EMPTY));
- private static final String TO_STRING = "toString";
-
- // No instantiation.
- private YtbUtil() {
- }
-
- /**
- * Returns the object of the node from the node info. Getting object for
- * augment and case differs from other node.
- *
- * @param nodeInfo node info of the holder
- * @param yangNode YANG node of the holder
- * @return object of the parent
- */
- public static Object getParentObjectOfNode(YtbNodeInfo nodeInfo,
- YangNode yangNode) {
- Object object;
- if (yangNode instanceof YangCase) {
- object = nodeInfo.getCaseObject();
- } else if (yangNode instanceof YangAugment) {
- object = nodeInfo.getAugmentObject();
- } else {
- object = nodeInfo.getYangObject();
- }
- return object;
- }
-
- /**
- * Returns the value of an attribute, in a class object. The attribute
- * name is taken from the YANG node java name.
- *
- * @param nodeObj object of the node
- * @param fieldName name of the attribute
- * @return object of the attribute
- * @throws NoSuchMethodException method not found exception
- */
- public static Object getAttributeOfObject(Object nodeObj, String fieldName)
- throws NoSuchMethodException {
- Class<?> nodeClass = nodeObj.getClass();
- Method getterMethod;
- try {
- getterMethod = nodeClass.getDeclaredMethod(fieldName);
- return getterMethod.invoke(nodeObj);
- } catch (InvocationTargetException | IllegalAccessException e) {
- throw new YtbException(e);
- }
- }
-
- /**
- * Returns the object of the declared method in parent class by invoking
- * through the child class object.
- *
- * @param childClass child class which inherits the parent class
- * @param methodName name of the declared method
- * @return value of the method
- */
- public static Object getAttributeFromInheritance(Object childClass,
- String methodName) {
- Class<?> parentClass = childClass.getClass().getSuperclass();
- Method getterMethod;
- try {
- getterMethod = parentClass.getDeclaredMethod(methodName);
- return getterMethod.invoke(childClass);
- } catch (InvocationTargetException | NoSuchMethodException |
- IllegalAccessException e) {
- throw new YtbException(e);
- }
- }
-
- /**
- * Returns interface class from an implementation class object.
- *
- * @param obj implementation class object
- * @return interface class
- */
- public static Class<?> getInterfaceClassFromImplClass(Object obj) {
- Class<?>[] interfaces = obj.getClass().getInterfaces();
- if (interfaces.length > ONE) {
- // TODO: Need to handle when impl class has more than one interface.
- throw new YtbException("Implementation class having more than one" +
- " interface is not handled");
- }
- return interfaces[0];
- }
-
- /**
- * Returns the operation type value for a class object. If the operation
- * type is not set, then none type is returned.
- *
- * @param nodeObj node object
- * @param typeName data type name
- * @return operation type of the class
- */
- public static YdtContextOperationType getNodeOpType(Object nodeObj,
- String typeName) {
- Object opTypeObj;
- try {
- opTypeObj = getAttributeOfObject(nodeObj, typeName);
- } catch (NoSuchMethodException e) {
- return YdtContextOperationType.valueOf(STR_NONE);
- }
- String opTypeValue = String.valueOf(opTypeObj);
- if (opTypeValue.equals(STR_NULL)) {
- return null;
- }
- return YdtContextOperationType.valueOf(opTypeValue);
- }
-
- /**
- * Returns true, if data type of leaf is primitive data type; false
- * otherwise.
- *
- * @param yangType leaf type
- * @return true if data type is primitive; false otherwise
- */
- public static boolean isTypePrimitive(YangType yangType) {
- if (yangType.getDataType() == LEAFREF) {
- YangLeafRef leafRef =
- (YangLeafRef) yangType.getDataTypeExtendedInfo();
- return isPrimitiveDataType(leafRef.getEffectiveDataType()
- .getDataType());
- }
- return isPrimitiveDataType(yangType.getDataType());
- }
-
- /**
- * Returns the registered class from the YSR of the module node where
- * augment is present.
- *
- * @param curNode current augment node
- * @param registry schema registry
- * @return class loader of module
- */
- public static Class<?> getClassLoaderForAugment(
- YangNode curNode, YangSchemaRegistry registry) {
- YangNode moduleNode = curNode.getParent();
- String moduleName = moduleNode.getJavaClassNameOrBuiltInType();
- String modulePackage = moduleNode.getJavaPackage();
- return registry.getRegisteredClass(moduleNode
- );
- }
-
- /**
- * Returns the string true, if the leaf data is actually set; false
- * otherwise.
- *
- * @param holder leaf holder
- * @param nodeObj object if the node
- * @param javaName java name of the leaf
- * @param methodName getter method name
- * @return string value of the boolean method
- * @throws NoSuchMethodException if the method is not present
- */
- public static String isValueOrSelectLeafSet(YangSchemaNode holder, Object nodeObj,
- String javaName, String methodName)
- throws NoSuchMethodException {
-
- Class<?> nodeClass = nodeObj.getClass();
-
- // Appends the enum inner package to the interface class package.
- String enumPackage = holder.getJavaPackage() + PERIOD +
- getCapitalCase(holder.getJavaClassNameOrBuiltInType()) +
- ENUM_LEAF_IDENTIFIER;
-
- ClassLoader classLoader = nodeClass.getClassLoader();
- Class leafEnum;
- try {
- leafEnum = classLoader.loadClass(enumPackage);
- Method getterMethod = nodeClass.getMethod(methodName, leafEnum);
- // Gets the value of the enum.
- Enum<?> value = Enum.valueOf(leafEnum, javaName.toUpperCase());
- // Invokes the method with the value of enum as param.
- return String.valueOf(getterMethod.invoke(nodeObj, value));
- } catch (IllegalAccessException | InvocationTargetException |
- ClassNotFoundException e) {
- throw new YtbException(e);
- }
- }
-
- /**
- * Returns the string value from the respective data types of the
- * leaf/leaf-list.
- *
- * @param holder leaf/leaf-list holder
- * @param holderObj leaf/leaf-list holder object
- * @param name leaf/leaf-list name
- * @param fieldObj object of the leaf/leaf-list field
- * @param dataType type of the leaf/leaf-list
- * @return string value from the type
- */
- public static String getStringFromType(YangSchemaNode holder, Object holderObj,
- String name, Object fieldObj, YangType dataType) {
-
- if (fieldObj == null) {
- throw new YtbException("Value of " + holder.getName() + " is null");
- }
-
- YangDataTypes type = dataType.getDataType();
- switch (type) {
- case INT8:
- case INT16:
- case INT32:
- case INT64:
- case UINT8:
- case UINT16:
- case UINT32:
- case UINT64:
- case EMPTY:
- case STRING:
- case DECIMAL64:
- case INSTANCE_IDENTIFIER:
- case DERIVED:
- case UNION:
- case ENUMERATION:
- case BOOLEAN:
- return String.valueOf(fieldObj).trim();
-
- case BITS:
- return getBitsValue(holder, holderObj, name, fieldObj).trim();
-
- case BINARY:
- return Base64.getEncoder().encodeToString((byte[]) fieldObj);
-
- case IDENTITYREF:
- YangIdentityRef ir =
- (YangIdentityRef) dataType.getDataTypeExtendedInfo();
- if (ir.isInGrouping()) {
- return String.valueOf(fieldObj).trim();
- }
- return getIdentityRefValue(fieldObj, ir, holderObj);
-
- case LEAFREF:
- YangLeafRef leafRef =
- (YangLeafRef) dataType.getDataTypeExtendedInfo();
- return getStringFromType(holder, holderObj, name, fieldObj,
- leafRef.getEffectiveDataType());
-
- default:
- throw new YtbException("Unsupported data type. Cannot be " +
- "processed.");
- }
- }
-
- /**
- * Returns the string values for the data type bits.
- *
- * @param holder leaf/leaf-list holder
- * @param holderObj leaf/leaf-list holder object
- * @param name leaf/leaf-list name
- * @param fieldObj object of the leaf/leaf-list field
- * @return string value for bits type
- */
- private static String getBitsValue(YangSchemaNode holder, Object holderObj,
- String name, Object fieldObj) {
-
- Class<?> holderClass = holderObj.getClass();
- String interfaceName = holder.getJavaClassNameOrBuiltInType();
- String className = interfaceName.toLowerCase() + PERIOD +
- getCapitalCase(name);
- String pkgName = holder.getJavaPackage() + PERIOD + className;
- ClassLoader classLoader = holderClass.getClassLoader();
-
- Class<?> bitClass;
- try {
- bitClass = classLoader.loadClass(pkgName);
- Method getterMethod = bitClass.getDeclaredMethod(
- TO_STRING, fieldObj.getClass());
- return String.valueOf(getterMethod.invoke(null, fieldObj));
- } catch (ClassNotFoundException | NoSuchMethodException |
- InvocationTargetException | IllegalAccessException e) {
- throw new YtbException(e);
- }
- }
-
- /**
- * Returns the string value of the type identity-ref.
- *
- * @param fieldObj object of the leaf/leaf-list field
- * @param ir YANG identity ref
- * @param holderObj leaf/leaf-list holder object
- * @return string value for identity ref type
- */
- private static String getIdentityRefValue(Object fieldObj, YangIdentityRef ir,
- Object holderObj) {
-
- YangIdentity id = ir.getReferredIdentity();
- String idName = id.getJavaClassNameOrBuiltInType();
- String idPkg = id.getJavaPackage() + PERIOD + getCapitalCase(idName);
- String methodName = idName + getCapitalCase(TO_STRING);
-
- Class<?> holderClass = holderObj.getClass();
- ClassLoader classLoader = holderClass.getClassLoader();
- Class<?> idClass;
- try {
- idClass = classLoader.loadClass(idPkg);
- Method method = idClass.getDeclaredMethod(methodName, null);
- return String.valueOf(method.invoke(fieldObj, null)).trim();
- } catch (ClassNotFoundException | NoSuchMethodException |
- InvocationTargetException | IllegalAccessException e) {
- throw new YtbException(e);
- }
- }
-
- /**
- * Returns true, if the data type is primitive; false otherwise.
- *
- * @param dataType data type
- * @return true if the data type is primitive; false otherwise
- */
- private static boolean isPrimitiveDataType(YangDataTypes dataType) {
- return PRIMITIVE_TYPES.contains(dataType);
- }
-
- /**
- * Returns true, if processing of the node is not required; false otherwise.
- * For the nodes such as notification, RPC, augment there is a different
- * flow, so these nodes are skipped in normal conditions.
- *
- * @param yangNode node to be checked
- * @return true if node processing is not required; false otherwise.
- */
- public static boolean isNonProcessableNode(YangNode yangNode) {
- return yangNode != null && (yangNode instanceof YangNotification) ||
- (yangNode instanceof YangRpc) || (yangNode instanceof YangAugment);
- }
-
- /**
- * Returns true, if multi instance node; false otherwise.
- *
- * @param yangNode YANG node
- * @return true, if multi instance node; false otherwise.
- */
- public static boolean isMultiInstanceNode(YangNode yangNode) {
- return yangNode.getYangSchemaNodeType() == YANG_MULTI_INSTANCE_NODE;
- }
-
- /**
- * Returns true, if augment node; false otherwise.
- *
- * @param yangNode YANG node
- * @return true, if augment node; false otherwise.
- */
- public static boolean isAugmentNode(YangNode yangNode) {
- return yangNode.getYangSchemaNodeType() == YANG_AUGMENT_NODE;
- }
-
- /**
- * Returns string for throwing error when empty object is given as input
- * to YTB.
- *
- * @param objName name of the object
- * @return error message
- */
- public static String emptyObjErrMsg(String objName) {
- return "The " + objName + " given for tree creation cannot be null";
- }
-
- /**
- * Returns the java name for the nodes, leaf/leaf-list.
- *
- * @param node YANG node
- * @return node java name
- */
- public static String getJavaName(Object node) {
- return ((JavaLeafInfoContainer) node).getJavaName(null);
- }
-
- /**
- * Returns true, if the list is not null and non-empty; false otherwise.
- *
- * @param c collection object
- * @return true, if the list is not null and non-empty; false otherwise
- */
- public static boolean nonEmpty(Collection<?> c) {
- return c != null && !c.isEmpty();
- }
-
- /**
- * Returns true, if the string is not null and non-empty; false otherwise.
- *
- * @param str string value
- * @return true, if the string is not null and non-empty; false otherwise.
- */
- public static boolean nonEmpty(String str) {
- return str != null && !str.isEmpty();
- }
-
- /**
- * Returns true when the node processing of RPC and notification is
- * completed; false otherwise. For RPC and notification, processing of
- * other nodes are invalid, so once node gets completed, it must be stopped.
- *
- * @param curNode current node
- * @param curTraversal current traversal of the node
- * @return true, if the node processing is completed; false otherwise.
- */
- public static boolean isNodeProcessCompleted(
- YangNode curNode, TraversalType curTraversal) {
- return (curTraversal == PARENT &&
- curNode instanceof YangNotification) ||
- curNode instanceof YangOutput;
- }
-
- /**
- * Returns the name of the operation type variable from the yang name.
- *
- * @param curNode YANG node
- * @return name of operation type
- */
- public static String getOpTypeName(YangNode curNode) {
- return YANG + getCapitalCase(curNode.getJavaClassNameOrBuiltInType()) +
- OP_TYPE;
- }
-}
diff --git a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/package-info.java b/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/package-info.java
deleted file mode 100644
index a3c95a3..0000000
--- a/apps/yms/app/src/main/java/org/onosproject/yms/app/ytb/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides implementation of YANG tree builder. YTB handles creation of YDT
- * from YANG modeled objects.
- */
-package org.onosproject.yms.app.ytb;
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yab/MockYmsManager.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yab/MockYmsManager.java
deleted file mode 100644
index 3fcd5aa..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yab/MockYmsManager.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yab;
-
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.ych.YangCodecHandler;
-import org.onosproject.yms.ych.YangDataTreeCodec;
-import org.onosproject.yms.ych.YangProtocolEncodingFormat;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtResponse;
-import org.onosproject.yms.ydt.YdtWalker;
-import org.onosproject.yms.ydt.YmsOperationType;
-import org.onosproject.yms.ymsm.YmsService;
-import org.onosproject.yms.ynh.YangNotificationService;
-import org.onosproject.yms.ysr.YangModuleIdentifier;
-import org.onosproject.yms.ysr.YangModuleLibrary;
-
-import java.util.List;
-
-/**
- * Represents implementation of YANG application management system manager.
- */
-public class MockYmsManager
- implements YmsService {
-
- YangSchemaRegistry schemaRegistry;
- TestYangSchemaNodeProvider testYangSchemaNodeProvider =
- new TestYangSchemaNodeProvider();
-
- @Override
- public YdtBuilder getYdtBuilder(String logicalRootName,
- String rootNamespace,
- YmsOperationType operationType) {
- testYangSchemaNodeProvider.processSchemaRegistry(new TestManager());
- schemaRegistry = testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
- return new YangRequestWorkBench(logicalRootName, rootNamespace,
- operationType, schemaRegistry, false);
- }
-
- @Override
- public YdtBuilder getYdtBuilder(String logicalRootName,
- String rootNamespace,
- YmsOperationType operationType,
- Object schemaRegistryForYdt) {
- return null;
- }
-
- @Override
- public YdtWalker getYdtWalker() {
- return null;
- }
-
- @Override
- public YdtResponse executeOperation(YdtBuilder operationRequest) {
- YangApplicationBroker requestBroker =
- new YangApplicationBroker(schemaRegistry);
- switch (operationRequest.getYmsOperationType()) {
- case EDIT_CONFIG_REQUEST:
- try {
- return requestBroker.processEdit(operationRequest);
- } catch (CloneNotSupportedException e) {
- }
- break;
- case QUERY_CONFIG_REQUEST:
- case QUERY_REQUEST:
- return requestBroker.processQuery(operationRequest);
- case RPC_REQUEST:
- return requestBroker.processOperation(operationRequest);
- default:
- }
- return null;
- }
-
- @Override
- public YangNotificationService getYangNotificationService() {
- return null;
- }
-
- @Override
- public void registerService(Object appManager, Class<?> yangService,
- List<String> supportedFeatureList) {
- }
-
- @Override
- public void unRegisterService(Object appManager, Class<?> yangService) {
-
- }
-
- @Override
- public YangModuleLibrary getYangModuleLibrary() {
- return null;
- }
-
- @Override
- public String getYangFile(YangModuleIdentifier moduleIdentifier) {
- return null;
- }
-
- @Override
- public void registerDefaultCodec(YangDataTreeCodec defaultCodec,
- YangProtocolEncodingFormat dataFormat) {
- }
-
- @Override
- public YangCodecHandler getYangCodecHandler() {
- return null;
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yab/TestManager.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yab/TestManager.java
deleted file mode 100644
index 182d4ca..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yab/TestManager.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yab;
-
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.Test;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.TestOpParam;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.TestService;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.Cont1;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.DefaultCont1;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.rockthehouse.DefaultRockTheHouseOutput;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.rockthehouse.RockTheHouseInput;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.rockthehouse.RockTheHouseOutput;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.rockthehouse1.RockTheHouse1Input;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.rockthehouse2.DefaultRockTheHouse2Output;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.test.rockthehouse2.RockTheHouse2Output;
-
-/**
- * Implementation of the application management service.
- */
-public class TestManager implements TestService {
-
- Test response;
-
- @Override
- public Test getTest(TestOpParam test) {
- Cont1 cont = new DefaultCont1.Cont1Builder().leaf4("4").build();
- Test response = new TestOpParam.TestBuilder().cont1(cont).build();
- return response;
- }
-
- @Override
- public void setTest(TestOpParam test) {
- response = test;
- }
-
- @Override
- public Test getAugmentedTestCont4(TestOpParam test) {
- Cont1 cont = new DefaultCont1.Cont1Builder().leaf4("4").build();
- Test response = new TestOpParam.TestBuilder().cont1(cont).build();
- return response;
- }
-
- @Override
- public void setAugmentedTestCont4(TestOpParam augmentedTestCont4) {
- response = augmentedTestCont4;
- }
-
- @Override
- public RockTheHouseOutput rockTheHouse(RockTheHouseInput inputVar) {
- return DefaultRockTheHouseOutput.builder().hello("hello").build();
- }
-
-
- @Override
- public void rockTheHouse1(RockTheHouse1Input inputVar) {
- // TODO : to be implemented
- }
-
- @Override
- public RockTheHouse2Output rockTheHouse2() {
- return DefaultRockTheHouse2Output
- .builder().leaf14("14").build();
- }
-
- @Override
- public void rockTheHouse3() {
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yab/YangApplicationBrokerTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yab/YangApplicationBrokerTest.java
deleted file mode 100644
index 8c03d47..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yab/YangApplicationBrokerTest.java
+++ /dev/null
@@ -1,1080 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yab;
-
-import org.junit.Test;
-import org.onosproject.yangutils.datamodel.YangAugment;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtAppContext;
-import org.onosproject.yms.app.ydt.YdtAppNodeOperationType;
-import org.onosproject.yms.app.ydt.YdtNode;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.RPC_REQUEST;
-
-/**
- * Unit test case for YANG application broker.
- */
-public class YangApplicationBrokerTest {
-
- MockYmsManager ymsManager = new MockYmsManager();
-
- /**
- * Returns YANG data tree to check edit operation of container.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForEditOperationWithoutDelete() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test", MERGE);
- defaultYdtBuilder.addChild("cont1", null, MERGE);
- defaultYdtBuilder.addChild("cont2", null, MERGE);
- defaultYdtBuilder.addChild("cont3", null, MERGE);
- defaultYdtBuilder.addLeaf("leaf1", null, "1");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf4", null, "4");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("cont4", null, MERGE);
- defaultYdtBuilder.addChild("cont5", null, MERGE);
- defaultYdtBuilder.addLeaf("leaf9", null, "9");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf10", null, "10");
- return defaultYdtBuilder;
- }
-
- private YangRequestWorkBench buildYdtForKeyLeavesInDeleteTree() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test", MERGE);
- defaultYdtBuilder.addChild("list2", null, MERGE);
- defaultYdtBuilder.addLeaf("leaf5", null, "5");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf6", null, "6");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf7", null, "7");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("cont7", null, DELETE);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check delete operation of container.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForEditOperationWithDelete() {
- String rootName = "rootNode";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test", MERGE);
- defaultYdtBuilder.addChild("cont1", null, MERGE);
- defaultYdtBuilder.addChild("cont2", null, DELETE);
- defaultYdtBuilder.addChild("cont3", null, DELETE);
- defaultYdtBuilder.addLeaf("leaf1", null, "1");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf4", null, "4");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("cont4", null, DELETE);
- defaultYdtBuilder.addChild("cont5", null, DELETE);
- defaultYdtBuilder.addLeaf("leaf9", null, "9");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf10", null, "10");
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check edit operation of list.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForListEditOperationWithoutDelete() {
- String rootName = "listWithoutDelete";
- Set<String> valueSet = new LinkedHashSet<>();
- valueSet.add("10");
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test", MERGE);
- defaultYdtBuilder.addChild("cont1", null, MERGE);
- defaultYdtBuilder.addChild("list1", null, MERGE);
- defaultYdtBuilder.addLeaf("leaf2", null, "2");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf3", null, "3");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf4", null, "4");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("list2", null, MERGE);
- defaultYdtBuilder.addLeaf("leaf5", null, "5");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf6", null, "6");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf7", null, "7");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaflist8", null, valueSet);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf10", null, "10");
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check delete operation of list.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForListEditOperationWithDelete() {
- String rootName = "listWithDelete";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test", MERGE);
- defaultYdtBuilder.addChild("cont1", null, MERGE);
- defaultYdtBuilder.addChild("list1", null, DELETE);
- defaultYdtBuilder.addLeaf("leaf2", null, "2");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf3", null, "3");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf4", null, "4");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("list2", null, DELETE);
- defaultYdtBuilder.addLeaf("leaf5", null, "5");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf6", null, "6");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf10", null, "10");
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check query operation of container.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForQueryOperation() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- QUERY_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("cont1", null);
- defaultYdtBuilder.addChild("cont2", null);
- defaultYdtBuilder.addChild("cont3", null);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("cont4", null);
- defaultYdtBuilder.addChild("cont5", null);
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check query operation of list.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForListQueryOperation() {
- String rootName = "listQuery";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- QUERY_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("cont1", null);
- defaultYdtBuilder.addChild("list1", null);
- defaultYdtBuilder.addLeaf("leaf2", null, "2");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("list2", null);
- defaultYdtBuilder.addLeaf("leaf5", null, "5");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf6", null, "6");
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check delete operation of a node.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtWithOneDeleteNode() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("cont1", null, MERGE);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("cont4", null, DELETE);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf10", null, "10");
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check delete operation of last node.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtWithDeleteNodeAsLastChild() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test", MERGE);
- defaultYdtBuilder.addChild("cont1", null, MERGE);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("list2", null, MERGE);
- defaultYdtBuilder.addLeaf("leaf5", null, "10");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf6", null, "10");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("cont4", null, DELETE);
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to with delete operation of all the nodes.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtWithAllDeleteNode() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test", DELETE);
- defaultYdtBuilder.addChild("cont1", null, DELETE);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("list2", null, DELETE);
- defaultYdtBuilder.addLeaf("leaf5", null, "10");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addLeaf("leaf6", null, "10");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("cont4", null, DELETE);
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check rpc operation with only input.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForRpcWithOnlyInput() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- RPC_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("rock-the-house1", null);
- defaultYdtBuilder.addChild("input", null);
- defaultYdtBuilder.addLeaf("leaf13", null, "5");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check rpc operation with only output.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForRpcWithOnlyOutput() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- RPC_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("rock-the-house2", null);
- defaultYdtBuilder.addChild("output", null);
- defaultYdtBuilder.addLeaf("leaf14", null, "14");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check rpc operation with both input and output.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForRpcWithBothInputOutput() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- RPC_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("rock-the-house", null);
- defaultYdtBuilder.addChild("input", null);
- defaultYdtBuilder.addLeaf("zip-code", null, "5");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.addChild("output", null);
- defaultYdtBuilder.addLeaf("hello", null, "5");
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check rpc operation.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForRpc() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- RPC_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("rock-the-house3", null);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check query operation with multiple level of
- * augment.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForQueryWithMultipleAugment() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- QUERY_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.traverseToParent();
- return defaultYdtBuilder;
- }
-
- /**
- * Returns YANG data tree to check delete operation with multiple level of
- * augment.
- *
- * @return YANG data tree
- */
- private YangRequestWorkBench buildYdtForDeleteWithMultipleAugment() {
- String rootName = "root";
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) ymsManager.getYdtBuilder(rootName, null,
- EDIT_CONFIG_REQUEST);
- defaultYdtBuilder.addChild("test", "ydt.test");
- defaultYdtBuilder.addChild("cont4", null, DELETE);
- defaultYdtBuilder.traverseToParent();
- defaultYdtBuilder.traverseToParent();
- return defaultYdtBuilder;
- }
-
- /**
- * Checks whether YANG data tree and delete tree is correct.
- */
- @Test
- public void validateDeleteTreeOnlyOneNodeInDeleteList()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForEditOperationWithDelete();
- YdtAppContext appContext =
- defaultYdtBuilder.getAppRootNode().getFirstChild();
- YdtContext ydtContext = appContext.getModuleContext();
- List<YdtContext> deleteNodes = appContext.getDeleteNodes();
-
- YdtContext cont1YdtContext;
- YdtContext cont2YdtContext;
- YdtContext cont3YdtContext;
- YdtContext cont4YdtContext;
- YdtContext deleteTree;
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- cont1YdtContext = ydtContext.getFirstChild();
- assertThat(cont1YdtContext.getName(), is("cont1"));
-
- cont2YdtContext = cont1YdtContext.getFirstChild();
- assertThat(cont2YdtContext.getName(), is("cont2"));
-
- cont3YdtContext = cont2YdtContext.getFirstChild();
- assertThat(cont3YdtContext.getName(), is("cont3"));
-
- ydtContext = cont3YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf1"));
- assertThat(ydtContext.getValue(), is("1"));
-
- ydtContext = cont2YdtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf4"));
- assertThat(ydtContext.getValue(), is("4"));
-
- cont4YdtContext = cont1YdtContext.getNextSibling();
- assertThat(cont4YdtContext.getName(), is("cont4"));
-
- ydtContext = cont4YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont5"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf9"));
- assertThat(ydtContext.getValue(), is("9"));
-
- ydtContext = cont4YdtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf10"));
- assertThat(ydtContext.getValue(), is("10"));
-
- // build delete tree
- YangApplicationBroker yab = new YangApplicationBroker(null);
- deleteTree = yab.buildDeleteTree(deleteNodes);
-
- // verify whether delete ydt tree is correct
- assertThat(deleteTree.getFirstChild().getName(), is("test"));
-
- cont1YdtContext = deleteTree.getFirstChild().getFirstChild();
- assertThat(cont1YdtContext.getName(), is("cont1"));
-
- cont2YdtContext = cont1YdtContext.getFirstChild();
- assertThat(cont2YdtContext.getName(), is("cont2"));
-
- cont3YdtContext = cont2YdtContext.getFirstChild();
- assertThat(cont3YdtContext.getName(), is("cont3"));
-
- ydtContext = cont3YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf1"));
- assertThat(ydtContext.getValue(), is("1"));
-
- assertThat(cont2YdtContext.getNextSibling(), nullValue());
-
- cont4YdtContext = cont1YdtContext.getNextSibling();
- assertThat(cont4YdtContext.getName(), is("cont4"));
-
- ydtContext = cont4YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont5"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf9"));
- assertThat(ydtContext.getValue(), is("9"));
-
- assertThat(cont4YdtContext.getNextSibling(), nullValue());
-
- // ydtTree after removing delete nodes
- ydtContext = appContext.getModuleContext();
- assertThat(ydtContext.getName(), is("test"));
-
- cont1YdtContext = ydtContext.getFirstChild();
- assertThat(cont1YdtContext.getName(), is("cont1"));
-
- ydtContext = cont1YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf4"));
- assertThat(ydtContext.getValue(), is("4"));
-
- ydtContext = cont1YdtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf10"));
- assertThat(ydtContext.getValue(), is("10"));
- }
-
- /**
- * Checks whether YANG data tree and delete tree is correct.
- */
- @Test
- public void validateListDeleteTree()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForListEditOperationWithDelete();
- YdtAppContext appContext =
- defaultYdtBuilder.getAppRootNode().getFirstChild();
- YdtContext ydtContext = appContext.getModuleContext();
- List<YdtContext> deleteNodes = appContext.getDeleteNodes();
-
- YdtContext cont1YdtContext;
- YdtContext list1YdtContext;
- YdtContext list2YdtContext;
- YdtContext deleteTree;
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- cont1YdtContext = ydtContext.getFirstChild();
- assertThat(cont1YdtContext.getName(), is("cont1"));
-
- list1YdtContext = cont1YdtContext.getFirstChild();
- assertThat(list1YdtContext.getName(), is("list1"));
-
- ydtContext = list1YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf2"));
- assertThat(ydtContext.getValue(), is("2"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf3"));
- assertThat(ydtContext.getValue(), is("3"));
-
- ydtContext = list1YdtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf4"));
- assertThat(ydtContext.getValue(), is("4"));
-
- list2YdtContext = cont1YdtContext.getNextSibling();
- assertThat(list2YdtContext.getName(), is("list2"));
-
- ydtContext = list2YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf5"));
- assertThat(ydtContext.getValue(), is("5"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf6"));
- assertThat(ydtContext.getValue(), is("6"));
-
- ydtContext = list2YdtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf10"));
- assertThat(ydtContext.getValue(), is("10"));
-
- // build delete tree
- YangApplicationBroker yab = new YangApplicationBroker(null);
- deleteTree = yab.buildDeleteTree(deleteNodes);
-
- assertThat(deleteTree.getFirstChild().getName(), is("test"));
-
- cont1YdtContext = deleteTree.getFirstChild().getFirstChild();
- assertThat(cont1YdtContext.getName(), is("cont1"));
-
- list1YdtContext = cont1YdtContext.getFirstChild();
- assertThat(list1YdtContext.getName(), is("list1"));
-
- ydtContext = list1YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf2"));
- assertThat(ydtContext.getValue(), is("2"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf3"));
- assertThat(ydtContext.getValue(), is("3"));
-
- assertThat(list1YdtContext.getNextSibling(), nullValue());
-
- list2YdtContext = cont1YdtContext.getNextSibling();
- assertThat(list2YdtContext.getName(), is("list2"));
-
- ydtContext = list2YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf5"));
- assertThat(ydtContext.getValue(), is("5"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf6"));
- assertThat(ydtContext.getValue(), is("6"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
-
- // verify whether ydt tree is correct
- ydtContext = appContext.getModuleContext();
- assertThat(ydtContext.getName(), is("test"));
-
- cont1YdtContext = ydtContext.getFirstChild();
- assertThat(cont1YdtContext.getName(), is("cont1"));
-
- ydtContext = cont1YdtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf4"));
- assertThat(ydtContext.getValue(), is("4"));
-
- ydtContext = cont1YdtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf10"));
- assertThat(ydtContext.getValue(), is("10"));
- }
-
- /**
- * Checks whether there is no exception when there is valid edit
- * request.
- */
- @Test
- public void testExecuteEditOperationWithoutDelete()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForEditOperationWithoutDelete();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks whether there is no exception when there is valid delete
- * request.
- */
- @Test
- public void testExecuteEditOperationWithDelete()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForEditOperationWithDelete();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks whether there is no exception when there is valid edit
- * request for list.
- */
- @Test
- public void testExecuteListEditOperationWithoutDelete()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForListEditOperationWithoutDelete();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks whether there is no exception when there is valid delete
- * request for list.
- */
- @Test
- public void testExecuteListEditOperationWithDelete()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForListEditOperationWithDelete();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks whether there is no exception when there is valid query
- * request.
- */
- @Test
- public void testExecuteQueryOperation()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder = buildYdtForQueryOperation();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks whether there is no exception when there is valid query
- * request for list.
- */
- @Test
- public void testExecuteListQueryOperation()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForListQueryOperation();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks whether delete tree is updated correctly.
- */
- @Test
- public void testSiblingsInDeleteTree()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder = buildYdtWithOneDeleteNode();
- YdtAppContext appContext =
- defaultYdtBuilder.getAppRootNode().getFirstChild();
- YdtContext ydtContext = appContext.getModuleContext();
- List<YdtContext> deleteNodes = appContext.getDeleteNodes();
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont1"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("cont4"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf10"));
- assertThat(ydtContext.getValue(), is("10"));
-
- // build delete tree
- YangApplicationBroker yab = new YangApplicationBroker(null);
- YdtContext deleteTree = yab.buildDeleteTree(deleteNodes);
-
- assertThat(deleteTree.getFirstChild().getName(), is("test"));
-
- ydtContext = deleteTree.getFirstChild().getFirstChild();
- assertThat(ydtContext.getName(), is("cont4"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
- assertThat(ydtContext.getPreviousSibling(), nullValue());
-
- ydtContext = appContext.getModuleContext();
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont1"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf10"));
- assertThat(ydtContext.getValue(), is("10"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
- }
-
- /**
- * Checks last child is updated correctly after delete tree is built.
- */
- @Test
- public void testLastChildInYdtTree()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtWithDeleteNodeAsLastChild();
- YdtAppContext appContext =
- defaultYdtBuilder.getAppRootNode().getFirstChild();
- YdtContext ydtContext = appContext.getModuleContext();
- List<YdtContext> deleteNodes = appContext.getDeleteNodes();
- assertThat(YdtAppNodeOperationType.BOTH,
- is(appContext.getOperationType()));
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont1"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("list2"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("cont4"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
-
- // build delete tree
- YangApplicationBroker yab = new YangApplicationBroker(null);
- YdtContext deleteTree = yab.buildDeleteTree(deleteNodes);
-
- assertThat(deleteTree.getFirstChild().getName(), is("test"));
-
- ydtContext = deleteTree.getFirstChild().getFirstChild();
- assertThat(ydtContext.getName(), is("cont4"));
-
- ydtContext = deleteTree.getFirstChild().getLastChild();
- assertThat(ydtContext.getName(), is("cont4"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
- assertThat(ydtContext.getPreviousSibling(), nullValue());
-
- ydtContext = appContext.getModuleContext();
-
- assertThat(ydtContext.getLastChild().getName(), is("list2"));
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont1"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("list2"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
- }
-
- /**
- * Checks YDT tree with all delete nodes.
- */
- @Test
- public void testYdtTreeWithAllDeleteNodes()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder = buildYdtWithAllDeleteNode();
- YdtAppContext appContext =
- defaultYdtBuilder.getAppRootNode().getFirstChild();
- YdtContext ydtContext = appContext.getModuleContext();
- List<YdtContext> deleteNodes = appContext.getDeleteNodes();
-
- assertThat(YdtAppNodeOperationType.DELETE_ONLY,
- is(appContext.getOperationType()));
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont1"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("list2"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("cont4"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
-
- // build delete tree
- YangApplicationBroker yab = new YangApplicationBroker(null);
- YdtContext deleteTree = yab.buildDeleteTree(deleteNodes);
-
- assertThat(deleteTree.getFirstChild().getName(), is("test"));
-
- ydtContext = deleteTree.getFirstChild().getFirstChild();
- assertThat(ydtContext.getName(), is("cont1"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("list2"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("cont4"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
- }
-
- /**
- * Checks whether key leaves are also available when there is delete
- * request for list.
- */
- @Test
- public void testKeyLeavesInDeleteTree() throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder = buildYdtForKeyLeavesInDeleteTree();
-
- YdtAppContext appContext =
- defaultYdtBuilder.getAppRootNode().getFirstChild();
- YdtContext ydtContext = appContext.getModuleContext();
- List<YdtContext> deleteNodes = appContext.getDeleteNodes();
-
- assertThat(YdtAppNodeOperationType.BOTH, is(appContext.getOperationType()));
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("list2"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf5"));
- assertThat(ydtContext.getValue(), is("5"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf6"));
- assertThat(ydtContext.getValue(), is("6"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf7"));
- assertThat(ydtContext.getValue(), is("7"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("cont7"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
-
- // build delete tree
- YangApplicationBroker yab = new YangApplicationBroker(null);
- YdtContext deleteTree = yab.buildDeleteTree(deleteNodes);
-
- assertThat(deleteTree.getFirstChild().getName(), is("test"));
-
- ydtContext = deleteTree.getFirstChild().getFirstChild();
- assertThat(ydtContext.getName(), is("list2"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext, notNullValue());
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext, notNullValue());
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("cont7"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
-
- ydtContext = appContext.getModuleContext();
-
- // verify whether ydt tree is correct
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("list2"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("leaf5"));
- assertThat(ydtContext.getValue(), is("5"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf6"));
- assertThat(ydtContext.getValue(), is("6"));
-
- ydtContext = ydtContext.getNextSibling();
- assertThat(ydtContext.getName(), is("leaf7"));
- assertThat(ydtContext.getValue(), is("7"));
-
- assertThat(ydtContext.getNextSibling(), nullValue());
- }
-
- /**
- * Checks YDT tree and application tree for query request with mutiple
- * augments.
- */
- @Test
- public void testApptreeForQueryWithMultipleAugment()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder = buildYdtForQueryWithMultipleAugment();
- YdtAppContext appContext = defaultYdtBuilder.getAppRootNode()
- .getFirstChild();
- YdtContext ydtNode = appContext.getModuleContext();
- YangNode yangNode = (YangNode) ((YdtNode) ydtNode).getYangSchemaNode();
-
- YangApplicationBroker yab = new YangApplicationBroker(defaultYdtBuilder.
- getYangSchemaRegistry());
- yab.setAugGenMethodSet(defaultYdtBuilder.getAugGenMethodSet());
- yab.processAugmentForChildNode(appContext, yangNode);
-
- assertThat(appContext.getModuleContext().getName(), is("test"));
-
- appContext = appContext.getFirstChild();
-
- String augmentName = ((YangAugment) appContext
- .getAugmentingSchemaNode()).getTargetNode().get(0)
- .getResolvedNode().getJavaClassNameOrBuiltInType();
- assertThat(augmentName, is("cont4"));
-
- assertThat(appContext.getFirstChild(), nullValue());
- assertThat(appContext.getLastChild(), nullValue());
- }
-
- /**
- * Checks whether there is no exception when there is valid query request
- * for data resource with multiple augments.
- */
- @Test
- public void testQueryWithMultipleAugment()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder = buildYdtForQueryWithMultipleAugment();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks whether YDT is updated correctly for delete with multiple augment.
- */
- @Test
- public void testYdtForDeleteWithMultipleAugment()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForDeleteWithMultipleAugment();
- YdtAppContext appContext = defaultYdtBuilder.getAppRootNode()
- .getFirstChild();
-
- YangApplicationBroker yab = new YangApplicationBroker(defaultYdtBuilder.
- getYangSchemaRegistry());
- yab.setAugGenMethodSet(defaultYdtBuilder.getAugGenMethodSet());
- YdtContext deleteTree = yab.buildDeleteTree(appContext.getDeleteNodes());
- yab.processAugmentedNodesForDelete(deleteTree.getFirstChild(),
- appContext);
-
- assertThat(appContext.getModuleContext().getName(), is("test"));
-
- appContext = appContext.getFirstChild();
- String augmentName = ((YangAugment) appContext
- .getAugmentingSchemaNode()).getTargetNode().get(0)
- .getResolvedNode().getJavaClassNameOrBuiltInType();
- assertThat(augmentName, is("cont4"));
-
- assertThat(appContext.getFirstChild(), nullValue());
- assertThat(appContext.getLastChild(), nullValue());
-
- YdtContext ydtContext = deleteTree.getFirstChild();
- assertThat(ydtContext.getName(), is("test"));
-
- ydtContext = ydtContext.getFirstChild();
- assertThat(ydtContext.getName(), is("cont4"));
- }
-
- /**
- * Checks whether there is no exception when there is valid delete request
- * for data resource with multiple augments.
- */
- @Test
- public void testDeleteWithMultipleAugment() {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForDeleteWithMultipleAugment();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks execute operation for rpc request with only output.
- */
- @Test
- public void testRpcWithOutput()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForRpcWithOnlyOutput();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks execute operation for rpc request with only input.
- */
- @Test
- public void testRpcWithInput()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForRpcWithOnlyInput();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks execute operation for rpc request with input and output.
- */
- @Test
- public void testRpcWithInputOutput()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForRpcWithBothInputOutput();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-
- /**
- * Checks execute operation for rpc request without input and
- * output.
- */
- @Test
- public void testRpcWithoutInputOutput()
- throws IOException, CloneNotSupportedException {
- YangRequestWorkBench defaultYdtBuilder =
- buildYdtForRpc();
- ymsManager.executeOperation(defaultYdtBuilder);
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ych/DefaultYangCodecHandlerTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ych/DefaultYangCodecHandlerTest.java
deleted file mode 100644
index 590bbc9..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ych/DefaultYangCodecHandlerTest.java
+++ /dev/null
@@ -1,1604 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ych;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_REQUEST;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.CombinedOpParam;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.AsNum;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.Attributes;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.DefaultAttributes;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.Metric;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.PathId;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.Aigp;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.BgpParameters;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultAigp;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultBgpParameters;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultLocalPref;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultMultiExitDisc;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultOrigin;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultUnrecognizedAttributes;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.LocalPref;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.MultiExitDisc;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.Origin;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.UnrecognizedAttributes;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.aigp.AigpTlv;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.aigp.DefaultAigpTlv;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.DefaultOptionalCapabilities;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.OptionalCapabilities;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.optionalcapabilities.Cparameters;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.optionalcapabilities.DefaultCparameters;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.optionalcapabilities.cparameters.As4BytesCapability;
-import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.optionalcapabilities.cparameters.DefaultAs4BytesCapability;
-import org.onosproject.yang.gen.v1.ych.empty.container.rev20160524.EmptyContainerOpParam;
-import org.onosproject.yang.gen.v1.ych.empty.container.rev20160524.emptycontainer.EmptyContainer;
-import org.onosproject.yang.gen.v1.ych.purchasing.supervisor.rev20160524.YchPurchasingsupervisor.OnosYangOpType;
-import org.onosproject.yang.gen.v1.ych.purchasing.supervisor.rev20160524.YchPurchasingsupervisorOpParam;
-import org.onosproject.yang.gen.v1.ych.purchasing.supervisor.rev20160524.ychpurchasingsupervisor.DefaultYchPurchasingSupervisor;
-import org.onosproject.yang.gen.v1.ych.purchasing.supervisor.rev20160524.ychpurchasingsupervisor.YchPurchasingSupervisor;
-import org.onosproject.yang.gen.v1.ych.purchasing.supervisor.rev20160524.ychpurchasingsupervisor.ychpurchasingsupervisor.DefaultYchIsManager;
-import org.onosproject.yang.gen.v1.ydt.customs.supervisor.rev20160524.CustomssupervisorOpParam;
-import org.onosproject.yang.gen.v1.ydt.material.supervisor.rev20160524.MaterialsupervisorOpParam;
-import org.onosproject.yang.gen.v1.ydt.material.supervisor.rev20160524.materialsupervisor.DefaultSupervisor;
-import org.onosproject.yang.gen.v1.ydt.material.supervisor.rev20160524.materialsupervisor.Supervisor;
-import org.onosproject.yang.gen.v1.ydt.merchandiser.supervisor.rev20160524.MerchandisersupervisorOpParam;
-import org.onosproject.yang.gen.v1.ydt.root.rev20160524.LogisticsManagerOpParam;
-import org.onosproject.yang.gen.v1.ydt.trading.supervisor.rev20160524.TradingsupervisorOpParam;
-import org.onosproject.yms.app.ych.defaultcodecs.YangCodecRegistry;
-import org.onosproject.yms.app.ysr.DefaultYangSchemaRegistry;
-import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider;
-import org.onosproject.yms.ych.YangCompositeEncoding;
-
-/**
- * Unit test case for default codec handler.
- */
-public class DefaultYangCodecHandlerTest {
- private TestYangSchemaNodeProvider testYangSchemaNodeProvider =
- new TestYangSchemaNodeProvider();
- private static final String AM_XML = "Incorrect XML generated: ";
- private static final String AM_OBJ = "Incorrect object generated: ";
- private static final String EMPTY_CONTAINER = "EmptyContainerOpParam";
- private static final String LOGISTIC_MOD = "LogisticsManagerOpParam";
- private static final String MERCHA_MOD = "MerchandisersupervisorOpParam";
- private static final String PURCH_MOD = "YchPurchasingsupervisorOpParam";
-
- /**
- * Returns the xml string for customssupervisor module.
- *
- * @return the xml string for customssupervisor module
- */
- private static String customsXml() {
- return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
- "<supervisor xmlns=\"ydt.customs-supervisor\">" +
- "Customssupervisor</supervisor>" +
- "</filter>";
- }
-
- /**
- * Returns the xml string for purchasesupervisor with empty selection node.
- *
- * @return the xml string for purchasesupervisor with empty selection node
- */
- private static String purchaseXmlEmptySelectionNode() {
- return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
- "<ych-purchasing-supervisor xmlns=\"ych.purchasing-supervisor\">" +
- "<ych-purchasing-specialist/>" +
- "</ych-purchasing-supervisor>" +
- "</filter>";
- }
-
- /**
- * Returns the xml string for merchandisersupervisor module.
- *
- * @return the xml string for merchandisersupervisor module
- */
- private static String merchandXml() {
- return "<config xmlns=\"ydt.root\" " +
- "xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
- "<supervisor xmlns=\"ydt.Merchandiser-supervisor\">" +
- "Merchandisersupervisor</supervisor>" +
- "</config>";
- }
-
- /**
- * Returns the xml string for tradingsupervisor module.
- *
- * @return the xml string for tradingsupervisor module
- */
- private static String tradingXml() {
- return "<config xmlns=\"ydt.root\" " +
- "xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
- "<supervisor xmlns=\"ydt.trading-supervisor\">" +
- "Tradingsupervisor</supervisor>" +
- "</config>";
- }
-
- /**
- * Returns the xml string for customssupervisor module.
- *
- * @return the xml string for customssupervisor module
- */
- private static String customsCompositeXml() {
- return "<filter xmlns=\"ydt.filter-type\">" +
- "<supervisor xmlns=\"ydt.customs-supervisor\">" +
- "Customssupervisor</supervisor></filter>";
- }
-
- /**
- * Returns the xml string for customssupervisor module with filter-type.
- *
- * @return the xml string for customssupervisor module with filter-type
- */
- private static String customsEmptyXml() {
- return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
- "</filter>";
- }
-
- /**
- * Returns the xml string for materialsupervisor module.
- *
- * @return the xml string for materialsupervisor module
- */
- private static String materialXml() {
- return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
- "<supervisor xmlns=\"ydt.material-supervisor\">" +
- "<name>abc1</name><departmentId>xyz1</departmentId>" +
- "</supervisor>" +
- "<supervisor xmlns=\"ydt.material-supervisor\"" +
- "><name>abc2</name><departmentId>xyz2</departmentId>" +
- "</supervisor>" +
- "<supervisor xmlns=\"ydt.material-supervisor\"" +
- "><name>abc3</name><departmentId>xyz3</departmentId>" +
- "</supervisor>" +
- "<supervisor xmlns=\"ydt.material-supervisor\"" +
- "><name>abc4</name><departmentId>xyz4</departmentId>" +
- "</supervisor>" +
- "<supervisor xmlns=\"ydt.material-supervisor\"" +
- "><name>abc5</name><departmentId>xyz5</departmentId>" +
- "</supervisor>" +
- "</filter>";
- }
-
- /**
- * Returns the xml string for EmptyContainer module.
- *
- * @return the xml string for EmptyContainer module
- */
- private static String containerEmptyXml() {
- return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
- "</filter>";
- }
-
- /**
- * Returns the xml string for Combined module.
- *
- * @return the xml string for Combined module
- */
- private static String listTestXml() {
- return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
- "<attributes xmlns=\"ych:combined\">" +
- "<origin><value>123</value></origin>" +
- "<multi-exit-disc><med>456</med></multi-exit-disc>" +
- "<local-pref><pref>23</pref></local-pref>" +
- "<aigp><aigp-tlv><metric>456</metric></aigp-tlv></aigp>" +
- "<unrecognized-attributes><partial>false</partial>" +
- "<transitive>false</transitive><type>1</type>" +
- "<value>QUJD</value></unrecognized-attributes>" +
- "<unrecognized-attributes><partial>true</partial>" +
- "<transitive>true</transitive><type>2</type>" +
- "<value>QUJD</value></unrecognized-attributes>" +
- "<unrecognized-attributes><partial>true</partial>" +
- "<transitive>false</transitive><type>3</type>" +
- "<value>QUJD</value></unrecognized-attributes>" +
- "<unrecognized-attributes><partial>false</partial>" +
- "<transitive>true</transitive><type>4</type>" +
- "<value>QUJD</value></unrecognized-attributes>" +
- "<bgp-parameters><optional-capabilities><c-parameters>" +
- "<as4-bytes-capability><as-number>11</as-number>" +
- "</as4-bytes-capability></c-parameters>" +
- "</optional-capabilities><optional-capabilities>" +
- "<c-parameters><as4-bytes-capability>" +
- "<as-number>22</as-number></as4-bytes-capability>" +
- "</c-parameters></optional-capabilities>" +
- "<optional-capabilities><c-parameters><as4-bytes-capability>" +
- "<as-number>33</as-number></as4-bytes-capability>" +
- "</c-parameters></optional-capabilities></bgp-parameters>" +
- "<bgp-parameters><optional-capabilities><c-parameters>" +
- "<as4-bytes-capability><as-number>11</as-number>" +
- "</as4-bytes-capability></c-parameters>" +
- "</optional-capabilities><optional-capabilities>" +
- "<c-parameters><as4-bytes-capability>" +
- "<as-number>22</as-number></as4-bytes-capability>" +
- "</c-parameters></optional-capabilities>" +
- "<optional-capabilities><c-parameters><as4-bytes-capability>" +
- "<as-number>33</as-number></as4-bytes-capability>" +
- "</c-parameters></optional-capabilities>" +
- "</bgp-parameters></attributes></filter>";
- }
-
- /**
- * Returns the xml string for ych-purchasingsupervisor module.
- *
- * @return the XML string for ych-purchasingsupervisor module
- */
- private static String purchaseXml() {
- return "<config xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" " +
- "xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
- "<ych-purchasing-supervisor xmlns=\"ych.purchasing-supervisor\" " +
- "nc:operation=\"create\">" +
- "<ych-purchasing-specialist>purchasingSpecialist" +
- "</ych-purchasing-specialist>" +
- "<ych-purchasing-support>support</ych-purchasing-support>" +
- "<ych-is-manager/>" +
- "</ych-purchasing-supervisor>" +
- "</config>";
- }
-
- /**
- * Returns the xml string for ych-purchasingsupervisor module with BitSet options.
- *
- * @return the XML string for ych-purchasingsupervisor module
- */
- private static String purchaseXmlOptions(BitSet options) {
- boolean isFirst = true;
-
- StringBuffer sb = new StringBuffer();
- sb.append("<config xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" ");
- sb.append("xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">");
- sb.append("<ych-purchasing-supervisor xmlns=\"ych.purchasing-supervisor\" " +
- "nc:operation=\"create\">");
- sb.append("<ych-purchasing-support>support</ych-purchasing-support>");
- if (options == null || options.isEmpty()) {
- sb.append("<ych-purchasing-options/>");
- } else {
- sb.append("<ych-purchasing-options>");
- for (int i = 0; i < 4; i++) {
- if (options.get(i)) {
- if (isFirst) {
- isFirst = false;
- } else {
- sb.append(' ');
- }
- sb.append("option" + i);
- }
- }
- sb.append("</ych-purchasing-options>");
- }
- sb.append("</ych-purchasing-supervisor>");
- sb.append("</config>");
-
- return sb.toString();
- }
-
- /**
- * Returns the xml string for employeeid module.
- *
- * @return the xml string for employeeid module
- */
- private static String emplyIdXml() {
- return "<config xmlns=\"ydt.root\">" +
- "<employeeid xmlns=\"ydt.employee-id\">" +
- "<employeeid>Employ1</employeeid>" +
- "<employeeid>Employ2</employeeid>" +
- "<employeeid>Employ3</employeeid>" +
- "<employeeid>Employ4</employeeid>" +
- "<employeeid>Employ5</employeeid>" +
- "</employeeid>" +
- "</config>";
- }
-
- /**
- * Returns the xml string for warehousesupervisor module.
- *
- * @return the xml string for warehousesupervisor module
- */
- private static String wareHseXml() {
- return "<config xmlns=\"ydt.root\">" +
- "<warehousesupervisor xmlns=\"ydt.warehouse-supervisor\">" +
- "<supervisor>supervisor1</supervisor>" +
- "<supervisor>supervisor2</supervisor>" +
- "<supervisor>supervisor3</supervisor>" +
- "<supervisor>supervisor4</supervisor>" +
- "<supervisor>supervisor5</supervisor>" +
- "</warehousesupervisor>" +
- "</config>";
- }
-
- /**
- * Returns the xml string for more than one module.
- *
- * @return the xml string for more than one module
- */
- private static String multiModuleXml() {
- return "<config xmlns=\"ydt.root\">" +
- "<customssupervisor xmlns=\"ydt.customs-supervisor\">" +
- "<supervisor>Customssupervisor</supervisor>" +
- "</customssupervisor>" +
- "<merchandisersupervisor xmlns=\"ydt.Merchandiser-supervisor\">" +
- "<supervisor>Merchandisersupervisor</supervisor>" +
- "</merchandisersupervisor>" +
- "<materialsupervisor xmlns=\"ydt.material-supervisor\">" +
- "<supervisor>" +
- "<name>abc1</name>" +
- "<departmentId>xyz1</departmentId>" +
- "</supervisor>" +
- "<supervisor>" +
- "<name>abc2</name>" +
- "<departmentId>xyz2</departmentId>" +
- "</supervisor>" +
- "<supervisor>" +
- "<name>abc3</name>" +
- "<departmentId>xyz3</departmentId>" +
- "</supervisor>" +
- "<supervisor>" +
- "<name>abc4</name>" +
- "<departmentId>xyz4</departmentId>" +
- "</supervisor>" +
- "<supervisor>" +
- "<name>abc5</name>" +
- "<departmentId>xyz5</departmentId>" +
- "</supervisor>" +
- "</materialsupervisor>" +
- "<ych-purchasingsupervisor xmlns=\"ych.purchasing-supervisor\">" +
- "<ych-purchasing-supervisor>" +
- "<ych-purchasing-specialist>purchasingSpecialist" +
- "</ych-purchasing-specialist>" +
- "<ych-purchasing-support>support</ych-purchasing-support>" +
- "</ych-purchasing-supervisor>" +
- "</ych-purchasingsupervisor>" +
- "<warehousesupervisor xmlns=\"ydt.warehouse-supervisor\">" +
- "<supervisor>supervisor1</supervisor>" +
- "<supervisor>supervisor2</supervisor>" +
- "<supervisor>supervisor3</supervisor>" +
- "<supervisor>supervisor4</supervisor>" +
- "<supervisor>supervisor5</supervisor>" +
- "</warehousesupervisor>" +
- "<tradingsupervisor xmlns=\"ydt.trading-supervisor\">" +
- "<supervisor>Tradingsupervisor</supervisor>" +
- "</tradingsupervisor>" +
- "<employeeid xmlns=\"ydt.employee-id\">" +
- "<employeeid>Employ1</employeeid>" +
- "<employeeid>Employ2</employeeid>" +
- "<employeeid>Employ3</employeeid>" +
- "<employeeid>Employ4</employeeid>" +
- "<employeeid>Employ5</employeeid>" +
- "</employeeid>" +
- "</config>";
- }
-
- /**
- * Returns the xml string for more than one module.
- *
- * @return the xml string for more than one module
- */
- private String multipleAppxml() {
- return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\"><supervisor" +
- " xmlns=\"ydt.customs-supervisor\">Customssupervisor" +
- "</supervisor><supervisor xmlns=\"ydt.material-supervisor\"" +
- "><name>abc1</name><departmentId>xyz1</departmentId" +
- "></supervisor><supervisor xmlns=\"ydt.material-supervisor\">" +
- "<name>abc2</name><departmentId>xyz2</departmentId>" +
- "</supervisor><supervisor xmlns=\"ydt" +
- ".material-supervisor\"><name>abc3</name><departmentId>xyz3" +
- "</departmentId></supervisor><supervisor xmlns=\"ydt" +
- ".material-supervisor\"><name>abc4</name><departmentId>xyz4" +
- "</departmentId></supervisor><supervisor xmlns=\"ydt" +
- ".material-supervisor\"><name>abc5</name><departmentId>xyz5" +
- "</departmentId></supervisor></filter>";
- }
-
- /**
- * Unit test case in which verifying xml string for module object with leaf
- * for composite encode.
- */
- @Test
- public void proceessCodecHandlerForCompositeEnc() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry();
-
- // Creating the object
- Object object = CustomssupervisorOpParam.builder()
- .supervisor("Customssupervisor").build();
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- YangCompositeEncoding xml =
- defaultYangCodecHandler
- .encodeCompositeOperation("filter", "ydt.filter-type",
- object, XML, null);
-
- assertNull("customs-super: resource id not null",
- xml.getResourceIdentifier());
- assertEquals(AM_XML + "customs-super: comp res info",
- customsCompositeXml(), xml.getResourceInformation());
-
- // Creating the object
- object = MerchandisersupervisorOpParam.builder()
- .supervisor("Merchandisersupervisor").build();
-
- // Get the xml string and compare
- xml = defaultYangCodecHandler.encodeCompositeOperation("config",
- "ydt.root",
- object, XML,
- null);
- assertNull("merch-super: res id not null", xml.getResourceIdentifier());
- assertEquals(AM_XML + "merch-super: comp res info",
- merchandXml(), xml.getResourceInformation());
-
- // Creating the object
- object = TradingsupervisorOpParam.builder()
- .supervisor("Tradingsupervisor").build();
-
- // Get the xml string and compare
- xml = defaultYangCodecHandler
- .encodeCompositeOperation("config", "ydt.root", object, XML,
- null);
- assertNull("trading-super: res id not null",
- xml.getResourceIdentifier());
- assertEquals(AM_XML + "trading-super: comp res info",
- tradingXml(), xml.getResourceInformation());
- }
-
- /**
- * Unit test case in which verifying xml string for module object with leaf.
- */
- @Test
- public void proceessCodecHandlerForLeaf() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry();
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- Object object = CustomssupervisorOpParam.builder()
- .supervisor("Customssupervisor").build();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- String xml =
- defaultYangCodecHandler.encodeOperation("filter",
- "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
-
- assertEquals(AM_XML + "customs-super: leaf info", customsXml(), xml);
-
- // Creating the object
- object = MerchandisersupervisorOpParam.builder()
- .supervisor("Merchandisersupervisor").build();
- yangModuleList.clear();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- xml = defaultYangCodecHandler.encodeOperation("config", "ydt.root",
- null, yangModuleList,
- XML, null);
- assertEquals(AM_XML + "merchandiser-super: leaf info", merchandXml(),
- xml);
-
- // Creating the object
- object = TradingsupervisorOpParam.builder()
- .supervisor("Tradingsupervisor").build();
- yangModuleList.clear();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- xml = defaultYangCodecHandler.encodeOperation("config", "ydt.root",
- null, yangModuleList,
- XML, null);
- assertEquals(AM_XML + "trading-super: leaf info", tradingXml(), xml);
- }
-
- /**
- * Unit test case in which verifying xml string for module object with
- * empty leaf.
- */
- @Test
- public void proceessCodecHandlerForEmptyLeaf() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry();
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- Object object = CustomssupervisorOpParam.builder().supervisor("")
- .build();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler codecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
-
- assertEquals(AM_XML + "customs-super: leaf is not empty",
- customsEmptyXml(), xml);
- }
-
- /**
- * Unit test case in which verifying xml string for more than one module
- * object.
- */
- @Test
- public void proceessCodecHandlerForMultipleApp() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry();
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- Object object = CustomssupervisorOpParam.builder()
- .supervisor("Customssupervisor").build();
- yangModuleList.add(object);
-
- // Creating the object
- Supervisor supervisor1 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc1").departmentId("xyz1").build();
- Supervisor supervisor2 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc2").departmentId("xyz2").build();
- Supervisor supervisor3 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc3").departmentId("xyz3").build();
- Supervisor supervisor4 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc4").departmentId("xyz4").build();
- Supervisor supervisor5 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc5").departmentId("xyz5").build();
-
- Object object1 = MaterialsupervisorOpParam.builder()
- .addToSupervisor(supervisor1)
- .addToSupervisor(supervisor2)
- .addToSupervisor(supervisor3)
- .addToSupervisor(supervisor4)
- .addToSupervisor(supervisor5).build();
- yangModuleList.add(object1);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler codecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
-
- assertEquals(AM_XML + "for multiple applications",
- multipleAppxml(), xml);
- }
-
- /**
- * Unit test case in which verifying xml string for module object with list.
- */
- @Test
- public void proceessCodecHandlerForList() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- Supervisor supervisor1 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc1").departmentId("xyz1").build();
- Supervisor supervisor2 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc2").departmentId("xyz2").build();
- Supervisor supervisor3 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc3").departmentId("xyz3").build();
- Supervisor supervisor4 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc4").departmentId("xyz4").build();
- Supervisor supervisor5 = new DefaultSupervisor.SupervisorBuilder()
- .name("abc5").departmentId("xyz5").build();
-
- Object object = MaterialsupervisorOpParam.builder()
- .addToSupervisor(supervisor1)
- .addToSupervisor(supervisor2)
- .addToSupervisor(supervisor3)
- .addToSupervisor(supervisor4)
- .addToSupervisor(supervisor5).build();
-
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler codecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
- assertEquals(AM_XML + "material-super: list info", materialXml(), xml);
- }
-
- /**
- * Unit test case in which verifying xml string for module object with
- * empty container.
- */
- @Test
- public void proceessCodecHandlerForEmptyContainer() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- EmptyContainer emptyContainer = EmptyContainerOpParam.builder()
- .emptyContainer();
- Object object = EmptyContainerOpParam.builder()
- .emptyContainer(emptyContainer).build();
-
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler codecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
- assertEquals(AM_XML + "empty-contain: container is not empty",
- containerEmptyXml(), xml);
- }
-
- /**
- * Unit test case in which verifying xml string for module object with list
- * inside list.
- */
- @Test
- public void proceessCodecHandlerForListInsideList() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- PathId pathId = new PathId(123);
- Origin origin = new DefaultOrigin.OriginBuilder().value(pathId)
- .build();
- MultiExitDisc multiExitDisc = new DefaultMultiExitDisc
- .MultiExitDiscBuilder().med(456).build();
- LocalPref localPref = new DefaultLocalPref.LocalPrefBuilder()
- .pref(23).build();
- Metric metric = new Metric(456);
- AigpTlv aigpTlv = new DefaultAigpTlv.AigpTlvBuilder().metric(metric)
- .build();
- Aigp aigp = new DefaultAigp.AigpBuilder().aigpTlv(aigpTlv).build();
-
- UnrecognizedAttributes unrecognizedAttributes1 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(false).transitive(false).type((short) 1)
- .value("ABC".getBytes()).build();
-
- UnrecognizedAttributes unrecognizedAttributes2 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(true).transitive(true).type((short) 2)
- .value("ABC".getBytes())
- .build();
-
- UnrecognizedAttributes unrecognizedAttributes3 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(true).transitive(false).type((short) 3)
- .value("ABC".getBytes())
- .build();
-
- UnrecognizedAttributes unrecognizedAttributes4 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(false).transitive(true).type((short) 4)
- .value("ABC".getBytes()).build();
-
- AsNum asNum1 = new AsNum(11);
- As4BytesCapability as4BytesCapability1 =
- new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
- .asNumber(asNum1).build();
- Cparameters cparameters1 = new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability1)
- .build();
- OptionalCapabilities optionalCapabilities1 =
- new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
- .cParameters(cparameters1).build();
-
- AsNum asNum2 = new AsNum(22);
- As4BytesCapability as4BytesCapability2 =
- new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
- .asNumber(asNum2).build();
- Cparameters cparameters2 = new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability2)
- .build();
- OptionalCapabilities optionalCapabilities2 =
- new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
- .cParameters(cparameters2).build();
-
- AsNum asNum3 = new AsNum(33);
- As4BytesCapability as4BytesCapability3 =
- new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
- .asNumber(asNum3).build();
- Cparameters cparameters3 = new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability3)
- .build();
- OptionalCapabilities optionalCapabilities3 =
- new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
- .cParameters(cparameters3).build();
-
- BgpParameters bgpParameters1 =
- new DefaultBgpParameters.BgpParametersBuilder()
- .addToOptionalCapabilities(optionalCapabilities1)
- .addToOptionalCapabilities(optionalCapabilities2)
- .addToOptionalCapabilities(optionalCapabilities3)
- .build();
-
- AsNum asNum4 = new AsNum(11);
- As4BytesCapability as4BytesCapability4 = new DefaultAs4BytesCapability
- .As4BytesCapabilityBuilder()
- .asNumber(asNum4).build();
- Cparameters cparameters4 = new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability4)
- .build();
- OptionalCapabilities optionalCapabilities4 =
- new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
- .cParameters(cparameters4).build();
-
- AsNum asNum5 = new AsNum(22);
- As4BytesCapability as4BytesCapability5 =
- new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
- .asNumber(asNum5).build();
- Cparameters cparameters5 =
- new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability5)
- .build();
- OptionalCapabilities optionalCapabilities5 =
- new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
- .cParameters(cparameters5).build();
-
- AsNum asNum6 = new AsNum(33);
- As4BytesCapability as4BytesCapability6 =
- new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
- .asNumber(asNum6).build();
- Cparameters cparameters6 =
- new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability6)
- .build();
- OptionalCapabilities optionalCapabilities6 =
- new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
- .cParameters(cparameters6).build();
-
- BgpParameters bgpParameters2 =
- new DefaultBgpParameters.BgpParametersBuilder()
- .addToOptionalCapabilities(optionalCapabilities4)
- .addToOptionalCapabilities(optionalCapabilities5)
- .addToOptionalCapabilities(optionalCapabilities6)
- .build();
-
- Attributes attributes = new DefaultAttributes.AttributesBuilder()
- .origin(origin)
- .multiExitDisc(multiExitDisc)
- .localPref(localPref)
- .aigp(aigp)
- .addToUnrecognizedAttributes(unrecognizedAttributes1)
- .addToUnrecognizedAttributes(unrecognizedAttributes2)
- .addToUnrecognizedAttributes(unrecognizedAttributes3)
- .addToUnrecognizedAttributes(unrecognizedAttributes4)
- .addToBgpParameters(bgpParameters1)
- .addToBgpParameters(bgpParameters2).build();
- Object object = CombinedOpParam.builder().attributes(attributes)
- .build();
-
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler codecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
- assertEquals(AM_XML + "combined: list info", listTestXml(), xml);
- }
-
-// TODO negative scenario will be handled later
- /**
- * Unit test case in which verifying xml string for module object with
- * container.
- */
- @Test
- public void proceessCodecHandlerForContainer() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- YchPurchasingSupervisor supervisor =
- new DefaultYchPurchasingSupervisor
- .YchPurchasingSupervisorBuilder()
- .ychPurchasingSpecialist("purchasingSpecialist")
- .ychPurchasingSupport("support")
- .ychIsManager(DefaultYchIsManager.builder().build())
- .yangYchPurchasingSupervisorOpType(OnosYangOpType.CREATE).build();
- Object object = YchPurchasingsupervisorOpParam.builder()
- .ychPurchasingSupervisor(supervisor).build();
- yangModuleList.add(object);
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler codecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
- String xml = codecHandler.encodeOperation("config", "urn:ietf:params:xml:ns:netconf:base:1.0",
- null, yangModuleList,
- XML, null);
- assertEquals(AM_XML + "puchas-super: container info", purchaseXml(),
- xml);
- }
-
-// /**
-// * Unit test case in which verifying xml string for module object with
-// * leaf list.
-// */
-// @Test
-// public void proceessCodecHandlerForLeafList() {
-// testYangSchemaNodeProvider.processSchemaRegistry(null);
-// DefaultYangSchemaRegistry schemaRegistry =
-// testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-// List<Object> yangModuleList = new ArrayList<>();
-//
-// // Creating the object
-// EmployeeidOpParam.EmployeeidBuilder employeeidBuilder =
-// EmployeeidOpParam.builder();
-// employeeidBuilder.addToEmployeeid("Employ1");
-// employeeidBuilder.addToEmployeeid("Employ2");
-// employeeidBuilder.addToEmployeeid("Employ3");
-// employeeidBuilder.addToEmployeeid("Employ4");
-// employeeidBuilder.addToEmployeeid("Employ5");
-//
-// Object object = employeeidBuilder.build();
-// yangModuleList.add(object);
-//
-// // Get the xml string and compare
-// YangCodecRegistry.initializeDefaultCodec();
-// DefaultYangCodecHandler codecHandler =
-// new DefaultYangCodecHandler(schemaRegistry);
-// String xml = codecHandler.encodeOperation("config", "ydt.root", null,
-// yangModuleList, XML, null);
-// assertEquals(AM_XML + "employ-id: leaf-list info", emplyIdXml(), xml);
-// WarehousesupervisorOpParam.WarehousesupervisorBuilder warehsebldr =
-// WarehousesupervisorOpParam.builder();
-// warehsebldr.addToSupervisor("supervisor1");
-// warehsebldr.addToSupervisor("supervisor2");
-// warehsebldr.addToSupervisor("supervisor3");
-// warehsebldr.addToSupervisor("supervisor4");
-// warehsebldr.addToSupervisor("supervisor5");
-//
-// object = warehsebldr.build();
-// yangModuleList.clear();
-// yangModuleList.add(object);
-//
-//
-// // Get the xml string and compare
-// xml = codecHandler.encodeOperation("config", "ydt.root", null,
-// yangModuleList, XML, null);
-//
-// assertEquals(AM_XML + "warehouse-super: leaf-list info", wareHseXml(),
-// xml);
-// }
-
-// /**
-// * Unit test case in which verifying xml string for multiple module object.
-// */
-// @Test
-// public void proceessCodecHandlerForMultipleModule() {
-// testYangSchemaNodeProvider.processSchemaRegistry(null);
-// DefaultYangSchemaRegistry schemaRegistry =
-// testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-//
-// List<Object> yangModuleList = new ArrayList<>();
-// YangCodecRegistry.initializeDefaultCodec();
-// DefaultYangCodecHandler codecHandler =
-// new DefaultYangCodecHandler(schemaRegistry);
-//
-// // Creating the object for customssupervisor module
-// Object object = CustomssupervisorOpParam.builder()
-// .supervisor("Customssupervisor").build();
-// yangModuleList.add(object);
-//
-// // Creating the object for merchandisersupervisor module
-// object = MerchandisersupervisorOpParam.builder()
-// .supervisor("Merchandisersupervisor").build();
-// yangModuleList.add(object);
-//
-// // Creating the object for materialsupervisor module
-// Supervisor supervisor1 = new DefaultSupervisor.SupervisorBuilder()
-// .name("abc1").departmentId("xyz1").build();
-// Supervisor supervisor2 = new DefaultSupervisor.SupervisorBuilder()
-// .name("abc2").departmentId("xyz2").build();
-// Supervisor supervisor3 = new DefaultSupervisor.SupervisorBuilder()
-// .name("abc3").departmentId("xyz3").build();
-// Supervisor supervisor4 = new DefaultSupervisor.SupervisorBuilder()
-// .name("abc4").departmentId("xyz4").build();
-// Supervisor supervisor5 = new DefaultSupervisor.SupervisorBuilder()
-// .name("abc5").departmentId("xyz5").build();
-//
-// object = MaterialsupervisorOpParam.builder()
-// .addToSupervisor(supervisor1)
-// .addToSupervisor(supervisor2)
-// .addToSupervisor(supervisor3)
-// .addToSupervisor(supervisor4)
-// .addToSupervisor(supervisor5).build();
-//
-// yangModuleList.add(object);
-//
-// // Creating the object for YchPurchasingsupervisor module
-// YchPurchasingSupervisor purSupervisor =
-// new DefaultYchPurchasingSupervisor
-// .YchPurchasingSupervisorBuilder()
-// .ychPurchasingSpecialist("purchasingSpecialist")
-// .ychPurchasingSupport("support").build();
-// object = YchPurchasingsupervisorOpParam.builder()
-// .ychPurchasingSupervisor(purSupervisor).build();
-// yangModuleList.add(object);
-//
-// // Creating the object for warehousesupervisor module
-// WarehousesupervisorOpParam.WarehousesupervisorBuilder warehsebldr =
-// WarehousesupervisorOpParam.builder();
-// warehsebldr.addToSupervisor("supervisor1");
-// warehsebldr.addToSupervisor("supervisor2");
-// warehsebldr.addToSupervisor("supervisor3");
-// warehsebldr.addToSupervisor("supervisor4");
-// warehsebldr.addToSupervisor("supervisor5");
-//
-// object = warehsebldr.build();
-// yangModuleList.add(object);
-//
-// // Creating the object for tradingsupervisor module
-// object = TradingsupervisorOpParam.builder()
-// .supervisor("Tradingsupervisor").build();
-// yangModuleList.add(object);
-//
-// List<String> employeeid = EmployeeidOpParam.builder().employeeid();
-// if (employeeid == null) {
-// employeeid = new ArrayList<>();
-// }
-// employeeid.add("Employ1");
-// employeeid.add("Employ2");
-// employeeid.add("Employ3");
-// employeeid.add("Employ4");
-// employeeid.add("Employ5");
-//
-// // Creating the object for employeeid module
-// object = EmployeeidOpParam.builder().employeeid(employeeid).build();
-// yangModuleList.add(object);
-//
-// // Get the xml string and compare
-// String xml = codecHandler.encodeOperation("config", "ydt.root", null,
-// yangModuleList, XML, null);
-// assertEquals(AM_XML + "multiple: module info", multiModuleXml(), xml);
-// }
-
- /**
- * Unit test case in which verifying object for xml string with config as
- * root name and multiple module.
- */
- @Test
- public void proceessCodecDecodeFunctionForListInsideList() {
- String path = "src/test/resources/ychTestResourceFiles/combinedrootname.xml";
- StringBuilder sb = new StringBuilder();
- String sCurrentLine;
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- try (BufferedReader br = new BufferedReader(new FileReader(path))) {
-
- while ((sCurrentLine = br.readLine()) != null) {
- sb.append(sCurrentLine);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // TODO YOB and YTB need to do some changes for binary
- // Verify the received object list
- /*objectList = defaultYangCodecHandler.decode(sb.toString(),
- XML_ENCODING,
- EDIT_CONFIG_REQUEST);
- Iterator<Object> iterator = objectList.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object.getClass().getSimpleName().equals("CombinedOpParam")) {
- CombinedOpParam combinedOpParam = (CombinedOpParam) object;
-
- PathId pathId = new PathId(123);
- Origin origin = new DefaultOrigin.OriginBuilder()
- .value(pathId).build();
- assertTrue(combinedOpParam.attributes().origin()
- .equals(origin));
-
- MultiExitDisc multiExitDisc = new DefaultMultiExitDisc
- .MultiExitDiscBuilder().med(456).build();
- assertTrue(combinedOpParam.attributes().multiExitDisc()
- .equals(multiExitDisc));
-
- LocalPref localPref = new DefaultLocalPref.LocalPrefBuilder()
- .pref(23).build();
- assertTrue(combinedOpParam.attributes().localPref()
- .equals(localPref));
-
- Metric metric = new Metric(456);
- AigpTlv aigpTlv = new DefaultAigpTlv.AigpTlvBuilder()
- .metric(metric).build();
- Aigp aigp = new DefaultAigp.AigpBuilder().aigpTlv(aigpTlv)
- .build();
- assertTrue(combinedOpParam.attributes().aigp().equals(aigp));
-
- UnrecognizedAttributes unrecognizedAttributes1 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(false).transitive(false).type((short) 1)
- .value("ABC".getBytes()).build();
-
- UnrecognizedAttributes unrecognizedAttributes2 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(true).transitive(true).type((short) 2)
- .value("BCA".getBytes()).build();
-
- UnrecognizedAttributes unrecognizedAttributes3 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(true).transitive(false).type((short) 3)
- .value("CAB".getBytes()).build();
-
- UnrecognizedAttributes unrecognizedAttributes4 =
- new DefaultUnrecognizedAttributes
- .UnrecognizedAttributesBuilder()
- .partial(false).transitive(true).type((short) 4)
- .value("111".getBytes()).build();
-
- AsNum asNum1 = new AsNum(11);
- As4BytesCapability as4BytesCapability1 =
- new DefaultAs4BytesCapability
- .As4BytesCapabilityBuilder()
- .asNumber(asNum1).build();
- Cparameters cparameters1 = new DefaultCparameters
- .CparametersBuilder()
- .as4BytesCapability(as4BytesCapability1)
- .build();
- OptionalCapabilities optionalCapabilities1 =
- new DefaultOptionalCapabilities
- .OptionalCapabilitiesBuilder()
- .cParameters(cparameters1).build();
-
- AsNum asNum2 = new AsNum(22);
- As4BytesCapability as4BytesCapability2 =
- new DefaultAs4BytesCapability
- .As4BytesCapabilityBuilder()
- .asNumber(asNum2).build();
- Cparameters cparameters2 = new DefaultCparameters
- .CparametersBuilder()
- .as4BytesCapability(as4BytesCapability2)
- .build();
- OptionalCapabilities optionalCapabilities2 =
- new DefaultOptionalCapabilities
- .OptionalCapabilitiesBuilder()
- .cParameters(cparameters2).build();
-
- AsNum asNum3 = new AsNum(33);
- As4BytesCapability as4BytesCapability3 =
- new DefaultAs4BytesCapability
- .As4BytesCapabilityBuilder()
- .asNumber(asNum3).build();
- Cparameters cparameters3 =
- new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability3)
- .build();
- OptionalCapabilities optionalCapabilities3 =
- new DefaultOptionalCapabilities
- .OptionalCapabilitiesBuilder()
- .cParameters(cparameters3).build();
-
- BgpParameters bgpParameters1 =
- new DefaultBgpParameters.BgpParametersBuilder()
- .addToOptionalCapabilities(optionalCapabilities1)
- .addToOptionalCapabilities(optionalCapabilities2)
- .addToOptionalCapabilities(optionalCapabilities3)
- .build();
-
- AsNum asNum4 = new AsNum(11);
- As4BytesCapability as4BytesCapability4 =
- new DefaultAs4BytesCapability
- .As4BytesCapabilityBuilder()
- .asNumber(asNum4).build();
- Cparameters cparameters4 =
- new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability4)
- .build();
- OptionalCapabilities optionalCapabilities4 =
- new DefaultOptionalCapabilities
- .OptionalCapabilitiesBuilder()
- .cParameters(cparameters4).build();
-
- AsNum asNum5 = new AsNum(22);
- As4BytesCapability as4BytesCapability5 =
- new DefaultAs4BytesCapability
- .As4BytesCapabilityBuilder()
- .asNumber(asNum5).build();
- Cparameters cparameters5 =
- new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability5)
- .build();
- OptionalCapabilities optionalCapabilities5 =
- new DefaultOptionalCapabilities
- .OptionalCapabilitiesBuilder()
- .cParameters(cparameters5).build();
-
- AsNum asNum6 = new AsNum(33);
- As4BytesCapability as4BytesCapability6 =
- new DefaultAs4BytesCapability
- .As4BytesCapabilityBuilder()
- .asNumber(asNum6).build();
- Cparameters cparameters6 =
- new DefaultCparameters.CparametersBuilder()
- .as4BytesCapability(as4BytesCapability6)
- .build();
- OptionalCapabilities optionalCapabilities6 =
- new DefaultOptionalCapabilities
- .OptionalCapabilitiesBuilder()
- .cParameters(cparameters6).build();
-
- BgpParameters bgpParameters2 =
- new DefaultBgpParameters.BgpParametersBuilder()
- .addToOptionalCapabilities(optionalCapabilities4)
- .addToOptionalCapabilities(optionalCapabilities5)
- .addToOptionalCapabilities(optionalCapabilities6)
- .build();
-
- Attributes attributes =
- new DefaultAttributes.AttributesBuilder()
- .origin(origin)
- .multiExitDisc(multiExitDisc)
- .localPref(localPref)
- .aigp(aigp)
- .addToUnrecognizedAttributes(unrecognizedAttributes1)
- .addToUnrecognizedAttributes(unrecognizedAttributes2)
- .addToUnrecognizedAttributes(unrecognizedAttributes3)
- .addToUnrecognizedAttributes(unrecognizedAttributes4)
- .addToBgpParameters(bgpParameters1)
- .addToBgpParameters(bgpParameters2).build();
- } else {
- assertTrue(false);
- }
- }*/
- }
-
-// /**
-// * Unit test case in which verifying object for xml string with config as root name and
-// * operation type.
-// */
-// @Test
-// public void proceessCodecDecodeFunctionForOperTypeTest() {
-// String path = "src/test/resources/ychTestResourceFiles/configrootnameOperationType.xml";
-// testYangSchemaNodeProvider.processSchemaRegistry(null);
-// DefaultYangSchemaRegistry schemaRegistry =
-// testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-//
-// YangCodecRegistry.initializeDefaultCodec();
-// DefaultYangCodecHandler defaultYangCodecHandler =
-// new DefaultYangCodecHandler(schemaRegistry);
-//
-// StringBuilder sb = new StringBuilder();
-// String sCurrentLine;
-//
-// try (BufferedReader br = new BufferedReader(new FileReader(path))) {
-//
-// while ((sCurrentLine = br.readLine()) != null) {
-// sb.append(sCurrentLine);
-// }
-//
-// } catch (IOException e) {
-// e.printStackTrace();
-// }
-//
-// // Verify the received object list
-// List<Object> objectList =
-// defaultYangCodecHandler.decode(sb.toString(),
-// XML, EDIT_CONFIG_REQUEST);
-// Iterator<Object> iterator = objectList.iterator();
-// while (iterator.hasNext()) {
-// Object object = iterator.next();
-// if (object.getClass().getSimpleName()
-// .equals(LOGISTIC_MOD)) {
-// LogisticsManagerOpParam logistics =
-// (LogisticsManagerOpParam) object;
-// DefaultPurchasingSupervisor purchasingSupervisor =
-// (DefaultPurchasingSupervisor) logistics
-// .purchasingSupervisor();
-//
-// assertEquals(AM_OBJ + "purchase-super: operation type", DELETE,
-// purchasingSupervisor.yangPurchasingSupervisorOpType());
-// assertEquals(AM_OBJ + "customs-super: leaf value", "abc",
-// logistics.customsSupervisor());
-// assertEquals(AM_OBJ + "purchase-spec: leaf value", "bcd",
-// logistics.purchasingSupervisor()
-// .purchasingSpecialist());
-// assertEquals(AM_OBJ + "purchase-support: leaf value",
-// "cde", logistics.purchasingSupervisor()
-// .support());
-//
-// } else if (object.getClass().getSimpleName()
-// .equals(MERCHA_MOD)) {
-// MerchandisersupervisorOpParam merchandisersupervisorOpParam =
-// (MerchandisersupervisorOpParam) object;
-// assertEquals(AM_OBJ + "merchandiser-super: leaf value",
-// "abc", merchandisersupervisorOpParam.supervisor());
-// } else {
-// assertEquals(AM_OBJ, LOGISTIC_MOD, object
-// .getClass().getSimpleName());
-// assertEquals(AM_OBJ, MERCHA_MOD, object
-// .getClass().getSimpleName());
-// }
-// }
-// }
-
- /**
- * Validate the leaf value for purchasing specialist.
- *
- * @param objectList object list
- */
- private void processPurchasingSpecObj(List<Object> objectList) {
- Iterator<Object> iterator = objectList.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if ("LogisticsManagerOpParam".equals(object.getClass().getSimpleName())) {
- LogisticsManagerOpParam logisticsManagerOpParam =
- (LogisticsManagerOpParam) object;
- assertEquals(AM_OBJ + "purchasing-spec: leaf value", "bcd",
- logisticsManagerOpParam.purchasingSupervisor()
- .purchasingSpecialist());
- } else {
- assertEquals(AM_OBJ, "LogisticsManagerOpParam", object
- .getClass().getSimpleName());
- }
- }
- }
-
- /**
- * Validate the leaf value for merchandiser supervisor.
- *
- * @param objectList object list
- */
- private void processMerchandiserObj(List<Object> objectList) {
- Iterator<Object> iterator = objectList.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object.getClass().getSimpleName()
- .equals(MERCHA_MOD)) {
- MerchandisersupervisorOpParam merchandisersupervisorOpParam =
- (MerchandisersupervisorOpParam) object;
- assertEquals(AM_OBJ + "merchandiser-super: leaf value", "abc",
- merchandisersupervisorOpParam.supervisor());
- } else {
- assertEquals(AM_OBJ, MERCHA_MOD, object
- .getClass().getSimpleName());
- }
- }
- }
-
- /**
- * Unit test case in which verifying object for xml string with get and
- * filter as root name.
- */
- @Test
- public void proceessCodecDecodeFunctionForGet() {
- String path = "src/test/resources/ychTestResourceFiles/getrootname.xml";
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- StringBuilder sb = new StringBuilder();
- String sCurrentLine;
-
- try (BufferedReader br = new BufferedReader(new FileReader(path))) {
-
- while ((sCurrentLine = br.readLine()) != null) {
- sb.append(sCurrentLine);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // Verify the received object list
- List<Object> objectList =
- defaultYangCodecHandler.decode(sb.toString(),
- XML, QUERY_REQUEST);
- processPurchasingSpecObj(objectList);
- }
-
- /**
- * Unit test case in which verifying object for xml string with get-config
- * and filter as root name.
- */
- @Test
- public void proceessCodecDecodeFunctionForGetConfig() {
- String path = "src/test/resources/ychTestResourceFiles/getconfigrootname.xml";
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- StringBuilder sb = new StringBuilder();
- String sCurrentLine;
-
- try (BufferedReader br = new BufferedReader(new FileReader(path))) {
-
- while ((sCurrentLine = br.readLine()) != null) {
- sb.append(sCurrentLine);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // Verify the received object list
- List<Object> objectList = defaultYangCodecHandler.decode(
- sb.toString(),
- XML, QUERY_CONFIG_REQUEST);
- processMerchandiserObj(objectList);
- }
-
- /**
- * Unit test case in which verifying object for xml string with data as
- * root name.
- */
- @Test
- public void proceessCodecDecodeFunctionForGetData() {
- String path = "src/test/resources/ychTestResourceFiles/getReply.xml";
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- StringBuilder sb = new StringBuilder();
- String sCurrentLine;
-
- try (BufferedReader br = new BufferedReader(new FileReader(path))) {
-
- while ((sCurrentLine = br.readLine()) != null) {
- sb.append(sCurrentLine);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // Verify the received object list
- List<Object> objectList = defaultYangCodecHandler.decode(
- sb.toString(),
- XML, QUERY_CONFIG_REQUEST);
- processPurchasingSpecObj(objectList);
- }
-
- /**
- * Unit test case in which verifying object for xml string with rpc-reply
- * and data as root name .
- */
- @Test
- public void proceessCodecDecodeFunctionForGetConfigData() {
- String path = "src/test/resources/ychTestResourceFiles/getconfigReply.xml";
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- StringBuilder sb = new StringBuilder();
- String sCurrentLine;
-
- try (BufferedReader br = new BufferedReader(new FileReader(path))) {
-
- while ((sCurrentLine = br.readLine()) != null) {
- sb.append(sCurrentLine);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // Verify the received object list
- List<Object> objectList = defaultYangCodecHandler.decode(sb.toString(),
- XML, null);
- processMerchandiserObj(objectList);
- }
-
- @Test
- public void proceessCodecDecodeFunctionForPresenceContainer() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- // Verify the received object list
- List<Object> objectList = defaultYangCodecHandler.decode(purchaseXml(),
- XML, null);
- assertNotNull(objectList);
- Iterator<Object> iterator = objectList.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object.getClass().getSimpleName().equals(PURCH_MOD)) {
- YchPurchasingsupervisorOpParam purchasingsupervisorOpParam =
- (YchPurchasingsupervisorOpParam) object;
- assertEquals(AM_OBJ + "purchasing-specialist: leaf value", "purchasingSpecialist",
- purchasingsupervisorOpParam.ychPurchasingSupervisor().ychPurchasingSpecialist());
- assertEquals(AM_OBJ + "purchasing-support: leaf value", "support",
- purchasingsupervisorOpParam.ychPurchasingSupervisor().ychPurchasingSupport());
- assertNotNull(AM_OBJ + "purchasing-manager: leaf value",
- purchasingsupervisorOpParam.ychPurchasingSupervisor().ychIsManager());
- } else {
- assertEquals(AM_OBJ, PURCH_MOD, object.getClass().getSimpleName());
- }
- }
- }
-
- @Test
- public void proceessCodecDecodeFunctionForSelectionNode() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- // Verify the received object list
- List<Object> objectList = defaultYangCodecHandler.decode(
- purchaseXmlEmptySelectionNode(), XML, null);
- assertNotNull(objectList);
- Iterator<Object> iterator = objectList.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object.getClass().getSimpleName().equals(PURCH_MOD)) {
- YchPurchasingsupervisorOpParam purchasingsupervisorOpParam =
- (YchPurchasingsupervisorOpParam) object;
- assertNull(AM_OBJ + "purchasing-specialist: leaf value not empty",
- purchasingsupervisorOpParam.
- ychPurchasingSupervisor().ychPurchasingSpecialist());
- } else {
- assertEquals(AM_OBJ, PURCH_MOD, object.getClass().getSimpleName());
- }
- }
- }
-
- @Test
- public void proceessCodecDecodeFunctionForBitmaskContainer() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- BitSet purchaseOptions = new BitSet(4);
- purchaseOptions.set(1); //option1
- purchaseOptions.set(3); //option3
-
- // Verify the received object list
- List<Object> objectList = defaultYangCodecHandler.decode(
- purchaseXmlOptions(purchaseOptions), XML, null);
- assertNotNull(objectList);
- Iterator<Object> iterator = objectList.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object.getClass().getSimpleName().equals(PURCH_MOD)) {
- YchPurchasingsupervisorOpParam purchasingsupervisorOpParam =
- (YchPurchasingsupervisorOpParam) object;
- assertEquals(AM_OBJ + "purchasing-support: leaf value", "support",
- purchasingsupervisorOpParam.ychPurchasingSupervisor().ychPurchasingSupport());
- assertEquals(AM_OBJ + "ych-puchasing-options: leaf value",
- purchaseOptions,
- purchasingsupervisorOpParam.ychPurchasingSupervisor().ychPurchasingOptions());
- } else {
- assertEquals(AM_OBJ, PURCH_MOD, object.getClass().getSimpleName());
- }
- }
- }
-
- @Test
- public void proceessCodecDecodeFunctionForEmptyBitmask() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry schemaRegistry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangCodecRegistry.initializeDefaultCodec();
- DefaultYangCodecHandler defaultYangCodecHandler =
- new DefaultYangCodecHandler(schemaRegistry);
-
- // Verify the received object list
- List<Object> objectList = defaultYangCodecHandler.decode(
- purchaseXmlOptions(null), XML, null);
- assertNotNull(objectList);
- Iterator<Object> iterator = objectList.iterator();
- while (iterator.hasNext()) {
- Object object = iterator.next();
- if (object.getClass().getSimpleName().equals(PURCH_MOD)) {
- YchPurchasingsupervisorOpParam purchasingsupervisorOpParam =
- (YchPurchasingsupervisorOpParam) object;
- assertEquals(AM_OBJ + "purchasing-support: leaf value", "support",
- purchasingsupervisorOpParam.ychPurchasingSupervisor().ychPurchasingSupport());
- assertNull(AM_OBJ + "ych-puchasing-options: leaf value empty",
- purchasingsupervisorOpParam.ychPurchasingSupervisor().ychPurchasingOptions());
- } else {
- assertEquals(AM_OBJ, PURCH_MOD, object.getClass().getSimpleName());
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/AugmentSequenceTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/AugmentSequenceTest.java
deleted file mode 100644
index 720b827..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/AugmentSequenceTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-
-import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.OTHER_EDIT;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.AUGNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.AUGSE;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.augmentSequenceYdt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppLogicalNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppModuleNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class AugmentSequenceTest {
-
- private static final String[] EXPECTED = {
- "Entry Node is augment.",
- "Entry Node is augmentSequence.",
- "Entry Node is l1.",
- "Entry Node is leaf1.",
- "Exit Node is leaf1.",
-
- "Entry Node is c1.",
- "Entry Node is leaf2.",
- "Exit Node is leaf2.",
- "Exit Node is c1.",
-
- "Entry Node is c2.",
- "Entry Node is leaf2.",
- "Exit Node is leaf2.",
- "Exit Node is c2.",
-
- "Exit Node is l1.",
- "Exit Node is augmentSequence.",
- "Exit Node is augment.",
- };
-
- /**
- * Creates and validates sequence of augment in ydt.
- */
- @Test
- public void augmentTest() {
- YangRequestWorkBench ydtBuilder = augmentSequenceYdt();
- validateTree(ydtBuilder);
- validateAppTree(ydtBuilder);
- walkINTree(ydtBuilder, EXPECTED);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // Assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, "augment", null);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "augmentSequence", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "l1", MERGE);
- ydtNode = ydtNode.getFirstChild();
-
- validateLeafContents(ydtNode, "leaf1", "1");
- ydtNode = ydtNode.getNextSibling();
-
- //Augmenting leaf2
- validateNodeContents(ydtNode, "c1", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "leaf2", "2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
-
- //Augmenting leaf3
- validateNodeContents(ydtNode, "c2", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "leaf2", "3");
- }
-
- /**
- * Validates the given built ydt application tree.
- */
- private void validateAppTree(YangRequestWorkBench ydtBuilder) {
-
- // Assign root node to ydtNode for validating purpose.
- YdtAppContext ydtAppContext = ydtBuilder.getAppRootNode();
- // Logical root node does not have operation type
- validateAppLogicalNodeContents(ydtAppContext);
- ydtAppContext = ydtAppContext.getFirstChild();
- validateAppModuleNodeContents(ydtAppContext, "augmentSequence",
- OTHER_EDIT);
- ydtAppContext = ydtAppContext.getFirstChild();
-
- //Inside list checking the first augmented leaf
- validateAppNodeContents(ydtAppContext, AUGSE, AUGNS, OTHER_EDIT);
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/AugmentTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/AugmentTest.java
deleted file mode 100644
index 9846d0a..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/AugmentTest.java
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.BOTH;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.A2L;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.A5L;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.A6L;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.AUG1;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.IETF;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.NETNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.SLINK;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.STP;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.TOPONS;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.augmentNetworkYdt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppLogicalNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppModuleNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafListContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
-import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class AugmentTest {
-
- private Set<String> valueSet = new HashSet();
-
- private static final String[] EXPECTED = {
- "Entry Node is yms-ietf-network.",
- "Entry Node is yms-ietf-network.",
- "Entry Node is networks.",
- "Entry Node is network.",
- "Entry Node is network-id.",
- "Exit Node is network-id.",
- "Entry Node is link.",
- "Entry Node is link-id.",
- "Exit Node is link-id.",
- "Entry Node is source.",
- "Entry Node is source-node.",
- "Exit Node is source-node.",
- "Entry Node is source-tp.",
- "Exit Node is source-tp.",
- "Exit Node is source.",
-
- "Entry Node is destination.",
- "Entry Node is dest-node.",
- "Exit Node is dest-node.",
- "Entry Node is dest-tp.",
- "Exit Node is dest-tp.",
- "Exit Node is destination.",
-
- "Entry Node is supporting-link.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Entry Node is link-ref.",
- "Exit Node is link-ref.",
- "Exit Node is supporting-link.",
-
- "Entry Node is supporting-link.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Entry Node is link-ref.",
- "Exit Node is link-ref.",
- "Exit Node is supporting-link.",
-
- "Entry Node is augment1.",
- "Entry Node is value1.",
- "Exit Node is value1.",
- "Exit Node is augment1.",
-
- "Entry Node is augment2.",
- "Entry Node is key1.",
- "Exit Node is key1.",
- "Entry Node is key2.",
- "Exit Node is key2.",
-
- "Entry Node is augment5.",
-
- "Entry Node is augment6leafList.",
- "Exit Node is augment6leafList.",
-
- "Entry Node is value5.",
- "Exit Node is value5.",
- "Exit Node is augment5.",
-
- "Entry Node is augment5leafList.",
- "Exit Node is augment5leafList.",
-
- "Entry Node is augment3.",
-
- "Entry Node is augment4.",
- "Entry Node is value4.",
- "Exit Node is value4.",
- "Exit Node is augment4.",
-
- "Entry Node is augment5.",
-
- "Entry Node is leaf6.",
- "Exit Node is leaf6.",
-
- "Entry Node is value5.",
- "Exit Node is value5.",
- "Exit Node is augment5.",
-
- "Entry Node is augment6.",
- "Entry Node is value6.",
- "Exit Node is value6.",
- "Exit Node is augment6.",
-
- "Entry Node is value3.",
- "Exit Node is value3.",
- "Exit Node is augment3.",
-
- "Entry Node is augment3leaf.",
- "Exit Node is augment3leaf.",
-
- "Exit Node is augment2.",
-
- "Entry Node is augment2leafList.",
- "Exit Node is augment2leafList.",
-
- "Exit Node is link.",
-
- "Entry Node is supporting-network.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Exit Node is supporting-network.",
- "Entry Node is node.",
- "Entry Node is node-id.",
- "Exit Node is node-id.",
- "Entry Node is t-point.",
- "Entry Node is tp-id.",
- "Exit Node is tp-id.",
-
- "Entry Node is supporting-termination-point.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Entry Node is node-ref.",
- "Exit Node is node-ref.",
- "Entry Node is tp-ref.",
- "Exit Node is tp-ref.",
-
- "Entry Node is augment1.",
- "Entry Node is value1.",
- "Exit Node is value1.",
- "Exit Node is augment1.",
-
- "Entry Node is augment1-leaf.",
- "Exit Node is augment1-leaf.",
-
- "Entry Node is augment2.",
-
- "Entry Node is augment3.",
- "Entry Node is value3.",
- "Exit Node is value3.",
- "Exit Node is augment3.",
-
- "Entry Node is augment4leaf.",
- "Exit Node is augment4leaf.",
-
- "Entry Node is value2.",
- "Exit Node is value2.",
- "Exit Node is augment2.",
- "Entry Node is augment2leafList.",
- "Exit Node is augment2leafList.",
- "Entry Node is augment2leaf.",
- "Exit Node is augment2leaf.",
-
- "Exit Node is supporting-termination-point.",
- "Exit Node is t-point.",
- "Entry Node is supporting-node.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Entry Node is node-ref.",
- "Exit Node is node-ref.",
- "Exit Node is supporting-node.",
-
- "Exit Node is node.",
- // last augmented sibling in network
- "Entry Node is link-id.",
- "Exit Node is link-id.",
-
- "Exit Node is network.",
- "Exit Node is networks.",
- "Entry Node is networks-state.",
- "Entry Node is network.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Entry Node is server-provided.",
- "Exit Node is server-provided.",
- "Exit Node is network.",
- "Exit Node is networks-state.",
- "Exit Node is yms-ietf-network.",
-
- "Entry Node is augmentNetwork.",
- "Entry Node is node.",
- "Entry Node is name.",
- "Exit Node is name.",
- "Entry Node is cont1s.",
- "Entry Node is cont1s.",
- "Entry Node is fine.",
- "Exit Node is fine.",
-
- // augmenting node augment1 under cont1s
- "Entry Node is augment1.",
- "Entry Node is value1.",
- "Exit Node is value1.",
- "Exit Node is augment1.",
-
- "Exit Node is cont1s.",
- "Exit Node is cont1s.",
- "Exit Node is node.",
- "Exit Node is augmentNetwork.",
-
- "Exit Node is yms-ietf-network."
- };
-
- /**
- * Creates and validates ietf network augment ydt.
- */
- @Test
- public void augmentTest() {
- YangRequestWorkBench ydtBuilder = augmentNetworkYdt();
- validateTree(ydtBuilder);
- validateAppTree(ydtBuilder);
- walkINTree(ydtBuilder, EXPECTED);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // Assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, "yms-ietf-network", null);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "yms-ietf-network", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "networks", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "network", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-id", "network1");
- ydtNode = ydtNode.getNextSibling();
-
- // Validating augmented child
- validateNodeContents(ydtNode, "link", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "link-id", "id1");
- ydtNode = ydtNode.getNextSibling();
-
- // Inside source node
- validateNodeContents(ydtNode, "source", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "source-node", "source1");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "source-tp", "source2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
-
- //Inside destination node
- validateNodeContents(ydtNode, "destination", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "dest-node", "dest1");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "dest-tp", "dest2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
-
- //Inside supporting links
- validateNodeContents(ydtNode, SLINK, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network1");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "link-ref", "id2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
-
- //Inside another supporting links instance
- validateNodeContents(ydtNode, SLINK, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network2");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "link-ref", "id3");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
-
- validateNodeContents(ydtNode, "augment1", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "value1", "1");
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "augment2", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "key1", "1");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "key2", "2");
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "augment5", DELETE);
- ydtNode = ydtNode.getFirstChild();
- valueSet.add("1");
- valueSet.add("2");
- validateLeafListContents(ydtNode, A6L, valueSet);
- ydtNode = ydtNode.getNextSibling();
-
- validateLeafContents(ydtNode, "value5", "5");
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateLeafListContents(ydtNode, A5L, valueSet);
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "augment3", MERGE);
- ydtNode = ydtNode.getFirstChild();
-
- validateNodeContents(ydtNode, "augment4", DELETE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "value4", "4");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
-
- validateNodeContents(ydtNode, "augment5", MERGE);
- ydtNode = ydtNode.getFirstChild();
-
- validateLeafContents(ydtNode, "leaf6", "6");
- ydtNode = ydtNode.getNextSibling();
-
- validateLeafContents(ydtNode, "value5", "5");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
-
- validateNodeContents(ydtNode, "augment6", DELETE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "value6", "6");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
-
- validateLeafContents(ydtNode, "value3", "3");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "augment3leaf", "3");
-
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateLeafListContents(ydtNode, A2L, valueSet);
-
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "supporting-network", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network2");
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "node", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "node-id", "node1");
- ydtNode = ydtNode.getNextSibling();
-
- //Inside termination-point
- validateNodeContents(ydtNode, "t-point", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "tp-id", "tp_id1");
- ydtNode = ydtNode.getNextSibling();
-
- validateTerminationPointAugment(ydtNode);
- }
-
- /**
- * Validates the termination point node in given built ydt.
- */
- private void validateTerminationPointAugment(YdtNode ydtNode) {
-
- //Inside supporting-termination-point
- validateNodeContents(ydtNode, STP, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network-ref");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "node-ref", "node-ref");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "tp-ref", "tp-ref");
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "augment1", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "value1", "1");
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "augment1-leaf", "1");
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "augment2", MERGE);
- ydtNode = ydtNode.getFirstChild();
-
- validateNodeContents(ydtNode, "augment3", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "value3", "3");
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "augment4leaf", "4");
-
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "value2", "2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateLeafListContents(ydtNode, A2L, valueSet);
-
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "augment2leaf", "2");
-
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "supporting-node", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network3");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "node-ref", "network4");
-
- ydtNode = ydtNode.getParent().getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "link-id", "id1");
- ydtNode = ydtNode.getParent().getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "networks-state", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "network", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network5");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "server-provided", "true");
- ydtNode = ydtNode.getParent().getParent().getParent();
-
- validateAugmentNetworkModule(ydtNode);
- }
-
- /**
- * Validates the given built ydt for augment network module.
- */
- private void validateAugmentNetworkModule(YdtNode ydtNode) {
-
- ydtNode = ydtNode.getNextSibling();
- //augmenting network module node
- validateNodeContents(ydtNode, "augmentNetwork", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "node", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "name", "node1");
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "cont1s", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "cont1s", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "fine", "leaf");
-
- // checking augmenting node augment1
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "augment1", DELETE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "value1", "1");
- }
-
- /**
- * Validates the given built ydt application tree.
- */
- private void validateAppTree(YangRequestWorkBench ydtBuilder) {
-
- // Assign root node to ydtNode for validating purpose.
- YdtAppContext ydtAppContext = ydtBuilder.getAppRootNode();
- // Logical root node does not have operation type
- validateAppLogicalNodeContents(ydtAppContext);
- ydtAppContext = ydtAppContext.getFirstChild();
- validateAppModuleNodeContents(ydtAppContext, IETF, BOTH);
- ydtAppContext = ydtAppContext.getFirstChild();
-
- //Inside link node
- validateAppNodeContents(ydtAppContext, AUG1, TOPONS, BOTH);
-
- ydtAppContext = ydtAppContext.getParent();
- validateAugmentNetworkAppTree(ydtAppContext);
- }
-
- /**
- * Validates the given built ydt application tree for augmenting network
- * module.
- */
- private void validateAugmentNetworkAppTree(YdtAppContext ydtAppContext) {
-
- ydtAppContext = ydtAppContext.getNextSibling();
- //augmenting network module node
- validateAppModuleNodeContents(ydtAppContext, "augmentNetwork", BOTH);
- ydtAppContext = ydtAppContext.getFirstChild();
- validateAppNodeContents(ydtAppContext, "/node", NETNS, BOTH);
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/EmptyLeafListTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/EmptyLeafListTest.java
deleted file mode 100644
index c7b63f2..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/EmptyLeafListTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafListContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class EmptyLeafListTest {
-
- // Logger list is used for walker testing.
- private final List<String> logger = new ArrayList<>();
-
- private static final String[] EXPECTED = {
- "Entry Node is empty.",
- "Entry Node is EmptyLeafList.",
- "Entry Node is l1.",
- "Exit Node is l1.",
- "Entry Node is l2.",
- "Exit Node is l2.",
- "Entry Node is l3.",
- "Exit Node is l3.",
- "Entry Node is list1.",
- "Exit Node is list1.",
- "Entry Node is list2.",
- "Exit Node is list2.",
- "Entry Node is list3.",
- "Exit Node is list3.",
- "Exit Node is EmptyLeafList.",
- "Exit Node is empty."
- };
-
- /**
- * Creates and validates empty leaf list ydt.
- */
- @Test
- public void emptyListTest() throws IOException {
-
- //TODO need to be handled later
-// YangRequestWorkBench ydtBuilder = emptyLeafListYdt();
-// validateTree(ydtBuilder);
-// walkINTree(ydtBuilder, EXPECTED);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- Set<String> valueSet = new HashSet();
-
- // Assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, "empty", null);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "EmptyLeafList", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "l1", null);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "l2", null);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "l3", null);
- ydtNode = ydtNode.getNextSibling();
-
- validateLeafListContents(ydtNode, "list1", valueSet);
- ydtNode = ydtNode.getNextSibling();
- validateLeafListContents(ydtNode, "list2", valueSet);
- ydtNode = ydtNode.getNextSibling();
- validateLeafListContents(ydtNode, "list3", valueSet);
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/FoodArenaTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/FoodArenaTest.java
deleted file mode 100644
index b7bcddb..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/FoodArenaTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.DELETE_ONLY;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.foodArenaYdt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.getYdtBuilder;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
-import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-
-public class FoodArenaTest {
-
- // Logger list is used for walker testing.
- private final List<String> logger = new ArrayList<>();
-
- private static final String[] EXPECTED = {
- "Entry Node is foodarena.",
- "Entry Node is food.",
- "Entry Node is food.",
- "Entry Node is chocolate.",
- "Exit Node is chocolate.",
- "Exit Node is food.",
- "Exit Node is food.",
- "Exit Node is foodarena."
- };
-
- /**
- * Creates and validates food arena ydt.
- */
- @Test
- public void foodArenaTest() throws IOException {
-
- YangRequestWorkBench ydtBuilder = foodArenaYdt();
- validateTree(ydtBuilder);
- walkINTree(ydtBuilder, EXPECTED);
- }
-
- /**
- * Creates and validates food arena ydt.
- */
- @Test
- public void foodArenaDeleteOperationTest() throws IOException {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder("foodarena", "food", "ydt.food", NONE);
- ydtBuilder.addChild("food", "ydt.food", DELETE);
- YdtAppContext appRootNode = ydtBuilder.getAppRootNode();
- assertEquals(DELETE_ONLY, appRootNode.getFirstChild().getOperationType());
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
- // Assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, "foodarena", null);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "food", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "food", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "chocolate", "dark");
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/IdentityTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/IdentityTest.java
deleted file mode 100644
index 68200f1..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/IdentityTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-import org.onosproject.yms.app.yob.DefaultYobBuilder;
-import org.onosproject.yms.app.ytb.DefaultYangTreeBuilder;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.OTHER_EDIT;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.identityRefYdt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppLogicalNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppModuleNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafListContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REPLY;
-
-public class IdentityTest {
-
- Set<String> valueSet = new HashSet();
-
- private static final String[] EXPECTED = {
- "Entry Node is identityref.",
- "Entry Node is crypto-base.",
- "Entry Node is crypto.",
- "Exit Node is crypto.",
- "Entry Node is abc-zeunion.",
- "Exit Node is abc-zeunion.",
- "Entry Node is level2.",
- "Exit Node is level2.",
- "Entry Node is level3.",
- "Exit Node is level3.",
- "Entry Node is level4.",
- "Exit Node is level4.",
- "Entry Node is abc-type.",
- "Exit Node is abc-type.",
- "Exit Node is crypto-base.",
- "Exit Node is identityref.",
- };
-
- /**
- * Creates and validates identity ref in ydt.
- */
- @Test
- public void identityRefTest() {
- YangRequestWorkBench ydtBuilder = identityRefYdt();
- validateTree(ydtBuilder);
- validateAppTree(ydtBuilder);
- walkINTree(ydtBuilder, EXPECTED);
-
- //TODO need to be handled later
-// validateYangObject(ydtBuilder);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- valueSet.add("crypto-alg");
- // Assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, "identityref", null);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "crypto-base", MERGE);
- ydtNode = ydtNode.getFirstChild();
-
- validateLeafContents(ydtNode, "crypto", "crypto-alg");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "abc-zeunion", "crypto-alg");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "level2", "crypto-alg2");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "level3", "crypto-alg3");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "level4", "crypto-alg3");
- ydtNode = ydtNode.getNextSibling();
- validateLeafListContents(ydtNode, "abc-type", valueSet);
-
- }
-
- /**
- * Validates the given built ydt application tree.
- */
- private void validateAppTree(YangRequestWorkBench ydtBuilder) {
-
- // Assign root node to ydtNode for validating purpose.
- YdtAppContext ydtAppContext = ydtBuilder.getAppRootNode();
- // Logical root node does not have operation type
- validateAppLogicalNodeContents(ydtAppContext);
- ydtAppContext = ydtAppContext.getFirstChild();
- validateAppModuleNodeContents(ydtAppContext, "crypto-base",
- OTHER_EDIT);
- }
-
- /**
- * Creates Ydt from YO using YTB.
- */
- private void validateYangObject(YangRequestWorkBench ydtBuilder) {
-
- YdtContext rootCtx = ydtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
-
- List<Object> list = new LinkedList<>();
- list.add(yangObject);
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) treeBuilder.getYdtBuilderForYo(
- list, "identityref", "ydt.crypto-base",
- EDIT_CONFIG_REPLY, YdtTestUtils
- .getSchemaRegistry());
-
- // Validate the created YDT
- walkINTree(defaultYdtBuilder, EXPECTED);
- validateTree(defaultYdtBuilder);
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/IetfNetworkTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/IetfNetworkTest.java
deleted file mode 100644
index b62ac87..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/IetfNetworkTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-
-import static org.onosproject.yms.app.ydt.YdtTestUtils.ietfNetwork1Ydt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class IetfNetworkTest {
-
- private static final String[] EXPECTED = {
- "Entry Node is yms-ietf-network.",
- "Entry Node is yms-ietf-network.",
- "Entry Node is networks.",
- "Entry Node is network.",
- "Entry Node is network-id.",
- "Exit Node is network-id.",
- "Entry Node is supporting-network.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Exit Node is supporting-network.",
- "Entry Node is node.",
- "Entry Node is node-id.",
- "Exit Node is node-id.",
- "Entry Node is supporting-node.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Entry Node is node-ref.",
- "Exit Node is node-ref.",
- "Exit Node is supporting-node.",
- "Exit Node is node.",
- "Exit Node is network.",
- "Exit Node is networks.",
- "Entry Node is networks-state.",
- "Entry Node is network.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Entry Node is server-provided.",
- "Exit Node is server-provided.",
- "Exit Node is network.",
- "Exit Node is networks-state.",
- "Exit Node is yms-ietf-network.",
- "Exit Node is yms-ietf-network."
- };
-
- /**
- * Creates and validates ietf network ydt.
- */
- @Test
- public void ietfNetwork1Test() {
- YangRequestWorkBench ydtBuilder = ietfNetwork1Ydt();
- validateTree(ydtBuilder);
- walkINTree(ydtBuilder, EXPECTED);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // Assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, "yms-ietf-network", null);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "yms-ietf-network", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "networks", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "network", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-id", "network1");
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "supporting-network", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network2");
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "node", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "node-id", "node1");
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "supporting-node", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network3");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "node-ref", "network4");
-
- ydtNode = ydtNode.getParent().getParent().getParent().getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "networks-state", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "network", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network5");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "server-provided", "true");
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/IetfTopologyTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/IetfTopologyTest.java
deleted file mode 100644
index c1c1fe9..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/IetfTopologyTest.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-
-import static org.onosproject.yms.app.ydt.YdtAppNodeOperationType.OTHER_EDIT;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.AUG1;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.IETF;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.SLINK;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.STP;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.TOPONS;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.ietfNetworkTopologyYdt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppLogicalNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppModuleNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateAppNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class IetfTopologyTest {
-
- private static final String[] EXPECTED = {
- "Entry Node is yms-ietf-network.",
- "Entry Node is yms-ietf-network.",
- "Entry Node is networks.",
- "Entry Node is network.",
- "Entry Node is network-id.",
- "Exit Node is network-id.",
- "Entry Node is link.",
- "Entry Node is link-id.",
- "Exit Node is link-id.",
- "Entry Node is source.",
- "Entry Node is source-node.",
- "Exit Node is source-node.",
- "Entry Node is source-tp.",
- "Exit Node is source-tp.",
- "Exit Node is source.",
-
- "Entry Node is destination.",
- "Entry Node is dest-node.",
- "Exit Node is dest-node.",
- "Entry Node is dest-tp.",
- "Exit Node is dest-tp.",
- "Exit Node is destination.",
-
- "Entry Node is supporting-link.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Entry Node is link-ref.",
- "Exit Node is link-ref.",
- "Exit Node is supporting-link.",
-
- "Entry Node is supporting-link.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Entry Node is link-ref.",
- "Exit Node is link-ref.",
- "Exit Node is supporting-link.",
- "Exit Node is link.",
-
- "Entry Node is supporting-network.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Exit Node is supporting-network.",
- "Entry Node is node.",
- "Entry Node is node-id.",
- "Exit Node is node-id.",
- "Entry Node is t-point.",
- "Entry Node is tp-id.",
- "Exit Node is tp-id.",
-
- "Entry Node is supporting-termination-point.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Entry Node is node-ref.",
- "Exit Node is node-ref.",
- "Entry Node is tp-ref.",
- "Exit Node is tp-ref.",
-
- "Exit Node is supporting-termination-point.",
- "Exit Node is t-point.",
- "Entry Node is supporting-node.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Entry Node is node-ref.",
- "Exit Node is node-ref.",
- "Exit Node is supporting-node.",
-
- "Exit Node is node.",
- // last augmented sibling in network
- "Entry Node is link-id.",
- "Exit Node is link-id.",
-
- "Exit Node is network.",
- "Exit Node is networks.",
- "Entry Node is networks-state.",
- "Entry Node is network.",
- "Entry Node is network-ref.",
- "Exit Node is network-ref.",
- "Entry Node is server-provided.",
- "Exit Node is server-provided.",
- "Exit Node is network.",
- "Exit Node is networks-state.",
- "Exit Node is yms-ietf-network.",
- "Exit Node is yms-ietf-network."
- };
-
- /**
- * Creates and validates ietf network ydt.
- */
- @Test
- public void ietfNetwork1Test() {
- YangRequestWorkBench ydtBuilder = ietfNetworkTopologyYdt();
- validateTree(ydtBuilder);
- validateAppTree(ydtBuilder);
- walkINTree(ydtBuilder, EXPECTED);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // Assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, "yms-ietf-network", null);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "yms-ietf-network", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "networks", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "network", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-id", "network1");
- ydtNode = ydtNode.getNextSibling();
-
- // Validating augmented child
- validateNodeContents(ydtNode, "link", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "link-id", "id1");
- ydtNode = ydtNode.getNextSibling();
-
- // Inside source node
- validateNodeContents(ydtNode, "source", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "source-node", "source1");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "source-tp", "source2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
-
- //Inside destination node
- validateNodeContents(ydtNode, "destination", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "dest-node", "dest1");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "dest-tp", "dest2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
-
- //Inside supporting links
- validateNodeContents(ydtNode, SLINK, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network1");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "link-ref", "id2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
-
- //Inside another supporting links instance
- validateNodeContents(ydtNode, SLINK, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network2");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "link-ref", "id3");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "supporting-network", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network2");
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "node", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "node-id", "node1");
- ydtNode = ydtNode.getNextSibling();
-
- //Inside termination-point
- validateNodeContents(ydtNode, "t-point", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "tp-id", "tp_id1");
- ydtNode = ydtNode.getNextSibling();
-
- //Inside supporting-termination-point
- validateNodeContents(ydtNode, STP, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network-ref");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "node-ref", "node-ref");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "tp-ref", "tp-ref");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "supporting-node", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network3");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "node-ref", "network4");
-
- ydtNode = ydtNode.getParent().getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "link-id", "id1");
- ydtNode = ydtNode.getParent().getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "networks-state", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "network", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "network-ref", "network5");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "server-provided", "true");
- }
-
- /**
- * Validates the given built ydt application tree.
- */
- private void validateAppTree(YangRequestWorkBench ydtBuilder) {
-
- // Assign root node to ydtNode for validating purpose.
- YdtAppContext ydtAppContext = ydtBuilder.getAppRootNode();
- // Logical root node does not have operation type
- validateAppLogicalNodeContents(ydtAppContext);
- ydtAppContext = ydtAppContext.getFirstChild();
- validateAppModuleNodeContents(ydtAppContext, IETF, OTHER_EDIT);
- ydtAppContext = ydtAppContext.getFirstChild();
-
- //Inside link node
- validateAppNodeContents(ydtAppContext, AUG1, TOPONS, OTHER_EDIT);
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/ListTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/ListTest.java
deleted file mode 100644
index 3929855..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/ListTest.java
+++ /dev/null
@@ -1,478 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.E_LEAF;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.E_LIST;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.E_TOPARENT;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.INV;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.LISTNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.LWC;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.getTestYdtBuilder;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.getYdtBuilder;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.listWithContainer1Ydt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.listWithContainer2Ydt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.listWithContainerYdt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.listWithoutContainerYdt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafListContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-import static org.onosproject.yms.ydt.YdtType.SINGLE_INSTANCE_NODE;
-
-public class ListTest {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private Set<String> valueSet = new HashSet();
-
- private static final String[] ERROR = {
- "rootlist is missing some of the keys of listwithcontainer.",
- "Duplicate entry with name invalid.",
- "Some of the key elements are not unique in listwithcontainer.",
- "Too few key parameters in listwithcontainer." +
- " Expected 2; actual 1.",
- "Too many key parameters in listwithcontainer." +
- " Expected 2; actual 3.",
- "Application with name \"" + "invalid\" doesn't exist.",
- "Too many instances of listwithcontainer. Expected maximum " +
- "instances 3.",
- "Duplicate entry found under invalidinterval leaf-list node.",
- "YANG file error : Input value \"string\" is not a valid uint16.",
- "Schema node with name listwithcontainer doesn't exist.",
- "Duplicate entry with name rootlist."
- };
-
- private static final String[] EXPECTED = {
- "Entry Node is list.",
- "Entry Node is rootlist.",
- "Entry Node is listwithoutcontainer.",
- "Entry Node is invalidinterval.",
- "Exit Node is invalidinterval.",
- "Exit Node is listwithoutcontainer.",
- "Exit Node is rootlist.",
- "Exit Node is list."
- };
-
- List<String> keysValueList = new ArrayList<>();
-
- /**
- * Creates and validates rootlist module with listwithoutcontainer node.
- */
- @Test
- public void listwithoutcontainerTest() throws YdtException {
- YangRequestWorkBench ydtBuilder = listWithoutContainerYdt();
- validateTree(ydtBuilder);
- // walker test
- walkINTree(ydtBuilder, EXPECTED);
- }
-
- /**
- * Creates and validates rootlist module with listwithcontainer node
- * using addMultiInstanceChild interface for adding multi instance node.
- */
- @Test
- public void listwithcontainerTest() throws YdtException {
- YangRequestWorkBench ydtBuilder = listWithContainerYdt();
- validateListwithcontainerTree(ydtBuilder);
- }
-
- /**
- * Creates and validates rootlist module with listwithcontainer
- * node using addChild interface for adding multi instance node.
- */
- @Test
- public void listwithcontainer1Test() throws YdtException {
- YangRequestWorkBench ydtBuilder = listWithContainer1Ydt();
- validateListwithcontainerTree(ydtBuilder);
- }
-
- /**
- * Creates and validates rootlist module with multiple instances of
- * listwithcontainer node using addMultiInstanceChild interface for adding
- * multi instance node.
- */
- @Test
- public void listwithcontainer2Test() throws YdtException {
- YangRequestWorkBench ydtBuilder = listWithContainer2Ydt();
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, "list", null);
-
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "rootlist", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "listwithoutcontainer", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, INV, "12");
- }
-
- /**
- * Validates the given list with container built ydt.
- */
- private void validateListwithcontainerTree(
- YangRequestWorkBench ydtBuilder) {
-
- valueSet.add("1");
- valueSet.add("2");
- // assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, "list", null);
-
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "rootlist", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, LWC, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "invalid", "12");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "invalid1", "12");
- ydtNode = ydtNode.getNextSibling();
- validateLeafListContents(ydtNode, INV, valueSet);
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "interface", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, INV, "12");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "invalid", "121");
- }
-
- /**
- * Tests the negative error scenario when application name for ydt is
- * invalid.
- */
- @Test
- public void negative1Test() {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage(ERROR[5]);
- getYdtBuilder("list", "invalid", "ydt.invalid", MERGE);
- }
-
- /**
- * Tests the negative error scenario when list node is not having all
- * key elements.
- */
- @Test
- public void negative2Test() throws YdtException {
-
- YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
- ydtBuilder.addChild(LWC, LISTNS);
- ydtBuilder.addLeaf("invalid", LISTNS, "12");
- ydtBuilder.traverseToParent();
-
- traversToParentErrorMsgValidator(ydtBuilder, ERROR[0]);
- }
-
- /**
- * Tests the negative error scenario when duplicate entry of list node
- * is created.
- */
- @Test
- public void negative3Test() throws YdtException {
- YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
- ydtBuilder.addChild(LWC, LISTNS);
- ydtBuilder.addLeaf("invalid", LISTNS, "12");
- ydtBuilder.traverseToParent();
- leafErrorMsgValidator(ydtBuilder, "invalid", "12", ERROR[1]);
- }
-
- /**
- * Tests the negative error scenario when key elements of list node
- * are not unique.
- */
- @Test
- public void negative4Test() throws YdtException {
- YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
- ydtBuilder.addChild(LWC, LISTNS);
- ydtBuilder.addLeaf("invalid", LISTNS, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("invalid1", LISTNS, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(LWC, LISTNS);
- ydtBuilder.addLeaf("invalid", LISTNS, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("invalid1", LISTNS, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- traversToParentErrorMsgValidator(ydtBuilder, ERROR[2]);
- }
-
- /**
- * Tests the negative error scenario when all key elements of list node
- * are not supplied.
- */
- @Test
- public void negative5Test() throws YdtException {
- keysValueList.clear();
- keysValueList.add("1");
- keysValueList.add("2");
- keysValueList.add("2");
- YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
- listNodeErrorMsgValidator(ydtBuilder, keysValueList, ERROR[4]);
-
- keysValueList.clear();
- keysValueList.add("1");
- ydtBuilder = getTestYdtBuilder(LISTNS);
- listNodeErrorMsgValidator(ydtBuilder, keysValueList, ERROR[3]);
- }
-
- /**
- * Tests the negative error scenario when instances of a list node are
- * created above the allowed limit.
- */
- @Test
- public void negative6Test() throws YdtException {
- keysValueList.clear();
- keysValueList.add("1");
- keysValueList.add("1");
- YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
- ydtBuilder.addMultiInstanceChild(LWC, LISTNS, keysValueList, null);
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(LWC, LISTNS);
- ydtBuilder.addLeaf("invalid", LISTNS, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("invalid1", LISTNS, "121");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(LWC, LISTNS);
- ydtBuilder.addLeaf("invalid", LISTNS, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("invalid1", LISTNS, "1211");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(LWC, LISTNS);
- ydtBuilder.addLeaf("invalid", LISTNS, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("invalid1", LISTNS, "21");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- traversToParentErrorMsgValidator(ydtBuilder, ERROR[6]);
- }
-
- /**
- * Tests the negative error scenario when list node is not having all
- * key elements.
- */
- @Test
- public void negative7Test() throws YdtException {
- YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
- ydtBuilder.addChild(LWC, LISTNS);
- traversToParentErrorMsgValidator(ydtBuilder, ERROR[0]);
- }
-
- /**
- * Tests the negative error scenario when duplicate key entry is created
- * inside leaf-list node.
- */
- @Test
- public void negative8Test() throws YdtException {
- YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
- ydtBuilder.addChild(LWC, LISTNS);
- ydtBuilder.addLeaf("invalid", LISTNS, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("invalid1", LISTNS, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(INV, LISTNS, "12");
- ydtBuilder.traverseToParent();
- leafErrorMsgValidator(ydtBuilder, INV, "12", ERROR[7]);
- }
-
- //TODO negative scenario will be handled later
-// /**
-// * Tests the negative error scenario when string is passed for uint16 type
-// * leaf node.
-// */
-// @Test
-// public void negative9Test() throws YdtException {
-// YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
-// ydtBuilder.addChild(LWC, LISTNS);
-// ydtBuilder.addLeaf("invalid", LISTNS, "12");
-// ydtBuilder.traverseToParent();
-// ydtBuilder.addLeaf("invalid1", LISTNS, "12");
-// ydtBuilder.traverseToParent();
-// leafErrorMsgValidator(ydtBuilder, INV, "string", ERROR[8]);
-// }
-//
-// /**
-// * Tests the negative error scenario when duplicate key entry created
-// * inside a leaf-list node.
-// */
-// @Test
-// public void negative10Test() throws YdtException {
-// valueSet.clear();
-// valueSet.add("1");
-// valueSet.add("2");
-// valueSet.add("12");
-// YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
-// ydtBuilder.addChild(LWC, LISTNS);
-// ydtBuilder.addLeaf("invalid", LISTNS, "12");
-// ydtBuilder.traverseToParent();
-// ydtBuilder.addLeaf("invalid1", LISTNS, "12");
-// ydtBuilder.traverseToParent();
-// ydtBuilder.addLeaf(INV, LISTNS, "12");
-// ydtBuilder.traverseToParent();
-// thrown.expect(IllegalArgumentException.class);
-// thrown.expectMessage(ERROR[7]);
-// ydtBuilder.addLeaf(INV, LISTNS, valueSet);
-// }
-
-// /**
-// * Tests the negative error scenario when string is passed for uint16 type
-// * key entry inside a leaf-list node.
-// */
-// @Test
-// public void negative11Test() throws YdtException {
-// valueSet.clear();
-// valueSet.add("string");
-// YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
-// ydtBuilder.addChild(LWC, LISTNS);
-// ydtBuilder.addLeaf("invalid", LISTNS, "12");
-// ydtBuilder.traverseToParent();
-// ydtBuilder.addLeaf("invalid1", LISTNS, "12");
-// ydtBuilder.traverseToParent();
-// ydtBuilder.addLeaf(INV, LISTNS, "12");
-// ydtBuilder.traverseToParent();
-// thrown.expect(DataTypeException.class);
-// thrown.expectMessage(ERROR[8]);
-// ydtBuilder.addLeaf(INV, LISTNS, valueSet);
-// }
-
- /**
- * Tests the negative error scenario when list node addition requested
- * with single instance request type.
- */
- @Test
- public void negative12Test() {
- YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage(ERROR[9]);
- ydtBuilder.addChild(LWC, LISTNS, SINGLE_INSTANCE_NODE, MERGE);
- }
-
- /**
- * Tests the negative error scenario when application with requested
- * name is already part of tree.
- */
- @Test
- public void negative13Test() {
- YangRequestWorkBench ydtBuilder = getTestYdtBuilder(LISTNS);
- ydtBuilder.traverseToParent();
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage(ERROR[10]);
- ydtBuilder.addChild("rootlist", LISTNS, MERGE);
- }
-
- /**
- * Validate the error message obtained by adding multi instance node in
- * current context against the given error string.
- *
- * @param bldr ydt builder
- * @param list list of key values
- * @param error error string
- */
- private void listNodeErrorMsgValidator(YangRequestWorkBench bldr,
- List<String> list, String error) {
- /*
- * This try catch is explicitly written to use as utility in other
- * test cases.
- */
- boolean isExpOccurred = false;
- try {
- bldr.addMultiInstanceChild(LWC, LISTNS, list, null);
- } catch (IllegalArgumentException e) {
- isExpOccurred = true;
- assertEquals(e.getMessage(), error);
- }
- assertEquals(E_LIST + LWC, isExpOccurred, true);
- }
-
- /**
- * Validate the error message obtained by traversing back to parent of
- * current context against the given error string.
- *
- * @param ydtBuilder ydt builder
- * @param error error string
- */
- private void traversToParentErrorMsgValidator(
- YangRequestWorkBench ydtBuilder, String error) {
- /*
- * This try catch is explicitly written to use as utility in other
- * test cases.
- */
- boolean isExpOccurred = false;
- try {
- ydtBuilder.traverseToParent();
- } catch (IllegalStateException e) {
- isExpOccurred = true;
- assertEquals(e.getMessage(), error);
- }
- assertEquals(E_TOPARENT, isExpOccurred, true);
- }
-
- /**
- * Validate the error message obtained by adding leaf node in
- * current context against the given error string.
- *
- * @param bldr ydt builder
- * @param name name of the leaf
- * @param val leaf value
- * @param error error string
- */
- private void leafErrorMsgValidator(
- YangRequestWorkBench bldr, String name, String val, String error) {
- /*
- * This try catch is explicitly written to use as utility in other
- * test cases.
- */
- boolean isExpOccurred = false;
- try {
- bldr.addLeaf(name, LISTNS, val);
- } catch (IllegalArgumentException e) {
- isExpOccurred = true;
- assertEquals(e.getMessage(), error);
- }
- assertEquals(E_LEAF + name, isExpOccurred, true);
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/LogisticsManagerTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/LogisticsManagerTest.java
deleted file mode 100644
index e56a128..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/LogisticsManagerTest.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.onosproject.yms.app.ydt.YdtTestUtils.logisticsManagerYdt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafListContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class LogisticsManagerTest {
-
- // Logger list is used for walker testing.
- private final List<String> logger = new ArrayList<>();
-
- private Set<String> valueSet = new HashSet();
-
- private static final String[] EXPECTED = {
- "Entry Node is logisticsmanager.",
- "Entry Node is customssupervisor.",
- "Entry Node is supervisor.",
- "Exit Node is supervisor.",
- "Exit Node is customssupervisor.",
- "Entry Node is merchandisersupervisor.",
- "Entry Node is supervisor.",
- "Exit Node is supervisor.",
- "Exit Node is merchandisersupervisor.",
- "Entry Node is materialsupervisor.",
- "Entry Node is supervisor.",
- "Entry Node is name.",
- "Exit Node is name.",
- "Entry Node is departmentId.",
- "Exit Node is departmentId.",
- "Exit Node is supervisor.",
- "Entry Node is supervisor.",
- "Entry Node is name.",
- "Exit Node is name.",
- "Entry Node is departmentId.",
- "Exit Node is departmentId.",
- "Exit Node is supervisor.",
- "Exit Node is materialsupervisor.",
- "Entry Node is purchasingsupervisor.",
- "Entry Node is supervisor.",
- "Entry Node is purchasing-specialist.",
- "Exit Node is purchasing-specialist.",
- "Entry Node is support.",
- "Exit Node is support.",
- "Exit Node is supervisor.",
- "Exit Node is purchasingsupervisor.",
- "Entry Node is warehousesupervisor.",
- "Entry Node is supervisor.",
- "Exit Node is supervisor.",
- "Exit Node is warehousesupervisor.",
- "Entry Node is tradingsupervisor.",
- "Entry Node is supervisor.",
- "Exit Node is supervisor.",
- "Exit Node is tradingsupervisor.",
- "Entry Node is employeeid.",
- "Entry Node is employeeid.",
- "Exit Node is employeeid.",
- "Exit Node is employeeid.",
- "Exit Node is logisticsmanager."
- };
-
- /**
- * Creates and validates logistics manager ydt.
- */
- @Test
- public void logisticsManagerTest() {
- YangRequestWorkBench ydtBuilder = logisticsManagerYdt();
- validateTree(ydtBuilder);
- // walker test
- walkINTree(ydtBuilder, EXPECTED);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
- valueSet.add("1");
- valueSet.add("2");
- valueSet.add("3");
- valueSet.add("4");
- valueSet.add("5");
- // assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, "logisticsmanager", null);
-
- ydtNode = ydtNode.getFirstChild();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, "customssupervisor", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "supervisor", "abc");
-
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "merchandisersupervisor", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "supervisor", "abc");
-
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "materialsupervisor", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "supervisor", MERGE);
-
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "name", "abc");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "departmentId", "xyz");
-
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "supervisor", MERGE);
-
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "name", "ab");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "departmentId", "xy");
-
- ydtNode = ydtNode.getParent().getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "purchasingsupervisor", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "supervisor", MERGE);
-
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "purchasing-specialist", "abc");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "support", "xyz");
-
- ydtNode = ydtNode.getParent().getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "warehousesupervisor", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafListContents(ydtNode, "supervisor", valueSet);
-
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "tradingsupervisor", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "supervisor", "abc");
-
- ydtNode = ydtNode.getParent();
-
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "employeeid", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafListContents(ydtNode, "employeeid", valueSet);
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/RpcTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/RpcTest.java
deleted file mode 100644
index 68894aa..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/RpcTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.onosproject.yms.app.ydt.YdtTestUtils.helloOnos;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.walkINTree;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class RpcTest {
-
- // Logger list is used for walker testing.
- private final List<String> logger = new ArrayList<>();
-
- private static final String[] EXPECTED = {
- "Entry Node is Hello-ONOS.",
- "Entry Node is Hello_ONOS.",
- "Entry Node is hello-world.",
- "Entry Node is input.",
- "Entry Node is name.",
- "Exit Node is name.",
- "Entry Node is surName.",
- "Exit Node is surName.",
- "Entry Node is stringList.",
- "Entry Node is string1.",
- "Exit Node is string1.",
- "Entry Node is string2.",
- "Exit Node is string2.",
- "Exit Node is stringList.",
- "Exit Node is input.",
- "Exit Node is hello-world.",
- "Exit Node is Hello_ONOS.",
- "Exit Node is Hello-ONOS."
- };
-
- /**
- * Creates and validates hello onos ydt.
- */
- @Test
- public void rpc1Test() {
- YangRequestWorkBench ydtBuilder = helloOnos();
- validateTree(ydtBuilder);
- // walker test
- walkINTree(ydtBuilder, EXPECTED);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, "Hello-ONOS", null);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "Hello_ONOS", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "hello-world", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "input", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "name", "onos");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "surName", "yang");
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "stringList", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "string1", "ON");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "string2", "LAB");
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtBitTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtBitTest.java
deleted file mode 100644
index ac60f21..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtBitTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-
-import static org.onosproject.yms.app.ydt.YdtTestUtils.bitYdt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class YdtBitTest {
-
- /*
- BINARY
-
- Positive scenario
- input with position 0
- input with position 1
- input with position 2
- */
-
- /**
- * Creates and validates bit ydt covering different positive scenario.
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench ydtBuilder = bitYdt();
- validateTree(ydtBuilder);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, "builtInType", null);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "bit", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "bitList", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "bit", "disable-nagle");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "bitList", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "bit", "auto-sense-speed");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "bitList", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "bit", "ten-Mb-only");
- }
-
- //TODO negative scenario will be handled later
-// /*
-// Negative scenario
-//
-// input with position 0
-// input with position 1
-// input with position 2
-// */
-//
-// /**
-// * Tests all the negative scenario's for bit data type.
-// */
-// @Test
-// public void negativeTest() {
-// validateErrMsg("bit", BITNS, "0", BIT, "bitList");
-// validateErrMsg("bit", BITNS, "default", BIT, "bitList");
-// validateErrMsg("bit", BITNS, "1", BIT, "bitList");
-// validateErrMsg("bit", BITNS, "", BIT, "bitList");
-// }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtBooleanTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtBooleanTest.java
deleted file mode 100644
index 2d38f78..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtBooleanTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-
-import static org.onosproject.yms.app.ydt.YdtTestUtils.booleanYdt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class YdtBooleanTest {
-
- /*
- BOOLEAN
- Positive scenario
- input with in "booleanList" and false
- */
-
- /**
- * Creates and validates boolean ydt covering different positive scenario.
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench ydtBuilder = booleanYdt();
- validateTree(ydtBuilder);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, "builtInType", null);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "bool", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "booleanList", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "boolean", "true");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "booleanList", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "boolean", "false");
- }
-
- //TODO negative scenario will be handled later
-// /*
-// Negative scenario
-//
-// input with in non zero value in case of "booleanList"
-// input with zero value in case of false
-// input with empty value in case of false
-// */
-//
-// /**
-// * Tests all the negative scenario's for boolean data type.
-// */
-// @Test
-// public void negativeTest() {
-// validateErrMsg("boolean", BOOLNS, "10", BOOL, "booleanList");
-// validateErrMsg("boolean", BOOLNS, "0", BOOL, "booleanList");
-// validateErrMsg("boolean", BOOLNS, "", BOOL, "booleanList");
-// validateErrMsg("boolean", BOOLNS, "-1", BOOL, "booleanList");
-// validateErrMsg("boolean", BOOLNS, "tru", BOOL, "booleanList");
-// validateErrMsg("boolean", BOOLNS, "boolean", BOOL, "booleanList");
-// }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtDecimal64Test.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtDecimal64Test.java
deleted file mode 100644
index 69fffb0..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtDecimal64Test.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-
-import static org.onosproject.yms.app.ydt.YdtTestConstants.A;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.B;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.C;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.E;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.F;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.G;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.H;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MINIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MRV;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.NIWMF;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.NWF;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.PIWMF;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.PWF;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.decimal64Ydt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class YdtDecimal64Test {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- /*
-
- Positive scenario
-
- input at boundary for decimal64 with fraction 2
- i. min value
- ii. max value
-
- input at boundry for decimal64 with minimum fraction
- i. min value
- ii. mid value
- iii. max value
-
- input at boundry for decimal64 with maximum fraction
- i. min value
- ii. mid value
- iii. max value
-
- input with in range
- if range is 10 to 100 for integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- input with multi interval range
- if range is 10..40 | 50..100 for decimal64
- i.1. input 11
- i.2. input 10
- i.3. input 40
- i.4. input 50
- i.5. input 55
- i.6. input 100
-
- if range is "min .. 3.14 | 10 | 20..max" for decimal64
- i.1. input min
- i.2. input 2.505
- i.3. input 3.14
- i.4. input 10
- i.5. input 20
- i.6. input 92233720368547757
- i.7. input 92233720368547758.07
-
- */
-
- /**
- * Creates and validates decimal64 ydt covering different positive scenario.
- */
- @Test
- public void positiveTest() throws YdtException {
- YangRequestWorkBench ydtBuilder = decimal64Ydt();
- validateTree(ydtBuilder);
-
- //TODO need to be handled later
-// YangRequestWorkBench sbiYdt = validateYangObject(
-// ydtBuilder, "builtInType", "ydt.decimal64");
-// validateTree(sbiYdt);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, TYPE, null);
-
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "decimal64", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "negInt", C);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "posInt", A);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, NIWMF, F);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, PIWMF, G);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, NWF, H);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, PWF, E);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MIDIWR, "11");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MINIWR, "10");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MAXIWR, "100");
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "decimal", "11");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "decimal", "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "decimal", "40");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "decimal", "50");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "decimal", "55");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "decimal", "100");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revDecimal", C);
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revDecimal", "2.505");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revDecimal", "3.14");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revDecimal", "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revDecimal", "20");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revDecimal", B);
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revDecimal", A);
- }
-
- //TODO negative scenario will be handled later
- /*
- Negative scenario
-
- input with position 0
- input with position 1
- input with position 2
- */
-
-// /**
-// * Tests all the negative scenario's for bit data type.
-// */
-// @Test
-// public void negativeTest() {
-// thrown.expect(IllegalArgumentException.class);
-// thrown.expectMessage(E_D64);
-// YangRequestWorkBench ydtBuilder;
-// ydtBuilder = getYdtBuilder("builtInType", "decimal64", "ydt.decimal64",
-// MERGE);
-// ydtBuilder.addLeaf("l1", null, "-9.1999999999e17");
-// ydtBuilder.traverseToParent();
-// }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtEmptyTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtEmptyTest.java
deleted file mode 100644
index e7ca320..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtEmptyTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-
-import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.emptyTypeYdt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class YdtEmptyTest {
-
- /*
- EMPTY
- Positive scenario
- input with in empty.
- */
-
- /**
- * Creates and validates empty ydt covering different positive scenario.
- */
- @Test
- public void positiveTest() throws YdtException {
- YangRequestWorkBench ydtBuilder = emptyTypeYdt();
- validateTree(ydtBuilder);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, TYPE, null);
-
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "emptydata", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "emptyList", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "empty", "");
- }
-
- //TODO negative scenario will be handled later
-// /*
-// Negative scenario
-//
-// input with " "
-// input with "tab"
-// input with """"
-// */
-//
-// /**
-// * Tests all the negative scenario's for empty data type.
-// */
-// @Test
-// public void negativeTest() throws YdtException {
-// validateErrMsg("empty", EMPTYNS, " ", EMPTY, "emptyList");
-// validateErrMsg("empty", EMPTYNS, " ", EMPTY, "emptyList");
-// validateErrMsg("empty", EMPTYNS, " ", EMPTY, "emptyList");
-// }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtEnumTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtEnumTest.java
deleted file mode 100644
index 3c71ede..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtEnumTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-
-import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.enumYdt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class YdtEnumTest {
-
-/*
- ENUM
-
- Positive scenario
-
- input with in enum
- input with "ten"
- input with "hundred"
- input with "thousand"
-*/
-
- /**
- * Creates and validates enum ydt covering different positive scenario.
- */
- @Test
- public void positiveTest() throws YdtException {
- YangRequestWorkBench ydtBuilder = enumYdt();
- validateTree(ydtBuilder);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, TYPE, null);
-
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "enumtest", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "enumList", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "enumleaf", "ten");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "enumList", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "enumleaf", "hundred");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, "enumList", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "enumleaf", "thousand");
- }
-
- //TODO negative scenario will be handled later
-// /*
-// Negative scenario
-//
-// input with "10"
-// input with "thousands"
-// */
-//
-// /**
-// * Tests all the negative scenario's for enum data type.
-// */
-// @Test
-// public void negativeTest() throws YdtException {
-// validateErrMsg("enumleaf", ENUMNS, "10", ENUM, "enumList");
-// validateErrMsg("enumleaf", ENUMNS, "thousands", ENUM, "enumList");
-// validateErrMsg("enumleaf", ENUMNS, "enumeration", ENUM, "enumList");
-// }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtInteger16Test.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtInteger16Test.java
deleted file mode 100644
index ceb5e89..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtInteger16Test.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDUIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MINIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MINUIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MRV;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.RUI;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.integer16Ydt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class YdtInteger16Test {
-
- /*
- Positive scenario
-
- input at boundry for integer
- i. min value
- ii. max value
-
- input at boundry for uinteger
- i. min value
- ii. max value
-
- input with in range
- if range is 10 to 100 for integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- if range is 10 to 100 for uinteger
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- input with multi interval range
- if range is 10..40 | 50..100 for integer
- i.1. input 11
- i.2. input 10
- i.3. input 40
- i.4. input 50
- i.5. input 55
- i.6. input 100
-
- if range is 10..40 | 50..100 for uinteger
- i.1. input 11
- i.2. input 10
- i.3. input 40
- i.4. input 50
- i.5. input 55
- i.6. input 100
-
- if range is "min .. 2 | 10 | 20..max" for integer
- i.1. input -32768
- i.2. input 1
- i.3. input 2
- i.4. input 10
- i.5. input 20
- i.6. input 100
- i.7. input 32767
-
- if range is "min .. 2 | 10 | 20..max" for uInteger
- i.1. input 0
- i.2. input 1
- i.3. input 2
- i.4. input 10
- i.5. input 20
- i.6. input 100
- i.7. input 65535
- */
-
- /**
- * Creates and validates integer16 ydt covering different positive scenario.
- */
- @Test
- public void positiveTest() throws YdtException {
- YangRequestWorkBench ydtBuilder = integer16Ydt();
- validateTree(ydtBuilder);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, TYPE, null);
-
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "integer16", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "negInt", "-32768");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "posInt", "32767");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "minUInt", "0");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "maxUInt", "65535");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MIDIWR, "11");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MINIWR, "10");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MAXIWR, "100");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MIDUIWR, "11");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MINUIWR, "10");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MAXUIWR, "100");
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "11");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "40");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "50");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "55");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "100");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "11");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "40");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "50");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "55");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "100");
-
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "-32768");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "1");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
-
- validate1Tree(ydtNode);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validate1Tree(YdtNode ydtNode) {
-
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "20");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "100");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "32767");
-
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "0");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "1");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "20");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "100");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "65535");
- }
-
- //TODO negative scenario will be handled later
- /*
- Negative scenario
-
- wrong type input
- i. input string instead of integer
- ii. input string instead of uinteger
-
- input out of range
- i. input for int 8 range -32768 to 32767
- i.1. input -32769
- i.2. input 32768
-
- ii. input for uint 8 range 0 to 65535
- ii.1. input -32769
- ii.2. input 65536
-
- input out of range parameter
- if range is 10 to 100 for int
- i.1. input 9
- i.2. input 101
-
- if range is 10 to 100 for uInt
- i.1. input 9
- i.2. input 101
-
- input with multi interval range
- if range is 10..40 | 50..100 for integer
- i.1. input 9
- i.2. input 41
- i.3. input 49
- i.4. input 101
-
- if range is 10..40 | 50..100 for uinteger
- i.1. input 9
- i.2. input 41
- i.3. input 49
- i.4. input 101
-
- input with multi interval range
- if range is min .. | 10 | 20..max for integer
- i.1. input -32769
- i.2. input 4
- i.3. input 9
- i.4. input 11
- i.5. input 19
- i.6. input 32768
-
- if range is min .. 3 | 10 | 20..max for uinteger
- i.1. input -32769
- i.2. input 4
- i.3. input 9
- i.4. input 11
- i.5. input 19
- i.6. input 65536
-
- */
-
- /**
- * Tests all the minimum and maximum value's negative scenario's for
- * signed integer16 data type.
- */
-// @Test
-// public void negative1Test() throws YdtException {
-// validateErrMsg("posInt", INT16NS, "integer", SINT16, null);
-// validateErrMsg("posInt", INT16NS, "127.0", SINT16, null);
-// validateErrMsg("negInt", INT16NS, "-32769", SINT16, null);
-// validateErrMsg("posInt", INT16NS, "32768", SINT16, null);
-// validateErrMsg(MINIWR, INT16NS, "9", CAPSINT16, null);
-// validateErrMsg(MAXIWR, INT16NS, "101", CAPSINT16, null);
-// }
-//
-// /**
-// * Tests all the minimum and maximum value's negative scenario's for
-// * unsigned integer16 data type.
-// */
-// @Test
-// public void negative2Test() throws YdtException {
-// validateErrMsg("maxUInt", INT16NS, "integer", SUINT16, null);
-// validateErrMsg("maxUInt", INT16NS, "127.0", SUINT16, null);
-// validateErrMsg("minUInt", INT16NS, "-32769", MINVALUE, null);
-// validateErrMsg("maxUInt", INT16NS, "65536", MAXUINT16, null);
-// validateErrMsg(MINUIWR, INT16NS, "9", CAPSUINT16, null);
-// validateErrMsg(MAXUIWR, INT16NS, "101", CAPSUINT16, null);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for signed integer16 data type
-// * with range "10..40 | 50..100".
-// */
-// @Test
-// public void negative3Test() throws YdtException {
-// validateErrMsg("integer", INT16NS, "9", CAPSINT16, MRV);
-// validateErrMsg("integer", INT16NS, "41", CAPSINT16, MRV);
-// validateErrMsg("integer", INT16NS, "49", CAPSINT16, MRV);
-// validateErrMsg("integer", INT16NS, "101", CAPSINT16, MRV);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for unsigned integer16 data type
-// * with range "10..40 | 50..100".
-// */
-// @Test
-// public void negative4Test() throws YdtException {
-// validateErrMsg("UnInteger", INT16NS, "9", CAPSUINT16, MRV);
-// validateErrMsg("UnInteger", INT16NS, "41", CAPSUINT16, MRV);
-// validateErrMsg("UnInteger", INT16NS, "49", CAPSUINT16, MRV);
-// validateErrMsg("UnInteger", INT16NS, "101", CAPSUINT16, MRV);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for signed integer16 data type
-// * with range "min .. 2 | 10 | 20..max".
-// */
-// @Test
-// public void negative5Test() throws YdtException {
-// // multi range validation
-// validateErrMsg("revInteger", INT16NS, "-32769", SINT16, MRV);
-// validateErrMsg("revInteger", INT16NS, "19", CAPSINT16, MRV);
-// validateErrMsg("revInteger", INT16NS, "4", CAPSINT16, MRV);
-// validateErrMsg("revInteger", INT16NS, "32768", SINT16, MRV);
-// validateErrMsg("revInteger", INT16NS, "9", CAPSINT16, MRV);
-// validateErrMsg("revInteger", INT16NS, "11", CAPSINT16, MRV);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for unsigned integer16 data type
-// * with range "min .. 2 | 10 | 20..max".
-// */
-// @Test
-// public void negative6Test() throws YdtException {
-// // multi range validation
-// validateErrMsg(RUI, INT16NS, "-32769", MINVALUE, MRV);
-// validateErrMsg(RUI, INT16NS, "4", CAPSUINT16, MRV);
-// validateErrMsg(RUI, INT16NS, "9", CAPSUINT16, MRV);
-// validateErrMsg(RUI, INT16NS, "11", CAPSUINT16, MRV);
-// validateErrMsg(RUI, INT16NS, "19", CAPSUINT16, MRV);
-// validateErrMsg(RUI, INT16NS, "65536", MAXUINT16, MRV);
-// }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtInteger32Test.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtInteger32Test.java
deleted file mode 100644
index 20c3c37..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtInteger32Test.java
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT32;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDUIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MINIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MINUIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MINVALUE;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MRV;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.RUI;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.integer32Ydt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class YdtInteger32Test {
-
- /*
- Positive scenario
-
- input at boundry for integer
- i. min value
- ii. max value
-
- input at boundry for uinteger
- i. min value
- ii. max value
-
- input with in range
- if range is 10 to 100 for integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- if range is 10 to 100 for uinteger
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- input with multi interval range
- if range is 10..40 | 50..100 for integer
- i.1. input 11
- i.2. input 10
- i.3. input 40
- i.4. input 50
- i.5. input 55
- i.6. input 100
-
- if range is 10..40 | 50..100 for uinteger
- i.1. input 11
- i.2. input 10
- i.3. input 40
- i.4. input 50
- i.5. input 55
- i.6. input 100
-
- if range is "min .. 2 | 10 | 20..max" for integer
- i.1. input -2147483648
- i.2. input 1
- i.3. input 2
- i.4. input 10
- i.5. input 20
- i.6. input 100
- i.7. input 2147483647
-
- if range is "min .. 2 | 10 | 20..max" for uInteger
- i.1. input 0
- i.2. input 1
- i.3. input 2
- i.4. input 10
- i.5. input 20
- i.6. input 100
- i.7. input 4294967295
- */
-
- /**
- * Creates and validates integer32 ydt covering different positive scenario.
- */
- @Test
- public void positiveTest() throws YdtException {
- YangRequestWorkBench ydtBuilder = integer32Ydt();
- validateTree(ydtBuilder);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, TYPE, null);
-
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "integer32", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "negInt", "-2147483648");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "posInt", "2147483647");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "minUInt", MINVALUE);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "maxUInt", MAXUINT32);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MIDIWR, "11");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MINIWR, "10");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MAXIWR, "100");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MIDUIWR, "11");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MINUIWR, "10");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MAXUIWR, "100");
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "11");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "40");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "50");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "55");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "100");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "11");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "40");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "50");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "55");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "100");
-
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "-2147483648");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "1");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "20");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
-
- validate1Tree(ydtNode);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validate1Tree(YdtNode ydtNode) {
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "100");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "2147483647");
-
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, MINVALUE);
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "1");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "20");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "100");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, MAXUINT32);
- }
-
- //TODO negative scenario will be handled later
- /*
- Negative scenario
-
- wrong type input
- i. input string instead of integer
- ii. input string instead of uinteger
-
- input out of range
- i. input for int 8 range -2147483648 to 2147483647
- i.1. input -2147483649
- i.2. input 2147483648
-
- ii. input for uint 8 range 0 to 4294967295
- ii.1. input -2147483649
- ii.2. input 4294967296
-
- input out of range parameter
- if range is 10 to 100 for int
- i.1. input 9
- i.2. input 101
-
- if range is 10 to 100 for uInt
- i.1. input 9
- i.2. input 101
-
- input with multi interval range
- if range is 10..40 | 50..100 for integer
- i.1. input 9
- i.2. input 41
- i.3. input 49
- i.4. input 101
-
- if range is 10..40 | 50..100 for uinteger
- i.1. input 9
- i.2. input 41
- i.3. input 49
- i.4. input 101
-
- input with multi interval range
- if range is min .. | 10 | 20..max for integer
- i.1. input -2147483649
- i.2. input 4
- i.3. input 9
- i.4. input 11
- i.5. input 19
- i.6. input 256
-
- if range is min .. 3 | 10 | 20..max for uinteger
- i.1. input -2147483649
- i.2. input 4
- i.3. input 9
- i.4. input 11
- i.5. input 19
- i.6. input 4294967296
-
- */
-
- /**
- * Tests all the minimum and maximum value's negative scenario's for
- * signed integer32 data type.
- */
-// @Test
-// public void negative1Test() throws YdtException {
-// validateErrMsg("posInt", INT32NS, "integer", SINT32, null);
-// validateErrMsg("posInt", INT32NS, "127.0", SINT32, null);
-// validateErrMsg("negInt", INT32NS, "-2147483649", SINT32, null);
-// validateErrMsg("posInt", INT32NS, "2147483648", SINT32, null);
-// validateErrMsg(MINIWR, INT32NS, "9", CAPSINT32, null);
-// validateErrMsg(MAXIWR, INT32NS, "101", CAPSINT32, null);
-// }
-//
-// /**
-// * Tests all the minimum and maximum value's negative scenario's for
-// * unsigned integer32 data type.
-// */
-// @Test
-// public void negative2Test() throws YdtException {
-// validateErrMsg("maxUInt", INT32NS, "integer", SUINT32, null);
-// validateErrMsg("maxUInt", INT32NS, "127.0", SUINT32, null);
-// validateErrMsg("minUInt", INT32NS, "-2147483649", MINVALUE, null);
-// validateErrMsg("maxUInt", INT32NS, "4294967296", MAXUINT32, null);
-// validateErrMsg(MINUIWR, INT32NS, "9", CAPSUINT32, null);
-// validateErrMsg(MAXUIWR, INT32NS, "101", CAPSUINT32, null);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for signed integer32 data type
-// * with range "10..40 | 50..100".
-// */
-// @Test
-// public void negative3Test() throws YdtException {
-// validateErrMsg("integer", INT32NS, "9", CAPSINT32, MRV);
-// validateErrMsg("integer", INT32NS, "41", CAPSINT32, MRV);
-// validateErrMsg("integer", INT32NS, "49", CAPSINT32, MRV);
-// validateErrMsg("integer", INT32NS, "101", CAPSINT32, MRV);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for unsigned integer32 data type
-// * with range "10..40 | 50..100".
-// */
-// @Test
-// public void negative4Test() throws YdtException {
-// validateErrMsg("UnInteger", INT32NS, "9", CAPSUINT32, MRV);
-// validateErrMsg("UnInteger", INT32NS, "41", CAPSUINT32, MRV);
-// validateErrMsg("UnInteger", INT32NS, "49", CAPSUINT32, MRV);
-// validateErrMsg("UnInteger", INT32NS, "101", CAPSUINT32, MRV);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for signed integer32 data type
-// * with range "min .. 2 | 10 | 20..max".
-// */
-// @Test
-// public void negative5Test() throws YdtException {
-// // Multi range validation
-// validateErrMsg("revInteger", INT32NS, "-2147483649", SINT32, MRV);
-// validateErrMsg("revInteger", INT32NS, "4", CAPSINT32, MRV);
-// validateErrMsg("revInteger", INT32NS, "9", CAPSINT32, MRV);
-// validateErrMsg("revInteger", INT32NS, "11", CAPSINT32, MRV);
-// validateErrMsg("revInteger", INT32NS, "19", CAPSINT32, MRV);
-// validateErrMsg("revInteger", INT32NS, "2147483648", SINT32, MRV);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for unsigned integer32 data type
-// * with range "min .. 2 | 10 | 20..max".
-// */
-// @Test
-// public void negative6Test() throws YdtException {
-// // Multi range validation
-// validateErrMsg(RUI, INT32NS, "-2147483649", MINVALUE, MRV);
-// validateErrMsg(RUI, INT32NS, "4", CAPSUINT32, MRV);
-// validateErrMsg(RUI, INT32NS, "9", CAPSUINT32, MRV);
-// validateErrMsg(RUI, INT32NS, "11", CAPSUINT32, MRV);
-// validateErrMsg(RUI, INT32NS, "19", CAPSUINT32, MRV);
-// validateErrMsg(RUI, INT32NS, "4294967296", MAXUINT32, MRV);
-// }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtInteger64Test.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtInteger64Test.java
deleted file mode 100644
index 4805786..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtInteger64Test.java
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-
-import static org.onosproject.yms.app.ydt.YdtTestConstants.J;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.K;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT64;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDUIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MINIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MINUIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MINVALUE;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MRV;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.RUI;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.integer64Ydt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class YdtInteger64Test {
-
- /*
-
- Positive scenario
-
- input at boundry for integer
- i. min value
- ii. max value
-
- input at boundry for uinteger
- i. min value
- ii. max value
-
- input with in range
- if range is 10 to 100 for integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- if range is 10 to 100 for uinteger
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- input with multi interval range
- if range is 10..40 | 50..100 for integer
- i.1. input 11
- i.2. input 10
- i.3. input 40
- i.4. input 50
- i.5. input 55
- i.6. input 100
-
- if range is 10..40 | 50..100 for uinteger
- i.1. input 11
- i.2. input 10
- i.3. input 40
- i.4. input 50
- i.5. input 55
- i.6. input 100
-
- if range is "min .. 2 | 10 | 20..max" for integer
- i.1. input -9223372036854775808
- i.2. input 1
- i.3. input 2
- i.4. input 10
- i.5. input 20
- i.6. input 100
- i.7. input 9223372036854775807
-
- if range is "min .. 2 | 10 | 20..max" for uInteger
- i.1. input 0
- i.2. input 1
- i.3. input 2
- i.4. input 10
- i.5. input 20
- i.6. input 100
- i.7. input 18446744073709551615
- */
-
- /**
- * Creates and validates integer64 ydt covering different positive scenario.
- */
- @Test
- public void positiveTest() throws YdtException {
- YangRequestWorkBench ydtBuilder = integer64Ydt();
- validateTree(ydtBuilder);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, TYPE, null);
-
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "integer64", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "negInt", K);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "posInt", J);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "minUInt", MINVALUE);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "maxUInt", MAXUINT64);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MIDIWR, "11");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MINIWR, "10");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MAXIWR, "100");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MIDUIWR, "11");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MINUIWR, "10");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MAXUIWR, "100");
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "11");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "40");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "50");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "55");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "100");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "11");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "40");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "50");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "55");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "100");
-
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", K);
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "1");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
-
- validate1Tree(ydtNode);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validate1Tree(YdtNode ydtNode) {
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "20");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "100");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", J);
-
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, MINVALUE);
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "1");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "20");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "100");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, MAXUINT64);
- }
-
- //TODO negative scenario will be handled later
- /*
- Negative scenario
-
- wrong type input
- i. input string instead of integer
- ii. input string instead of uinteger
-
- input out of range
- i. input for int 8 range -9223372036854775808 to 9223372036854775807
- i.1. input -9223372036854775809
- i.2. input 9223372036854775808
-
- ii. input for uint 8 range 0 to 18446744073709551615
- ii.1. input -9223372036854775809
- ii.2. input 18446744073709551616
-
- input out of range parameter
- if range is 10 to 100 for int
- i.1. input 9
- i.2. input 101
-
- if range is 10 to 100 for uInt
- i.1. input 9
- i.2. input 101
-
- input with multi interval range
- if range is 10..40 | 50..100 for integer
- i.1. input 9
- i.2. input 41
- i.3. input 49
- i.4. input 101
-
- if range is 10..40 | 50..100 for uinteger
- i.1. input 9
- i.2. input 41
- i.3. input 49
- i.4. input 101
-
- input with multi interval range
- if range is min .. | 10 | 20..max for integer
- i.1. input -9223372036854775809
- i.2. input 4
- i.3. input 9
- i.4. input 11
- i.5. input 19
- i.6. input 9223372036854775808
-
- if range is min .. 3 | 10 | 20..max for uinteger
- i.1. input -9223372036854775809
- i.2. input 4
- i.3. input 9
- i.4. input 11
- i.5. input 19
- i.6. input 18446744073709551616
-
- */
-
- /**
- * Tests all the minimum and maximum value's negative scenario's for
- * signed integer64 data type.
- */
-// @Test
-// public void negative1Test() throws YdtException {
-// validateErrMsg("posInt", INT64NS, "integer", SMALLINT64, null);
-// validateErrMsg("posInt", INT64NS, "127.0", SMALLINT64, null);
-// validateErrMsg("negInt", INT64NS, L, SMALLINT64, null);
-// validateErrMsg("posInt", INT64NS, I, SMALLINT64, null);
-// validateErrMsg(MINIWR, INT64NS, "9", CAPSINT64, null);
-// validateErrMsg(MAXIWR, INT64NS, "101", CAPSINT64, null);
-// }
-//
-// /**
-// * Tests all the minimum and maximum value's negative scenario's for
-// * unsigned integer64 data type.
-// */
-// @Test
-// public void negative2Test() throws YdtException {
-// validateErrMsg("maxUInt", INT64NS, "integer", SMALLUINT64, null);
-// validateErrMsg("maxUInt", INT64NS, "127.0", SMALLUINT64, null);
-// validateErrMsg("minUInt", INT64NS, L, MINVALUE, null);
-// validateErrMsg("maxUInt", INT64NS, M, MAXUINT64, null);
-// validateErrMsg(MINUIWR, INT64NS, "9", CAPSUINT64, null);
-// validateErrMsg(MAXUIWR, INT64NS, "101", CAPSUINT64, null);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for signed integer64 data type
-// * with range "10..40 | 50..100".
-// */
-// @Test
-// public void negative3Test() throws YdtException {
-// validateErrMsg("integer", INT64NS, "9", CAPSINT64, MRV);
-// validateErrMsg("integer", INT64NS, "41", CAPSINT64, MRV);
-// validateErrMsg("integer", INT64NS, "49", CAPSINT64, MRV);
-// validateErrMsg("integer", INT64NS, "101", CAPSINT64, MRV);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for unsigned integer64 data type
-// * with range "10..40 | 50..100".
-// */
-// @Test
-// public void negative4Test() throws YdtException {
-// validateErrMsg("UnInteger", INT64NS, "9", CAPSUINT64, MRV);
-// validateErrMsg("UnInteger", INT64NS, "41", CAPSUINT64, MRV);
-// validateErrMsg("UnInteger", INT64NS, "49", CAPSUINT64, MRV);
-// validateErrMsg("UnInteger", INT64NS, "101", CAPSUINT64, MRV);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for signed integer64 data type
-// * with range "min .. 2 | 10 | 20..max".
-// */
-// @Test
-// public void negative5Test() throws YdtException {
-// // multi range validation
-// validateErrMsg("revInteger", INT64NS, L, SMALLINT64, MRV);
-// validateErrMsg("revInteger", INT64NS, "11", CAPSINT64, MRV);
-// validateErrMsg("revInteger", INT64NS, "4", CAPSINT64, MRV);
-// validateErrMsg("revInteger", INT64NS, "9", CAPSINT64, MRV);
-// validateErrMsg("revInteger", INT64NS, "19", CAPSINT64, MRV);
-// validateErrMsg("revInteger", INT64NS, I, SMALLINT64, MRV);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for unsigned integer64 data type
-// * with range "min .. 2 | 10 | 20..max".
-// */
-// @Test
-// public void negative6Test() throws YdtException {
-// // multi range validation
-// validateErrMsg(RUI, INT64NS, L, MINVALUE, MRV);
-// validateErrMsg(RUI, INT64NS, "4", CAPSUINT64, MRV);
-// validateErrMsg(RUI, INT64NS, "9", CAPSUINT64, MRV);
-// validateErrMsg(RUI, INT64NS, "11", CAPSUINT64, MRV);
-// validateErrMsg(RUI, INT64NS, "19", CAPSUINT64, MRV);
-// validateErrMsg(RUI, INT64NS, M, MAXUINT64, MRV);
-// }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtInteger8Test.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtInteger8Test.java
deleted file mode 100644
index 70727aa..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtInteger8Test.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.exceptions.YdtException;
-
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT8;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MIDUIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MINIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MINUIWR;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MINVALUE;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MRV;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.RUI;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.integer8Ydt;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents;
-import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-
-public class YdtInteger8Test {
-
- /*
- Positive scenario
-
- input at boundry for integer
- i. min value
- ii. max value
-
- input at boundry for uinteger
- i. min value
- ii. max value
-
- input with in range
- if range is 10 to 100 for integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- if range is 10 to 100 for uinteger
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- input with multi interval range
- if range is 10..40 | 50..100 for integer
- i.1. input 11
- i.2. input 10
- i.3. input 40
- i.4. input 50
- i.5. input 55
- i.6. input 100
-
- if range is 10..40 | 50..100 for uinteger
- i.1. input 11
- i.2. input 10
- i.3. input 40
- i.4. input 50
- i.5. input 55
- i.6. input 100
-
- if range is "min .. 2 | 10 | 20..max" for integer
- i.1. input -128
- i.2. input 1
- i.3. input 2
- i.4. input 10
- i.5. input 20
- i.6. input 100
- i.7. input 127
-
- if range is "min .. 2 | 10 | 20..max" for uInteger
- i.1. input 0
- i.2. input 1
- i.3. input 2
- i.4. input 10
- i.5. input 20
- i.6. input 100
- i.7. input 255
- */
-
- /**
- * Creates and validates integer8 ydt covering different positive scenario.
- */
- @Test
- public void positiveTest() throws YdtException {
- YangRequestWorkBench ydtBuilder = integer8Ydt();
- validateTree(ydtBuilder);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validateTree(YangRequestWorkBench ydtBuilder) {
-
- // assign root node to ydtNode for validating purpose.
- YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode();
- // Logical root node does not have operation type
- validateNodeContents(ydtNode, TYPE, null);
-
- ydtNode = ydtNode.getFirstChild();
- validateNodeContents(ydtNode, "integer8", MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "negInt", "-128");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "posInt", "127");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "minUInt", MINVALUE);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, "maxUInt", MAXUINT8);
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MIDIWR, "11");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MINIWR, "10");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MAXIWR, "100");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MIDUIWR, "11");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MINUIWR, "10");
- ydtNode = ydtNode.getNextSibling();
- validateLeafContents(ydtNode, MAXUIWR, "100");
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "11");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "40");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "50");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "55");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "integer", "100");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "11");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "40");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "50");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "55");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "UnInteger", "100");
-
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "-128");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "1");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- validate1Tree(ydtNode);
- }
-
- /**
- * Validates the given built ydt.
- */
- private void validate1Tree(YdtNode ydtNode) {
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "20");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "100");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, "revInteger", "127");
-
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, MINVALUE);
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "1");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "2");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "10");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "20");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, "100");
- ydtNode = ydtNode.getParent();
- ydtNode = ydtNode.getNextSibling();
- validateNodeContents(ydtNode, MRV, MERGE);
- ydtNode = ydtNode.getFirstChild();
- validateLeafContents(ydtNode, RUI, MAXUINT8);
- }
-
- //TODO negative scenario will be handled later
- /*
- Negative scenario
-
- wrong type input
- i. input string instead of integer
- ii. input string instead of uinteger
-
- input out of range
- i. input for int 8 range -128 to 127
- i.1. input -129
- i.2. input 128
-
- ii. input for uint 8 range 0 to 255
- ii.1. input -128
- ii.2. input 256
-
- input out of range parameter
- if range is 10 to 100 for int
- i.1. input 9
- i.2. input 101
-
- if range is 10 to 100 for uInt
- i.1. input 9
- i.2. input 101
-
- input with multi interval range
- if range is 10..40 | 50..100 for integer
- i.1. input 9
- i.2. input 41
- i.3. input 49
- i.4. input 101
-
- if range is 10..40 | 50..100 for uinteger
- i.1. input 9
- i.2. input 41
- i.3. input 49
- i.4. input 101
-
- input with multi interval range
- if range is min .. | 10 | 20..max for integer
- i.1. input -129
- i.2. input 4
- i.3. input 9
- i.4. input 11
- i.5. input 19
- i.6. input 128
-
- if range is min .. 3 | 10 | 20..max for uinteger
- i.1. input -129
- i.2. input 4
- i.3. input 9
- i.4. input 11
- i.5. input 19
- i.6. input 256
-
- */
-
- /**
- * Tests all the minimum and maximum value's negative scenario's for
- * signed integer8 data type.
- */
-// @Test
-// public void negative1Test() throws YdtException {
-// validateErrMsg("posInt", INT8NS, "integer", SMALLINT8, null);
-// validateErrMsg("posInt", INT8NS, "127.0", SMALLINT8, null);
-// validateErrMsg("negInt", INT8NS, "-129", SMALLINT8, null);
-// validateErrMsg("posInt", INT8NS, "128", SMALLINT8, null);
-// validateErrMsg(MINIWR, INT8NS, "9", CAPSINT8, null);
-// validateErrMsg(MAXIWR, INT8NS, "101", CAPSINT8, null);
-// }
-//
-// /**
-// * Tests all the minimum and maximum value's negative scenario's for
-// * unsigned integer8 data type.
-// */
-// @Test
-// public void negative2Test() throws YdtException {
-// validateErrMsg("maxUInt", INT8NS, "integer", SMALLUINT8, null);
-// validateErrMsg("maxUInt", INT8NS, "127.0", SMALLUINT8, null);
-// validateErrMsg("minUInt", INT8NS, "-128", MINVALUE, null);
-// validateErrMsg("maxUInt", INT8NS, "256", MAXUINT8, null);
-// validateErrMsg(MINUIWR, INT8NS, "9", CAPSUINT8, null);
-// validateErrMsg(MAXUIWR, INT8NS, "101", CAPSUINT8, null);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for signed integer8 data type
-// * with range "10..40 | 50..100".
-// */
-// @Test
-// public void negative3Test() throws YdtException {
-// validateErrMsg("integer", INT8NS, "9", CAPSINT8, MRV);
-// validateErrMsg("integer", INT8NS, "41", CAPSINT8, MRV);
-// validateErrMsg("integer", INT8NS, "49", CAPSINT8, MRV);
-// validateErrMsg("integer", INT8NS, "101", CAPSINT8, MRV);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for unsigned integer8 data type
-// * with range "10..40 | 50..100".
-// */
-// @Test
-// public void negative4Test() throws YdtException {
-// validateErrMsg("UnInteger", INT8NS, "9", CAPSUINT8, MRV);
-// validateErrMsg("UnInteger", INT8NS, "41", CAPSUINT8, MRV);
-// validateErrMsg("UnInteger", INT8NS, "49", CAPSUINT8, MRV);
-// validateErrMsg("UnInteger", INT8NS, "101", CAPSUINT8, MRV);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for signed integer8 data type
-// * with range "min .. 2 | 10 | 20..max".
-// */
-// @Test
-// public void negative5Test() throws YdtException {
-// // multi range validation
-// validateErrMsg("revInteger", INT8NS, "-129", SMALLINT8, MRV);
-// validateErrMsg("revInteger", INT8NS, "128", SMALLINT8, MRV);
-// validateErrMsg("revInteger", INT8NS, "4", CAPSINT8, MRV);
-// validateErrMsg("revInteger", INT8NS, "11", CAPSINT8, MRV);
-// validateErrMsg("revInteger", INT8NS, "9", CAPSINT8, MRV);
-// validateErrMsg("revInteger", INT8NS, "19", CAPSINT8, MRV);
-// }
-//
-// /**
-// * Tests all possible negative scenario's for unsigned integer8 data type
-// * with range "min .. 2 | 10 | 20..max".
-// */
-// @Test
-// public void negative6Test() throws YdtException {
-// // multi range validation
-// validateErrMsg(RUI, INT8NS, "-129", MINVALUE, MRV);
-// validateErrMsg(RUI, INT8NS, "4", CAPSUINT8, MRV);
-// validateErrMsg(RUI, INT8NS, "9", CAPSUINT8, MRV);
-// validateErrMsg(RUI, INT8NS, "11", CAPSUINT8, MRV);
-// validateErrMsg(RUI, INT8NS, "19", CAPSUINT8, MRV);
-// validateErrMsg(RUI, INT8NS, "256", MAXUINT8, MRV);
-// }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtTestConstants.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtTestConstants.java
deleted file mode 100644
index d4f3d8b..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtTestConstants.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ydt;
-
-/**
- * Represents common constant utility for YANG data tree UT framework.
- */
-final class YdtTestConstants {
-
- // No instantiation.
- private YdtTestConstants() {
- }
-
- public static final String BACKSLASH = "\"";
- public static final String PERIOD = ".";
- public static final String A = "92233720368547758.07";
- public static final String B = "92233720368547757";
- public static final String C = "-92233720368547758.08";
- public static final String D = "92233720368547757";
- public static final String E = "9.223372036854775807";
- public static final String F = "-922337203685477580.8";
- public static final String G = "922337203685477580.7";
- public static final String H = "-9.223372036854775808";
- public static final String I = "9223372036854775808";
- public static final String J = "9223372036854775807";
- public static final String K = "-9223372036854775808";
- public static final String L = "-9223372036854775809";
- public static final String M = "18446744073709551616";
- public static final String NWF = "negIntWithMaxFraction";
- public static final String PWF = "posIntWithMaxFraction";
- public static final String NIWMF = "negIntWithMinFraction";
- public static final String PIWMF = "posIntWithMinFraction";
- public static final String CAPSUINT8 = "UINT8";
- public static final String CAPSINT8 = "INT8";
- public static final String SMALLUINT8 = "uint8.";
- public static final String SMALLINT8 = "int8.";
- public static final String MAXUINT8 = "255";
- public static final String CAPSUINT16 = "UINT16";
- public static final String CAPSINT16 = "INT16";
- public static final String SUINT16 = "uint16.";
- public static final String SINT16 = "int16.";
- public static final String MAXUINT16 = "65535";
- public static final String CAPSUINT32 = "UINT32";
- public static final String CAPSINT32 = "INT32";
- public static final String SUINT32 = "uint32.";
- public static final String SINT32 = "int32.";
- public static final String MAXUINT32 = "4294967295";
- public static final String CAPSUINT64 = "UINT64";
- public static final String CAPSINT64 = "INT64";
- public static final String SMALLUINT64 = "uint64.";
- public static final String SMALLINT64 = "int64.";
- public static final String MAXUINT64 = "18446744073709551615";
- public static final String MINVALUE = "0";
- public static final String MINIWR = "minIntWithRange";
- public static final String MIDIWR = "midIntWithRange";
- public static final String MAXIWR = "maxIntWithRange";
- public static final String MINUIWR = "minUIntWithRange";
- public static final String MIDUIWR = "midUIntWithRange";
- public static final String MAXUIWR = "maxUIntWithRange";
- public static final String MRV = "multiRangeValidation";
- public static final String RUI = "revUnInteger";
- public static final String TYPE = "builtInType";
- public static final String INT8NS = "ydt.integer8";
- public static final String BIT = "BITS";
- public static final String BOOL = "BOOLEAN";
- public static final String EMPTY = "";
- public static final String ENUM = "ENUMERATION";
- public static final String LIST = "List";
- public static final String LWC = "listwithcontainer";
- public static final String INV = "invalidinterval";
- public static final String INT16NS = "ydt.integer16";
- public static final String INT32NS = "ydt.integer32";
- public static final String INT64NS = "ydt.integer64";
- public static final String BITNS = "ydt.bit";
- public static final String BOOLNS = "ydt.boolean";
- public static final String EMPTYNS = "ydt.emptydata";
- public static final String ENUMNS = "ydt.enumtest";
- public static final String LISTNS = "ydt.rootlist";
- public static final String A1 = "ydt.augment-topology1";
- public static final String A2 = "ydt.augment-topology2";
- public static final String A3 = "ydt.augment-topology3";
- public static final String A4 = "ydt.augment-topology4";
- public static final String A5 = "ydt.augment-topology5";
- public static final String A6 = "ydt.augment-topology6";
- public static final String A2L = "augment2leafList";
- public static final String A5L = "augment5leafList";
- public static final String A6L = "augment6leafList";
- public static final String MATERIALNS = "ydt.material-supervisor";
- public static final String PURCHASNS = "ydt.purchasing-supervisor";
- public static final String WAREHNS = "ydt.warehouse-supervisor";
- public static final String TRADNS = "ydt.trading-supervisor";
- public static final String EMPNS = "ydt.employee-id";
- public static final String COUSTOMNS = "ydt.customs-supervisor";
- public static final String MERCHNS = "ydt.Merchandiser-supervisor";
- public static final String STP = "supporting-termination-point";
- public static final String SLINK = "supporting-link";
- public static final String AUGSE = "/aug:l1";
- public static final String ELNS = "ydt.Empty.leafList";
- public static final String AUG1 = "/nd:networks/nd:network";
- public static final String AUG2 = "/nd:networks/nd:network/nd:node";
- public static final String AUG3 = "/nd:networks/nd:network/topo:link";
- public static final String AUG4 = "/nd:networks/nd:network/nd:node/" +
- "topo:t-point/supporting-termination-point";
- public static final String AUG5 = "/nd:networks/nd:network/topo:link/" +
- "aug2:augment2";
- public static final String AUG6 = "/nd:networks/nd:network/nd:node/" +
- "topo:t-point/supporting-termination-point/aug2:augment2";
- public static final String AUG7 = "/nd:networks/nd:network/topo:link/" +
- "aug2:augment2/aug3:augment3";
- public static final String AUG8 = "/nd:networks/nd:network/topo:link/" +
- "aug2:augment2/aug3:augment3/aug5:augment5";
- public static final String AUG9 = "/nd:networks/nd:network/topo:link/" +
- "aug2:augment2/aug5:augment5";
- public static final String AUG10 = "/aug:node/aug:cont1s/aug:cont1s";
- public static final String NETNS = "ydt.augmentNetwork";
- public static final String AUGNS = "ydt.augmentSequence1";
- public static final String IETFNS =
- "urn:ietf:params:xml:ns:yang:ietf-network";
- public static final String IETF = "yms-ietf-network";
- public static final String TOPONS =
- "urn:ietf:params:xml:ns:yang:ietf-network-topology";
- public static final String E_LEAF = "Exception has not occurred for " +
- "invalid leaf value with name ";
- public static final String E_LIST = "Exception has not occurred for " +
- "invalid node addition with the name ";
- public static final String E_TOPARENT = "Exception has not occurred " +
- "in traverse back to parent for multi instance node.";
- public static final String E_D64 = "YANG file error : value is not in" +
- " decimal64 range.";
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtTestUtils.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtTestUtils.java
deleted file mode 100644
index 989f85d..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ydt/YdtTestUtils.java
+++ /dev/null
@@ -1,1938 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.yms.app.ydt;
-
-import org.junit.Rule;
-import org.junit.rules.ExpectedException;
-import org.onosproject.yms.app.yob.DefaultYobBuilder;
-import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-import org.onosproject.yms.app.ytb.DefaultYangTreeBuilder;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-import org.onosproject.yms.ydt.YdtListener;
-import org.onosproject.yms.ydt.YdtType;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.A1;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.A2;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.A2L;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.A3;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.A4;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.A5;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.A5L;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.A6;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.A6L;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.BACKSLASH;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.BIT;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.BITNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.BOOL;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.BOOLNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSINT16;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSINT32;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSINT64;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSINT8;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSUINT16;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSUINT32;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSUINT64;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.CAPSUINT8;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.COUSTOMNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.ELNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.EMPNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.EMPTY;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.EMPTYNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.ENUM;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.ENUMNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.E_LEAF;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.IETF;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.IETFNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.INT16NS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.INT32NS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.INT64NS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.INT8NS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.INV;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.LIST;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.LISTNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.LWC;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MATERIALNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT16;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT32;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT64;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MAXUINT8;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MERCHNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MINVALUE;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.MRV;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.NETNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.NIWMF;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.NWF;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.PERIOD;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.PIWMF;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.PURCHASNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.PWF;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.SINT16;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.SINT32;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.SLINK;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.SMALLINT64;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.SMALLINT8;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.SMALLUINT64;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.SMALLUINT8;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.STP;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.SUINT16;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.SUINT32;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.TOPONS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.TRADNS;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.TYPE;
-import static org.onosproject.yms.app.ydt.YdtTestConstants.WAREHNS;
-import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REPLY;
-
-public class YdtTestUtils implements YdtListener {
-
- private static List<String> kValList = new ArrayList<>();
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private static YangSchemaRegistry schemaRegistry;
-
- private static TestYangSchemaNodeProvider schemaProvider =
- new TestYangSchemaNodeProvider();
-
- // Logger list is used for walker testing.
- private static final List<String> LOGGER = new ArrayList<>();
-
- /**
- * Returns the LOGGER with log for testing the YDT walker.
- *
- * @return list of logs
- */
- public static List<String> getLogger() {
- return LOGGER;
- }
-
- /**
- * Clear the LOGGER array.
- */
- public static void resetLogger() {
- LOGGER.clear();
- }
-
- @Override
- public void enterYdtNode(YdtContext ydtContext) {
- LOGGER.add("Entry Node is " + ydtContext.getName() + PERIOD);
- }
-
- @Override
- public void exitYdtNode(YdtContext ydtContext) {
- LOGGER.add("Exit Node is " + ydtContext.getName() + PERIOD);
- }
-
- /**
- * Returns schema registry of YDT.
- *
- * @return schema registry
- */
- public static YangSchemaRegistry getSchemaRegistry() {
- return schemaRegistry;
- }
-
- /**
- * Sets the ydt schema registry.
- *
- * @param registry schema registry
- */
- public static void setSchemaRegistry(YangSchemaRegistry registry) {
- schemaRegistry = registry;
- }
-
- /**
- * Returns the ydt builder for food module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench foodArenaYdt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder("foodarena", "food", "ydt.food", MERGE);
- ydtBuilder.addChild("food", "ydt.food");
-// ydtBuilder.addChild("snack", null, "ydt.food");
-// ydtBuilder.addChild("latenight", null, "ydt.food");
- ydtBuilder.addLeaf("chocolate", "ydt.food", "dark");
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for empty leaf list module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench emptyLeafListYdt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder("empty", "EmptyLeafList", ELNS, MERGE);
- ydtBuilder.addChild("l1", ELNS);
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("l2", ELNS);
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("l3", ELNS);
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("list1", ELNS);
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("list2", ELNS);
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("list3", ELNS);
- ydtBuilder.traverseToParent();
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for yms-ietf-network module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench ietfNetwork1Ydt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder(IETF, IETF, IETFNS, MERGE);
- // Adding container
- ydtBuilder.addChild("networks", null);
- // Adding list inside container
- ydtBuilder.addChild("network", null);
- // Adding key element network Id
- ydtBuilder.addLeaf("network-id", null, "network1");
- ydtBuilder.traverseToParent();
-
- // Adding list inside list
- ydtBuilder.addChild("supporting-network", null);
- // Adding key element network-ref
- ydtBuilder.addLeaf("network-ref", null, "network2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- // Adding list inside list
- ydtBuilder.addChild("node", null);
- // Adding key element node-id
- ydtBuilder.addLeaf("node-id", null, "node1");
- ydtBuilder.traverseToParent();
-
- // Adding list inside list
- ydtBuilder.addChild("supporting-node", null);
- // Adding key element network-ref
- ydtBuilder.addLeaf("network-ref", null, "network3");
- ydtBuilder.traverseToParent();
-
- // Adding key element node-ref
- ydtBuilder.addLeaf("node-ref", null, "network4");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- // Adding container
- ydtBuilder.addChild("networks-state", null);
- // Adding list inside container
- ydtBuilder.addChild("network", null);
- // Adding key element network-ref
- ydtBuilder.addLeaf("network-ref", null, "network5");
- ydtBuilder.traverseToParent();
- // Adding leaf server-provided
- ydtBuilder.addLeaf("server-provided", null, "true");
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for yms-ietf-network-topology module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench ietfNetworkTopologyYdt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder(IETF, IETF, IETFNS, MERGE);
- // Adding container
- ydtBuilder.addChild("networks", IETFNS, MERGE);
- // Adding list inside container
- ydtBuilder.addChild("network", IETFNS, MERGE);
-
- // Adding key element network Id
- ydtBuilder.addLeaf("network-id", null, "network1");
- ydtBuilder.traverseToParent();
-
- kValList.clear();
- kValList.add("id1");
- // adding the augmented node
- ydtBuilder.addMultiInstanceChild("link", TOPONS, kValList, MERGE);
- // container source
- ydtBuilder.addChild("source", TOPONS, MERGE);
- ydtBuilder.addLeaf("source-node", null, "source1");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("source-tp", null, "source2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- // container destination
- ydtBuilder.addChild("destination", TOPONS, MERGE);
- ydtBuilder.addLeaf("dest-node", null, "dest1");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("dest-tp", null, "dest2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- kValList.clear();
- kValList.add("network1");
- kValList.add("id2");
- // adding the supporting-link list node
- ydtBuilder.addMultiInstanceChild(SLINK, TOPONS, kValList, MERGE);
- ydtBuilder.traverseToParent();
-
- kValList.clear();
- kValList.add("network2");
- kValList.add("id3");
- // adding the supporting-link list another instance
- ydtBuilder.addMultiInstanceChild(SLINK, TOPONS, kValList, MERGE);
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- // Adding list inside list
- ydtBuilder.addChild("supporting-network", null);
- // Adding key element network-ref
- ydtBuilder.addLeaf("network-ref", null, "network2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- // Adding list inside list
- ydtBuilder.addChild("node", null);
- // Adding key element node-id
- ydtBuilder.addLeaf("node-id", null, "node1");
- ydtBuilder.traverseToParent();
-
- kValList.clear();
- kValList.add("tp_id1");
- //adding augmented termination-point list
- ydtBuilder.addMultiInstanceChild("t-point", TOPONS,
- kValList, MERGE);
- kValList.clear();
- kValList.add("network-ref");
- kValList.add("node-ref");
- kValList.add("tp-ref");
- //adding supporting-termination-point
- ydtBuilder.addMultiInstanceChild(STP, TOPONS, kValList, MERGE);
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- // Adding list inside list
- ydtBuilder.addChild("supporting-node", null);
- // Adding key element network-ref
- ydtBuilder.addLeaf("network-ref", null, "network3");
- ydtBuilder.traverseToParent();
-
- // Adding key element node-ref
- ydtBuilder.addLeaf("node-ref", null, "network4");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("link-id", TOPONS, "id1");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- // Adding container
- ydtBuilder.addChild("networks-state", null);
- // Adding list inside container
- ydtBuilder.addChild("network", null);
- // Adding key element network-ref
- ydtBuilder.addLeaf("network-ref", null, "network5");
- ydtBuilder.traverseToParent();
- // Adding leaf server-provided
- ydtBuilder.addLeaf("server-provided", null, "true");
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for augmented module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench augmentNetworkYdt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder(IETF, IETF, IETFNS, MERGE);
- // Adding container
- ydtBuilder.addChild("networks", IETFNS, MERGE);
- // Adding list inside container
- ydtBuilder.addChild("network", IETFNS, MERGE);
-
- // Adding key element network Id
- ydtBuilder.addLeaf("network-id", null, "network1");
- ydtBuilder.traverseToParent();
-
- kValList.clear();
- kValList.add("id1");
- // adding the augmented node
- ydtBuilder.addMultiInstanceChild("link", TOPONS, kValList, MERGE);
- // container source
- ydtBuilder.addChild("source", TOPONS, MERGE);
- ydtBuilder.addLeaf("source-node", null, "source1");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("source-tp", null, "source2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- // container destination
- ydtBuilder.addChild("destination", TOPONS, MERGE);
- ydtBuilder.addLeaf("dest-node", null, "dest1");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("dest-tp", null, "dest2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- kValList.clear();
- kValList.add("network1");
- kValList.add("id2");
- // adding the supporting-link list node
- ydtBuilder.addMultiInstanceChild(SLINK, TOPONS, kValList, MERGE);
- ydtBuilder.traverseToParent();
-
- kValList.clear();
- kValList.add("network2");
- kValList.add("id3");
- // adding the supporting-link list another instance
- ydtBuilder.addMultiInstanceChild(SLINK, TOPONS, kValList, MERGE);
- ydtBuilder.traverseToParent();
-
- kValList.clear();
- kValList.add("1");
- ydtBuilder.addMultiInstanceChild("augment1", A1, kValList, MERGE);
- ydtBuilder.traverseToParent();
-
- kValList.clear();
- kValList.add("1");
- kValList.add("2");
- ydtBuilder.addMultiInstanceChild("augment2", A2, kValList, MERGE);
-
- ydtBuilder.addChild("augment5", A5, DELETE);
-
- ydtBuilder.addMultiInstanceChild(A6L, A6, kValList, DELETE);
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("value5", null, "5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addMultiInstanceChild(A5L, A5, kValList, DELETE);
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("augment3", A3, MERGE);
-
- ydtBuilder.addChild("augment4", A4, DELETE);
- ydtBuilder.addLeaf("value4", null, "4");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("augment5", A5, MERGE);
-
- ydtBuilder.addLeaf("leaf6", A6, "6");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("value5", null, "5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("augment6", A6, DELETE);
- ydtBuilder.addLeaf("value6", null, "6");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("value3", null, "3");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("augment3leaf", A3, "3");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addMultiInstanceChild(A2L, A2, kValList, MERGE);
- ydtBuilder.traverseToParent();
-
- ydtBuilder.traverseToParent();
-
- // Adding list inside list
- ydtBuilder.addChild("supporting-network", null);
- // Adding key element network-ref
- ydtBuilder.addLeaf("network-ref", null, "network2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- // Adding list inside list
- ydtBuilder.addChild("node", null);
- // Adding key element node-id
- ydtBuilder.addLeaf("node-id", null, "node1");
- ydtBuilder.traverseToParent();
-
- kValList.clear();
- kValList.add("tp_id1");
- //adding augmented termination-point list
- ydtBuilder.addMultiInstanceChild("t-point", TOPONS,
- kValList, MERGE);
- kValList.clear();
- kValList.add("network-ref");
- kValList.add("node-ref");
- kValList.add("tp-ref");
- //adding supporting-termination-point
- ydtBuilder.addMultiInstanceChild(STP, TOPONS, kValList, MERGE);
-
- // Adding augmented container1 inside supporting-termination-point
- augmentTerminationPointYdt(ydtBuilder);
-
- return ydtBuilder;
- }
-
- /**
- * Adds augments inside supporting-termination-point in augmented module.
- *
- * @param ydtBuilder ydt builder which need to be updated
- */
- private static void augmentTerminationPointYdt(YangRequestWorkBench ydtBuilder) {
-
- ydtBuilder.addChild("augment1", A1);
- ydtBuilder.addLeaf("value1", null, "1");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("augment1-leaf", A1, "1");
-
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("augment2", A2, MERGE);
-
- ydtBuilder.addChild("augment3", A3, MERGE);
- ydtBuilder.addLeaf("value3", null, "3");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("augment4leaf", A4, "4");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("value2", null, "2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- kValList.clear();
- kValList.add("1");
- kValList.add("2");
- ydtBuilder.addMultiInstanceChild(A2L, A2, kValList, MERGE);
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("augment2leaf", A2, "2");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- // Adding list inside list
- ydtBuilder.addChild("supporting-node", null);
- // Adding key element network-ref
- ydtBuilder.addLeaf("network-ref", null, "network3");
- ydtBuilder.traverseToParent();
-
- // Adding key element node-ref
- ydtBuilder.addLeaf("node-ref", null, "network4");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("link-id", TOPONS, "id1");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- // Adding container
- ydtBuilder.addChild("networks-state", null);
- // Adding list inside container
- ydtBuilder.addChild("network", null);
- // Adding key element network-ref
- ydtBuilder.addLeaf("network-ref", null, "network5");
- ydtBuilder.traverseToParent();
- // Adding leaf server-provided
- ydtBuilder.addLeaf("server-provided", null, "true");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- augmentNetworkYdt(ydtBuilder);
- }
-
- /**
- * Adds augmented module augment-network under logical node ietf-network.
- *
- * @param ydtBuilder ydt builder which need to be updated
- */
- private static void augmentNetworkYdt(YangRequestWorkBench ydtBuilder) {
- ydtBuilder.addChild("augmentNetwork", NETNS);
-
- //adding list with name node under module node
- ydtBuilder.addChild("node", null);
-
- //adding key leaf for node
- ydtBuilder.addLeaf("name", null, "node1");
- ydtBuilder.traverseToParent();
-
- // adding augmented container cont1s under list
- ydtBuilder.addChild("cont1s", null);
- // adding container cont1s under cont1s
- ydtBuilder.addChild("cont1s", null);
- //adding leaf under cont1s
- ydtBuilder.addLeaf("fine", null, "leaf");
-
- //adding augmented list node bu augment-topology1 under container
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("augment1", A1, DELETE);
- //adding key leaf for list node augment1
- ydtBuilder.addLeaf("value1", null, "1");
- }
-
- /**
- * Returns the ydt builder for rootlist module with listwithcontainer node
- * using addMultiInstanceChild interface for adding multi instance node.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench listWithContainerYdt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder("list", "rootlist", "ydt.rootlist", MERGE);
- kValList.clear();
- kValList.add("12");
- kValList.add("12");
- ydtBuilder.addMultiInstanceChild(LWC, null, kValList, MERGE);
- ydtBuilder.addLeaf(INV, null, "1");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(INV, null, "2");
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("interface", null);
- ydtBuilder.addLeaf(INV, null, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("invalid", null, "121");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for rootlist module with listwithcontainer
- * node using addChild interface for adding multi instance node.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench listWithContainer1Ydt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder("list", "rootlist", "ydt.rootlist", MERGE);
- ydtBuilder.addChild(LWC, null);
- ydtBuilder.addLeaf("invalid", null, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("invalid1", null, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(INV, null, "1");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(INV, null, "2");
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("interface", null);
- ydtBuilder.addLeaf(INV, null, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("invalid", null, "121");
- ydtBuilder.traverseToParent();
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for rootlist module with multiple instances of
- * listwithcontainer node using addMultiInstanceChild interface for adding
- * multi instance node.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench listWithContainer2Ydt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder("list", "rootlist", "ydt.rootlist", MERGE);
- kValList.clear();
- kValList.add("1222");
- kValList.add("1212");
- ydtBuilder.addMultiInstanceChild(LWC, null, kValList, MERGE);
-
- kValList.clear();
- kValList.add("12");
- kValList.add("1");
- ydtBuilder.addMultiInstanceChild(INV, null, kValList, MERGE);
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(INV, null, "122");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(INV, null, "2222");
- ydtBuilder.traverseToParent();
-
- kValList.clear();
- kValList.add("1222");
- kValList.add("1212");
- ydtBuilder.addMultiInstanceChild(INV, null, kValList, MERGE);
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("interface", null);
- ydtBuilder.addLeaf(INV, null, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for rootlist module with listwithoutcontainer
- * node.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench listWithoutContainerYdt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder("list", "rootlist", "ydt.rootlist", MERGE);
- ydtBuilder.addChild("listwithoutcontainer", null);
- ydtBuilder.addLeaf(INV, null, "12");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for logisticsmanager module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench logisticsManagerYdt() {
-
- Set<String> valueSet = new HashSet();
- valueSet.add("1");
- valueSet.add("2");
- valueSet.add("3");
- valueSet.add("4");
- valueSet.add("5");
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder("logisticsmanager", "customssupervisor",
- null, MERGE);
- ydtBuilder.addLeaf("supervisor", COUSTOMNS, "abc");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("merchandisersupervisor", MERCHNS, MERGE);
- ydtBuilder.addLeaf("supervisor", MERCHNS, "abc");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("materialsupervisor", MATERIALNS, MERGE);
- ydtBuilder.addChild("supervisor", MATERIALNS);
- ydtBuilder.addLeaf("name", MATERIALNS, "abc");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("departmentId", MATERIALNS, "xyz");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("supervisor", MATERIALNS);
- ydtBuilder.addLeaf("name", MATERIALNS, "ab");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("departmentId", MATERIALNS, "xy");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("purchasingsupervisor", PURCHASNS, MERGE);
- ydtBuilder.addChild("supervisor", PURCHASNS);
- ydtBuilder.addLeaf("purchasing-specialist", PURCHASNS, "abc");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("support", "ydt.purchasing-supervisor", "xyz");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("warehousesupervisor", WAREHNS, MERGE);
- ydtBuilder.addLeaf("supervisor", WAREHNS, valueSet);
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("tradingsupervisor", TRADNS, MERGE);
- ydtBuilder.addLeaf("supervisor", TRADNS, "abc");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("employeeid", EMPNS, MERGE);
- ydtBuilder.addLeaf("employeeid", EMPNS, valueSet);
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for bit module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench bitYdt() {
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder("builtInType", "bit", "ydt.bit", MERGE);
- ydtBuilder.addChild("bitList", null);
- ydtBuilder.addLeaf("bit", null, "disable-nagle");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("bitList", null);
- ydtBuilder.addLeaf("bit", null, "auto-sense-speed");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("bitList", null);
- ydtBuilder.addLeaf("bit", null, "ten-Mb-only");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("bitList", null);
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for bool module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench booleanYdt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder("builtInType", "bool", "ydt.boolean", MERGE);
- ydtBuilder.addChild("booleanList", null);
- ydtBuilder.addLeaf("boolean", null, "true");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("booleanList", null);
- ydtBuilder.addLeaf("boolean", null, "false");
- ydtBuilder.traverseToParent();
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for emptydata module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench emptyTypeYdt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder(
- "builtInType", "emptydata", "ydt.emptydata", MERGE);
- ydtBuilder.addChild("emptyList", null);
- ydtBuilder.addLeaf("empty", null, "");
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for enumtest module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench enumYdt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder(
- "builtInType", "enumtest", "ydt.enumtest", MERGE);
- ydtBuilder.addChild("enumList", null);
- ydtBuilder.addLeaf("enumleaf", null, "ten");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("enumList", null);
- ydtBuilder.addLeaf("enumleaf", null, "hundred");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("enumList", null);
- ydtBuilder.addLeaf("enumleaf", null, "thousand");
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for augmentSequence module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench augmentSequenceYdt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder(
- "augment", "augmentSequence", "ydt.augmentSequence", MERGE);
- ydtBuilder.addChild("l1", null);
- ydtBuilder.addLeaf("leaf1", null, "1");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("c1", "ydt.augmentSequence1");
- ydtBuilder.addLeaf("leaf2", null, "2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild("c2", "ydt.augmentSequence2");
- ydtBuilder.addLeaf("leaf2", null, "3");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for crypto-base module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench identityRefYdt() {
-
- Set<String> valueSet = new HashSet();
- valueSet.add("crypto-alg");
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder(
- "identityref", "crypto-base", "ydt.crypto-base", MERGE);
- ydtBuilder.addLeaf("crypto", null, "crypto-alg");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("abc-zeunion", null, "crypto-alg");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("level2", null, "crypto-alg2");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("level3", null, "crypto-alg3");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("level4", null, "crypto-alg3");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("abc-type", null, valueSet);
- ydtBuilder.traverseToParent();
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for builtin type integer8 module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench integer8Ydt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder(
- "builtInType", "integer8", "ydt.integer8", MERGE);
- ydtBuilder.addLeaf("negInt", null, "-128");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("posInt", null, "127");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("minUInt", null, "0");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("maxUInt", null, "255");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("midIntWithRange", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("minIntWithRange", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("maxIntWithRange", null, "100");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("midUIntWithRange", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("minUIntWithRange", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("maxUIntWithRange", null, "100");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "40");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "50");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "55");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("UnInteger", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "40");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "50");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "55");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("revInteger", null, "-128");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "1");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "20");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "127");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "0");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "1");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "20");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "255");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for builtin type integer16 module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench integer16Ydt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder(
- "builtInType", "integer16", "ydt.integer16", MERGE);
- ydtBuilder.addLeaf("negInt", null, "-32768");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("posInt", null, "32767");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("minUInt", null, "0");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("maxUInt", null, "65535");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("midIntWithRange", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("minIntWithRange", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("maxIntWithRange", null, "100");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("midUIntWithRange", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("minUIntWithRange", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("maxUIntWithRange", null, "100");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "40");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "50");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "55");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("UnInteger", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "40");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "50");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "55");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("revInteger", null, "-32768");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "1");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "20");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "32767");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "0");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "1");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "20");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "65535");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for builtin type integer32 module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench integer32Ydt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder(
- "builtInType", "integer32", "ydt.integer32", MERGE);
- ydtBuilder.addLeaf("negInt", null, "-2147483648");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("posInt", null, "2147483647");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("minUInt", null, "0");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("maxUInt", null, "4294967295");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("midIntWithRange", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("minIntWithRange", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("maxIntWithRange", null, "100");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("midUIntWithRange", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("minUIntWithRange", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("maxUIntWithRange", null, "100");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "40");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "50");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "55");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("UnInteger", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "40");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "50");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "55");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("revInteger", null, "-2147483648");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "1");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "20");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "2147483647");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "0");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "1");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "20");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "4294967295");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for builtin type integer64 module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench integer64Ydt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder(
- "builtInType", "integer64", "ydt.integer64", MERGE);
- ydtBuilder.addLeaf("negInt", null, "-9223372036854775808");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("posInt", null, "9223372036854775807");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("minUInt", null, "0");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("maxUInt", null, "18446744073709551615");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("midIntWithRange", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("minIntWithRange", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("maxIntWithRange", null, "100");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addLeaf("midUIntWithRange", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("minUIntWithRange", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("maxUIntWithRange", null, "100");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "40");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "50");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "55");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("integer", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("UnInteger", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "40");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "50");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "55");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("UnInteger", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("revInteger", null, "-9223372036854775808");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "1");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "20");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revInteger", null, "9223372036854775807");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "0");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "1");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "2");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "20");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null, YdtType.MULTI_INSTANCE_NODE);
- ydtBuilder.addLeaf("revUnInteger", null, "18446744073709551615");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder for builtin type decimal64 module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench decimal64Ydt() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder(
- "builtInType", "decimal64", "ydt.decimal64", MERGE);
- ydtBuilder.addLeaf("negInt", null, "-92233720368547758.08");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("posInt", null, "92233720368547758.07");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(NIWMF, null, "-922337203685477580.8");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(PIWMF, null, "922337203685477580.7");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(NWF, null, "-9.223372036854775808");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(PWF, null, "9.223372036854775807");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("midIntWithRange", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("minIntWithRange", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("maxIntWithRange", null, "100");
- ydtBuilder.traverseToParent();
-
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("decimal", null, "11");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("decimal", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("decimal", null, "40");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("decimal", null, "50");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("decimal", null, "55");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("decimal", null, "100");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("revDecimal", null, "-92233720368547758.08");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("revDecimal", null, "2.505");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("revDecimal", null, "3.14");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("revDecimal", null, "10");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("revDecimal", null, "20");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("revDecimal", null, "92233720368547757");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild(MRV, null);
- ydtBuilder.addLeaf("revDecimal", null, "92233720368547758.07");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- return ydtBuilder;
- }
-
- /**
- * Returns the ydt builder with requested logical root name and module name.
- *
- * @param rootName logical rootNode name
- * @param moduleName application(module) name
- * @param nameSpace namespace of module
- * @param opType operation type
- * @return ydt builder
- */
- public static YangRequestWorkBench getYdtBuilder(String rootName, String
- moduleName, String nameSpace, YdtContextOperationType opType) {
- setSchemaRegistry(schemaProvider.getDefaultYangSchemaRegistry());
- YangRequestWorkBench ydtBuilder;
- schemaProvider.processSchemaRegistry(null);
- ydtBuilder = new YangRequestWorkBench(
- rootName, null, null, schemaProvider
- .getDefaultYangSchemaRegistry(), true);
- ydtBuilder.addChild(moduleName, nameSpace, opType);
- return ydtBuilder;
- }
-
- /**
- * Compares the two value sets.
- */
- public static void compareValueSet(Set<String> valueSet,
- Set<String> userInputValueSet) {
- // Check the value against user input.
- assertTrue("Expected 'valueSet' and 'userInputValueSet' to be equal.",
- valueSet.containsAll(userInputValueSet));
- }
-
- /**
- * Returns the ydt builder for Hello_ONOS module.
- *
- * @return ydt builder
- */
- public static YangRequestWorkBench helloOnos() {
-
- YangRequestWorkBench ydtBuilder;
- ydtBuilder = getYdtBuilder(
- "Hello-ONOS", "Hello_ONOS", "ydt:hello_onos", MERGE);
- ydtBuilder.addChild("hello-world", null);
- ydtBuilder.addChild("input", null);
- ydtBuilder.addLeaf("name", null, "onos");
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf("surName", null, "yang");
- ydtBuilder.traverseToParent();
-
- kValList.clear();
- kValList.add("ON");
- kValList.add("LAB");
- ydtBuilder.addMultiInstanceChild("stringList", null, kValList,
- MERGE);
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
-
- return ydtBuilder;
- }
-
- /**
- * Returns the error message for requested node.
- *
- * @param value value in string format
- * @param dataType requested data type
- * @return error string
- */
- static String getErrorString(String value, String dataType) {
- StringBuilder msg = new StringBuilder();
- switch (dataType) {
- case SINT16:
- case SINT32:
- case SMALLINT8:
- case SMALLINT64:
- case SMALLUINT8:
- case SMALLUINT64:
- case SUINT16:
- case SUINT32:
- case CAPSINT8:
- case CAPSINT16:
- case CAPSINT32:
- case CAPSINT64:
- case CAPSUINT8:
- case CAPSUINT16:
- case CAPSUINT32:
- case CAPSUINT64:
- case BIT:
- case BOOL:
- case ENUM:
- msg.append("YANG file error : Input value ").append(BACKSLASH)
- .append(value).append(BACKSLASH)
- .append(" is not a valid ").append(dataType);
- break;
- case EMPTY:
- msg.append("YANG file error : Input value ").append(BACKSLASH)
- .append(value).append(BACKSLASH).append(
- " is not allowed for a data type EMPTY");
- break;
- case MINVALUE:
- msg.append("YANG file error : ").append(value)
- .append(" is lesser than minimum value ")
- .append(MINVALUE).append(PERIOD);
- break;
- case MAXUINT8:
- case MAXUINT16:
- case MAXUINT32:
- case MAXUINT64:
- msg.append("YANG file error : ").append(value)
- .append(" is greater than maximum value ")
- .append(dataType).append(PERIOD);
- break;
- default:
- return null;
- }
- return msg.toString();
- }
-
- /**
- * Validates the error message which is obtained by checking the given
- * value against its data type restrictions.
- *
- * @param name leaf name
- * @param nameSpace leaf namespace
- * @param val leaf value
- * @param type data type suffix string for exception message
- * @param childName child name
- */
- public static void validateErrMsg(String name, String nameSpace,
- String val, String type, String childName) {
- YangRequestWorkBench ydtBuilder = getTestYdtBuilder(nameSpace);
- boolean isExpOccurred = false;
- /*
- * If childName exist then leaf need to be added under the
- * child node with the given childName
- */
- if (childName != null) {
- ydtBuilder.addChild(childName, nameSpace);
- }
- /*
- * This try catch is explicitly written to use as utility in other
- * test cases.
- */
- try {
- ydtBuilder.addLeaf(name, nameSpace, val);
- } catch (IllegalArgumentException e) {
- isExpOccurred = true;
- assertEquals(e.getMessage(), getErrorString(val, type));
- }
- assertEquals(E_LEAF + name, isExpOccurred, true);
- }
-
- /**
- * Returns ydt builder for requested namespace.
- *
- * @param namespace namespace of the requested yang data tree
- * @return ydt builder
- */
- public static YangRequestWorkBench getTestYdtBuilder(String namespace) {
-
- switch (namespace) {
- case INT8NS:
- return getYdtBuilder(TYPE, "integer8", INT8NS, MERGE);
- case INT16NS:
- return getYdtBuilder(TYPE, "integer16", INT16NS, MERGE);
- case INT32NS:
- return getYdtBuilder(TYPE, "integer32", INT32NS, MERGE);
- case INT64NS:
- return getYdtBuilder(TYPE, "integer64", INT64NS, MERGE);
- case BITNS:
- return getYdtBuilder(TYPE, "bit", BITNS, MERGE);
- case BOOLNS:
- return getYdtBuilder(TYPE, "bool", BOOLNS, MERGE);
- case EMPTYNS:
- return getYdtBuilder(TYPE, "emptydata", EMPTYNS, MERGE);
- case ENUMNS:
- return getYdtBuilder(TYPE, "enumtest", ENUMNS, MERGE);
- case LISTNS:
- return getYdtBuilder(LIST, "rootlist", LISTNS, MERGE);
- default:
- return null;
- }
- }
-
- /**
- * Validates the contents of node like name, namespace and operation type.
- *
- * @param ydtNode node need to be validate
- * @param name name of the node
- * @param opType operation type of the node
- */
- public static void validateNodeContents(YdtNode ydtNode, String name,
- YdtContextOperationType opType) {
- assertEquals(ydtNode.getName(), name);
- assertEquals(ydtNode.getYdtContextOperationType(), opType);
- }
-
- /**
- * Validates the contents of leaf node like name, namespace and operation
- * type.
- *
- * @param ydtNode node need to be validate
- * @param name name of the node
- * @param value value of the leaf node
- */
- public static void validateLeafContents(YdtNode ydtNode, String name,
- String value) {
- validateNodeContents(ydtNode, name, null);
- assertEquals(ydtNode.getValue(), value);
- }
-
- /**
- * Validates the contents of leaf-list node like name, namespace and
- * operation type.
- *
- * @param ydtNode node need to be validate
- * @param name name of the node
- * @param valueSet value of the leaf node
- */
- public static void validateLeafListContents(YdtNode ydtNode, String name,
- Set<String> valueSet) {
- validateNodeContents(ydtNode, name, null);
- compareValueSet(ydtNode.getValueSet(), valueSet);
- }
-
- /**
- * Validates the contents of ydt application logical node.
- *
- * @param ydtAppNode node need to be validate
- */
- public static void validateAppLogicalNodeContents(
- YdtAppContext ydtAppNode) {
-
- assertNull(ydtAppNode.getOperationType());
- assertNull(ydtAppNode.getParent());
- assertNull(ydtAppNode.getNextSibling());
- assertNull(ydtAppNode.getPreviousSibling());
- assertNotNull(ydtAppNode.getFirstChild());
- assertNotNull(ydtAppNode.getLastChild());
- }
-
- /**
- * Validates the contents of ydt application module node.
- *
- * @param ydtAppNode node need to be validate
- * @param name name of the node
- * @param opType operation type of the app node
- */
- public static void validateAppModuleNodeContents(
- YdtAppContext ydtAppNode, String name,
- YdtAppNodeOperationType opType) {
-
- assertEquals(ydtAppNode.getModuleContext().getName(), name);
- assertEquals(ydtAppNode.getOperationType(), opType);
- }
-
- /**
- * Validates the contents of ydt application node like name, namespace
- * and operation type.
- *
- * @param ydtAppNode node need to be validate
- * @param name name of the schema node
- * @param ns namespace of the schema node
- * @param opType operation type of the app node
- */
- public static void validateAppNodeContents(
- YdtAppContext ydtAppNode, String name, String ns,
- YdtAppNodeOperationType opType) {
- assertEquals(ydtAppNode.getAugmentingSchemaNode().getName(), name);
- assertEquals(ydtAppNode.getAugmentingSchemaNode().getNameSpace()
- .getModuleNamespace(), ns);
- assertEquals(ydtAppNode.getOperationType(), opType);
- }
-
- /**
- * Walks in the given built ydt and validates it.
- */
- public static void walkINTree(YangRequestWorkBench ydtBuilder,
- String[] expected) {
- DefaultYdtWalker ydtWalker = new DefaultYdtWalker();
- resetLogger();
-
- YdtTestUtils utils = new YdtTestUtils();
- // Assign root node as starting node to walk the whole tree.
- ydtWalker.walk(utils, ydtBuilder.getRootNode());
- // Logger list is used for walker testing.
- List<String> logger = getLogger();
-
- for (int i = 0; i < expected.length; i++) {
- assertEquals(expected[i], logger.get(i));
- }
- }
-
- /**
- * Creates Ydt from YO using YTB.
- */
- static YangRequestWorkBench validateYangObject(
- YangRequestWorkBench ydtBuilder, String name, String namespace) {
-
- YdtContext rootCtx = ydtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
-
- List<Object> list = new LinkedList<>();
- list.add(yangObject);
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YangRequestWorkBench defaultYdtBuilder =
- (YangRequestWorkBench) treeBuilder.getYdtBuilderForYo(
- list, name, namespace, EDIT_CONFIG_REPLY, YdtTestUtils
- .getSchemaRegistry());
- return defaultYdtBuilder;
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/MockCoreService.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/MockCoreService.java
deleted file mode 100644
index 2b8d7e6..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/MockCoreService.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ymsm;
-
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.core.IdGenerator;
-import org.onosproject.core.Version;
-
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * Represents implementation of CoreService interfaces.
- */
-public class MockCoreService implements CoreService {
- @Override
- public Version version() {
- return null;
- }
-
- @Override
- public Set<ApplicationId> getAppIds() {
- return null;
- }
-
- @Override
- public ApplicationId getAppId(Short id) {
- return null;
- }
-
- @Override
- public ApplicationId getAppId(String name) {
- return null;
- }
-
- @Override
- public ApplicationId registerApplication(String name) {
- return null;
- }
-
- @Override
- public ApplicationId registerApplication(String name,
- Runnable preDeactivate) {
- return null;
- }
-
- @Override
- public IdGenerator getIdGenerator(String topic) {
- return new IdGenerator() {
- private AtomicLong counter = new AtomicLong(0);
-
- @Override
- public long getNewId() {
- return counter.getAndIncrement();
- }
- };
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/MockOverriddenDataTreeCodec.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/MockOverriddenDataTreeCodec.java
deleted file mode 100644
index 3585ee1..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/MockOverriddenDataTreeCodec.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ymsm;
-
-import org.onosproject.yms.app.ych.YchException;
-import org.onosproject.yms.ych.YangCompositeEncoding;
-import org.onosproject.yms.ych.YangDataTreeCodec;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YmsOperationType;
-
-/**
- * Represents implementation of overridden YANG data tree codec interfaces.
- */
-public class MockOverriddenDataTreeCodec implements YangDataTreeCodec {
- private static final String PREFIX = "OverriddenDataTreeCodec ";
- private static final String ENCODE = PREFIX +
- "encodeYdtToProtocolFormat Called.";
- private static final String COMPOSITE_ENCODE = PREFIX +
- "encodeYdtToCompositeProtocolFormat Called.";
- private static final String DECODE = PREFIX +
- "decodeProtocolDataToYdt Called.";
- private static final String COMPOSITE_DECODE = PREFIX +
- "decodeCompositeProtocolDataToYdt Called.";
-
- @Override
- public String encodeYdtToProtocolFormat(YdtBuilder ydtBuilder) {
-
- throw new YchException(ENCODE);
- }
-
- @Override
- public YangCompositeEncoding encodeYdtToCompositeProtocolFormat(
- YdtBuilder ydtBuilder) {
-
- throw new YchException(COMPOSITE_ENCODE);
- }
-
- @Override
- public YdtBuilder decodeProtocolDataToYdt(String protocolData,
- Object schemaRegistryForYdt,
- YmsOperationType proOper) {
-
- throw new YchException(DECODE);
- }
-
- @Override
- public YdtBuilder decodeCompositeProtocolDataToYdt(
- YangCompositeEncoding protocolData,
- Object schemaRegistryForYdt,
- YmsOperationType proOper) {
-
- throw new YchException(COMPOSITE_DECODE);
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/MockRegisteredDataTreeCodec.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/MockRegisteredDataTreeCodec.java
deleted file mode 100644
index c3fa150..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/MockRegisteredDataTreeCodec.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.yms.app.ymsm;
-
-import org.onosproject.yms.app.ych.YchException;
-import org.onosproject.yms.ych.YangCompositeEncoding;
-import org.onosproject.yms.ych.YangDataTreeCodec;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YmsOperationType;
-
-/**
- * Represents implementation of YANG SBI broker interfaces.
- */
-public class MockRegisteredDataTreeCodec implements YangDataTreeCodec {
- private static final String PREFIX = "RegisteredDataTreeCodec ";
- private static final String ENCODE = PREFIX +
- "encodeYdtToProtocolFormat Called.";
- private static final String COMPOSITE_ENCODE = PREFIX +
- "encodeYdtToCompositeProtocolFormat Called.";
- private static final String DECODE = PREFIX +
- "decodeProtocolDataToYdt Called.";
- private static final String COMPOSITE_DECODE = PREFIX +
- "decodeCompositeProtocolDataToYdt Called.";
-
- @Override
- public String encodeYdtToProtocolFormat(YdtBuilder ydtBuilder) {
- throw new YchException(ENCODE);
- }
-
- @Override
- public YangCompositeEncoding encodeYdtToCompositeProtocolFormat(
- YdtBuilder ydtBuilder) {
-
- throw new YchException(COMPOSITE_ENCODE);
- }
-
- @Override
- public YdtBuilder decodeProtocolDataToYdt(String protocolData,
- Object schemaRegistry,
- YmsOperationType proOper) {
-
- throw new YchException(DECODE);
- }
-
- @Override
- public YdtBuilder decodeCompositeProtocolDataToYdt(
- YangCompositeEncoding protocolData,
- Object schemaRegistry,
- YmsOperationType proOper) {
-
- throw new YchException(COMPOSITE_DECODE);
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/MockYangCompositeEncoding.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/MockYangCompositeEncoding.java
deleted file mode 100644
index af4dc7c..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/MockYangCompositeEncoding.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ymsm;
-
-import org.onosproject.yms.ych.YangCompositeEncoding;
-import org.onosproject.yms.ych.YangResourceIdentifierType;
-
-/**
- * Represents implementation of YangCompositeEncoding interfaces.
- */
-public class MockYangCompositeEncoding implements YangCompositeEncoding {
- /**
- * Resource identifier for composite encoding.
- */
- private String resourceIdentifier;
-
- /**
- * Resource information for composite encoding.
- */
- private String resourceInformation;
-
- /**
- * Resource identifier type.
- */
- private YangResourceIdentifierType resourceIdentifierType;
-
- /**
- * Sets resource identifier.
- *
- * @param resIdentifier resource identifier
- */
- public void setResourceIdentifier(String resIdentifier) {
- resourceIdentifier = resIdentifier;
- }
-
- /**
- * Sets the resource information.
- *
- * @param resInformation resource information
- */
- public void setResourceInformation(String resInformation) {
- resourceInformation = resInformation;
- }
-
- /**
- * Sets the resource identifier type.
- *
- * @param resIdent resource identifier
- */
- public void setResourceIdentifierType(YangResourceIdentifierType resIdent) {
- resourceIdentifierType = resIdent;
- }
-
- @Override
- public String getResourceIdentifier() {
- return resourceIdentifier;
- }
-
- @Override
- public YangResourceIdentifierType getResourceIdentifierType() {
- return resourceIdentifierType;
- }
-
- @Override
- public String getResourceInformation() {
- return resourceInformation;
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/YchCompositeHandlerTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/YchCompositeHandlerTest.java
deleted file mode 100644
index 50f178c..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ymsm/YchCompositeHandlerTest.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ymsm;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onosproject.yang.gen.v1.ydt.customs.supervisor.rev20160524.CustomssupervisorOpParam;
-import org.onosproject.yms.app.ych.defaultcodecs.YangCodecRegistry;
-import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider;
-import org.onosproject.yms.ych.YangCodecHandler;
-import org.onosproject.yms.ych.YangCompositeEncoding;
-import org.onosproject.yms.ych.YangDataTreeCodec;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static junit.framework.TestCase.assertNotNull;
-import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
-
-/**
- * Unit test case for YCH composite codec handler.
- */
-public class YchCompositeHandlerTest {
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private static final String REG_PREFIX = "RegisteredDataTreeCodec ";
- private static final String REG_ENCODE = REG_PREFIX +
- "encodeYdtToProtocolFormat Called.";
- private static final String REG_DECODE = REG_PREFIX +
- "decodeProtocolDataToYdt Called.";
- private static final String REG_COMPO_ENCODE = REG_PREFIX +
- "encodeYdtToCompositeProtocolFormat Called.";
- private static final String REG_COMPO_DECODE = REG_PREFIX +
- "decodeCompositeProtocolDataToYdt Called.";
- private static final String OVERRIDE_PREFIX = "OverriddenDataTreeCodec ";
- private static final String OVERRIDE_ENCODE = OVERRIDE_PREFIX +
- "encodeYdtToProtocolFormat Called.";
- private static final String OVERRIDE_DECODE = OVERRIDE_PREFIX +
- "decodeProtocolDataToYdt Called.";
- private static final String OVERRIDE_COMPO_ENCODE = OVERRIDE_PREFIX +
- "encodeYdtToCompositeProtocolFormat Called.";
- private static final String OVERRIDE_COMPO_DECODE = OVERRIDE_PREFIX +
- "decodeCompositeProtocolDataToYdt Called.";
-
- private TestYangSchemaNodeProvider provider =
- new TestYangSchemaNodeProvider();
-
- /**
- * Unit test case in which verifying codec handler is null or not.
- */
- @Test
- public void checkForCodecHandler() {
- YmsManager ymsManager = new YmsManager();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
- }
-
- /**
- * Unit test case in which verifying registered codec handler for encode is
- * null or not.
- */
- @Test
- public void checkForRegisterDefaultCodecEncode() {
- thrown.expectMessage(REG_ENCODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- YangCodecRegistry.initializeDefaultCodec();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- provider.processSchemaRegistry(null);
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- Object object = CustomssupervisorOpParam.builder()
- .supervisor("Customssupervisor").build();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
-
- yangCodecHandler.encodeOperation("filter", "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
- }
-
- /**
- * Unit test case in which verifying registered codec handler for decode is
- * null or not.
- */
- @Test
- public void checkForRegisterDefaultCodecDecode() {
- thrown.expectMessage(REG_DECODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- YangCodecRegistry.initializeDefaultCodec();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- provider.processSchemaRegistry(null);
- yangCodecHandler.decode("XML String", XML, null);
- }
-
- /**
- * Unit test case in which verifying registered codec handler for
- * composite encode is null or not.
- */
- @Test
- public void checkForRegisterDefaultCodecCompEncode() {
- thrown.expectMessage(REG_COMPO_ENCODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- YangCodecRegistry.initializeDefaultCodec();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- provider.processSchemaRegistry(null);
- // Creating the object
- Object object = CustomssupervisorOpParam.builder()
- .supervisor("Customssupervisor").build();
-
- yangCodecHandler.encodeCompositeOperation("filter",
- "ydt.filter-type", object,
- XML, null);
- }
-
- /**
- * Unit test case in which verifying registered codec handler for
- * composite decode is null or not.
- */
- @Test
- public void checkForRegisterDefaultCodecCompDecode() {
- thrown.expectMessage(REG_COMPO_DECODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- YangCodecRegistry.initializeDefaultCodec();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- provider.processSchemaRegistry(null);
- // Creating the object
- YangCompositeEncoding yangCompositeEncoding =
- new MockYangCompositeEncoding();
- yangCodecHandler.decode(yangCompositeEncoding, XML, null);
- }
-
- /**
- * Unit test case in which verifying overridden codec handler for encode is
- * null or not.
- */
- @Test
- public void checkForOverriddenDataTreeCodecEncode() {
- thrown.expectMessage(OVERRIDE_ENCODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- YangDataTreeCodec overriddenCodec = new MockOverriddenDataTreeCodec();
- yangCodecHandler.registerOverriddenCodec(overriddenCodec, XML);
-
- provider.processSchemaRegistry(null);
- List<Object> yangModuleList = new ArrayList<>();
-
- // Creating the object
- Object object = CustomssupervisorOpParam.builder()
- .supervisor("Customssupervisor").build();
- yangModuleList.add(object);
-
- // Get the xml string and compare
- Map<String, String> tagAttr = new HashMap<String, String>();
- tagAttr.put("type", "subtree");
- yangCodecHandler.encodeOperation("filter", "ydt.filter-type",
- tagAttr, yangModuleList,
- XML, null);
- }
-
- /**
- * Unit test case in which verifying overridden codec handler for decode is
- * null or not.
- */
- @Test
- public void checkForOverriddenDataTreeCodecDecode() {
- thrown.expectMessage(OVERRIDE_DECODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- YangDataTreeCodec overriddenCodec = new MockOverriddenDataTreeCodec();
- yangCodecHandler.registerOverriddenCodec(overriddenCodec, XML);
-
- provider.processSchemaRegistry(null);
- yangCodecHandler.decode("XML String", XML, null);
- }
-
- /**
- * Unit test case in which verifying overridden codec handler for
- * composite encode is null or not.
- */
- @Test
- public void checkForOverriddenDataTreeCodecCompoEncode() {
- thrown.expectMessage(OVERRIDE_COMPO_ENCODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- YangDataTreeCodec overriddenCodec = new MockOverriddenDataTreeCodec();
- yangCodecHandler.registerOverriddenCodec(overriddenCodec, XML);
-
- provider.processSchemaRegistry(null);
- // Creating the object
- Object object = CustomssupervisorOpParam.builder()
- .supervisor("Customssupervisor").build();
- yangCodecHandler.encodeCompositeOperation("filter",
- "ydt.filter-type",
- object,
- XML, null);
- }
-
- /**
- * Unit test case in which verifying overridden codec handler for
- * composite decode is null or not.
- */
- @Test
- public void checkForOverriddenDataTreeCodecCompoDecode() {
- thrown.expectMessage(OVERRIDE_COMPO_DECODE);
- YangDataTreeCodec yangDataTreeCodec = new MockRegisteredDataTreeCodec();
- YmsManager ymsManager = new YmsManager();
- ymsManager.coreService = new MockCoreService();
- ymsManager.activate();
- ymsManager.registerDefaultCodec(yangDataTreeCodec, XML);
- YangCodecHandler yangCodecHandler = ymsManager.getYangCodecHandler();
- assertNotNull("Codec handler is null", yangCodecHandler);
-
- YangDataTreeCodec overriddenCodec = new MockOverriddenDataTreeCodec();
- yangCodecHandler.registerOverriddenCodec(overriddenCodec, XML);
-
- provider.processSchemaRegistry(null);
- // Verify the received object list
- YangCompositeEncoding yangCompositeEncoding =
- new MockYangCompositeEncoding();
- yangCodecHandler.decode(yangCompositeEncoding, XML, null);
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobAugmentTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobAugmentTest.java
deleted file mode 100644
index c366c4b..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobAugmentTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.urn.ip.topo.rev20140101.ymsiptopology.node.AugmentedTopoNode;
-import org.onosproject.yang.gen.v1.urn.ip.topo.rev20140101.ymsiptopology.node.DefaultAugmentedTopoNode;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.YmsTopologyOpParam;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.DefaultNode;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.onosproject.yms.app.yob.YobTestUtils.NODE;
-import static org.onosproject.yms.app.yob.YobTestUtils.ROOT_DATA_RESOURCE;
-import static org.onosproject.yms.app.yob.YobTestUtils.ROUTER_ID;
-import static org.onosproject.yms.app.yob.YobTestUtils.ROUTER_IP;
-import static org.onosproject.yms.app.yob.YobTestUtils.STR_LEAF_VALUE;
-import static org.onosproject.yms.app.yob.YobTestUtils.TOPOLOGY;
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-
-/**
- * Test the YANG object building for the YANG data tree based on the non
- * schema augmented nodes.
- */
-public class YobAugmentTest {
-
- private YobTestUtils utils = YobTestUtils.instance();
-
- @Test
- public void augmentedLeaf() throws IOException {
-
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
-
- ydtBuilder.addChild(TOPOLOGY, null, NONE);
- ydtBuilder.addChild(NODE, null);
- ydtBuilder.addLeaf(ROUTER_ID, "urn:ip:topo", STR_LEAF_VALUE);
-
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertNotNull("Fail to create augmented YANG object", yangObject);
-
- assertEquals("invalid augmented node created", YmsTopologyOpParam.class,
- yangObject.getClass());
-
- YmsTopologyOpParam topology = (YmsTopologyOpParam) yangObject;
- assertNotNull("failed to build augmented node", topology.node());
- assertEquals("Single node entry is expected", 1, topology.node().size());
- assertEquals("Node type is not DefaultNode", DefaultNode.class,
- topology.node().get(0).getClass());
-
- DefaultNode node = (DefaultNode) topology.node().get(0);
- assertNotNull("Augmented info is missing", node.yangAugmentedInfo(
- AugmentedTopoNode.class));
- assertEquals("Augmented class is incorrect",
- DefaultAugmentedTopoNode.class,
- node.yangAugmentedInfo(AugmentedTopoNode.class)
- .getClass());
-
- DefaultAugmentedTopoNode augmentedNode = (DefaultAugmentedTopoNode)
- node.yangAugmentedInfo(AugmentedTopoNode.class);
- assertThat("Augmented leaf value is incorrect",
- augmentedNode.routerId(), is(STR_LEAF_VALUE));
- }
-
- @Test
- public void augmentedLeaves() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
-
- ydtBuilder.addChild(TOPOLOGY, null, NONE);
- ydtBuilder.addChild(NODE, null);
- ydtBuilder.addLeaf(ROUTER_ID, "urn:ip:topo", STR_LEAF_VALUE);
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(ROUTER_IP, "urn:ip:topo", STR_LEAF_VALUE);
-
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertNotNull("Fail to create augmented YANG object", yangObject);
-
- assertEquals("invalid augmented node created",
- YmsTopologyOpParam.class, yangObject.getClass());
-
- YmsTopologyOpParam topology = (YmsTopologyOpParam) yangObject;
- assertNotNull("failed to build augmented node", topology.node());
- assertEquals("Single node entry is expected", 1,
- topology.node().size());
- assertEquals("Node type is not DefaultNode", DefaultNode.class,
- topology.node().get(0).getClass());
-
- DefaultNode node = (DefaultNode) topology.node().get(0);
- assertNotNull("Augmented info is missing", node.yangAugmentedInfo(
- AugmentedTopoNode.class));
- assertEquals("Augmented class is incorrect",
- DefaultAugmentedTopoNode.class,
- node.yangAugmentedInfo(AugmentedTopoNode.class)
- .getClass());
-
- DefaultAugmentedTopoNode augmentedNode = (DefaultAugmentedTopoNode)
- node.yangAugmentedInfo(AugmentedTopoNode.class);
- assertThat("Augmented router id is incorrect",
- augmentedNode.routerId(), is(STR_LEAF_VALUE));
- assertThat("Augmented router ip is incorrect",
- augmentedNode.routerIp(), is(STR_LEAF_VALUE));
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobBinaryTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobBinaryTest.java
deleted file mode 100644
index 2b3d4cb..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobBinaryTest.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.ydt.binarytest.rev20160524.BinarytestOpParam;
-import org.onosproject.yang.gen.v1.ydt.binarytest.rev20160524.binarytest.cont1.AugmentedCont1;
-import org.onosproject.yang.gen.v1.ydt.binarytest.rev20160524.binarytest.food.snack.Sportsarena;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.onosproject.yms.app.yob.YobTestUtils.ROOT_DATA_RESOURCE;
-
-/**
- * Test the YANG object building for the YANG data tree based on the binary.
- */
-public class YobBinaryTest {
-
- private YobTestUtils utils = YobTestUtils.instance();
-
- @Test
- public void testBinaryInLeaf() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("binarytest", "ydt.binarytest");
- ydtBuilder.addChild("binaryList", null);
- ydtBuilder.addLeaf("binary", null, "YmluYXJ5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BinarytestOpParam binarytestOpParam = ((BinarytestOpParam) yangObject);
-
- byte[] binaryValue = binarytestOpParam.binaryList().get(0).binary();
- String value = new String(binaryValue);
- assertThat(value, is("binary"));
- }
-
- @Test
- public void testBinaryInTypedef() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("binarytest", "ydt.binarytest");
- ydtBuilder.addLeaf("name", null, "YmluYXJ5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BinarytestOpParam binarytestOpParam = ((BinarytestOpParam) yangObject);
-
- byte[] binaryValue = binarytestOpParam.name().binary();
- String value = new String(binaryValue);
- assertThat(value, is("binary"));
- }
-
- @Test
- public void testBinaryInGrouping() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("binarytest", "ydt.binarytest");
- ydtBuilder.addChild("cont1", "ydt.binarytest");
- ydtBuilder.addLeaf("surname", null, "YmluYXJ5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BinarytestOpParam binarytestOpParam = ((BinarytestOpParam) yangObject);
-
- byte[] binaryValue = binarytestOpParam.cont1().surname();
- String value = new String(binaryValue);
- assertThat(value, is("binary"));
- }
-
- @Test
- public void testBinaryInAugment() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("binarytest", "ydt.binarytest");
- ydtBuilder.addChild("cont1", "ydt.binarytest");
- ydtBuilder.addLeaf("lastname", null, "YmluYXJ5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BinarytestOpParam binarytestOpParam = ((BinarytestOpParam) yangObject);
-
- AugmentedCont1 augmentedCont1 = (AugmentedCont1) binarytestOpParam.cont1()
- .yangAugmentedInfo(AugmentedCont1.class);
- byte[] binaryValue = augmentedCont1.lastname();
- String value = new String(binaryValue);
- assertThat(value, is("binary"));
- }
-
- @Test
- public void testBinaryInCase() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("binarytest", "ydt.binarytest");
- ydtBuilder.addChild("food", "ydt.binarytest");
- ydtBuilder.addLeaf("pretzel", null, "YmluYXJ5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BinarytestOpParam binarytestOpParam = ((BinarytestOpParam) yangObject);
- Sportsarena sportsArena = ((Sportsarena) binarytestOpParam.food()
- .snack());
- byte[] binaryValue = sportsArena.pretzel();
- String value = new String(binaryValue);
- assertThat(value, is("binary"));
- }
-
- @Test
- public void testBinaryInUnion() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("binarytest", "ydt.binarytest");
- ydtBuilder.addLeaf("middlename", null, "YmluYXJ5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BinarytestOpParam binarytestOpParam = ((BinarytestOpParam) yangObject);
-
- byte[] binaryValue = binarytestOpParam.middlename().binary();
- String value = new String(binaryValue);
- assertThat(value, is("binary"));
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobBitTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobBitTest.java
deleted file mode 100644
index 565576f..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobBitTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.ydt.bit.rev20160524.BitOpParam;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YmsOperationType;
-
-import java.io.IOException;
-
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onosproject.yms.app.yob.YobTestUtils.ROOT_DATA_RESOURCE;
-
-/**
- * Test the YANG object building for the YDT based on the bits.
- */
-public class YobBitTest {
-
- private YobTestUtils utils = YobTestUtils.instance();
-
- @Test
- public void testBitsInLeaf() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("bit", "ydt.bit");
- ydtBuilder.addChild("bitList", null);
- ydtBuilder.addLeaf("bit", null, "disable-nagle");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("bitList", null);
- ydtBuilder.addLeaf("bit", null, "auto-sense-speed");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.addChild("bitList", null);
- ydtBuilder.addLeaf("bit", null, "ten-Mb-only");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BitOpParam bitOpParam = ((BitOpParam) yangObject);
-
- assertThat(bitOpParam.bitList().get(0).bit().get(0), is(true));
- assertThat(bitOpParam.bitList().get(0).bit().get(1), is(false));
- assertThat(bitOpParam.bitList().get(1).bit().get(0), is(false));
- assertThat(bitOpParam.bitList().get(1).bit().get(1), is(true));
- assertThat(bitOpParam.bitList().get(2).bit().get(0), is(false));
- assertThat(bitOpParam.bitList().get(2).bit().get(1), is(false));
- assertThat(bitOpParam.bitList().get(2).bit().get(2), is(true));
- assertThat(bitOpParam.bitList().get(2).bit().get(2), is(true));
- }
-
- @Test
- public void testBitsInTypedef() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("bit", "ydt.bit");
- ydtBuilder.addLeaf("name", null, "bit3");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BitOpParam bitOpParam = ((BitOpParam) yangObject);
-
- assertThat(bitOpParam.name().bits().get(0), is(false));
- assertThat(bitOpParam.name().bits().get(3), is(true));
- }
-
- @Test
- public void testBitsQuery() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, YmsOperationType.QUERY_REQUEST,
- utils.schemaRegistry(), true);
- ydtBuilder.addChild("bit", "ydt.bit");
- ydtBuilder.addChild("name", "ydt.bit");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- BitOpParam bitOpParam = ((BitOpParam) yangObject);
- assertThat(bitOpParam.selectLeafFlags().get(1), is(true));
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobBooleanTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobBooleanTest.java
deleted file mode 100644
index ea87ca7..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobBooleanTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-import java.util.List;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public class YobBooleanTest {
-
- private static final String BOOLEAN_LIST = "booleanList";
- private static final String AUTO_PREFIX_BOOLEAN = "yangAutoPrefixBoolean";
-
- /*
- BOOLEAN
- Positive scenario
- input with in true and false
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.booleanYdt();
- validateYangObject(defaultYdtBuilder);
- }
-
- private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
-
- Field field = yangObject.getClass().getDeclaredField(BOOLEAN_LIST);
- field.setAccessible(true);
- List booleanList = (List) field.get(yangObject);
- Field invalidInterval = booleanList.get(0).getClass()
- .getDeclaredField(AUTO_PREFIX_BOOLEAN);
- invalidInterval.setAccessible(true);
- assertTrue((boolean) invalidInterval.get(booleanList.get(0)));
- assertFalse((boolean) invalidInterval.get(booleanList.get(1)));
- } catch (NoSuchFieldException | IllegalAccessException e) {
- Assert.fail();
- }
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobChoiceTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobChoiceTest.java
deleted file mode 100644
index fdad2ec..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobChoiceTest.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.YmsTopologyOpParam;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.DefaultNode;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.Node;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.Case1a;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.Case1b;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.DefaultCase1a;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.DefaultCase1b;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.case1b.choice1b.Case1Bi;
-import org.onosproject.yang.gen.v1.urn.topo.rev20140101.ymstopology.node.choice1.case1b.choice1b.DefaultCase1Bi;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.onosproject.yms.app.yob.YobTestUtils.LEAF_1A1;
-import static org.onosproject.yms.app.yob.YobTestUtils.LEAF_1A2;
-import static org.onosproject.yms.app.yob.YobTestUtils.LEAF_1BIA;
-import static org.onosproject.yms.app.yob.YobTestUtils.LEAF_1BIB;
-import static org.onosproject.yms.app.yob.YobTestUtils.NODE;
-import static org.onosproject.yms.app.yob.YobTestUtils.ROOT_DATA_RESOURCE;
-import static org.onosproject.yms.app.yob.YobTestUtils.STR_LEAF_VALUE;
-import static org.onosproject.yms.app.yob.YobTestUtils.TOPOLOGY;
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-
-/**
- * Test the YANG object building for the YANG data tree based on the non
- * schema choice and case nodes.
- */
-public class YobChoiceTest {
-
- private YobTestUtils utils = YobTestUtils.instance();
-
- @Test
- public void caseInChoice() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
-
- ydtBuilder.addChild(TOPOLOGY, null, NONE);
- ydtBuilder.addChild(NODE, null);
- ydtBuilder.addLeaf(LEAF_1A1, null, STR_LEAF_VALUE);
-
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertNotNull(yangObject);
- assertEquals("YANG object created is not topology object",
- YmsTopologyOpParam.class, yangObject.getClass());
-
- YmsTopologyOpParam topology = (YmsTopologyOpParam) yangObject;
- assertNotNull("Failed to build the object", topology.node());
- assertEquals("Single node entry is expected", 1,
- topology.node().size());
- assertEquals("Node type is not DefaultNode", DefaultNode.class,
- topology.node().get(0).getClass());
-
- Node node = topology.node().get(0);
- assertNotNull("choice1 is not set in node", node.choice1());
- assertEquals("choice 1 type is not ", DefaultCase1a.class,
- node.choice1().getClass());
-
- Case1a case1a = (Case1a) node.choice1();
- assertNotNull("leaf1a1 is not set in case", case1a.leaf1A1());
- assertEquals("leaf1a1 type is not correct", String.class,
- case1a.leaf1A1().getClass());
- assertEquals("leaf1a1 value is not correct", STR_LEAF_VALUE,
- case1a.leaf1A1());
-
- }
-
- @Test
- public void caseWithMultiAttribute() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
-
- ydtBuilder.addChild(TOPOLOGY, null, NONE);
- ydtBuilder.addChild(NODE, null);
- ydtBuilder.addLeaf(LEAF_1A1, null, STR_LEAF_VALUE);
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(LEAF_1A2, null, STR_LEAF_VALUE);
-
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertNotNull(yangObject);
- assertEquals("YANG object created is not topology object",
- YmsTopologyOpParam.class, yangObject.getClass());
-
- YmsTopologyOpParam topology = (YmsTopologyOpParam) yangObject;
- assertNotNull("Failed to build the object", topology.node());
- assertEquals("Single node entry is expected", 1,
- topology.node().size());
- assertEquals("Node type is not DefaultNode", DefaultNode.class,
- topology.node().get(0).getClass());
-
- Node node = topology.node().get(0);
- assertNotNull("choice1 is not set in node", node.choice1());
- assertEquals("choice 1 type is not ", DefaultCase1a.class,
- node.choice1().getClass());
-
- Case1a case1a = (Case1a) node.choice1();
- assertNotNull("leaf1a1 is not set in case", case1a.leaf1A1());
- assertEquals("leaf1a1 type is not correct", String.class,
- case1a.leaf1A1().getClass());
- assertEquals("leaf1a1 value is not correct", STR_LEAF_VALUE,
- case1a.leaf1A1());
-
- assertNotNull("leaf1a2 is not set in case", case1a.leaf1A2());
- assertEquals("leaf1a2 type is not correct", String.class,
- case1a.leaf1A2().getClass());
- assertEquals("leaf1a1 value is not correct", STR_LEAF_VALUE,
- case1a.leaf1A1());
-
- }
-
- @Test
- public void recursiveChoice() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
-
- ydtBuilder.addChild(TOPOLOGY, null, NONE);
- ydtBuilder.addChild(NODE, null);
- ydtBuilder.addLeaf(LEAF_1BIA, null, STR_LEAF_VALUE);
-
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertNotNull(yangObject);
- assertEquals("YANG object created is not topology object",
- YmsTopologyOpParam.class, yangObject.getClass());
-
- YmsTopologyOpParam topology = (YmsTopologyOpParam) yangObject;
- assertNotNull("Failed to build the object", topology.node());
- assertEquals("Single node entry is expected", 1,
- topology.node().size());
- assertEquals("Node type is not DefaultNode", DefaultNode.class,
- topology.node().get(0).getClass());
-
- Node node = topology.node().get(0);
- assertNotNull("Choice 1 is not set in Node", node.choice1());
- assertEquals("Choice 1 is not of type DefaultCase1b",
- DefaultCase1b.class, node.choice1().getClass());
-
- Case1b case1b = (Case1b) node.choice1();
- assertNotNull("Case1b does not have child choice1b ",
- case1b.choice1b());
- assertEquals("choice1b is not of type DefaultCase1Bi",
- DefaultCase1Bi.class, case1b.choice1b().getClass());
-
- Case1Bi case1Bi = (Case1Bi) case1b.choice1b();
- assertNotNull("leaf1bia is not set", case1Bi.leaf1Bia());
- assertEquals("leaf1bia type is not string", String.class,
- case1Bi.leaf1Bia().getClass());
- assertEquals("leaf1bia value is wrong", STR_LEAF_VALUE,
- case1Bi.leaf1Bia());
- }
-
- @Test
- public void recursiveChoiceWithMultipleAttribute() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
-
- ydtBuilder.addChild(TOPOLOGY, null, NONE);
- ydtBuilder.addChild(NODE, null);
- ydtBuilder.addLeaf(LEAF_1BIA, null, STR_LEAF_VALUE);
- ydtBuilder.traverseToParent();
- ydtBuilder.addLeaf(LEAF_1BIB, null, STR_LEAF_VALUE);
-
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertNotNull(yangObject);
- assertEquals("YANG object created is not topology object",
- YmsTopologyOpParam.class, yangObject.getClass());
-
- YmsTopologyOpParam topology = (YmsTopologyOpParam) yangObject;
- assertNotNull("Failed to build the object", topology.node());
- assertEquals("Single node entry is expected", 1,
- topology.node().size());
- assertEquals("Node type is not DefaultNode", DefaultNode.class,
- topology.node().get(0).getClass());
-
- Node node = topology.node().get(0);
- assertNotNull("Choice 1 is not set in Node", node.choice1());
- assertEquals("Choice 1 is not of type DefaultCase1b",
- DefaultCase1b.class,
- node.choice1().getClass());
-
- Case1b case1b = (Case1b) node.choice1();
- assertNotNull("Case1b does not have child choice1b ",
- case1b.choice1b());
- assertEquals("choice1b is not of type DefaultCase1Bi",
- DefaultCase1Bi.class,
- case1b.choice1b().getClass());
-
- Case1Bi case1Bi = (Case1Bi) case1b.choice1b();
- assertNotNull("leaf1bia is not set", case1Bi.leaf1Bia());
- assertEquals("leaf1bia type is not string", String.class,
- case1Bi.leaf1Bia().getClass());
- assertEquals("leaf1bia value is wrong", STR_LEAF_VALUE,
- case1Bi.leaf1Bia());
-
- assertNotNull("leaf1bib is not set", case1Bi.leaf1Bib());
- assertEquals("leaf1bia type is not string", String.class,
- case1Bi.leaf1Bib().getClass());
- assertEquals("leaf1bia value is wrong", STR_LEAF_VALUE,
- case1Bi.leaf1Bib());
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobDecimal64Test.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobDecimal64Test.java
deleted file mode 100644
index d0b9f1e..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobDecimal64Test.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class YobDecimal64Test {
-
- /*
-
- Positive scenario
-
- input at boundary for decimal64 with fraction 2
- i. min value
- ii. max value
-
- input at boundary for decimal64 with minimum fraction
- i. min value
- ii. mid value
- iii. max value
-
- input at boundary for decimal64 with maximum fraction
- i. min value
- ii. mid value
- iii. max value
-
- input with in range
- if range is 10 to 100 for integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- input with multi interval range
- if range is 10..40 | 50..100 for decimal64
- i.1. input 11
- i.2. input 10
- i.3. input 40
- i.4. input 50
- i.5. input 55
- i.6. input 100
-
- if range is "min .. 3.14 | 10 | 20..max" for decimal64
- i.1. input min
- i.2. input 2.505
- i.3. input 3.14
- i.4. input 10
- i.5. input 20
- i.6. input 92233720368547757
- i.7. input 92233720368547758.07
-
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.decimal64Ydt();
- validateYangObject(defaultYdtBuilder);
- }
-
- private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
- Field negInt = yangObject.getClass().getDeclaredField("negInt");
- negInt.setAccessible(true);
- assertEquals("-92233720368547758.08", negInt
- .get(yangObject).toString());
- Field negIntWithMaxFraction = yangObject.getClass()
- .getDeclaredField("negIntWithMaxFraction");
- negIntWithMaxFraction.setAccessible(true);
- assertEquals("-9.223372036854775808", negIntWithMaxFraction
- .get(yangObject).toString());
- Field negIntWithMinFraction = yangObject.getClass()
- .getDeclaredField("negIntWithMinFraction");
- negIntWithMinFraction.setAccessible(true);
- assertEquals("-922337203685477580.8", negIntWithMinFraction
- .get(yangObject).toString());
- Field posInt = yangObject.getClass()
- .getDeclaredField("posInt");
- posInt.setAccessible(true);
- assertEquals("92233720368547758.07", posInt
- .get(yangObject).toString());
- Field posIntWithMaxFraction = yangObject
- .getClass().getDeclaredField("posIntWithMaxFraction");
- posIntWithMaxFraction.setAccessible(true);
- assertEquals("9.223372036854775807", posIntWithMaxFraction
- .get(yangObject).toString());
- Field posIntWithMinFraction = yangObject.getClass()
- .getDeclaredField("posIntWithMinFraction");
- posIntWithMinFraction.setAccessible(true);
- assertEquals("922337203685477580.7", posIntWithMinFraction
- .get(yangObject).toString());
- Field minIntWithRange = yangObject.getClass()
- .getDeclaredField("minIntWithRange");
- minIntWithRange.setAccessible(true);
- assertEquals("10", minIntWithRange
- .get(yangObject).toString());
- Field midIntWithRange = yangObject
- .getClass().getDeclaredField("midIntWithRange");
- midIntWithRange.setAccessible(true);
- assertEquals("11", midIntWithRange.get(yangObject).toString());
- Field maxIntWithRange = yangObject
- .getClass().getDeclaredField("maxIntWithRange");
- maxIntWithRange.setAccessible(true);
- assertEquals("100", maxIntWithRange.get(yangObject).toString());
- } catch (IllegalAccessException | NoSuchFieldException e) {
- Assert.fail();
- }
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobEmptyTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobEmptyTest.java
deleted file mode 100644
index 6a3fc05..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobEmptyTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-/**
- * Test the YANG object building for the YANG data tree based on the schema
- * nodes with empty data type.
- */
-public class YobEmptyTest {
-
- /*
- EMPTY
- Positive scenario
- input with in empty.
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.emptyTypeYdt();
- validateYangObject(defaultYdtBuilder);
- }
-
- private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
-
- try {
- Field field = yangObject.getClass().getDeclaredField("emptyList");
- field.setAccessible(true);
- List booleanList = (List) field.get(yangObject);
- Field invalidInterval = booleanList.get(0)
- .getClass().getDeclaredField("empty");
- invalidInterval.setAccessible(true);
- assertEquals(true, invalidInterval.get(booleanList.get(0)));
- } catch (NoSuchFieldException | IllegalAccessException e) {
- fail();
- }
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobEnumTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobEnumTest.java
deleted file mode 100644
index 48eda96..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobEnumTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class YobEnumTest {
-
-/*
- ENUM
-
- Positive scenario
-
- input with in enum
- input with "ten"
- input with "hundred"
- input with "thousand"
-*/
-
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.enumYdt();
- validateYangObject(defaultYdtBuilder);
- }
-
- private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
- Field field = yangObject.getClass().getDeclaredField("enumList");
- field.setAccessible(true);
- List enumList = (List) field.get(yangObject);
- assertEquals(false, enumList.isEmpty());
- Field enumleaf = enumList.get(0)
- .getClass().getDeclaredField("enumleaf");
- enumleaf.setAccessible(true);
- assertEquals("ten", enumleaf
- .get(enumList.get(0)).toString().toLowerCase());
- assertEquals("hundred", enumleaf
- .get(enumList.get(1)).toString().toLowerCase());
- assertEquals("thousand", enumleaf
- .get(enumList.get(2)).toString().toLowerCase());
- } catch (IllegalAccessException | NoSuchFieldException e) {
- Assert.fail();
- }
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobGroupingUsesTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobGroupingUsesTest.java
deleted file mode 100644
index 08b2484..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobGroupingUsesTest.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.YmsIetfNetworkOpParam;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.networksstate.Network;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.YmsNetworkTopology;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.ymsnetworktopology.networks.network.AugmentedNdNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.ymsnetworktopology.networks.network.DefaultAugmentedNdNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.ymsnetworktopology.networks.network.augmentedndnetwork.Link;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160317.YmsIetfTeTopology;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160317.YmsIetfTeTopologyOpParam;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160317.ymsietftetopology.TeAdminStatus;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160317.ymsietftetopology.networks.network.link.AugmentedNtLink;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160317.ymsietftetopology.networks.network.link.DefaultAugmentedNtLink;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160317.ymsietftetopology.teadminstatus.TeAdminStatusEnum;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160317.ymsietftetopology.telinkconfig.bundlestacklevel.DefaultBundle;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20160317.ymsietftetopology.telinkconfig.bundlestacklevel.bundle.bundledlinks.BundledLink;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.onosproject.yms.app.yob.YobTestUtils.ADMIN_STATUS;
-import static org.onosproject.yms.app.yob.YobTestUtils.BUNDLED_LINK;
-import static org.onosproject.yms.app.yob.YobTestUtils.BUNDLED_LINKS;
-import static org.onosproject.yms.app.yob.YobTestUtils.CONFIG;
-import static org.onosproject.yms.app.yob.YobTestUtils.IETF_TE_TOPOLOGY;
-import static org.onosproject.yms.app.yob.YobTestUtils.LINK;
-import static org.onosproject.yms.app.yob.YobTestUtils.NETWORK;
-import static org.onosproject.yms.app.yob.YobTestUtils.NETWORKS;
-import static org.onosproject.yms.app.yob.YobTestUtils.NETWORKS_STATE;
-import static org.onosproject.yms.app.yob.YobTestUtils.NETWORK_REF;
-import static org.onosproject.yms.app.yob.YobTestUtils.ROOT_DATA_RESOURCE;
-import static org.onosproject.yms.app.yob.YobTestUtils.SEQUENCE;
-import static org.onosproject.yms.app.yob.YobTestUtils.STR_LEAF_VALUE;
-import static org.onosproject.yms.app.yob.YobTestUtils.TE;
-import static org.onosproject.yms.app.yob.YobTestUtils.TE_LINK_TEMPLATE;
-import static org.onosproject.yms.app.yob.YobTestUtils.TE_NODE_ATTRIBUTES;
-import static org.onosproject.yms.app.yob.YobTestUtils.TE_NODE_EVENT;
-import static org.onosproject.yms.app.yob.YobTestUtils.UP;
-import static org.onosproject.yms.app.yob.YobTestUtils.YMS_IETF_NETWORK;
-import static org.onosproject.yms.app.yob.YobTestUtils.YMS_NETWORK_TOPOLOGY;
-import static org.onosproject.yms.ydt.YdtContextOperationType.CREATE;
-
-/**
- * Test the YANG object building for the YANG data tree based on the grouping
- * and uses nodes.
- */
-public class YobGroupingUsesTest {
-
- private YobTestUtils utils = YobTestUtils.instance();
-
- @Test
- public void testGroupingUsesLeaf() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild(YMS_IETF_NETWORK, null, CREATE);
- ydtBuilder.addChild(NETWORKS_STATE, null);
- ydtBuilder.addChild(NETWORK, null);
- ydtBuilder.addLeaf(NETWORK_REF, null, STR_LEAF_VALUE);
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertThat(yangObject, is(notNullValue()));
- YmsIetfNetworkOpParam ietfNetwork = (YmsIetfNetworkOpParam) yangObject;
- Network network = ietfNetwork.networksState().network().iterator().next();
- assertThat(network.networkRef(), is(STR_LEAF_VALUE));
- }
-
- @Test
- public void testGroupingUsesContainer() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild(IETF_TE_TOPOLOGY, null, CREATE);
- ydtBuilder.addChild(TE_NODE_EVENT, null);
- ydtBuilder.addChild(TE_NODE_ATTRIBUTES, null);
- ydtBuilder.addLeaf(ADMIN_STATUS, null, UP);
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertThat(yangObject, is(notNullValue()));
- YmsIetfTeTopologyOpParam ietfTeTopology = (YmsIetfTeTopologyOpParam)
- yangObject;
- TeAdminStatus adminStatus = ietfTeTopology.teNodeEvent()
- .teNodeAttributes()
- .adminStatus();
- assertThat(adminStatus.enumeration(), is(TeAdminStatusEnum.UP));
- }
-
- @Test
- public void testGroupingUsesInterfile() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild(YMS_IETF_NETWORK, null, CREATE);
- ydtBuilder.addChild(NETWORKS, null);
- ydtBuilder.addChild(NETWORK, null);
- ydtBuilder.addChild(LINK, YMS_NETWORK_TOPOLOGY);
- ydtBuilder.addChild(TE, IETF_TE_TOPOLOGY);
- ydtBuilder.addChild(CONFIG, IETF_TE_TOPOLOGY);
- ydtBuilder.addChild(BUNDLED_LINKS, IETF_TE_TOPOLOGY);
- ydtBuilder.addChild(BUNDLED_LINK, IETF_TE_TOPOLOGY);
- ydtBuilder.addLeaf(SEQUENCE, null, "1");
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertThat(yangObject, is(notNullValue()));
- YmsIetfNetworkOpParam ietfNetwork = (YmsIetfNetworkOpParam) yangObject;
-
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang
- .ietf.network.rev20151208.ymsietfnetwork
- .networks.Network network = ietfNetwork.networks().network().get(0);
-
- DefaultAugmentedNdNetwork augmentedNdNetworks = (DefaultAugmentedNdNetwork) network
- .yangAugmentedInfo(AugmentedNdNetwork.class);
- assertThat(augmentedNdNetworks.yangAugmentedNdNetworkOpType(),
- is(YmsNetworkTopology.OnosYangOpType.CREATE));
-
- Link link = augmentedNdNetworks.link().get(0);
- DefaultAugmentedNtLink augmentedNtLink = (DefaultAugmentedNtLink) link
- .yangAugmentedInfo(AugmentedNtLink.class);
- assertThat(augmentedNtLink.yangAugmentedNtLinkOpType(),
- is(YmsIetfTeTopology.OnosYangOpType.CREATE));
-
- DefaultBundle bundleStackLevel = (DefaultBundle) augmentedNtLink.te()
- .config().bundleStackLevel();
- assertThat(bundleStackLevel.yangBundleOpType(),
- is(YmsIetfTeTopology.OnosYangOpType.CREATE));
-
- BundledLink bundledLink = bundleStackLevel.bundledLinks().bundledLink().get(0);
- assertThat(bundledLink.yangBundledLinkOpType(),
- is(YmsIetfTeTopology.OnosYangOpType.CREATE));
- assertThat(bundledLink.sequence(), is(1L));
- }
-
- @Test
- public void testGroupingUsesAugment() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild(YMS_IETF_NETWORK, null, CREATE);
- ydtBuilder.addChild(NETWORKS, null);
- ydtBuilder.addChild(NETWORK, null);
- ydtBuilder.addChild(LINK, YMS_NETWORK_TOPOLOGY);
- ydtBuilder.addChild(TE, IETF_TE_TOPOLOGY);
- ydtBuilder.addChild(CONFIG, IETF_TE_TOPOLOGY);
- ydtBuilder.addLeaf(TE_LINK_TEMPLATE, null, "1");
- YdtContext logicalRoot = ydtBuilder.getRootNode();
- YdtExtendedContext appRoot =
- (YdtExtendedContext) logicalRoot.getFirstChild();
-
- DefaultYobBuilder yobBuilder = new DefaultYobBuilder();
- Object yangObject = yobBuilder.getYangObject(appRoot,
- utils.schemaRegistry());
- assertThat(yangObject, is(notNullValue()));
- YmsIetfNetworkOpParam ietfNetwork = (YmsIetfNetworkOpParam) yangObject;
-
- org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang
- .ietf.network.rev20151208.ymsietfnetwork
- .networks.Network network = ietfNetwork.networks().network().get(0);
-
- DefaultAugmentedNdNetwork augmentedNdNetworks = (DefaultAugmentedNdNetwork) network
- .yangAugmentedInfo(AugmentedNdNetwork.class);
- assertThat(augmentedNdNetworks.yangAugmentedNdNetworkOpType(),
- is(YmsNetworkTopology.OnosYangOpType.CREATE));
-
- Link link = augmentedNdNetworks.link().get(0);
- DefaultAugmentedNtLink augmentedNtLink = (DefaultAugmentedNtLink) link
- .yangAugmentedInfo(AugmentedNtLink.class);
- assertThat(augmentedNtLink.yangAugmentedNtLinkOpType(),
- is(YmsIetfTeTopology.OnosYangOpType.CREATE));
-
- assertThat(augmentedNtLink.te().config().teLinkTemplate().get(0),
- is("1"));
- }
-}
-
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobIetfNetworkTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobIetfNetworkTest.java
deleted file mode 100644
index df6df658..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobIetfNetworkTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import static org.junit.Assert.assertNotNull;
-
-public class YobIetfNetworkTest {
-
- @Test
- public void ietfNetwork1Test() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.ietfNetwork1Ydt();
- validateYangObject(defaultYdtBuilder);
- }
-
- private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- //TODO yangObject need to verify
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobInteger16Test.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobInteger16Test.java
deleted file mode 100644
index 650a958..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobInteger16Test.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class YobInteger16Test {
-
- /*
-
- Positive scenario
-
- input at boundary for integer
- i. min value
- ii. max value
-
- input at boundary for unsigned integer
- i. min value
- ii. max value
-
- input with in range
- if range is 10 to 100 for integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- if range is 10 to 100 for unsigned integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.integer16Ydt();
- validateYangObject(defaultYdtBuilder);
- }
-
- public void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
- Field negInt = yangObject.getClass().getDeclaredField("negInt");
- negInt.setAccessible(true);
- assertEquals("-32768", negInt.get(yangObject).toString());
- Field posInt = yangObject.getClass().getDeclaredField("posInt");
- posInt.setAccessible(true);
- assertEquals("32767", posInt.get(yangObject).toString());
- Field minIntWithRange = yangObject
- .getClass().getDeclaredField("minIntWithRange");
- minIntWithRange.setAccessible(true);
- assertEquals("10", minIntWithRange.get(yangObject).toString());
- Field midIntWithRange = yangObject
- .getClass().getDeclaredField("midIntWithRange");
- midIntWithRange.setAccessible(true);
- assertEquals("11", midIntWithRange.get(yangObject).toString());
- Field maxIntWithRange = yangObject
- .getClass().getDeclaredField("maxIntWithRange");
- maxIntWithRange.setAccessible(true);
- assertEquals("100", maxIntWithRange.get(yangObject).toString());
- Field minUint = yangObject.getClass().getDeclaredField("minUint");
- minUint.setAccessible(true);
- assertEquals("0", minUint.get(yangObject).toString());
- Field maxUint = yangObject.getClass().getDeclaredField("maxUint");
- maxUint.setAccessible(true);
- assertEquals("65535", maxUint.get(yangObject).toString());
- Field minUintWithRange = yangObject
- .getClass().getDeclaredField("minUintWithRange");
- minUintWithRange.setAccessible(true);
- assertEquals("10", minUintWithRange.get(yangObject).toString());
- Field midUintWithRange = yangObject
- .getClass().getDeclaredField("midUintWithRange");
- midUintWithRange.setAccessible(true);
- assertEquals("11", midUintWithRange.get(yangObject).toString());
- Field maxUintWithRange = yangObject
- .getClass().getDeclaredField("maxUintWithRange");
- maxUintWithRange.setAccessible(true);
- assertEquals("100", maxUintWithRange.get(yangObject).toString());
- } catch (IllegalAccessException | NoSuchFieldException e) {
- Assert.fail();
- }
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobInteger32Test.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobInteger32Test.java
deleted file mode 100644
index 663b544..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobInteger32Test.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class YobInteger32Test {
-
- /*
-
- Positive scenario
-
- input at boundary for integer
- i. min value
- ii. max value
-
- input at boundary for unsigned integer
- i. min value
- ii. max value
-
- input with in range
- if range is 10 to 100 for integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- if range is 10 to 100 for unsigned integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.integer32Ydt();
- validateYangObject(defaultYdtBuilder);
- }
-
- public void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
- Field negInt = yangObject.getClass().getDeclaredField("negInt");
- negInt.setAccessible(true);
- assertEquals("-2147483648", negInt.get(yangObject).toString());
- Field posInt = yangObject.getClass().getDeclaredField("posInt");
- posInt.setAccessible(true);
- assertEquals("2147483647", posInt.get(yangObject).toString());
- Field minIntWithRange = yangObject
- .getClass().getDeclaredField("minIntWithRange");
- minIntWithRange.setAccessible(true);
- assertEquals("10", minIntWithRange.get(yangObject).toString());
- Field midIntWithRange = yangObject
- .getClass().getDeclaredField("midIntWithRange");
- midIntWithRange.setAccessible(true);
- assertEquals("11", midIntWithRange.get(yangObject).toString());
- Field maxIntWithRange = yangObject
- .getClass().getDeclaredField("maxIntWithRange");
- maxIntWithRange.setAccessible(true);
- assertEquals("100", maxIntWithRange.get(yangObject).toString());
- Field minUint = yangObject.getClass().getDeclaredField("minUint");
- minUint.setAccessible(true);
- assertEquals("0", minUint.get(yangObject).toString());
- Field maxUint = yangObject.getClass().getDeclaredField("maxUint");
- maxUint.setAccessible(true);
- assertEquals("4294967295", maxUint.get(yangObject).toString());
- Field minUintWithRange = yangObject
- .getClass().getDeclaredField("minUintWithRange");
- minUintWithRange.setAccessible(true);
- assertEquals("10", minUintWithRange.get(yangObject).toString());
- Field midUintWithRange = yangObject
- .getClass().getDeclaredField("midUintWithRange");
- midUintWithRange.setAccessible(true);
- assertEquals("11", midUintWithRange.get(yangObject).toString());
- Field maxUintWithRange = yangObject
- .getClass().getDeclaredField("maxUintWithRange");
- maxUintWithRange.setAccessible(true);
- assertEquals("100", maxUintWithRange.get(yangObject).toString());
- } catch (IllegalAccessException | NoSuchFieldException e) {
- Assert.fail();
- }
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobInteger64Test.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobInteger64Test.java
deleted file mode 100644
index 0f3ba8b..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobInteger64Test.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-
-public class YobInteger64Test {
-
- /*
-
- Positive scenario
-
- input at boundary for integer
- i. min value
- ii. max value
-
- input at boundary for unsigned integer
- i. min value
- ii. max value
-
- input with in range
- if range is 10 to 100 for integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- if range is 10 to 100 for unsigned integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.integer64Ydt();
- validateYangObject(defaultYdtBuilder);
- }
-
- private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
- Field negInt = yangObject.getClass().getDeclaredField("negInt");
- negInt.setAccessible(true);
- assertEquals("-9223372036854775808", negInt
- .get(yangObject).toString());
- Field posIntField = yangObject
- .getClass().getDeclaredField("posInt");
- posIntField.setAccessible(true);
- assertEquals("9223372036854775807", posIntField
- .get(yangObject).toString());
- Field minIntWithRange = yangObject
- .getClass().getDeclaredField("minIntWithRange");
- minIntWithRange.setAccessible(true);
- assertEquals("10", minIntWithRange.get(yangObject).toString());
- Field midIntWithRange = yangObject
- .getClass().getDeclaredField("midIntWithRange");
- midIntWithRange.setAccessible(true);
- assertEquals("11", midIntWithRange.get(yangObject).toString());
- Field maxIntWithRange = yangObject
- .getClass().getDeclaredField("maxIntWithRange");
- maxIntWithRange.setAccessible(true);
- assertEquals("100", maxIntWithRange.get(yangObject).toString());
- Field minUint = yangObject.getClass().getDeclaredField("minUint");
- minUint.setAccessible(true);
- assertEquals("0", minUint.get(yangObject).toString());
- Field maxUint = yangObject.getClass().getDeclaredField("maxUint");
- maxUint.setAccessible(true);
- assertEquals("18446744073709551615", maxUint
- .get(yangObject).toString());
- Field minUintWithRange = yangObject
- .getClass().getDeclaredField("minUintWithRange");
- minUintWithRange.setAccessible(true);
- assertEquals("10", minUintWithRange.get(yangObject).toString());
- Field midUintWithRange = yangObject
- .getClass().getDeclaredField("midUintWithRange");
- midUintWithRange.setAccessible(true);
- assertEquals("11", midUintWithRange.get(yangObject).toString());
- Field maxUintWithRange = yangObject
- .getClass().getDeclaredField("maxUintWithRange");
- maxUintWithRange.setAccessible(true);
- assertEquals("100", maxUintWithRange.get(yangObject).toString());
- } catch (IllegalAccessException | NoSuchFieldException e) {
- Assert.fail();
- }
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobInteger8Test.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobInteger8Test.java
deleted file mode 100644
index 9755c65..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobInteger8Test.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.lang.reflect.Field;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class YobInteger8Test {
-
- /*
-
- Positive scenario
-
- input at boundary for integer
- i. min value
- ii. max value
-
- input at boundary for unsigned integer
- i. min value
- ii. max value
-
- input with in range
- if range is 10 to 100 for integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- if range is 10 to 100 for unsigned integer
- i.1. input 11
- i.2. min value 10
- i.3. max value 100
-
- input with multi interval range
- if range is 10..40 | 50..100 for integer
- i.1. input 11
- i.2. input 10
- i.3. input 40
- i.4. input 50
- i.5. input 55
- i.6. input 100
-
- if range is 10..40 | 50..100 for unsigned integer
- i.1. input 11
- i.2. input 10
- i.3. input 40
- i.4. input 50
- i.5. input 55
- i.6. input 100
-
- if range is "min .. 2 | 10 | 20..max" for integer
- i.1. input -128
- i.2. input 1
- i.3. input 2
- i.4. input 10
- i.5. input 20
- i.6. input 100
- i.7. input 127
-
- if range is "min .. 2 | 10 | 20..max" for unsigned Integer
- i.1. input 0
- i.2. input 1
- i.3. input 2
- i.4. input 10
- i.5. input 20
- i.6. input 100
- i.7. input 255
- */
- @Test
- public void positiveTest() {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils.integer8Ydt();
- validateYangObject(defaultYdtBuilder);
- }
-
- private void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- try {
- Field negInt = yangObject.getClass().getDeclaredField("negInt");
- negInt.setAccessible(true);
- assertEquals("-128", negInt.get(yangObject).toString());
- Field posInt = yangObject.getClass().getDeclaredField("posInt");
- posInt.setAccessible(true);
- assertEquals("127", posInt.get(yangObject).toString());
- Field minIntWithRange = yangObject
- .getClass().getDeclaredField("minIntWithRange");
- minIntWithRange.setAccessible(true);
- assertEquals("10", minIntWithRange
- .get(yangObject).toString());
- Field midIntWithRange = yangObject
- .getClass().getDeclaredField("midIntWithRange");
- midIntWithRange.setAccessible(true);
- assertEquals("11", midIntWithRange
- .get(yangObject).toString());
- Field maxIntWithRange = yangObject
- .getClass().getDeclaredField("maxIntWithRange");
- maxIntWithRange.setAccessible(true);
- assertEquals("100", maxIntWithRange.get(yangObject).toString());
- Field minUint = yangObject.getClass().getDeclaredField("minUint");
- minUint.setAccessible(true);
- assertEquals("0", minUint.get(yangObject).toString());
- Field maxUint = yangObject.getClass().getDeclaredField("maxUint");
- maxUint.setAccessible(true);
- assertEquals("255", maxUint.get(yangObject).toString());
- Field minUintWithRange = yangObject
- .getClass().getDeclaredField("maxIntWithRange");
- minUintWithRange.setAccessible(true);
- assertEquals("100", minUintWithRange.get(yangObject).toString());
- Field midUintWithRange = yangObject
- .getClass().getDeclaredField("midUintWithRange");
- midUintWithRange.setAccessible(true);
- assertEquals("11", midUintWithRange.get(yangObject).toString());
- Field maxUintWithRange = yangObject
- .getClass().getDeclaredField("maxUintWithRange");
- maxUintWithRange.setAccessible(true);
- assertEquals("100", maxUintWithRange.get(yangObject).toString());
- } catch (IllegalAccessException | NoSuchFieldException e) {
- Assert.fail();
- }
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobLeafRefTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobLeafRefTest.java
deleted file mode 100644
index fe6801e..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobLeafRefTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.ydt.leafreftest.rev20160524.LeafreftestOpParam;
-import org.onosproject.yang.gen.v1.ydt.leafreftest.rev20160524.leafreftest.cont1.AugmentedCont1;
-import org.onosproject.yang.gen.v1.ydt.leafreftest.rev20160524.leafreftest.food.snack.Sportsarena;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.onosproject.yms.app.yob.YobTestUtils.ROOT_DATA_RESOURCE;
-
-/**
- * Test the YANG object building for the YANG data tree based on the leaf ref.
- */
-public class YobLeafRefTest {
-
- private YobTestUtils utils = YobTestUtils.instance();
-
- @Test
- public void testLeafrefInLeaf() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("leafreftest", "ydt.leafreftest");
- ydtBuilder.addChild("leafrefList", null);
- ydtBuilder.addLeaf("id", null, "leafref");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- LeafreftestOpParam leafrefTestOpParam = ((LeafreftestOpParam)
- yangObject);
- assertThat(leafrefTestOpParam.leafrefList().get(0).id().toString(),
- is("leafref"));
- }
-
- @Test
- public void testLeafrefInTypedef() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("leafreftest", "ydt.leafreftest");
- ydtBuilder.addLeaf("name", null, "leafref");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- LeafreftestOpParam leafrefTestOpParam = ((LeafreftestOpParam) yangObject);
- assertThat(leafrefTestOpParam.name().toString(), is("leafref"));
- }
-
- @Test
- public void testLeafrefInGrouping() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("leafreftest", "ydt.leafreftest");
- ydtBuilder.addChild("cont1", "ydt.leafreftest");
- ydtBuilder.addLeaf("surname", null, "leafref");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- LeafreftestOpParam leafreftestOpParam = ((LeafreftestOpParam) yangObject);
- assertThat(leafreftestOpParam.cont1().surname().toString(),
- is("leafref"));
- }
-
- @Test
- public void testLeafrefInAugment() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("leafreftest", "ydt.leafreftest");
- ydtBuilder.addChild("cont1", "ydt.leafreftest");
- ydtBuilder.addLeaf("lastname", null, "yang");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- LeafreftestOpParam leafreftestOpParam = ((LeafreftestOpParam) yangObject);
- AugmentedCont1 augmentedCont1 = (AugmentedCont1) leafreftestOpParam
- .cont1().yangAugmentedInfo(AugmentedCont1.class);
- assertThat(augmentedCont1.lastname().toString(), is("yang"));
- }
-
- @Test
- public void testLeafrefInCase() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("leafreftest", "ydt.leafreftest");
- ydtBuilder.addChild("food", "ydt.leafreftest");
- ydtBuilder.addLeaf("pretzel", null, "yang");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- LeafreftestOpParam leafreftestOpParam = ((LeafreftestOpParam)
- yangObject);
- Sportsarena sportsArena = ((Sportsarena) leafreftestOpParam.food()
- .snack());
- assertThat(sportsArena.pretzel().toString(), is("yang"));
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobListTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobListTest.java
deleted file mode 100644
index 1c32f86..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobListTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-public class YobListTest {
-
- @Test
- public void listwithoutcontainerTest() {
- YangRequestWorkBench defaultYdtBuilder =
- YdtTestUtils.listWithoutContainerYdt();
- validateYangObjectList(defaultYdtBuilder);
- }
-
- private void validateYangObjectList(
- YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils.
- getSchemaRegistry());
- assertNotNull(yangObject);
- assertTrue("RootlistOpParam".equals(yangObject.getClass().getSimpleName()));
- try {
-
- Field field =
- yangObject.getClass().getDeclaredField("listwithcontainer");
- field.setAccessible(true);
- List listwithcontainer = (List) field.get(yangObject);
- assertNull(listwithcontainer);
- Field field1 = yangObject.getClass()
- .getDeclaredField("listwithoutcontainer");
- field1.setAccessible(true);
- List listwithoutcontainer = (List) field1.get(yangObject);
- assertEquals(false, listwithoutcontainer.isEmpty());
- Field invalidinterval = listwithoutcontainer.get(0).getClass()
- .getDeclaredField("invalidinterval");
- invalidinterval.setAccessible(true);
- assertEquals("12", invalidinterval.get(listwithoutcontainer.get(0))
- .toString());
- } catch (NoSuchFieldException | IllegalAccessException e) {
- Assert.fail();
- }
- }
-
- @Test
- public void listwithcontainerTest()
- throws IOException {
- YangRequestWorkBench defaultYdtBuilder =
- YdtTestUtils.listWithContainerYdt();
-
- validateYangObject(defaultYdtBuilder);
- }
-
- public void validateYangObject(YangRequestWorkBench defaultYdtBuilder) {
-
- YdtContext ydtContext = defaultYdtBuilder.getRootNode();
-
- YdtContext ydtContext1 = ydtContext.getFirstChild();
-
- DefaultYobBuilder defaultYobBuilder = new DefaultYobBuilder();
-
- Object yangObject = defaultYobBuilder.getYangObject(
- (YdtExtendedContext) ydtContext1, YdtTestUtils
- .getSchemaRegistry());
- assertNotNull(yangObject);
- assertTrue("RootlistOpParam".equals(yangObject.getClass().getSimpleName()));
- try {
-
- Field field = yangObject.getClass()
- .getDeclaredField("listwithoutcontainer");
- field.setAccessible(true);
- List listwithoutcontainer = (List) field.get(yangObject);
- assertNull(listwithoutcontainer);
- Field listwithcontainerField =
- yangObject.getClass().getDeclaredField("listwithcontainer");
- listwithcontainerField.setAccessible(true);
- List listwithcontainer =
- (List) listwithcontainerField.get(yangObject);
- Field invalid = listwithcontainer.get(0).getClass()
- .getDeclaredField("invalid");
- invalid.setAccessible(true);
- assertEquals("12",
- invalid.get(listwithcontainer.get(0)).toString());
- Field invalidinterval = listwithcontainer.get(0).getClass()
- .getDeclaredField("invalidinterval");
- invalidinterval.setAccessible(true);
- List invalidintervalList =
- (List) invalidinterval.get(listwithcontainer.get(0));
- assertEquals("1", invalidintervalList.get(0).toString());
- assertEquals("2", invalidintervalList.get(1).toString());
- } catch (NoSuchFieldException | IllegalAccessException e) {
- Assert.fail();
- }
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobLogisticsManagerTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobLogisticsManagerTest.java
deleted file mode 100644
index ec1f14c..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobLogisticsManagerTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.onosproject.yms.app.ydt.YdtTestUtils;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-
-import static org.junit.Assert.assertEquals;
-
-public class YobLogisticsManagerTest {
-
- @Test
- public void logisticsManagerTest() throws IOException {
- YangRequestWorkBench defaultYdtBuilder = YdtTestUtils
- .logisticsManagerYdt();
-
- YdtContext rootCtx = defaultYdtBuilder.getRootNode();
-
- YdtContext childCtx = rootCtx.getFirstChild();
-
- DefaultYobBuilder builder = new DefaultYobBuilder();
-
- while (childCtx != null) {
-
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, YdtTestUtils
- .getSchemaRegistry());
- Class<?> aClass = yangObject.getClass();
- if ("CustomssupervisorOpParam".equals(aClass.getSimpleName())) {
- try {
- Field field = aClass.getDeclaredField("supervisor");
- Field onosYangNodeOperationType = aClass
- .getDeclaredField("yangCustomssupervisorOpType");
- field.setAccessible(true);
- onosYangNodeOperationType.setAccessible(true);
- try {
- assertEquals("abc", field.get(yangObject).toString());
- assertEquals("MERGE", onosYangNodeOperationType
- .get(yangObject).toString());
- } catch (IllegalAccessException e) {
- Assert.fail();
- }
- } catch (NoSuchFieldException e) {
- Assert.fail();
- }
- }
-
- if ("MerchandisersupervisorOpParam".equals(aClass.getSimpleName())) {
- try {
- Field field = aClass.getDeclaredField("supervisor");
- field.setAccessible(true);
- try {
- assertEquals("abc", field.get(yangObject).toString());
- } catch (IllegalAccessException e) {
- Assert.fail();
- }
- } catch (NoSuchFieldException e) {
- Assert.fail();
- }
- }
-
- if ("WarehousesupervisorOpParam".equals(aClass.getSimpleName())) {
- try {
- Field field = aClass.getDeclaredField("supervisor");
- field.setAccessible(true);
- try {
- ArrayList<String> arrayList =
- (ArrayList<String>) field.get(yangObject);
- assertEquals("1", arrayList.get(0));
- assertEquals("2", arrayList.get(1));
- assertEquals("3", arrayList.get(2));
- assertEquals("4", arrayList.get(3));
- assertEquals("5", arrayList.get(4));
- } catch (IllegalAccessException e) {
- Assert.fail();
- }
- } catch (NoSuchFieldException e) {
- Assert.fail();
- }
- }
- childCtx = childCtx.getNextSibling();
- }
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobTestUtils.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobTestUtils.java
deleted file mode 100644
index 6ec1517..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobTestUtils.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.yms.app.yob;
-
-import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider;
-import org.onosproject.yms.app.ysr.YangSchemaRegistry;
-
-/**
- * YOB test Utility.
- */
-final class YobTestUtils {
-
- /**
- * Schema nodes.
- */
- static final String ROOT_DATA_RESOURCE = "/restconf/data";
- static final String TOPOLOGY = "yms-topology";
- static final String NODE = "node";
- static final String LEAF_1A1 = "leaf1a1";
- static final String LEAF_1A2 = "leaf1a2";
- static final String LEAF_1BIA = "leaf1bia";
- static final String LEAF_1BIB = "leaf1bib";
- static final String ROUTER_ID = "router-id";
- static final String ROUTER_IP = "router-ip";
- static final String STR_LEAF_VALUE = "leaf value";
- static final String YMS_IETF_NETWORK = "yms-ietf-network";
- static final String NETWORKS_STATE = "networks-state";
- static final String NETWORKS = "networks";
- static final String NETWORK = "network";
- static final String NETWORK_REF = "network-ref";
- static final String IETF_TE_TOPOLOGY = "yms-ietf-te-topology";
- static final String TE_NODE_EVENT = "te-node-event";
- static final String TE_NODE_ATTRIBUTES = "te-node-attributes";
- static final String ADMIN_STATUS = "admin-status";
- static final String UP = "up";
- static final String LINK = "link";
- static final String YMS_NETWORK_TOPOLOGY = "yms-network-topology";
- static final String TE = "te";
- static final String CONFIG = "config";
- static final String BUNDLED_LINKS = "bundled-links";
- static final String BUNDLED_LINK = "bundled-link";
- static final String SEQUENCE = "sequence";
- static final String TE_LINK_TEMPLATE = "te-link-template";
-
- private YobTestUtils() {
- TEST_SCHEMA_PROVIDER.processSchemaRegistry(null);
- }
-
- private static final TestYangSchemaNodeProvider
- TEST_SCHEMA_PROVIDER = new TestYangSchemaNodeProvider();
-
- YangSchemaRegistry schemaRegistry() {
- return TEST_SCHEMA_PROVIDER.getDefaultYangSchemaRegistry();
- }
-
- /**
- * Returns the YANG object builder factory instance.
- *
- * @return YANG object builder factory instance
- */
- static YobTestUtils instance() {
- return LazyHolder.INSTANCE;
- }
-
- /*
- * Bill Pugh Singleton pattern. INSTANCE won't be instantiated until the
- * LazyHolder class is loaded via a call to the instance() method below.
- */
- private static class LazyHolder {
- private static final YobTestUtils INSTANCE = new YobTestUtils();
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobUnionTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobUnionTest.java
deleted file mode 100644
index 729829b..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/yob/YobUnionTest.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.yob;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.ydt.uniontest.rev20160524.UniontestOpParam;
-import org.onosproject.yang.gen.v1.ydt.uniontest.rev20160524.uniontest.cont1.AugmentedCont1;
-import org.onosproject.yang.gen.v1.ydt.uniontest.rev20160524.uniontest.food.snack.Sportsarena;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.io.IOException;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.onosproject.yms.app.yob.YobTestUtils.ROOT_DATA_RESOURCE;
-
-/**
- * Test the YANG object building for the YANG data tree based on the union.
- */
-public class YobUnionTest {
-
- private YobTestUtils utils = YobTestUtils.instance();
-
- @Test
- public void testUnionInLeaf() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("uniontest", "ydt.uniontest");
- ydtBuilder.addChild("unionList", null);
- ydtBuilder.addLeaf("id", null, "YmluYXJ5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- UniontestOpParam unionTestOpParam = ((UniontestOpParam) yangObject);
-
- byte[] binaryValue = unionTestOpParam.unionList().get(0).id().binary();
- String value = new String(binaryValue);
- assertThat(value, is("binary"));
- }
-
- @Test
- public void testUnionInTypedef() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("uniontest", "ydt.uniontest");
- ydtBuilder.addLeaf("name", null, "bit1");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- UniontestOpParam unionTestOpParam = ((UniontestOpParam) yangObject);
- assertThat(unionTestOpParam.name().union().bits().get(1), is(true));
- }
-
- @Test
- public void testUnionInGrouping() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("uniontest", "ydt.uniontest");
- ydtBuilder.addChild("cont1", "ydt.uniontest");
- ydtBuilder.addLeaf("surname", null, "yang");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- UniontestOpParam uniontestOpParam = ((UniontestOpParam) yangObject);
- assertThat(uniontestOpParam.cont1().surname().string(), is("yang"));
- }
-
- @Test
- public void testUnionInAugment() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("uniontest", "ydt.uniontest");
- ydtBuilder.addChild("cont1", "ydt.uniontest");
- ydtBuilder.addLeaf("lastname", null, "bit0");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- UniontestOpParam uniontestOpParam = ((UniontestOpParam) yangObject);
-
- AugmentedCont1 augmentedCont1 = (AugmentedCont1) uniontestOpParam
- .cont1().yangAugmentedInfo(AugmentedCont1.class);
- assertThat(augmentedCont1.lastname().bits().get(0), is(true));
- }
-
- @Test
- public void testUnionInCase() throws IOException {
- YangRequestWorkBench ydtBuilder = new YangRequestWorkBench(
- ROOT_DATA_RESOURCE, null, null, utils.schemaRegistry(), true);
- ydtBuilder.addChild("uniontest", "ydt.uniontest");
- ydtBuilder.addChild("food", "ydt.uniontest");
- ydtBuilder.addLeaf("pretzel", null, "YmluYXJ5");
- ydtBuilder.traverseToParent();
- ydtBuilder.traverseToParent();
- YdtContext rootCtx = ydtBuilder.getRootNode();
- YdtContext childCtx = rootCtx.getFirstChild();
- DefaultYobBuilder builder = new DefaultYobBuilder();
- Object yangObject = builder.getYangObject(
- (YdtExtendedContext) childCtx, utils.schemaRegistry());
- assertThat(yangObject, notNullValue());
- UniontestOpParam uniontestOpParam = ((UniontestOpParam) yangObject);
- Sportsarena sportsArena = ((Sportsarena) uniontestOpParam.food()
- .snack());
- byte[] binaryValue = sportsArena.pretzel().binary();
- String value = new String(binaryValue);
- assertThat(value, is("binary"));
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ypm/DefaultYpmNodeTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ypm/DefaultYpmNodeTest.java
deleted file mode 100644
index a5f561db..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ypm/DefaultYpmNodeTest.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ypm;
-
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-
-import org.onosproject.yms.ypm.YpmContext;
-import org.onosproject.yms.ypm.DefaultYpmNode;
-
-/**
- * Unit tests for DefaultYpmNode class.
- */
-public class DefaultYpmNodeTest {
- private final String logicalName = "logicalYpmNode";
- private final String moduleName1 = "portPairModule1";
- private final String moduleName2 = "portPairModule2";
- private final String xNodeName = "x";
- private final String yNodeName = "y";
- private final String zNodeName = "z";
- private final String x1NodeName = "x1";
- private final String x2NodeName = "x2";
- private final String y1NodeName = "y1";
- private final String y2NodeName = "y2";
- private final String z1NodeName = "z1";
- private final String z2NodeName = "z2";
-
- /**
- * Constructs ypm tree with single module.
- *
- * @return ypm tree root node
- */
- private YpmContext constructYpmTreeSingleModule() {
- // Create logical node
- DefaultYpmNode rootNode = new DefaultYpmNode(logicalName);
- // Create module node with moduleName1
- rootNode.addChild(moduleName1); // child to logical node
- YpmContext moduleNode = rootNode.getChild(moduleName1);
- moduleNode.addChild(xNodeName); // child to module node
- moduleNode.addChild(yNodeName); // sibling node to child node "x"
- YpmContext xNode = moduleNode.getChild("x");
- xNode.addSibling(zNodeName); // sibling node to child node "x"
- xNode.addChild(x1NodeName); // child to node x
- xNode.addChild(x2NodeName); // child to node x
- YpmContext yNode = moduleNode.getChild(yNodeName);
- yNode.addChild(y1NodeName); // child to node y
- yNode.addChild(y2NodeName); // child to node y
- YpmContext zNode = moduleNode.getChild(zNodeName);
- zNode.addChild(z1NodeName); // child to node z
- zNode.addChild(z2NodeName); // child to node z
- return rootNode;
- }
-
- /**
- * Constructs ypm tree with multi module.
- *
- * @return ypm tree root node
- */
- private YpmContext constructYpmTreeMultiModule(DefaultYpmNode rootNode) {
- rootNode.addChild(moduleName2); // child to logical node
- YpmContext moduleNode = rootNode.getChild(moduleName2);
- moduleNode.addChild(xNodeName); // child to module node
- moduleNode.addChild(yNodeName); // sibling node to child node "x"
- YpmContext xNode = moduleNode.getChild("x");
- xNode.addSibling(zNodeName); // sibling node to child node "x"
- xNode.addChild(x1NodeName); // child to node x
- xNode.addChild(x2NodeName); // child to node x
- YpmContext yNode = moduleNode.getChild(yNodeName);
- yNode.addChild(y1NodeName); // child to node y
- yNode.addChild(y2NodeName); // child to node y
- YpmContext zNode = moduleNode.getChild(zNodeName);
- zNode.addChild(z1NodeName); // child to node z
- zNode.addChild(z2NodeName); // child to node z
- return rootNode;
- }
-
- /**
- * Checks ypm tree single module construction.
- */
- @Test
- public void testYpmTreeSingleModuleConstruction() {
- DefaultYpmNode rootNode = (DefaultYpmNode) constructYpmTreeSingleModule();
- // Check one by one node
- String name = rootNode.getName();
- assertThat(name, is(logicalName));
- YpmContext moduleNode = rootNode.getChild(moduleName1);
- assertThat(moduleNode.getName(), is(moduleName1));
- YpmContext ypmNode = moduleNode.getChild(xNodeName);
- assertThat(ypmNode.getName(), is(xNodeName));
- // Check sibling by using getNextSibling();
- ypmNode = ypmNode.getNextSibling();
- assertThat(ypmNode, notNullValue()); // either y or z should be there as sibling
- ypmNode = ypmNode.getNextSibling();
- assertThat(ypmNode, notNullValue()); // either y or z should be there as sibling
- ypmNode = ypmNode.getNextSibling();
- assertThat(ypmNode, nullValue()); // last sibling point to next sibling as null
- // Check sibling by using getPreviousSibling()
- ypmNode = moduleNode.getChild(zNodeName);
- assertThat(ypmNode.getName(), is(zNodeName));
- ypmNode = ypmNode.getPreviousSibling();
- assertThat(ypmNode, notNullValue()); // either x or y should be there as sibling
- ypmNode = ypmNode.getPreviousSibling();
- assertThat(ypmNode, notNullValue()); // either x or y should be there as sibling
- ypmNode = ypmNode.getPreviousSibling();
- assertThat(ypmNode, nullValue()); // last sibling point to next sibling as null
- // Checks the child x1 and x2
- ypmNode = moduleNode.getChild(xNodeName);
- ypmNode = ypmNode.getChild(x1NodeName);
- assertThat(ypmNode.getName(), is(x1NodeName));
- ypmNode = ypmNode.getSibling(x2NodeName);
- assertThat(ypmNode.getName(), is(x2NodeName));
- // Checks the child y1 and y2
- ypmNode = moduleNode.getChild(yNodeName);
- ypmNode = ypmNode.getChild(y1NodeName);
- assertThat(ypmNode.getName(), is(y1NodeName));
- ypmNode = ypmNode.getSibling(y2NodeName);
- assertThat(ypmNode.getName(), is(y2NodeName));
- // Checks the child z1 and z2
- ypmNode = moduleNode.getChild(zNodeName);
- ypmNode = ypmNode.getChild(z1NodeName);
- assertThat(ypmNode.getName(), is(z1NodeName));
- ypmNode = ypmNode.getSibling(z2NodeName);
- assertThat(ypmNode.getName(), is(z2NodeName));
- }
-
- /**
- * Checks ypm tree multiple module construction.
- */
- @Test
- public void testYpmTreeMultiModuleConstruction() {
- DefaultYpmNode rootNode = (DefaultYpmNode) constructYpmTreeSingleModule();
- rootNode = (DefaultYpmNode) constructYpmTreeMultiModule(rootNode);
- // Check one by one node
- String name = rootNode.getName();
- assertThat(name, is(logicalName));
- YpmContext moduleNode = rootNode.getChild(moduleName2);
- assertThat(moduleNode.getName(), is(moduleName2));
- YpmContext ypmNode = moduleNode.getChild(xNodeName);
- assertThat(ypmNode.getName(), is(xNodeName));
- // Check sibling by using getNextSibling();
- ypmNode = ypmNode.getNextSibling();
- assertThat(ypmNode, notNullValue()); // either y or z should be there as sibling
- ypmNode = ypmNode.getNextSibling();
- assertThat(ypmNode, notNullValue()); // either y or z should be there as sibling
- ypmNode = ypmNode.getNextSibling();
- assertThat(ypmNode, nullValue()); // last sibling point to next sibling as null
- // Check sibling by using getPreviousSibling()
- ypmNode = moduleNode.getChild(zNodeName);
- assertThat(ypmNode.getName(), is(zNodeName));
- ypmNode = ypmNode.getPreviousSibling();
- assertThat(ypmNode, notNullValue()); // either x or y should be there as sibling
- ypmNode = ypmNode.getPreviousSibling();
- assertThat(ypmNode, notNullValue()); // either x or y should be there as sibling
- ypmNode = ypmNode.getPreviousSibling();
- assertThat(ypmNode, nullValue()); // last sibling point to next sibling as null
- // Checks the child x1 and x2
- ypmNode = moduleNode.getChild(xNodeName);
- ypmNode = ypmNode.getChild(x1NodeName);
- assertThat(ypmNode.getName(), is(x1NodeName));
- ypmNode = ypmNode.getSibling(x2NodeName);
- assertThat(ypmNode.getName(), is(x2NodeName));
- // Checks the child y1 and y2
- ypmNode = moduleNode.getChild(yNodeName);
- ypmNode = ypmNode.getChild(y1NodeName);
- assertThat(ypmNode.getName(), is(y1NodeName));
- ypmNode = ypmNode.getSibling(y2NodeName);
- assertThat(ypmNode.getName(), is(y2NodeName));
- // Checks the child z1 and z2
- ypmNode = moduleNode.getChild(zNodeName);
- ypmNode = ypmNode.getChild(z1NodeName);
- assertThat(ypmNode.getName(), is(z1NodeName));
- ypmNode = ypmNode.getSibling(z2NodeName);
- assertThat(ypmNode.getName(), is(z2NodeName));
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ypm/YdtNodeAdapter.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ypm/YdtNodeAdapter.java
deleted file mode 100644
index a5b6556..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ypm/YdtNodeAdapter.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ypm;
-
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
-import org.onosproject.yms.app.ydt.AppType;
-import org.onosproject.yms.app.ydt.YdtExtendedContext;
-import org.onosproject.yms.app.ydt.YdtNode;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-import org.onosproject.yms.ydt.YdtExtendedInfoType;
-import org.onosproject.yms.ydt.YdtType;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Represents implementation of interfaces to build and obtain YANG data tree.
- */
-public class YdtNodeAdapter<T> implements YdtExtendedContext {
-
- /**
- * Parent reference.
- */
- private YdtNodeAdapter parent;
-
- /**
- * First child reference.
- */
- private YdtNodeAdapter child;
-
- /**
- * Next sibling reference.
- */
- private YdtNodeAdapter nextSibling;
-
- /**
- * Previous sibling reference.
- */
- private YdtNodeAdapter previousSibling;
-
- /**
- * Last child reference.
- */
- private YdtNode lastChild;
-
- /**
- * Type of node.
- */
- private YdtType ydtType;
-
- /**
- * Flag to keep the track of context switch.
- */
- private boolean isContextSwitch;
-
- private T ydtExtendedInfo;
-
- /**
- * YDT extended information type.
- */
- YdtExtendedInfoType ydtExtendedInfoType;
-
- /**
- * Ydt map to keep the track of node added in YDT.
- */
- private Map<YangSchemaNodeIdentifier, List<YdtNode<T>>> ydtNodeMap = new HashMap<>();
-
- /**
- * Reference for data-model schema node.
- */
- private YangSchemaNode yangSchemaNode;
-
- /**
- * Reference for ydt node operation type.
- */
- private YdtContextOperationType ydtContextOperationType;
-
- /**
- * Key object for ydtNodeMap.
- */
- protected YangSchemaNodeIdentifier nodeIdentifier;
-
- /**
- * Ydt map to keep the track of application information object with respective type.
- */
- Map<AppType, Object> ydtAppInfoMap = new HashMap<>();
-
-
- /**
- * Creation of YANG node object.
- */
- public YdtNodeAdapter() {
- }
-
- /**
- * Creates a specific type of node.
- *
- * @param type of YDT node
- * @param name name of the YDT node
- */
- public YdtNodeAdapter(YdtType type, String name) {
- setYdtType(type);
- }
-
- @Override
- public String getName() {
- return this.nodeIdentifier.getName();
- }
-
- @Override
- public String getNamespace() {
- return yangSchemaNode.getNameSpace().getModuleNamespace();
- }
-
- @Override
- public String getModuleNameAsNameSpace() {
- return null;
- }
-
- @Override
- public <T> T getYdtContextExtendedInfo() {
- return (T) ydtExtendedInfo;
- }
-
- @Override
- public YdtExtendedInfoType getYdtExtendedInfoType() {
- return ydtExtendedInfoType;
- }
-
- @Override
- public YdtType getYdtType() {
- return ydtType;
- }
-
- /**
- * Sets the node type.
- *
- * @param ydtType type of YDT attribute
- */
- public void setYdtType(YdtType ydtType) {
- this.ydtType = ydtType;
- }
-
- @Override
- public YdtNodeAdapter getParent() {
- return parent;
- }
-
- /**
- * Sets the parent of node.
- *
- * @param parent node
- */
- public void setParent(YdtNodeAdapter parent) {
- this.parent = parent;
- }
-
- @Override
- public YdtNodeAdapter getFirstChild() {
- return child;
- }
-
- @Override
- public YdtNodeAdapter getNextSibling() {
- return nextSibling;
- }
-
- /**
- * Sets the next sibling of node.
- *
- * @param sibling YANG node
- */
- public void setNextSibling(YdtNodeAdapter sibling) {
- nextSibling = sibling;
- }
-
- @Override
- public YdtNodeAdapter getPreviousSibling() {
- return previousSibling;
- }
-
- /**
- * Sets the previous sibling.
- *
- * @param previousSibling points to predecessor sibling
- */
- public void setPreviousSibling(YdtNodeAdapter previousSibling) {
- this.previousSibling = previousSibling;
- }
-
- /**
- * Returns data-model node reference for of a given node.
- *
- * @return yang schema data node of a data-model.
- */
- public YangSchemaNode getYangSchemaNode() {
- return yangSchemaNode;
- }
-
- /**
- * Sets the data-model node reference for of a given node..
- *
- * @param yangSchemaNode YANG data node.
- */
- public void setYangSchemaNode(YangSchemaNode yangSchemaNode) {
- this.yangSchemaNode = yangSchemaNode;
- }
-
- @Override
- public YdtNode getLastChild() {
- return lastChild;
- }
-
- /**
- * Sets the last instance of a child node.
- *
- * @param child is last child to be set
- */
- public void setLastChild(YdtNode child) {
- this.lastChild = child;
- }
-
- public void setNodeIdentifier(YangSchemaNodeIdentifier nodeIdentifier) {
- this.nodeIdentifier = nodeIdentifier;
- }
-
- /**
- * Adds a child node.
- *
- * @param newChild refers to a child to be added
- */
- public void addChild(YdtContext newChild) {
-
- ((YdtNodeAdapter) newChild).setParent(this);
-
- if (this.child == null) {
- this.child = (YdtNodeAdapter) newChild;
- return;
- }
-
- YdtNodeAdapter currNode = this.child;
- while (currNode.getNextSibling() != null) {
- currNode = currNode.getNextSibling();
- }
- currNode.setNextSibling((YdtNodeAdapter) newChild);
- ((YdtNodeAdapter) newChild).setPreviousSibling(currNode);
- }
-
- /**
- * Adds a sibling to YANG data tree.
- *
- * @param newSibling context of sibling to be added
- */
- public void addSibling(YdtContext newSibling) {
-
- ((YdtNodeAdapter) newSibling).setParent(this.getParent());
-
- YdtNodeAdapter currNode = this;
-
- while (currNode.getNextSibling() != null) {
- currNode = currNode.getNextSibling();
- }
- currNode.setNextSibling((YdtNodeAdapter) newSibling);
- ((YdtNodeAdapter) newSibling).setPreviousSibling(currNode);
- }
-
- /**
- * Gets the flag for node if context switch.
- *
- * @return isContextSwitch flag of a node.
- */
- public boolean getContextSwitch() {
- return isContextSwitch;
- }
-
- /**
- * Sets the flag to keep the track of context switch.
- *
- * @param contextSwitch boolean flag.
- */
- public void setContextSwitch(boolean contextSwitch) {
- isContextSwitch = contextSwitch;
- }
-
- @Override
- public String getValue() {
- return null;
- }
-
- @Override
- public Set<String> getValueSet() {
- return null;
- }
-
- @Override
- public Object getAppInfo(AppType appType) {
- return null;
- }
-
- @Override
- public void addAppInfo(AppType appType, Object object) {
-
- }
-
- @Override
- public YdtContextOperationType getYdtContextOperationType() {
- return ydtContextOperationType;
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ypm/YpmManagerTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ypm/YpmManagerTest.java
deleted file mode 100644
index d9ebca7..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ypm/YpmManagerTest.java
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ypm;
-
-import org.junit.Test;
-import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
-import org.onosproject.yms.ypm.DefaultYpmNode;
-import org.onosproject.yms.ypm.YpmContext;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-
-/**
- * Unit tests for YpmManager class.
- */
-public class YpmManagerTest {
- private final String logicalName = "logicalYpmNode";
- private final String moduleName1 = "portPairModule1";
- private final String moduleName2 = "portPairModule2";
- private final String xNodeName = "x";
- private final String yNodeName = "y";
- private final String zNodeName = "z";
- private final String x1NodeName = "x1";
- private final String x2NodeName = "x2";
- private final String y1NodeName = "y1";
- private final String y2NodeName = "y2";
- private final String y11NodeName = "y11";
- private final String z1NodeName = "z1";
- private final String z2NodeName = "z2";
- private final String z3NodeName = "z3";
-
- /**
- * Creates module1 ydt tree.
- */
- public YdtNodeAdapter createModule1Tree() throws CloneNotSupportedException {
- YangSchemaNodeIdentifier tmpNodeIdentifier;
- YdtNodeAdapter rootNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(logicalName);
- rootNode.setNodeIdentifier(tmpNodeIdentifier);
-
- // Create module node with moduleName1
- YdtNodeAdapter moduleNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(moduleName1);
- moduleNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.setParent(rootNode);
- rootNode.addChild(moduleNode); // child to logical node
- YdtNodeAdapter xNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(xNodeName);
- xNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter yNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(yNodeName);
- yNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter zNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(zNodeName);
- zNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.addChild(xNode); // child to module node
- xNode.addSibling(yNode);
- yNode.addSibling(zNode);
- YdtNodeAdapter x1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(x1NodeName);
- x1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter x2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(x2NodeName);
- x2Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter y1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y1NodeName);
- y1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter y2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y2NodeName);
- y2Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter z1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(z1NodeName);
- z1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter z2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(z2NodeName);
- z2Node.setNodeIdentifier(tmpNodeIdentifier);
- xNode.addChild(x1Node);
- x1Node.addSibling(x2Node);
- yNode.addChild(y1Node);
- y1Node.addSibling(y2Node);
- zNode.addChild(z1Node);
- z1Node.addSibling(z2Node);
-
- return rootNode;
- }
-
- /**
- * Checks the protocol data added in YpmManger when only single module exists.
- */
- @Test
- public void retrieveAndCheckProtocolDataWhenSingleModule() throws CloneNotSupportedException {
- YdtNodeAdapter rootNode = createModule1Tree();
-
- YpmManager ypmManager = new YpmManager();
- Object metaData = 10;
- ypmManager.setProtocolData(rootNode, metaData);
- YpmContext ypmContext = ypmManager.getProtocolData(rootNode);
- DefaultYpmNode rootYpmNode = (DefaultYpmNode) ypmContext;
- assertThat(rootYpmNode.getName(), is(logicalName));
- DefaultYpmNode currYpmNode = (DefaultYpmNode) rootYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(moduleName1));
- currYpmNode = (DefaultYpmNode) currYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(xNodeName)); // x node
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // y or z node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // y or z node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue()); // no sibling
-
- // Check x node leaf's x1 and x2
- DefaultYpmNode moduleYpmNode = currYpmNode.getParent();
- assertThat(moduleYpmNode.getName(), is(moduleName1));
- DefaultYpmNode xYpmNode = (DefaultYpmNode) moduleYpmNode.getFirstChild();
- assertThat(xYpmNode.getName(), is(xNodeName));
- assertThat(xYpmNode.getMetaData(), is(metaData));
- // Check x1 node
- currYpmNode = (DefaultYpmNode) xYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(x1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- // Check x2 node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(x2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
-
- // Check y node leaf's y1 and y2
- DefaultYpmNode yYpmNode = xYpmNode.getNextSibling();
- assertThat(yYpmNode.getName(), is(yNodeName));
- assertThat(yYpmNode.getMetaData(), is(metaData));
- // Check y1 node
- currYpmNode = (DefaultYpmNode) yYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(y1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- // Check y2 node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(y2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
-
- // Check z node leaf's z1 and z2
- DefaultYpmNode zYpmNode = yYpmNode.getNextSibling();
- assertThat(zYpmNode.getName(), is(zNodeName));
- assertThat(zYpmNode.getMetaData(), is(metaData));
- // Check z1 node
- currYpmNode = (DefaultYpmNode) zYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(z1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- // Check z2 node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(z2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- }
-
- /**
- * Creates module2 ydt tree. Module1 and Module2 trees are point to same logical root.
- */
- public YdtNodeAdapter createModule2Tree() throws CloneNotSupportedException {
- YangSchemaNodeIdentifier tmpNodeIdentifier;
- YdtNodeAdapter rootNode = createModule1Tree();
- YdtNodeAdapter moduleNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(moduleName2);
- moduleNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.setParent(rootNode);
- rootNode.addChild(moduleNode); // child to logical node
- YdtNodeAdapter xNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(xNodeName);
- xNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter yNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(yNodeName);
- yNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter zNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(zNodeName);
- zNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.addChild(xNode); // child to module node
- xNode.addSibling(yNode);
- yNode.addSibling(zNode);
- YdtNodeAdapter x1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(x1NodeName);
- x1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter x2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(x2NodeName);
- x2Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter y1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y1NodeName);
- y1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter y2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y2NodeName);
- y2Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter z1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(z1NodeName);
- z1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter z2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(z2NodeName);
- z2Node.setNodeIdentifier(tmpNodeIdentifier);
- xNode.addChild(x1Node);
- x1Node.addSibling(x2Node);
- yNode.addChild(y1Node);
- y1Node.addSibling(y2Node);
- zNode.addChild(z1Node);
- z1Node.addSibling(z2Node);
-
- return rootNode;
- }
-
- /**
- * Checks the protocol data added in YpmManger when multiple modules exists.
- */
- @Test
- public void retrieveAndCheckProtocolDataWhenMultipleModule() throws CloneNotSupportedException {
- YdtNodeAdapter rootNode = createModule2Tree();
-
- YpmManager ypmManager = new YpmManager();
- Object metaData = 10;
- ypmManager.setProtocolData(rootNode, metaData);
- YpmContext ypmContext = ypmManager.getProtocolData(rootNode);
- DefaultYpmNode rootYpmNode = (DefaultYpmNode) ypmContext;
- assertThat(rootYpmNode.getName(), is(logicalName));
- DefaultYpmNode currYpmNode = (DefaultYpmNode) rootYpmNode.getFirstChild();
- currYpmNode = currYpmNode.getNextSibling(); // jump to next module (module2)
- assertThat(currYpmNode.getName(), is(moduleName2));
- currYpmNode = (DefaultYpmNode) currYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(xNodeName)); // x node
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // y or z node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // y or z node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue()); // no sibling
-
- // Check x node leaf's x1 and x2
- DefaultYpmNode moduleYpmNode = currYpmNode.getParent();
- assertThat(moduleYpmNode.getName(), is(moduleName2));
- DefaultYpmNode xYpmNode = (DefaultYpmNode) moduleYpmNode.getFirstChild();
- assertThat(xYpmNode.getName(), is(xNodeName));
- assertThat(xYpmNode.getMetaData(), is(metaData));
- // Check x1 node
- currYpmNode = (DefaultYpmNode) xYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(x1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- // Check x2 node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(x2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
-
- // Check y node leaf's y1 and y2
- DefaultYpmNode yYpmNode = xYpmNode.getNextSibling();
- assertThat(yYpmNode.getName(), is(yNodeName));
- assertThat(yYpmNode.getMetaData(), is(metaData));
- // Check y1 node
- currYpmNode = (DefaultYpmNode) yYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(y1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- // Check y2 node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(y2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
-
- // Check z node leaf's z1 and z2
- DefaultYpmNode zYpmNode = yYpmNode.getNextSibling();
- assertThat(zYpmNode.getName(), is(zNodeName));
- assertThat(zYpmNode.getMetaData(), is(metaData));
- // Check z1 node
- currYpmNode = (DefaultYpmNode) zYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(z1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- // Check z2 node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(z2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- }
-
- /**
- * Checks the protocol data added in YpmManger, but tests only part of module1 tree.
- */
- @Test
- public void retrieveAndCheckProtocolDataChosenFromPartOfModule1Tree() throws CloneNotSupportedException {
- YangSchemaNodeIdentifier tmpNodeIdentifier;
- YdtNodeAdapter rootNode = createModule2Tree();
-
- // Sets the tree
- YpmManager ypmManager = new YpmManager();
- Object metaData = 10;
- ypmManager.setProtocolData(rootNode, metaData);
-
- // Create new ydt tree part of module1 tree
- YdtNodeAdapter rootNewYdtNode = new YdtNodeAdapter();
- // Create module node with moduleName1
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(logicalName);
- rootNewYdtNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter moduleNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(moduleName1);
- moduleNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.setParent(rootNewYdtNode);
- rootNewYdtNode.addChild(moduleNode); // child to logical node
- YdtNodeAdapter yNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(yNodeName);
- yNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter zNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(zNodeName);
- zNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.addChild(yNode); // child to module node
- yNode.addSibling(zNode);
- YdtNodeAdapter y1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y1NodeName);
- y1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter y2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y2NodeName);
- y2Node.setNodeIdentifier(tmpNodeIdentifier);
- yNode.addChild(y1Node);
- y1Node.addSibling(y2Node);
-
- // Again sets the protocol data
- metaData = 20;
- ypmManager.setProtocolData(rootNewYdtNode, metaData);
-
- // Retrieve protocol data and check the contents
- YpmContext ypmContext = ypmManager.getProtocolData(rootNewYdtNode);
- DefaultYpmNode rootYpmNode = (DefaultYpmNode) ypmContext;
- assertThat(rootYpmNode.getName(), is(logicalName));
- DefaultYpmNode currYpmNode = (DefaultYpmNode) rootYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(moduleName1));
- // Check y and z node
- currYpmNode = (DefaultYpmNode) currYpmNode.getFirstChild();
- DefaultYpmNode yYpmNode = currYpmNode;
- assertThat(currYpmNode.getName(), is(yNodeName)); // x node
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // z node
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(zNodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue()); // no sibling
- // Check y1 and y2 node
- currYpmNode = (DefaultYpmNode) yYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(y1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // y2 should exists
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(y2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue());
- }
-
- /**
- * Checks the protocol data added in YpmManger, but tests part of module1 tree with little bit extended tree.
- */
- @Test
- public void retrieveAndCheckProtocolDataChosenFromPartOfModule1TreeWithExtended()
- throws CloneNotSupportedException {
- YangSchemaNodeIdentifier tmpNodeIdentifier;
- YdtNodeAdapter rootNode = createModule2Tree();
-
- // Sets the tree
- YpmManager ypmManager = new YpmManager();
- Object metaData = 10;
- ypmManager.setProtocolData(rootNode, metaData);
-
- // Create new ydt tree part of module1 tree
- YdtNodeAdapter rootNewYdtNode = new YdtNodeAdapter();
- // Create module node with moduleName1
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(logicalName);
- rootNewYdtNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter moduleNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(moduleName1);
- moduleNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.setParent(rootNewYdtNode);
- rootNewYdtNode.addChild(moduleNode); // child to logical node
- YdtNodeAdapter yNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(yNodeName);
- yNode.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter zNode = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(zNodeName);
- zNode.setNodeIdentifier(tmpNodeIdentifier);
- moduleNode.addChild(yNode); // child to module node
- yNode.addSibling(zNode);
- YdtNodeAdapter y1Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y1NodeName);
- y1Node.setNodeIdentifier(tmpNodeIdentifier);
- YdtNodeAdapter y2Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y2NodeName);
- y2Node.setNodeIdentifier(tmpNodeIdentifier);
- yNode.addChild(y1Node);
- y1Node.addSibling(y2Node);
- YdtNodeAdapter y11Node = new YdtNodeAdapter();
- // Add new y11 node
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(y11NodeName);
- y11Node.setNodeIdentifier(tmpNodeIdentifier);
- y1Node.addChild(y11Node);
- // Add new y3 node
- YdtNodeAdapter z3Node = new YdtNodeAdapter();
- tmpNodeIdentifier = new YangSchemaNodeIdentifier();
- tmpNodeIdentifier.setName(z3NodeName);
- z3Node.setNodeIdentifier(tmpNodeIdentifier);
- zNode.addChild(z3Node);
-
- // Again sets the protocol data
- metaData = 20;
- ypmManager.setProtocolData(rootNewYdtNode, metaData);
-
- // Retrieve protocol data and check the contents
- YpmContext ypmContext = ypmManager.getProtocolData(rootNewYdtNode);
- DefaultYpmNode rootYpmNode = (DefaultYpmNode) ypmContext;
- assertThat(rootYpmNode.getName(), is(logicalName));
- DefaultYpmNode currYpmNode = (DefaultYpmNode) rootYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(moduleName1));
- // Check y and z node
- currYpmNode = (DefaultYpmNode) currYpmNode.getFirstChild();
- DefaultYpmNode yYpmNode = currYpmNode;
- assertThat(currYpmNode.getName(), is(yNodeName)); // y node
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // z node
- currYpmNode = currYpmNode.getNextSibling();
- DefaultYpmNode zYpmNode = currYpmNode;
- assertThat(currYpmNode.getName(), is(zNodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue()); // no sibling
- // Check y1 and y2 node
- currYpmNode = (DefaultYpmNode) yYpmNode.getFirstChild();
- DefaultYpmNode y1YpmNode = currYpmNode;
- assertThat(currYpmNode.getName(), is(y1NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), notNullValue()); // y2 should exists
- currYpmNode = currYpmNode.getNextSibling();
- assertThat(currYpmNode.getName(), is(y2NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue());
- // Check new y11 node
- currYpmNode = (DefaultYpmNode) y1YpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(y11NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue());
- assertThat(currYpmNode.getFirstChild(), nullValue());
- // Check new z3 node
- currYpmNode = (DefaultYpmNode) zYpmNode.getFirstChild();
- assertThat(currYpmNode.getName(), is(z3NodeName));
- assertThat(currYpmNode.getMetaData(), is(metaData));
- assertThat(currYpmNode.getNextSibling(), nullValue());
- assertThat(currYpmNode.getFirstChild(), nullValue());
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ysr/DefaultYangSchemaRegistryTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ysr/DefaultYangSchemaRegistryTest.java
deleted file mode 100644
index 9e40b39..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ysr/DefaultYangSchemaRegistryTest.java
+++ /dev/null
@@ -1,704 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ysr;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network1.rev20151208.IetfNetwork1Service;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.IetfNetwork2Service;
-import org.onosproject.yang.gen.v1.ydt.test.rev20160524.TestService;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangRevision;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-import org.onosproject.yms.app.yab.TestManager;
-
-import java.io.IOException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-
-/**
- * Unit test case for default schema registry.
- */
-public class DefaultYangSchemaRegistryTest {
-
- private static final String SERVICE_NAME_1 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network1.rev20151208.IetfNetwork1Service";
- private static final String SCHEMA_NAME_1 = "ietf-network1";
- private static final String EVENT_NAME_1 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network1.rev20151208.ietfnetwork1.IetfNetwork1Event";
- private static final String INTERFACE_NAME_1 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network1.rev20151208.IetfNetwork1";
- private static final String OP_PARAM_NAME_1 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network1.rev20151208.IetfNetwork1OpParam";
-
- private static final String SERVICE_NAME_2 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network2.rev20151208.IetfNetwork2Service";
- private static final String SCHEMA_NAME_2 = "ietf-network2";
- private static final String EVENT_NAME_2 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network2.rev20151208.ietfnetwork2.IetfNetwork2Event";
- private static final String INTERFACE_NAME_2 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network2.rev20151208.IetfNetwork2";
- private static final String OP_PARAM_NAME_2 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network2.rev20151208.IetfNetwork2OpParam";
-
- private static final String SERVICE_NAME_3 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network3.rev20151208.IetfNetwork3Service";
- private static final String SCHEMA_NAME_3 = "ietf-network3";
- private static final String EVENT_NAME_3 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network3.rev20151208.ietfnetwork3.IetfNetwork3Event";
- private static final String INTERFACE_NAME_3 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network3.rev20151208.IetfNetwork3";
- private static final String OP_PARAM_NAME_3 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network3.rev20151208.IetfNetwork3OpParam";
-
- private static final String SCHEMA_NAME_4_14 = "ietf-network4@2014-00-08";
- private static final String SCHEMA_NAME_4_15 = "ietf-network4@2015-00-08";
- private static final String SCHEMA_NAME_4_16 = "ietf-network4@2016-00-08";
- private static final String SCHEMA_NAME_4_17 = "ietf-network4@2017-00-08";
- private static final String SCHEMA_NAME_4 = "ietf-network4";
- private static final String SERVICE_NAME_REV_14 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20141208.IetfNetwork4Service";
- private static final String EVENT_NAME_REV_14 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20141208.ietfnetwork4.IetfNetwork4Event";
- private static final String INTERFACE_NAME_REV_14 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20141208.IetfNetwork4";
- private static final String OP_PARAM_NAME_REV_14 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20141208.IetfNetwork4OpParam";
-
- private static final String SERVICE_NAME_REV_15 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20151208.IetfNetwork4Service";
- private static final String EVENT_NAME_REV_15 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20151208.ietfnetwork4.IetfNetwork4Event";
- private static final String INTERFACE_NAME_REV_15 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20151208.IetfNetwork4";
- private static final String OP_PARAM_NAME_REV_15 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20151208.IetfNetwork4OpParam";
-
- private static final String SERVICE_NAME_REV_16 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20161208.IetfNetwork4Service";
-
- private static final String EVENT_NAME_REV_16 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20161208.ietfnetwork4.IetfNetwork4Event";
- private static final String INTERFACE_NAME_REV_16 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20161208.IetfNetwork4";
- private static final String OP_PARAM_NAME_REV_16 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20161208.IetfNetwork4OpParam";
-
- private static final String SERVICE_NAME_REV_17 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20171208.IetfNetwork4Service";
- private static final String EVENT_NAME_REV_17 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20171208.ietfnetwork4.IetfNetwork4Event";
- private static final String INTERFACE_NAME_REV_17 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20171208.IetfNetwork4";
- private static final String OP_PARAM_NAME_REV_17 =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.rev20171208.IetfNetwork4OpParam";
-
- private static final String SERVICE_NAME_NO_REV =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.IetfNetwork4Service";
- private static final String EVENT_NAME_NO_REV =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.ietfnetwork4.IetfNetwork4Event";
- private static final String INTERFACE_NAME_NO_REV =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.IetfNetwork4";
- private static final String OP_PARAM_NAME_NO_REV =
- "org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf" +
- ".network4.IetfNetwork4OpParam";
-
- private static final String DATE = "2014-00-08";
- private static final String SCHEMA_NAME_WITH_DATE =
- "ietf-network4@2014-00-08";
-
- private static final String UN_REG_SCHEMA_NAME = "ietf-routing";
- private static final String UN_REG_INTERFACE_NAME = "IetfRouting";
- private static final String UN_REG_OP_PARAM_NAME = "IetfRoutingOpParam";
- private static final String UN_REG_SERVICE_NAME = "IetfRoutingService";
- private static final String UN_REG_EVENT_NAME = "IetfRoutingEvent";
- private static final String CHECK = "check";
- private static final String DATE_NAMESPACE = "2015-00-08";
- private static final String NAMESPACE =
- "urn:ietf:params:xml:ns:yang:ietf-network4:check:namespace";
-
- private final TestYangSchemaNodeProvider testYangSchemaNodeProvider =
- new TestYangSchemaNodeProvider();
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- /**
- * Unit test case in which schema node should be present.
- *
- * @throws IOException when fails to do IO operation
- */
- @Test
- public void testForGetSchemaNode()
- throws IOException {
-
- testYangSchemaNodeProvider.processSchemaRegistry(null);
-
- DefaultYangSchemaRegistry registry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangSchemaNode yangNode =
- registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_1);
- assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_1);
- assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_1);
- assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_1);
- assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_1);
- assertThat(true, is(SCHEMA_NAME_1.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- Object object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_1);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_1);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_1);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_1);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_1);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_1);
- assertThat(true, is(yangNode == null));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
-
- //With second service.
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_2);
- assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_2);
- assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_2);
- assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_2);
- assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_2);
- assertThat(true, is(SCHEMA_NAME_2.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
-
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_2);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_2);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_2);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_2);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_2);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_2);
- assertThat(true, is(yangNode == null));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
-
- //With third service.
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_3);
- assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_3);
- assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_3);
- assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_3);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_3);
- assertThat(true, is(SCHEMA_NAME_3.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
-
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_3);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_3);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_3);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_3);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_3);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_3);
- assertThat(true, is(yangNode == null));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- }
-
- /**
- * Unit test case in which schema node should not be present.
- *
- * @throws IOException when fails to do IO operation
- */
- @Test
- public void testForDoNotGetSchemaNode()
- throws IOException {
-
- DefaultYangSchemaRegistry registry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- // here all nodes should be null as we have not done any registration
- // for this application.
- YangSchemaNode yangNode =
- registry.getYangSchemaNodeUsingAppName(UN_REG_SERVICE_NAME);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(UN_REG_SCHEMA_NAME);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- UN_REG_INTERFACE_NAME);
- assertThat(true, is(yangNode == null));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- UN_REG_OP_PARAM_NAME);
- assertThat(true, is(yangNode == null));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(
- UN_REG_EVENT_NAME);
- assertThat(true, is(yangNode == null));
-
- //As we have not registered an application this object should be null.
- Object object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- }
-
- /**
- * Unit test case in which schema node should be present with multi
- * revisions.
- *
- * @throws IOException when fails to do IO operation
- */
- @Test
- public void testForGetSchemaNodeWhenNoRevision()
- throws IOException {
-
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- //Service with rev.
- YangSchemaNode yangNode =
- registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(
- EVENT_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- Object object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_15);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_15);
- assertThat(true, is(yangNode == null));
-
- //Here the yangNode should be the node which does not have revision.
- // asset should pass with false.
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(((YangNode) yangNode).getRevision() == null));
-
- //Service no revision.
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_NO_REV);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_NO_REV);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_NO_REV);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_NO_REV);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_NO_REV);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_NO_REV);
- assertThat(true, is(yangNode == null));
-
- //Here the yangNode should be the node which have different revision.
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(yangNode != null));
- assertThat(true, is(((YangNode) yangNode).getRevision() != null));
- }
-
- /**
- * Unit test case in which schema node should be present with multi
- * revisions.
- *
- * @throws IOException when fails to do IO operation
- */
- @Test
- public void testForGetSchemaNodeWhenMultiRevision()
- throws IOException {
-
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- //Service with rev.
- YangSchemaNode yangNode =
- registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(
- EVENT_NAME_REV_15);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- Object object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_15);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_15);
- assertThat(true, is(yangNode == null));
-
- //Here the yangNode should be the node which does not have revision.
- // asset should pass with false.
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(((YangNode) yangNode).getRevision() == null));
-
- //Service with different revision.
- yangNode = registry
- .getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_16);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4_16);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_REV_16);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_REV_16);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_REV_16);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_16);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_16);
- assertThat(true, is(yangNode == null));
-
- //Here the yangNode should be the node which have different revision.
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(((YangNode) yangNode).getRevision() == null));
-
- //Service with different revision.
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_17);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4_17);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_REV_17);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_REV_17);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(
- EVENT_NAME_REV_17);
- assertThat(true, is(yangNode == null));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_17);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_17);
- assertThat(true, is(yangNode == null));
-
- //Here the yangNode should be the node which have different revision.
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(((YangNode) yangNode).getRevision() == null));
-
- //Service no revision.
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_NO_REV);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_NO_REV);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_NO_REV);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(EVENT_NAME_NO_REV);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_NO_REV);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_NO_REV);
- assertThat(true, is(yangNode == null));
-
- //Here the yangNode should be the node which have different revision.
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4);
- assertThat(true, is(yangNode != null));
- assertThat(true, is(((YangNode) yangNode).getRevision() != null));
-
- //Service with different revision.
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_14);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_4_14);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeInterfaceFileName(
- INTERFACE_NAME_REV_14);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode =
- registry.getYangSchemaNodeUsingGeneratedRootNodeOpPramFileName(
- OP_PARAM_NAME_REV_14);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- yangNode = registry.getRootYangSchemaNodeForNotification(
- EVENT_NAME_REV_14);
- assertThat(true, is(SCHEMA_NAME_4.equals(yangNode.getName())));
-
- //As we have not registered an application this object should be null.
- object = registry.getRegisteredApplication(yangNode);
- assertThat(true, is(object == null));
- testYangSchemaNodeProvider.unregisterService(SERVICE_NAME_REV_14);
-
- yangNode = registry.getYangSchemaNodeUsingAppName(SERVICE_NAME_REV_14);
- assertThat(true, is(yangNode == null));
- }
-
- /**
- * Unit test case should generate exceptions.
- */
- @Test
- public void testRegistration() {
- thrown.expect(RuntimeException.class);
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- testYangSchemaNodeProvider.processRegistrationOfApp();
- }
-
- /**
- * Unit test case should not generate any exceptions and should
- * return specific revision node.
- */
- @Test
- public void testGetWithSpecificRevision() {
- testYangSchemaNodeProvider.processSchemaRegistry(null);
- YangSchemaNode schemaNode = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry()
- .getYangSchemaNodeUsingSchemaName(SCHEMA_NAME_WITH_DATE);
-
- assertThat(true, is(schemaNode.getName().equals(SCHEMA_NAME_4)));
- String date = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry()
- .getDateInStringFormat(schemaNode);
- assertThat(true, is(date.equals(DATE)));
- }
-
- /**
- * Unit test case should not generate any exceptions
- * verify notification should be checked for registration.
- */
- @Test
- public void testNotification() {
- MockIetfManager manager = new MockIetfManager();
- testYangSchemaNodeProvider.processSchemaRegistry(manager);
- boolean isRegWithNotification =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry()
- .verifyNotificationObject(manager, IetfNetwork1Service.class);
- assertThat(true, is(isRegWithNotification));
- isRegWithNotification = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry()
- .verifyNotificationObject(manager, IetfNetwork2Service.class);
- assertThat(false, is(isRegWithNotification));
- isRegWithNotification = testYangSchemaNodeProvider
- .getDefaultYangSchemaRegistry()
- .verifyNotificationObject(new TestManager(), TestService.class);
- assertThat(false, is(isRegWithNotification));
- }
-
- /**
- * get schema for namespace in decode test.
- */
- @Test
- public void testGetNodeWrtNamespace() {
- MockIetfManager manager = new MockIetfManager();
- testYangSchemaNodeProvider.processSchemaRegistry(manager);
- DefaultYangSchemaRegistry registry =
- testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
-
- YangSchemaNode yangNode =
- registry.getSchemaWrtNameSpace(NAMESPACE);
- assertThat(true, is(CHECK.equals(yangNode.getName())));
-
- YangRevision rev = ((YangNode) yangNode).getRevision();
- assertThat(true, is(rev != null));
-
- String date = registry.getDateInStringFormat(yangNode);
- assertThat(true, is(DATE_NAMESPACE.equals(date)));
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ysr/MockIetfManager.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ysr/MockIetfManager.java
deleted file mode 100644
index 2086ed4..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ysr/MockIetfManager.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ysr;
-
-import org.onosproject.event.ListenerRegistry;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.IetfNetwork2;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.IetfNetwork2OpParam;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.IetfNetwork2Service;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.ietfnetwork2.IetfNetwork2Event;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network2.rev20151208.ietfnetwork2.IetfNetwork2EventListener;
-
-/**
- * Represent mock implementation for services.
- */
-public class MockIetfManager
- extends ListenerRegistry<IetfNetwork2Event, IetfNetwork2EventListener>
- implements IetfNetwork2Service {
-
- @Override
- public IetfNetwork2 getIetfNetwork2(IetfNetwork2OpParam ietfNetwork2) {
- return null;
- }
-
- @Override
- public void setIetfNetwork2(IetfNetwork2OpParam ietfNetwork2) {
-
- }
-
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ysr/TestYangSchemaNodeProvider.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ysr/TestYangSchemaNodeProvider.java
deleted file mode 100644
index f78d903..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ysr/TestYangSchemaNodeProvider.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ysr;
-
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network1.rev20151208.IetfNetwork1Service;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangSchemaNode;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.deSerializeDataModel;
-import static org.onosproject.yangutils.utils.UtilConstants.TEMP;
-import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
-
-/**
- * Represents mock bundle context. provides bundle context for YSR to do unit
- * testing.
- */
-public class TestYangSchemaNodeProvider {
-
- private static final String FS = File.separator;
- private static final String PATH = System.getProperty("user.dir") +
- FS + "target" + FS + "classes" + FS;
- private static final String SER_FILE_PATH = "yang" + FS + "resources" +
- FS + "YangMetaData.ser";
- private static final String TEMP_FOLDER_PATH = PATH + TEMP;
- private final DefaultYangSchemaRegistry registry =
- new DefaultYangSchemaRegistry();
- private static final String RESOURCE = "src/test/resources";
- private List<YangNode> nodes = new ArrayList<>();
-
- /**
- * Creates an instance of mock bundle context.
- */
- public TestYangSchemaNodeProvider() {
- }
-
- /**
- * Process YANG schema node for a application.
- *
- * @param appObject application object
- */
- public void processSchemaRegistry(Object appObject) {
- try {
- Set<YangNode> appNode = deSerializeDataModel(PATH + SER_FILE_PATH);
- nodes.addAll(appNode);
- String appName;
- ClassLoader classLoader = TestYangSchemaNodeProvider.class.getClassLoader();
- for (YangSchemaNode node : nodes) {
- appName = registry.getServiceName(node);
- Class<?> cls;
- try {
- cls = classLoader.loadClass(appName);
- } catch (ClassNotFoundException e) {
- continue;
- }
- registry.processRegistration(cls, RESOURCE, nodes, appObject, true);
- registry.updateServiceClass(cls);
- //interface generation.
- appName = registry.getInterfaceClassName(node);
- try {
- cls = classLoader.loadClass(appName);
- } catch (ClassNotFoundException e) {
- continue;
- }
- registry.processRegistration(cls, RESOURCE,
- nodes, appObject, true);
- registry.updateServiceClass(cls);
- }
- deleteDirectory(TEMP_FOLDER_PATH);
- } catch (IOException e) {
- }
- }
-
- /**
- * Unregisters services.
- *
- * @param appName application name
- */
- void unregisterService(String appName) {
- ClassLoader classLoader = TestYangSchemaNodeProvider.class.getClassLoader();
- try {
- Class<?> cls = classLoader.loadClass(appName);
- registry.unRegisterApplication(null, cls);
- } catch (ClassNotFoundException e) {
- }
-
- }
-
- /**
- * Returns schema registry.
- *
- * @return schema registry
- */
- public DefaultYangSchemaRegistry getDefaultYangSchemaRegistry() {
- return registry;
- }
-
- /**
- * Process registration of a service.
- */
- void processRegistrationOfApp() {
- getDefaultYangSchemaRegistry().doPreProcessing(IetfNetwork1Service.class,
- new MockIetfManager());
- }
-
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ytb/DefaultYangTreeBuilderTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ytb/DefaultYangTreeBuilderTest.java
deleted file mode 100644
index c38aa95..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ytb/DefaultYangTreeBuilderTest.java
+++ /dev/null
@@ -1,1155 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ytb;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onosproject.yang.gen.v1.yms.test.ytb.derived.type.with.bits.and.binary.rev20160826.YtbDerivedTypeWithBitsAndBinary;
-import org.onosproject.yang.gen.v1.yms.test.ytb.derived.type.with.bits.and.binary.rev20160826.YtbDerivedTypeWithBitsAndBinaryOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.derived.type.with.bits.and.binary.rev20160826.ytbderivedtypewithbitsandbinary.Derivedbinarya;
-import org.onosproject.yang.gen.v1.yms.test.ytb.derived.type.with.bits.and.binary.rev20160826.ytbderivedtypewithbitsandbinary.Derivedbinaryb;
-import org.onosproject.yang.gen.v1.yms.test.ytb.derived.type.with.bits.and.binary.rev20160826.ytbderivedtypewithbitsandbinary.Derivedbitsa;
-import org.onosproject.yang.gen.v1.yms.test.ytb.derived.type.with.bits.and.binary.rev20160826.ytbderivedtypewithbitsandbinary.Derivedbitsb;
-import org.onosproject.yang.gen.v1.yms.test.ytb.derived.type.with.bits.and.binary.rev20160826.ytbderivedtypewithbitsandbinary.ForunionUnion;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.container.rev20160826.YtbModuleWithContainer;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.container.rev20160826.YtbModuleWithContainerOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.container.rev20160826.ytbmodulewithcontainer.DefaultSched;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.container.rev20160826.ytbmodulewithcontainer.Sched;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.leaf.ietfschedule.rev20160826.YtbIetfSchedule;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.leaf.ietfschedule.rev20160826.YtbIetfSchedule.OnosYangOpType;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.leaf.ietfschedule.rev20160826.YtbIetfScheduleOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.leaf.ietfschedule.rev20160826.ytbietfschedule.Enum1Enum;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.leaf.ietfschedule.rev20160826.ytbietfschedule.Enum2Enum;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.leaflist.rev20160826.YtbModuleWithLeafList;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.leaflist.rev20160826.YtbModuleWithLeafListOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.yangautoprefixlist.rev20160826.YtbModuleWithList;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.yangautoprefixlist.rev20160826.YtbModuleWithListOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.yangautoprefixlist.rev20160826.ytbmodulewithlist.DefaultYtblistlist;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.yangautoprefixlist.rev20160826.ytbmodulewithlist.Find;
-import org.onosproject.yang.gen.v1.yms.test.ytb.module.with.yangautoprefixlist.rev20160826.ytbmodulewithlist.Ytblistlist;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.a.rev20160826.YtbMultiModulea;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.a.rev20160826.YtbMultiModuleaOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.a.rev20160826.ytbmultimodulea.DefaultYtbmultilist;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.a.rev20160826.ytbmultimodulea.Ytbmultilist;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.b.rev20160826.YtbMultiModuleb;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.b.rev20160826.YtbMultiModulebOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.b.rev20160826.ytbmultimoduleb.DefaultYtbmultilistb;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.module.b.rev20160826.ytbmultimoduleb.Ytbmultilistb;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.notification.with.container.rev20160826.ytbmultinotificationwithcontainer.DefaultFortesta;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.notification.with.container.rev20160826.ytbmultinotificationwithcontainer.Fortesta;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.notification.with.container.rev20160826.ytbmultinotificationwithcontainer.YtbMultiNotificationWithContainerEvent;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.notification.with.container.rev20160826.ytbmultinotificationwithcontainer.YtbMultiNotificationWithContainerEventSubject;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.notification.with.container.rev20160826.ytbmultinotificationwithcontainer.fortesta.DefaultYtbnot;
-import org.onosproject.yang.gen.v1.yms.test.ytb.multi.notification.with.container.rev20160826.ytbmultinotificationwithcontainer.fortesta.Ytbnot;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.yangautoprefixlist.having.yangautoprefixlist.rev20160826.YtbTreeBuilderForListHavingList;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.yangautoprefixlist.having.yangautoprefixlist.rev20160826.YtbTreeBuilderForListHavingListOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.yangautoprefixlist.having.yangautoprefixlist.rev20160826.ytbtreebuilderforlisthavinglist.Carrier;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.yangautoprefixlist.having.yangautoprefixlist.rev20160826.ytbtreebuilderforlisthavinglist.DefaultCarrier;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.yangautoprefixlist.having.yangautoprefixlist.rev20160826.ytbtreebuilderforlisthavinglist.carrier.DefaultMultiplexes;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.yangautoprefixlist.having.yangautoprefixlist.rev20160826.ytbtreebuilderforlisthavinglist.carrier.Multiplexes;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.yangautoprefixlist.having.yangautoprefixlist.rev20160826.ytbtreebuilderforlisthavinglist.carrier.multiplexes.ApplicationAreas;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.yangautoprefixlist.having.yangautoprefixlist.rev20160826.ytbtreebuilderforlisthavinglist.carrier.multiplexes.DefaultApplicationAreas;
-import org.onosproject.yang.gen.v1.yms.test.ytb.tree.builder.yangautoprefixfor.yangautoprefixlist.having.yangautoprefixlist.rev20160826.ytbtreebuilderforlisthavinglist.carrier.multiplexes.TypesEnum;
-import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
-import org.onosproject.yms.app.ydt.YdtNode;
-import org.onosproject.yms.app.ysr.DefaultYangSchemaRegistry;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YdtContextOperationType;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNull.nullValue;
-import static org.onosproject.yms.ydt.YdtContextOperationType.CREATE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE;
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_REQUEST;
-
-/**
- * Unit test cases for YANG tree builder with different YANG object
- * configuration.
- */
-public class DefaultYangTreeBuilderTest extends YtbErrMsgAndConstants {
-
- private static final String ONE = "1";
- private static final String TWO = "2";
- private static final String THREE = "3";
- private static final String FOUR = "4";
- private static final String FIVE = "5";
- private static final String SIX = "6";
- private static final String NINE = "9";
- private static final String IETF_SCHEDULE = "YtbIetfSchedule";
- private static final String TIME = "time";
- private static final String MOD_LEAF_LIST = "YtbModuleWithLeafList";
- private static final String ENUM_1 = "enum1";
- private static final String ENUM_2 = "enum2";
- private static final String HUNDRED_100 = "hundred-100";
- private static final String TEN_10 = "ten-10";
- private static final String THOUSAND_1000 = "thousand-1000";
- private static final String MOD_CONT = "YtbModuleWithContainer";
- private static final String SCHED = "sched";
- private static final String PREDICT_VAL = "98989";
- private static final String MOD_LIST = "YtbModuleWithList";
- private static final String LIST_LIST = "ytblistlist";
- private static final String PREDICTION = "prediction";
- private static final String TRUE = "true";
- private static final String FALSE = "false";
- private static final String MUL_NOTIFY =
- "YtbMultiNotificationWithContainer";
- private static final String NOTIFICATION = "notification";
- private static final String NOTIFY = "fortesta";
- private static final String YTB_NOTIFY_CONT = "ytbnot";
- private static final String NOTIFY_LEAF = "notileaf";
- private static final String ANT = "ant";
- private static final String ANIMAL = "animal";
- private static final String BIRD = "bird";
- private static final String BALL = "ball";
- private static final String BAT = "bat";
- private static final String MUL_MOD_A = "YtbMultiModulea";
- private static final String MUL_LIST_A = "ytbmultilist";
- private static final String CHECK = "check";
- private static final String MUL_MOD_B = "YtbMultiModuleb";
- private static final String MUL_LIST_B = "ytbmultilistb";
- private static final String CHECKIN = "checkin";
- private static final String LIST_WITH_LIST =
- "YtbTreeBuilderForListHavingList";
- private static final String CONT_CARRIER = "carrier";
- private static final String LIST_MULTIPLEXES = "multiplexes";
- private static final String TYPES = "types";
- private static final String TIME_DIVISION = "time-division";
- private static final String APP_AREA_LIST = "application-areas";
- private static final String DEST_AREA = "destination-areas";
- private static final String FREQUENCY_DIV = "frequency-division";
- private static final String MOD_BIT_BIN = "YtbDerivedTypeWithBitsAndBinary";
- private static final String FOR_BINARY = "forbinary";
- private static final String BIN_VAL_1 = "BQUF";
- private static final String FOR_BITS = "forbits";
- private static final String FOR_BINARY_LIST = "forbinarylist";
- private static final String BIN_VAL_2 = "CQkA";
- private static final String BIN_VAL_3 = "DAYA";
- private static final String BIN_VAL_4 = "EB0Z";
- private static final String FOR_BITS_LIST = "forbitslist";
- private static final String FOR_UNION = "forunion";
- private static final String BIN_VAL_5 = "AAAA";
- private static final String BIT_VAL_1 = "leaf1 leaf2";
- private static final String BIN_VAL_6 = "AQYD";
- private static final String BIN_VAL_7 = "AgcE";
- private static final String BIN_VAL_8 = "BQYB";
- private static final String BIN_VAL_9 = "AwgE";
- private static final String BIN_VAL_10 = "AQAA";
- private static final String BIN_VAL_11 = "AAAB";
- private static final String BIN_VAL_12 = "BwcH";
- private static final String BIN_VAL_13 = "AAE=";
- private static final String BIT_VAL_2 = "index signature";
- private static final String BIT_VAL_3 = "index";
- private static final String BIT_VAL_4 = "index name";
- private static final String BIT_VAL_5 = "index name signature";
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private static String emptyObjErrMsg(String objName) {
- return "The " + objName + " given for tree creation cannot be null";
- }
-
- private static BigDecimal getBigDeci(int bigDecimal) {
- return BigDecimal.valueOf(bigDecimal);
- }
-
- /**
- * Processes an empty object list to the YTB and checks that the
- * exception is thrown.
- */
- @Test
- public void processInvalidListInput() {
- thrown.expect(YtbException.class);
- thrown.expectMessage(emptyObjErrMsg("object list"));
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- treeBuilder.getYdtBuilderForYo(null, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, null);
- }
-
- /**
- * Processes an empty notification object to the YTB and checks that the
- * exception is thrown.
- */
- @Test
- public void processInvalidInputForNotification() {
- thrown.expect(YtbException.class);
- thrown.expectMessage(emptyObjErrMsg("event object"));
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- treeBuilder.getYdtForNotification(null, ROOT_NAME, null);
- }
-
- /**
- * Processes an empty rpc output object to the YTB and checks that the
- * exception is thrown.
- */
- @Test
- public void processInvalidInputForRpc() {
- thrown.expect(YtbException.class);
- thrown.expectMessage(emptyObjErrMsg("output object"));
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- treeBuilder.getYdtForRpcResponse(null, null);
- }
-
- /**
- * Processes a YAB/YSB request to YTB with a leaf value being filled in
- * the app object. Checks the constructed YDT tree for module and leaf
- * and its value.
- */
- @Test
- public void processModuleAndLeaf() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
- YtbIetfSchedule schedule = new YtbIetfScheduleOpParam
- .YtbIetfScheduleBuilder()
- .time((byte) 9)
- .yangYtbIetfScheduleOpType(OnosYangOpType.MERGE)
- .build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(schedule);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and checks the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- YdtContextOperationType opType = ((YdtNode) module)
- .getYdtContextOperationType();
- assertThat(getInCrtName(MODULE, IETF_SCHEDULE),
- module.getName(), is(IETF_SCHEDULE));
- assertThat(getInCrtOpType(MODULE, IETF_SCHEDULE),
- opType, is(MERGE));
-
- // Gets the first leaf from module IetfSchedule.
- YdtContext leafContext = module.getFirstChild();
- assertThat(getInCrtName(LEAF, TIME),
- leafContext.getName(), is(TIME));
- assertThat(getInCrtLeafValue(TIME, NINE),
- leafContext.getValue(), is(NINE));
- }
-
- /**
- * Processes a YAB/YSB request to YTB with a leaf-list value being filled
- * in the app object. Checks the constructed YDT tree for module and
- * leaf-list and its value.
- */
- @Test
- public void processModuleAndLeafList() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates list of type long for setting the leaf-list.
- List<Long> longList = new ArrayList<>();
- longList.add((long) 1);
- longList.add((long) 2);
- longList.add((long) 3);
-
- YtbModuleWithLeafList leafListModule = new YtbModuleWithLeafListOpParam
- .YtbModuleWithLeafListBuilder().time(longList).build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(leafListModule);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE, QUERY_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- YdtContextOperationType opType = ((YdtNode) module)
- .getYdtContextOperationType();
- assertThat(getInCrtName(MODULE, MOD_LEAF_LIST),
- module.getName(), is(MOD_LEAF_LIST));
- assertThat(getInCrtOpType(MODULE, MOD_LEAF_LIST), opType, nullValue());
-
- // Gets the first leaf-list from module.
- YdtContext leafList = module.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, TIME), leafList.getName(),
- is(TIME));
- Set<String> value = leafList.getValueSet();
- assertThat(getInCrtLeafListValue(TIME, ONE),
- value.contains(ONE), is(true));
- assertThat(getInCrtLeafListValue(TIME, TWO),
- value.contains(TWO), is(true));
- assertThat(getInCrtLeafListValue(TIME, THREE),
- value.contains(THREE), is(true));
- }
-
- /**
- * Processes leaf and leaf-list with type enum under module. Checks the
- * constructed YDT tree has YANG enum value.
- */
- @Test
- public void processWithTypeEnum() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates enum list for setting the leaf-list.
- List<Enum2Enum> enumList = new ArrayList<>();
- enumList.add(Enum2Enum.HUNDRED_100);
- enumList.add(Enum2Enum.TEN_10);
- enumList.add(Enum2Enum.THOUSAND_1000);
-
- YtbIetfSchedule schedule = new YtbIetfScheduleOpParam
- .YtbIetfScheduleBuilder()
- .time((byte) 9)
- .yangYtbIetfScheduleOpType(OnosYangOpType.MERGE)
- .enum1(Enum1Enum.HUNDRED)
- .enum2(enumList)
- .build();
-
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(schedule);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- YdtContextOperationType opType =
- ((YdtNode) module).getYdtContextOperationType();
- assertThat(getInCrtName(MODULE, IETF_SCHEDULE),
- module.getName(), is(IETF_SCHEDULE));
- assertThat(getInCrtOpType(MODULE, IETF_SCHEDULE), opType, is(MERGE));
-
- // Checks the leaf and leaf-list values.
- YdtContext timeLeaf = module.getFirstChild();
- assertThat(getInCrtName(LEAF, TIME), timeLeaf.getName(), is(TIME));
- assertThat(getInCrtLeafValue(TIME, NINE),
- timeLeaf.getValue(), is(NINE));
-
- YdtContext enum1Leaf = timeLeaf.getNextSibling();
- assertThat(getInCrtName(LEAF, ENUM_1), enum1Leaf.getName(), is(ENUM_1));
- assertThat(getInCrtLeafValue(ENUM_1, HUNDRED),
- enum1Leaf.getValue(), is(HUNDRED));
-
- YdtContext enum2LeafList = enum1Leaf.getNextSibling();
- assertThat(getInCrtName(LEAF_LIST, ENUM_2),
- enum2LeafList.getName(), is(ENUM_2));
- Set<String> valueSet = enum2LeafList.getValueSet();
- assertThat(getInCrtLeafListValue(ENUM_2, HUNDRED_100),
- valueSet.contains(HUNDRED_100), is(true));
- assertThat(getInCrtLeafListValue(ENUM_2, TEN_10),
- valueSet.contains(TEN_10), is(true));
- assertThat(getInCrtLeafListValue(ENUM_2, THOUSAND_1000),
- valueSet.contains(THOUSAND_1000), is(true));
- }
-
- /**
- * Processes a YAB/YSB request to YTB with a container having leaf value
- * being filled in the app object. Checks the constructed YDT tree for
- * module and container and leaf.
- */
- @Test
- public void processModuleWithContainer() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates container object with leaf of decimal type.
- Sched sched = new DefaultSched.SchedBuilder()
- .predict(getBigDeci(98989))
- .yangSchedOpType(
- YtbModuleWithContainerOpParam.OnosYangOpType.DELETE)
- .build();
- // Creates module object with the container.
- YtbModuleWithContainer contModule = new YtbModuleWithContainerOpParam
- .YtbModuleWithContainerBuilder()
- .sched(sched)
- .yangYtbModuleWithContainerOpType(
- YtbModuleWithContainerOpParam.OnosYangOpType.CREATE)
- .build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(contModule);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- QUERY_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- YdtContextOperationType opType = ((YdtNode) module)
- .getYdtContextOperationType();
-
- assertThat(getInCrtName(MODULE, MOD_CONT),
- module.getName(), is(MOD_CONT));
- assertThat(getInCrtOpType(MODULE, MOD_CONT), opType, is(CREATE));
-
- // Get the container from module.
- YdtContext container = module.getFirstChild();
- YdtContextOperationType opTypeOfCont = ((YdtNode) container)
- .getYdtContextOperationType();
-
- assertThat(getInCrtName(CONTAINER, SCHED),
- container.getName(), is("sched"));
- assertThat(getInCrtOpType(CONTAINER, SCHED), opTypeOfCont, is(DELETE));
-
- // Gets leaf from container.
- YdtContext leafContext = container.getFirstChild();
- assertThat(getInCrtName(LEAF, PREDICT),
- leafContext.getName(), is(PREDICT));
- assertThat(getInCrtLeafValue(PREDICT, PREDICT_VAL),
- leafContext.getValue(), is(PREDICT_VAL));
- }
-
- /**
- * Processes a YAB/YSB request to YTB with a list having leaf-list value
- * being filled in the app object. Checks the constructed YDT tree for
- * module and list and leaf-list.
- */
- @Test
- public void processModuleWithList() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates multi typedef values.
- Find find1 = new Find(true);
- Find find2 = new Find(false);
- Find find3 = new Find(true);
- Find find4 = new Find(false);
-
- // Creates two lists, with the typedef values added.
- List<Find> findList1 = new ArrayList<>();
- List<Find> findList2 = new ArrayList<>();
- findList1.add(find1);
- findList1.add(find2);
- findList2.add(find3);
- findList2.add(find4);
-
- // Creates two list contents.
- Ytblistlist list1 = new DefaultYtblistlist
- .YtblistlistBuilder().prediction(findList1).build();
- Ytblistlist list2 = new DefaultYtblistlist
- .YtblistlistBuilder().prediction(findList2).build();
-
- List<Ytblistlist> ytbList = new ArrayList<>();
- ytbList.add(list1);
- ytbList.add(list2);
-
- // Creates module having list.
- YtbModuleWithList listModule = new YtbModuleWithListOpParam
- .YtbModuleWithListBuilder().ytblistlist(ytbList).build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(listModule);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- YdtContextOperationType opType = ((YdtNode) module)
- .getYdtContextOperationType();
-
- assertThat(getInCrtName(MODULE, MOD_LIST),
- module.getName(), is(MOD_LIST));
- assertThat(getInCrtOpType(MODULE, MOD_LIST), opType, nullValue());
-
- // Gets the first list from module YtbModuleWithList.
- YdtContext firstList = module.getFirstChild();
- YdtContextOperationType listOpType = ((YdtNode) firstList)
- .getYdtContextOperationType();
- // Checks the contents in the list.
- assertThat(getInCrtName(LIST, LIST_LIST),
- firstList.getName(), is(LIST_LIST));
- assertThat(getInCrtOpType(LIST, LIST_LIST), listOpType, nullValue());
-
- // Gets the contents of the leaf-list in the first list content.
- YdtContext leafListInList1 = firstList.getFirstChild();
-
- // Evaluates the leaf-list values.
- Set leafListValue1 = leafListInList1.getValueSet();
- assertThat(getInCrtName(LEAF_LIST, PREDICTION),
- leafListInList1.getName(), is(PREDICTION));
- assertThat(getInCrtLeafListValue(PREDICTION, TRUE),
- leafListValue1.contains(TRUE), is(true));
- assertThat(getInCrtLeafListValue(PREDICTION, FALSE),
- leafListValue1.contains(FALSE), is(true));
-
- // Gets the second list from module YtbModuleWithList.
- YdtContext secondList = firstList.getNextSibling();
-
- // Gets the contents of the leaf-list in the second list content.
- YdtContext leafListInList2 = secondList.getFirstChild();
- // Evaluates the leaf-list values.
- Set leafListValue2 = leafListInList2.getValueSet();
- assertThat(getInCrtName(LEAF_LIST, PREDICTION),
- leafListInList2.getName(), is(PREDICTION));
- assertThat(getInCrtLeafListValue(PREDICTION, TRUE),
- leafListValue2.contains(TRUE), is(true));
- assertThat(getInCrtLeafListValue(PREDICTION, FALSE),
- leafListValue2.contains(FALSE), is(true));
- }
-
- /**
- * Processes multi notification under module when request comes for one
- * notification event in module.
- */
- @Test
- public void processMultiNotificationWithContainer() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Sets the bit value.
- BitSet bitleaf = new BitSet();
- bitleaf.set(0);
- bitleaf.set(1);
-
- // Creates container with the leaf.
- Ytbnot ytbnot = new DefaultYtbnot.YtbnotBuilder().notileaf(bitleaf)
- .build();
- // Creates notification with container.
- Fortesta testa = new DefaultFortesta.FortestaBuilder()
- .ytbnot(ytbnot).build();
- // Invokes event subject class with notification.
- YtbMultiNotificationWithContainerEventSubject eventSubject = new
- YtbMultiNotificationWithContainerEventSubject();
- eventSubject.fortesta(testa);
- // Invokes event class with the event type and the event subject obj.
- YtbMultiNotificationWithContainerEvent event =
- new YtbMultiNotificationWithContainerEvent(
- YtbMultiNotificationWithContainerEvent.Type.FORTESTA,
- eventSubject);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtContext ydtContext = treeBuilder.getYdtForNotification(
- event, ROOT_NAME, registry);
-
- // Gets the first module from logical root node.
- YdtContext context = ydtContext.getFirstChild();
- YdtContextOperationType opType = ((YdtNode) context)
- .getYdtContextOperationType();
-
- assertThat(getInCrtName(MODULE, MUL_NOTIFY), context.getName(),
- is(MUL_NOTIFY));
- assertThat(getInCrtOpType(MODULE, MUL_NOTIFY), opType, is(NONE));
-
- // Gets the notification under module.
- YdtContext notify = context.getFirstChild();
- YdtContextOperationType notifyOpType = ((YdtNode) notify)
- .getYdtContextOperationType();
-
- // Checks the contents in the first notification.
- assertThat(getInCrtName(NOTIFICATION, NOTIFY), notify.getName(),
- is(NOTIFY));
- assertThat(getInCrtOpType(NOTIFICATION, NOTIFY), notifyOpType,
- is(NONE));
-
- // Gets the container in notification
- YdtContext container = notify.getFirstChild();
- assertThat(getInCrtName(CONTAINER, YTB_NOTIFY_CONT),
- container.getName(), is(YTB_NOTIFY_CONT));
-
- // Evaluates the leaf values.
- YdtContext leafInCont = container.getFirstChild();
- assertThat(getInCrtName(LEAF, NOTIFY_LEAF), leafInCont.getName(),
- is(NOTIFY_LEAF));
- assertThat(getInCrtLeafValue(NOTIFY_LEAF, BIT_VAL_1),
- leafInCont.getValue(), is(BIT_VAL_1));
- }
-
- /**
- * Processes multi module with list in both the modules and checks the
- * YANG data tree building.
- */
- @Test
- public void processMultiModule() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates list of big integer for leaf-list under list1.
- List<BigInteger> bigIntegerList = new ArrayList<>();
- bigIntegerList.add(BigInteger.valueOf(1));
- bigIntegerList.add(BigInteger.valueOf(2));
- bigIntegerList.add(BigInteger.valueOf(3));
- // Creates list of big integer for leaf-list under list2.
- List<BigInteger> bigIntegerList1 = new ArrayList<>();
- bigIntegerList1.add(BigInteger.valueOf(4));
- bigIntegerList1.add(BigInteger.valueOf(5));
- bigIntegerList1.add(BigInteger.valueOf(6));
-
- // Creates two list contents.
- Ytbmultilist listContent1 = new DefaultYtbmultilist
- .YtbmultilistBuilder().check(bigIntegerList).build();
- Ytbmultilist listContent2 = new DefaultYtbmultilist
- .YtbmultilistBuilder().check(bigIntegerList1).build();
-
- List<Ytbmultilist> ytbmultilists = new ArrayList<>();
- ytbmultilists.add(listContent1);
- ytbmultilists.add(listContent2);
-
- // Creates module-a with two list contents created.
- YtbMultiModulea modulea = new YtbMultiModuleaOpParam
- .YtbMultiModuleaBuilder().ytbmultilist(ytbmultilists).build();
-
- // Creates list of string for leaf-list under list1.
- List<String> stringList = new ArrayList<>();
- stringList.add(ANT);
- stringList.add(ANIMAL);
- stringList.add(BIRD);
-
- // Creates list of string for leaf-list under list2.
- List<String> stringList1 = new ArrayList<>();
- stringList1.add(CATCH);
- stringList1.add(BALL);
- stringList1.add(BAT);
-
- // Creates two list contents.
- Ytbmultilistb listContent3 = new DefaultYtbmultilistb
- .YtbmultilistbBuilder().checkin(stringList).build();
- Ytbmultilistb listContent4 = new DefaultYtbmultilistb
- .YtbmultilistbBuilder().checkin(stringList1).build();
-
- List<Ytbmultilistb> ytbMultiListb = new ArrayList<>();
- ytbMultiListb.add(listContent3);
- ytbMultiListb.add(listContent4);
-
- // Creates module-b with two list contents created.
- YtbMultiModuleb moduleb = new YtbMultiModulebOpParam
- .YtbMultiModulebBuilder().ytbmultilistb(ytbMultiListb).build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> listOfModules = new ArrayList<>();
- listOfModules.add(modulea);
- listOfModules.add(moduleb);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- listOfModules, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Checks module-a under root node.
- YdtContext moduleA = context.getFirstChild();
- assertThat(getInCrtName(MODULE, MUL_MOD_A), moduleA.getName(),
- is(MUL_MOD_A));
-
- // Checks list-a in module-a and its respective leaf-list.
- YdtContext list1InModuleA = moduleA.getFirstChild();
- assertThat(getInCrtName(LIST, MUL_LIST_A), list1InModuleA.getName(),
- is(MUL_LIST_A));
-
- YdtContext leafListA = list1InModuleA.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, CHECK), leafListA.getName(),
- is(CHECK));
-
- Set<String> valueA = leafListA.getValueSet();
- assertThat(getInCrtLeafListValue(CHECK, ONE), valueA.contains(ONE),
- is(true));
- assertThat(getInCrtLeafListValue(CHECK, TWO), valueA.contains(TWO),
- is(true));
- assertThat(getInCrtLeafListValue(CHECK, THREE), valueA.contains(THREE),
- is(true));
-
- // Checks list-b in module-a and its respective leaf-list.
- YdtContext list2InModuleA = list1InModuleA.getNextSibling();
- assertThat(getInCrtName(LIST, MUL_LIST_A), list2InModuleA.getName(),
- is(MUL_LIST_A));
-
- YdtContext leafListB = list2InModuleA.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, CHECK), leafListB.getName(),
- is(CHECK));
-
- Set<String> valueB = leafListB.getValueSet();
- assertThat(getInCrtLeafListValue(CHECK, FOUR), valueB.contains(FOUR),
- is(true));
- assertThat(getInCrtLeafListValue(CHECK, FIVE), valueB.contains(FIVE),
- is(true));
- assertThat(getInCrtLeafListValue(CHECK, SIX), valueB.contains(SIX),
- is(true));
-
- // Checks module-b under root node.
- YdtContext moduleB = moduleA.getNextSibling();
- assertThat(getInCrtName(MODULE, MUL_MOD_B), moduleB.getName(),
- is(MUL_MOD_B));
-
- // Checks list-a in module-b and its respective leaf-list.
- YdtContext list1InModuleB = moduleB.getFirstChild();
- assertThat(getInCrtName(LIST, MUL_LIST_B), list1InModuleB.getName(),
- is(MUL_LIST_B));
-
- YdtContext leafListC = list1InModuleB.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, CHECKIN), leafListC.getName(),
- is(CHECKIN));
-
- Set<String> valueC = leafListC.getValueSet();
- assertThat(getInCrtLeafListValue(CHECKIN, ANT), valueC.contains(ANT),
- is(true));
- assertThat(getInCrtLeafListValue(CHECKIN, ANIMAL),
- valueC.contains(ANIMAL), is(true));
- assertThat(getInCrtLeafListValue(CHECKIN, BIRD),
- valueC.contains(BIRD), is(true));
-
- // Checks list-b in module-b and its respective leaf-list.
- YdtContext list2InModuleB = list1InModuleB.getNextSibling();
- assertThat(getInCrtName(LIST, MUL_LIST_B), list2InModuleB.getName(),
- is(MUL_LIST_B));
-
- YdtContext leafListD = list2InModuleB.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, CHECKIN), leafListD.getName(),
- is(CHECKIN));
-
- Set<String> valueD = leafListD.getValueSet();
- assertThat(getInCrtLeafListValue(CHECKIN, CATCH),
- valueD.contains(CATCH), is(true));
- assertThat(getInCrtLeafListValue(CHECKIN, BALL),
- valueD.contains(BALL), is(true));
- assertThat(getInCrtLeafListValue(CHECKIN, BAT),
- valueD.contains(BAT), is(true));
- }
-
- /**
- * Processes tree building when a list node is having list inside it.
- */
- @Test
- public void processTreeBuilderForListHavingList() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates two binary leaf-lists for two list app areas.
- List<byte[]> destArea1 = new ArrayList<>();
- byte[] arr = new byte[]{1, 6, 3};
- byte[] arr1 = new byte[]{2, 7, 4};
- destArea1.add(arr);
- destArea1.add(arr1);
-
- List<byte[]> destArea2 = new ArrayList<>();
- byte[] arr2 = new byte[]{3, 8, 4};
- byte[] arr3 = new byte[]{5, 6, 1};
- destArea2.add(arr2);
- destArea2.add(arr3);
-
- // Creates two app areas list.
- ApplicationAreas appArea1 = new DefaultApplicationAreas
- .ApplicationAreasBuilder().destinationAreas(destArea1).build();
- ApplicationAreas appArea2 = new DefaultApplicationAreas
- .ApplicationAreasBuilder().destinationAreas(destArea2).build();
-
- List<ApplicationAreas> applicationAreasList = new ArrayList<>();
- applicationAreasList.add(appArea1);
- applicationAreasList.add(appArea2);
-
- // Adds two lists under the multiplex list for content 1.
- Multiplexes mpx1 = new DefaultMultiplexes.MultiplexesBuilder()
- .types(TypesEnum.TIME_DIVISION)
- .applicationAreas(applicationAreasList).build();
-
- // Creates two binary leaf-lists for two list app areas.
- List<byte[]> destArea3 = new ArrayList<>();
- byte[] arrB = new byte[]{0, 0, 1};
- byte[] arr1B = new byte[]{1, 0, 0};
- destArea3.add(arrB);
- destArea3.add(arr1B);
-
- List<byte[]> destArea4 = new ArrayList<>();
- byte[] arr2B = new byte[]{7, 7, 7};
- byte[] arr3B = new byte[]{0, 1};
- destArea4.add(arr2B);
- destArea4.add(arr3B);
-
- // Creates two app areas list.
- ApplicationAreas appArea3 = new DefaultApplicationAreas
- .ApplicationAreasBuilder().destinationAreas(destArea3).build();
- ApplicationAreas appArea4 = new DefaultApplicationAreas
- .ApplicationAreasBuilder().destinationAreas(destArea4).build();
-
- List<ApplicationAreas> applicationAreasListB = new ArrayList<>();
- applicationAreasListB.add(appArea3);
- applicationAreasListB.add(appArea4);
-
- // Adds two lists under the multiplex list for content 2.
- Multiplexes mpx2 = new DefaultMultiplexes.MultiplexesBuilder()
- .types(TypesEnum.FREQUENCY_DIVISION)
- .applicationAreas(applicationAreasListB).build();
-
- List<Multiplexes> multiplexList = new ArrayList<>();
- multiplexList.add(mpx1);
- multiplexList.add(mpx2);
-
- // Sets it in the container carrier.
- Carrier carrier = new DefaultCarrier.CarrierBuilder()
- .multiplexes(multiplexList).build();
-
- YtbTreeBuilderForListHavingList listWithList = new
- YtbTreeBuilderForListHavingListOpParam
- .YtbTreeBuilderForListHavingListBuilder()
- .carrier(carrier).build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(listWithList);
-
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- QUERY_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(LIST, LIST_WITH_LIST), module.getName(),
- is(LIST_WITH_LIST));
-
- // Checks the container node under module node.
- YdtContext container = module.getFirstChild();
- assertThat(getInCrtName(CONTAINER, CONT_CARRIER), container.getName(),
- is(CONT_CARRIER));
-
- // Checks the list node with content 1 of multiplex.
- YdtContext mtx1 = container.getFirstChild();
- assertThat(getInCrtName(LIST, LIST_MULTIPLEXES), mtx1.getName(),
- is(LIST_MULTIPLEXES));
-
- // Checks enum leaf under multiplex of content1.
- YdtContext enumLeaf1 = mtx1.getFirstChild();
- assertThat(getInCrtName(LEAF, TYPES), enumLeaf1.getName(), is(TYPES));
- assertThat(getInCrtLeafValue(TYPES, TIME_DIVISION),
- enumLeaf1.getValue(), is(TIME_DIVISION));
-
- // Checks list app area content 1 under multiplex content 1.
- YdtContext appAreaList1 = enumLeaf1.getNextSibling();
- assertThat(getInCrtName(LIST, APP_AREA_LIST), appAreaList1.getName(),
- is(APP_AREA_LIST));
-
- YdtContext leafList1 = appAreaList1.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, DEST_AREA), leafList1.getName(),
- is(DEST_AREA));
- Set value1 = leafList1.getValueSet();
- assertThat(getInCrtLeafListValue(DEST_AREA, BIN_VAL_6),
- value1.contains(BIN_VAL_6), is(true));
- assertThat(getInCrtLeafListValue(DEST_AREA, BIN_VAL_7),
- value1.contains(BIN_VAL_7), is(true));
-
- // Checks list app area content 2 under multiplex content 1.
- YdtContext appAreaList2 = appAreaList1.getNextSibling();
- assertThat(getInCrtName(LIST, APP_AREA_LIST), appAreaList2.getName(),
- is(APP_AREA_LIST));
-
- YdtContext leafList2 = appAreaList2.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, DEST_AREA), leafList2.getName(),
- is(DEST_AREA));
- Set value2 = leafList2.getValueSet();
- assertThat(getInCrtLeafListValue(DEST_AREA, BIN_VAL_8),
- value2.contains(BIN_VAL_8), is(true));
- assertThat(getInCrtLeafListValue(DEST_AREA, BIN_VAL_9),
- value2.contains(BIN_VAL_9), is(true));
-
- // Checks the list node with content 2 of multiplex.
- YdtContext mtx2 = mtx1.getNextSibling();
- assertThat(getInCrtName(LIST, LIST_MULTIPLEXES), mtx2.getName(),
- is(LIST_MULTIPLEXES));
-
- // Checks enum leaf under multiplex of content2.
- YdtContext enumLeaf2 = mtx2.getFirstChild();
- assertThat(getInCrtName(LEAF, TYPES), enumLeaf2.getName(), is(TYPES));
- assertThat(getInCrtLeafValue(TYPES, FREQUENCY_DIV),
- enumLeaf2.getValue(), is(FREQUENCY_DIV));
-
- // Checks list app area content 1 under multiplex content 2.
- YdtContext appAreaList3 = enumLeaf2.getNextSibling();
- assertThat(getInCrtName(LIST, APP_AREA_LIST), appAreaList3.getName(),
- is(APP_AREA_LIST));
-
- YdtContext leafList3 = appAreaList3.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, DEST_AREA), leafList3.getName(),
- is(DEST_AREA));
- Set value3 = leafList3.getValueSet();
- assertThat(getInCrtLeafListValue(DEST_AREA, BIN_VAL_10),
- value3.contains(BIN_VAL_10), is(true));
- assertThat(getInCrtLeafListValue(DEST_AREA, BIN_VAL_11),
- value3.contains(BIN_VAL_11), is(true));
-
- // Checks list app area content 2 under multiplex content 2.
- YdtContext appAreaList4 = appAreaList3.getNextSibling();
- assertThat(getInCrtName(LIST, APP_AREA_LIST), appAreaList4.getName(),
- is(APP_AREA_LIST));
-
- YdtContext leafList4 = appAreaList4.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, DEST_AREA), leafList4.getName(),
- is(DEST_AREA));
- Set value4 = leafList4.getValueSet();
- assertThat(getInCrtLeafListValue(DEST_AREA, BIN_VAL_12),
- value4.contains(BIN_VAL_12), is(true));
- assertThat(getInCrtLeafListValue(DEST_AREA, BIN_VAL_13),
- value4.contains(BIN_VAL_13), is(true));
- }
-
- /**
- * Processes tree building from the derived type of leaf and leaf-list
- * having binary and bits .
- */
- @Test
- public void processTreeBuilderForBinaryAndBits() {
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates a byte array for binary leaf.
- byte[] binLeaf = new byte[]{5, 5, 5};
-
- // Assigns the value in the chained loop of typedef.
- Derivedbinaryb derBinb = new Derivedbinaryb(binLeaf);
- Derivedbinarya derBina = new Derivedbinarya(derBinb);
-
- // Creates bit set for bit leaf.
- BitSet bitLeaf = new BitSet();
- bitLeaf.set(1);
- bitLeaf.set(100);
-
- // Assigns the value in the chained loop of typedef.
- Derivedbitsb derBitb = new Derivedbitsb(bitLeaf);
- Derivedbitsa derBita = new Derivedbitsa(derBitb);
-
- // Creates a byte array list for binary leaf-list.
- byte[] binList1 = new byte[]{9, 9, 0};
- byte[] binList2 = new byte[]{12, 6, 0};
- byte[] binList3 = new byte[]{16, 29, 25};
-
- // Assigns the value in the chained loop of typedef.
- Derivedbinaryb derBinBList1 = new Derivedbinaryb(binList1);
- Derivedbinaryb derBinBList2 = new Derivedbinaryb(binList2);
- Derivedbinaryb derBinBList3 = new Derivedbinaryb(binList3);
-
- Derivedbinarya derBinAList1 = new Derivedbinarya(derBinBList1);
- Derivedbinarya derBinAList2 = new Derivedbinarya(derBinBList2);
- Derivedbinarya derBinAList3 = new Derivedbinarya(derBinBList3);
-
- List<Derivedbinarya> binAlist = new ArrayList<>();
- binAlist.add(derBinAList1);
- binAlist.add(derBinAList2);
- binAlist.add(derBinAList3);
-
- // Creates a bit set list for bit leaf-list.
- BitSet bitList1 = new BitSet();
- bitList1.set(1);
- BitSet bitList2 = new BitSet();
- bitList2.set(1);
- bitList2.set(10);
- BitSet bitList3 = new BitSet();
- bitList3.set(1);
- bitList3.set(10);
- bitList3.set(100);
-
- // Assigns the value in the chained loop of typedef.
- Derivedbitsb bitBlist1 = new Derivedbitsb(bitList1);
- Derivedbitsb bitBlist2 = new Derivedbitsb(bitList2);
- Derivedbitsb bitBlist3 = new Derivedbitsb(bitList3);
-
- Derivedbitsa bitAlist1 = new Derivedbitsa(bitBlist1);
- Derivedbitsa bitAlist2 = new Derivedbitsa(bitBlist2);
- Derivedbitsa bitAlist3 = new Derivedbitsa(bitBlist3);
-
- List<Derivedbitsa> bitAlist = new ArrayList<>();
- bitAlist.add(bitAlist1);
- bitAlist.add(bitAlist2);
- bitAlist.add(bitAlist3);
-
- // Creates a module by assigning all the leaf and leaf-list.
- YtbDerivedTypeWithBitsAndBinary bitsAndBinary = new
- YtbDerivedTypeWithBitsAndBinaryOpParam
- .YtbDerivedTypeWithBitsAndBinaryBuilder()
- .forbinary(derBina).forbits(derBita)
- .forbinarylist(binAlist)
- .forbitslist(bitAlist).build();
-
- // As YSB or YAB protocol, sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(bitsAndBinary);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, MOD_BIT_BIN), module.getName(),
- is(MOD_BIT_BIN));
-
- // Checks the leaf for binary.
- YdtContext binaryLeaf = module.getFirstChild();
- assertThat(getInCrtName(LEAF, FOR_BINARY), binaryLeaf.getName(),
- is(FOR_BINARY));
- assertThat(getInCrtLeafValue(FOR_BINARY, BIN_VAL_1),
- binaryLeaf.getValue(), is(BIN_VAL_1));
-
- // Checks the leaf for bits.
- YdtContext bitsLeaf = binaryLeaf.getNextSibling();
- assertThat(getInCrtName(LEAF, FOR_BITS), bitsLeaf.getName(),
- is(FOR_BITS));
- assertThat(getInCrtLeafValue(FOR_BITS, BIT_VAL_2),
- bitsLeaf.getValue(), is(BIT_VAL_2));
-
- // Checks the leaf-list for binary.
- YdtContext binaryLeafList = bitsLeaf.getNextSibling();
- assertThat(getInCrtName(LEAF_LIST, FOR_BINARY_LIST),
- binaryLeafList.getName(), is(FOR_BINARY_LIST));
-
- Set value2 = binaryLeafList.getValueSet();
- assertThat(getInCrtLeafListValue(FOR_BINARY_LIST, BIN_VAL_2),
- value2.contains(BIN_VAL_2), is(true));
- assertThat(getInCrtLeafListValue(FOR_BINARY_LIST, BIN_VAL_3),
- value2.contains(BIN_VAL_3), is(true));
- assertThat(getInCrtLeafListValue(FOR_BINARY_LIST, BIN_VAL_4),
- value2.contains(BIN_VAL_4), is(true));
-
- // Checks the leaf-list for bits.
- YdtContext bitsLeafList = binaryLeafList.getNextSibling();
- assertThat(getInCrtName(LEAF_LIST, FOR_BITS_LIST),
- bitsLeafList.getName(), is(FOR_BITS_LIST));
- Set value3 = bitsLeafList.getValueSet();
- assertThat(getInCrtLeafListValue(FOR_BITS_LIST, BIT_VAL_3),
- value3.contains(BIT_VAL_3), is(true));
- assertThat(getInCrtLeafListValue(FOR_BITS_LIST, BIT_VAL_4),
- value3.contains(BIT_VAL_4), is(true));
- assertThat(getInCrtLeafListValue(FOR_BITS_LIST, BIT_VAL_5),
- value3.contains(BIT_VAL_5), is(true));
- }
-
- /**
- * Processes tree building for the union type.
- */
- @Test
- public void processYtbUnionType() {
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates union with binary type.
- byte[] binary = new byte[]{0, 0, 0};
- ForunionUnion union = new ForunionUnion(binary);
-
- // Creates module with union.
- YtbDerivedTypeWithBitsAndBinary unionType = new
- YtbDerivedTypeWithBitsAndBinaryOpParam
- .YtbDerivedTypeWithBitsAndBinaryBuilder()
- .forunion(union)
- .build();
-
- // As YSB or YAB protocol, sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(unionType);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext rootNode = ydtBuilder.getRootNode();
- YdtContext module = rootNode.getFirstChild();
- YdtContext unionChild = module.getFirstChild();
- assertThat(getInCrtName(LEAF, FOR_UNION), unionChild.getName(),
- is(FOR_UNION));
- assertThat(getInCrtLeafValue(FOR_UNION, BIN_VAL_5),
- unionChild.getValue(), is(BIN_VAL_5));
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ytb/YtbContextSwitchTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ytb/YtbContextSwitchTest.java
deleted file mode 100644
index 5787f62..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ytb/YtbContextSwitchTest.java
+++ /dev/null
@@ -1,1216 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ytb;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev20130715.ymsietfinettypes.Uri;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.YmsIetfNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.YmsIetfNetworkOpParam;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.DefaultNetworks;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.NetworkId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.Networks;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.NodeId;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.networks.DefaultNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.networks.Network;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.networks.network.DefaultNode;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.networks.network.Node;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.networks.network.node.DefaultSupportingNode;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ymsietfnetwork.networks.network.node.SupportingNode;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.from.another.file.rev20160826.ytbaugmentfromanotherfile.networks.network.node.AugmentedNdNode;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.from.another.file.rev20160826.ytbaugmentfromanotherfile.networks.network.node.DefaultAugmentedNdNode;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.from.another.file.rev20160826.ytbaugmentfromanotherfile.networks.network.node.augmentedndnode.DefaultTerminationPoint;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.from.another.file.rev20160826.ytbaugmentfromanotherfile.networks.network.node.augmentedndnode.TerminationPoint;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.from.another.file.rev20160826.ytbaugmentfromanotherfile.networks.network.node.augmentedndnode.terminationpoint.DefaultSupportingTerminationPoint;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.from.another.file.rev20160826.ytbaugmentfromanotherfile.networks.network.node.augmentedndnode.terminationpoint.SupportingTerminationPoint;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput.activatesoftwareimage.output.AugmentedRpcOutput;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput.activatesoftwareimage.output.DefaultAugmentedRpcOutput;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput.activatesoftwareimage.output.augmentedrpcoutput.Selection;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput.activatesoftwareimage.output.augmentedrpcoutput.selection.DefaultValueIn;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput.activatesoftwareimage.output.augmentedrpcoutput.selection.valuein.ValueIn;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput2.activatesoftwareimage.output.AugmentedInputOutput;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput2.activatesoftwareimage.output.DefaultAugmentedInputOutput;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput2.activatesoftwareimage.output.augmentedinputoutput.DefaultFriction;
-import org.onosproject.yang.gen.v1.yms.test.ytb.augment.yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput2.activatesoftwareimage.output.augmentedinputoutput.Friction;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.yangautoprefixlist.rev20160826.YtbChoiceWithContainerAndLeafList;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.yangautoprefixlist.rev20160826.YtbChoiceWithContainerAndLeafListOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.yangautoprefixlist.rev20160826.ytbchoicewithcontainerandleaflist.ContentTest;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.yangautoprefixlist.rev20160826.ytbchoicewithcontainerandleaflist.CurrentValue;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.yangautoprefixlist.rev20160826.ytbchoicewithcontainerandleaflist.contenttest.DefaultChoiceContainer;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.yangautoprefixlist.rev20160826.ytbchoicewithcontainerandleaflist.contenttest.choicecontainer.ChoiceContainer;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.yangautoprefixlist.rev20160826.ytbchoicewithcontainerandleaflist.contenttest.choicecontainer.choicecontainer.DefaultPredict;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.yangautoprefixlist.rev20160826.ytbchoicewithcontainerandleaflist.contenttest.choicecontainer.choicecontainer.Predict;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.yangautoprefixlist.rev20160826.ytbchoicewithcontainerandleaflist.contenttest.choicecontainer.choicecontainer.predict.DefaultReproduce;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.yangautoprefixlist.rev20160826.ytbchoicewithcontainerandleaflist.contenttest.choicecontainer.choicecontainer.predict.Reproduce;
-import org.onosproject.yang.gen.v1.yms.test.ytb.choice.with.container.and.leaf.yangautoprefixlist.rev20160826.ytbchoicewithcontainerandleaflist.currentvalue.DefaultYtbAbsent;
-import org.onosproject.yang.gen.v1.yms.test.ytb.rpc.response.with.advanced.input.and.output.rev20160826.ytbrpcresponsewithadvancedinputandoutput.activatesoftwareimage.ActivateSoftwareImageOutput;
-import org.onosproject.yang.gen.v1.yms.test.ytb.rpc.response.with.advanced.input.and.output.rev20160826.ytbrpcresponsewithadvancedinputandoutput.activatesoftwareimage.DefaultActivateSoftwareImageOutput;
-import org.onosproject.yang.gen.v1.yms.test.ytb.rpc.response.with.advanced.input.and.output.rev20160826.ytbrpcresponsewithadvancedinputandoutput.activatesoftwareimage.activatesoftwareimageoutput.DefaultOutputList;
-import org.onosproject.yang.gen.v1.yms.test.ytb.rpc.response.with.advanced.input.and.output.rev20160826.ytbrpcresponsewithadvancedinputandoutput.activatesoftwareimage.activatesoftwareimageoutput.OutputList;
-import org.onosproject.yang.gen.v1.yms.test.ytb.rpc.response.with.advanced.input.and.output.rev20160826.ytbrpcresponsewithadvancedinputandoutput.activatesoftwareimage.activatesoftwareimageoutput.outputlist.ContentInside;
-import org.onosproject.yang.gen.v1.yms.test.ytb.rpc.response.with.advanced.input.and.output.rev20160826.ytbrpcresponsewithadvancedinputandoutput.activatesoftwareimage.activatesoftwareimageoutput.outputlist.DefaultContentInside;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.YtbSimpleAugment;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.YtbSimpleAugmentOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.ytbsimpleaugment.Cont1;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.ytbsimpleaugment.DefaultCont1;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.ytbsimpleaugment.cont1.DefaultCont2;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.ytbsimpleaugment.cont1.cont2.AugmentedCont2;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.ytbsimpleaugment.cont1.cont2.DefaultAugmentedCont2;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.ytbsimpleaugment.cont1.cont2.augmentedcont2.Cont1s;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826.ytbsimpleaugment.cont1.cont2.augmentedcont2.DefaultCont1s;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.choice.yangautoprefixcase.rev20160826.YtbSimpleChoiceCase;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.choice.yangautoprefixcase.rev20160826.YtbSimpleChoiceCaseOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.choice.yangautoprefixcase.rev20160826.ytbsimplechoicecase.DefaultYtbFood;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.choice.yangautoprefixcase.rev20160826.ytbsimplechoicecase.YtbFood;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.choice.yangautoprefixcase.rev20160826.ytbsimplechoicecase.ytbfood.YtbSnack;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.choice.yangautoprefixcase.rev20160826.ytbsimplechoicecase.ytbfood.ytbsnack.DefaultYtbLateNight;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.rpc.response.rev20160826.ytbsimplerpcresponse.rpc.DefaultRpcOutput;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.rpc.response.rev20160826.ytbsimplerpcresponse.rpc.RpcOutput;
-import org.onosproject.yms.app.ydt.YangRequestWorkBench;
-import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
-import org.onosproject.yms.app.ysr.DefaultYangSchemaRegistry;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REPLY;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_CONFIG_REPLY;
-import static org.onosproject.yms.ydt.YmsOperationType.RPC_REQUEST;
-
-/**
- * Unit test cases for YANG tree builder for context switch for augment, RPC
- * and case.
- */
-public class YtbContextSwitchTest extends YtbErrMsgAndConstants {
-
- private static final String RPC_ADV_NAME = "RPCAdvanced";
- private static final String RPC_ADV_NAMESPACE = "RPCAdvancedSpace";
- private static final String RPC_ADV_IO =
- "YtbRpcResponseWithAdvancedInputAndOutput";
- private static final String ACT_IMG = "activate-software-image";
- private static final String INPUT = "input";
- private static final String FINAL = "final";
- private static final String AUG_NW_REF_1 = "network-ref-aug1";
- private static final String AUG_NODE_REF_1 = "node-ref-aug1";
- private static final String AUG_TP_REF_1 = "tp-ref-aug-1";
- private static final String AUG_TP_ID_1 = "tp-id-aug-1";
- private static final String AUG_NW_REF_B1 = "network-ref-augb1";
- private static final String AUG_NODE_REF_B1 = "node-ref-augb1";
- private static final String AUG_TP_REF_B1 = "tp-ref-aug-b1";
- private static final String AUG_TP_ID_B1 = "tp-id-aug-1b";
- private static final String NW_REF = "network-ref";
- private static final String NODE_REF = "node-ref";
- private static final String NW_REF_2 = "network-ref2";
- private static final String NODE_REF_3 = "node-ref3";
- private static final String NW_REF_B = "network-ref-b";
- private static final String NODE_REF_B = "node-ref-b";
- private static final String NW_REF_2B = "network-ref2-b";
- private static final String NODE_REF_2B = "node-ref2-b";
- private static final String NODE_REF_3B = "node-ref3-b";
- private static final String CHOC = "choc";
- private static final String CHOICE_CASE = "YtbSimpleChoiceCase";
- private static final String FOOD = "YtbFood";
- private static final String CHOCOLATE = "chocolate";
- private static final String VAL = "val";
- private static final String IND = "ind";
- private static final String CHOICE_ROOT_NAME = "choiceContainerRootName";
- private static final String CHOICE_ROOT_NAMESPACE =
- "choiceContainerRootNamespace";
- private static final String CHOICE_CONT =
- "YtbChoiceWithContainerAndLeafList";
- private static final String CONT_CHOICE = "choice-container";
- private static final String REPRODUCE = "reproduce";
- private static final String NINETY = "90";
- private static final String HUNDRED = "100";
- private static final String RPC_RT_NAME = "rpcRootName";
- private static final String RPC_RT_NAMESPACE = "rpcRootNameSpace";
- private static final String OUTPUT_LEAF = "output-leaf";
- private static final String FIVE_HUNDRED = "500";
- private static final String OUTPUT_LIST = "output-list";
- private static final String LIST_KEY = "list-key";
- private static final String BIN_VAL_1 = "AAE=";
- private static final String CONT_INSIDE = "content_inside";
- private static final String BIN_VAL_2 = "CAk=";
- private static final String AVAILABLE = "available";
- private static final String EIGHTY_NINE = "89";
- private static final String NINETY_EIGHT = "98";
- private static final String BIN_VAL_3 = "AAA=";
- private static final String SIM_AUG = "simpleAugment";
- private static final String SIM_AUG_NAMESPACE = "simpleAugmentSpace";
- private static final String SIMPLE_AUG = "YtbSimpleAugment";
- private static final String CONT1 = "cont1";
- private static final String CONT2 = "cont2";
- private static final String LEAF4 = "leaf4";
- private static final String CONT1S = "cont1s";
- private static final String INTER_AUG = "inter-file-augment";
- private static final String INTER_AUG_NAMESPACE =
- "inter-file-augment-space";
- private static final String IETF_NW = "yms-ietf-network";
- private static final String NWS = "networks";
- private static final String NW = "network";
- private static final String NODE = "node";
- private static final String NODE_ID = "node-id";
- private static final String TERM_POINT = "termination-point";
- private static final String TP_ID = "tp-id";
- private static final String SUP_TERM_POINT = "supporting-termination-point";
- private static final String TP_REF = "tp-ref";
- private static final String SUP_NODE = "supporting-node";
- private static final String KIN1 = "kin1";
- private static final String KIN2 = "kin2";
-
- /**
- * Creates object as like an application for RPC with list.
- *
- * @return object of RPC
- */
- private List<OutputList> createApplicationBuiltObjectForRpc() {
-
- // Creates a empty container inside without leaf for list1.
- ContentInside inside1 = new DefaultContentInside.ContentInsideBuilder()
- .build();
-
- // Creates a leaf list-key which is a leaf ref.
- byte[] listKey1 = new byte[]{0, 1};
-
- // Creates the list content 1.
- OutputList output1 = new DefaultOutputList.OutputListBuilder()
- .listKey(listKey1).contentInside(inside1).build();
-
- // Creates a list of leaf for available.
- List<Short> avail = new ArrayList<>();
- avail.add((short) 89);
- avail.add((short) 98);
-
- // Adds the leaf list in the inside container.
- ContentInside inside2 = new DefaultContentInside.ContentInsideBuilder()
- .available(avail).build();
-
- // Creates a leaf, list-key which is a leaf ref.
- byte[] listKey2 = new byte[]{8, 9};
-
- // Creates the list content 2.
- OutputList outputList2 = new DefaultOutputList.OutputListBuilder()
- .listKey(listKey2).contentInside(inside2).build();
-
- // Creates only leaf, list-key which is a leaf ref.
- byte[] arr3 = new byte[]{0, 0};
-
- // Creates the list content 3.
- OutputList outputList3 = new DefaultOutputList.OutputListBuilder()
- .listKey(arr3).build();
-
- // Adds all the list contents in array list and gives returns it.
- List<OutputList> outputLists = new ArrayList<>();
- outputLists.add(output1);
- outputLists.add(outputList2);
- outputLists.add(outputList3);
- return outputLists;
- }
-
- /**
- * Builds YANG request work bench for RPC with container input.
- *
- * @param registry schema registry
- * @return YANG request work bench
- */
- private YangRequestWorkBench buildYangRequestWorkBenchForRpc(
- DefaultYangSchemaRegistry registry) {
-
- // Creates a request work bench and adds the input child into it.
- YangRequestWorkBench workBench = new YangRequestWorkBench(
- RPC_ADV_NAME, RPC_ADV_NAMESPACE, RPC_REQUEST,
- registry, true);
- Set<String> valueList = new HashSet<>();
- valueList.add("800");
- valueList.add("900");
- workBench.addChild(RPC_ADV_IO, null, NONE);
- workBench.addChild(ACT_IMG, null, NONE);
- workBench.addChild(INPUT, null, NONE);
- workBench.addChild(FINAL, null, NONE);
- workBench.addLeaf("value", null, valueList);
- return workBench;
- }
-
- /**
- * Creates an application object for inter file augment.
- *
- * @return application object
- */
- private Object createObjectForInterFileAugment() {
-
- // Creates leaf value for network-ref.
- Uri nwkRef = new Uri(AUG_NW_REF_1);
- NetworkId nwIdUri = new NetworkId(nwkRef);
- Uri nwkRef2 = new Uri("network-ref-aug2");
- NetworkId nwIdUri2 = new NetworkId(nwkRef2);
-
- // Creates leaf value for node-ref
- Uri nodeRef = new Uri(AUG_NODE_REF_1);
- NodeId nodeId = new NodeId(nodeRef);
-
- Uri nodeRef2 = new Uri("node-ref-aug2");
- NodeId nodeId2 = new NodeId(nodeRef2);
-
- // Creates support termination list with the above two contents.
- SupportingTerminationPoint point1 =
- new DefaultSupportingTerminationPoint
- .SupportingTerminationPointBuilder()
- .networkRef(nwIdUri).nodeRef(nodeId)
- .tpRef(AUG_TP_REF_1).build();
- SupportingTerminationPoint point2 =
- new DefaultSupportingTerminationPoint
- .SupportingTerminationPointBuilder()
- .networkRef(nwIdUri2).nodeRef(nodeId2)
- .tpRef("tp-ref-aug-2").build();
-
- List<SupportingTerminationPoint> pointList = new ArrayList<>();
- pointList.add(point1);
- pointList.add(point2);
-
- // Adds the list created to the termination point content1.
- TerminationPoint tPoint1 = new DefaultTerminationPoint
- .TerminationPointBuilder()
- .supportingTerminationPoint(pointList)
- .tpId(AUG_TP_ID_1).build();
-
- // Creates leaf value for network-ref.
- Uri nwkRef3 = new Uri(AUG_NW_REF_B1);
- NetworkId nwIdUri3 = new NetworkId(nwkRef3);
- Uri nwkRef4 = new Uri("network-ref-augb2");
- NetworkId nwIdUri4 = new NetworkId(nwkRef4);
-
- // Creates leaf value for node-ref
- Uri nodeRef3 = new Uri(AUG_NODE_REF_B1);
- NodeId nodeId3 = new NodeId(nodeRef3);
-
- Uri nodeRef4 = new Uri("node-ref-augb2");
- NodeId nodeId4 = new NodeId(nodeRef4);
-
- // Creates support termination list with the above two contents.
- SupportingTerminationPoint point3 =
- new DefaultSupportingTerminationPoint
- .SupportingTerminationPointBuilder()
- .networkRef(nwIdUri3).nodeRef(nodeId3)
- .tpRef(AUG_TP_REF_B1).build();
- SupportingTerminationPoint point4 =
- new DefaultSupportingTerminationPoint
- .SupportingTerminationPointBuilder()
- .networkRef(nwIdUri4).nodeRef(nodeId4)
- .tpRef("tp-ref-aug-b2").build();
-
- List<SupportingTerminationPoint> pointList2 = new ArrayList<>();
- pointList2.add(point3);
- pointList2.add(point4);
-
- // Adds the list created to the termination point content2.
- TerminationPoint tPoint2 = new DefaultTerminationPoint
- .TerminationPointBuilder()
- .supportingTerminationPoint(pointList2)
- .tpId(AUG_TP_ID_B1).build();
-
- List<TerminationPoint> terminationPointList = new ArrayList<>();
- terminationPointList.add(tPoint1);
- terminationPointList.add(tPoint2);
-
- // Adds all the above contents to the augment.
- AugmentedNdNode augment = new DefaultAugmentedNdNode
- .AugmentedNdNodeBuilder()
- .terminationPoint(terminationPointList)
- .build();
-
- // Creates leaf value for network-ref in augmented node(ietf-network).
- Uri nwRef5 = new Uri(NW_REF);
- NetworkId nwIdUri5 = new NetworkId(nwRef5);
-
- //Creates leaf value for node-ref in augmented node(ietf-network).
- Uri nodeRef5 = new Uri(NODE_REF);
- NodeId nodeId5 = new NodeId(nodeRef5);
-
- // Creates supporting node list content 1 with above contents.
- SupportingNode supNode1 = new DefaultSupportingNode
- .SupportingNodeBuilder().nodeRef(nodeId5)
- .networkRef(nwIdUri5).build();
-
- // Creates leaf value for network-ref in augmented node(ietf-network).
- Uri nwRef6 = new Uri(NW_REF_2);
- NetworkId nwIdUri6 = new NetworkId(nwRef6);
-
- //Creates leaf value for node-ref in augmented node(ietf-network).
- Uri nodeRef6 = new Uri("node-ref2");
- NodeId nodeId6 = new NodeId(nodeRef6);
-
- // Creates supporting node list content 2 with above contents.
- SupportingNode supNode2 = new DefaultSupportingNode
- .SupportingNodeBuilder()
- .nodeRef(nodeId6)
- .networkRef(nwIdUri6).build();
-
- List<SupportingNode> supNodeList = new ArrayList<>();
- supNodeList.add(supNode1);
- supNodeList.add(supNode2);
-
- // Creates leaf value for node-id in augmented node(ietf-network).
- Uri nodeId1 = new Uri(NODE_REF_3);
- NodeId nodeIdForId = new NodeId(nodeId1);
-
- // Creates node list with content 1 by adding augment also.
- DefaultNode.NodeBuilder nodeBuilder = new DefaultNode.NodeBuilder();
- nodeBuilder.addYangAugmentedInfo(
- augment, AugmentedNdNode.class);
- nodeBuilder.supportingNode(supNodeList);
- nodeBuilder.nodeId(nodeIdForId);
- Node node1 = nodeBuilder.build();
-
- // Creates an augment node without any values set to it.
- AugmentedNdNode augmentedNdNode2 = new DefaultAugmentedNdNode
- .AugmentedNdNodeBuilder().build();
-
- // Creates leaf value for network-ref in augmented node(ietf-network).
- Uri nwRef7 = new Uri(NW_REF_B);
- NetworkId nwIdUri7 = new NetworkId(nwRef7);
- //Creates leaf value for node-ref in augmented node(ietf-network).
- Uri nodeRef7 = new Uri(NODE_REF_B);
- NodeId nodeId7 = new NodeId(nodeRef7);
-
- // Creates supporting node list content 1 with above contents.
- SupportingNode supNode3 = new DefaultSupportingNode
- .SupportingNodeBuilder().nodeRef(nodeId7)
- .networkRef(nwIdUri7).build();
-
- // Creates leaf value for network-ref in augmented node(ietf-network).
- Uri nwRef8 = new Uri(NW_REF_2B);
- NetworkId nwIdUri8 = new NetworkId(nwRef8);
-
- //Creates leaf value for node-ref in augmented node(ietf-network).
- Uri nodeRef8 = new Uri(NODE_REF_2B);
- NodeId nodeId8 = new NodeId(nodeRef8);
-
- // Creates supporting node list content 1 with above contents.
- SupportingNode supNode4 = new DefaultSupportingNode
- .SupportingNodeBuilder()
- .nodeRef(nodeId8)
- .networkRef(nwIdUri8).build();
-
- List<SupportingNode> supNodeList2 = new ArrayList<>();
- supNodeList2.add(supNode3);
- supNodeList2.add(supNode4);
-
- // Creates leaf value for node-id in augmented node(ietf-network).
- Uri nodeIdLeaf = new Uri(NODE_REF_3B);
- NodeId nodeIdForId2 = new NodeId(nodeIdLeaf);
-
- // Creates node list with content 2 by adding empty augment also.
- DefaultNode.NodeBuilder nodeBuilder2 = new DefaultNode.NodeBuilder();
- nodeBuilder2.addYangAugmentedInfo(
- augmentedNdNode2, AugmentedNdNode.class);
- nodeBuilder2.supportingNode(supNodeList2);
- nodeBuilder2.nodeId(nodeIdForId2);
- Node node2 = nodeBuilder2.build();
-
- // Adds both nodes into the list.
- List<Node> nodeList = new LinkedList<>();
- nodeList.add(node1);
- nodeList.add(node2);
-
- // Adds the list into the network list.
- Network nwkList = new DefaultNetwork.NetworkBuilder()
- .node(nodeList).build();
-
- List<Network> networkList = new ArrayList<>();
- networkList.add(nwkList);
-
- // Adds the network list into networks container.
- Networks contNetworks = new DefaultNetworks.NetworksBuilder()
- .network(networkList).build();
-
- // Adds the container into the module.
- YmsIetfNetwork opParam = new YmsIetfNetworkOpParam
- .YmsIetfNetworkBuilder()
- .networks(contNetworks).build();
- return opParam;
- }
-
- /**
- * Processes a simple choice case and builds the YDT.
- */
- @Test
- public void processSimpleChoiceCase() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates a choice snack with the case late night.
- YtbSnack lateNight = new DefaultYtbLateNight.YtbLateNightBuilder()
- .chocolate(CHOC).build();
-
- // Creates container food with the created case.
- YtbFood food = new DefaultYtbFood.YtbFoodBuilder()
- .ytbSnack(lateNight).build();
-
- // Creates module with the container food.
- YtbSimpleChoiceCase choiceCase = new YtbSimpleChoiceCaseOpParam
- .YtbSimpleChoiceCaseBuilder().ytbFood(food).build();
-
- // As YSB or YAB protocol, sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(choiceCase);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REPLY, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext rootNode = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = rootNode.getFirstChild();
- assertThat(getInCrtName(MODULE, CHOICE_CASE), module.getName(),
- is(CHOICE_CASE));
-
- // Gets the container food from module.
- YdtContext container = module.getFirstChild();
- assertThat(getInCrtName(CONTAINER, FOOD), container.getName(),
- is(FOOD));
-
- // Gets the case-leaf from container
- YdtContext caseNode = container.getFirstChild();
- assertThat(getInCrtName(LEAF, CHOCOLATE), caseNode.getName(),
- is(CHOCOLATE));
- assertThat(getInCrtLeafValue(CHOCOLATE, CHOC), caseNode.getValue(),
- is(CHOC));
- }
-
- /**
- * Processes module with two choices and a choice having node and a
- * leaf-list.
- */
- @Test
- public void processChoiceWithNodeAndLeafList() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates reproduce container for list predict-1.
- Reproduce reproduce1 = new DefaultReproduce.ReproduceBuilder()
- .yangAutoPrefixCatch((short) 90).build();
-
- // Assigns predict-1 with the container.
- Predict predict1 = new DefaultPredict.PredictBuilder()
- .reproduce(reproduce1).build();
-
- // Creates reproduce container for list predict-2.
- Reproduce reproduce2 = new DefaultReproduce.ReproduceBuilder()
- .yangAutoPrefixCatch((short) 100).build();
-
- // Assigns predict-2 with the container.
- Predict predict2 = new DefaultPredict.PredictBuilder()
- .reproduce(reproduce2).build();
-
- List<Predict> predictList = new ArrayList<>();
- predictList.add(predict1);
- predictList.add(predict2);
-
- // Case container is added to the choice content-test.
- ChoiceContainer containerCase = new org.onosproject.yang.gen.v1.yms
- .test.ytb.choice.with.container.and.leaf.yangautoprefixlist
- .rev20160826.ytbchoicewithcontainerandleaflist.contenttest
- .choicecontainer.DefaultChoiceContainer.ChoiceContainerBuilder()
- .predict(predictList).build();
-
- // Case container is added to the choice content-test.
- ContentTest contentTest = new DefaultChoiceContainer
- .ChoiceContainerBuilder().choiceContainer(containerCase).build();
-
- // Creates string list for leaf-list final.
- List<String> stringList = new ArrayList<>();
- stringList.add(VAL);
- stringList.add(IND);
-
- // For choice current value, the leaf list gets added as case.
- CurrentValue currentValue = new DefaultYtbAbsent.YtbAbsentBuilder()
- .yangAutoPrefixFinal(stringList).build();
-
- // Adds choice as child to the module.
- YtbChoiceWithContainerAndLeafList choiceWithContainerAndLeafList =
- new YtbChoiceWithContainerAndLeafListOpParam
- .YtbChoiceWithContainerAndLeafListBuilder()
- .contentTest(contentTest).currentValue(currentValue)
- .build();
-
- // As YSB or YAB protocol, sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(choiceWithContainerAndLeafList);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, CHOICE_ROOT_NAME, CHOICE_ROOT_NAMESPACE,
- QUERY_CONFIG_REPLY, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, CHOICE_CONT), module.getName(),
- is(CHOICE_CONT));
-
- // Gets the first choice content under the module, as container.
- YdtContext choice1 = module.getFirstChild();
- assertThat(getInCrtName(CONTAINER, CONT_CHOICE), choice1.getName(),
- is(CONT_CHOICE));
-
- // Gets the first content in the list predict.
- YdtContext list1 = choice1.getFirstChild();
- assertThat(getInCrtName(LIST, PREDICT), list1.getName(), is(PREDICT));
-
- // Gets the container and its child leaf in the list predict.
- YdtContext container1 = list1.getFirstChild();
- assertThat(getInCrtName(CONTAINER, REPRODUCE), container1.getName(),
- is(REPRODUCE));
- YdtContext leaf1 = container1.getFirstChild();
- assertThat(getInCrtName(LEAF, CATCH), leaf1.getName(), is(CATCH));
- assertThat(getInCrtLeafValue(CATCH, NINETY), leaf1.getValue(),
- is(NINETY));
-
- // Gets the second content in the list predict.
- YdtContext list2 = list1.getNextSibling();
- assertThat(getInCrtName(LIST, PREDICT), list2.getName(), is(PREDICT));
-
- // Gets the container and its child leaf in the list predict.
- YdtContext container2 = list2.getFirstChild();
- assertThat(getInCrtName(CONTAINER, REPRODUCE), container2.getName(),
- is(REPRODUCE));
- YdtContext leaf2 = container2.getFirstChild();
- assertThat(getInCrtName(LEAF, CATCH), leaf2.getName(), is(CATCH));
- assertThat(getInCrtLeafValue(CATCH, HUNDRED), leaf2.getValue(),
- is(HUNDRED));
-
- // Gets the second choice content under the module, as leaf-list.
- YdtContext choice2 = choice1.getNextSibling();
- assertThat(getInCrtName(LEAF_LIST, FINAL), choice2.getName(),
- is(FINAL));
- Set value2 = choice2.getValueSet();
- assertThat(getInCrtLeafListValue(FINAL, VAL), value2.contains(VAL),
- is(true));
- assertThat(getInCrtLeafListValue(FINAL, IND), value2.contains(IND),
- is(true));
- }
-
- /**
- * Processes RPC response of a simple output with only a leaf content
- * inside.
- */
- @Test
- public void processSimpleRpcResponse() {
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
- RpcOutput output = new DefaultRpcOutput.RpcOutputBuilder()
- .outputLeaf(500).build();
-
- // Creates request work bench of rpc.
- YangRequestWorkBench workBench = new YangRequestWorkBench(
- RPC_RT_NAME, RPC_RT_NAMESPACE, RPC_REQUEST, registry, true);
- workBench.addChild(RPC_NAME, null, NONE);
- workBench.addChild(RPC, null, NONE);
- workBench.addChild(INPUT, null, NONE);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtForRpcResponse(
- output, workBench);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, RPC_NAME), module.getName(),
- is(RPC_NAME));
-
- // Gets the rpc node from the module.
- YdtContext rpc = module.getFirstChild();
- assertThat(getInCrtName(RPC, RPC), rpc.getName(), is(RPC));
-
- // Gets the output node from the module.
- // TODO: Change assert after YANG utils is merged.
- YdtContext rpcOutput = rpc.getFirstChild();
- //assertThat(rpcOutputNode.getName(), is("output"));
-
- YdtContext outputLeaf = rpcOutput.getFirstChild();
- assertThat(getInCrtName(LEAF, OUTPUT_LEAF), outputLeaf.getName(),
- is(OUTPUT_LEAF));
- assertThat(getInCrtLeafValue(OUTPUT_LEAF, FIVE_HUNDRED),
- outputLeaf.getValue(), is(FIVE_HUNDRED));
- }
-
- /**
- * Processes RPC response of an output defined with list.
- */
- @Test
- public void processRpcResponseForAdvInputOutput() {
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
- List<OutputList> list = createApplicationBuiltObjectForRpc();
- ActivateSoftwareImageOutput output =
- new DefaultActivateSoftwareImageOutput
- .ActivateSoftwareImageOutputBuilder()
- .outputList(list).build();
-
- // Creates request work bench of rpc.
- YangRequestWorkBench workBench = buildYangRequestWorkBenchForRpc(
- registry);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtForRpcResponse(
- output, workBench);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, RPC_ADV_IO), module.getName(),
- is(RPC_ADV_IO));
-
- // Gets the rpc node from module.
- YdtContext rpc = module.getFirstChild();
- assertThat(getInCrtName(RPC, ACT_IMG), rpc.getName(), is(ACT_IMG));
-
- // Gets the output node from the module.
- // TODO: Change assert after YANG utils is merged.
- YdtContext rpcOutput = rpc.getFirstChild();
- //assertThat(rpcOutputNode.getName(), is("output"));
-
- // Gets the list content 1 as the node from output.
- YdtContext outputList1 = rpcOutput.getFirstChild();
- assertThat(getInCrtName(LIST, OUTPUT_LIST), outputList1.getName(),
- is(OUTPUT_LIST));
-
- // Gets the leaf key-list from list content1.
- YdtContext keyList1 = outputList1.getFirstChild();
- assertThat(getInCrtName(LEAF, LIST_KEY), keyList1.getName(),
- is(LIST_KEY));
- assertThat(getInCrtLeafValue(LIST_KEY, BIN_VAL_1), keyList1.getValue(),
- is(BIN_VAL_1));
-
- // Gets the content inside container from list content 1.
- YdtContext cont1 = keyList1.getNextSibling();
- assertThat(getInCrtName(CONTAINER, CONT_INSIDE), cont1.getName(),
- is(CONT_INSIDE));
-
- // Gets the list content 2 as the node from output.
- YdtContext outputList2 = outputList1.getNextSibling();
- assertThat(getInCrtName(LIST, OUTPUT_LIST), outputList2.getName(),
- is(OUTPUT_LIST));
-
- // Gets the leaf-list key-list from list content2.
- YdtContext keyList2 = outputList2.getFirstChild();
- assertThat(getInCrtName(LEAF, LIST_KEY), keyList2.getName(),
- is(LIST_KEY));
- assertThat(getInCrtLeafValue(LIST_KEY, BIN_VAL_2), keyList2.getValue(),
- is(BIN_VAL_2));
-
- // Gets the content inside container from list content 2.
- YdtContext cont2 = keyList2.getNextSibling();
- assertThat(getInCrtName(CONTAINER, CONT_INSIDE), cont2.getName(),
- is(CONT_INSIDE));
-
- // Gets the leaf-list available inside container.
- YdtContext availLeafList = cont2.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, AVAILABLE), availLeafList.getName(),
- is(AVAILABLE));
- Set value1 = availLeafList.getValueSet();
- assertThat(getInCrtLeafListValue(AVAILABLE, EIGHTY_NINE),
- value1.contains(EIGHTY_NINE), is(true));
- assertThat(getInCrtLeafListValue(AVAILABLE, NINETY_EIGHT),
- value1.contains(NINETY_EIGHT), is(true));
-
- // Gets the list content 3.
- YdtContext outputList3 = outputList2.getNextSibling();
- assertThat(getInCrtName(LIST, OUTPUT_LIST), outputList3.getName(),
- is(OUTPUT_LIST));
-
- // Gets the leaf list-key in content 3 of list.
- YdtContext keyList3 = outputList3.getFirstChild();
- assertThat(getInCrtName(LEAF, LIST_KEY), keyList3.getName(),
- is(LIST_KEY));
- assertThat(getInCrtLeafValue(LIST_KEY, BIN_VAL_3), keyList3.getValue(),
- is(BIN_VAL_3));
- }
-
- /**
- * Processes simple self augment file with leaf and container inside
- * augment.
- */
- @Test
- public void processSimpleAugment() {
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates container cont1s with the leaf.
- org.onosproject.yang.gen.v1.yms.test.ytb.simple.augment.rev20160826
- .ytbsimpleaugment.cont1.cont2.augmentedcont2.cont1s
- .Cont1s cont1s1 = new org.onosproject.yang.gen.v1.yms.test
- .ytb.simple.augment.rev20160826.ytbsimpleaugment.cont1.cont2
- .augmentedcont2.cont1s.DefaultCont1s.Cont1sBuilder().build();
-
- // Appends the created container into another container.
- Cont1s cont1s = new DefaultCont1s.Cont1sBuilder()
- .cont1s(cont1s1).build();
-
- // Creates augment with the container and leaf.
- AugmentedCont2 augment = new DefaultAugmentedCont2
- .AugmentedCont2Builder().cont1s(cont1s).leaf4(500).build();
-
- // Creates for the node which will be getting augmented.
- // Creates cont2 where content will be augmented into.
- DefaultCont2.Cont2Builder augCont2 = new DefaultCont2
- .Cont2Builder();
- augCont2.addYangAugmentedInfo(augment, AugmentedCont2.class);
-
- // Creates cont1 where cont2 is added.
- Cont1 cont1 = new DefaultCont1.Cont1Builder()
- .cont2(augCont2.build()).build();
-
- // Creates module with the nodes inside.
- YtbSimpleAugment simpleAugment = new YtbSimpleAugmentOpParam
- .YtbSimpleAugmentBuilder().cont1(cont1).build();
-
- // As YSB or YAB protocol, sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(simpleAugment);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, SIM_AUG, SIM_AUG_NAMESPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, SIMPLE_AUG), module.getName(),
- is(SIMPLE_AUG));
-
- // Gets the cont1 under module.
- YdtContext container1 = module.getFirstChild();
- assertThat(getInCrtName(CONTAINER, CONT1), container1.getName(),
- is(CONT1));
-
- // Gets the cont2 under cont1.
- YdtContext container2 = container1.getFirstChild();
- assertThat(getInCrtName(CONTAINER, CONT2), container2.getName(),
- is(CONT2));
-
- // Gets the leaf4 which was augmented under cont2.
- YdtContext leaf4 = container2.getFirstChild();
- assertThat(getInCrtName(LEAF, LEAF4), leaf4.getName(), is(LEAF4));
- assertThat(getInCrtLeafValue(LEAF4, FIVE_HUNDRED), leaf4.getValue(),
- is(FIVE_HUNDRED));
-
- // Gets the cont1s which was augmented under cont2.
- YdtContext container1s = leaf4.getNextSibling();
- assertThat(getInCrtName(CONTAINER, CONT1S), container1s.getName(),
- is(CONT1S));
-
- // Gets the cont2s which was augmented under cont1s.
- YdtContext container2s = container1s.getFirstChild();
- assertThat(getInCrtName(CONTAINER, CONT1S), container2s.getName(),
- is(CONT1S));
- }
-
- /**
- * Processes inter file augment with augmented node as list and the
- * augment having list.
- */
- @Test
- public void processInterFileAugment() {
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
- Object opParam = createObjectForInterFileAugment();
-
- // As YSB or YAB protocol, sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(opParam);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, INTER_AUG, INTER_AUG_NAMESPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Checks the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, IETF_NW), module.getName(),
- is(IETF_NW));
-
- // Checks the container networks from module.
- YdtContext nwksCont = module.getFirstChild();
- assertThat(getInCrtName(CONTAINER, NWS), nwksCont.getName(), is(NWS));
-
- // Checks the list network from container networks.
- YdtContext nwrkList = nwksCont.getFirstChild();
- assertThat(getInCrtName(LIST, NW), nwrkList.getName(), is(NW));
-
- // Checks the node list content 1 under network list.
- YdtContext node1 = nwrkList.getFirstChild();
- assertThat(getInCrtName(LIST, NODE), node1.getName(), is(NODE));
-
- // Checks the node-id leaf for list content 1.
- YdtContext nodeId1 = node1.getFirstChild();
- assertThat(getInCrtName(LEAF, NODE_ID), nodeId1.getName(), is(NODE_ID));
- assertThat(getInCrtLeafValue(NODE_ID, NODE_REF_3), nodeId1.getValue(),
- is(NODE_REF_3));
-
- // Checks termination list 1 under node 1, from augment.
- YdtContext terList1 = nodeId1.getNextSibling();
- assertThat(getInCrtName(LIST, TERM_POINT), terList1.getName(),
- is(TERM_POINT));
-
- // Checks tp-id leaf from termination list content 1.
- YdtContext tpId1 = terList1.getFirstChild();
- assertThat(getInCrtName(LEAF, TP_ID), tpId1.getName(), is(TP_ID));
- assertThat(getInCrtLeafValue(TP_ID, AUG_TP_ID_1), tpId1.getValue(),
- is(AUG_TP_ID_1));
-
- // Checks supporting term point list content1 from term list content 1.
- YdtContext supTerm1 = tpId1.getNextSibling();
- assertThat(getInCrtName(LIST, SUP_TERM_POINT), supTerm1.getName(),
- is(SUP_TERM_POINT));
-
- YdtContext nwkRefSupTerm1 = supTerm1.getFirstChild();
- assertThat(getInCrtName(LEAF, NW_REF), nwkRefSupTerm1.getName(),
- is(NW_REF));
- assertThat(getInCrtLeafValue(NW_REF, AUG_NW_REF_1),
- nwkRefSupTerm1.getValue(), is(AUG_NW_REF_1));
-
- YdtContext nodeRefSupTerm1 = nwkRefSupTerm1.getNextSibling();
- assertThat(getInCrtName(LEAF, NODE_REF), nodeRefSupTerm1.getName(),
- is(NODE_REF));
- assertThat(getInCrtLeafValue(NODE_REF, AUG_NODE_REF_1),
- nodeRefSupTerm1.getValue(), is(AUG_NODE_REF_1));
-
- YdtContext tpRefSupTerm1 = nodeRefSupTerm1.getNextSibling();
- assertThat(getInCrtName(LEAF, TP_REF), tpRefSupTerm1.getName(),
- is(TP_REF));
- assertThat(getInCrtLeafValue(TP_REF, AUG_TP_REF_1),
- tpRefSupTerm1.getValue(), is(AUG_TP_REF_1));
-
- // Checks termination list 2 under node 1, from augment.
- YdtContext terminationList2 = terList1.getNextSibling();
- assertThat(getInCrtName(LIST, TERM_POINT), terminationList2.getName(),
- is(TERM_POINT));
-
- YdtContext terList2 = terminationList2.getFirstChild();
- assertThat(getInCrtName(LEAF, TP_ID), terList2.getName(), is(TP_ID));
- assertThat(getInCrtLeafValue(TP_ID, AUG_TP_ID_B1), terList2.getValue(),
- is(AUG_TP_ID_B1));
-
- // Checks supporting term point list content1 from term list content 2.
- YdtContext supTerm2 = terList2.getNextSibling();
- assertThat(getInCrtName(LIST, SUP_TERM_POINT), supTerm2.getName(),
- is(SUP_TERM_POINT));
-
- YdtContext nwkRefSupTerm2 = supTerm2.getFirstChild();
- assertThat(getInCrtName(LEAF, NW_REF), nwkRefSupTerm2.getName(),
- is(NW_REF));
- assertThat(getInCrtLeafValue(NW_REF, AUG_NW_REF_B1),
- nwkRefSupTerm2.getValue(), is(AUG_NW_REF_B1));
-
- YdtContext nodeRefSupTerm2 = nwkRefSupTerm2.getNextSibling();
- assertThat(getInCrtName(LEAF, NODE_REF), nodeRefSupTerm2.getName(),
- is(NODE_REF));
- assertThat(getInCrtLeafValue(NODE_REF, AUG_NODE_REF_B1),
- nodeRefSupTerm2.getValue(), is(AUG_NODE_REF_B1));
-
- YdtContext tpRefSupTerm2 = nodeRefSupTerm2.getNextSibling();
- assertThat(getInCrtName(LEAF, TP_REF), tpRefSupTerm2.getName(),
- is(TP_REF));
- assertThat(getInCrtLeafValue(TP_REF, AUG_TP_REF_B1),
- tpRefSupTerm2.getValue(), is(AUG_TP_REF_B1));
-
- // Checks the content of the supporting node list content 1 in node 1.
- YdtContext supNode1 = terminationList2.getNextSibling();
- assertThat(getInCrtName(LIST, SUP_NODE), supNode1.getName(),
- is(SUP_NODE));
-
- YdtContext nwkRefSupNode1 = supNode1.getFirstChild();
- assertThat(getInCrtName(LEAF, NW_REF), nwkRefSupNode1.getName(),
- is(NW_REF));
- assertThat(getInCrtLeafValue(NW_REF, NW_REF), nwkRefSupNode1.getValue(),
- is(NW_REF));
-
- YdtContext nodeRefSupNode1 = nwkRefSupNode1.getNextSibling();
- assertThat(getInCrtName(LEAF, NODE_REF), nodeRefSupNode1.getName(),
- is(NODE_REF));
- assertThat(getInCrtLeafValue(NODE_REF, NW_REF),
- nwkRefSupNode1.getValue(), is(NW_REF));
-
- // Checks the content of the supporting node list content 2 in node 1.
- YdtContext supNode2 = supNode1.getNextSibling();
- assertThat(getInCrtName(LIST, SUP_NODE), supNode2.getName(),
- is(SUP_NODE));
-
- YdtContext nwkRefSupNode2 = supNode2.getFirstChild();
- assertThat(getInCrtName(LEAF, NW_REF), nwkRefSupNode2.getName(),
- is(NW_REF));
- assertThat(getInCrtLeafValue(NW_REF, NW_REF_2),
- nwkRefSupNode2.getValue(), is(NW_REF_2));
-
- YdtContext nodeRefSupNode2 = nwkRefSupNode2.getNextSibling();
- assertThat(getInCrtName(LEAF, NODE_REF), nodeRefSupNode2.getName(),
- is(NODE_REF));
- assertThat(getInCrtLeafValue(NODE_REF, NW_REF_2),
- nwkRefSupNode2.getValue(), is(NW_REF_2));
-
- // Checks the node list content 2 under network list.
- YdtContext node2 = node1.getNextSibling();
- assertThat(getInCrtName(LIST, NODE), node2.getName(), is(NODE));
-
- // Checks the node-id leaf for list content 2.
- YdtContext nodeId2 = node2.getFirstChild();
- assertThat(getInCrtName(LEAF, NODE_ID), nodeId2.getName(), is(NODE_ID));
- assertThat(getInCrtLeafValue(NODE_ID, NODE_REF_3B), nodeId2.getValue(),
- is(NODE_REF_3B));
-
- // Checks supporting term point list content1 from term list content 2.
- YdtContext supNode3 = nodeId2.getNextSibling();
- assertThat(getInCrtName(LIST, SUP_NODE), supNode3.getName(),
- is(SUP_NODE));
-
- YdtContext nwkRefSupNode3 = supNode3.getFirstChild();
- assertThat(getInCrtName(LEAF, NW_REF), nwkRefSupNode3.getName(),
- is(NW_REF));
- assertThat(getInCrtLeafValue(NW_REF, NW_REF_B),
- nwkRefSupNode3.getValue(), is(NW_REF_B));
-
- YdtContext nodeRefSupNode3 = nwkRefSupNode3.getNextSibling();
- assertThat(getInCrtName(LEAF, NODE_REF), nodeRefSupNode3.getName(),
- is(NODE_REF));
- assertThat(getInCrtLeafValue(NODE_REF, NODE_REF_B),
- nodeRefSupNode3.getValue(), is(NODE_REF_B));
-
- // Checks supporting term point list content2 from term list content 2.
- YdtContext supNode4 = supNode3.getNextSibling();
- assertThat(getInCrtName(LIST, SUP_NODE), supNode4.getName(),
- is(SUP_NODE));
-
- YdtContext nwkRefSupNode4 = supNode4.getFirstChild();
- assertThat(getInCrtName(LEAF, NW_REF), nwkRefSupNode4.getName(),
- is(NW_REF));
- assertThat(getInCrtLeafValue(NW_REF, NW_REF_2B),
- nwkRefSupNode4.getValue(), is(NW_REF_2B));
-
- YdtContext nodeRefSupNode4 = nwkRefSupNode4.getNextSibling();
- assertThat(getInCrtName(LEAF, NODE_REF), nodeRefSupNode4.getName(),
- is(NODE_REF));
- assertThat(getInCrtLeafValue(NODE_REF, NODE_REF_2B),
- nodeRefSupNode4.getValue(), is(NODE_REF_2B));
- }
-
- /**
- * Processes inter file augment with rpc output as its target node.
- */
- @Test
- public void processInterFileAugmentWithRpcInputAsTarget() {
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // Builds RPC request tree in YDT.
- YangRequestWorkBench workBench =
- buildYangRequestWorkBenchForRpc(registry);
-
- // Creates augment code object.
-
- // Creates the list of value in, case value in.
- ValueIn valuein1 = new org.onosproject.yang.gen.v1.yms.test.ytb.augment
- .yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput
- .activatesoftwareimage.output.augmentedrpcoutput.selection
- .valuein.DefaultValueIn.ValueInBuilder().kinetic(KIN1)
- .build();
- ValueIn valuein2 = new org.onosproject.yang.gen.v1.yms.test.ytb.augment
- .yangautoprefixfor.rpc.input.rev20160826.ytbaugmentforrpcinput
- .activatesoftwareimage.output.augmentedrpcoutput.selection
- .valuein.DefaultValueIn.ValueInBuilder().kinetic(KIN2)
- .build();
-
- List<ValueIn> valueInList = new ArrayList<>();
- valueInList.add(valuein1);
- valueInList.add(valuein2);
-
- // Adds the case value into the choice interface.
- Selection selection = new DefaultValueIn.ValueInBuilder()
- .valueIn(valueInList).build();
-
- // Augment is created for the object.
- AugmentedRpcOutput augmentRpcOutput = new DefaultAugmentedRpcOutput
- .AugmentedRpcOutputBuilder().selection(selection).build();
-
- // Create two list object of friction.
- Friction friction1 = new DefaultFriction.FrictionBuilder()
- .speed(BigInteger.valueOf(500)).build();
- Friction friction2 = new DefaultFriction.FrictionBuilder()
- .speed(BigInteger.valueOf(1000)).build();
-
- List<Friction> fricList = new ArrayList<>();
- fricList.add(friction1);
- fricList.add(friction2);
-
- // Create augment with the friction object created.
- AugmentedInputOutput augmentedIO = new DefaultAugmentedInputOutput
- .AugmentedInputOutputBuilder().friction(fricList).build();
-
- // Creates RPC object.
- List<OutputList> outputLists = createApplicationBuiltObjectForRpc();
-
- // Adds the augment and the rps output values into the output.
- DefaultActivateSoftwareImageOutput
- .ActivateSoftwareImageOutputBuilder output =
- new DefaultActivateSoftwareImageOutput
- .ActivateSoftwareImageOutputBuilder();
- output.addYangAugmentedInfo(augmentRpcOutput, AugmentedRpcOutput.class);
- output.addYangAugmentedInfo(augmentedIO, AugmentedInputOutput.class);
- output.outputList(outputLists);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtForRpcResponse(
- output, workBench);
-
- // Receives YDT context and check the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Checks the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, RPC_ADV_IO), module.getName(),
- is(RPC_ADV_IO));
-
- // Gets the rpc under module.
- YdtContext rpc = module.getFirstChild();
- assertThat(getInCrtName(RPC, ACT_IMG), rpc.getName(), is(ACT_IMG));
-
- // Gets the output value under rpc.
- // TODO: Change assert after YANG utils is merged.
- YdtContext rpcOutputNode = rpc.getFirstChild();
- //assertThat(rpcOutputNode.getName(), is("output"));
-
- YdtContext firstNode = rpcOutputNode.getFirstChild();
- assertThat(firstNode, notNullValue());
-
- YdtContext secondNode = firstNode.getNextSibling();
- assertThat(secondNode, notNullValue());
-
- YdtContext thirdNode = secondNode.getNextSibling();
- assertThat(thirdNode, notNullValue());
-
- YdtContext fourthNode = thirdNode.getNextSibling();
- assertThat(fourthNode, notNullValue());
-
- // Gets the list content 1 as the node from output.
- YdtContext outputList1 = fourthNode.getNextSibling();
- assertThat(getInCrtName(LIST, OUTPUT_LIST), outputList1.getName(),
- is(OUTPUT_LIST));
-
- // Gets the leaf key-list from list content1.
- YdtContext keyList1 = outputList1.getFirstChild();
- assertThat(getInCrtName(LEAF, LIST_KEY), keyList1.getName(),
- is(LIST_KEY));
- assertThat(getInCrtLeafValue(LIST_KEY, BIN_VAL_1), keyList1.getValue(),
- is(BIN_VAL_1));
-
- // Gets the content inside container from list content 1.
- YdtContext cont1 = keyList1.getNextSibling();
- assertThat(getInCrtName(CONTAINER, CONT_INSIDE), cont1.getName(),
- is(CONT_INSIDE));
-
- // Gets the list content 2 as the node from output.
- YdtContext outputList2 = outputList1.getNextSibling();
- assertThat(getInCrtName(LIST, OUTPUT_LIST), outputList2.getName(),
- is(OUTPUT_LIST));
-
- // Gets the leaf-list key-list from list content2.
- YdtContext keyList2 = outputList2.getFirstChild();
- assertThat(getInCrtName(LEAF, LIST_KEY), keyList2.getName(),
- is(LIST_KEY));
- assertThat(getInCrtLeafValue(LIST_KEY, BIN_VAL_2), keyList2.getValue(),
- is(BIN_VAL_2));
-
- // Gets the content inside container from list content 2.
- YdtContext cont2 = keyList2.getNextSibling();
- assertThat(getInCrtName(CONTAINER, CONT_INSIDE), cont2.getName(),
- is(CONT_INSIDE));
-
- // Gets the leaf-list available inside container.
- YdtContext availLeafList = cont2.getFirstChild();
- assertThat(getInCrtName(LEAF_LIST, AVAILABLE), availLeafList.getName(),
- is(AVAILABLE));
- Set value1 = availLeafList.getValueSet();
- assertThat(getInCrtLeafListValue(AVAILABLE, EIGHTY_NINE),
- value1.contains(EIGHTY_NINE), is(true));
- assertThat(getInCrtLeafListValue(AVAILABLE, NINETY_EIGHT),
- value1.contains(NINETY_EIGHT), is(true));
-
- // Gets the list content 3.
- YdtContext outputList3 = outputList2.getNextSibling();
- assertThat(getInCrtName(LIST, OUTPUT_LIST), outputList3.getName(),
- is(OUTPUT_LIST));
-
- // Gets the leaf list-key in content 3 of list.
- YdtContext keyList3 = outputList3.getFirstChild();
- assertThat(getInCrtName(LEAF, LIST_KEY), keyList3.getName(),
- is(LIST_KEY));
- assertThat(getInCrtLeafValue(LIST_KEY, BIN_VAL_3), keyList3.getValue(),
- is(BIN_VAL_3));
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ytb/YtbErrMsgAndConstants.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ytb/YtbErrMsgAndConstants.java
deleted file mode 100644
index 7b82454..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ytb/YtbErrMsgAndConstants.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ytb;
-
-import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider;
-
-/**
- * Represents the abstract class for ytb test classes having common methods
- * and the constants.
- */
-public abstract class YtbErrMsgAndConstants {
-
- /**
- * Static attribute of root name.
- */
- public static final String ROOT_NAME = "rootName";
-
- /**
- * Static attribute of root name space.
- */
- public static final String ROOT_NAME_SPACE = "rootNameSpace";
-
- /**
- * Static attribute of module which is YANG name.
- */
- public static final String MODULE = "module";
-
- /**
- * Static attribute of list which is YANG name.
- */
- public static final String LIST = "list";
-
- /**
- * Static attribute of leaf which is YANG name.
- */
- public static final String LEAF = "leaf";
-
- /**
- * Static attribute of leaf-list which is YANG name.
- */
- public static final String LEAF_LIST = "leaf-list";
-
- /**
- * Static attribute of container which is YANG name.
- */
- public static final String CONTAINER = "container";
-
- /**
- * Static attribute of name predict.
- */
- public static final String PREDICT = "predict";
-
- /**
- * Static attribute of name catch.
- */
- public static final String CATCH = "catch";
-
- /**
- * Static attribute of YANG file name.
- */
- public static final String RPC_NAME = "YtbSimpleRpcResponse";
-
- /**
- * Static attribute of name rpc.
- */
- public static final String RPC = "rpc";
- public static final String HUNDRED = "hundred";
- /**
- * Created a schema node provider, which will register the app.
- */
- public TestYangSchemaNodeProvider schemaProvider =
- new TestYangSchemaNodeProvider();
-
- /**
- * Returns the error message for when leaf value doesn't match with the
- * expected value. It takes name of leaf and expected value as its
- * parameter, to throw the message.
- *
- * @param name leaf name
- * @param value expected value of leaf
- * @return error message of leaf value as incorrect
- */
- public static String getInCrtLeafValue(String name, String value) {
- return "The value of leaf " + name + " is not " + value;
- }
-
- /**
- * Returns the error message, when node name doesn't match with the
- * expected value. It takes YANG name of the node and the node name as
- * parameter, to throw the message.
- *
- * @param node YANG node name
- * @param nodeName node name
- * @return error message as the node name is incorrect
- */
- public static String getInCrtName(String node, String nodeName) {
- return getCapitalCase(node) + "'s name " + nodeName + " is incorrect.";
- }
-
- /**
- * Returns the error message, when operation type doesn't match with the
- * expected value. It takes YANG name of the node and the node name as
- * parameter, to throw the message.
- *
- * @param node YANG node name
- * @param nodeName node name
- * @return error message as the operation type is incorrect
- */
- public static String getInCrtOpType(String node, String nodeName) {
- return "The operation type of " + node + " " + nodeName + " is " +
- "incorrect";
- }
-
- /**
- * Returns the error message for when leaf-list value doesn't match with the
- * expected value. It takes name of leaf-list and expected value as its
- * parameter, to throw the message.
- *
- * @param name leaf-list name
- * @param value value in leaf-list
- * @return error message as the value in the leaf-list is incorrect
- */
- public static String getInCrtLeafListValue(String name, String value) {
- return "The leaf-list " + name + " does not have " + value + " in it.";
- }
-
- /**
- * Returns the capital cased first letter of the given string.
- *
- * @param name string to be capital cased
- * @return capital cased string
- */
- private static String getCapitalCase(String name) {
- return name.substring(0, 1).toUpperCase() + name.substring(1);
- }
-}
diff --git a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ytb/YtbInvalidNodeSkipTest.java b/apps/yms/ut/src/test/java/org/onosproject/yms/app/ytb/YtbInvalidNodeSkipTest.java
deleted file mode 100644
index 42da150..0000000
--- a/apps/yms/ut/src/test/java/org/onosproject/yms/app/ytb/YtbInvalidNodeSkipTest.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yms.app.ytb;
-
-import org.junit.Test;
-import org.onosproject.yang.gen.v1.yms.test.ytb.data.type.rev20160826.YtbDataType;
-import org.onosproject.yang.gen.v1.yms.test.ytb.data.type.rev20160826.YtbDataTypeOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.data.type.rev20160826.ytbdatatype.EnumDer1;
-import org.onosproject.yang.gen.v1.yms.test.ytb.data.type.rev20160826.ytbdatatype.EnumDer2;
-import org.onosproject.yang.gen.v1.yms.test.ytb.data.type.rev20160826.ytbdatatype.EnumLeafListUnion;
-import org.onosproject.yang.gen.v1.yms.test.ytb.data.type.rev20160826.ytbdatatype.UnionEnumUnion;
-import org.onosproject.yang.gen.v1.yms.test.ytb.data.type.rev20160826.ytbdatatype.enumder2.EnumDer2Enum;
-import org.onosproject.yang.gen.v1.yms.test.ytb.data.type.rev20160826.ytbdatatype.enumleaflistunion.EnumLeafListUnionEnum1;
-import org.onosproject.yang.gen.v1.yms.test.ytb.empty.type.rev20160826.YtbEmptyType;
-import org.onosproject.yang.gen.v1.yms.test.ytb.empty.type.rev20160826.YtbEmptyTypeOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.empty.type.rev20160826.ytbemptytype.EmpType;
-import org.onosproject.yang.gen.v1.yms.test.ytb.empty.type.rev20160826.ytbemptytype.EmpType2;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.rpc.response.rev20160826.YtbSimpleRpcResponse;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.rpc.response.rev20160826.YtbSimpleRpcResponseOpParam;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.rpc.response.rev20160826.ytbsimplerpcresponse.Cumulative;
-import org.onosproject.yang.gen.v1.yms.test.ytb.simple.rpc.response.rev20160826.ytbsimplerpcresponse.DefaultCumulative;
-import org.onosproject.yms.app.ydt.YdtExtendedBuilder;
-import org.onosproject.yms.app.ysr.DefaultYangSchemaRegistry;
-import org.onosproject.yms.ydt.YdtContext;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNull.nullValue;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REQUEST;
-
-/**
- * Unit test cases for invalid node skip in YANG tree builder.
- */
-public class YtbInvalidNodeSkipTest extends YtbErrMsgAndConstants {
-
- private static final String CUMULATIVE = "cumulative";
- private static final String SUM = "sum";
- private static final String FIVE = "5";
- private static final String TEN_NUM = "10";
- private static final String DATA_TYPE = "YtbDataType";
- private static final String ENUM = "enum";
- private static final String EMPTY = "empty";
- private static final String THOUSAND = "thousand";
- private static final String TEN = "ten";
- private static final String ENUM_LEAF_LIST = "enum-leaf-list";
- private static final String UNION_ENUM = "union-enum";
- private static final String ENUM_LEAF_REF = "leaf-ref-enum";
- private static final String EMPTY_MOD = "YtbEmptyType";
- private static final String EMPTY_REF_LIST = "empty-list-ref";
- private static final String EMPTY_TYPE = "empty-type";
- private static final String EMP_LIST_REF_TYPE = "empty-list-ref-type";
-
- /**
- * Processes RPC node which is the sibling to the empty current node.
- */
- @Test
- public void processRpcSiblingWhenNodeIsEmpty() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
- Cumulative cumulative1 = new DefaultCumulative.CumulativeBuilder()
- .sum((byte) 5).build();
- Cumulative cumulative2 = new DefaultCumulative.CumulativeBuilder()
- .sum((byte) 10).build();
- List<Cumulative> list = new ArrayList<>();
- list.add(cumulative1);
- list.add(cumulative2);
- YtbSimpleRpcResponse rpc = new YtbSimpleRpcResponseOpParam
- .YtbSimpleRpcResponseBuilder().cumulative(list).build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(rpc);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and checks the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, RPC_NAME), module.getName(),
- is(RPC_NAME));
-
- // Gets the first list content of cumulative.
- YdtContext list1 = module.getFirstChild();
- assertThat(getInCrtName(LIST, CUMULATIVE), list1.getName(),
- is(CUMULATIVE));
-
- YdtContext sum1 = list1.getFirstChild();
- assertThat(getInCrtName(LEAF, SUM), sum1.getName(), is(SUM));
- assertThat(getInCrtLeafValue(SUM, FIVE), sum1.getValue(), is(FIVE));
-
- // Gets the second list content of cumulative.
- YdtContext list2 = list1.getNextSibling();
- assertThat(getInCrtName(LIST, CUMULATIVE), list2.getName(),
- is(CUMULATIVE));
-
- YdtContext sum2 = list2.getFirstChild();
- assertThat(getInCrtName(LEAF, SUM), sum2.getName(), is(SUM));
- assertThat(getInCrtLeafValue(SUM, TEN_NUM), sum2.getValue(), is(TEN_NUM));
- }
-
- @Test
- public void processEnumDataType() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // Creates the enum hundred for leaf enum.
- EnumDer2 der2 = new EnumDer2(EnumDer2Enum.HUNDRED);
- EnumDer1 der1 = new EnumDer1(der2);
-
- // Creates the enum hundred and ten for leaf-list having union.
- EnumLeafListUnion union1 = new EnumLeafListUnion(EnumLeafListUnionEnum1
- .HUNDRED);
- EnumLeafListUnion union2 = new EnumLeafListUnion(EnumLeafListUnionEnum1
- .TEN);
-
- List<EnumLeafListUnion> leafList = new ArrayList<>();
- leafList.add(union1);
- leafList.add(union2);
-
- // Creates a leaf having typedef in union, where as the typedef is enum.
- UnionEnumUnion enumUnion = new UnionEnumUnion(der1);
-
- // Creates a leaf-list with leaf-ref pointing to leaf with enum.
- EnumDer2 enum2 = new EnumDer2(EnumDer2Enum.THOUSAND);
- EnumDer1 enum1 = new EnumDer1(enum2);
- EnumDer2 enum4 = new EnumDer2(EnumDer2Enum.HUNDRED);
- EnumDer1 enum3 = new EnumDer1(enum4);
-
- List<EnumDer1> enumDer1 = new ArrayList<>();
- enumDer1.add(enum1);
- enumDer1.add(enum3);
-
- YtbDataType dataType = new YtbDataTypeOpParam.YtbDataTypeBuilder()
- .yangAutoPrefixEnum(der1).enumLeafList(leafList)
- .unionEnum(enumUnion).leafRefEnum(enumDer1).build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(dataType);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and checks the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, DATA_TYPE), module.getName(),
- is(DATA_TYPE));
-
- // Gets the first list content of cumulative.
- YdtContext leafEnum = module.getFirstChild();
- assertThat(getInCrtName(LEAF, ENUM), leafEnum.getName(), is(ENUM));
- assertThat(getInCrtLeafValue(ENUM, HUNDRED), leafEnum.getValue(),
- is(HUNDRED));
-
- YdtContext unionEnum = leafEnum.getNextSibling();
- assertThat(getInCrtName(LEAF_LIST, UNION_ENUM), unionEnum.getName(),
- is(UNION_ENUM));
- assertThat(getInCrtLeafValue(UNION_ENUM, HUNDRED), unionEnum.getValue(),
- is(HUNDRED));
-
- YdtContext leafListEnum = unionEnum.getNextSibling();
- Set leafListVal = leafListEnum.getValueSet();
- assertThat(getInCrtName(LEAF_LIST, ENUM_LEAF_LIST),
- leafListEnum.getName(), is(ENUM_LEAF_LIST));
- assertThat(getInCrtLeafListValue(ENUM_LEAF_LIST, HUNDRED),
- leafListVal.contains(HUNDRED), is(true));
- assertThat(getInCrtLeafListValue(ENUM_LEAF_LIST, TEN_NUM),
- leafListVal.contains(TEN), is(true));
-
- YdtContext leafRef = leafListEnum.getNextSibling();
- Set leafRefVal = leafRef.getValueSet();
- assertThat(getInCrtName(LEAF_LIST, ENUM_LEAF_REF), leafRef.getName(),
- is(ENUM_LEAF_REF));
- assertThat(getInCrtLeafListValue(ENUM_LEAF_REF, HUNDRED),
- leafRefVal.contains(HUNDRED), is(true));
- assertThat(getInCrtLeafListValue(ENUM_LEAF_REF, TEN_NUM),
- leafRefVal.contains(THOUSAND), is(true));
- }
-
- @Test
- public void processEmptyDataType() {
-
- schemaProvider.processSchemaRegistry(null);
- DefaultYangSchemaRegistry registry = schemaProvider
- .getDefaultYangSchemaRegistry();
-
- // As an application, creates the object.
-
- // For leaf-list empty-list.
- List<Boolean> empList = new ArrayList<>();
- empList.add(false);
- empList.add(true);
-
- // For leaf-list empty-list-ref-type and emp-ref-list.
- List<Boolean> empRefList = new ArrayList<>();
- empRefList.add(true);
- empRefList.add(false);
-
- // For leaf empty-type with typedef emp-type
- EmpType2 type2 = new EmpType2(true);
- EmpType type1 = new EmpType(type2);
-
- // For leaf-list empty-list-type with typedef emp-type
- EmpType2 type4 = new EmpType2(false);
- EmpType type3 = new EmpType(type4);
- EmpType2 type6 = new EmpType2(true);
- EmpType type5 = new EmpType(type6);
-
- List<EmpType> typeList = new ArrayList<>();
- typeList.add(type3);
- typeList.add(type5);
-
- YtbEmptyType emType = new YtbEmptyTypeOpParam.YtbEmptyTypeBuilder()
- .empty(true).emptyList(empList).emptyRef(false)
- .emptyListRef(empRefList).emptyType(type1)
- .emptyListType(typeList).emptyRefType(false)
- .emptyListRefType(empRefList).build();
-
- // As YSB or YAB protocol sets the value for YTB.
- List<Object> objectList = new ArrayList<>();
- objectList.add(emType);
-
- // Builds YANG tree in YTB.
- DefaultYangTreeBuilder treeBuilder = new DefaultYangTreeBuilder();
- YdtExtendedBuilder ydtBuilder = treeBuilder.getYdtBuilderForYo(
- objectList, ROOT_NAME, ROOT_NAME_SPACE,
- EDIT_CONFIG_REQUEST, registry);
-
- // Receives YDT context and checks the tree that is built.
- YdtContext context = ydtBuilder.getRootNode();
-
- // Gets the first module from logical root node.
- YdtContext module = context.getFirstChild();
- assertThat(getInCrtName(MODULE, EMPTY_MOD), module.getName(),
- is(EMPTY_MOD));
-
- // Gets the first list content of cumulative.
- YdtContext empty = module.getFirstChild();
- assertThat(getInCrtName(LEAF, EMPTY), empty.getName(), is(EMPTY));
- assertThat(empty.getValue(), nullValue());
-
- YdtContext emptyType = empty.getNextSibling();
- assertThat(getInCrtName(LEAF_LIST, EMPTY_TYPE), emptyType.getName(),
- is(EMPTY_TYPE));
- assertThat(emptyType.getValue(), nullValue());
-
- YdtContext emptyRefList = emptyType.getNextSibling();
- assertThat(getInCrtName(LEAF_LIST, EMPTY_REF_LIST),
- emptyRefList.getName(), is(EMPTY_REF_LIST));
- Set valueSet = emptyRefList.getValueSet();
- assertThat(valueSet.isEmpty(), is(true));
-
- YdtContext emptyListRefType = emptyRefList.getNextSibling();
- assertThat(getInCrtName(LEAF_LIST, EMP_LIST_REF_TYPE),
- emptyListRefType.getName(), is(EMP_LIST_REF_TYPE));
- Set valueSet1 = emptyListRefType.getValueSet();
- assertThat(valueSet1.isEmpty(), is(true));
- }
-}
diff --git a/apps/yms/ut/src/test/resources/YobTestYangFiles/ip-topology.yang b/apps/yms/ut/src/test/resources/YobTestYangFiles/ip-topology.yang
deleted file mode 100644
index ca117b7..0000000
--- a/apps/yms/ut/src/test/resources/YobTestYangFiles/ip-topology.yang
+++ /dev/null
@@ -1,29 +0,0 @@
-
-module yms-ip-topology {
- yang-version 1;
- namespace urn:ip:topo;
- prefix ip-topo;
- import yms-topology {
- prefix topo;
- revision-date "2014-01-01";
- }
- revision 2014-01-01 {
- description "desc";
- reference "ref";
- }
-
- augment /topo:node{
- leaf router-id {
- type string;
- }
- leaf router-ip {
- type string;
- }
- }
-
- augment /topo:node/topo:termination-points/topo:termination-point {
- leaf ip-address {
- type string;
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/YobTestYangFiles/topology.yang b/apps/yms/ut/src/test/resources/YobTestYangFiles/topology.yang
deleted file mode 100644
index 62c0279..0000000
--- a/apps/yms/ut/src/test/resources/YobTestYangFiles/topology.yang
+++ /dev/null
@@ -1,74 +0,0 @@
-
-module yms-topology {
- yang-version 1;
- namespace urn:topo;
- prefix topo;
- revision 2014-01-01 {
- description "desc";
- reference "ref";
- }
- list node {
- key "node-id";
- leaf node-id{
- type string;
- }
- leaf-list node-prop{
- type string;
- }
- container termination-points{
- leaf number-of-tp {
- type int16;
- }
- list termination-point {
- key "tp-id";
- leaf tp-id {
- type string;
- }
- }
- }
- choice choice1{
- case case1a{
- leaf leaf1a1{
- type string;
- }
- leaf leaf1a2{
- type string;
- }
- }
- case case1b{
- choice choice1b{
- case case1bi{
- leaf leaf1bia{
- type string;
- }
- leaf leaf1bib{
- type string;
- }
- }
- case case1bii{
- leaf leaf1biia{
- type string;
- }
- leaf leaf1biib{
- type string;
- }
- }
- }
- }
- }
- }
-
- rpc set-node-limit {
- input {
- leaf node-limit {
- type int16;
- }
- }
- }
-
- notification node-limit-reached {
- leaf node-limit {
- type int16;
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/yabTestYangFiles/test.yang b/apps/yms/ut/src/test/resources/yabTestYangFiles/test.yang
deleted file mode 100644
index e37bed6..0000000
--- a/apps/yms/ut/src/test/resources/yabTestYangFiles/test.yang
+++ /dev/null
@@ -1,111 +0,0 @@
-module test {
-
- yang-version 1;
- namespace "ydt.test";
- prefix "t6";
- organization "ON-LAB";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- container cont1 {
- container cont2 {
- container cont3 {
- leaf leaf1 {
- type string;
- }
- }
- }
- list list1 {
- key leaf2;
- leaf leaf2 {
- type string;
- }
- leaf leaf3 {
- type string;
- }
- }
- leaf leaf4 {
- type string;
- }
- }
- list list2 {
- key "leaf5 leaf6";
- leaf leaf5 {
- type string;
- }
- leaf leaf6 {
- type string;
- }
- leaf leaf7 {
- type string;
- }
- leaf-list leaflist8 {
- type string;
- }
- container cont7 {
- leaf leaf12 {
- type string;
- }
- }
- }
- container cont4 {
- container cont5 {
- leaf leaf9 {
- type string;
- }
- }
- }
- leaf leaf10 {
- type string;
- }
-
- rpc rock-the-house {
- input {
- leaf zip-code {
- type string;
- }
- }
- output {
- leaf hello {
- type string;
- }
- }
- }
-
- rpc rock-the-house1 {
- input {
- leaf leaf13 {
- type string;
- }
- }
- }
-
- rpc rock-the-house2 {
- output {
- leaf leaf14 {
- type string;
- }
- }
- }
-
- rpc rock-the-house3 {
- }
-
- augment "/cont4" {
- container cont6 {
- leaf leaf11 {
- type string;
- }
- }
- }
-
- augment "/cont4/cont6" {
- container cont7 {
- leaf leaf12 {
- type string;
- }
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ychTestResourceFiles/Combined.yang b/apps/yms/ut/src/test/resources/ychTestResourceFiles/Combined.yang
deleted file mode 100644
index a9c2f48..0000000
--- a/apps/yms/ut/src/test/resources/ychTestResourceFiles/Combined.yang
+++ /dev/null
@@ -1,114 +0,0 @@
-module Combined {
-
- yang-version 1;
- namespace "ych:combined";
- prefix "combined";
-
- organization "Huawei India Pvt. Ltd.";
-
- description "This module defines for purchasing-supervisor.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- typedef protocol-version {
- type uint8 {
- range 1..7;
- }
- }
-
- typedef path-id {
- type uint32;
- default 0;
- description
- "Identifier of a single path. The identifier does not
- carry any semantic meaning beyond uniquely identifying
- a path.";
- }
-
- typedef as-num {
- type uint32;
- default 0;
- description
- "Identifier of a single path. The identifier does not
- carry any semantic meaning beyond uniquely identifying
- a path.";
- }
-
- typedef metric {
- type uint32;
- default 0;
- description
- "Identifier of a single path. The identifier does not
- carry any semantic meaning beyond uniquely identifying
- a path.";
- }
-
- container attributes {
- container origin {
- reference "http://tools.ietf.org/html/rfc4271#section-5.1.1";
- leaf value {
- type path-id;
- mandatory true;
- }
- }
- container multi-exit-disc {
- reference "http://tools.ietf.org/html/rfc4271#section-5.1.4";
- leaf med {
- type uint32;
- }
- }
- container local-pref {
- reference "http://tools.ietf.org/html/rfc4271#section-5.1.5";
- leaf pref {
- type uint32;
- }
- }
- container aigp {
- container aigp-tlv {
- leaf metric {
- type metric;
- }
- }
- }
-
- list unrecognized-attributes {
- key type;
- leaf partial {
- type boolean;
- mandatory true;
- }
- leaf transitive {
- type boolean;
- mandatory true;
- }
- leaf type {
- type uint8;
- mandatory true;
- }
- leaf value {
- type binary {
- length 0..65535;
- }
- mandatory true;
- }
- }
-
- list bgp-parameters {
- config false;
- list optional-capabilities {
- config false;
- reference "http://tools.ietf.org/html/rfc5492#section-4";
- container c-parameters {
- container as4-bytes-capability {
- reference "http://tools.ietf.org/html/rfc6793";
- leaf as-number {
- type as-num;
- }
- }
- }
- }
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ychTestResourceFiles/EmptyContainer.yang b/apps/yms/ut/src/test/resources/ychTestResourceFiles/EmptyContainer.yang
deleted file mode 100644
index 92106e9..0000000
--- a/apps/yms/ut/src/test/resources/ychTestResourceFiles/EmptyContainer.yang
+++ /dev/null
@@ -1,19 +0,0 @@
-module EmptyContainer {
-
- yang-version 1;
-
- namespace "ych.Empty.Container";
-
- prefix "purchasing";
-
- organization "ON-LAB";
-
- description "This module defines for purchasing-supervisor.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- container EmptyContainer {
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ychTestResourceFiles/combinedrootname.xml b/apps/yms/ut/src/test/resources/ychTestResourceFiles/combinedrootname.xml
deleted file mode 100644
index 04078f1..0000000
--- a/apps/yms/ut/src/test/resources/ychTestResourceFiles/combinedrootname.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-<rpc message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <edit-config>
- <target>
- <running/>
- </target>
- <filter xmlns="ydt.filter-type" type="subtree">
- <attributes xmlns="ych:combined">
- <origin>
- <value>123</value>
- </origin>
- <multi-exit-disc>
- <med>456</med>
- </multi-exit-disc>
- <local-pref>
- <pref>23</pref>
- </local-pref>
- <aigp>
- <aigp-tlv>
- <metric>456</metric>
- </aigp-tlv>
- </aigp>
- <unrecognized-attributes>
- <partial>false</partial>
- <transitive>false</transitive>
- <type>1</type>
- <value>QUJD</value>
- </unrecognized-attributes>
- <unrecognized-attributes>
- <partial>true</partial>
- <transitive>true</transitive>
- <type>2</type>
- <value>QUJD</value>
- </unrecognized-attributes>
- <unrecognized-attributes>
- <partial>true</partial>
- <transitive>false</transitive>
- <type>3</type>
- <value>QUJD</value>
- </unrecognized-attributes>
- <unrecognized-attributes>
- <partial>false</partial>
- <transitive>true</transitive>
- <type>4</type>
- <value>QUJD</value>
- </unrecognized-attributes>
- <bgp-parameters>
- <optional-capabilities>
- <c-parameters>
- <as4-bytes-capability>
- <as-number>11</as-number>
- </as4-bytes-capability>
- </c-parameters>
- </optional-capabilities>
- <optional-capabilities>
- <c-parameters>
- <as4-bytes-capability>
- <as-number>22</as-number>
- </as4-bytes-capability>
- </c-parameters>
- </optional-capabilities>
- <optional-capabilities>
- <c-parameters>
- <as4-bytes-capability>
- <as-number>33</as-number>
- </as4-bytes-capability>
- </c-parameters>
- </optional-capabilities>
- </bgp-parameters>
- <bgp-parameters>
- <optional-capabilities>
- <c-parameters>
- <as4-bytes-capability>
- <as-number>33</as-number>
- </as4-bytes-capability>
- </c-parameters>
- </optional-capabilities>
- <optional-capabilities>
- <c-parameters>
- <as4-bytes-capability>
- <as-number>33</as-number>
- </as4-bytes-capability>
- </c-parameters>
- </optional-capabilities>
- <optional-capabilities>
- <c-parameters>
- <as4-bytes-capability>
- <as-number>33</as-number>
- </as4-bytes-capability>
- </c-parameters>
- </optional-capabilities>
- </bgp-parameters>
- </attributes>
- </filter>
- </edit-config>
-</rpc>
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ychTestResourceFiles/configrootname.xml b/apps/yms/ut/src/test/resources/ychTestResourceFiles/configrootname.xml
deleted file mode 100644
index 64c25aa..0000000
--- a/apps/yms/ut/src/test/resources/ychTestResourceFiles/configrootname.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<rpc message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <edit-config>
- <target>
- <running/>
- </target>
- <config>
- <Customs-supervisor xmlns="ydt.root">abc</Customs-supervisor>
- <Purchasing-supervisor xmlns="ydt.root">
- <purchasing-specialist>bcd</purchasing-specialist>
- <support>cde</support>
- </Purchasing-supervisor>
- <supervisor xmlns="ydt.Merchandiser-supervisor">abc</supervisor>
- </config>
- </edit-config>
-</rpc>
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ychTestResourceFiles/configrootnameOperationType.xml b/apps/yms/ut/src/test/resources/ychTestResourceFiles/configrootnameOperationType.xml
deleted file mode 100644
index ce63205..0000000
--- a/apps/yms/ut/src/test/resources/ychTestResourceFiles/configrootnameOperationType.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<rpc message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <edit-config>
- <target>
- <running/>
- </target>
- <config>
- <Customs-supervisor xmlns="ydt.root">abc</Customs-supervisor>
- <Purchasing-supervisor xmlns="ydt.root" operation="delete">
- <purchasing-specialist>bcd</purchasing-specialist>
- <support>cde</support>
- </Purchasing-supervisor>
- <supervisor xmlns="ydt.Merchandiser-supervisor">abc</supervisor>
- </config>
- </edit-config>
-</rpc>
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ychTestResourceFiles/getReply.xml b/apps/yms/ut/src/test/resources/ychTestResourceFiles/getReply.xml
deleted file mode 100644
index 0b836d3..0000000
--- a/apps/yms/ut/src/test/resources/ychTestResourceFiles/getReply.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<rpc-reply message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
- xmlns:ex="http://example.net/content/1.0">
- <data>
- <Purchasing-supervisor xmlns="ydt.root">
- <purchasing-specialist>bcd</purchasing-specialist>
- </Purchasing-supervisor>
- </data>
-</rpc-reply>
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ychTestResourceFiles/getconfigReply.xml b/apps/yms/ut/src/test/resources/ychTestResourceFiles/getconfigReply.xml
deleted file mode 100644
index bf3fc7b..0000000
--- a/apps/yms/ut/src/test/resources/ychTestResourceFiles/getconfigReply.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<rpc message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <data>
- <supervisor xmlns="ydt.Merchandiser-supervisor">abc</supervisor>
- </data>
-</rpc>
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ychTestResourceFiles/getconfigemptycontainer.xml b/apps/yms/ut/src/test/resources/ychTestResourceFiles/getconfigemptycontainer.xml
deleted file mode 100644
index adc7902..0000000
--- a/apps/yms/ut/src/test/resources/ychTestResourceFiles/getconfigemptycontainer.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<rpc message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <get-config>
- <source>
- <running/>
- </source>
- <filter xmlns="ydt.filter-type" type="subtree">
- <EmptyContainer xmlns="ych.Empty.Container"/>
- </filter>
- </get-config>
-</rpc>
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ychTestResourceFiles/getconfigrootname.xml b/apps/yms/ut/src/test/resources/ychTestResourceFiles/getconfigrootname.xml
deleted file mode 100644
index 0c35df5..0000000
--- a/apps/yms/ut/src/test/resources/ychTestResourceFiles/getconfigrootname.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<rpc message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <get-config>
- <source>
- <running/>
- </source>
- <filter type="subtree">
- <supervisor xmlns="ydt.Merchandiser-supervisor">abc</supervisor>
- </filter>
- </get-config>
-</rpc>
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ychTestResourceFiles/getrootname.xml b/apps/yms/ut/src/test/resources/ychTestResourceFiles/getrootname.xml
deleted file mode 100644
index b7fc97d..0000000
--- a/apps/yms/ut/src/test/resources/ychTestResourceFiles/getrootname.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<rpc message-id="101"
- xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <get>
- <filter type="subtree">
- <Purchasing-supervisor xmlns="ydt.root">
- <purchasing-specialist>bcd</purchasing-specialist>
- </Purchasing-supervisor>
- </filter>
- </get>
-</rpc>
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ychTestResourceFiles/purchasingsupervisor.yang b/apps/yms/ut/src/test/resources/ychTestResourceFiles/purchasingsupervisor.yang
deleted file mode 100644
index 29123a8..0000000
--- a/apps/yms/ut/src/test/resources/ychTestResourceFiles/purchasingsupervisor.yang
+++ /dev/null
@@ -1,43 +0,0 @@
-module ych-purchasingsupervisor {
-
- yang-version 1;
-
- namespace "ych.purchasing-supervisor";
-
- prefix "purchasing";
-
- organization "ON-LAB";
-
- description "This module defines for purchasing-supervisor.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- container ych-purchasing-supervisor {
- leaf ych-purchasing-specialist {
- type string;
- description "name of the purchasing-specialist person";
- }
-
- leaf ych-purchasing-support {
- type string;
- description "name of the support person";
- }
-
- leaf ych-purchasing-options {
- type bits {
- bit "option0";
- bit "option1";
- bit "option2";
- bit "option3";
- }
- description
- "A bit mask that may have 0, 1, many or all options present";
- }
-
- container ych-is-manager {
- presence "If node is present denotes that supervisor is a manager";
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/EmptyLeafList.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/EmptyLeafList.yang
deleted file mode 100644
index b6174c7..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/EmptyLeafList.yang
+++ /dev/null
@@ -1,51 +0,0 @@
-module EmptyLeafList {
-
- yang-version 1;
-
- namespace "ydt.Empty.leafList";
-
- prefix "emptyleaflist";
-
- organization "ON-LAB";
-
- description "This module defines for empty leaf list.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- typedef type-def {
- type leafref {
- path /l1;
- }
- }
-
- leaf l1 {
- type empty;
- }
-
- leaf l2 {
- type leafref {
- path /l1;
- }
- }
-
- leaf l3 {
- type type-def;
- }
-
- leaf-list list1 {
- type empty;
- }
-
- leaf-list list2 {
- type leafref {
- path /l1;
- }
- }
-
- leaf-list list3 {
- type type-def;
- }
-
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/Hello_ONOS.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/Hello_ONOS.yang
deleted file mode 100644
index d5eafbe..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/Hello_ONOS.yang
+++ /dev/null
@@ -1,57 +0,0 @@
-module Hello_ONOS {
- yang-version 1;
- namespace "ydt:hello_onos";
- prefix "hello";
-
- revision "2016-09-03" {
- description "Initial revision of hello model";
- }
-
- grouping greeting {
- leaf name {
- type string;
- }
-
- leaf surName {
- type string;
- }
- }
-
- rpc hello-world {
- input {
-
- // uses greeting;
-
- leaf name {
- type string;
- }
-
- leaf surName {
- type string;
- }
-
- leaf inputDefault {
- type string;
- }
-
- list stringList {
- key "string1 string2";
- unique "string3";
- leaf string1 {
- type string;
- }
- leaf string2 {
- type string;
- }
- leaf string3 {
- type string;
- }
- }
- }
- output {
- leaf greetingOut {
- type string;
- }
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/Logistics-manager.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/Logistics-manager.yang
deleted file mode 100644
index 3cd4321..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/Logistics-manager.yang
+++ /dev/null
@@ -1,66 +0,0 @@
-module Logistics-manager {
-
- yang-version 1;
-
- namespace "ydt.root";
-
- prefix "root";
-
- organization "ON-LAB";
-
- description "This module defines for organisation.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- leaf Customs-supervisor {
- type string;
- description "name of the customs-supervisor.";
- }
-
- leaf Merchandiser-supervisor {
- type string;
- description "name of merchandiser-supervisor";
- }
-
- list Material-supervisor {
- key "name";
- leaf name {
- type string;
- description "name of logistics-supervisor";
- }
-
- leaf departmentId {
- type string;
- description "name of department";
- }
- }
-
- container Purchasing-supervisor {
- leaf purchasing-specialist {
- type string;
- description "name of the purchasing-specialist person";
- }
-
- leaf support {
- type string;
- description "name of the support person";
- }
- }
-
- leaf-list Warehouse-supervisor {
- type string;
- description "name of the warehouse-supervisor's";
- }
-
- leaf trading-supervisor {
- type string;
- description "name of the trading-supervisor";
- }
-
- leaf-list employee-id {
- type string;
- description "list of the employee id";
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology1.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology1.yang
deleted file mode 100644
index fc0eee5..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology1.yang
+++ /dev/null
@@ -1,66 +0,0 @@
-module augment-topology1 {
-
- yang-version 1;
-
- namespace "ydt.augment-topology1";
-
- prefix "aug1";
-
- import yms-ietf-network {
- prefix nd;
- }
-
- import yms-network-topology {
- prefix topo;
- }
-
- import augmentNetwork {
- prefix aug;
- }
-
- organization "ON-LAB";
-
- description "This module defines for augment-topology1 classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- augment "/nd:networks/nd:network/topo:link" {
- description
- "Add augment1 to the link model.";
- list augment1 {
- key "value1";
- leaf value1 {
- type int8;
- }
- }
- }
-
- augment "/nd:networks/nd:network/nd:node/topo:t-point" +
- "/supporting-termination-point" {
- description
- "Add augment1 to the termination-point model.";
- container augment1 {
- leaf value1 {
- type int8;
- }
- }
-
- leaf augment1-leaf {
- type string;
- }
-
- }
-
- augment "/aug:node/aug:cont1s/aug:cont1s" {
- description
- "Add augment1 to the link model.";
- list augment1 {
- key "value1";
- leaf value1 {
- type int8;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology2.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology2.yang
deleted file mode 100644
index 82a19d7..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology2.yang
+++ /dev/null
@@ -1,63 +0,0 @@
-module augment-topology2 {
-
- yang-version 1;
-
- namespace "ydt.augment-topology2";
-
- prefix "aug2";
-
- import yms-ietf-network {
- prefix nd;
- }
-
- import yms-network-topology {
- prefix topo;
- }
-
- organization "ON-LAB";
-
- description "This module defines for augment-topology2 classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- augment "/nd:networks/nd:network/topo:link" {
- description
- "Add augment2 to the link model.";
- list augment2 {
- key "key1 key2";
- leaf key1 {
- type int8;
- }
- leaf key2 {
- type int8;
- }
- }
-
- leaf-list augment2leafList {
- type string;
- }
- }
-
- augment "/nd:networks/nd:network/nd:node/topo:t-point/" +
- "supporting-termination-point" {
- description
- "Add augment2 to the supporting-termination-point model.";
- container augment2 {
- config false;
- leaf value2 {
- type int8;
- }
- }
-
- leaf-list augment2leafList {
- type string;
- }
-
- leaf augment2leaf {
- type string;
- }
-
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology3.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology3.yang
deleted file mode 100644
index d2c58ce..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology3.yang
+++ /dev/null
@@ -1,59 +0,0 @@
-module augment-topology3 {
-
- yang-version 1;
-
- namespace "ydt.augment-topology3";
-
- prefix "aug3";
-
- import yms-ietf-network {
- prefix nd;
- }
-
- import augment-topology1 {
- prefix aug1;
- }
-
- import augment-topology2 {
- prefix aug2;
- }
-
- import yms-network-topology {
- prefix topo;
- }
-
- organization "ON-LAB";
-
- description "This module defines for augment-topology3 classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- augment "/nd:networks/nd:network/topo:link/aug2:augment2" {
- description
- "Add augment3 to the augment2 model.";
- container augment3 {
- config false;
- leaf value3 {
- type int8;
- }
- }
-
- leaf augment3leaf {
- type string;
- }
- }
-
- augment "/nd:networks/nd:network/nd:node/topo:t-point/" +
- "supporting-termination-point/aug2:augment2" {
- description
- "Add augment3 to the augment2 model.";
- container augment3 {
- config false;
- leaf value3 {
- type int8;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology4.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology4.yang
deleted file mode 100644
index b8cea93..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology4.yang
+++ /dev/null
@@ -1,58 +0,0 @@
-module augment-topology4 {
-
- yang-version 1;
-
- namespace "ydt.augment-topology4";
-
- prefix "aug4";
-
- import yms-ietf-network {
- prefix nd;
- }
-
- import augment-topology1 {
- prefix aug1;
- }
-
- import augment-topology2 {
- prefix aug2;
- }
-
- import augment-topology3 {
- prefix aug3;
- }
-
- import yms-network-topology {
- prefix topo;
- }
-
- organization "ON-LAB";
-
- description "This module defines for augment-topology4 classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- augment "/nd:networks/nd:network/topo:link/aug2:augment2/aug3:augment3" {
- description
- "Add augment4 to the augment3 model.";
- container augment4 {
- config false;
- leaf value4 {
- type int8;
- }
- }
- }
-
- augment "/nd:networks/nd:network/nd:node/topo:t-point/" +
- "supporting-termination-point/aug2:augment2" {
- description
- "Add augment4leaf to the augment2 model.";
-
- leaf augment4leaf{
- type string;
- }
-
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology5.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology5.yang
deleted file mode 100644
index a13a688..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology5.yang
+++ /dev/null
@@ -1,66 +0,0 @@
-module augment-topology5 {
-
- yang-version 1;
-
- namespace "ydt.augment-topology5";
-
- prefix "aug5";
-
- import yms-ietf-network {
- prefix nd;
- }
-
- import augment-topology1 {
- prefix aug1;
- }
-
- import augment-topology2 {
- prefix aug2;
- }
-
- import augment-topology3 {
- prefix aug3;
- }
-
- import augment-topology4 {
- prefix aug4;
- }
-
- import yms-network-topology {
- prefix topo;
- }
-
- organization "ON-LAB";
-
- description "This module defines for augment-topology5 classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- augment "/nd:networks/nd:network/topo:link/aug2:augment2" {
- description
- "Add container to the augment2 model.";
- container augment5 {
- config false;
- leaf value5 {
- type int8;
- }
- }
-
- leaf-list augment5leafList {
- type string;
- }
- }
-
- augment "/nd:networks/nd:network/topo:link/aug2:augment2/aug3:augment3" {
- description
- "Add augment5 to the augment3 model.";
- container augment5 {
- config false;
- leaf value5 {
- type int8;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology6.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology6.yang
deleted file mode 100644
index 15bd3d5..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment-topology6.yang
+++ /dev/null
@@ -1,73 +0,0 @@
-module augment-topology6 {
-
- yang-version 1;
-
- namespace "ydt.augment-topology6";
-
- prefix "aug5";
-
- import yms-ietf-network {
- prefix nd;
- }
-
- import augment-topology1 {
- prefix aug1;
- }
-
- import augment-topology2 {
- prefix aug2;
- }
-
- import augment-topology3 {
- prefix aug3;
- }
-
- import augment-topology4 {
- prefix aug4;
- }
-
- import augment-topology5 {
- prefix aug5;
- }
-
- import yms-network-topology {
- prefix topo;
- }
-
- organization "ON-LAB";
-
- description "This module defines for augment-topology6 classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- augment "/nd:networks/nd:network/topo:link/aug2:augment2/aug3:augment3" {
- description
- "Add augment6 to the augment3 model.";
- container augment6 {
- config true;
- leaf value6 {
- type int8;
- }
- }
- }
-
- augment "/nd:networks/nd:network/topo:link/aug2:augment2/aug3:augment3/" +
- "aug5:augment5" {
- description
- "Add leaf6 to the augment5 model.";
- leaf leaf6 {
- type string;
- }
-
- }
-
- augment "/nd:networks/nd:network/topo:link/aug2:augment2/aug5:augment5" {
- description
- "Add list to the augment5 model.";
- leaf-list augment6leafList {
- type string;
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment2.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment2.yang
deleted file mode 100644
index 70d45c4..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augment2.yang
+++ /dev/null
@@ -1,32 +0,0 @@
-module augment2 {
-
- yang-version 1;
-
- namespace "ydt.augment2";
-
- prefix "aug";
-
- organization "ON-LAB";
-
- description "This module defines for augmentNetwork classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- container aug {
- container aug {
- leaf aug {
- type string;
- }
- }
- }
-
- augment "/aug:" {
- description
- "Add container to the augment2 model.";
- leaf aug1 {
- type string;
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augmentNetwork.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/augmentNetwork.yang
deleted file mode 100644
index a769a5e..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augmentNetwork.yang
+++ /dev/null
@@ -1,36 +0,0 @@
-module augmentNetwork {
-
- yang-version 1;
-
- namespace "ydt.augmentNetwork";
-
- prefix "aug";
-
- organization "ON-LAB";
-
- description "This module defines for augmentNetwork classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- list node {
- key "name";
- leaf name {
- type string;
- description "name of node";
- }
- }
-
- augment "/node" {
- description
- "Add container to the node model.";
- container cont1s {
- container cont1s {
- leaf fine {
- type string;
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augmentSequence.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/augmentSequence.yang
deleted file mode 100644
index aba3c17..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augmentSequence.yang
+++ /dev/null
@@ -1,23 +0,0 @@
-module augmentSequence {
-
- yang-version 1;
-
- namespace "ydt.augmentSequence";
-
- prefix "aug";
-
- organization "ON-LAB";
-
- description "This module defines for augmentSequence classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- list l1 {
- key leaf1;
- leaf leaf1 {
- type int8;
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augmentSequence1.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/augmentSequence1.yang
deleted file mode 100644
index adaf43f..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augmentSequence1.yang
+++ /dev/null
@@ -1,28 +0,0 @@
-module augmentSequence1 {
-
- yang-version 1;
-
- namespace "ydt.augmentSequence1";
-
- prefix "sequence1";
-
- import augmentSequence {
- prefix aug;
- }
-
- organization "ON-LAB";
-
- description "This module defines for augmentSequence1 classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- augment "/aug:l1" {
- container c1 {
- leaf leaf2 {
- type int8;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augmentSequence2.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/augmentSequence2.yang
deleted file mode 100644
index f32d508..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/augmentSequence2.yang
+++ /dev/null
@@ -1,28 +0,0 @@
-module augmentSequence2 {
-
- yang-version 1;
-
- namespace "ydt.augmentSequence2";
-
- prefix "sequence2";
-
- import augmentSequence {
- prefix aug;
- }
-
- organization "ON-LAB";
-
- description "This module defines for augmentSequence2 classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- augment "/aug:l1" {
- container c2 {
- leaf leaf2 {
- type int8;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/binarytest.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/binarytest.yang
deleted file mode 100644
index f6db459d..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/binarytest.yang
+++ /dev/null
@@ -1,74 +0,0 @@
-module binarytest {
-
- yang-version 1;
-
- namespace "ydt.binarytest";
-
- prefix "binarytest";
-
- organization "ON-LAB";
-
- description "This module defines for binarytest classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- list binaryList {
- config false;
- leaf binary {
- type binary;
- }
- leaf binaryWithRange {
- type binary {
- length "2 .. 10";
- }
- }
- leaf binaryWithMultiRange {
- type binary {
- length "min..10 | 20 | 30..max";
- }
- }
- }
-
- typedef percent {
- type binary;
- }
-
- leaf name {
- type percent;
- }
-
- grouping greeting {
- leaf surname {
- type binary;
- }
- }
-
- container cont1 {
- uses greeting;
- }
-
- augment "/cont1" {
- leaf lastname {
- type binary;
- }
- }
-
- container food {
- choice snack {
- case sportsarena {
- leaf pretzel {
- type binary;
- }
- }
- }
- }
-
- leaf middlename {
- type union {
- type int8;
- type binary;
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/bit.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/bit.yang
deleted file mode 100644
index 8b4f0c3..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/bit.yang
+++ /dev/null
@@ -1,107 +0,0 @@
-module bit {
-
- yang-version 1;
-
- namespace "ydt.bit";
-
- prefix "bit";
-
- organization "ON-LAB";
-
- description "This module defines for bit classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- list bitList {
- config false;
- leaf bit {
- type bits {
- bit disable-nagle {
- position 0;
- }
- bit auto-sense-speed {
- position 1;
- }
- bit ten-Mb-only {
- position 2;
- }
- }
- }
- }
-
- typedef percent {
- type bits {
- bit bit3 {
- position 3;
- }
- bit bit4 {
- position 4;
- }
- bit bit5 {
- position 5;
- }
- }
- }
-
- leaf name {
- type percent;
- }
-
- grouping greeting {
- leaf surname {
- type bits {
- bit bit6 {
- position 6;
- }
- bit bit7 {
- position 7;
- }
- bit bit8 {
- position 8;
- }
- }
- }
- }
-
- container cont1 {
- uses greeting;
- }
-
- augment "/cont1" {
- leaf lastname {
- type bits {
- bit bit9 {
- position 9;
- }
- bit bit10 {
- position 10;
- }
- bit bit11 {
- position 11;
- }
- }
- }
- }
-
- container food {
- choice snack {
- case sportsarena {
- leaf pretzel {
- type bits {
- bit bit12 {
- position 12;
- }
- bit bit13 {
- position 13;
- }
- bit bit14 {
- position 14;
- }
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/bool.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/bool.yang
deleted file mode 100644
index 1bb6181..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/bool.yang
+++ /dev/null
@@ -1,23 +0,0 @@
-module bool {
-
- yang-version 1;
-
- namespace "ydt.boolean";
-
- prefix "bool";
-
- organization "ON-LAB";
-
- description "This module defines for bool classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- list booleanList {
- key boolean;
- leaf boolean {
- type boolean;
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/crypto-base.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/crypto-base.yang
deleted file mode 100644
index 602b911..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/crypto-base.yang
+++ /dev/null
@@ -1,76 +0,0 @@
-module crypto-base {
-
- yang-version 1;
-
- namespace "ydt.crypto-base";
-
- prefix "crypto";
-
- organization "ON-LAB";
-
- description "This module defines for crypto-base classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- identity crypto-alg {
- description
- "Base identity from which all crypto algorithms
- are derived.";
- }
-
- identity crypto-alg2 {
- base crypto-alg;
- }
-
- identity crypto-alg3 {
- base crypto-alg2;
- }
-
- leaf crypto {
- type identityref {
- base "crypto-alg";
- }
- }
-
- typedef abc {
- type identityref {
- base "crypto-alg";
- }
- }
-
- leaf-list abc-type {
- type abc;
- }
-
- leaf abc-zeunion {
- type union {
- type identityref {
- base "crypto-alg";
- }
- type abc;
- }
- }
-
- leaf level2 {
- type identityref {
- base "crypto-alg2";
- }
- }
-
- leaf level3 {
- type identityref {
- base "crypto-alg3";
- }
- }
-
- leaf level4 {
- type union {
- type identityref {
- base "crypto-alg3";
- }
- type abc;
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/customssupervisor.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/customssupervisor.yang
deleted file mode 100644
index 73aa806..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/customssupervisor.yang
+++ /dev/null
@@ -1,21 +0,0 @@
-module customssupervisor {
-
- yang-version 1;
-
- namespace "ydt.customs-supervisor";
-
- prefix "customs";
-
- organization "ON-LAB";
-
- description "This module defines for customs-supervisor.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- leaf supervisor {
- type string;
- description "name of the customs-supervisor.";
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/decimal64.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/decimal64.yang
deleted file mode 100644
index 746c23e3..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/decimal64.yang
+++ /dev/null
@@ -1,95 +0,0 @@
-module decimal64 {
-
- yang-version 1;
-
- namespace "ydt.decimal64";
-
- prefix "decimal64";
-
- organization "ON-LAB";
-
- description "This module defines for decimal64 classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
- leaf negInt {
- type decimal64 {
- fraction-digits 2;
- }
- }
-
- leaf posInt {
- type decimal64 {
- fraction-digits 2;
- }
- }
-
- leaf negIntWithMinFraction {
- type decimal64 {
- fraction-digits 1;
- }
- }
-
- leaf posIntWithMinFraction {
- type decimal64 {
- fraction-digits 1;
- }
-
- }
- leaf negIntWithMaxFraction {
- type decimal64 {
- fraction-digits 18;
- }
- }
-
- leaf posIntWithMaxFraction {
- type decimal64 {
- fraction-digits 18;
- }
-
- }
-
- leaf midIntWithRange {
- type decimal64 {
- fraction-digits 2;
- range "10 .. 100";
- }
- }
-
- leaf minIntWithRange {
- type decimal64 {
- fraction-digits 2;
- range "10 .. 100";
- }
- }
-
- leaf maxIntWithRange {
- type decimal64 {
- fraction-digits 2;
- range "10 .. 100";
- }
- }
-
- list multiRangeValidation {
- config false;
- leaf decimal {
- type decimal64 {
- fraction-digits 2;
- range "10..40 | 50..100";
- }
- }
- leaf revDecimal {
- type decimal64 {
- fraction-digits 2;
- range "min .. 3.14 | 10 | 20..max";
- }
- }
- }
-
- leaf l1 {
- type decimal64 {
- fraction-digits 2;
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/employeeid.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/employeeid.yang
deleted file mode 100644
index be27c70..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/employeeid.yang
+++ /dev/null
@@ -1,21 +0,0 @@
-module employeeid {
-
- yang-version 1;
-
- namespace "ydt.employee-id";
-
- prefix "id";
-
- organization "ON-LAB";
-
- description "This module defines for employee-id.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- leaf-list employeeid {
- type string;
- description "list of the employee id";
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/emptydata.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/emptydata.yang
deleted file mode 100644
index 33f58b3..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/emptydata.yang
+++ /dev/null
@@ -1,23 +0,0 @@
-module emptydata {
-
- yang-version 1;
-
- namespace "ydt.emptydata";
-
- prefix "emptydata";
-
- organization "ON-LAB";
-
- description "This module defines for emptydata classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- list emptyList {
- config false;
- leaf empty {
- type empty;
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/enumtest.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/enumtest.yang
deleted file mode 100644
index a9255c5..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/enumtest.yang
+++ /dev/null
@@ -1,27 +0,0 @@
-module enumtest {
-
- yang-version 1;
-
- namespace "ydt.enumtest";
-
- prefix "enumtest";
-
- organization "ON-LAB";
-
- description "This module defines for enumtest classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- list enumList {
- key enumleaf;
- leaf enumleaf {
- type enumeration {
- enum ten { value "10";}
- enum hundred { value "100";}
- enum thousand { value "1000"; }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/food.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/food.yang
deleted file mode 100644
index 202d11f..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/food.yang
+++ /dev/null
@@ -1,39 +0,0 @@
-module food {
-
- yang-version 1;
-
- namespace "ydt.food";
-
- prefix "foodType";
-
- organization "ON-LAB";
-
- description "This module defines for food.";
-
- revision "2016-06-24" {
- description "Initial revision.";
- }
-
- container food {
- choice snack {
- case sportsarena {
-
- leaf pretzel {
- type empty;
- }
- leaf beer {
- type empty;
- }
- }
- case latenight {
- leaf chocolate {
- type enumeration {
- enum dark;
- enum milk;
- enum first-available;
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/integer16.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/integer16.yang
deleted file mode 100644
index 8db77be..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/integer16.yang
+++ /dev/null
@@ -1,98 +0,0 @@
-module integer16 {
-
- yang-version 1;
-
- namespace "ydt.integer16";
-
- prefix "integer16";
-
- organization "ON-LAB";
-
- description "This module defines for integer16 classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- list multiRangeValidation {
- config false;
- leaf integer {
- type int16 {
- range "10..40 | 50..100";
- }
- }
- leaf UnInteger {
- type uint16 {
- range "10..40 | 50..100";
- }
- }
-
- leaf revInteger {
- type int16 {
- range "min .. 2 | 10 | 20..max";
- }
- }
-
- leaf revUnInteger {
- type uint16 {
- range "min .. 2 | 10 | 20..max";
- }
- }
- }
-
- leaf negInt {
- type int16 {
- }
- }
-
- leaf posInt {
- type int16 {
- }
- }
-
- leaf minIntWithRange {
- type int16 {
- range "10 .. 100";
- }
- }
-
- leaf midIntWithRange {
- type int16 {
- range "10 .. 100";
- }
- }
-
- leaf maxIntWithRange {
- type int16 {
- range "10 .. 100";
- }
- }
-
- leaf minUInt {
- type uint16 {
- }
- }
-
- leaf maxUInt {
- type uint16 {
- }
- }
-
- leaf minUIntWithRange {
- type uint16 {
- range "10 .. 100";
- }
- }
-
- leaf midUIntWithRange {
- type uint16 {
- range "10 .. 100";
- }
- }
-
- leaf maxUIntWithRange {
- type uint16 {
- range "10 .. 100";
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/integer32.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/integer32.yang
deleted file mode 100644
index fb596cf..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/integer32.yang
+++ /dev/null
@@ -1,98 +0,0 @@
-module integer32 {
-
- yang-version 1;
-
- namespace "ydt.integer32";
-
- prefix "integer32";
-
- organization "ON-LAB";
-
- description "This module defines for integer32 classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- list multiRangeValidation {
- config false;
- leaf integer {
- type int32 {
- range "10..40 | 50..100";
- }
- }
- leaf UnInteger {
- type uint32 {
- range "10..40 | 50..100";
- }
- }
-
- leaf revInteger {
- type int32 {
- range "min .. 2 | 10 | 20..max";
- }
- }
-
- leaf revUnInteger {
- type uint32 {
- range "min .. 2 | 10 | 20..max";
- }
- }
- }
-
- leaf negInt {
- type int32 {
- }
- }
-
- leaf posInt {
- type int32 {
- }
- }
-
- leaf minIntWithRange {
- type int32 {
- range "10 .. 100";
- }
- }
-
- leaf midIntWithRange {
- type int32 {
- range "10 .. 100";
- }
- }
-
- leaf maxIntWithRange {
- type int32 {
- range "10 .. 100";
- }
- }
-
- leaf minUInt {
- type uint32 {
- }
- }
-
- leaf maxUInt {
- type uint32 {
- }
- }
-
- leaf minUIntWithRange {
- type uint32 {
- range "10 .. 100";
- }
- }
-
- leaf midUIntWithRange {
- type uint32 {
- range "10 .. 100";
- }
- }
-
- leaf maxUIntWithRange {
- type uint32 {
- range "10 .. 100";
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/integer64.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/integer64.yang
deleted file mode 100644
index 39479c6..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/integer64.yang
+++ /dev/null
@@ -1,98 +0,0 @@
-module integer64 {
-
- yang-version 1;
-
- namespace "ydt.integer64";
-
- prefix "integer64";
-
- organization "ON-LAB";
-
- description "This module defines for integer64 classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- list multiRangeValidation {
- config false;
- leaf integer {
- type int64 {
- range "10..40 | 50..100";
- }
- }
- leaf UnInteger {
- type uint64 {
- range "10..40 | 50..100";
- }
- }
-
- leaf revInteger {
- type int64 {
- range "min .. 2 | 10 | 20..max";
- }
- }
-
- leaf revUnInteger {
- type uint64 {
- range "min .. 2 | 10 | 20..max";
- }
- }
- }
-
- leaf negInt {
- type int64 {
- }
- }
-
- leaf posInt {
- type int64 {
- }
- }
-
- leaf minIntWithRange {
- type int64 {
- range "10 .. 100";
- }
- }
-
- leaf midIntWithRange {
- type int64 {
- range "10 .. 100";
- }
- }
-
- leaf maxIntWithRange {
- type int64 {
- range "10 .. 100";
- }
- }
-
- leaf minUInt {
- type uint64 {
- }
- }
-
- leaf maxUInt {
- type uint64 {
- }
- }
-
- leaf minUIntWithRange {
- type uint64 {
- range "10 .. 100";
- }
- }
-
- leaf midUIntWithRange {
- type uint64 {
- range "10 .. 100";
- }
- }
-
- leaf maxUIntWithRange {
- type uint64 {
- range "10 .. 100";
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/integer8.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/integer8.yang
deleted file mode 100644
index e05c235..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/integer8.yang
+++ /dev/null
@@ -1,99 +0,0 @@
-module integer8 {
-
- yang-version 1;
-
- namespace "ydt.integer8";
-
- prefix "integer8";
-
- organization "ON-LAB";
-
- description "This module defines for integer8 classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- list multiRangeValidation {
- config false;
- leaf integer {
- type int8 {
- range "10..40 | 50..100";
- }
- }
- leaf UnInteger {
- type uint8 {
- range "10..40 | 50..100";
- }
- }
-
- leaf revInteger {
- type int8 {
- range "min .. 2 | 10 | 20..max";
- }
- }
-
- leaf revUnInteger {
- type uint8 {
- range "min .. 2 | 10 | 20..max";
- }
- }
- }
-
-
- leaf negInt {
- type int8 {
- }
- }
-
- leaf posInt {
- type int8 {
- }
- }
-
- leaf minIntWithRange {
- type int8 {
- range "10 .. 100";
- }
- }
-
- leaf midIntWithRange {
- type int8 {
- range "10 .. 100";
- }
- }
-
- leaf maxIntWithRange {
- type int8 {
- range "10 .. 100";
- }
- }
-
- leaf minUInt {
- type uint8 {
- }
- }
-
- leaf maxUInt {
- type uint8 {
- }
- }
-
- leaf minUIntWithRange {
- type uint8 {
- range "10 .. 100";
- }
- }
-
- leaf midUIntWithRange {
- type uint8 {
- range "10 .. 100";
- }
- }
-
- leaf maxUIntWithRange {
- type uint8 {
- range "10 .. 100";
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/leafreftest.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/leafreftest.yang
deleted file mode 100644
index 5191b72..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/leafreftest.yang
+++ /dev/null
@@ -1,71 +0,0 @@
-module leafreftest {
-
- yang-version 1;
-
- namespace "ydt.leafreftest";
-
- prefix "uniontest";
-
- organization "ON-LAB";
-
- description "This module defines for union classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- leaf middlename {
- type string;
- }
-
- list leafrefList {
- config false;
- leaf id {
- type leafref {
- path "/middlename";
- }
- }
- }
-
- typedef percent {
- type leafref {
- path "/middlename";
- }
- }
-
- leaf name {
- type percent;
- }
-
- grouping greeting {
- leaf surname {
- type leafref {
- path "/middlename";
- }
- }
- }
-
- container cont1 {
- uses greeting;
- }
-
- augment "/cont1" {
- leaf lastname {
- type leafref {
- path "/middlename";
- }
- }
- }
-
- container food {
- choice snack {
- case sportsarena {
- leaf pretzel {
- type leafref {
- path "/middlename";
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/logisticsmanager.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/logisticsmanager.yang
deleted file mode 100644
index 7198611..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/logisticsmanager.yang
+++ /dev/null
@@ -1,16 +0,0 @@
-module logisticsmanager {
-
- yang-version 1;
-
- namespace "ydt.logistics-manager";
-
- prefix "root";
-
- organization "ON-LAB";
-
- description "This module defines for logistics-manager.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/materialsupervisor.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/materialsupervisor.yang
deleted file mode 100644
index 6ab16ea..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/materialsupervisor.yang
+++ /dev/null
@@ -1,29 +0,0 @@
-module materialsupervisor {
-
- yang-version 1;
-
- namespace "ydt.material-supervisor";
-
- prefix "material";
-
- organization "ON-LAB";
-
- description "This module defines for material-supervisor.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- list supervisor {
- key "name";
- leaf name {
- type string;
- description "name of material-supervisor";
- }
-
- leaf departmentId {
- type string;
- description "name of department";
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/merchandisersupervisor.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/merchandisersupervisor.yang
deleted file mode 100644
index db40c7e..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/merchandisersupervisor.yang
+++ /dev/null
@@ -1,21 +0,0 @@
-module merchandisersupervisor {
-
- yang-version 1;
-
- namespace "ydt.Merchandiser-supervisor";
-
- prefix "merchandiser";
-
- organization "ON-LAB";
-
- description "This module defines for Merchandiser-supervisor.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- leaf supervisor {
- type string;
- description "name of the Merchandiser-supervisor.";
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/purchasingsupervisor.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/purchasingsupervisor.yang
deleted file mode 100644
index a52b4c5..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/purchasingsupervisor.yang
+++ /dev/null
@@ -1,27 +0,0 @@
-module purchasingsupervisor {
-
- yang-version 1;
-
- namespace "ydt.purchasing-supervisor";
-
- prefix "purchasing";
-
- organization "ON-LAB";
-
- description "This module defines for purchasing-supervisor.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- container supervisor {
- leaf purchasing-specialist {
- type string;
- description "name of the purchasing-specialist person";
- }
- leaf support {
- type string;
- description "name of the support person";
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/rootlist.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/rootlist.yang
deleted file mode 100644
index ef5a0a0..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/rootlist.yang
+++ /dev/null
@@ -1,111 +0,0 @@
-module rootlist {
-
- yang-version 1;
-
- namespace "ydt.rootlist";
-
- prefix "rootlist";
-
- organization "ON-LAB";
-
- description "This submodule defines for root.";
-
- revision "2016-06-24" {
- description "Initial revision.";
- }
-/*
- +--------------+---------+-------------+
- | substatement | section | cardinality |
- +--------------+---------+-------------+
- | anyxml | 7.10 | 0..n |
- | choice | 7.9 | 0..n |
- | config | 7.19.1 | 0..1 |
- | container | 7.5 | 0..n |
- | description | 7.19.3 | 0..1 |
- | grouping | 7.11 | 0..n |
- | if-feature | 7.18.2 | 0..n |
- | key | 7.8.2 | 0..1 |
- | leaf | 7.6 | 0..n |
- | leaf-list | 7.7 | 0..n |
- | list | 7.8 | 0..n |
- | max-elements | 7.7.4 | 0..1 |
- | min-elements | 7.7.3 | 0..1 |
- | must | 7.5.3 | 0..n |
- | ordered-by | 7.7.5 | 0..1 |
- | reference | 7.19.4 | 0..1 |
- | status | 7.19.2 | 0..1 |
- | typedef | 7.3 | 0..n |
- | unique | 7.8.3 | 0..n |
- | uses | 7.12 | 0..n |
- | when | 7.19.5 | 0..1 |
- +--------------+---------+-------------+
-*/
-
- list listwithoutcontainer {
- key "invalidinterval";
- min-elements 1; //-- comment
- leaf invalidinterval {
- type "uint16";
- units "seconds";
- description "Interval before a route is declared invalid";
- config true;
- mandatory true;
- status current;
- reference "RFC 6020";
- }
- }
-
- list listwithcontainer {
- key "invalid invalid1";
- max-elements 3;
- min-elements 1;
- reference "list reference";
- unique "invalid";
- leaf-list invalidinterval {
- type "uint16";
- units "seconds";
- description "Interval before a route is declared invalid";
- config false;
- status current;
- reference "RFC 6020";
- }
-
- container interface {
- leaf invalidinterval {
- type "uint16";
- units "seconds";
- status current;
- mandatory true;
- reference "RFC 6020";
- }
-
- leaf invalid {
- type "uint16";
- units "seconds";
- description "Interval before a route is declared invalid";
- default "16";
- status current;
- reference "RFC 6020";
- }
-
- }
-
- leaf invalid {
- type "uint16";
- units "seconds";
- description "Interval before a route is declared invalid";
- mandatory true;
- status current;
- reference "RFC 6020";
- }
-
- leaf invalid1 {
- type "uint16";
- units "seconds";
- description "Interval before a route is declared invalid";
- mandatory true;
- status current;
- reference "RFC 6020";
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/tradingsupervisor.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/tradingsupervisor.yang
deleted file mode 100644
index a6c8681..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/tradingsupervisor.yang
+++ /dev/null
@@ -1,21 +0,0 @@
-module tradingsupervisor {
-
- yang-version 1;
-
- namespace "ydt.trading-supervisor";
-
- prefix "trading";
-
- organization "ON-LAB";
-
- description "This module defines for trading-supervisor.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- leaf supervisor {
- type string;
- description "name of the trading-supervisor";
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/uniontest.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/uniontest.yang
deleted file mode 100644
index 4ab5801..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/uniontest.yang
+++ /dev/null
@@ -1,92 +0,0 @@
-module uniontest {
-
- yang-version 1;
-
- namespace "ydt.uniontest";
-
- prefix "uniontest";
-
- organization "ON-LAB";
-
- description "This module defines for union classifier.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- list unionList {
- config false;
- leaf id {
- type union {
- type int8;
- type binary;
- }
- }
- }
-
- typedef percent {
- type union {
- type int8;
- type bits {
- bit bit0 {
- position 0;
- }
- bit bit1 {
- position 1;
- }
- bit bit2 {
- position 2;
- }
- }
- }
- }
-
- leaf name {
- type percent;
- }
-
- grouping greeting {
- leaf surname {
- type union {
- type int8;
- type string;
- }
- }
- }
-
- container cont1 {
- uses greeting;
- }
-
- augment "/cont1" {
- leaf lastname {
- type union {
- type int8;
- type bits {
- bit bit0 {
- position 0;
- }
- bit bit1 {
- position 1;
- }
- bit bit2 {
- position 2;
- }
- }
- }
- }
- }
-
- container food {
- choice snack {
- case sportsarena {
- leaf pretzel {
- type union {
- type int8;
- type binary;
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/warehousesupervisor.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/warehousesupervisor.yang
deleted file mode 100644
index 5145824..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/warehousesupervisor.yang
+++ /dev/null
@@ -1,21 +0,0 @@
-module warehousesupervisor {
-
- yang-version 1;
-
- namespace "ydt.warehouse-supervisor";
-
- prefix "warehouse";
-
- organization "ON-LAB";
-
- description "This module defines for warehouse-supervisor.";
-
- revision "2016-05-24" {
- description "Initial revision.";
- }
-
- leaf-list supervisor {
- type string;
- description "name of the warehouse-supervisor's";
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-inet-types.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-inet-types.yang
deleted file mode 100644
index 6b994bb..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-inet-types.yang
+++ /dev/null
@@ -1,454 +0,0 @@
- module yms-ietf-inet-types {
-
- yang-version 1;
-
- namespace
- "urn:ietf:params:xml:ns:yang:ietf-inet-types";
-
- prefix inet;
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/netmod/>
- WG List: <mailto:netmod@ietf.org>
-
- WG Chair: David Kessens
- <mailto:david.kessens@nsn.com>
-
- WG Chair: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>
-
- Editor: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>";
-
- description
- "This module contains a collection of generally useful derived
- YANG data types for Internet addresses and related things.
-
- Copyright (c) 2013 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC 6991; see
- the RFC itself for full legal notices.";
-
- revision "2013-07-15" {
- description
- "This revision adds the following new data types:
- - ip-address-no-zone
- - ipv4-address-no-zone
- - ipv6-address-no-zone";
- reference
- "RFC 6991: Common YANG Data Types";
-
- }
-
- revision "2010-09-24" {
- description "Initial revision.";
- reference
- "RFC 6021: Common YANG Data Types";
-
- }
-
-
- typedef ip-version {
- type enumeration {
- enum "unknown" {
- value 0;
- description
- "An unknown or unspecified version of the Internet
- protocol.";
- }
- enum "ipv4" {
- value 1;
- description
- "The IPv4 protocol as defined in RFC 791.";
- }
- enum "ipv6" {
- value 2;
- description
- "The IPv6 protocol as defined in RFC 2460.";
- }
- }
- description
- "This value represents the version of the IP protocol.
-
- In the value set and its semantics, this type is equivalent
- to the InetVersion textual convention of the SMIv2.";
- reference
- "RFC 791: Internet Protocol
- RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
- RFC 4001: Textual Conventions for Internet Network Addresses";
-
- }
-
- typedef dscp {
- type uint8 {
- range "0..63";
- }
- description
- "The dscp type represents a Differentiated Services Code Point
- that may be used for marking packets in a traffic stream.
- In the value set and its semantics, this type is equivalent
- to the Dscp textual convention of the SMIv2.";
- reference
- "RFC 3289: Management Information Base for the Differentiated
- Services Architecture
- RFC 2474: Definition of the Differentiated Services Field
- (DS Field) in the IPv4 and IPv6 Headers
- RFC 2780: IANA Allocation Guidelines For Values In
- the Internet Protocol and Related Headers";
-
- }
-
- typedef ipv6-flow-label {
- type uint32 {
- range "0..1048575";
- }
- description
- "The ipv6-flow-label type represents the flow identifier or Flow
- Label in an IPv6 packet header that may be used to
- discriminate traffic flows.
-
- In the value set and its semantics, this type is equivalent
- to the IPv6FlowLabel textual convention of the SMIv2.";
- reference
- "RFC 3595: Textual Conventions for IPv6 Flow Label
- RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
-
- }
-
- typedef port-number {
- type uint16 {
- range "0..65535";
- }
- description
- "The port-number type represents a 16-bit port number of an
- Internet transport-layer protocol such as UDP, TCP, DCCP, or
- SCTP. Port numbers are assigned by IANA. A current list of
- all assignments is available from <http://www.iana.org/>.
-
- Note that the port number value zero is reserved by IANA. In
- situations where the value zero does not make sense, it can
- be excluded by subtyping the port-number type.
- In the value set and its semantics, this type is equivalent
- to the InetPortNumber textual convention of the SMIv2.";
- reference
- "RFC 768: User Datagram Protocol
- RFC 793: Transmission Control Protocol
- RFC 4960: Stream Control Transmission Protocol
- RFC 4340: Datagram Congestion Control Protocol (DCCP)
- RFC 4001: Textual Conventions for Internet Network Addresses";
-
- }
-
- typedef as-number {
- type uint32;
- description
- "The as-number type represents autonomous system numbers
- which identify an Autonomous System (AS). An AS is a set
- of routers under a single technical administration, using
- an interior gateway protocol and common metrics to route
- packets within the AS, and using an exterior gateway
- protocol to route packets to other ASes. IANA maintains
- the AS number space and has delegated large parts to the
- regional registries.
-
- Autonomous system numbers were originally limited to 16
- bits. BGP extensions have enlarged the autonomous system
- number space to 32 bits. This type therefore uses an uint32
- base type without a range restriction in order to support
- a larger autonomous system number space.
-
- In the value set and its semantics, this type is equivalent
- to the InetAutonomousSystemNumber textual convention of
- the SMIv2.";
- reference
- "RFC 1930: Guidelines for creation, selection, and registration
- of an Autonomous System (AS)
- RFC 4271: A Border Gateway Protocol 4 (BGP-4)
- RFC 4001: Textual Conventions for Internet Network Addresses
- RFC 6793: BGP Support for Four-Octet Autonomous System (AS)
- Number Space";
-
- }
-
- typedef ip-address {
- type union {
- type ipv4-address;
- type ipv6-address;
- }
- description
- "The ip-address type represents an IP address and is IP
- version neutral. The format of the textual representation
- implies the IP version. This type supports scoped addresses
- by allowing zone identifiers in the address format.";
- reference
- "RFC 4007: IPv6 Scoped Address Architecture";
-
- }
-
- typedef ipv4-address {
- type string {
- pattern
- '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?';
- }
- description
- "The ipv4-address type represents an IPv4 address in
- dotted-quad notation. The IPv4 address may include a zone
- index, separated by a % sign.
-
- The zone index is used to disambiguate identical address
- values. For link-local addresses, the zone index will
- typically be the interface index number or the name of an
- interface. If the zone index is not present, the default
- zone of the device will be used.
-
- The canonical format for the zone index is the numerical
- format";
- }
-
- typedef ipv6-address {
- type string {
- pattern
- '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(%[\p{N}\p{L}]+)?';
- pattern
- '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)(%.+)?';
- }
- description
- "The ipv6-address type represents an IPv6 address in full,
- mixed, shortened, and shortened-mixed notation. The IPv6
- address may include a zone index, separated by a % sign.
-
- The zone index is used to disambiguate identical address
- values. For link-local addresses, the zone index will
- typically be the interface index number or the name of an
- interface. If the zone index is not present, the default
- zone of the device will be used.
-
-
-
- The canonical format of IPv6 addresses uses the textual
- representation defined in Section 4 of RFC 5952. The
- canonical format for the zone index is the numerical
- format as described in Section 11.2 of RFC 4007.";
- reference
- "RFC 4291: IP Version 6 Addressing Architecture
- RFC 4007: IPv6 Scoped Address Architecture
- RFC 5952: A Recommendation for IPv6 Address Text
- Representation";
-
- }
-
- typedef ip-address-no-zone {
- type union {
- type ipv4-address-no-zone;
- type ipv6-address-no-zone;
- }
- description
- "The ip-address-no-zone type represents an IP address and is
- IP version neutral. The format of the textual representation
- implies the IP version. This type does not support scoped
- addresses since it does not allow zone identifiers in the
- address format.";
- reference
- "RFC 4007: IPv6 Scoped Address Architecture";
-
- }
-
- typedef ipv4-address-no-zone {
- type ipv4-address {
- pattern '[0-9\.]*';
- }
- description
- "An IPv4 address without a zone index. This type, derived from
- ipv4-address, may be used in situations where the zone is
- known from the context and hence no zone index is needed.";
- }
-
- typedef ipv6-address-no-zone {
- type ipv6-address {
- pattern '[0-9a-fA-F:\.]*';
- }
- description
- "An IPv6 address without a zone index. This type, derived from
- ipv6-address, may be used in situations where the zone is
- known from the context and hence no zone index is needed.";
- reference
- "RFC 4291: IP Version 6 Addressing Architecture
- RFC 4007: IPv6 Scoped Address Architecture
- RFC 5952: A Recommendation for IPv6 Address Text
- Representation";
-
- }
-
- typedef ip-prefix {
- type union {
- type ipv4-prefix;
- type ipv6-prefix;
- }
- description
- "The ip-prefix type represents an IP prefix and is IP
- version neutral. The format of the textual representations
- implies the IP version.";
- }
-
- typedef ipv4-prefix {
- type string {
- pattern
- '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))';
- }
- description
- "The ipv4-prefix type represents an IPv4 address prefix.
- The prefix length is given by the number following the
- slash character and must be less than or equal to 32.
-
- A prefix length value of n corresponds to an IP address
- mask that has n contiguous 1-bits from the most
- significant bit (MSB) and all other bits set to 0.
-
- The canonical format of an IPv4 prefix has all bits of
- the IPv4 address set to zero that are not part of the
- IPv4 prefix.";
- }
-
- typedef ipv6-prefix {
- type string {
- pattern
- '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
- pattern
- '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)(/.+)';
- }
- description
- "The ipv6-prefix type represents an IPv6 address prefix.
- The prefix length is given by the number following the
- slash character and must be less than or equal to 128.
-
- A prefix length value of n corresponds to an IP address
- mask that has n contiguous 1-bits from the most
- significant bit (MSB) and all other bits set to 0.
-
- The IPv6 address should have all bits that do not belong
- to the prefix set to zero.
-
- The canonical format of an IPv6 prefix has all bits of
- the IPv6 address set to zero that are not part of the
- IPv6 prefix. Furthermore, the IPv6 address is represented
- as defined in Section 4 of RFC 5952.";
- reference
- "RFC 5952: A Recommendation for IPv6 Address Text
- Representation";
-
- }
-
- typedef domain-name {
- type string {
- length "1..253";
- pattern
- '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)|\.';
- }
- description
- "The domain-name type represents a DNS domain name. The
- name SHOULD be fully qualified whenever possible.
-
- Internet domain names are only loosely specified. Section
- 3.5 of RFC 1034 recommends a syntax (modified in Section
- 2.1 of RFC 1123). The pattern above is intended to allow
- for current practice in domain name use, and some possible
- future expansion. It is designed to hold various types of
- domain names, including names used for A or AAAA records
- (host names) and other records, such as SRV records. Note
- that Internet host names have a stricter syntax (described
- in RFC 952) than the DNS recommendations in RFCs 1034 and
- 1123, and that systems that want to store host names in
- schema nodes using the domain-name type are recommended to
- adhere to this stricter standard to ensure interoperability.
-
- The encoding of DNS names in the DNS protocol is limited
- to 255 characters. Since the encoding consists of labels
- prefixed by a length bytes and there is a trailing NULL
- byte, only 253 characters can appear in the textual dotted
- notation.
-
- The description clause of schema nodes using the domain-name
- type MUST describe when and how these names are resolved to
- IP addresses. Note that the resolution of a domain-name value
- may require to query multiple DNS records (e.g., A for IPv4
- and AAAA for IPv6). The order of the resolution process and
- which DNS record takes precedence can either be defined
- explicitly or may depend on the configuration of the
- resolver.
-
- Domain-name values use the US-ASCII encoding. Their canonical
- format uses lowercase US-ASCII characters. Internationalized
- domain names MUST be A-labels as per RFC 5890.";
- reference
- "RFC 952: DoD Internet Host Table Specification
- RFC 1034: Domain Names - Concepts and Facilities
- RFC 1123: Requirements for Internet Hosts -- Application
- and Support
- RFC 2782: A DNS RR for specifying the location of services
- (DNS SRV)
- RFC 5890: Internationalized Domain Names in Applications
- (IDNA): Definitions and Document Framework";
-
- }
-
- typedef host {
- type union {
- type ip-address;
- type domain-name;
- }
- description
- "The host type represents either an IP address or a DNS
- domain name.";
- }
-
- typedef uri {
- type string;
- description
- "The uri type represents a Uniform Resource Identifier
- (URI) as defined by STD 66.
-
- Objects using the uri type MUST be in US-ASCII encoding,
- and MUST be normalized as described by RFC 3986 Sections
- 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary
- percent-encoding is removed, and all case-insensitive
- characters are set to lowercase except for hexadecimal
- digits, which are normalized to uppercase as described in
- Section 6.2.2.1.
-
- The purpose of this normalization is to help provide
- unique URIs. Note that this normalization is not
- sufficient to provide uniqueness. Two URIs that are
- textually distinct after this normalization may still be
- equivalent.
-
- Objects using the uri type may restrict the schemes that
- they permit. For example, 'data:' and 'urn:' schemes
- might not be appropriate.
-
- A zero-length URI is not a valid URI. This can be used to
- express 'URI absent' where required.
-
- In the value set and its semantics, this type is equivalent
- to the Uri SMIv2 textual convention defined in RFC 5017.";
- reference
- "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
- RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
- Group: Uniform Resource Identifiers (URIs), URLs,
- and Uniform Resource Names (URNs): Clarifications
- and Recommendations
- RFC 5017: MIB Textual Conventions for Uniform Resource
- Identifiers (URIs)";
-
- }
- } // module ietf-inet-types
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-network.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-network.yang
deleted file mode 100644
index dc65182..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-network.yang
+++ /dev/null
@@ -1,216 +0,0 @@
- module yms-ietf-network {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network";
- prefix nd;
-
- import yms-ietf-inet-types {
- prefix inet;
- }
-
- organization
- "IETF I2RS (Interface to the Routing System) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/i2rs/>
- WG List: <mailto:i2rs@ietf.org>
-
- WG Chair: Susan Hares
- <mailto:shares@ndzh.com>
-
- WG Chair: Jeffrey Haas
- <mailto:jhaas@pfrc.org>
-
- Editor: Alexander Clemm
- <mailto:alex@cisco.com>
-
- Editor: Jan Medved
- <mailto:jmedved@cisco.com>
-
- Editor: Robert Varga
- <mailto:rovarga@cisco.com>
-
- Editor: Tony Tkacik
- <mailto:ttkacik@cisco.com>
-
- Editor: Nitin Bahadur
- <mailto:nitin_bahadur@yahoo.com>
-
- Editor: Hariharan Ananthakrishnan
- <mailto:hari@packetdesign.com>";
-
- description
- "This module defines a common base model for a collection
- of nodes in a network. Node definitions are further used
- in network topologies and inventories.
-
- Copyright (c) 2015 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of
- draft-ietf-i2rs-yang-network-topo-02;
- see the RFC itself for full legal notices.
-
- NOTE TO RFC EDITOR: Please replace above reference to
- draft-ietf-i2rs-yang-network-topo-02 with RFC
- number when published (i.e. RFC xxxx).";
-
- revision 2015-12-08 {
- description
- "Initial revision.
- NOTE TO RFC EDITOR: Please replace the following reference
- to draft-ietf-i2rs-yang-network-topo-02 with
- RFC number when published (i.e. RFC xxxx).";
- reference
- "draft-ietf-i2rs-yang-network-topo-02";
- }
-
- typedef node-id {
- type inet:uri;
- description
- "Identifier for a node.";
- }
-
- typedef network-id {
- type inet:uri;
- description
- "Identifier for a network.";
- }
- grouping network-ref {
- description
- "Contains the information necessary to reference a network,
- for example an underlay network.";
- leaf network-ref {
- type leafref {
- path "/nd:networks/nd:network/nd:network-id";
- require-instance false;
- }
- description
- "Used to reference a network, for example an underlay
- network.";
- }
- }
-
- grouping node-ref {
- description
- "Contains the information necessary to reference a node.";
- leaf node-ref {
- type leafref {
- path "/nd:networks/nd:network[nd:network-id=current()/../"+
- "network-ref]/nd:node/nd:node-id";
- require-instance false;
- }
- description
- "Used to reference a node.
- Nodes are identified relative to the network they are
- contained in.";
- }
- uses network-ref;
- }
-
- container networks {
- description
- "Serves as top-level container for a list of networks.";
- list network {
- key "network-id";
- description
- "Describes a network.
- A network typically contains an inventory of nodes,
- topological information (augmented through
- network-topology model), as well as layering
- information.";
- container network-types {
- description
- "Serves as an augmentation target.
- The network type is indicated through corresponding
- presence containers augmented into this container.";
- }
- leaf network-id {
- type network-id;
- description
- "Identifies a network.";
- }
- list supporting-network {
- key "network-ref";
- description
- "An underlay network, used to represent layered network
- topologies.";
- leaf network-ref {
- type leafref {
- path "/networks/network/network-id";
- require-instance false;
- }
- description
- "References the underlay network.";
- }
- }
- list node {
- key "node-id";
- description
- "The inventory of nodes of this network.";
- leaf node-id {
- type node-id;
- description
- "Identifies a node uniquely within the containing
- network.";
- }
- list supporting-node {
- key "network-ref node-ref";
- description
- "Represents another node, in an underlay network, that
- this node is supported by. Used to represent layering
- structure.";
- leaf network-ref {
- type leafref {
- path "../../../supporting-network/network-ref";
- require-instance false;
- }
- description
- "References the underlay network that the
- underlay node is part of.";
- }
- leaf node-ref {
- type leafref {
- path "/networks/network/node/node-id";
- require-instance false;
- }
- description
- "References the underlay node itself.";
- }
- }
- }
- }
- }
- container networks-state {
- config false;
- description
- "Serves as top-level container for a list of state information
- for networks";
- list network {
- key "network-ref";
- description
- "Data nodes representing operational data and state of
- networks.
- An instance is automatically created for every network
- in the corresponding list under the networks container.";
- uses network-ref;
- leaf server-provided {
- type boolean;
- description
- "Indicates whether the information concerning this
- particular network is populated by the server
- (server-provided true, the general case for network
- information discovered from the server),
- or whether it is configured by a client
- (server-provided true, possible e.g. for
- service overlays managed through a controller).";
- }
- }
- }
- }
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-schedule.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-schedule.yang
deleted file mode 100644
index 6b278b7..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-schedule.yang
+++ /dev/null
@@ -1,64 +0,0 @@
- module yms-ietf-schedule {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-schedule";
- // replace with IANA namespace when assigned
-
- prefix "sch";
-
- import yms-ietf-yang-types {
- prefix "yang";
- }
-
- organization "TBD";
- contact "TBD";
- description
- "The model allows time scheduling parameters to be specified.";
-
- revision "2016-03-01" {
- description "Initial revision";
- reference "TBD";
- }
-
- /*
- * Groupings
- */
-
- grouping schedules {
- description
- "A list of schedules defining when a particular
- configuration takes effect.";
- container schedules {
- description
- "Container of a schedule list defining when a particular
- configuration takes effect.";
- list schedule {
- key "schedule-id";
- description "A list of schedule elements.";
-
- leaf schedule-id {
- type uint32;
- description "Identifies the schedule element.";
- }
- leaf start {
- type yang:date-and-time;
- description "Start time.";
- }
- leaf schedule-duration {
- type string {
- pattern
- 'P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?(\d+S)?';
- }
- description "Schedule duration in ISO 8601 format.";
- }
- leaf repeat-interval {
- type string {
- pattern
- 'R\d*/P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?'
- + '(\d+S)?';
- }
- description "Repeat interval in ISO 8601 format.";
- }
- }
- }
- } // schedules
- }
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-te-topology.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-te-topology.yang
deleted file mode 100644
index 8815682..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-te-topology.yang
+++ /dev/null
@@ -1,1112 +0,0 @@
-module yms-ietf-te-topology {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
- // replace with IANA namespace when assigned
-
- prefix "tet";
-
- import yms-ietf-inet-types {
- prefix "inet";
- }
-
- import yms-ietf-schedule {
- prefix "sch";
- }
-
- import yms-ietf-te-types {
- prefix "te-types";
- }
-
- import yms-ietf-network {
- prefix "nw";
- }
-
- import yms-network-topology {
- prefix "nt";
- }
-
- organization
- "Traffic Engineering Architecture and Signaling (TEAS)
- Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/teas/>
- WG List: <mailto:teas@ietf.org>
- WG Chair: Lou Berger
- <mailto:lberger@labn.net>
- WG Chair: Vishnu Pavan Beeram
- <mailto:vbeeram@juniper.net>
- Editor: Xufeng Liu
- <mailto:xliu@kuatrotech.com>
- Editor: Igor Bryskin
- <mailto:Igor.Bryskin@huawei.com>
- Editor: Vishnu Pavan Beeram
- <mailto:vbeeram@juniper.net>
- Editor: Tarek Saad
- <mailto:tsaad@cisco.com>
- Editor: Himanshu Shah
- <mailto:hshah@ciena.com>
- Editor: Oscar Gonzalez De Dios
- <mailto:oscar.gonzalezdedios@telefonica.com>";
-
- description "TE topology model";
-
- revision "2016-03-17" {
- description "Initial revision";
- reference "TBD";
- }
-
- /*
- * Features
- */
-
- feature configuration-schedule {
- description
- "This feature indicates that the system supports
- configuration scheduling.";
- }
-
- feature te-topology-hierarchy {
- description
- "This feature indicates that the system allows underlay
- and/or overlay TE topology hierarchy.";
- }
-
- feature te-performance-metric {
- description
- "This feature indicates that the system supports
- TE performance metric defined in
- RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
- }
-
- feature template {
- description
- "This feature indicates that the system supports
- template configuration.";
- }
-
- /*
- * Typedefs
- */
- typedef performance-metric-normality {
- type enumeration {
- enum "unknown" {
- value 0;
- description
- "Unknown.";
- }
- enum "normal" {
- value 1;
- description
- "Normal.";
- }
- enum "abnormal" {
- value 2;
- description
- "Abnormal. The anomalous bit is set.";
- }
- }
- description
- "Indicates whether a performance metric is normal, abnormal, or
- unknown.";
- reference
- "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
- }
-
- typedef te-admin-status {
- type enumeration {
- enum up {
- description
- "Enabled.";
- }
- enum down {
- description
- "Disabled.";
- }
- enum testing {
- description
- "In some test mode.";
- }
- enum preparing-maintenance {
- description
- "Resource is disabled in the control plane to prepare for
- graceful shutdown for maintenance purposes.";
- reference
- "RFC5817: Graceful Shutdown in MPLS and Generalized MPLS
- Traffic Engineering Networks";
- }
- enum maintenance {
- description
- "Resource is disabled in the data plane for maintenance
- purposes.";
- }
- }
- description
- "Defines a type representing the administrative status of
- a TE resource.";
- }
- typedef te-global-id {
- type uint32;
- description
- "An identifier to uniquely identify an operator, which can be
- either a provider or a client.
- The definition of this type is taken from RFC6370 and RFC5003.
- This attribute type is used solely to provide a globally
- unique context for TE topologies.";
- }
-
- typedef te-link-access-type {
- type enumeration {
- enum point-to-point {
- description
- "The link is point-to-point.";
- }
- enum multi-access {
- description
- "The link is multi-access, including broacast and NBMA.";
- }
- }
- description
- "Defines a type representing the access type of a TE link.";
- reference
- "RFC3630: Traffic Engineering (TE) Extensions to OSPF
- Version 2.";
- }
-
- typedef te-node-id {
- type inet:ip-address;
- description
- "An identifier for a node in a topology.
- The identifier is represented as an IPv4 or IPv6 address.
- This attribute is mapped to Router ID in
- RFC3630, RFC5329, RFC5305, and RFC 6119.";
- }
-
- typedef te-oper-status {
- type enumeration {
- enum up {
- description
- "Operational up.";
- }
- enum down {
- description
- "Operational down.";
- }
- enum testing {
- description
- "In some test mode.";
- }
- enum unknown {
- description
- "Status cannot be determined for some reason.";
- }
- enum preparing-maintenance {
- description
- "Resource is disabled in the control plane to prepare for
- graceful shutdown for maintenance purposes.";
- reference
- "RFC5817: Graceful Shutdown in MPLS and Generalized MPLS
- Traffic Engineering Networks";
- }
- enum maintenance {
- description
- "Resource is disabled in the data plane for maintenance
- purposes.";
- }
- }
- description
- "Defines a type representing the operational status of
- a TE resource.";
- }
-
- typedef te-recovery-status {
- type enumeration {
- enum normal {
- description
- "Both the recovery and working spans are fully
- allocated and active, data traffic is being
- transported over (or selected from) the working
- span, and no trigger events are reported.";
- }
- enum recovery-started {
- description
- "The recovery action has been started, but not completed.";
- }
- enum recovery-succeeded {
- description
- "The recovery action has succeeded. The working span has
- reported a failure/degrade condition and the user traffic
- is being transported (or selected) on the recovery span.";
- }
- enum recovery-failed {
- description
- "The recovery action has failed.";
- }
- enum reversion-started {
- description
- "The reversion has started.";
- }
- enum reversion-failed {
- description
- "The reversion has failed.";
- }
- enum recovery-unavailable {
- description
- "The recovery is unavailable -- either as a result of an
- operator Lockout command or a failure condition detected
- on the recovery span.";
- }
- enum recovery-admin {
- description
- "The operator has issued a command switching the user
- traffic to the recovery span.";
- }
- enum wait-to-restore {
- description
- "The recovery domain is recovering from a failuer/degrade
- condition on the working span that is being controlled by
- the Wait-to-Restore (WTR) timer.";
- }
- }
- }
-
- typedef te-template-name {
- type string {
- pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
- }
- }
-
- typedef te-topology-event-type {
- type enumeration {
- enum "add" {
- value 0;
- }
- enum "remove" {
- value 1;
- }
- enum "update" {
- value 2;
- }
- }
- } // te-topology-event-type
- typedef te-topology-id {
- type string {
- pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
- }
- }
-
- typedef te-tp-id {
- type union {
- type uint32; // Unnumbered
- type inet:ip-address; // IPv4 or IPv6 address
- }
- }
-
- /*
- * Identities
- */
-
- /*
- * Groupings
- */
- grouping information-source-attributes {
- leaf information-source {
- type enumeration {
- enum "unknown";
- enum "locally-configured";
- enum "ospfv2";
- enum "ospfv3";
- enum "isis";
- enum "system-processed";
- enum "other";
- }
- }
- container information-source-state {
- leaf credibility-preference {
- type uint16;
- }
- container topology {
- uses te-topology-ref;
- } // topology
- leaf routing-instance {
- type string;
- } // routing-information
- }
- } // information-source-attributes
-
- grouping performance-metric-attributes {
- leaf unidirectional-delay {
- type uint32 {
- range 0..16777215;
- }
- }
- leaf unidirectional-min-delay {
- type uint32 {
- range 0..16777215;
- }
- }
- leaf unidirectional-max-delay {
- type uint32 {
- range 0..16777215;
- }
- }
- leaf unidirectional-delay-variation {
- type uint32 {
- range 0..16777215;
- }
- }
- leaf unidirectional-packet-loss {
- type decimal64 {
- fraction-digits 6;
- range "0 .. 50.331642";
- }
- }
- leaf unidirectional-residual-bandwidth {
- type decimal64 {
- fraction-digits 2;
- }
- }
- leaf unidirectional-available-bandwidth {
- type decimal64 {
- fraction-digits 2;
- }
- }
- leaf unidirectional-utilized-bandwidth {
- type decimal64 {
- fraction-digits 2;
- }
- }
- } // performance-metric-attributes
- grouping performance-metric-normality-attributes {
- leaf unidirectional-delay {
- type performance-metric-normality;
- }
- leaf unidirectional-min-delay {
- type performance-metric-normality;
- }
- leaf unidirectional-max-delay {
- type performance-metric-normality;
- }
- leaf unidirectional-delay-variation {
- type performance-metric-normality;
- }
- leaf unidirectional-packet-loss {
- type performance-metric-normality;
- }
- leaf unidirectional-residual-bandwidth {
- type performance-metric-normality;
- }
- leaf unidirectional-available-bandwidth {
- type performance-metric-normality;
- }
- leaf unidirectional-utilized-bandwidth {
- type performance-metric-normality;
- }
- } // performance-metric-normality-attributes
-
- grouping performance-metric-throttle-container {
- container performance-metric-throttle {
- leaf unidirectional-delay-offset {
- type uint32 {
- range 0..16777215;
- }
- }
- leaf measure-interval {
- type uint32;
- default 30;
- }
- leaf advertisement-interval {
- type uint32;
- }
- leaf suppression-interval {
- type uint32 {
- range "1 .. max";
- }
- default 120;
- }
- container threshold-out {
- uses performance-metric-attributes;
- }
- container threshold-in {
- uses performance-metric-attributes;
- }
- container threshold-accelerated-advertisement {
- uses performance-metric-attributes;
- }
- }
- } // performance-metric-throttle-container
-
- grouping te-link-augment {
- container te {
- presence "TE support.";
- container config {
- uses te-link-config;
- } // config
- container state {
- config false;
- uses te-link-config;
- uses te-link-state-derived;
- } // state
- } // te
- } // te-link-augment
-
- grouping te-link-config {
- choice bundle-stack-level {
- case bundle {
- container bundled-links {
- list bundled-link {
- key "sequence";
- leaf sequence {
- type uint32;
- }
- leaf src-tp-ref {
- type leafref {
- path "../../../../../../nw:node[nw:node-id = "
- + "current()/../../../../../nt:source/"
- + "nt:source-node]/"
- + "nt:t-point/nt:tp-id";
- require-instance true;
- }
- }
- leaf des-tp-ref {
- type leafref {
- path "../../../../../../nw:node[nw:node-id = "
- + "current()/../../../../../nt:destination/"
- + "nt:dest-node]/"
- + "nt:t-point/nt:tp-id";
- require-instance true;
- }
- }
- } // list bundled-link
- }
- }
- case component {
- container component-links {
- list component-link {
- key "sequence";
- leaf sequence {
- type uint32;
- }
- leaf src-interface-ref {
- type string;
- }
- leaf des-interface-ref {
- type string;
- }
- }
- }
- }
- } // bundle-stack-level
-
- leaf-list te-link-template {
- if-feature template;
- type leafref {
- path "../../../../../te/templates/link-template/name";
- }
- }
- uses te-link-config-attributes;
- } // te-link-config
-
- grouping te-link-config-attributes {
- container te-link-attributes {
- uses sch:schedules;
- leaf access-type {
- type te-link-access-type;
- }
- leaf is-abstract {
- type empty;
- }
- leaf name {
- type string;
- }
- container underlay {
- presence
- "Indicates the underlay exists for this link.";
- uses te-link-underlay-attributes;
- } // underlay
- leaf admin-status {
- type te-admin-status;
- description
- "The administrative state of the link.";
- }
-
- uses performance-metric-throttle-container;
- uses te-link-info-attributes;
- } // te-link-attributes
- } // te-link-config-attributes
-
- grouping te-link-info-attributes {
- leaf link-index {
- type uint64;
- }
- leaf administrative-group {
- type te-types:admin-groups;
- }
- leaf max-link-bandwidth {
- type decimal64 {
- fraction-digits 2;
- }
- }
- leaf max-resv-link-bandwidth {
- type decimal64 {
- fraction-digits 2;
- }
- }
- list unreserved-bandwidth {
- key "priority";
- max-elements "8";
- leaf priority {
- type uint8 {
- range "0..7";
- }
- }
- leaf bandwidth {
- type decimal64 {
- fraction-digits 2;
- }
- }
- }
- leaf te-default-metric {
- type uint32;
- }
- container performance-metric {
- container measurement {
- uses performance-metric-attributes;
- }
- container normality
- {
- uses performance-metric-normality-attributes;
- }
- }
- leaf link-protection-type {
- type enumeration {
- enum "unprotected";
- enum "extra-traffic";
- enum "shared";
- enum "1-for-1";
- enum "1-plus-1";
- enum "enhanced";
- }
- }
- list interface-switching-capability {
- key "switching-capability";
- leaf switching-capability {
- type identityref {
- base te-types:switching-capabilities;
- }
- }
- leaf encoding {
- type identityref {
- base te-types:lsp-encoding-types;
- }
- }
- list max-lsp-bandwidth {
- key "priority";
- max-elements "8";
- leaf priority {
- type uint8 {
- range "0..7";
- }
- }
- leaf bandwidth {
- type decimal64 {
- fraction-digits 2;
- }
- }
- }
- container time-division-multiplex-capable {
- leaf minimum-lsp-bandwidth {
- type decimal64 {
- fraction-digits 2;
- }
- }
- leaf indication {
- type enumeration {
- enum "standard";
- enum "arbitrary";
- }
- }
- }
- list interface-adjustment-capability {
- key "upper-sc";
- leaf upper-sc {
- type identityref {
- base te-types:switching-capabilities;
- }
- }
- leaf upper-encoding {
- type identityref {
- base te-types:lsp-encoding-types;
- }
- }
- list max-lsp-bandwidth {
- key "priority";
- max-elements "8";
- leaf priority {
- type uint8 {
- range "0..7";
- }
- description "Priority.";
- }
- leaf bandwidth {
- type decimal64 {
- fraction-digits 2;
- }
- }
- }
- } // interface-adjustment-capability
- } // interface-switching-capability
- container te-srlgs {
- leaf-list values {
- type te-types:srlg;
- }
- }
- } // te-link-info-attributes
-
- grouping te-link-state-derived {
- leaf oper-status {
- type te-oper-status;
- }
- uses information-source-attributes;
- list alt-information-sources {
- key "information-source";
- uses information-source-attributes;
- uses te-link-info-attributes;
- }
- container recovery {
- leaf restoration-status {
- type te-recovery-status;
- }
- leaf protection-status {
- type te-recovery-status;
- }
- }
- container underlay {
- uses te-link-state-underlay-attributes;
- }
- } // te-link-state-derived
- grouping te-link-state-underlay-attributes {
- leaf dynamic {
- type boolean;
- }
- leaf committed {
- type boolean;
- }
- } // te-link-state-underlay-attributes
-
- grouping te-link-underlay-attributes {
- container underlay-primary-path {
- uses te-topology-ref;
- list path-element {
- key "path-element-id";
- leaf path-element-id {
- type uint32;
- }
- uses te-path-element;
- }
- } // underlay-primary-path
- list underlay-backup-path {
- key "index";
- leaf index {
- type uint32;
- }
- uses te-topology-ref;
- list path-element {
- key "path-element-id";
- leaf path-element-id {
- type uint32;
- }
- uses te-path-element;
- }
- } // underlay-backup-path
- leaf underlay-protection-type {
- type uint16;
- }
- container underlay-trail-src {
- uses nt:tp-ref;
- }
- container underlay-trail-des {
- uses nt:tp-ref;
- }
- } // te-link-underlay-attributes
-
- grouping te-node-augment {
- container te {
- presence "TE support.";
- leaf te-node-id {
- type te-node-id;
- }
-
- container config {
- description
- "Configuration data.";
- uses te-node-config;
- } // config
- container state {
- config false;
- description
- "Operational state data.";
-
- uses te-node-config;
- uses te-node-state-derived;
- } // state
-
- list tunnel-termination-point {
- key "tunnel-tp-id";
- leaf tunnel-tp-id {
- type binary;
- }
- container config {
- uses te-node-tunnel-termination-capability;
- }
-
- container state {
- config false;
- uses te-node-tunnel-termination-capability;
- leaf switching-capability {
- type identityref {
- base te-types:switching-capabilities;
- }
- }
- leaf encoding {
- type identityref {
- base te-types:lsp-encoding-types;
- }
- }
- } // state
-
- } // tunnel-termination-point
- } // te
- } // te-node-augment
-
- grouping te-node-config {
- leaf-list te-node-template {
- if-feature template;
- type leafref {
- path "../../../../../te/templates/node-template/name";
- }
- }
- uses te-node-config-attributes;
- } // te-node-config
-
- grouping te-node-config-attributes {
- container te-node-attributes {
- uses sch:schedules;
- leaf admin-status {
- type te-admin-status;
- description
- "The administrative state of the link.";
- }
- uses te-node-connectivity-matrix;
- uses te-node-info-attributes;
- } // te-node-attributes
- } // te-node-config-attributes
-
- grouping te-node-config-attributes-notification {
- container te-node-attributes {
- uses sch:schedules;
- leaf admin-status {
- type te-admin-status;
- }
- uses te-node-connectivity-matrix-abs;
- uses te-node-info-attributes;
- } // te-node-attributes
- } // te-node-config-attributes-notification
-
- grouping te-node-config-attributes-template {
- container te-node-attributes {
- uses sch:schedules;
- leaf admin-status {
- type te-admin-status;
- }
- uses te-node-info-attributes;
- } // te-node-attributes
- } // te-node-config-attributes-template
-
- grouping te-node-connectivity-matrix {
- list connectivity-matrix {
- key "id";
- leaf id {
- type uint32;
- }
- container from {
- leaf tp-ref {
- type leafref {
- path "../../../../../../nt:t-point/nt:tp-id";
- }
- }
- }
- container to {
- leaf tp-ref {
- type leafref {
- path "../../../../../../nt:t-point/nt:tp-id";
- }
- }
- }
- leaf is-allowed {
- type boolean;
- }
- }
- } // te-node-connectivity-matrix
-
- grouping te-node-connectivity-matrix-abs {
- list connectivity-matrix {
- key "id";
- leaf id {
- type uint32;
- }
- container from {
- uses nt:tp-ref;
- }
- container to {
- uses nt:tp-ref;
- }
- leaf is-allowed {
- type boolean;
- }
- }
- } // te-node-connectivity-matrix-abs
-
- grouping te-node-info-attributes {
- leaf domain-id {
- type uint32;
- }
- leaf is-abstract {
- type empty;
- }
- leaf name {
- type inet:domain-name;
- }
- leaf-list signaling-address {
- type inet:ip-address;
- }
- container underlay-topology {
- if-feature te-topology-hierarchy;
- uses te-topology-ref;
- }
- } // te-node-info-attributes
-
- grouping te-node-state-derived {
- description "Node state attributes in a TE topology.";
- leaf oper-status {
- type te-oper-status;
- }
- leaf is-multi-access-dr {
- type empty;
- }
- uses information-source-attributes;
- list alt-information-sources {
- key "information-source";
- uses information-source-attributes;
- uses te-node-connectivity-matrix;
- uses te-node-info-attributes;
- }
- } // te-node-state-derived
-
- grouping te-node-state-derived-notification {
- description "Node state attributes in a TE topology.";
- leaf oper-status {
- type te-oper-status;
- }
- leaf is-multi-access-dr {
- type empty;
- }
- uses information-source-attributes;
- list alt-information-sources {
- key "information-source";
- uses information-source-attributes;
- uses te-node-connectivity-matrix-abs;
- uses te-node-info-attributes;
- }
- } // te-node-state-derived-notification
-
- grouping te-node-tunnel-termination-capability {
- list termination-capability {
- key "link-tp";
- leaf link-tp {
- type leafref {
- path "../../../../../nt:t-point/nt:tp-id";
- }
- }
- } // termination-capability
- } // te-node-tunnel-termination-capability
-
- grouping te-path-element {
- uses te-types:explicit-route-subobject;
- } // te-path-element
-
- grouping te-termination-point-augment {
-
- container te {
- presence "TE support.";
-
- leaf te-tp-id {
- type te-tp-id;
- mandatory true;
- }
-
- container config {
- uses te-termination-point-config;
- } // config
- container state {
- config false;
- uses te-termination-point-config;
- } // state
- } // te
- } // te-termination-point-augment
-
- grouping te-termination-point-config {
- uses sch:schedules;
- } // te-termination-point-config
-
- grouping te-topologies-augment {
-
- container te {
- presence "TE support.";
-
- container templates {
- list node-template {
- if-feature template;
- key "name";
- leaf name {
- type te-template-name;
- }
- uses template-attributes;
- uses te-node-config-attributes-template;
- } // node-template
-
- list link-template {
- if-feature template;
- key "name";
- leaf name {
- type te-template-name;
- }
- uses template-attributes;
- uses te-link-config-attributes;
- } // link-template
- } // templates
- } // te
- } // te-topologies-augment
-
- grouping te-topology-augment {
-
- container te {
- presence "TE support.";
- leaf provider-id {
- type te-global-id;
- }
- leaf client-id {
- type te-global-id;
- }
- leaf te-topology-id {
- type te-topology-id;
- mandatory true;
- }
-
- container config {
- uses te-topology-config;
- } // config
- container state {
- config false;
- uses te-topology-config;
- } // state
- } // te
- } // te-topology-augment
-
- grouping te-topology-config {
- uses sch:schedules;
- leaf preference {
- type uint8 {
- range "1..255";
- }
- }
- } // te-topology-config
-
- grouping te-topology-ref {
- leaf provider-id-ref {
- type leafref {
- path "/nw:networks/nw:network[nw:network-id = "
- + "current()/../network-id-ref]/tet:te/tet:provider-id";
- require-instance false;
- }
- }
- leaf client-id-ref {
- type leafref {
- path "/nw:networks/nw:network[nw:network-id = "
- + "current()/../network-id-ref]/tet:te/tet:client-id";
- require-instance false;
- }
- }
- leaf te-topology-id-ref {
- type leafref {
- path "/nw:networks/nw:network[nw:network-id = "
- + "current()/../network-id-ref]/tet:te/tet:te-topology-id";
- require-instance false;
- }
- }
- leaf network-id-ref {
- type leafref {
- path "/nw:networks/nw:network/nw:network-id";
- require-instance false;
- }
- }
- } // te-topology-ref
-
- grouping te-topology-type {
- container te-topology {
- presence "Indicates TE topology.";
- }
- } // te-topology-type
-
- grouping template-attributes {
- leaf priority {
- type uint16;
- }
- leaf reference-change-policy {
- type enumeration {
- enum no-action;
- enum not-allowed;
- enum cascade;
- }
- }
- } // template-attributes
-
- /*
- * Configuration data nodes
- */
- augment "/nw:networks/nw:network/nw:network-types" {
- uses te-topology-type;
- }
-
- augment "/nw:networks" {
- uses te-topologies-augment;
- }
-
- augment "/nw:networks/nw:network" {
- uses te-topology-augment;
- }
-
- augment "/nw:networks/nw:network/nw:node" {
- uses te-node-augment;
- }
-
- augment "/nw:networks/nw:network/nt:link" {
- uses te-link-augment;
- }
-
- augment "/nw:networks/nw:network/nw:node/"
- + "nt:t-point" {
- uses te-termination-point-augment;
- }
-
- container te-node-event {
- leaf event-type {
- type te-topology-event-type;
- description "Event type.";
- }
- uses nw:node-ref;
- uses te-topology-type;
- uses tet:te-node-config-attributes-notification;
- uses tet:te-node-state-derived-notification;
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-te-types.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-te-types.yang
deleted file mode 100644
index 206346b..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-te-types.yang
+++ /dev/null
@@ -1,870 +0,0 @@
- module yms-ietf-te-types {
-
- namespace "urn:ietf:params:xml:ns:yang:ietf-te-types";
-
- /* Replace with IANA when assigned */
- prefix "te-types";
-
- import yms-ietf-inet-types {
- prefix inet;
- }
-
- organization
- "IETF Traffic Engineering Architecture and Signaling (TEAS)
- Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/teas/>
- WG List: <mailto:teas@ietf.org>
-
- WG Chair: Lou Berger
- <mailto:lberger@labn.net>
-
- WG Chair: Vishnu Pavan Beeram
- <mailto:vbeeram@juniper.net>
-
- Editor: Tarek Saad
- <mailto:tsaad@cisco.com>
-
- Editor: Rakesh Gandhi
- <mailto:rgandhi@cisco.com>
-
- Editor: Vishnu Pavan Beeram
- <mailto:vbeeram@juniper.net>
-
- Editor: Himanshu Shah
- <mailto:hshah@ciena.com>
-
- Editor: Xufeng Liu
- <mailto:xufeng.liu@ericsson.com>
-
- Editor: Xia Chen
- <mailto:jescia.chenxia@huawei.com>
-
- Editor: Raqib Jones
- <mailto:raqib@Brocade.com>
-
- Editor: Bin Wen
- <mailto:Bin_Wen@cable.comcast.com>";
-
- description
- "This module contains a collection of generally
- useful TE specific YANG data type defintions.";
-
- revision 2016-03-20 {
- description "Latest revision of TE generic types";
- reference "RFC3209";
- }
-
- identity tunnel-type {
- description
- "Base identity from which specific tunnel types are
- derived.";
- }
-
- identity tunnel-p2p {
- base tunnel-type;
- description
- "TE point-to-point tunnel type.";
- }
-
- identity tunnel-p2mp {
- base tunnel-type;
- description
- "TE point-to-multipoint tunnel type.";
- }
-
- identity state-type {
- description
- "Base identity for TE states";
- }
-
- identity state-up {
- base state-type;
- description
- "State up";
- }
-
- identity state-down {
- base state-type;
- description
- "State down";
- }
-
- identity lsp-prot-type {
- description
- "Base identity from which LSP protection types are
- derived.";
- }
-
- identity lsp-prot-unprotected {
- description
- "LSP protection 'Unprotected'";
- reference "RFC4872";
- }
-
- identity lsp-prot-reroute-extra {
- description
- "LSP protection '(Full) Rerouting'";
- reference "RFC4872";
- }
-
- identity lsp-prot-reroute {
- description
- "LSP protection 'Rerouting without Extra-Traffic'";
- reference "RFC4872";
- }
-
- identity lsp-prot-1-for-n {
- description
- "LSP protection '1:N Protection with Extra-Traffic'";
- reference "RFC4872";
- }
-
- identity lsp-prot-unidir-1-to-1 {
- description
- "LSP protection '1+1 Unidirectional Protection'";
- reference "RFC4872";
- }
-
- identity lsp-prot-bidir-1-to-1 {
- description
- "LSP protection '1+1 Bidirectional Protection'";
- reference "RFC4872";
- }
-
- identity switching-capabilities {
- description
- "Base identity for interface switching capabilities";
- }
-
- identity switching-psc1 {
- base switching-capabilities;
- description
- "Packet-Switch Capable-1 (PSC-1)";
- }
-
- identity switching-evpl {
- base switching-capabilities;
- description
- "Ethernet Virtual Private Line (EVPL)";
- }
-
- identity switching-l2sc {
- base switching-capabilities;
- description
- "Layer-2 Switch Capable (L2SC)";
- }
-
- identity switching-tdm {
- base switching-capabilities;
- description
- "Time-Division-Multiplex Capable (TDM)";
- }
-
- identity switching-otn {
- base switching-capabilities;
- description
- "OTN-TDM capable";
- }
-
- identity switching-dcsc {
- base switching-capabilities;
- description
- "Data Channel Switching Capable (DCSC)";
- }
- identity switching-lsc {
- base switching-capabilities;
- description
- "Lambda-Switch Capable (LSC)";
- }
-
- identity switching-fsc {
- base switching-capabilities;
- description
- "Fiber-Switch Capable (FSC)";
- }
-
- identity lsp-encoding-types {
- description
- "Base identity for encoding types";
- }
-
- identity lsp-encoding-packet {
- base lsp-encoding-types;
- description
- "Packet LSP encoding";
- }
-
- identity lsp-encoding-ethernet {
- base lsp-encoding-types;
- description
- "Ethernet LSP encoding";
- }
-
- identity lsp-encoding-pdh {
- base lsp-encoding-types;
- description
- "ANSI/ETSI LSP encoding";
- }
-
- identity lsp-encoding-sdh {
- base lsp-encoding-types;
- description
- "SDH ITU-T G.707 / SONET ANSI T1.105 LSP encoding";
- }
-
- identity lsp-encoding-digital-wrapper {
- base lsp-encoding-types;
- description
- "Digital Wrapper LSP encoding";
- }
-
- identity lsp-encoding-lambda {
- base lsp-encoding-types;
- description
- "Lambda (photonic) LSP encoding";
- }
-
- identity lsp-encoding-fiber {
- base lsp-encoding-types;
- description
- "Fiber LSP encoding";
- }
-
- identity lsp-encoding-fiber-channel {
- base lsp-encoding-types;
- description
- "FiberChannel LSP encoding";
- }
-
- identity lsp-encoding-oduk {
- base lsp-encoding-types;
- description
- "G.709 ODUk (Digital Path)LSP encoding";
- }
-
- identity lsp-encoding-optical-channel {
- base lsp-encoding-types;
- description
- "Line (e.g., 8B/10B) LSP encoding";
- }
-
- identity lsp-encoding-line {
- base lsp-encoding-types;
- description
- "Line (e.g., 8B/10B) LSP encoding";
- }
-
- /* TE basic features */
- feature p2mp-te {
- description
- "Indicates support for P2MP-TE";
- }
-
- feature frr-te {
- description
- "Indicates support for TE FastReroute (FRR)";
- }
-
- feature extended-admin-groups {
- description
- "Indicates support for TE link extended admin
- groups.";
- }
-
- feature named-path-affinities {
- description
- "Indicates support for named path affinities";
- }
-
- feature named-extended-admin-groups {
- description
- "Indicates support for named extended admin groups";
- }
-
- feature named-srlg-groups {
- description
- "Indicates support for named SRLG groups";
- }
-
- feature named-path-constraints {
- description
- "Indicates support for named path constraints";
- }
-
- grouping explicit-route-subobject {
- description
- "The explicit route subobject grouping";
- choice type {
- description
- "The explicit route subobject type";
- case ipv4-address {
- description
- "IPv4 address explicit route subobject";
- leaf v4-address {
- type inet:ipv4-address;
- description
- "An IPv4 address. This address is
- treated as a prefix based on the
- prefix length value below. Bits beyond
- the prefix are ignored on receipt and
- SHOULD be set to zero on transmission.";
- }
- leaf v4-prefix-length {
- type uint8;
- description
- "Length in bits of the IPv4 prefix";
- }
- leaf v4-loose {
- type boolean;
- description
- "Describes whether the object is loose
- if set, or otherwise strict";
- }
- }
- case ipv6-address {
- description
- "IPv6 address Explicit Route Object";
- leaf v6-address {
- type inet:ipv6-address;
- description
- "An IPv6 address. This address is
- treated as a prefix based on the
- prefix length value below. Bits
- beyond the prefix are ignored on
- receipt and SHOULD be set to zero
- on transmission.";
- }
- leaf v6-prefix-length {
- type uint8;
- description
- "Length in bits of the IPv4 prefix";
- }
- leaf v6-loose {
- type boolean;
- description
- "Describes whether the object is loose
- if set, or otherwise strict";
- }
- }
- case as-number {
- leaf as-number {
- type uint16;
- description "AS number";
- }
- description
- "Autonomous System explicit route subobject";
- }
- case unnumbered-link {
- leaf router-id {
- type inet:ip-address;
- description
- "A router-id address";
- }
- leaf interface-id {
- type uint32;
- description "The interface identifier";
- }
- description
- "Unnumbered link explicit route subobject";
- reference
- "RFC3477: Signalling Unnumbered Links in
- RSVP-TE";
- }
- case label {
- leaf value {
- type uint32;
- description "the label value";
- }
- description
- "The Label ERO subobject";
- }
- /* AS domain sequence..? */
- }
- }
-
- grouping record-route-subobject {
- description
- "The record route subobject grouping";
- choice type {
- description
- "The record route subobject type";
- case ipv4-address {
- leaf v4-address {
- type inet:ipv4-address;
- description
- "An IPv4 address. This address is
- treated as a prefix based on the prefix
- length value below. Bits beyond the
- prefix are ignored on receipt and
- SHOULD be set to zero on transmission.";
- }
- leaf v4-prefix-length {
- type uint8;
- description
- "Length in bits of the IPv4 prefix";
- }
- leaf v4-flags {
- type uint8;
- description
- "IPv4 address sub-object flags";
- reference "RFC3209";
- }
- }
- case ipv6-address {
- leaf v6-address {
- type inet:ipv6-address;
- description
- "An IPv6 address. This address is
- treated as a prefix based on the
- prefix length value below. Bits
- beyond the prefix are ignored on
- receipt and SHOULD be set to zero
- on transmission.";
- }
- leaf v6-prefix-length {
- type uint8;
- description
- "Length in bits of the IPv4 prefix";
- }
- leaf v6-flags {
- type uint8;
- description
- "IPv6 address sub-object flags";
- reference "RFC3209";
- }
- }
- case label {
- leaf value {
- type uint32;
- description "the label value";
- }
- leaf flags {
- type uint8;
- description
- "Label sub-object flags";
- reference "RFC3209";
- }
- description
- "The Label ERO subobject";
- }
- }
- }
-
- identity route-usage-type {
- description
- "Base identity for route usage";
- }
-
- identity route-include-ero {
- base route-usage-type;
- description
- "Include ERO from route";
- }
-
- identity route-exclude-ero {
- base route-usage-type;
- description
- "Exclude ERO from route";
- }
-
- identity route-exclude-srlg {
- base route-usage-type;
- description
- "Exclude SRLG from route";
- }
-
- identity path-metric-type {
- description
- "Base identity for path metric type";
- }
-
- identity path-metric-te {
- base path-metric-type;
- description
- "TE path metric";
- }
-
- identity path-metric-igp {
- base path-metric-type;
- description
- "IGP path metric";
- }
-
- identity path-tiebreaker-type {
- description
- "Base identity for path tie-breaker type";
- }
-
- identity path-tiebreaker-minfill {
- base path-tiebreaker-type;
- description
- "Min-Fill LSP path placement";
- }
-
- identity path-tiebreaker-maxfill {
- base path-tiebreaker-type;
- description
- "Max-Fill LSP path placement";
- }
-
- identity path-tiebreaker-randoom {
- base path-tiebreaker-type;
- description
- "Random LSP path placement";
- }
-
- identity bidir-provisioning-mode {
- description
- "Base identity for bidirectional provisioning
- mode.";
- }
-
- identity bidir-provisioning-single-sided {
- base bidir-provisioning-mode;
- description
- "Single-sided bidirectional provioning mode";
- }
-
- identity bidir-provisioning-double-sided {
- base bidir-provisioning-mode;
- description
- "Double-sided bidirectional provioning mode";
- }
-
- identity bidir-association-type {
- description
- "Base identity for bidirectional association type";
- }
-
- identity bidir-assoc-corouted {
- base bidir-association-type;
- description
- "Co-routed bidirectional association type";
- }
-
- identity bidir-assoc-non-corouted {
- base bidir-association-type;
- description
- "Non co-routed bidirectional association type";
- }
-
- identity resource-affinities-type {
- description
- "Base identity for resource affinities";
- }
-
- identity resource-aff-include-all {
- base resource-affinities-type;
- description
- "The set of attribute filters associated with a
- tunnel all of which must be present for a link
- to be acceptable";
- }
-
- identity resource-aff-include-any {
- base resource-affinities-type;
- description
- "The set of attribute filters associated with a
- tunnel any of which must be present for a link
- to be acceptable";
- }
-
- identity resource-aff-exclude-any {
- base resource-affinities-type;
- description
- "The set of attribute filters associated with a
- tunnel any of which renders a link unacceptable";
- }
-
- typedef admin-group {
- type binary {
- length 32;
- }
- description
- "Administrative group/Resource class/Color.";
- }
-
- typedef extended-admin-group {
- type binary;
- description
- "Extended administrative group/Resource class/Color.";
- }
-
- typedef admin-groups {
- type union {
- type admin-group;
- type extended-admin-group;
- }
- description "TE administrative group derived type";
- }
-
- typedef srlg {
- type uint32;
- description "SRLG type";
- }
-
- identity path-computation-srlg-type {
- description
- "Base identity for SRLG path computation";
- }
-
- identity srlg-ignore {
- base path-computation-srlg-type;
- description
- "Ignores SRLGs in path computation";
- }
-
- identity srlg-strict {
- base path-computation-srlg-type;
- description
- "Include strict SRLG check in path computation";
- }
-
- identity srlg-preferred {
- base path-computation-srlg-type;
- description
- "Include preferred SRLG check in path computation";
- }
-
- identity srlg-weighted {
- base path-computation-srlg-type;
- description
- "Include weighted SRLG check in path computation";
- }
-
- typedef te-metric {
- type uint32;
- description
- "TE link metric";
- }
-
- typedef topology-id {
- type string {
- pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
- }
- description
- "An identifier for a topology.";
- }
-
- /**
- * TE tunnel generic groupings
- **/
-
- /* Tunnel path selection parameters */
- grouping tunnel-path-selection {
- description
- "Tunnel path selection properties grouping";
- container path-selection {
- description
- "Tunnel path selection properties container";
- leaf topology {
- type te-types:topology-id;
- description
- "The tunnel path is computed using the specific
- topology identified by this identifier";
- }
- leaf cost-limit {
- type uint32 {
- range "1..4294967295";
- }
- description
- "The tunnel path cost limit.";
- }
- leaf hop-limit {
- type uint8 {
- range "1..255";
- }
- description
- "The tunnel path hop limit.";
- }
- leaf metric-type {
- type identityref {
- base path-metric-type;
- }
- default path-metric-te;
- description
- "The tunnel path metric type.";
- }
- leaf tiebreaker-type {
- type identityref {
- base path-tiebreaker-type;
- }
- default path-tiebreaker-maxfill;
- description
- "The tunnel path computation tie breakers.";
- }
- leaf ignore-overload {
- type boolean;
- description
- "The tunnel path can traverse overloaded node.";
- }
- uses tunnel-path-affinities;
- uses tunnel-path-srlgs;
- }
- }
-
- grouping tunnel-path-affinities {
- description
- "Path affinities grouping";
- container tunnel-path-affinities {
- if-feature named-path-affinities;
- description
- "Path affinities container";
- choice style {
- description
- "Path affinities representation style";
- case values {
- leaf value {
- type uint32 {
- range "0..4294967295";
- }
- description
- "Affinity value";
- }
- leaf mask {
- type uint32 {
- range "0..4294967295";
- }
- description
- "Affinity mask";
- }
- }
- case named {
- list constraints {
- key "usage";
- leaf usage {
- type identityref {
- base resource-affinities-type;
- }
- description "Affinities usage";
- }
- container constraint {
- description
- "Container for named affinities";
- list affinity-names {
- key "name";
- leaf name {
- type string;
- description
- "Affinity name";
- }
- description
- "List of named affinities";
- }
- }
- description
- "List of named affinity constraints";
- }
- }
- }
- }
- }
-
- grouping tunnel-path-srlgs {
- description
- "Path SRLG properties grouping";
- container tunnel-path-srlgs {
- description
- "Path SRLG properties container";
- choice style {
- description
- "Type of SRLG representation";
- case values {
- leaf usage {
- type identityref {
- base route-exclude-srlg;
- }
- description "SRLG usage";
- }
- leaf-list values {
- type te-types:srlg;
- description "SRLG value";
- }
- }
- case named {
- list constraints {
- key "usage";
- leaf usage {
- type identityref {
- base route-exclude-srlg;
- }
- description "SRLG usage";
- }
- container constraint {
- description
- "Container for named SRLG list";
- list srlg-names {
- key "name";
- leaf name {
- type string;
- description
- "The SRLG name";
- }
- description
- "List named SRLGs";
- }
- }
- description
- "List of named SRLG constraints";
- }
- }
- }
- }
- }
-
- grouping tunnel-bidir-assoc-properties {
- description
- "TE tunnel associated bidirectional properties
- grouping";
- container bidirectional {
- description
- "TE tunnel associated bidirectional attributes.";
- container association {
- description
- "Tunnel bidirectional association properties";
- leaf id {
- type uint16;
- description
- "The TE tunnel association identifier.";
- }
- leaf source {
- type inet:ip-address;
- description
- "The TE tunnel association source.";
- }
- leaf global-source {
- type inet:ip-address;
- description
- "The TE tunnel association global
- source.";
- }
- leaf type {
- type identityref {
- base bidir-association-type;
- }
- default bidir-assoc-non-corouted;
- description
- "The TE tunnel association type.";
- }
- leaf provisioing {
- type identityref {
- base bidir-provisioning-mode;
- }
- description
- "Describes the provisioning model of the
- associated bidirectional LSP";
- reference
- "draft-ietf-teas-mpls-tp-rsvpte-ext-
- associated-lsp, section-3.2";
- }
- }
- }
- }
- /*** End of TE tunnel groupings ***/
-
- /**
- * TE interface generic groupings
- **/
- }
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-yang-types.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-yang-types.yang
deleted file mode 100644
index bc248a6..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-ietf-yang-types.yang
+++ /dev/null
@@ -1,490 +0,0 @@
- module yms-ietf-yang-types {
-
- yang-version 1;
-
- namespace
- "urn:ietf:params:xml:ns:yang:ietf-yang-types";
-
- prefix yang;
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/netmod/>
- WG List: <mailto:netmod@ietf.org>
-
- WG Chair: David Kessens
- <mailto:david.kessens@nsn.com>
-
- WG Chair: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>
-
- Editor: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>";
-
- description
- "This module contains a collection of generally useful derived
- YANG data types.
-
- Copyright (c) 2013 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC 6991; see
- the RFC itself for full legal notices.";
-
- revision "2013-07-15" {
- description
- "This revision adds the following new data types:
- - yang-identifier
- - hex-string
- - uuid
- - dotted-quad";
- reference
- "RFC 6991: Common YANG Data Types";
-
- }
-
- revision "2010-09-24" {
- description "Initial revision.";
- reference
- "RFC 6021: Common YANG Data Types";
-
- }
-
-
- typedef counter32 {
- type uint32;
- description
- "The counter32 type represents a non-negative integer
- that monotonically increases until it reaches a
- maximum value of 2^32-1 (4294967295 decimal), when it
- wraps around and starts increasing again from zero.
-
- Counters have no defined 'initial' value, and thus, a
- single value of a counter has (in general) no information
- content. Discontinuities in the monotonically increasing
- value normally occur at re-initialization of the
- management system, and at other times as specified in the
- description of a schema node using this type. If such
- other times can occur, for example, the creation of
- a schema node of type counter32 at times other than
- re-initialization, then a corresponding schema node
- should be defined, with an appropriate type, to indicate
- the last discontinuity.
-
- The counter32 type should not be used for configuration
- schema nodes. A default statement SHOULD NOT be used in
- combination with the type counter32.
-
- In the value set and its semantics, this type is equivalent
- to the Counter32 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2
- (SMIv2)";
-
- }
-
- typedef zero-based-counter32 {
- type counter32;
- default "0";
- description
- "The zero-based-counter32 type represents a counter32
- that has the defined 'initial' value zero.
-
- A schema node of this type will be set to zero (0) on creation
- and will thereafter increase monotonically until it reaches
- a maximum value of 2^32-1 (4294967295 decimal), when it
- wraps around and starts increasing again from zero.
-
- Provided that an application discovers a new schema node
- of this type within the minimum time to wrap, it can use the
- 'initial' value as a delta. It is important for a management
- station to be aware of this minimum time and the actual time
- between polls, and to discard data if the actual time is too
- long or there is no defined minimum time.
-
- In the value set and its semantics, this type is equivalent
- to the ZeroBasedCounter32 textual convention of the SMIv2.";
- reference
- "RFC 4502: Remote Network Monitoring Management Information
- Base Version 2";
-
- }
-
- typedef counter64 {
- type uint64;
- description
- "The counter64 type represents a non-negative integer
- that monotonically increases until it reaches a
- maximum value of 2^64-1 (18446744073709551615 decimal),
- when it wraps around and starts increasing again from zero.
-
- Counters have no defined 'initial' value, and thus, a
- single value of a counter has (in general) no information
- content. Discontinuities in the monotonically increasing
- value normally occur at re-initialization of the
- management system, and at other times as specified in the
- description of a schema node using this type. If such
- other times can occur, for example, the creation of
- a schema node of type counter64 at times other than
- re-initialization, then a corresponding schema node
- should be defined, with an appropriate type, to indicate
- the last discontinuity.
-
- The counter64 type should not be used for configuration
- schema nodes. A default statement SHOULD NOT be used in
- combination with the type counter64.
-
- In the value set and its semantics, this type is equivalent
- to the Counter64 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2
- (SMIv2)";
-
- }
-
- typedef zero-based-counter64 {
- type counter64;
- default "0";
- description
- "The zero-based-counter64 type represents a counter64 that
- has the defined 'initial' value zero.
-
-
-
-
- A schema node of this type will be set to zero (0) on creation
- and will thereafter increase monotonically until it reaches
- a maximum value of 2^64-1 (18446744073709551615 decimal),
- when it wraps around and starts increasing again from zero.
-
- Provided that an application discovers a new schema node
- of this type within the minimum time to wrap, it can use the
- 'initial' value as a delta. It is important for a management
- station to be aware of this minimum time and the actual time
- between polls, and to discard data if the actual time is too
- long or there is no defined minimum time.
-
- In the value set and its semantics, this type is equivalent
- to the ZeroBasedCounter64 textual convention of the SMIv2.";
- reference
- "RFC 2856: Textual Conventions for Additional High Capacity
- Data Types";
-
- }
-
- typedef gauge32 {
- type uint32;
- description
- "The gauge32 type represents a non-negative integer, which
- may increase or decrease, but shall never exceed a maximum
- value, nor fall below a minimum value. The maximum value
- cannot be greater than 2^32-1 (4294967295 decimal), and
- the minimum value cannot be smaller than 0. The value of
- a gauge32 has its maximum value whenever the information
- being modeled is greater than or equal to its maximum
- value, and has its minimum value whenever the information
- being modeled is smaller than or equal to its minimum value.
- If the information being modeled subsequently decreases
- below (increases above) the maximum (minimum) value, the
- gauge32 also decreases (increases).
-
- In the value set and its semantics, this type is equivalent
- to the Gauge32 type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2
- (SMIv2)";
-
- }
-
- typedef gauge64 {
- type uint64;
- description
- "The gauge64 type represents a non-negative integer, which
- may increase or decrease, but shall never exceed a maximum
- value, nor fall below a minimum value. The maximum value
- cannot be greater than 2^64-1 (18446744073709551615), and
- the minimum value cannot be smaller than 0. The value of
- a gauge64 has its maximum value whenever the information
- being modeled is greater than or equal to its maximum
- value, and has its minimum value whenever the information
- being modeled is smaller than or equal to its minimum value.
- If the information being modeled subsequently decreases
- below (increases above) the maximum (minimum) value, the
- gauge64 also decreases (increases).
-
- In the value set and its semantics, this type is equivalent
- to the CounterBasedGauge64 SMIv2 textual convention defined
- in RFC 2856";
- reference
- "RFC 2856: Textual Conventions for Additional High Capacity
- Data Types";
-
- }
-
- typedef object-identifier {
- type string {
- pattern
- '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))(\.(0|([1-9]\d*)))*';
- }
- description
- "The object-identifier type represents administratively
- assigned names in a registration-hierarchical-name tree.
-
- Values of this type are denoted as a sequence of numerical
- non-negative sub-identifier values. Each sub-identifier
- value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers
- are separated by single dots and without any intermediate
- whitespace.
-
- The ASN.1 standard restricts the value space of the first
- sub-identifier to 0, 1, or 2. Furthermore, the value space
- of the second sub-identifier is restricted to the range
- 0 to 39 if the first sub-identifier is 0 or 1. Finally,
- the ASN.1 standard requires that an object identifier
- has always at least two sub-identifiers. The pattern
- captures these restrictions.
-
- Although the number of sub-identifiers is not limited,
- module designers should realize that there may be
- implementations that stick with the SMIv2 limit of 128
- sub-identifiers.
-
- This type is a superset of the SMIv2 OBJECT IDENTIFIER type
- since it is not restricted to 128 sub-identifiers. Hence,
- this type SHOULD NOT be used to represent the SMIv2 OBJECT
- IDENTIFIER type; the object-identifier-128 type SHOULD be
- used instead.";
- reference
- "ISO9834-1: Information technology -- Open Systems
- Interconnection -- Procedures for the operation of OSI
- Registration Authorities: General procedures and top
- arcs of the ASN.1 Object Identifier tree";
-
- }
-
- typedef object-identifier-128 {
- type object-identifier {
- pattern '\d*(\.\d*){1,127}';
- }
- description
- "This type represents object-identifiers restricted to 128
- sub-identifiers.
-
- In the value set and its semantics, this type is equivalent
- to the OBJECT IDENTIFIER type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2
- (SMIv2)";
-
- }
-
- typedef yang-identifier {
- type string {
- length "1..max";
- pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*';
- pattern
- '.|..|[^xX].*|.[^mM].*|..[^lL].*';
- }
- description
- "A YANG identifier string as defined by the 'identifier'
- rule in Section 12 of RFC 6020. An identifier must
- start with an alphabetic character or an underscore
- followed by an arbitrary sequence of alphabetic or
- numeric characters, underscores, hyphens, or dots.
-
- A YANG identifier MUST NOT start with any possible
- combination of the lowercase or uppercase character
- sequence 'xml'.";
- reference
- "RFC 6020: YANG - A Data Modeling Language for the Network
- Configuration Protocol (NETCONF)";
-
- }
-
- typedef date-and-time {
- type string {
- pattern
- '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-]\d{2}:\d{2})';
- }
- description
- "The date-and-time type is a profile of the ISO 8601
- standard for representation of dates and times using the
- Gregorian calendar. The profile is defined by the
- date-time production in Section 5.6 of RFC 3339.
-
- The date-and-time type is compatible with the dateTime XML
- schema type with the following notable exceptions:
-
- (a) The date-and-time type does not allow negative years.
-
- (b) The date-and-time time-offset -00:00 indicates an unknown
- time zone (see RFC 3339) while -00:00 and +00:00 and Z
- all represent the same time zone in dateTime.
-
- (c) The canonical format (see below) of data-and-time values
- differs from the canonical format used by the dateTime XML
- schema type, which requires all times to be in UTC using
- the time-offset 'Z'.
-
- This type is not equivalent to the DateAndTime textual
- convention of the SMIv2 since RFC 3339 uses a different
- separator between full-date and full-time and provides
- higher resolution of time-secfrac.
-
- The canonical format for date-and-time values with a known time
- zone uses a numeric time zone offset that is calculated using
- the device's configured known offset to UTC time. A change of
- the device's offset to UTC time will cause date-and-time values
- to change accordingly. Such changes might happen periodically
- in case a server follows automatically daylight saving time
- (DST) time zone offset changes. The canonical format for
- date-and-time values with an unknown time zone (usually
- referring to the notion of local time) uses the time-offset
- -00:00.";
- reference
- "RFC 3339: Date and Time on the Internet: Timestamps
- RFC 2579: Textual Conventions for SMIv2
- XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
-
- }
-
- typedef timeticks {
- type uint32;
- description
- "The timeticks type represents a non-negative integer that
- represents the time, modulo 2^32 (4294967296 decimal), in
- hundredths of a second between two epochs. When a schema
- node is defined that uses this type, the description of
- the schema node identifies both of the reference epochs.
-
- In the value set and its semantics, this type is equivalent
- to the TimeTicks type of the SMIv2.";
- reference
- "RFC 2578: Structure of Management Information Version 2
- (SMIv2)";
-
- }
-
- typedef timestamp {
- type timeticks;
- description
- "The timestamp type represents the value of an associated
- timeticks schema node at which a specific occurrence
- happened. The specific occurrence must be defined in the
- description of any schema node defined using this type. When
- the specific occurrence occurred prior to the last time the
- associated timeticks attribute was zero, then the timestamp
- value is zero. Note that this requires all timestamp values
- to be reset to zero when the value of the associated timeticks
- attribute reaches 497+ days and wraps around to zero.
-
- The associated timeticks schema node must be specified
- in the description of any schema node using this type.
-
- In the value set and its semantics, this type is equivalent
- to the TimeStamp textual convention of the SMIv2.";
- reference
- "RFC 2579: Textual Conventions for SMIv2";
-
- }
-
- typedef phys-address {
- type string {
- pattern
- '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
- }
- description
- "Represents media- or physical-level addresses represented
- as a sequence octets, each octet represented by two hexadecimal
- numbers. Octets are separated by colons. The canonical
- representation uses lowercase characters.
-
- In the value set and its semantics, this type is equivalent
- to the PhysAddress textual convention of the SMIv2.";
- reference
- "RFC 2579: Textual Conventions for SMIv2";
-
- }
-
- typedef mac-address {
- type string {
- pattern
- '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
- }
- description
- "The mac-address type represents an IEEE 802 MAC address.
- The canonical representation uses lowercase characters.
-
- In the value set and its semantics, this type is equivalent
- to the MacAddress textual convention of the SMIv2.";
- reference
- "IEEE 802: IEEE Standard for Local and Metropolitan Area
- Networks: Overview and Architecture
- RFC 2579: Textual Conventions for SMIv2";
-
- }
-
- typedef xpath1.0 {
- type string;
- description
- "This type represents an XPATH 1.0 expression.
-
- When a schema node is defined that uses this type, the
- description of the schema node MUST specify the XPath
- context in which the XPath expression is evaluated.";
- reference
- "XPATH: XML Path Language (XPath) Version 1.0";
-
- }
-
- typedef hex-string {
- type string {
- pattern
- '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
- }
- description
- "A hexadecimal string with octets represented as hex digits
- separated by colons. The canonical representation uses
- lowercase characters.";
- }
-
- typedef uuid {
- type string {
- pattern
- '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
- }
- description
- "A Universally Unique IDentifier in the string representation
- defined in RFC 4122. The canonical representation uses
- lowercase characters.
-
- The following is an example of a UUID in string representation:
- f81d4fae-7dec-11d0-a765-00a0c91e6bf6
- ";
- reference
- "RFC 4122: A Universally Unique IDentifier (UUID) URN
- Namespace";
-
- }
-
- typedef dotted-quad {
- type string {
- pattern
- '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
- }
- description
- "An unsigned 32-bit number expressed in the dotted-quad
- notation, i.e., four octets written as decimal numbers
- and separated with the '.' (full stop) character.";
- }
- } // module ietf-yang-types
-
diff --git a/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-network-topology.yang b/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-network-topology.yang
deleted file mode 100644
index 4700365..0000000
--- a/apps/yms/ut/src/test/resources/ydtTestYangFiles/yms-network-topology.yang
+++ /dev/null
@@ -1,304 +0,0 @@
- module yms-network-topology {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology";
- prefix lnk;
-
- import yms-ietf-inet-types {
- prefix inet;
- }
- import yms-ietf-network {
- prefix nd;
- }
-
- organization
- "IETF I2RS (Interface to the Routing System) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/i2rs/>
- WG List: <mailto:i2rs@ietf.org>
-
- WG Chair: Susan Hares
- <mailto:shares@ndzh.com>
-
- WG Chair: Jeffrey Haas
- <mailto:jhaas@pfrc.org>
-
- Editor: Alexander Clemm
- <mailto:alex@cisco.com>
-
- Editor: Jan Medved
- <mailto:jmedved@cisco.com>
-
- Editor: Robert Varga
- <mailto:rovarga@cisco.com>
-
- Editor: Tony Tkacik
- <mailto:ttkacik@cisco.com>
-
- Editor: Nitin Bahadur
- <mailto:nitin_bahadur@yahoo.com>
-
- Editor: Hariharan Ananthakrishnan
- <mailto:hari@packetdesign.com>";
-
- description
- "This module defines a common base model for network topology,
- augmenting the base network model with links to connect nodes,
- as well as termination points to terminate links on nodes.
-
- Copyright (c) 2015 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of
- draft-ietf-i2rs-yang-network-topo-02;
- see the RFC itself for full legal notices.
-
- NOTE TO RFC EDITOR: Please replace above reference to
- draft-ietf-i2rs-yang-network-topo-02 with RFC
- number when published (i.e. RFC xxxx).";
-
- revision 2015-12-08 {
- description
- "Initial revision.
- NOTE TO RFC EDITOR: Please replace the following reference
- to draft-ietf-i2rs-yang-network-topo-02 with
- RFC number when published (i.e. RFC xxxx).";
- reference
- "draft-ietf-i2rs-yang-network-topo-02.";
- }
-
- typedef link-id {
- type inet:uri;
- description
- "An identifier for a link in a topology.
- The identifier SHOULD be chosen such that the same link in a
- real network topology will always be identified through the
- same identifier, even if the model is instantiated in
- separate datastores. An implementation MAY choose to capture
- semantics in the identifier, for example to indicate the type
- of link and/or the type of topology that the link is a part
- of.";
- }
-
- typedef tp-id {
- type inet:uri;
- description
- "An identifier for termination points on a node.
- The identifier SHOULD be chosen such that the same TP in a
- real network topology will always be identified through the
- same identifier, even if the model is instantiated in
- separate datastores. An implementation MAY choose to capture
- semantics in the identifier, for example to indicate the type
- of TP and/or the type of node and topology that the TP is a
- part of.";
- }
- grouping link-ref {
- description
- "References a link in a specific network.";
- leaf link-ref {
- type leafref {
- path "/nd:networks/nd:network[nd:network-id=current()/../"+
- "network-ref]/lnk:link/lnk:link-id";
- require-instance false;
- }
- description
- "A type for an absolute reference a link instance.
- (This type should not be used for relative references.
- In such a case, a relative path should be used instead.)";
- }
- uses nd:network-ref;
- }
-
- grouping tp-ref {
- description
- "References a termination point in a specific node.";
- leaf tp-ref {
- type leafref {
- path "/nd:networks/nd:network[nd:network-id=current()/../"+
- "network-ref]/nd:node[nd:node-id=current()/../"+
- "node-ref]/lnk:t-point/lnk:tp-id";
- require-instance false;
- }
- description
- "A type for an absolute reference to a termination point.
- (This type should not be used for relative references.
- In such a case, a relative path should be used instead.)";
- }
- uses nd:node-ref;
- }
-
- augment "/nd:networks/nd:network" {
- description
- "Add links to the network model.";
- list link {
- key "link-id";
- description
- "A Network Link connects a by Local (Source) node and
- a Remote (Destination) Network Nodes via a set of the
- nodes' termination points.
- As it is possible to have several links between the same
- source and destination nodes, and as a link could
- potentially be re-homed between termination points, to
- ensure that we would always know to distinguish between
- links, every link is identified by a dedicated link
- identifier.
- Note that a link models a point-to-point link, not a
- multipoint link.
- Layering dependencies on links in underlay topologies are
- not represented as the layering information of nodes and of
- termination points is sufficient.";
- container source {
- description
- "This container holds the logical source of a particular
- link.";
- leaf source-node {
- type leafref {
- path "../../../nd:node/nd:node-id";
- }
- mandatory true;
- description
- "Source node identifier, must be in same topology.";
- }
- leaf source-tp {
- type leafref {
- path "../../../nd:node[nd:node-id=current()/../"+
- "source-node]/t-point/tp-id";
- }
- description
- "Termination point within source node that terminates
- the link.";
- }
- }
- container destination {
- description
- "This container holds the logical destination of a
- particular link.";
- leaf dest-node {
- type leafref {
- path "../../../nd:node/nd:node-id";
- }
- mandatory true;
- description
- "Destination node identifier, must be in the same
- network.";
- }
- leaf dest-tp {
- type leafref {
- path "../../../nd:node[nd:node-id=current()/../"+
- "dest-node]/t-point/tp-id";
- }
- description
- "Termination point within destination node that
- terminates the link.";
- }
- }
- leaf link-id {
- type link-id;
- description
- "The identifier of a link in the topology.
- A link is specific to a topology to which it belongs.";
- }
- list supporting-link {
- key "network-ref link-ref";
- description
- "Identifies the link, or links, that this link
- is dependent on.";
- leaf network-ref {
- type leafref {
- path "../../../nd:supporting-network/nd:network-ref";
- require-instance false;
- }
- description
- "This leaf identifies in which underlay topology
- supporting link is present.";
- }
- leaf link-ref {
- type leafref {
- path "/nd:networks/nd:network[nd:network-id=current()/"+
- "../network-ref]/link/link-id";
- require-instance false;
- }
- description
- "This leaf identifies a link which is a part
- of this link's underlay. Reference loops, in which
- a link identifies itself as its underlay, either
- directly or transitively, are not allowed.";
- }
- }
- }
-
- leaf link-id {
- type link-id;
- description
- "The identifier of a link in the topology.
- A link is specific to a topology to which it belongs.";
- }
- }
- augment "/nd:networks/nd:network/nd:node" {
- description
- "Augment termination points which terminate links.
- Termination points can ultimately be mapped to interfaces.";
- list t-point {
- key "tp-id";
- description
- "A termination point can terminate a link.
- Depending on the type of topology, a termination point
- could, for example, refer to a port or an interface.";
- leaf tp-id {
- type tp-id;
- description
- "Termination point identifier.";
- }
- list supporting-termination-point {
- key "network-ref node-ref tp-ref";
- description
- "The leaf list identifies any termination points that
- the termination point is dependent on, or maps onto.
- Those termination points will themselves be contained
- in a supporting node.
- This dependency information can be inferred from
- the dependencies between links. For this reason,
- this item is not separately configurable. Hence no
- corresponding constraint needs to be articulated.
- The corresponding information is simply provided by the
- implementing system.";
- leaf network-ref {
- type leafref {
- path "../../../nd:supporting-node/nd:network-ref";
- require-instance false;
- }
- description
- "This leaf identifies in which topology the
- supporting termination point is present.";
- }
- leaf node-ref {
- type leafref {
- path "../../../nd:supporting-node/nd:node-ref";
- require-instance false;
- }
- description
- "This leaf identifies in which node the supporting
- termination point is present.";
- }
- leaf tp-ref {
- type leafref {
- path "/nd:networks/nd:network[nd:network-id=current()/"+
- "../network-ref]/nd:node[nd:node-id=current()/../"+
- "node-ref]/t-point/tp-id";
- require-instance false;
- }
- description
- "Reference to the underlay node, must be in a
- different topology";
- }
- }
- }
- }
- }
diff --git a/apps/yms/ut/src/test/resources/ysrTestYangFiles/CheckWithNamespace.yang b/apps/yms/ut/src/test/resources/ysrTestYangFiles/CheckWithNamespace.yang
deleted file mode 100644
index 7e5726e..0000000
--- a/apps/yms/ut/src/test/resources/ysrTestYangFiles/CheckWithNamespace.yang
+++ /dev/null
@@ -1,80 +0,0 @@
- module check {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network4:check:namespace";
- prefix nd;
-
- organization
- "IETF I2RS (Interface to the Routing System) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/i2rs/>
- WG List: <mailto:i2rs@ietf.org>
-
- WG Chair: Susan Hares
- <mailto:shares@ndzh.com>
-
- WG Chair: Jeffrey Haas
- <mailto:jhaas@pfrc.org>
-
- Editor: Alexander Clemm
- <mailto:alex@cisco.com>
-
- Editor: Jan Medved
- <mailto:jmedved@cisco.com>
-
- Editor: Robert Varga
- <mailto:rovarga@cisco.com>
-
- Editor: Tony Tkacik
- <mailto:ttkacik@cisco.com>
-
- Editor: Nitin Bahadur
- <mailto:nitin_bahadur@yahoo.com>
-
- Editor: Hariharan Ananthakrishnan
- <mailto:hari@packetdesign.com>";
-
- description
- "This module defines a common base model for a collection
- of nodes in a network. Node definitions are further used
- in network topologies and inventories.
-
- Copyright (c) 2015 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of
- draft-ietf-i2rs-yang-network-topo-02;
- see the RFC itself for full legal notices.
-
- NOTE TO RFC EDITOR: Please replace above reference to
- draft-ietf-i2rs-yang-network-topo-02 with RFC
- number when published (i.e. RFC xxxx).";
-
- revision 2015-12-08 {
- description
- "Initial revision.
- NOTE TO RFC EDITOR: Please replace the following reference
- to draft-ietf-i2rs-yang-network-topo-02 with
- RFC number when published (i.e. RFC xxxx).";
- reference
- "draft-ietf-i2rs-yang-network-topo-02";
- }
-
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/norev.yang b/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/norev.yang
deleted file mode 100644
index 23eaaba..0000000
--- a/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/norev.yang
+++ /dev/null
@@ -1,85 +0,0 @@
- module ietf-network4 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
- prefix nd;
-
- organization
- "IETF I2RS (Interface to the Routing System) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/i2rs/>
- WG List: <mailto:i2rs@ietf.org>
-
- WG Chair: Susan Hares
- <mailto:shares@ndzh.com>
-
- WG Chair: Jeffrey Haas
- <mailto:jhaas@pfrc.org>
-
- Editor: Alexander Clemm
- <mailto:alex@cisco.com>
-
- Editor: Jan Medved
- <mailto:jmedved@cisco.com>
-
- Editor: Robert Varga
- <mailto:rovarga@cisco.com>
-
- Editor: Tony Tkacik
- <mailto:ttkacik@cisco.com>
-
- Editor: Nitin Bahadur
- <mailto:nitin_bahadur@yahoo.com>
-
- Editor: Hariharan Ananthakrishnan
- <mailto:hari@packetdesign.com>";
-
- description
- "This module defines a common base model for a collection
- of nodes in a network. Node definitions are further used
- in network topologies and inventories.
-
- Copyright (c) 2015 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of
- draft-ietf-i2rs-yang-network-topo-02;
- see the RFC itself for full legal notices.
-
- NOTE TO RFC EDITOR: Please replace above reference to
- draft-ietf-i2rs-yang-network-topo-02 with RFC
- number when published (i.e. RFC xxxx).";
-
- notification network-up {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
- notification network-down {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
-
-}
diff --git a/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/withrev.yang b/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/withrev.yang
deleted file mode 100644
index ab0cffa..0000000
--- a/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/withrev.yang
+++ /dev/null
@@ -1,95 +0,0 @@
- module ietf-network4 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
- prefix nd;
-
- organization
- "IETF I2RS (Interface to the Routing System) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/i2rs/>
- WG List: <mailto:i2rs@ietf.org>
-
- WG Chair: Susan Hares
- <mailto:shares@ndzh.com>
-
- WG Chair: Jeffrey Haas
- <mailto:jhaas@pfrc.org>
-
- Editor: Alexander Clemm
- <mailto:alex@cisco.com>
-
- Editor: Jan Medved
- <mailto:jmedved@cisco.com>
-
- Editor: Robert Varga
- <mailto:rovarga@cisco.com>
-
- Editor: Tony Tkacik
- <mailto:ttkacik@cisco.com>
-
- Editor: Nitin Bahadur
- <mailto:nitin_bahadur@yahoo.com>
-
- Editor: Hariharan Ananthakrishnan
- <mailto:hari@packetdesign.com>";
-
- description
- "This module defines a common base model for a collection
- of nodes in a network. Node definitions are further used
- in network topologies and inventories.
-
- Copyright (c) 2015 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of
- draft-ietf-i2rs-yang-network-topo-02;
- see the RFC itself for full legal notices.
-
- NOTE TO RFC EDITOR: Please replace above reference to
- draft-ietf-i2rs-yang-network-topo-02 with RFC
- number when published (i.e. RFC xxxx).";
-
- revision 2015-12-08 {
- description
- "Initial revision.
- NOTE TO RFC EDITOR: Please replace the following reference
- to draft-ietf-i2rs-yang-network-topo-02 with
- RFC number when published (i.e. RFC xxxx).";
- reference
- "draft-ietf-i2rs-yang-network-topo-02";
- }
-
- notification network-up {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
- notification network-down {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
-
-}
diff --git a/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/withrev2.yang b/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/withrev2.yang
deleted file mode 100644
index f7c9a16..0000000
--- a/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/withrev2.yang
+++ /dev/null
@@ -1,95 +0,0 @@
- module ietf-network4 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
- prefix nd;
-
- organization
- "IETF I2RS (Interface to the Routing System) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/i2rs/>
- WG List: <mailto:i2rs@ietf.org>
-
- WG Chair: Susan Hares
- <mailto:shares@ndzh.com>
-
- WG Chair: Jeffrey Haas
- <mailto:jhaas@pfrc.org>
-
- Editor: Alexander Clemm
- <mailto:alex@cisco.com>
-
- Editor: Jan Medved
- <mailto:jmedved@cisco.com>
-
- Editor: Robert Varga
- <mailto:rovarga@cisco.com>
-
- Editor: Tony Tkacik
- <mailto:ttkacik@cisco.com>
-
- Editor: Nitin Bahadur
- <mailto:nitin_bahadur@yahoo.com>
-
- Editor: Hariharan Ananthakrishnan
- <mailto:hari@packetdesign.com>";
-
- description
- "This module defines a common base model for a collection
- of nodes in a network. Node definitions are further used
- in network topologies and inventories.
-
- Copyright (c) 2015 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of
- draft-ietf-i2rs-yang-network-topo-02;
- see the RFC itself for full legal notices.
-
- NOTE TO RFC EDITOR: Please replace above reference to
- draft-ietf-i2rs-yang-network-topo-02 with RFC
- number when published (i.e. RFC xxxx).";
-
- revision 2016-12-08 {
- description
- "Initial revision.
- NOTE TO RFC EDITOR: Please replace the following reference
- to draft-ietf-i2rs-yang-network-topo-02 with
- RFC number when published (i.e. RFC xxxx).";
- reference
- "draft-ietf-i2rs-yang-network-topo-02";
- }
-
- notification network-up {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
- notification network-down {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
-
-}
diff --git a/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/withrev3.yang b/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/withrev3.yang
deleted file mode 100644
index f4abc06..0000000
--- a/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/withrev3.yang
+++ /dev/null
@@ -1,95 +0,0 @@
- module ietf-network4 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
- prefix nd;
-
- organization
- "IETF I2RS (Interface to the Routing System) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/i2rs/>
- WG List: <mailto:i2rs@ietf.org>
-
- WG Chair: Susan Hares
- <mailto:shares@ndzh.com>
-
- WG Chair: Jeffrey Haas
- <mailto:jhaas@pfrc.org>
-
- Editor: Alexander Clemm
- <mailto:alex@cisco.com>
-
- Editor: Jan Medved
- <mailto:jmedved@cisco.com>
-
- Editor: Robert Varga
- <mailto:rovarga@cisco.com>
-
- Editor: Tony Tkacik
- <mailto:ttkacik@cisco.com>
-
- Editor: Nitin Bahadur
- <mailto:nitin_bahadur@yahoo.com>
-
- Editor: Hariharan Ananthakrishnan
- <mailto:hari@packetdesign.com>";
-
- description
- "This module defines a common base model for a collection
- of nodes in a network. Node definitions are further used
- in network topologies and inventories.
-
- Copyright (c) 2015 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of
- draft-ietf-i2rs-yang-network-topo-02;
- see the RFC itself for full legal notices.
-
- NOTE TO RFC EDITOR: Please replace above reference to
- draft-ietf-i2rs-yang-network-topo-02 with RFC
- number when published (i.e. RFC xxxx).";
-
- revision 2014-12-08 {
- description
- "Initial revision.
- NOTE TO RFC EDITOR: Please replace the following reference
- to draft-ietf-i2rs-yang-network-topo-02 with
- RFC number when published (i.e. RFC xxxx).";
- reference
- "draft-ietf-i2rs-yang-network-topo-02";
- }
-
- notification network-up {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
- notification network-down {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
-
-}
diff --git a/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/withrev4.yang b/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/withrev4.yang
deleted file mode 100644
index 9352fb4..0000000
--- a/apps/yms/ut/src/test/resources/ysrTestYangFiles/multiRevisions/withrev4.yang
+++ /dev/null
@@ -1,76 +0,0 @@
- module ietf-network4 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network4";
- prefix nd;
-
- organization
- "IETF I2RS (Interface to the Routing System) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/i2rs/>
- WG List: <mailto:i2rs@ietf.org>
-
- WG Chair: Susan Hares
- <mailto:shares@ndzh.com>
-
- WG Chair: Jeffrey Haas
- <mailto:jhaas@pfrc.org>
-
- Editor: Alexander Clemm
- <mailto:alex@cisco.com>
-
- Editor: Jan Medved
- <mailto:jmedved@cisco.com>
-
- Editor: Robert Varga
- <mailto:rovarga@cisco.com>
-
- Editor: Tony Tkacik
- <mailto:ttkacik@cisco.com>
-
- Editor: Nitin Bahadur
- <mailto:nitin_bahadur@yahoo.com>
-
- Editor: Hariharan Ananthakrishnan
- <mailto:hari@packetdesign.com>";
-
- description
- "This module defines a common base model for a collection
- of nodes in a network. Node definitions are further used
- in network topologies and inventories.
-
- Copyright (c) 2015 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of
- draft-ietf-i2rs-yang-network-topo-02;
- see the RFC itself for full legal notices.
-
- NOTE TO RFC EDITOR: Please replace above reference to
- draft-ietf-i2rs-yang-network-topo-02 with RFC
- number when published (i.e. RFC xxxx).";
-
- revision 2017-12-08 {
- description
- "Initial revision.
- NOTE TO RFC EDITOR: Please replace the following reference
- to draft-ietf-i2rs-yang-network-topo-02 with
- RFC number when published (i.e. RFC xxxx).";
- reference
- "draft-ietf-i2rs-yang-network-topo-02";
- }
-
- container network {
- leaf ip {
- type int32;
- }
- }
-
-}
diff --git a/apps/yms/ut/src/test/resources/ysrTestYangFiles/withNotification/ysr1.yang b/apps/yms/ut/src/test/resources/ysrTestYangFiles/withNotification/ysr1.yang
deleted file mode 100644
index a58e99d..0000000
--- a/apps/yms/ut/src/test/resources/ysrTestYangFiles/withNotification/ysr1.yang
+++ /dev/null
@@ -1,95 +0,0 @@
- module ietf-network1 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network1";
- prefix nd;
-
- organization
- "IETF I2RS (Interface to the Routing System) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/i2rs/>
- WG List: <mailto:i2rs@ietf.org>
-
- WG Chair: Susan Hares
- <mailto:shares@ndzh.com>
-
- WG Chair: Jeffrey Haas
- <mailto:jhaas@pfrc.org>
-
- Editor: Alexander Clemm
- <mailto:alex@cisco.com>
-
- Editor: Jan Medved
- <mailto:jmedved@cisco.com>
-
- Editor: Robert Varga
- <mailto:rovarga@cisco.com>
-
- Editor: Tony Tkacik
- <mailto:ttkacik@cisco.com>
-
- Editor: Nitin Bahadur
- <mailto:nitin_bahadur@yahoo.com>
-
- Editor: Hariharan Ananthakrishnan
- <mailto:hari@packetdesign.com>";
-
- description
- "This module defines a common base model for a collection
- of nodes in a network. Node definitions are further used
- in network topologies and inventories.
-
- Copyright (c) 2015 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of
- draft-ietf-i2rs-yang-network-topo-02;
- see the RFC itself for full legal notices.
-
- NOTE TO RFC EDITOR: Please replace above reference to
- draft-ietf-i2rs-yang-network-topo-02 with RFC
- number when published (i.e. RFC xxxx).";
-
- revision 2015-12-08 {
- description
- "Initial revision.
- NOTE TO RFC EDITOR: Please replace the following reference
- to draft-ietf-i2rs-yang-network-topo-02 with
- RFC number when published (i.e. RFC xxxx).";
- reference
- "draft-ietf-i2rs-yang-network-topo-02";
- }
-
- notification network-up {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
- notification network-down {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
-
-}
diff --git a/apps/yms/ut/src/test/resources/ysrTestYangFiles/withNotification/ysr2.yang b/apps/yms/ut/src/test/resources/ysrTestYangFiles/withNotification/ysr2.yang
deleted file mode 100644
index c241068..0000000
--- a/apps/yms/ut/src/test/resources/ysrTestYangFiles/withNotification/ysr2.yang
+++ /dev/null
@@ -1,95 +0,0 @@
- module ietf-network2 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network2";
- prefix nd;
-
- organization
- "IETF I2RS (Interface to the Routing System) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/i2rs/>
- WG List: <mailto:i2rs@ietf.org>
-
- WG Chair: Susan Hares
- <mailto:shares@ndzh.com>
-
- WG Chair: Jeffrey Haas
- <mailto:jhaas@pfrc.org>
-
- Editor: Alexander Clemm
- <mailto:alex@cisco.com>
-
- Editor: Jan Medved
- <mailto:jmedved@cisco.com>
-
- Editor: Robert Varga
- <mailto:rovarga@cisco.com>
-
- Editor: Tony Tkacik
- <mailto:ttkacik@cisco.com>
-
- Editor: Nitin Bahadur
- <mailto:nitin_bahadur@yahoo.com>
-
- Editor: Hariharan Ananthakrishnan
- <mailto:hari@packetdesign.com>";
-
- description
- "This module defines a common base model for a collection
- of nodes in a network. Node definitions are further used
- in network topologies and inventories.
-
- Copyright (c) 2015 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of
- draft-ietf-i2rs-yang-network-topo-02;
- see the RFC itself for full legal notices.
-
- NOTE TO RFC EDITOR: Please replace above reference to
- draft-ietf-i2rs-yang-network-topo-02 with RFC
- number when published (i.e. RFC xxxx).";
-
- revision 2015-12-08 {
- description
- "Initial revision.
- NOTE TO RFC EDITOR: Please replace the following reference
- to draft-ietf-i2rs-yang-network-topo-02 with
- RFC number when published (i.e. RFC xxxx).";
- reference
- "draft-ietf-i2rs-yang-network-topo-02";
- }
-
- notification network-up {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
- notification network-down {
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
- }
-
-}
diff --git a/apps/yms/ut/src/test/resources/ysrTestYangFiles/withoutNotification/ysr3.yang b/apps/yms/ut/src/test/resources/ysrTestYangFiles/withoutNotification/ysr3.yang
deleted file mode 100644
index 0e86062..0000000
--- a/apps/yms/ut/src/test/resources/ysrTestYangFiles/withoutNotification/ysr3.yang
+++ /dev/null
@@ -1,81 +0,0 @@
- module ietf-network3 {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:ietf-network3";
- prefix nd;
-
- organization
- "IETF I2RS (Interface to the Routing System) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/i2rs/>
- WG List: <mailto:i2rs@ietf.org>
-
- WG Chair: Susan Hares
- <mailto:shares@ndzh.com>
-
- WG Chair: Jeffrey Haas
- <mailto:jhaas@pfrc.org>
-
- Editor: Alexander Clemm
- <mailto:alex@cisco.com>
-
- Editor: Jan Medved
- <mailto:jmedved@cisco.com>
-
- Editor: Robert Varga
- <mailto:rovarga@cisco.com>
-
- Editor: Tony Tkacik
- <mailto:ttkacik@cisco.com>
-
- Editor: Nitin Bahadur
- <mailto:nitin_bahadur@yahoo.com>
-
- Editor: Hariharan Ananthakrishnan
- <mailto:hari@packetdesign.com>";
-
- description
- "This module defines a common base model for a collection
- of nodes in a network. Node definitions are further used
- in network topologies and inventories.
-
- Copyright (c) 2015 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of
- draft-ietf-i2rs-yang-network-topo-02;
- see the RFC itself for full legal notices.
-
- NOTE TO RFC EDITOR: Please replace above reference to
- draft-ietf-i2rs-yang-network-topo-02 with RFC
- number when published (i.e. RFC xxxx).";
-
- revision 2015-12-08 {
- description
- "Initial revision.
- NOTE TO RFC EDITOR: Please replace the following reference
- to draft-ietf-i2rs-yang-network-topo-02 with
- RFC number when published (i.e. RFC xxxx).";
- reference
- "draft-ietf-i2rs-yang-network-topo-02";
- }
-
- container networks {
- leaf id {
- type int32;
- }
- container network {
- leaf ip-address {
- type int32;
- }
- }
- }
-
-}
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbAugmentForRpcInput.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbAugmentForRpcInput.yang
deleted file mode 100644
index 2e8d1b3..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbAugmentForRpcInput.yang
+++ /dev/null
@@ -1,20 +0,0 @@
-module YtbAugmentForRpcInput {
- yang-version 1;
- namespace "yms:test:ytb:augment:for:rpc:input";
- prefix "sch";
- import YtbRpcResponseWithAdvancedInputAndOutput {
- prefix rpc;
- }
- revision "2016-08-26";
-
- augment "/rpc:activate-software-image/rpc:output/" {
- choice selection {
- list value-in {
- key "kinetic";
- leaf kinetic {
- type "string";
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbAugmentForRpcInput2.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbAugmentForRpcInput2.yang
deleted file mode 100644
index af59b47..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbAugmentForRpcInput2.yang
+++ /dev/null
@@ -1,17 +0,0 @@
-module YtbAugmentForRpcInput2 {
- yang-version 1;
- namespace "yms:test:ytb:augment:for:rpc:input";
- prefix "sch";
- import YtbRpcResponseWithAdvancedInputAndOutput {
- prefix input;
- }
- revision "2016-08-26";
- augment "/input:activate-software-image/input:output/" {
- list friction {
- key "speed";
- leaf speed {
- type uint64;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbAugmentFromAnotherFile.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbAugmentFromAnotherFile.yang
deleted file mode 100644
index 990bf55..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbAugmentFromAnotherFile.yang
+++ /dev/null
@@ -1,41 +0,0 @@
-module YtbAugmentFromAnotherFile {
- yang-version 1;
- namespace "yms:test:ytb:augment:from:another:file";
- prefix "sch";
- import yms-ietf-network {
- prefix nd;
- }
- revision "2016-08-26";
-
- augment "/nd:networks/nd:network/nd:node" {
- list termination-point {
- key "tp-id";
- leaf tp-id {
- type string;
- }
- list supporting-termination-point {
- key "network-ref node-ref tp-ref";
- leaf network-ref {
- type leafref {
- path "../../../nd:supporting-node/nd:network-ref";
- require-instance false;
- }
- }
- leaf node-ref {
- type leafref {
- path "../../../nd:supporting-node/nd:node-ref";
- require-instance false;
- }
- }
- leaf tp-ref {
- type leafref {
- path "/nd:networks/nd:network[nd:network-id=current()/"+
- "../network-ref]/nd:node[nd:node-id=current()/../"+
- "node-ref]/termination-point/tp-id";
- require-instance false;
- }
- }
- }
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbChoiceWithContainerAndLeafList.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbChoiceWithContainerAndLeafList.yang
deleted file mode 100644
index 9ae462e..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbChoiceWithContainerAndLeafList.yang
+++ /dev/null
@@ -1,76 +0,0 @@
-module YtbChoiceWithContainerAndLeafList {
- yang-version 1;
- namespace "yms:test:ytb:choice:with:container:and:leaf:list";
- prefix "sch";
- revision "2016-08-26";
- leaf refer {
- type binary;
- }
- rpc invalid1 {
- input {
- leaf value {
- type string;
- }
- }
- output {
- leaf value {
- type string;
- }
- }
- }
- choice content-test {
- leaf-list list-items {
- type leafref {
- path "/refer";
- }
- }
- container choice-container {
- list predict {
- config "false";
- container reproduce {
- leaf catch {
- type int16;
- }
- }
- }
- }
- case valid {
- list validlistincase {
- config "false";
- leaf validity {
- type int32;
- }
- }
- }
- case invalid {
- leaf create-invalid {
- type uint16;
- }
- }
- }
- notification invalid {
- leaf value {
- type string;
- }
- }
- notification invalid2 {
- list node {
- config false;
- leaf value {
- type string;
- }
- }
- }
- choice current-value {
- case ytb-present {
- leaf-list represent {
- type uint32;
- }
- }
- case ytb-absent {
- leaf-list final {
- type instance-identifier;
- }
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbDataType.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbDataType.yang
deleted file mode 100644
index 3d2e7c8..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbDataType.yang
+++ /dev/null
@@ -1,48 +0,0 @@
-module YtbDataType {
- yang-version 1;
- namespace "yms:test:ytb:data:type";
- prefix "data";
- revision "2016-08-26";
- // Enum with all combinations.
- typedef enum-der-1 {
- type enum-der-2;
- }
- typedef enum-der-2 {
- type enumeration {
- enum ten { value "10";}
- enum hundred { value "100";}
- enum thousand { value "1000"; }
- }
- }
- leaf enum {
- type enum-der-1;
- }
- leaf-list enum-leaf-list {
- type union {
- type uint64;
- type enumeration {
- enum ten { value "10";}
- enum hundred { value "100";}
- enum thousand { value "1000"; }
- }
- }
- }
- leaf union-enum {
- type union {
- type enumeration {
- enum ten { value "10";}
- enum hundred { value "100";}
- enum thousand { value "1000"; }
- }
- type enum-der-1;
- }
- }
- leaf-list leaf-ref-enum {
- type leafref {
- path "/enum";
- }
- }
-
-
-
-}
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbDerivedTypeWithBitsAndBinary.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbDerivedTypeWithBitsAndBinary.yang
deleted file mode 100644
index 1ca30a4..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbDerivedTypeWithBitsAndBinary.yang
+++ /dev/null
@@ -1,56 +0,0 @@
-module YtbDerivedTypeWithBitsAndBinary {
- yang-version 1;
- namespace "yms:test:ytb:derived:type:with:bits:and:binary";
- prefix "sch";
- revision "2016-08-26";
-
- typedef derivedbinarya {
- type derivedbinaryb;
- }
-
- typedef derivedbinaryb {
- type binary;
- }
-
- typedef derivedbitsa {
- type derivedbitsb;
- }
-
- typedef derivedbitsb {
- type bits {
- bit index {
- position 1;
- }
- bit name {
- position 10;
- }
- bit signature {
- position 100;
- }
- }
- }
-
- leaf forbinary {
- type derivedbinarya;
- }
-
- leaf forbits {
- type derivedbitsa;
- }
-
- leaf-list forbinarylist {
- type derivedbinarya;
- }
-
- leaf-list forbitslist {
- type derivedbitsa;
- }
-
- leaf forunion {
- type union {
- type binary;
- type int8;
- }
- }
-}
-
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbEmptyType.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbEmptyType.yang
deleted file mode 100644
index 8fcb277..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbEmptyType.yang
+++ /dev/null
@@ -1,45 +0,0 @@
-module YtbEmptyType {
- yang-version 1;
- namespace "yms:test:ytb:empty:type";
- prefix "data";
- revision "2016-08-26";
- typedef emp-type {
- type emp-type2;
- }
- typedef emp-type2 {
- type empty;
- }
- typedef emp-type3 {
- type leafref {
- path "/empty";
- }
- }
- leaf empty {
- type empty;
- }
- leaf-list empty-list {
- type empty;
- }
- leaf empty-ref {
- type leafref {
- path "/empty";
- }
- }
- leaf-list empty-list-ref {
- type leafref {
- path "/empty-list";
- }
- }
- leaf empty-type {
- type emp-type;
- }
- leaf-list empty-list-type {
- type emp-type;
- }
- leaf empty-ref-type {
- type emp-type3;
- }
- leaf-list empty-list-ref-type {
- type emp-type3;
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbIetfSchedule.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbIetfSchedule.yang
deleted file mode 100644
index 84c908b..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbIetfSchedule.yang
+++ /dev/null
@@ -1,29 +0,0 @@
-module YtbIetfSchedule {
- yang-version 1;
- namespace "yms:test:ytb:module:with:leaf:ietfschedule";
- prefix "sch";
- revision "2016-08-26";
- leaf time {
- type int8;
- }
- leaf enum1 {
- type enumeration {
- enum ten { value "10";}
- enum hundred { value "100";}
- enum thousand { value "1000"; }
- }
- }
- leaf-list enum2 {
- type enumeration {
- enum ten-10 { value "10";}
- enum hundred-100 { value "100";}
- enum thousand-1000 { value "1000"; }
- }
- }
- container monitor {
- leaf check {
- type uint8;
- }
- }
-}
-
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbModuleWithContainer.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbModuleWithContainer.yang
deleted file mode 100644
index d611bee..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbModuleWithContainer.yang
+++ /dev/null
@@ -1,13 +0,0 @@
-module YtbModuleWithContainer {
- yang-version 1;
- namespace "yms:test:ytb:module:with:container";
- prefix "sch";
- revision "2016-08-26";
- container sched {
- leaf predict {
- type decimal64 {
- fraction-digits 2;
- }
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbModuleWithLeafList.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbModuleWithLeafList.yang
deleted file mode 100644
index 3d02384..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbModuleWithLeafList.yang
+++ /dev/null
@@ -1,9 +0,0 @@
-module YtbModuleWithLeafList {
- yang-version 1;
- namespace "yms:test:ytb:module:with:leaflist";
- prefix "sch";
- revision "2016-08-26";
- leaf-list time {
- type int64;
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbModuleWithList.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbModuleWithList.yang
deleted file mode 100644
index 297a8f4..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbModuleWithList.yang
+++ /dev/null
@@ -1,15 +0,0 @@
-module YtbModuleWithList {
- yang-version 1;
- namespace "yms:test:ytb:module:with:list";
- prefix "sch";
- revision "2016-08-26";
- list ytblistlist {
- config false;
- leaf-list prediction {
- type find;
- }
- }
- typedef find {
- type boolean;
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbMultiModulea.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbMultiModulea.yang
deleted file mode 100644
index 523f400..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbMultiModulea.yang
+++ /dev/null
@@ -1,12 +0,0 @@
-module YtbMultiModulea {
- yang-version 1;
- namespace "yms:test:ytb:multi:module:a";
- prefix "sch";
- revision "2016-08-26";
- list ytbmultilist {
- config false;
- leaf-list check {
- type uint64;
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbMultiModuleb.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbMultiModuleb.yang
deleted file mode 100644
index 7c2c257..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbMultiModuleb.yang
+++ /dev/null
@@ -1,12 +0,0 @@
-module YtbMultiModuleb {
- yang-version 1;
- namespace "yms:test:ytb:multi:module:b";
- prefix "sch";
- revision "2016-08-26";
- list ytbmultilistb {
- config false;
- leaf-list checkin {
- type string;
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbMultiNotificationWithContainer.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbMultiNotificationWithContainer.yang
deleted file mode 100644
index 9a66110..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbMultiNotificationWithContainer.yang
+++ /dev/null
@@ -1,31 +0,0 @@
-module YtbMultiNotificationWithContainer {
- yang-version 1;
- namespace "yms:test:ytb:multi:notification:with:container";
- prefix "sch";
- revision "2016-08-26";
- notification fortesta {
- container ytbnot {
- leaf notileaf {
- type bits {
- bit leaf1 {
- position 0;
- }
- bit leaf2 {
- position 1;
- }
- }
- }
- }
- }
- list cumulative {
- key "sum";
- leaf sum {
- type int8;
- }
- }
- notification fortestb {
- leaf-list notileaflist {
- type empty;
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbRpcResponseWithAdvancedInputAndOutput.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbRpcResponseWithAdvancedInputAndOutput.yang
deleted file mode 100644
index c9f708e..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbRpcResponseWithAdvancedInputAndOutput.yang
+++ /dev/null
@@ -1,39 +0,0 @@
-module YtbRpcResponseWithAdvancedInputAndOutput {
- yang-version 1;
- namespace "yms:test:ytb:rpc:response:with:advanced:input:and:output";
- prefix "sch";
- revision "2016-08-26";
- leaf refer {
- type binary;
- }
- rpc activate-software-image {
- input {
- container final {
- leaf-list value {
- type uint16;
- }
- }
- }
- output {
- list output-list {
- key "list-key";
- leaf list-key {
- type leafref {
- path "/refer";
- }
- }
- container content_inside {
- leaf-list available {
- type int16;
- }
- }
- }
- }
- }
- list cumulative {
- key "sum";
- leaf sum {
- type int8;
- }
- }
-}
\ No newline at end of file
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbSimpleAugment.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbSimpleAugment.yang
deleted file mode 100644
index 919d5ed..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbSimpleAugment.yang
+++ /dev/null
@@ -1,26 +0,0 @@
-module YtbSimpleAugment {
- yang-version 1;
- namespace "yms:test:ytb:simple:augment";
- prefix "sch";
- revision "2016-08-26";
- container cont1 {
- container cont2 {
- leaf fine {
- type string;
- }
- }
- }
-
- augment /cont1/cont2 {
- leaf leaf4 {
- type int32;
- }
- container cont1s {
- container cont1s {
- leaf fine {
- type string;
- }
- }
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbSimpleChoiceCase.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbSimpleChoiceCase.yang
deleted file mode 100644
index 818d04e..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbSimpleChoiceCase.yang
+++ /dev/null
@@ -1,23 +0,0 @@
-module YtbSimpleChoiceCase {
- yang-version 1;
- namespace "yms:test:ytb:simple:choice:case";
- prefix "sch";
- revision "2016-08-26";
- container YtbFood {
- choice YtbSnack {
- case ytb-sports-arena {
- leaf pretzel {
- type string;
- }
- leaf beer {
- type string;
- }
- }
- case ytb-late-night {
- leaf chocolate {
- type string;
- }
- }
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbSimpleRpcResponse.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbSimpleRpcResponse.yang
deleted file mode 100644
index 7aaa50f..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbSimpleRpcResponse.yang
+++ /dev/null
@@ -1,26 +0,0 @@
-module YtbSimpleRpcResponse {
- yang-version 1;
- namespace "yms:test:ytb:simple:rpc:response";
- prefix "sch";
- revision "2016-08-26";
- container ytb-rpc-cont {
- leaf vary {
- type uint8;
- }
- }
- rpc rpc {
- input {
- }
- output {
- leaf output-leaf {
- type uint32;
- }
- }
- }
- list cumulative {
- key "sum";
- leaf sum {
- type int8;
- }
- }
-}
diff --git a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbTreeBuilderForListHavingList.yang b/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbTreeBuilderForListHavingList.yang
deleted file mode 100644
index bd58e30..0000000
--- a/apps/yms/ut/src/test/resources/ytbTestYangFiles/YtbTreeBuilderForListHavingList.yang
+++ /dev/null
@@ -1,26 +0,0 @@
-module YtbTreeBuilderForListHavingList {
- yang-version 1;
- namespace "yms:test:ytb:tree:builder:for:list:having:list";
- prefix "sch";
- revision "2016-08-26";
- container carrier {
- list multiplexes {
- key "types";
- list application-areas {
- config false;
- leaf-list destination-areas {
- type binary;
- }
- }
- leaf types {
- type enumeration {
- enum space-division;
- enum frequency-division;
- enum time-division {
- value 3;
- }
- }
- }
- }
- }
-}
diff --git a/models/huawei/BUILD b/models/huawei/BUILD
deleted file mode 100644
index 93be622..0000000
--- a/models/huawei/BUILD
+++ /dev/null
@@ -1,7 +0,0 @@
-load("//tools/build/bazel:yang.bzl", "yang_model")
-
-yang_model(
- app_name = "org.onosproject.models.huawei",
- custom_registrator = True,
- title = "Huawei YANG Models",
-)
diff --git a/models/huawei/src/main/java/org/onosproject/HuaweiModelRegistrator.java b/models/huawei/src/main/java/org/onosproject/HuaweiModelRegistrator.java
deleted file mode 100644
index ea5e7cc..0000000
--- a/models/huawei/src/main/java/org/onosproject/HuaweiModelRegistrator.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.models.huawei;
-
-import com.google.common.collect.ImmutableMap;
-import org.osgi.service.component.annotations.Component;
-import org.onosproject.yang.AbstractYangModelRegistrator;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.NeBgpcomm;
-import org.onosproject.yang.gen.v1.nebgpcommtype.rev20141225.NeBgpcommType;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.NeL3VpnApi;
-import org.onosproject.yang.gen.v1.nel3vpncomm.rev20141225.NeL3Vpncomm;
-import org.onosproject.yang.gen.v1.nel3vpncommtype.rev20141225.NeL3VpncommType;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.NeTnlm;
-import org.onosproject.yang.gen.v1.netnlmtype.rev20141225.NeTnlmType;
-import org.onosproject.yang.model.DefaultYangModuleId;
-import org.onosproject.yang.model.YangModuleId;
-import org.onosproject.yang.runtime.AppModuleInfo;
-import org.onosproject.yang.runtime.DefaultAppModuleInfo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Representation of huawei model registrator which registers huawei device
- * models.
- */
-@Component(immediate = true)
-public class HuaweiModelRegistrator extends AbstractYangModelRegistrator {
-
- private static final String MODEL_VERSION = "2014-12-25";
-
- /**
- * Creates L3VPN model registrator.
- */
- public HuaweiModelRegistrator() {
- super(HuaweiModelRegistrator.class, getAppInfo());
- }
-
- private static Map<YangModuleId, AppModuleInfo> getAppInfo() {
- Map<YangModuleId, AppModuleInfo> appInfo = new HashMap<>();
- appInfo.put(new DefaultYangModuleId("ne-bgpcomm", MODEL_VERSION),
- new DefaultAppModuleInfo(NeBgpcomm.class, null));
- appInfo.put(new DefaultYangModuleId("ne-bgpcomm-type", MODEL_VERSION),
- new DefaultAppModuleInfo(NeBgpcommType.class, null));
- appInfo.put(new DefaultYangModuleId("ne-l3vpn-api", MODEL_VERSION),
- new DefaultAppModuleInfo(NeL3VpnApi.class, null));
- appInfo.put(new DefaultYangModuleId("ne-l3vpncomm", MODEL_VERSION),
- new DefaultAppModuleInfo(NeL3Vpncomm.class, null));
- appInfo.put(new DefaultYangModuleId("ne-l3vpncomm-type", MODEL_VERSION),
- new DefaultAppModuleInfo(NeL3VpncommType.class, null));
- appInfo.put(new DefaultYangModuleId("ne-tnlm", MODEL_VERSION),
- new DefaultAppModuleInfo(NeTnlm.class, null));
- appInfo.put(new DefaultYangModuleId("ne-tnlm-type", MODEL_VERSION),
- new DefaultAppModuleInfo(NeTnlmType.class, null));
- return ImmutableMap.copyOf(appInfo);
- }
-}
diff --git a/models/huawei/src/main/java/org/onosproject/package-info.java b/models/huawei/src/main/java/org/onosproject/package-info.java
deleted file mode 100644
index 0169ca5..0000000
--- a/models/huawei/src/main/java/org/onosproject/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * Huawei YANG models.
- */
-package org.onosproject.models.huawei;
diff --git a/models/huawei/src/main/yang/ne-bgpcomm-type@2014-12-25.yang b/models/huawei/src/main/yang/ne-bgpcomm-type@2014-12-25.yang
deleted file mode 100644
index 28f98e4..0000000
--- a/models/huawei/src/main/yang/ne-bgpcomm-type@2014-12-25.yang
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-WARNING:
-This yang model is just for fuction ONOS opensource project demo purpose only,
-And is subject to change in future, Huawei does not commit provide compatibilty
-in commercial product.
-*/
-module ne-bgpcomm-type {
- namespace "ne-bgpcomm-type";
- prefix bgpcomm-type;
- organization "Huawei Technologies Co., Ltd";
- contact "Huawei Industrial Base
- Bantian, Longgang
- Shenzhen 518129
- People's Republic of China
- Website: http://www.huawei.com
- Email: support@huawei.com";
- description "ne-bgpcomm-type yang";
- revision "2014-12-25" {
- description "Initial version";
- }
- typedef bgpcommImRouteProtocol {
- type enumeration {
- enum "direct" {
- value 0;
- description "direct:";
- }
- enum "ospf" {
- value 1;
- description "ospf:";
- }
- enum "isis" {
- value 2;
- description "isis:";
- }
- enum "static" {
- value 3;
- description "static:";
- }
- enum "rip" {
- value 4;
- description "rip:";
- }
- enum "ospfv3" {
- value 5;
- description "ospfv3:";
- }
- enum "ripng" {
- value 6;
- description "ripng:";
- }
- enum "unr" {
- value 7;
- description "unr:";
- }
- enum "op-route" {
- value 8;
- description "op-route:";
- }
- }
- description "";
- }
- typedef bgpcommPrefixType {
- type enumeration {
- enum "ipv4uni" {
- value 0;
- description "ipv4uni:";
- }
- enum "ipv4multi" {
- value 1;
- description "ipv4multi:";
- }
- enum "ipv4vpn" {
- value 2;
- description "ipv4vpn:";
- }
- enum "ipv6uni" {
- value 3;
- description "ipv6uni:";
- }
- enum "ipv6vpn" {
- value 4;
- description "ipv6vpn:";
- }
- enum "ipv4flow" {
- value 5;
- description "ipv4flow:";
- }
- enum "l2vpnad" {
- value 6;
- description "l2vpnad:";
- }
- enum "mvpn" {
- value 7;
- description "mvpn:";
- }
- enum "evpn" {
- value 8;
- description "evpn:";
- }
- enum "ipv4vpnmcast" {
- value 9;
- description "ipv4vpnmcast:";
- }
- enum "ls" {
- value 10;
- description "ls:";
- }
- enum "mdt" {
- value 11;
- description "mdt:";
- }
- }
- description "";
- }
-}
diff --git a/models/huawei/src/main/yang/ne-bgpcomm@2014-12-25.yang b/models/huawei/src/main/yang/ne-bgpcomm@2014-12-25.yang
deleted file mode 100644
index b0bb113..0000000
--- a/models/huawei/src/main/yang/ne-bgpcomm@2014-12-25.yang
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-WARNING:
-This yang model is just for fuction ONOS opensource project demo purpose only,
-And is subject to change in future, Huawei does not commit provide compatibilty
-in commercial product.
-*/
-module ne-bgpcomm {
- namespace "ne-bgpcomm";
- prefix bgpcomm;
- import ne-bgpcomm-type {
- prefix bgpcomm-type;
- }
- organization "Huawei Technologies Co., Ltd";
- contact "Huawei Industrial Base
- Bantian, Longgang
- Shenzhen 518129
- People's Republic of China
- Website: http://www.huawei.com
- Email: support@huawei.com";
- description "ne-bgpcomm yang";
- revision "2014-12-25" {
- description "Initial version";
- }
-
- container devices {
- list device {
- key deviceid;
- leaf deviceid {
- type string;
- }
- container bgp {
- container bgpcomm {
- description "";
- container bgpVrfs {
- description "";
- list bgpVrf {
- key "vrfName";
- description "BGP instance class";
- leaf vrfName {
- description "Specifies the name of the VPN in stance.
- It is a string of 1 to 31 case-sensitive characters.";
- type string;
- }
- container bgpVrfAFs {
- description "";
- list bgpVrfAF {
- key "afType";
- description "IPv4 unicast Address family class for
- BGP instance";
- leaf afType {
- type "bgpcomm-type:bgpcommPrefixType";
- description "Address family";
- }
- container importRoutes {
- description "";
- list importRoute {
- key "importProtocol importProcessId";
- description "Import route class";
- leaf importProtocol {
- type "bgpcomm-type:bgpcommImRouteProtocol";
- description "Specifies the protocol from
- which routes are imported.";
- }
- leaf importProcessId {
- type "string";
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
diff --git a/models/huawei/src/main/yang/ne-l3vpn-api@2014-12-25.yang b/models/huawei/src/main/yang/ne-l3vpn-api@2014-12-25.yang
deleted file mode 100644
index 5320617..0000000
--- a/models/huawei/src/main/yang/ne-l3vpn-api@2014-12-25.yang
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-WARNING:
-This yang model is just for fuction ONOS opensource project demo purpose only,
-And is subject to change in future, Huawei does not commit provide compatibilty
-in commercial product.
-*/
-module ne-l3vpn-api {
- namespace "ne-l3vpn-api";
- prefix l3vpn-api;
- import ne-l3vpncomm-type {
- prefix l3vpncomm-type;
- }
- import ne-l3vpncomm {
- prefix l3vpncomm;
- }
- organization "Huawei Technologies Co., Ltd";
- contact "Huawei Industrial Base
- Bantian, Longgang
- Shenzhen 518129
- People's Republic of China
- Website: http://www.huawei.com
- Email: support@huawei.com";
- description "VRP V800R010 Schema";
- revision "2014-12-25" {
- reference "Huawei VRPV8 Schema";
- }
- container devices {
- list device {
- key deviceid;
- leaf deviceid {
- type string;
- }
- container l3vpn {
- container l3vpncomm {
- container l3vpnInstances {
- description "";
- list l3vpnInstance {
- key "vrfName";
- leaf vrfName {
- type string;
- }
- leaf vrfDescription {
- type string;
- }
- uses l3vpncomm:l3vpnIfs;
- container vpnInstAFs {
- description "";
- list vpnInstAF {
- key "afType";
- description "Address family";
- leaf afType {
- type "l3vpncomm-type:l3vpncommonL3vpnPrefixType";
- description "Address family";
- }
- leaf vrfRD {
- when "vrfName != '_public_'";
- type "string";
- description "route-distinguisher.";
- }
- leaf tnlPolicyName {
- type "string";
- }
- container vpnTargets {
- description "";
- list vpnTarget {
- must "vrfName != '_public_' and vpnTarget = '0'";
- key "vrfRTValue vrfRTType";
- description "L3vpn vpntarget configure class";
- leaf vrfRTValue {
- type "string";
- }
- leaf vrfRTType {
- type "l3vpncomm-type:l3vpncommonVrfRtType";
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
diff --git a/models/huawei/src/main/yang/ne-l3vpncomm-type@2014-12-25.yang b/models/huawei/src/main/yang/ne-l3vpncomm-type@2014-12-25.yang
deleted file mode 100644
index 3bc62f2..0000000
--- a/models/huawei/src/main/yang/ne-l3vpncomm-type@2014-12-25.yang
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-WARNING:
-This yang model is just for fuction ONOS opensource project demo purpose only,
-And is subject to change in future, Huawei does not commit provide compatibilty
-in commercial product.
-*/
-module ne-l3vpncomm-type {
- namespace "l3vpn-comm-type";
- prefix l3vpncomm-type;
- organization "Huawei Technologies Co., Ltd";
- contact "Huawei Industrial Base
- Bantian, Longgang
- Shenzhen 518129
- People's Republic of China
- Website: http://www.huawei.com
- Email: support@huawei.com";
- description "";
- revision "2014-12-25" {
- description "Initial version";
- }
- typedef l3vpncommonL3vpnPrefixType {
- type enumeration {
- enum "ipv4uni" {
- value 0;
- description "ipv4uni:";
- }
- enum "ipv6uni" {
- value 1;
- description "ipv6uni:";
- }
- }
- description "";
- }
- typedef l3vpncommonVrfRtType {
- type enumeration {
- enum "export_extcommunity" {
- value 0;
- description "export-extcommunity:";
- }
- enum "import_extcommunity" {
- value 1;
- description "import-extcommunity:";
- }
- }
- description "";
- }
- typedef ipv4Address {
- type string {
- length "0..255";
- pattern "((([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))";
- }
- }
-}
diff --git a/models/huawei/src/main/yang/ne-l3vpncomm@2014-12-25.yang b/models/huawei/src/main/yang/ne-l3vpncomm@2014-12-25.yang
deleted file mode 100644
index b03c382..0000000
--- a/models/huawei/src/main/yang/ne-l3vpncomm@2014-12-25.yang
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-WARNING:
-This yang model is just for fuction ONOS opensource project demo purpose only,
-And is subject to change in future, Huawei does not commit provide compatibilty
-in commercial product.
-*/
-module ne-l3vpncomm {
- namespace "ne-l3vpn-comm";
- prefix "l3vpncomm";
- import ne-l3vpncomm-type {
- prefix l3vpncomm-type;
- }
- organization "Huawei Technologies Co., Ltd";
- contact "Huawei Industrial Base
- Bantian, Longgang
- Shenzhen 518129
- People's Republic of China
- Website: http://www.huawei.com
- Email: support@huawei.com";
- description "";
- revision "2014-12-25" {
- description "Initial version";
- }
- grouping l3vpnIfs {
- container l3vpnIfs {
- description "";
- list l3vpnIf {
- key "ifName";
- description "interface Name.";
- leaf ifName {
- type string;
- description "interface Name";
- }
- leaf ipv4Addr {
- when "subnetMask != null";
- mandatory "true";
- type "l3vpncomm-type:ipv4Address";
- description "Interface Address.";
- }
- leaf subnetMask {
- when "ipv4Addr != null";
- mandatory "true";
- type "l3vpncomm-type:ipv4Address";
- description "Interface address mask.";
- }
- }
- }
- }
-}
diff --git a/models/huawei/src/main/yang/ne-tnlm-type@2014-12-25.yang b/models/huawei/src/main/yang/ne-tnlm-type@2014-12-25.yang
deleted file mode 100644
index 8dac8e8..0000000
--- a/models/huawei/src/main/yang/ne-tnlm-type@2014-12-25.yang
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-WARNING:
-This yang model is just for fuction ONOS opensource project demo purpose only,
-And is subject to change in future, Huawei does not commit provide compatibilty
-in commercial product.
-*/
-module ne-tnlm-type {
- namespace "ne-tnlm-type";
- prefix tnlm-type;
- organization "Huawei Technologies Co., Ltd";
- contact "Huawei Industrial Base
- Bantian, Longgang
- Shenzhen 518129
- People's Republic of China
- Website: http://www.huawei.com
- Email: support@huawei.com";
- description "VRP V800R010 Schema";
-
- revision "2014-12-25" {
- reference "Huawei VRPV8 Schema";
- }
-
- typedef tnlmbaseTnlPolicyType {
- type enumeration {
- enum invalid;
- enum tnlSelectSeq;
- enum tnlBinding;
- }
- }
-}
\ No newline at end of file
diff --git a/models/huawei/src/main/yang/ne-tnlm@2014-12-25.yang b/models/huawei/src/main/yang/ne-tnlm@2014-12-25.yang
deleted file mode 100644
index 73796f4..0000000
--- a/models/huawei/src/main/yang/ne-tnlm@2014-12-25.yang
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-WARNING:
-This yang model is just for fuction ONOS opensource project demo purpose only,
-And is subject to change in future, Huawei does not commit provide compatibilty
-in commercial product.
-*/
-module ne-tnlm {
- namespace "ne-tnlm";
- prefix tnlm;
-
- import ne-l3vpncomm-type {
- prefix l3vpncomm-type;
- }
- import ne-tnlm-type {
- prefix tnlmtype;
- }
- organization "Huawei Technologies Co., Ltd";
- contact "Huawei Industrial Base
- Bantian, Longgang
- Shenzhen 518129
- People's Republic of China
- Website: http://www.huawei.com
- Email: support@huawei.com";
- description "VRP V800R010 Schema";
- revision "2014-12-25" {
- reference "Huawei VRPV8 Schema";
- }
- container devices {
- list device {
- key deviceid;
- leaf deviceid {
- type string;
- }
- container tnlm {
- container tunnelPolicys {
- list tunnelPolicy {
- key tnlPolicyName;
- leaf tnlPolicyName {
- type string;
- }
- leaf tnlPolicyType {
- type tnlmtype:tnlmbaseTnlPolicyType;
- }
- container tpNexthops {
- list tpNexthop {
- key nexthopIPaddr;
- leaf nexthopIPaddr {
- type "l3vpncomm-type:ipv4Address";
- }
- leaf tnlPolicyName {
- type string;
- }
- container tpTunnels {
- list tpTunnel {
- key "tunnelName";
- leaf autoTunnel {
- type boolean;
- }
- leaf tunnelName {
- type string;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/models/l3vpn/BUILD b/models/l3vpn/BUILD
deleted file mode 100644
index d7b0870..0000000
--- a/models/l3vpn/BUILD
+++ /dev/null
@@ -1,17 +0,0 @@
-load("//tools/build/bazel:yang.bzl", "yang_model")
-
-COMPILE_DEPS = [
- "//models/common:onos-models-common",
-]
-
-APPS = [
- "org.onosproject.models.common",
-]
-
-yang_model(
- app_name = "org.onosproject.models.l3vpn",
- custom_registrator = True,
- required_apps = APPS,
- title = "L3VPN YANG Models",
- deps = COMPILE_DEPS,
-)
diff --git a/models/l3vpn/src/main/java/org/onosproject/models/l3vpn/L3VpnModelRegistrator.java b/models/l3vpn/src/main/java/org/onosproject/models/l3vpn/L3VpnModelRegistrator.java
deleted file mode 100644
index 1c3cd64..0000000
--- a/models/l3vpn/src/main/java/org/onosproject/models/l3vpn/L3VpnModelRegistrator.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.models.l3vpn;
-
-import com.google.common.collect.ImmutableMap;
-import org.osgi.service.component.annotations.Component;
-import org.onosproject.yang.AbstractYangModelRegistrator;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.IetfBgpL3Vpn;
-import org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.IetfInterfaces;
-import org.onosproject.yang.gen.v1.ietfip.rev20140616.IetfIp;
-import org.onosproject.yang.gen.v1.ietfl3vpnsvc.rev20160730.IetfL3VpnSvc;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.IetfNetworkInstance;
-import org.onosproject.yang.gen.v1.l3vpnsvcext.rev20160730.L3VpnSvcExt;
-import org.onosproject.yang.model.DefaultYangModuleId;
-import org.onosproject.yang.model.YangModuleId;
-import org.onosproject.yang.runtime.AppModuleInfo;
-import org.onosproject.yang.runtime.DefaultAppModuleInfo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Representation of L3VPN model registrator which registers L3VPN service
- * model.
- */
-@Component(immediate = true)
-public class L3VpnModelRegistrator extends AbstractYangModelRegistrator {
-
- /**
- * Creates L3VPN model registrator.
- */
- public L3VpnModelRegistrator() {
- super(L3VpnModelRegistrator.class, getAppInfo());
- }
-
- private static Map<YangModuleId, AppModuleInfo> getAppInfo() {
- Map<YangModuleId, AppModuleInfo> appInfo = new HashMap<>();
- appInfo.put(new DefaultYangModuleId("ietf-l3vpn-svc", "2016-07-30"),
- new DefaultAppModuleInfo(IetfL3VpnSvc.class, null));
- appInfo.put(new DefaultYangModuleId("l3vpn-svc-ext", "2016-07-30"),
- new DefaultAppModuleInfo(L3VpnSvcExt.class, null));
- appInfo.put(new DefaultYangModuleId("ietf-interfaces", "2014-05-08"),
- new DefaultAppModuleInfo(IetfInterfaces.class, null));
- appInfo.put(new DefaultYangModuleId("ietf-bgp-l3vpn", "2016-09-09"),
- new DefaultAppModuleInfo(IetfBgpL3Vpn.class, null));
- appInfo.put(new DefaultYangModuleId("ietf-ip", "2014-06-16"),
- new DefaultAppModuleInfo(IetfIp.class, null));
- appInfo.put(new DefaultYangModuleId("ietf-network-instance",
- "2016-06-23"),
- new DefaultAppModuleInfo(IetfNetworkInstance.class, null));
- return ImmutableMap.copyOf(appInfo);
- }
-}
diff --git a/models/l3vpn/src/main/java/org/onosproject/models/l3vpn/package-info.java b/models/l3vpn/src/main/java/org/onosproject/models/l3vpn/package-info.java
deleted file mode 100644
index 55e1dbb..0000000
--- a/models/l3vpn/src/main/java/org/onosproject/models/l3vpn/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * L3vpn YANG models.
- */
-package org.onosproject.models.l3vpn;
diff --git a/models/l3vpn/src/main/yang/ietf-bgp-l3vpn@2016-09-09.yang b/models/l3vpn/src/main/yang/ietf-bgp-l3vpn@2016-09-09.yang
deleted file mode 100644
index 276a59f..0000000
--- a/models/l3vpn/src/main/yang/ietf-bgp-l3vpn@2016-09-09.yang
+++ /dev/null
@@ -1,723 +0,0 @@
-module ietf-bgp-l3vpn {
- namespace "urn:ietf:params:xml:ns:yang:ietf-bgp-l3vpn";
- // replace with IANA namespace when assigned
- prefix l3vpn ;
-
- import ietf-network-instance {
- prefix ni;
- revision-date 2016-06-23;
- }
-
- import ietf-interfaces {
- prefix if;
- }
-
-// TODO: TBD for bgp-info
-// import ietf-bgp {
-// prefix bgp;
-// revision-date 2016-06-21;
-// }
-
- organization
- "IETF BGP Enabled Services WG";
-
- contact
- "BESS working group - bess@ietf.org";
- description
- "This YANG module defines a YANG data model to configure and
- manage BGP Layer3 VPNs. It augments the IETF bgp yang model
- and IETF network instance model to add L3VPN specific
- configuration and operational knobs.
-
-
- Terms and Acronyms
-
- AF : Address Family
-
- AS : Autonomous System
-
- ASBR : Autonomous Systems Border Router
-
- BGP (bgp) : Border Gateway Protocol
-
- CE : Customer Edge
-
- IP (ip) : Internet Protocol
-
- IPv4 (ipv4):Internet Protocol Version 4
-
- IPv6 (ipv6): Internet Protocol Version 6
-
- L3VPN: Layer 3 VPN
-
- PE : Provider Edge
-
- RT : Route Target
-
- RD : Route Distinguisher
-
- VPN : Virtual Private Network
-
- VRF : Virtual Routing and Forwarding
-
- ";
-
- revision 2016-09-09 {
- description
- "Initial revision.";
- reference
- "RFC XXXX: A YANG Data Model for BGP L3VPN config management";
- }
-
- //RD
- grouping route-distinguisher-params {
- description "BGP route distinguisher";
- container route-distinguisher {
- description "Route distinguisher value as per RFC4364";
- container config {
- description
- "Configuration parameters for route distinguisher";
- leaf rd {
- type string;
- description "Route distinguisher value as per RFC4364";
- }
- }
- container state {
- config "false" ;
- description
- "State information for route distinguisher";
- leaf rd {
- type string;
- description "Route distinguisher value";
- }
- }
- }
- }
-
- //Label mode
- typedef bgp-label-mode {
- type enumeration {
- enum per-ce {
- description "Allocate labels per CE";
- }
- enum per-route {
- description "Allocate labels per prefix";
- }
- enum per-vpn {
- description "Allocate labels per VRF";
- }
- }
- description "BGP label allocation mode";
- }
-
- //Fwding mode
- typedef fwd-mode-type {
- type enumeration {
- enum mpls {
- description "Forwarding mode mpls";
- }
- }
- description
- "Enable forwarding mode under ASBR facing interface";
- }
-
- grouping forwarding-mode {
- description "Forwarding mode of interface for ASBR scenario";
- container forwarding-mode {
- description "Forwarding mode of interface for ASBR scenario";
- container config {
- description "Configuration of Forwarding mode";
- leaf forwarding-mode {
- type fwd-mode-type;
- description "Forwarding mode for this interface";
- }
- }
- container state {
- config "false";
- description "State information of Forwarding mode";
- leaf forwarding-mode {
- type fwd-mode-type;
- description "Forwarding mode for this interface";
- }
- }
- }
- }
-
- grouping label-security {
- description "Mpls label security for ASBR option B scenario";
- container mpls-label-security {
- description "MPLS label secruity";
- container config {
- description "Configuration parameters";
- leaf rpf {
- type boolean;
- description "Enable MPLS label security rpf on interface";
- }
- }
- container state {
- config "false";
- description "State information";
- leaf rpf {
- type boolean;
- description "MPLS label security rpf on interface";
- }
- }
- }
- }
-
-
- //per VPN instance table limit under BGP
- grouping prefix-limit {
- description
- "The prefix limit command sets a limit on the maximum
- number of prefixes supported in the existing VPN
- instance, preventing the PE from importing excessive
- VPN route prefixes.
- ";
-
- leaf prefix-limit-number {
- type uint32 {
- range "1..4294967295";
- }
- description
- "Specifies the maximum number of prefixes supported in the
- VPN instance IPv4 or IPv6 address family.";
- }
-
- choice prefix-limit-action {
- description ".";
- case enable-alert-percent {
- leaf alert-percent-value {
- type uint8 {
- range "1..100";
- }
- description
- "Specifies the proportion of the alarm threshold to the
- maximum number of prefixes.";
- }
- leaf route-unchanged {
- type boolean;
- default "false";
- description
- "Indicates that the routing table remains unchanged.
- By default, route-unchanged is not configured. When
- the number of prefixes in the routing table is
- greater than the value of the parameter number,
- routes are processed as follows:
- (1)If route-unchanged is configured, routes in the
- routing table remain unchanged.
- (2)If route-unchanged is not configured, all routes
- in the routing table are deleted and then
- re-added.";
- }
- }
- case enable-simple-alert {
- leaf simple-alert {
- type boolean;
- default "false";
- description
- "Indicates that when the number of VPN route prefixes
- exceeds number, prefixes can still join the VPN
- routing table and alarms are displayed.";
- }
- }
- }
- }
-
- grouping vpn-pfx-limit {
- description "Per VPN instance table limit under BGP";
- container vpn-prefix-limit {
- description "Prefix limit for this table";
- container config {
- description "Config parameters";
- uses prefix-limit;
- }
- container state {
- config "false";
- description "State parameters";
- uses prefix-limit;
- }
- }
- }
-
- grouping route-target-set {
- description
- "Extended community route-target set ";
- list rts {
- key "rt" ;
- description
- "List of route-targets" ;
- leaf rt {
- type string {
- pattern '([0-9]+:[0-9]+)';
- }
- description "Route target extended community as per RFC4360";
- }
- leaf rt-type {
- type enumeration {
- enum import {
- description "Route target is for import routes";
- }
- enum export {
- description "Route target is for export routes";
- }
- enum both {
- description
- "Route target is for both import and export routes";
- }
- }
- description "Route target type";
- }
- }
- leaf route-policy {
- type string;
- description
- "Reference to the policy containing set of routes.
- TBD: leafref to policy entry in IETF policy model";
- }
- }
-
- grouping import-from-gbl {
- description "Import from global routing table";
- leaf enable {
- type boolean;
- description "Enable";
- }
- leaf advertise-as-vpn {
- type boolean;
- description
- "Advertise routes imported from global table as VPN routes";
- }
- leaf route-policy {
- type string;
- description "Route policy as filter for importing routes";
- }
-
- leaf bgp-valid-route {
- type boolean;
- description
- "Enable all valid routes (including non-best paths) to be
- candidate for import";
- }
-
- leaf protocol {
- type enumeration {
- enum ALL {
- value "0";
- description "ALL:";
- }
- enum Direct {
- value "1";
- description "Direct:";
- }
- enum OSPF {
- value "2";
- description "OSPF:";
- }
- enum ISIS {
- value "3";
- description "ISIS:";
- }
- enum Static {
- value "4";
- description "Static:";
- }
- enum RIP {
- value "5";
- description "RIP:";
- }
- enum BGP {
- value "6";
- description "BGP:";
- }
- enum OSPFV3 {
- value "7";
- description "OSPFV3:";
- }
- enum RIPNG {
- value "8";
- description "RIPNG:";
- }
- }
- description
- "Specifies the protocol from which routes are imported.
- At present, In the IPv4 unicast address family view,
- the protocol can be IS-IS,static, direct and BGP.";
- }
-
- leaf instance {
- type string;
- description
- "Specifies the instance id of the protocol";
- }
- }
- grouping global-imports {
- description "Grouping for imports from global routing table";
- container import-from-global {
- description "Import from global routing table";
- container config {
- description "Configuration";
- uses import-from-gbl;
- }
- container state {
- config "false";
- description "State";
- uses import-from-gbl;
- }
- }
- }
-
-
- grouping export-to-gbl {
- description "Export routes to default VRF";
- leaf enable {
- type boolean;
- description "Enable";
- }
- }
-
- grouping global-exports {
- description "Grouping for exports routes to global table";
- container export-to-global {
- description "Export to global routing table";
- container config {
- description "Configuration";
- uses export-to-gbl;
- }
- container state {
- config "false";
- description "State";
- uses export-to-gbl;
- }
- }
- }
-
- grouping route-target-params {
- description "Grouping to specify rules for route import and export";
- container route-targets {
- description
- "Set of route-targets to match for import and export routes
- to/from VRF";
- container config {
- description
- "Configuration of route targets";
- uses route-target-set ;
- }
- container state {
- config "false" ;
- description
- "State information for route targets";
- uses route-target-set ;
- }
- }
- }
-
- grouping route-tbl-limit-params {
- description "Grouping for VPN table prefix limit config";
- leaf routing-table-limit-number {
- type uint32 {
- range "1..4294967295";
- }
- description
- "Specifies the maximum number of routes supported by a
- VPN instance. ";
- }
-
- choice routing-table-limit-action {
- description ".";
- case enable-alert-percent {
- leaf alert-percent-value {
- type uint8 {
- range "1..100";
- }
- description
- "Specifies the percentage of the maximum number of
- routes. When the maximum number of routes that join
- the VPN instance is up to the value
- (number*alert-percent)/100, the system prompts
- alarms. The VPN routes can be still added to the
- routing table, but after the number of routes
- reaches number, the subsequent routes are
- dropped.";
- }
- }
- case enable-simple-alert {
- leaf simple-alert {
- type boolean;
- description
- "Indicates that when VPN routes exceed number, routes
- can still be added into the routing table, but the
- system prompts alarms.
- However, after the total number of VPN routes and
- network public routes reaches the unicast route limit
- specified in the License, the subsequent VPN routes
- are dropped.";
- }
- }
- }
- }
-
- grouping routing-tbl-limit {
- description ".";
- container routing-table-limit {
- description
- "The routing-table limit command sets a limit on the maximum
- number of routes that the IPv4 or IPv6 address family of a
- VPN instance can support.
- By default, there is no limit on the maximum number of
- routes that the IPv4 or IPv6 address family of a VPN
- instance can support, but the total number of private
- network and public network routes on a device cannot
- exceed the allowed maximum number of unicast routes.";
- container config {
- description "Config parameters";
- uses route-tbl-limit-params;
- }
- container state {
- config "false";
- description "State parameters";
- uses route-tbl-limit-params;
- }
- }
- }
-
- // Tunnel policy parameters
- grouping tunnel-params {
- description "Tunnel parameters";
- container tunnel-params {
- description "Tunnel config parameters";
- container config {
- description "configuration parameters";
- leaf tunnel-policy {
- type string;
- description
- "Tunnel policy name.";
- }
- }
- container state {
- config "false";
- description "state parameters";
- leaf tunnel-policy {
- type string;
- description
- "Tunnel policy name.";
- }
- }
- }
- }
-
- // Grouping for the L3vpn specific parameters under VRF
- // (network-instance)
- grouping l3vpn-vrf-params {
- description "Specify route filtering rules for import/export";
- container ipv4 {
- description
- "Specify route filtering rules for import/export";
- container unicast {
- description
- "Specify route filtering rules for import/export";
- uses route-target-params;
- uses global-imports;
- uses global-exports;
- uses routing-tbl-limit;
- uses tunnel-params;
- }
- }
- container ipv6 {
- description
- "Ipv6 address family specific rules for import/export";
- container unicast {
- description "Ipv6 unicast address family";
- uses route-target-params;
- uses global-imports;
- uses global-exports;
- uses routing-tbl-limit;
- uses tunnel-params;
- }
- }
- }
-
- grouping bgp-label-mode {
- description "MPLS/VPN label allocation mode";
- container config {
- description
- "Configuration parameters for label allocation mode";
- leaf label-mode {
- type bgp-label-mode;
- description "Label allocation mode";
- }
- }
- container state {
- config "false" ;
- description "State information for label allocation mode";
- leaf label-mode {
- type bgp-label-mode;
- description "Label allocation mode";
- }
- }
- }
-
- grouping retain-route-targets {
- description "Grouping for route target accept";
- container retain-route-targets {
- description "Control route target acceptance behavior for ASBRs";
- container config {
- description
- "Configuration parameters for retaining route targets";
- leaf all {
- type empty;
- description "Disable filtering of all route-targets";
- }
- leaf route-policy {
- type string;
- description "Filter routes as per filter policy name
- TBD: leafref to IETF routing policy model";
- }
- }
- container state {
- config "false" ;
- description "State information for retaining route targets";
- leaf all {
- type empty;
- description "Disable filtering of all route-targets";
- }
- leaf route-policy {
- type string;
- description "Filter routes as per filter policy name";
- }
- }
- }
- }
-
- grouping nexthop-opts {
- description "Next hop control options for inter-as route exchange";
- leaf next-hop-self {
- type boolean;
- description
- "Set nexthop of the route to self when advertising routes";
- }
- leaf next-hop-unchanged {
- type boolean;
- description "Enforce no nexthop change when advertising routes";
- }
- }
-
- grouping asbr-nexthop-options {
- description "Nexthop parameters for inter-as VPN options ";
- container nexthop-options {
- description "Nexthop related options for inter-as options";
- container config {
- description "Configuration parameters for nexthop options";
- uses nexthop-opts;
- }
- container state {
- config "false";
- description "State information for nexthop options" ;
- uses nexthop-opts;
- }
- }
- }
-
- //
- // VRF specific parameters.
- // RD and RTs and route import-export rules are added under
- // network instance container in network instance model, hence
- // per VRF scoped
- augment "/ni:devices/ni:device/ni:network-instances/ni:network-instance" {
- description
- "Augment network instance for per VRF L3vpn parameters";
- container l3vpn {
- //Enable this check once network instance model has
- //identify defined for VRF type
- //when "../type='rt:vrf-network-instance'" {
- // description
- // "This container is only valid for vrf routing instance.";
- //}
- description "Configuration of L3VPN specific parameters";
-
- uses route-distinguisher-params;
- uses l3vpn-vrf-params ;
- }
- }
-
- // bgp mpls forwarding enable required for inter-as option AB.
- augment "/if:devices/if:device/if:interfaces/if:interface" {
- description
- "BGP mpls forwarding mode configuration on interface for
- ASBR scenario";
- uses forwarding-mode ;
- uses label-security;
- }
-
- //
- // BGP Specific Paramters
- //
-
- //
- // Retain route-target for inter-as option ASBR knob.
- // vpn prefix limits
- // vpnv4/vpnv6 address-family only.
- //augment "/bgp:bgp/bgp:global/bgp:afi-safis/" +
- // "bgp:afi-safi/bgp:l3vpn-ipv4-unicast" {
- // description "Retain route targets for ASBR scenario";
- // uses retain-route-targets;
- // uses vpn-pfx-limit;
- // }
-
- // augment "/bgp:bgp/bgp:global/bgp:afi-safis/" +
- // "bgp:afi-safi/bgp:l3vpn-ipv6-unicast" {
- // description "Retain route targets for ASBR scenario";
- // uses retain-route-targets;
- // uses vpn-pfx-limit;
- // }
-
- // Label allocation mode configuration. Certain AFs only.
- // augment "/bgp:bgp/bgp:global/bgp:afi-safis/" +
- // "bgp:afi-safi/bgp:ipv4-unicast" {
- // description
- // "Augment BGP global AF mode for label allocation mode
- // configuration";
- // uses bgp-label-mode ;
- // uses routing-tbl-limit;
- // }
-
- // augment "/bgp:bgp/bgp:global/bgp:afi-safis/" +
- // "bgp:afi-safi/bgp:ipv6-unicast" {
- // description
- // "Augment BGP global AF mode for label allocation mode
- // configuration";
- // uses bgp-label-mode ;
- // uses routing-tbl-limit;
- // }
-
-
- // Nexthop options for the inter-as ASBR peering.
- // augment "/bgp:bgp/bgp:neighbors/bgp:neighbor" {
- // description
- // "Augment BGP NBR mode with nexthop options for inter-as ASBRs";
- // uses asbr-nexthop-options;
- // }
-
- // augment "/bgp:bgp/bgp:peer-groups/bgp:peer-group" {
- // description
- // "Augment BGP peer-group mode with nexthop options for inter-as
- // ASBRs";
- // uses asbr-nexthop-options;
- // }
-
- // augment "/bgp:bgp/bgp:neighbors/bgp:neighbor/" +
- // "bgp:afi-safis/bgp:afi-safi" {
- // description
- // "Augment BGP NBR AF mode with nexthop options for inter-as
- // ASBRs";
- // uses asbr-nexthop-options;
- // }
-
- // augment "/bgp:bgp/bgp:peer-groups/bgp:peer-group/" +
- // "bgp:afi-safis/bgp:afi-safi" {
- // description
- // "Augment BGP peer-group AF mode with nexthop options for inter-as
- // ASBRs";
- // uses asbr-nexthop-options;
- // }
-}
diff --git a/models/l3vpn/src/main/yang/ietf-interfaces@2014-05-08.yang b/models/l3vpn/src/main/yang/ietf-interfaces@2014-05-08.yang
deleted file mode 100644
index 2171a5a..0000000
--- a/models/l3vpn/src/main/yang/ietf-interfaces@2014-05-08.yang
+++ /dev/null
@@ -1,704 +0,0 @@
-module ietf-interfaces {
-
- namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces";
- prefix if;
-
- import ietf-yang-types {
- prefix yang;
- }
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/netmod/>
- WG List: <mailto:netmod@ietf.org>
-
- WG Chair: Thomas Nadeau
- <mailto:tnadeau@lucidvision.com>
-
- WG Chair: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>
-
- Editor: Martin Bjorklund
- <mailto:mbj@tail-f.com>";
-
- description
- "This module contains a collection of YANG definitions for
- managing network interfaces.
-
- Copyright (c) 2014 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC 7223; see
- the RFC itself for full legal notices.";
- revision 2014-05-08 {
- description
- "Initial revision.";
- reference
- "RFC 7223: A YANG Data Model for Interface Management";
- }
-
- /*
- * Typedefs
- */
-
- typedef interface-ref {
- type leafref {
- path "/if:devices/if:device/if:interfaces/if:interface/if:name";
- }
- description
- "This type is used by data models that need to reference
- configured interfaces.";
- }
-
- typedef interface-state-ref {
- type leafref {
- path "/if:devices/if:device/if:interfaces-state/if:interface/if:name";
- }
- description
- "This type is used by data models that need to reference
- the operationally present interfaces.";
- }
-
- /*
- * Identities
- */
-
- identity interface-type {
- description
- "Base identity from which specific interface types are
- derived.";
- }
-
- /*
- * Features
- */
-
- feature arbitrary-names {
- description
- "This feature indicates that the device allows user-controlled
- interfaces to be named arbitrarily.";
- }
- feature pre-provisioning {
- description
- "This feature indicates that the device supports
- pre-provisioning of interface configuration, i.e., it is
- possible to configure an interface whose physical interface
- hardware is not present on the device.";
- }
-
- feature if-mib {
- description
- "This feature indicates that the device implements
- the IF-MIB.";
- reference
- "RFC 2863: The Interfaces Group MIB";
- }
-
- /*
- * Configuration data nodes
- */
- container devices {
- list device {
- key deviceid;
- leaf deviceid {
- type string;
- }
- container interfaces {
- description
- "Interface configuration parameters.";
-
- list interface {
- key "name";
-
- description
- "The list of configured interfaces on the device.
- The operational state of an interface is available
- in the /interfaces-state/interface list. If the
- configuration of a system-controlled interface
- cannot be used by the system (e.g., the interface
- hardware present does not match the interface type),
- then the configuration is not applied to the
- system-controlled interface shown in the of a
- /interfaces-state/interface list. If the configuration
- user-controlled interface cannot be used by the system,
- the configured interface is not instantiated in the
- /interfaces-state/interface list.";
-
- leaf name {
- type string;
- description
- "The name of the interface.
-
- A device MAY restrict the allowed values for
- this leaf, possibly depending on the type of the
- interface. For system-controlled interfaces,
- this leaf is the device-specific name of the
- interface. The 'config false' list
- /interfaces-state/interface contains the
- currently existing interfaces on the device.
-
- If a client tries to create configuration for a
- system-controlled interface that is not present
- in the /interfaces-state/interface list, the
- server MAY reject the request if the
- implementation does not support pre-provisioning
- of interfaces or if the name refers to an
- interface that can never exist in the system. A
- NETCONF server MUST reply with an rpc-error with
- the error-tag 'invalid-value' in this case.
-
- If the device supports pre-provisioning of
- interface configuration, the 'pre-provisioning'
- feature is advertised.
-
- If the device allows arbitrarily named
- user-controlled interfaces, the
- 'arbitrary-names' feature is advertised.
-
- When a configured user-controlled interface is
- created by the system, it is instantiated with
- the same name in the /interface-state/interface
- list.";
- }
-
- leaf description {
- type string;
- description
- "A textual description of the interface.
-
- A server implementation MAY map this leaf to the
- ifAlias MIB object. Such an implementation
- needs touse some mechanism to handle the
- differences in sizeand characters allowed
- between this leaf and ifAlias.The definition of
- such a mechanism is outside the scope of this
- document.
-
- Since ifAlias is defined to be stored in
- non-volatile storage, the MIB implementation
- MUST map ifAlias to the value of 'description'
- in the persistently stored datastore.
-
- Specifically, if the device supports ':startup',
- when ifAlias is read the device MUST return the
- value of 'description' in the 'startup'
- datastore, and when it is written, it MUST be
- written to the 'running' and 'startup'
- datastores. Note that it is up to the
- implementation to decide whether to modify this
- single leaf in 'startup' or perform an implicit
- copy-config from 'running' to 'startup'.
-
- If the device does not support ':startup',
- ifAlias MUST be mapped to the 'description' leaf
- in the 'running' datastore.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifAlias";
- }
-
- leaf type {
- type identityref {
- base interface-type;
- }
- mandatory true;
- description
- "The type of the interface.
-
- When an interface entry is created, a server MAY
- initialize the type leaf with a valid value, e.g.,
- if it is possible to derive the type from the name
- of the interface.
-
- If a client tries to set the type of an
- interface to a value that can never be used by
- the system, e.g., if the type is not supported
- or if the type does not match the name of the
- interface, the server MUST reject the request. A
- NETCONF server MUST reply with an rpc-error with
- the error-tag 'invalid-value' in this case.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifType";
- }
-
- leaf enabled {
- type boolean;
- default "true";
- description
- "This leaf contains the configured, desired state
- of the interface.
-
- Systems that implement the IF-MIB use the value
- of this leaf in the 'running' datastore to set
- IF-MIB.ifAdminStatus to 'up' or 'down' after an
- ifEntry has been initialized, as described in
- RFC 2863. Changes in this leaf in the 'running'
- datastore are reflected in ifAdminStatus, but if
- ifAdminStatus is changed over SNMP, this leaf is
- not affected.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifAdminStatus";
- }
-
- leaf link-up-down-trap-enable {
- if-feature if-mib;
- type enumeration {
- enum enabled {
- value 1;
- }
- enum disabled {
- value 2;
- }
- }
- description
- "Controls whether linkUp/linkDown SNMP
- notifications should be generated for this
- interface.
-
- If this node is not configured, the value 'enabled'
- is operationally used by the server for
- interfaces that do not operate on top of any
- other interface (i.e., there are no
- 'lower-layer-if' entries), and 'disabled'
- otherwise.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifLinkUpDownTrapEnable";
- }
- }
- }
- /*
- * Operational state data nodes
- */
-
- container interfaces-state {
- config false;
- description
- "Data nodes for the operational state of interfaces.";
-
- list interface {
- key "name";
- description
- "The list of interfaces on the device.
-
- System-controlled interfaces created by the system are
- always present in this list, whether they are configured or
- not.";
-
- leaf name {
- type string;
- description
- "The name of the interface.
-
- A server implementation MAY map this leaf to the ifName
- MIB object. Such an implementation needs to use some
- mechanism to handle the differences in size and characters
- allowed between this leaf and ifName. The definition of
- such a mechanism is outside the scope of this document.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifName";
- }
-
- leaf type {
- type identityref {
- base interface-type;
- }
- mandatory true;
- description
- "The type of the interface.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifType";
- }
-
- leaf admin-status {
- if-feature if-mib;
- type enumeration {
- enum up {
- value 1;
- description
- "Ready to pass packets.";
- }
- enum down {
- value 2;
- description
- "Not ready to pass packets and not in some test mode.";
- }
- enum testing {
- value 3;
- description
- "In some test mode.";
- }
- }
- mandatory true;
- description
- "The desired state of the interface.
-
- This leaf has the same read semantics as ifAdminStatus.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifAdminStatus";
- }
-
- leaf oper-status {
- type enumeration {
- enum up {
- value 1;
- description
- "Ready to pass packets.";
- }
- enum down {
- value 2;
- description
- "The interface does not pass any packets.";
- }
- enum testing {
- value 3;
- description
- "In some test mode. No operational packets can
- be passed.";
- }
- enum unknown {
- value 4;
- description
- "Status cannot be determined for some reason.";
- }
- enum dormant {
- value 5;
- description
- "Waiting for some external event.";
- }
- enum not-present {
- value 6;
- description
- "Some component (typically hardware) is missing.";
- }
- enum lower-layer-down {
- value 7;
- description
- "Down due to state of lower-layer interface(s).";
- }
- }
- mandatory true;
- description
- "The current operational state of the interface.
-
- This leaf has the same semantics as ifOperStatus.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifOperStatus";
- }
-
- leaf last-change {
- type yang:date-and-time;
- description
- "The time the interface entered its current operational
- state. If the current state was entered prior to the
- last re-initialization of the local network management
- subsystem, then this node is not present.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifLastChange";
- }
-
- leaf if-index {
- if-feature if-mib;
- type int32 {
- range "1..2147483647";
- }
- mandatory true;
- description
- "The ifIndex value for the ifEntry represented by this
- interface.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifIndex";
- }
-
- leaf phys-address {
- type yang:phys-address;
- description
- "The interface's address at its protocol sub-layer. For
- example, for an 802.x interface, this object normally
- contains a Media Access Control (MAC) address. The
- interface's media-specific modules must define the bit
-
- and byte ordering and the format of the value of this
- object. For interfaces that do not have such an address
- (e.g., a serial line), this node is not present.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifPhysAddress";
- }
-
- leaf-list higher-layer-if {
- type interface-state-ref;
- description
- "A list of references to interfaces layered on top of this
- interface.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifStackTable";
- }
-
- leaf-list lower-layer-if {
- type interface-state-ref;
- description
- "A list of references to interfaces layered underneath this
- interface.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifStackTable";
- }
-
- leaf speed {
- type yang:gauge64;
- units "bits/second";
- description
- "An estimate of the interface's current bandwidth in bits
- per second. For interfaces that do not vary in
- bandwidth or for those where no accurate estimation can
- be made, this node should contain the nominal bandwidth.
- For interfaces that have no concept of bandwidth, this
- node is not present.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifSpeed, ifHighSpeed";
- }
- container statistics {
- description
- "A collection of interface-related statistics objects.";
-
- leaf discontinuity-time {
- type yang:date-and-time;
- mandatory true;
- description
- "The time on the most recent occasion at which any one or
- more of this interface's counters suffered a
- discontinuity. If no such discontinuities have occurred
- since the last re-initialization of the local management
- subsystem, then this node contains the time the local
- management subsystem re-initialized itself.";
- }
-
- leaf in-octets {
- type yang:counter64;
- description
- "The total number of octets received on the interface,
- including framing characters.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifHCInOctets";
- }
-
- leaf in-unicast-pkts {
- type yang:counter64;
- description
- "The number of packets, delivered by this sub-layer to a
- higher (sub-)layer, that were not addressed to a
- multicast or broadcast address at this sub-layer.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts";
- }
- leaf in-broadcast-pkts {
- type yang:counter64;
- description
- "The number of packets, delivered by this sub-layer to a
- higher (sub-)layer, that were addressed to a broadcast
- address at this sub-layer.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifHCInBroadcastPkts";
- }
-
- leaf in-multicast-pkts {
- type yang:counter64;
- description
- "The number of packets, delivered by this sub-layer to a
- higher (sub-)layer, that were addressed to a multicast
- address at this sub-layer. For a MAC-layer protocol,
- this includes both Group and Functional addresses.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifHCInMulticastPkts";
- }
-
- leaf in-discards {
- type yang:counter32;
- description
- "The number of inbound packets that were chosen to be
- discarded even though no errors had been detected to
- prevent their being deliverable to a higher-layer
- protocol. One possible reason for discarding such a
- packet could be to free up buffer space.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifInDiscards";
- }
-
- leaf in-errors {
- type yang:counter32;
- description
- "For packet-oriented interfaces, the number of inbound
- packets that contained errors preventing them from being
- deliverable to a higher-layer protocol. For character-
- oriented or fixed-length interfaces, the number of
- inbound transmission units that contained errors
- preventing them from being deliverable to a higher-layer
- protocol.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifInErrors";
- }
-
- leaf in-unknown-protos {
- type yang:counter32;
- description
- "For packet-oriented interfaces, the number of packets
- received via the interface that were discarded because
- of an unknown or unsupported protocol. For
- character-oriented or fixed-length interfaces that
- support protocol multiplexing, the number of
- transmission units received via the interface that were
- discarded because of an unknown or unsupported protocol.
- For any interface that does not support protocol
- multiplexing, this counter is not present.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos";
- }
- leaf out-octets {
- type yang:counter64;
- description
- "The total number of octets transmitted out of the
- interface, including framing characters.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifHCOutOctets";
- }
-
- leaf out-unicast-pkts {
- type yang:counter64;
- description
- "The total number of packets that higher-level protocols
- requested be transmitted, and that were not addressed
- to a multicast or broadcast address at this sub-layer,
- including those that were discarded or not sent.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts";
- }
-
- leaf out-broadcast-pkts {
- type yang:counter64;
- description
- "The total number of packets that higher-level protocols
- requested be transmitted, and that were addressed to a
- broadcast address at this sub-layer, including those
- that were discarded or not sent.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifHCOutBroadcastPkts";
- }
- leaf out-multicast-pkts {
- type yang:counter64;
- description
- "The total number of packets that higher-level protocols
- requested be transmitted, and that were addressed to a
- multicast address at this sub-layer, including those
- that were discarded or not sent. For a MAC-layer
- protocol, this includes both Group and Functional
- addresses.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB -
- ifHCOutMulticastPkts";
- }
-
- leaf out-discards {
- type yang:counter32;
- description
- "The number of outbound packets that were chosen to be
- discarded even though no errors had been detected to
- prevent their being transmitted. One possible reason
- for discarding such a packet could be to free up buffer
- space.
-
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifOutDiscards";
- }
-
- leaf out-errors {
- type yang:counter32;
- description
- "For packet-oriented interfaces, the number of outbound
- packets that could not be transmitted because of errors.
- For character-oriented or fixed-length interfaces, the
- number of outbound transmission units that could not be
- transmitted because of errors.
- Discontinuities in the value of this counter can occur
- at re-initialization of the management system, and at
- other times as indicated by the value of
- 'discontinuity-time'.";
- reference
- "RFC 2863: The Interfaces Group MIB - ifOutErrors";
- }
- }
- }
- }
- }
- }
- }
\ No newline at end of file
diff --git a/models/l3vpn/src/main/yang/ietf-ip@2014-06-16.yang b/models/l3vpn/src/main/yang/ietf-ip@2014-06-16.yang
deleted file mode 100644
index 0446258..0000000
--- a/models/l3vpn/src/main/yang/ietf-ip@2014-06-16.yang
+++ /dev/null
@@ -1,740 +0,0 @@
-module ietf-ip {
-
- yang-version 1;
-
- namespace
- "urn:ietf:params:xml:ns:yang:ietf-ip";
-
- prefix ip;
-
- import ietf-interfaces {
- prefix if;
- }
- import ietf-inet-types {
- prefix inet;
- }
- import ietf-yang-types {
- prefix yang;
- }
-
- organization
- "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
- contact
- "WG Web: <http://tools.ietf.org/wg/netmod/>
- WG List: <mailto:netmod@ietf.org>
-
- WG Chair: Thomas Nadeau
- <mailto:tnadeau@lucidvision.com>
-
- WG Chair: Juergen Schoenwaelder
- <mailto:j.schoenwaelder@jacobs-university.de>
-
- Editor: Martin Bjorklund
- <mailto:mbj@tail-f.com>";
-
- description
- "This module contains a collection of YANG definitions for
- configuring IP implementations.
-
- Copyright (c) 2014 IETF Trust and the persons identified as
- authors of the code. All rights reserved.
-
- Redistribution and use in source and binary forms, with or
- without modification, is permitted pursuant to, and subject
- to the license terms contained in, the Simplified BSD License
- set forth in Section 4.c of the IETF Trust's Legal Provisions
- Relating to IETF Documents
- (http://trustee.ietf.org/license-info).
-
- This version of this YANG module is part of RFC 7277; see
- the RFC itself for full legal notices.";
-
- revision "2014-06-16" {
- description "Initial revision.";
- reference
- "RFC 7277: A YANG Data Model for IP Management";
-
- }
-
- feature ipv4-non-contiguous-netmasks {
- description
- "Indicates support for configuring non-contiguous
- subnet masks.";
- }
-
- feature ipv6-privacy-autoconf {
- description
- "Indicates support for Privacy Extensions for Stateless Address
- Autoconfiguration in IPv6.";
- reference
- "RFC 4941: Privacy Extensions for Stateless Address
- Autoconfiguration in IPv6";
- }
-
- typedef ip-address-origin {
- type enumeration {
- enum "other" {
- value 0;
- description
- "None of the following.";
- }
- enum "static" {
- value 1;
- description
- "Indicates that the address has been statically
- configured - for example, using NETCONF or a Command Line
- Interface.";
- }
- enum "dhcp" {
- value 2;
- description
- "Indicates an address that has been assigned to this
- system by a DHCP server.";
- }
- enum "link-layer" {
- value 3;
- description
- "Indicates an address created by IPv6 stateless
- autoconfiguration that embeds a link-layer address in its
- interface identifier.";
- }
- enum "random" {
- value 4;
- description
- "Indicates an address chosen by the system at
-
- random, e.g., an IPv4 address within 169.254/16, an
- RFC 4941 temporary address, or an RFC 7217 semantically
- opaque address.";
- reference
- "RFC 4941: Privacy Extensions for Stateless Address
- Autoconfiguration in IPv6
- RFC 7217: A Method for Generating Semantically Opaque
- Interface Identifiers with IPv6 Stateless
- Address Autoconfiguration (SLAAC)";
- }
- }
- description
- "The origin of an address.";
- }
-
- typedef neighbor-origin {
- type enumeration {
- enum "other" {
- value 0;
- description
- "None of the following.";
- }
- enum "static" {
- value 1;
- description
- "Indicates that the mapping has been statically
- configured - for example, using NETCONF or a Command Line
- Interface.";
- }
- enum "dynamic" {
- value 2;
- description
- "Indicates that the mapping has been dynamically resolved
- using, e.g., IPv4 ARP or the IPv6 Neighbor Discovery
- protocol.";
- }
- }
- description
- "The origin of a neighbor entry.";
- }
-
- augment /if:devices/if:device/if:interfaces/if:interface {
- description
- "Parameters for configuring IP on interfaces.
-
- If an interface is not capable of running IP, the server
- must not allow the client to configure these parameters.";
- container ipv4 {
- presence
- "Enables IPv4 unless the 'enabled' leaf
- (which defaults to 'true') is set to 'false'";
- description
- "Parameters for the IPv4 address family.";
- leaf enabled {
- type boolean;
- default true;
- description
- "Controls whether IPv4 is enabled or disabled on this
- interface. When IPv4 is enabled, this interface is
- connected to an IPv4 stack, and the interface can send
- and receive IPv4 packets.";
- }
-
- leaf forwarding {
- type boolean;
- default false;
- description
- "Controls IPv4 packet forwarding of datagrams received by,
- but not addressed to, this interface. IPv4 routers
- forward datagrams. IPv4 hosts do not (except those
- source-routed via the host).";
- }
-
- leaf mtu {
- type uint16 {
- range "68..max";
- }
- units "octets";
- description
- "The size, in octets, of the largest IPv4 packet that the
- interface will send and receive.
-
- The server may restrict the allowed values for this leaf,
- depending on the interface's type.
-
- If this leaf is not configured, the operationally used MTU
- depends on the interface's type.";
- reference
- "RFC 791: Internet Protocol";
-
- }
-
- list address {
- key "ip";
- description
- "The list of configured IPv4 addresses on the interface.";
- leaf ip {
- type inet:ipv4-address-no-zone;
- description
- "The IPv4 address on the interface.";
- }
-
- choice subnet {
- mandatory true;
- description
- "The subnet can be specified as a prefix-length, or,
- if the server supports non-contiguous netmasks, as
- a netmask.";
- leaf prefix-length {
- type uint8 {
- range "0..32";
- }
- description
- "The length of the subnet prefix.";
- }
- leaf netmask {
- if-feature ipv4-non-contiguous-netmasks;
- type yang:dotted-quad;
- description
- "The subnet specified as a netmask.";
- }
- } // choice subnet
- } // list address
-
- list neighbor {
- key "ip";
- description
- "A list of mappings from IPv4 addresses to
- link-layer addresses.
-
- Entries in this list are used as static entries in the
- ARP Cache.";
- reference
- "RFC 826: An Ethernet Address Resolution Protocol";
-
- leaf ip {
- type inet:ipv4-address-no-zone;
- description
- "The IPv4 address of the neighbor node.";
- }
-
- leaf link-layer-address {
- type yang:phys-address;
- mandatory true;
- description
- "The link-layer address of the neighbor node.";
- }
- } // list neighbor
- } // container ipv4
-
- container ipv6 {
- presence
- "Enables IPv6 unless the 'enabled' leaf
- (which defaults to 'true') is set to 'false'";
- description
- "Parameters for the IPv6 address family.";
- leaf enabled {
- type boolean;
- default true;
- description
- "Controls whether IPv6 is enabled or disabled on this
- interface. When IPv6 is enabled, this interface is
- connected to an IPv6 stack, and the interface can send
- and receive IPv6 packets.";
- }
-
- leaf forwarding {
- type boolean;
- default false;
- description
- "Controls IPv6 packet forwarding of datagrams received by,
- but not addressed to, this interface. IPv6 routers
- forward datagrams. IPv6 hosts do not (except those
- source-routed via the host).";
- reference
- "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
- Section 6.2.1, IsRouter";
-
- }
-
- leaf mtu {
- type uint32 {
- range "1280..max";
- }
- units "octets";
- description
- "The size, in octets, of the largest IPv6 packet that the
- interface will send and receive.
-
- The server may restrict the allowed values for this leaf,
- depending on the interface's type.
-
- If this leaf is not configured, the operationally used MTU
- depends on the interface's type.";
- reference
- "RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
- Section 5";
-
- }
-
- list address {
- key "ip";
- description
- "The list of configured IPv6 addresses on the interface.";
- leaf ip {
- type inet:ipv6-address-no-zone;
- description
- "The IPv6 address on the interface.";
- }
-
- leaf prefix-length {
- type uint8 {
- range "0..128";
- }
- mandatory true;
- description
- "The length of the subnet prefix.";
- }
- } // list address
-
- list neighbor {
- key "ip";
- description
- "A list of mappings from IPv6 addresses to
- link-layer addresses.
-
- Entries in this list are used as static entries in the
- Neighbor Cache.";
- reference
- "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)";
-
- leaf ip {
- type inet:ipv6-address-no-zone;
- description
- "The IPv6 address of the neighbor node.";
- }
-
- leaf link-layer-address {
- type yang:phys-address;
- mandatory true;
- description
- "The link-layer address of the neighbor node.";
- }
- } // list neighbor
-
- leaf dup-addr-detect-transmits {
- type uint32;
- default 1;
- description
- "The number of consecutive Neighbor Solicitation messages
- sent while performing Duplicate Address Detection on a
- tentative address. A value of zero indicates that
- Duplicate Address Detection is not performed on
- tentative addresses. A value of one indicates a single
- transmission with no follow-up retransmissions.";
- reference
- "RFC 4862: IPv6 Stateless Address Autoconfiguration";
-
- }
-
- container autoconf {
- description
- "Parameters to control the autoconfiguration of IPv6
- addresses, as described in RFC 4862.";
- reference
- "RFC 4862: IPv6 Stateless Address Autoconfiguration";
-
- leaf create-global-addresses {
- type boolean;
- default true;
- description
- "If enabled, the host creates global addresses as
- described in RFC 4862.";
- reference
- "RFC 4862: IPv6 Stateless Address Autoconfiguration
- Section 5.5";
-
- }
-
- leaf create-temporary-addresses {
- if-feature ipv6-privacy-autoconf;
- type boolean;
- default false;
- description
- "If enabled, the host creates temporary addresses as
- described in RFC 4941.";
- reference
- "RFC 4941: Privacy Extensions for Stateless Address
- Autoconfiguration in IPv6";
-
- }
-
- leaf temporary-valid-lifetime {
- if-feature ipv6-privacy-autoconf;
- type uint32;
- units "seconds";
- default 604800;
- description
- "The time period during which the temporary address
- is valid.";
- reference
- "RFC 4941: Privacy Extensions for Stateless Address
- Autoconfiguration in IPv6
- - TEMP_VALID_LIFETIME";
-
- }
-
- leaf temporary-preferred-lifetime {
- if-feature ipv6-privacy-autoconf;
- type uint32;
- units "seconds";
- default 86400;
- description
- "The time period during which the temporary address is
- preferred.";
- reference
- "RFC 4941: Privacy Extensions for Stateless Address
- Autoconfiguration in IPv6
- - TEMP_PREFERRED_LIFETIME";
-
- }
- } // container autoconf
- } // container ipv6
- }
-
- augment /if:devices/if:device/if:interfaces-state/if:interface {
- description
- "Data nodes for the operational state of IP on interfaces.";
- container ipv4 {
- presence
- "Present if IPv4 is enabled on this interface";
- config false;
- description
- "Interface-specific parameters for the IPv4 address family.";
- leaf forwarding {
- type boolean;
- description
- "Indicates whether IPv4 packet forwarding is enabled or
- disabled on this interface.";
- }
-
- leaf mtu {
- type uint16 {
- range "68..max";
- }
- units "octets";
- description
- "The size, in octets, of the largest IPv4 packet that the
- interface will send and receive.";
- reference
- "RFC 791: Internet Protocol";
-
- }
-
- list address {
- key "ip";
- description
- "The list of IPv4 addresses on the interface.";
- leaf ip {
- type inet:ipv4-address-no-zone;
- description
- "The IPv4 address on the interface.";
- }
-
- choice subnet {
- description
- "The subnet can be specified as a prefix-length, or,
- if the server supports non-contiguous netmasks, as
- a netmask.";
- leaf prefix-length {
- type uint8 {
- range "0..32";
- }
- description
- "The length of the subnet prefix.";
- }
- leaf netmask {
- if-feature ipv4-non-contiguous-netmasks;
- type yang:dotted-quad;
- description
- "The subnet specified as a netmask.";
- }
- } // choice subnet
-
- leaf origin {
- type ip-address-origin;
- description
- "The origin of this address.";
- }
- } // list address
-
- list neighbor {
- key "ip";
- description
- "A list of mappings from IPv4 addresses to
- link-layer addresses.
-
- This list represents the ARP Cache.";
- reference
- "RFC 826: An Ethernet Address Resolution Protocol";
-
- leaf ip {
- type inet:ipv4-address-no-zone;
- description
- "The IPv4 address of the neighbor node.";
- }
-
- leaf link-layer-address {
- type yang:phys-address;
- description
- "The link-layer address of the neighbor node.";
- }
-
- leaf origin {
- type neighbor-origin;
- description
- "The origin of this neighbor entry.";
- }
- } // list neighbor
- } // container ipv4
-
- container ipv6 {
- presence
- "Present if IPv6 is enabled on this interface";
- config false;
- description
- "Parameters for the IPv6 address family.";
- leaf forwarding {
- type boolean;
- default false;
- description
- "Indicates whether IPv6 packet forwarding is enabled or
- disabled on this interface.";
- reference
- "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
- Section 6.2.1, IsRouter";
-
- }
-
- leaf mtu {
- type uint32 {
- range "1280..max";
- }
- units "octets";
- description
- "The size, in octets, of the largest IPv6 packet that the
- interface will send and receive.";
- reference
- "RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
- Section 5";
-
- }
-
- list address {
- key "ip";
- description
- "The list of IPv6 addresses on the interface.";
- leaf ip {
- type inet:ipv6-address-no-zone;
- description
- "The IPv6 address on the interface.";
- }
-
- leaf prefix-length {
- type uint8 {
- range "0..128";
- }
- mandatory true;
- description
- "The length of the subnet prefix.";
- }
-
- leaf origin {
- type ip-address-origin;
- description
- "The origin of this address.";
- }
-
- leaf status {
- type enumeration {
- enum "preferred" {
- value 0;
- description
- "This is a valid address that can appear as the
- destination or source address of a packet.";
- }
- enum "deprecated" {
- value 1;
- description
- "This is a valid but deprecated address that should
- no longer be used as a source address in new
- communications, but packets addressed to such an
- address are processed as expected.";
- }
- enum "invalid" {
- value 2;
- description
- "This isn't a valid address, and it shouldn't appear
- as the destination or source address of a packet.";
- }
- enum "inaccessible" {
- value 3;
- description
- "The address is not accessible because the interface
- to which this address is assigned is not
- operational.";
- }
- enum "unknown" {
- value 4;
- description
- "The status cannot be determined for some reason.";
- }
- enum "tentative" {
- value 5;
- description
- "The uniqueness of the address on the link is being
- verified. Addresses in this state should not be
- used for general communication and should only be
- used to determine the uniqueness of the address.";
- }
- enum "duplicate" {
- value 6;
- description
- "The address has been determined to be non-unique on
- the link and so must not be used.";
- }
- enum "optimistic" {
- value 7;
- description
- "The address is available for use, subject to
- restrictions, while its uniqueness on a link is
- being verified.";
- }
- }
- description
- "The status of an address. Most of the states correspond
- to states from the IPv6 Stateless Address
- Autoconfiguration protocol.";
- reference
- "RFC 4293: Management Information Base for the
- Internet Protocol (IP)
- - IpAddressStatusTC
- RFC 4862: IPv6 Stateless Address Autoconfiguration";
-
- }
- } // list address
-
- list neighbor {
- key "ip";
- description
- "A list of mappings from IPv6 addresses to
- link-layer addresses.
-
- This list represents the Neighbor Cache.";
- reference
- "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)";
-
- leaf ip {
- type inet:ipv6-address-no-zone;
- description
- "The IPv6 address of the neighbor node.";
- }
-
- leaf link-layer-address {
- type yang:phys-address;
- description
- "The link-layer address of the neighbor node.";
- }
-
- leaf origin {
- type neighbor-origin;
- description
- "The origin of this neighbor entry.";
- }
-
- leaf is-router {
- type empty;
- description
- "Indicates that the neighbor node acts as a router.";
- }
-
- leaf state {
- type enumeration {
- enum "incomplete" {
- value 0;
- description
- "Address resolution is in progress, and the link-layer
- address of the neighbor has not yet been
- determined.";
- }
- enum "reachable" {
- value 1;
- description
- "Roughly speaking, the neighbor is known to have been
- reachable recently (within tens of seconds ago).";
- }
- enum "stale" {
- value 2;
- description
- "The neighbor is no longer known to be reachable, but
- until traffic is sent to the neighbor no attempt
- should be made to verify its reachability.";
- }
- enum "delay" {
- value 3;
- description
- "The neighbor is no longer known to be reachable, and
- traffic has recently been sent to the neighbor.
- Rather than probe the neighbor immediately, however,
- delay sending probes for a short while in order to
- give upper-layer protocols a chance to provide
- reachability confirmation.";
- }
- enum "probe" {
- value 4;
- description
- "The neighbor is no longer known to be reachable, and
- unicast Neighbor Solicitation probes are being sent
- to verify reachability.";
- }
- }
- description
- "The Neighbor Unreachability Detection state of this
- entry.";
- reference
- "RFC 4861: Neighbor Discovery for IP version 6 (IPv6)
- Section 7.3.2";
-
- }
- } // list neighbor
- } // container ipv6
- }
- } // module ietf-ip
-
diff --git a/models/l3vpn/src/main/yang/ietf-l3vpn-svc@2016-07-30.yang b/models/l3vpn/src/main/yang/ietf-l3vpn-svc@2016-07-30.yang
deleted file mode 100644
index dbd60dc..0000000
--- a/models/l3vpn/src/main/yang/ietf-l3vpn-svc@2016-07-30.yang
+++ /dev/null
@@ -1,2599 +0,0 @@
-module ietf-l3vpn-svc {
-
- namespace "urn:ietf:params:xml:ns:yang:ietf-l3vpn-svc";
-
- prefix l3vpn-svc;
-
- import ietf-inet-types {
- prefix inet;
- }
-
- import ietf-yang-types {
- prefix yang;
- }
-
- organization
- "IETF L3SM Working Group";
-
- contact
- "WG List: <mailto:l3sm@ietf.org>
-
- Editor:
-
- ";
-
- description
- "The YANG module defines a generic service configuration
- model for Layer 3 VPN common across all of the vendor
- implementations.";
-
- revision 2016-07-30 {
- description
- "Eliminated warnings";
- reference
- "draft-ietf-l3sm-l3vpn-service-yang-11";
- }
-
- revision 2016-07-05 {
- description
- "Draft text update";
- reference
- "draft-ietf-l3sm-l3vpn-service-yang-11";
- }
- revision 2016-06-27 {
- description
- "
- * Removed templates
- * Add site-network-access-type
- * Add a leaf number-of-dynamic-address in case
- of pe-dhcp addressing;
-
- ";
- reference "draft-ietf-l3sm-l3vpn-service-yang-10";
- }
- revision 2016-06-10 {
- description
- "Add site-vpn-flavor NNI";
- reference "draft-ietf-l3sm-l3vpn-service-yang-09";
- }
- revision 2016-06-09 {
- description
- "Traffic protection moved to site level.
- Decouple operational-requirements in two containers.
- ";
- reference "draft-ietf-l3sm-l3vpn-service-yang-08";
- }
- revision 2016-06-06 {
- description
- "Set config false to actual-site-start and stop
- Add a container before cloud-access list
- Add a container before authorized-sites list
- Add a container before denied-sites list
- Modified access-diversity modeling
- Replacing type placement diversity by an identity";
- reference "draft-ietf-l3sm-l3vpn-service-yang-07";
- }
- revision 2016-04-19 {
- description
- "* remove reference to core routing model :
- created new address family identities
- * added features
- * Modified bearer parameters
- * Modified union for ipv4/ipv6 addresses to ip-address
- type
- * Add BSR parameters for multicast
- * Add applications matching for QoS classification
- ";
- reference "draft-ietf-l3sm-l3vpn-service-yang-06";
- }
- revision 2016-04-05 {
- description
- "
- * Added linecard diverse for site diversity
- * Added a new diversity enum in placement-diversity : none
- * Added state to site location
-
- ";
- reference "";
- }
- revision 2016-03-11 {
- description
- "
- * Modify VPN policy and creating a vpn-policy-list
- * Add VPN policy reference and VPN ID reference
- under site-network-access
- ";
- reference "draft-ietf-l3sm-l3vpn-service-yang-05";
- }
- revision 2016-01-04 {
- description
- "
- * Add extranet-vpn container in vpn-svc
- * Creating top level containers
- * Refine groupings
- * Added site-vpn-flavor
- ";
- reference "draft-ietf-l3sm-l3vpn-service-yang-03";
- }
- revision 2016-01-04 {
- description
- "
- * qos-profile moved to choice
- * vpn leaf moved to vpn-id in vpn-policy
- * added ordered-by user to qos classification list
- * moved traffic protection to access availability
- * creating a choice in matching filter for VPN policy
- * added dot1p matching field in flow-definition
- ";
- reference "";
- }
- revision 2015-12-07 {
- description
- "
- * A site is now a collection of site-accesses.
- This was introduced to support M to N availability.
- * Site-availability has been removed, replaced by
- availability parameters under site-accesses
- * Added transport-constraints within vpn-svc
- ";
- reference "draft-ietf-l3sm-l3vpn-service-yang-02";
- }
- revision 2015-11-03 {
- description "
- * Add ToS support in match-flow
- * nexthop in cascaded lan as mandatory
- * customer-specific-info deleted and moved to routing
- protocols
- * customer-lan-connection modified : need prefix and CE address
- * add choice in managing PE-CE addressing
- * Simplifying traffic protection
- ";
- reference "";
- }
- revision 2015-09-10 {
- description "
- * Refine groupings for vpn-svc
- * Removed name in vpn-svc
- * id in vpn-svc moved to string
- * Rename id in vpn-svc to vpn-id
- * Changed key of vpn-svc list to vpn-id
- * Add DSCP support in flow definition
- ";
- reference "";
- }
- revision 2015-08-07 {
- description
- "
- Multicast :
- * Removed ACL from security
- * Add FW for site and cloud access
- ";
- reference "";
- }
- revision 2015-08-05 {
- description
- "
- Multicast :
- * Removed anycast-rp identity as discovery mechanism
- * Added rp-group mappings for multicast
- * Added flag for provider managed RP.
- ";
- reference "";
- }
- revision 2015-08-03 {
- description
- " * Creating multiple reusable groupings
- * Added mpls leaf in vpn-svc for carrier's carrier case
- * Modify identity single to single-site
- * Modify site-type to site-role and also child identities.
- * Creating OAM container under site and moved BFD in.
- * Creating flow-definition grouping to be reused
- in ACL, QoS ...
- * Simplified VPN policy.
- * Adding multicast static group to RP mappings.
- * Removed native-vpn and site-role from global site
- cfg, now managed within the VPN policy.
- * Creating a separate list for site templates.
- ";
- reference "draft-ietf-l3sm-l3vpn-service-yang-01";
- }
- revision 2015-07-02 {
- reference "draft-ietf-l3sm-l3vpn-service-yang-00";
- }
- revision 2015-04-24 {
- description "
- * Add encryption parameters
- * Adding holdtime for BFD.
- * Add postal address in location
- ";
- reference "draft-lstd-l3sm-l3vpn-service-yang-00";
- }
- revision 2015-02-05 {
- description "Initial revision.";
- reference "draft-l3vpn-service-yang-00";
- }
-
- /* Features */
-
- feature cloud-access {
- description
- "Allow VPN to connect to a Cloud Service
- provider.";
- }
- feature multicast {
- description
- "Enables multicast capabilities in a VPN";
- }
- feature ipv4 {
- description
- "Enables IPv4 support in a VPN";
- }
- feature ipv6 {
- description
- "Enables IPv6 support in a VPN";
- }
- feature carrierscarrier {
- description
- "Enables support of carrier's carrier";
- }
- feature traffic-engineering {
- description
- "Enables support of transport constraint.";
- }
- feature traffic-engineering-multicast {
- description
- "Enables support of transport constraint
- for multicast.";
- }
- feature extranet-vpn {
- description
- "Enables support of extranet VPNs";
- }
- feature site-diversity {
- description
- "Enables support of site diversity constraints";
- }
- feature encryption {
- description
- "Enables support of encryption";
- }
- feature qos {
- description
- "Enables support of Class of Services";
- }
- feature qos-custom {
- description
- "Enables support of custom qos profile";
- }
- feature rtg-bgp {
- description
- "Enables support of BGP routing protocol.";
- }
- feature rtg-rip {
- description
- "Enables support of RIP routing protocol.";
- }
- feature rtg-ospf {
- description
- "Enables support of OSPF routing protocol.";
- }
- feature rtg-ospf-sham-link {
- description
- "Enables support of OSPF sham-links.";
- }
- feature rtg-vrrp {
- description
- "Enables support of VRRP routing protocol.";
- }
- feature fast-reroute {
- description
- "Enables support of Fast Reroute.";
- }
- feature bfd {
- description
- "Enables support of BFD.";
- }
- feature always-on {
- description
- "Enables support for always-on access
- constraint.";
- }
- feature requested-type {
- description
- "Enables support for requested-type access
- constraint.";
- }
- feature bearer-reference {
- description
- "Enables support for bearer-reference access
- constraint.";
- }
-
- /* Typedefs */
-
- typedef svc-id {
- type string;
- description
- "Defining a type of service component
- identificators.";
- }
-
- typedef template-id {
- type string;
- description
- "Defining a type of service template
- identificators.";
- }
-
- /* Identities */
-
- identity site-network-access-type {
- description
- "Base identity for site-network-access type";
- }
- identity point-to-point {
- base site-network-access-type;
- description
- "Identity for point-to-point connection";
- }
- identity multipoint {
- base site-network-access-type;
- description
- "Identity for multipoint connection
- Example : ethernet broadcast segment";
- }
- identity placement-diversity {
- description
- "Base identity for site placement
- constraints";
- }
- identity pe-diverse {
- base placement-diversity;
- description
- "Identity for PE diversity";
- }
- identity pop-diverse {
- base placement-diversity;
- description
- "Identity for POP diversity";
- }
- identity linecard-diverse {
- base placement-diversity;
- description
- "Identity for linecard diversity";
- }
- identity same-pe {
- base placement-diversity;
- description
- "Identity for having sites connected
- on the same PE";
- }
- identity same-bearer {
- base placement-diversity;
- description
- "Identity for having sites connected
- using the same bearer";
- }
- identity customer-application {
- description
- "Base identity for customer application";
- }
- identity web {
- base customer-application;
- description
- "Identity for web application (e.g. HTTP,HTTPS)";
- }
- identity mail {
- base customer-application;
- description
- "Identity for mail applications";
- }
- identity file-transfer {
- base customer-application;
- description
- "Identity for file transfer applications (
- e.g. FTP, SFTP, ...)";
- }
- identity database {
- base customer-application;
- description
- "Identity for database applications";
- }
- identity social {
- base customer-application;
- description
- "Identity for social network applications";
- }
- identity games {
- base customer-application;
- description
- "Identity for gaming applications";
- }
- identity p2p {
- base customer-application;
- description
- "Identity for peer to peer applications";
- }
- identity network-management {
- base customer-application;
- description
- "Identity for management applications (e.g. telnet
- syslog, snmp ...)";
- }
- identity voice {
- base customer-application;
- description
- "Identity for voice applications";
- }
- identity video {
- base customer-application;
- description
- "Identity for video conference applications";
- }
- identity address-family {
- description
- "Base identity for an address family.";
- }
- identity ipv4 {
- base address-family;
- description
- "Identity for IPv4 address family.";
- }
- identity ipv6 {
- base address-family;
- description
- "Identity for IPv6 address family.";
- }
- identity site-vpn-flavor {
- description
- "Base identity for the site VPN service flavor.";
- }
- identity site-vpn-flavor-single {
- base site-vpn-flavor;
- description
- "Base identity for the site VPN service flavor.
- Used when the site belongs to only one VPN.";
- }
- identity site-vpn-flavor-multi {
- base site-vpn-flavor;
- description
- "Base identity for the site VPN service flavor.
- Used when a logical connection of a site
- belongs to multiple VPNs.";
- }
- identity site-vpn-flavor-sub {
- base site-vpn-flavor;
- description
- "Base identity for the site VPN service flavor.
- Used when a site has multiple logical connections.
- Each of the connection may belong to different
- multiple VPNs.";
- }
- identity site-vpn-flavor-nni {
- base site-vpn-flavor;
- description
- "Base identity for the site VPN service flavor.
- Used to describe a NNI option A connection.";
- }
- identity transport-constraint {
- description
- "Base identity for transport constraint.";
- }
- identity tc-latency {
- base transport-constraint;
- description
- "Base identity for transport constraint
- based on latency.";
- }
- identity tc-jitter {
- base transport-constraint;
- description
- "Base identity for transport constraint
- based on jitter.";
- }
- identity tc-bandwidth {
- base transport-constraint;
- description
- "Base identity for transport constraint
- based on bandwidth.";
- }
- identity tc-path-diversity {
- base transport-constraint;
- description
- "Base identity for transport constraint
- based on path diversity.";
- }
- identity tc-site-diversity {
- base transport-constraint;
- description
- "Base identity for transport constraint
- based on site diversity.";
- }
- identity management {
- description
- "Base identity for site management scheme.";
- }
- identity co-managed {
- base management;
- description
- "Base identity for comanaged site.";
- }
- identity customer-managed {
- base management;
- description
- "Base identity for customer managed site.";
- }
- identity provider-managed {
- base management;
- description
- "Base identity for provider managed site.";
- }
- identity address-allocation-type {
- description
- "Base identity for address-allocation-type
- for PE-CE link.";
- }
- identity pe-dhcp {
- base address-allocation-type;
- description
- "PE router provides DHCP service to CE.";
- }
- identity static-address {
- base address-allocation-type;
- description
- "PE-CE addressing is static.";
- }
- identity slaac {
- base address-allocation-type;
- description
- "Use IPv6 SLAAC.";
- }
- identity site-role {
- description
- "Base identity for site type.";
- }
- identity any-to-any-role {
- base site-role;
- description
- "Site in a any to any IPVPN.";
- }
- identity spoke-role {
- base site-role;
- description
- "Spoke Site in a Hub & Spoke IPVPN.";
- }
- identity hub-role {
- base site-role;
- description
- "Hub Site in a Hub & Spoke IPVPN.";
- }
- identity vpn-topology {
- description
- "Base identity for VPN topology.";
- }
- identity any-to-any {
- base vpn-topology;
- description
- "Identity for any to any VPN topology.";
- }
- identity hub-spoke {
- base vpn-topology;
- description
- "Identity for Hub'n'Spoke VPN topology.";
- }
- identity hub-spoke-disjoint {
- base vpn-topology;
- description
- "Identity for Hub'n'Spoke VPN topology
- where Hubs cannot talk between each other.";
- }
- identity multicast-tree-type {
- description
- "Base identity for multicast tree type.";
- }
- identity ssm-tree-type {
- base multicast-tree-type;
- description
- "Identity for SSM tree type.";
- }
- identity asm-tree-type {
- base multicast-tree-type;
- description
- "Identity for ASM tree type.";
- }
- identity bidir-tree-type {
- base multicast-tree-type;
- description
- "Identity for BiDir tree type.";
- }
- identity multicast-rp-discovery-type {
- description
- "Base identity for rp discovery type.";
- }
- identity auto-rp {
- base multicast-rp-discovery-type;
- description
- "Base identity for auto-rp discovery type.";
- }
- identity static-rp {
- base multicast-rp-discovery-type;
- description
- "Base identity for static type.";
- }
- identity bsr-rp {
- base multicast-rp-discovery-type;
- description
- "Base identity for BDR discovery type.";
- }
- identity routing-protocol-type {
- description
- "Base identity for routing-protocol type.";
- }
- identity ospf {
- base routing-protocol-type;
- description
- "Identity for OSPF protocol type.";
- }
- identity bgp {
- base routing-protocol-type;
- description
- "Identity for BGP protocol type.";
- }
- identity static {
- base routing-protocol-type;
- description
- "Identity for static routing protocol type.";
- }
- identity rip {
- base routing-protocol-type;
- description
- "Identity for RIP protocol type.";
- }
- identity rip-ng {
- base routing-protocol-type;
- description
- "Identity for RIPng protocol type.";
- }
- identity vrrp {
- base routing-protocol-type;
- description
- "Identity for VRRP protocol type.
- This is to be used when LAn are directly connected
- to provider Edge routers.";
- }
- identity direct {
- base routing-protocol-type;
- description
- "Identity for direct protocol type.
- .";
- }
- identity protocol-type {
- description
- "Base identity for protocol field type.";
- }
- identity tcp {
- base protocol-type;
- description
- "TCP protocol type.";
- }
- identity udp {
- base protocol-type;
- description
- "UDP protocol type.";
- }
- identity icmp {
- base protocol-type;
- description
- "icmp protocol type.";
- }
- identity icmp6 {
- base protocol-type;
- description
- "icmp v6 protocol type.";
- }
- identity gre {
- base protocol-type;
- description
- "GRE protocol type.";
- }
- identity ipip {
- base protocol-type;
- description
- "IPinIP protocol type.";
- }
- identity hop-by-hop {
- base protocol-type;
- description
- "Hop by Hop IPv6 header type.";
- }
- identity routing {
- base protocol-type;
- description
- "Routing IPv6 header type.";
- }
- identity esp {
- base protocol-type;
- description
- "ESP header type.";
- }
- identity ah {
- base protocol-type;
- description
- "AH header type.";
- }
-
- /* Groupings */
-
- grouping vpn-service-cloud-access {
- container cloud-accesses {
- list cloud-access {
- if-feature cloud-access;
- key cloud-identifier;
-
- leaf cloud-identifier {
- type string;
- description
- "Identification of cloud service. Local
- admin meaning.";
- }
- container authorized-sites {
- list authorized-site {
- key site-id;
-
- leaf site-id {
- type leafref {
- path "/l3vpn-svc/sites/site/site-id";
- }
- description
- "Site ID.";
- }
- description
- "List of authorized sites.";
- }
- description
- "Configuration of authorized sites";
- }
- container denied-sites {
- list denied-site {
- key site-id;
-
- leaf site-id {
- type leafref {
- path "/l3vpn-svc/sites/site/site-id";
- }
- description
- "Site ID.";
- }
- description
- "List of denied sites.";
- }
- description
- "Configuration of denied sites";
- }
- leaf nat-enabled {
- type boolean;
- description
- "Control if NAT is required or not.";
- }
- leaf customer-nat-address {
- type inet:ipv4-address;
- description
- "NAT address to be used in case of public
- or shared cloud.
- This is to be used in case customer is providing
- the public address.";
- }
- description
- "Cloud access configuration.";
- }
- description
- "Container for cloud access configurations";
- }
- description
- "grouping for vpn cloud definition";
- }
-
- grouping multicast-rp-group-cfg {
- choice group-format {
- case startend {
- leaf group-start {
- type inet:ip-address;
- description
- "First group address.";
- }
- leaf group-end {
- type inet:ip-address;
- description
- "Last group address.";
- }
- }
- case singleaddress {
- leaf group-address {
- type inet:ip-address;
- description
- "Group address";
- }
- }
- description
- "Choice for group format.";
- }
- description
- "Definition of groups for
- RP to group mapping.";
- }
-
- grouping vpn-service-multicast {
- container multicast {
- if-feature multicast;
- leaf enabled {
- type boolean;
- default false;
- description
- "Enable multicast.";
- }
- container customer-tree-flavors {
- list tree-flavor {
- key type;
-
- leaf type {
- type identityref {
- base multicast-tree-type;
- }
- description
- "Type of tree to be used.";
- }
- description
- "List of tree flavors.";
- }
- description
- "Type of trees used by customer.";
- }
- container rp {
- container rp-group-mappings {
- list rp-group-mapping {
- key "id";
-
- leaf id {
- type uint16;
- description
- "Unique identifier for the mapping.";
- }
- container provider-managed {
- leaf enabled {
- type boolean;
- default false;
- description
- "Set to true, if the RP must be a
- provider
- managed node.
- Set to false, if it is a customer
- managed node.";
- }
-
- leaf rp-redundancy {
- when "../enabled = 'true'" {
- description
- "Relevant when RP
- is provider managed.";
- }
- type boolean;
- default false;
- description
- "If true, redundancy
- mechanism for RP is required.";
- }
- leaf optimal-traffic-delivery {
- when "../enabled = 'true'" {
- description
- "Relevant when RP
- is provider managed.";
- }
- type boolean;
- default false;
- description
- "If true, SP must ensure
- that traffic uses an optimal path.";
- }
- description
- "Parameters for provider managed RP.";
- }
-
- leaf rp-address {
- when "../provider-managed/enabled='false'" {
- description
- "Relevant when RP
- is provider managed.";
- }
- type inet:ip-address;
- description
- "Defines the address of the
- RendezvousPoint.
- Used if RP is customer managed.";
- }
-
- container groups {
- list group {
- key id;
-
- leaf id {
- type uint16;
- description
- "Identifier for the group.";
- }
- uses multicast-rp-group-cfg;
- description
- "List of groups.";
- }
- description
- "Multicast groups associated with RP.";
- }
-
- description
- "List of RP to group mappings.";
- }
- description
- "RP to group mappings.";
- }
- container rp-discovery {
- leaf rp-discovery-type {
- type identityref {
- base multicast-rp-discovery-type;
- }
- default static-rp;
- description
- "Type of RP discovery used.";
- }
- container bsr-candidates {
- when "../rp-discovery-type='bsr-rp'" {
- description
- "Only applicable if discovery type
- is BSR-RP";
- }
- list bsr-candidate {
- key address;
-
- leaf address {
- type inet:ip-address;
- description
- "Address of BSR candidate";
- }
-
- description
- "List of customer BSR candidates";
- }
- description
- "Customer BSR candidates address";
- }
- description
- "RP discovery parameters";
- }
-
- description
- "RendezvousPoint parameters.";
- }
- description
- "Multicast global parameters for the VPN service.";
- }
- description
- "grouping for multicast vpn definition";
- }
-
- grouping vpn-service-mpls {
- leaf carrierscarrier {
- if-feature carrierscarrier;
- type boolean;
- default false;
- description
- "The VPN is using Carrier's Carrier,
- and so MPLS is required.";
- }
- description
- "grouping for mpls CsC definition";
- }
-
- grouping customer-location-info {
- container location {
- leaf address {
- type string;
- description
- "Address (number and street)
- of the site.";
-
- }
- leaf zip-code {
- type string;
- description
- "ZIP code of the site.";
- }
- leaf state {
- type string;
- description
- "State of the site.
- This leaf can also be used
- to describe a region
- for country who does not have
- states.
- ";
- }
- leaf city {
- type string;
- description
- "City of the site.";
- }
- leaf country-code {
- type string;
- description
- "Country of the site.";
- }
- description
- "Location of the site.";
- }
- description
- "This grouping defines customer location
- parameters";
- }
-
- grouping site-diversity {
- container site-diversity {
- if-feature site-diversity;
-
- container groups {
- list group {
- key group-id;
-
- leaf group-id {
- type string;
- description
- "Group-id the site
- is belonging to";
- }
- description
- "List of group-id";
- }
- description
- "Groups the site
- is belonging to.
- All site network accesses will
- inherit those group values.";
- }
- description
- "Diversity constraint type.";
- }
- description
- "This grouping defines site diversity
- parameters";
- }
-
- grouping access-diversity {
- container access-diversity {
- if-feature site-diversity;
- container groups {
- list group {
- key group-id;
-
- leaf group-id {
- type string;
- description
- "Group-id the site network access
- is belonging to";
- }
- description
- "List of group-id";
- }
- description
- "Groups the site network access
- is belonging to";
- }
- container constraints {
- list constraint {
- key constraint-type;
-
- leaf constraint-type {
- type identityref {
- base placement-diversity;
- }
- description
- "Diversity constraint type.";
- }
- container target {
- choice target-flavor {
- case id {
- list group {
- key group-id;
-
- leaf group-id {
- type string;
- description
- "The constraint will apply
- against this particular
- group-id";
- }
- description
- "List of groups";
- }
- }
- case all-accesses {
- leaf all-other-accesses {
- type empty;
- description
- "The constraint will apply
- against all other site network
- access
- of this site";
- }
- }
- case all-groups {
- leaf all-other-groups {
- type empty;
- description
- "The constraint will apply
- against all other groups the
- customer
- is managing";
- }
- }
- description
- "Choice for the group definition";
- }
- description
- "The constraint will apply against
- this list of groups";
- }
- description
- "List of constraints";
- }
- description
- "Constraints for placing this site
- network access";
- }
-
- description
- "Diversity parameters.";
- }
- description
- "This grouping defines access diversity
- parameters";
- }
-
- grouping operational-requirements {
- leaf requested-site-start {
- type yang:date-and-time;
- description
- "Optional leaf indicating requested date
- and time
- when the service at a particular site is
- expected
- to start";
- }
-
- leaf requested-site-stop {
- type yang:date-and-time;
- description
- "Optional leaf indicating requested date
- and time
- when the service at a particular site is
- expected
- to stop";
- }
- description
- "This grouping defines some operational parameters
- parameters";
- }
-
- grouping operational-requirements-ops {
- leaf actual-site-start {
- type yang:date-and-time;
- config false;
- description
- "Optional leaf indicating actual date
- and time
- when the service at a particular site
- actually
- started";
- }
- leaf actual-site-stop {
- type yang:date-and-time;
- config false;
- description
- "Optional leaf indicating actual date
- and time
- when the service at a particular site
- actually
- stopped";
- }
- description
- "This grouping defines some operational parameters
- parameters";
- }
-
- grouping flow-definition {
- container match-flow {
- leaf dscp {
- type uint8 {
- range "0 .. 63";
- }
- description
- "DSCP value.";
- }
- leaf tos {
- type uint8 {
- range "0 .. 254";
- }
- description
- "TOS value.";
- }
- leaf dot1p {
- type uint8 {
- range "0 .. 7";
- }
- description
- "802.1p matching.";
- }
- leaf ipv4-src-prefix {
- type inet:ipv4-prefix;
- description
- "Match on IPv4 src address.";
- }
- leaf ipv6-src-prefix {
- type inet:ipv6-prefix;
- description
- "Match on IPv6 src address.";
- }
- leaf ipv4-dst-prefix {
- type inet:ipv4-prefix;
- description
- "Match on IPv4 dst address.";
- }
- leaf ipv6-dst-prefix {
- type inet:ipv6-prefix;
- description
- "Match on IPv6 dst address.";
- }
- leaf l4-src-port {
- type uint16;
- description
- "Match on layer 4 src port.";
- }
- leaf l4-dst-port {
- type uint16;
- description
- "Match on layer 4 dst port.";
- }
- leaf protocol-field {
- type union {
- type uint8;
- type identityref {
- base protocol-type;
- }
- }
- description
- "Match on IPv4 protocol or
- Ipv6 Next Header
- field.";
- }
-
- description
- "Describe flow matching
- criterions.";
- }
- description
- "Flow definition based on criteria.";
- }
-
- grouping site-service-basic {
- leaf svc-input-bandwidth {
- type uint32;
- units bps;
- description
- "From the PE perspective, the service input
- bandwidth of the connection.";
- }
- leaf svc-output-bandwidth {
- type uint32;
- units bps;
- description
- "From the PE perspective, the service output
- bandwidth of the connection.";
- }
- leaf svc-mtu {
- type uint16;
- units bytes;
- description
- "MTU at service level.
- If the service is IP,
- it refers to the IP MTU.";
- }
- description
- "Defines basic service parameters for a site.";
- }
-
- grouping site-protection {
- container traffic-protection {
- if-feature fast-reroute;
- leaf enabled {
- type boolean;
- description
- "Enables
- traffic protection of access link.";
- }
-
- description
- "Fast reroute service parameters
- for the site.";
- }
- description
- "Defines protection service parameters for a site.";
- }
-
- grouping site-service-mpls {
- container carrierscarrier {
- if-feature carrierscarrier;
- leaf signalling-type {
- type enumeration {
- enum "ldp" {
- description
- "Use LDP as signalling
- protocol between PE and CE.";
- }
- enum "bgp" {
- description
- "Use BGP 3107 as signalling
- protocol between PE and CE.
- In this case, bgp must be also
- configured
- as routing-protocol.
- ";
- }
- }
- description
- "MPLS signalling type.";
- }
- description
- "This container is used when customer provides
- MPLS based services.
- This is used in case of Carrier's
- Carrier.";
- }
- description
- "Defines MPLS service parameters for a site.";
- }
-
- grouping site-service-qos-profile {
- container qos {
- if-feature qos;
- container qos-classification-policy {
- list rule {
- key id;
- ordered-by user;
-
- leaf id {
- type uint16;
- description
- "ID of the rule.";
- }
-
- choice match-type {
- case match-flow {
- uses flow-definition;
- }
- case match-application {
- leaf match-application {
- type identityref {
- base customer-application;
- }
- description
- "Defines the application
- to match.";
- }
- }
- description
- "Choice for classification";
- }
-
- leaf target-class-id {
- type string;
- description
- "Identification of the
- class of service.
- This identifier is internal to
- the administration.";
- }
-
- description
- "List of marking rules.";
- }
- description
- "Need to express marking rules ...";
- }
- container qos-profile {
-
- choice qos-profile {
- description
- "Choice for QoS profile.
- Can be standard profile or custom.";
- case standard {
- leaf profile {
- type string;
- description
- "QoS profile to be used";
- }
- }
- case custom {
- container classes {
- if-feature qos-custom;
- list class {
- key class-id;
-
- leaf class-id {
- type string;
- description
- "Identification of the
- class of service.
- This identifier is internal to
- the administration.";
- }
- leaf rate-limit {
- type uint8;
- units percent;
- description
- "To be used if class must
- be rate
- limited. Expressed as
- percentage of the svc-bw.";
- }
- leaf priority-level {
- type uint8;
- description
- "Defines the level of the
- class in
- term of priority queueing.
- The higher the level is the
- higher
- is the priority.";
- }
- leaf guaranteed-bw-percent {
- type uint8;
- units percent;
- description
- "To be used to define the
- guaranteed
- BW in percent of the svc-bw
- available at the priority-level.";
- }
- description
- "List of class of services.";
- }
- description
- "Container for
- list of class of services.";
- }
-
- }
-
- }
- description
- "Qos profile configuration.";
- }
- description
- "QoS configuration.";
- }
- description
- "This grouping defines QoS parameters
- for a site";
-
- }
-
- grouping site-security-authentication {
- container authentication {
- description
- "Authentication parameters";
- }
- description
- "This grouping defines authentication
- parameters
- for a site";
- }
-
- grouping site-security-encryption {
- container encryption {
- if-feature encryption;
- leaf enabled {
- type boolean;
- description
- "If true, access encryption is required.";
- }
- leaf layer {
- type enumeration {
- enum layer2 {
- description
- "Encryption will occur at layer2.";
- }
- enum layer3 {
- description
- "IPSec is requested.";
- }
- }
- description
- "Layer on which encryption is applied.";
- }
- container encryption-profile {
- choice profile {
- case provider-profile {
- leaf profile-name {
- type string;
- description
- "Name of the SP profile
- to be applied.";
- }
- }
- case customer-profile {
- leaf algorithm {
- type string;
- description
- "Encryption algorithm to
- be used.";
- }
- choice key-type {
- case psk {
- leaf preshared-key {
- type string;
- description
- "Key coming from
- customer.";
- }
- }
- case pki {
-
- }
- description
- "Type of keys to be used.";
- }
- }
- description
- "Choice of profile.";
- }
- description
- "Profile of encryption to be applied.";
- }
- description
- "Encryption parameters.";
- }
- description
- "This grouping defines encryption parameters
- for a site";
- }
-
- grouping site-attachment-bearer {
- container bearer {
- container requested-type {
- if-feature requested-type;
- leaf requested-type {
- type string;
- description
- "Type of requested bearer Ethernet, DSL,
- Wireless ...
- Operator specific.";
- }
- leaf strict {
- type boolean;
- default false;
- description
- "define if the requested-type is a preference
- or a strict requirement.";
- }
- description
- "Container for requested type.";
- }
- leaf always-on {
- if-feature always-on;
- type boolean;
- default true;
- description
- "Request for an always on access type.
- This means no Dial access type for
- example.";
- }
- leaf bearer-reference {
- if-feature bearer-reference;
- type string;
- description
- "This is an internal reference for the
- service provider.
- Used ";
- }
- description
- "Bearer specific parameters.
- To be augmented.";
- }
- description
- "Defines physical properties of
- a site attachment.";
- }
-
- grouping site-routing {
- container routing-protocols {
- list routing-protocol {
- key type;
-
- leaf type {
- type identityref {
- base routing-protocol-type;
- }
- description
- "Type of routing protocol.";
- }
-
-
- container ospf {
- when "../type = 'ospf'" {
- description
- "Only applies
- when protocol is OSPF.";
- }
- if-feature rtg-ospf;
- leaf-list address-family {
- type identityref {
- base address-family;
- }
- description
- "Address family to be activated.";
- }
- leaf area-address {
- type yang:dotted-quad;
- description
- "Area address.";
- }
- leaf metric {
- type uint16;
- description
- "Metric of PE-CE link.";
- }
- container sham-links {
- if-feature rtg-ospf-sham-link;
- list sham-link {
- key target-site;
-
- leaf target-site {
- type svc-id;
- description
- "Target site for the sham link
- connection.
- The site is referred through it's ID.";
- }
- leaf metric {
- type uint16;
- description
- "Metric of the sham link.";
- }
- description
- "Creates a shamlink with another
- site";
- }
- description
- "List of Sham links";
- }
- description
- "OSPF specific configuration.";
- }
-
- container bgp {
-
- when "../type = 'bgp'" {
- description
- "Only applies when
- protocol is BGP.";
- }
- if-feature rtg-bgp;
- leaf autonomous-system {
- type uint32;
- description
- "AS number.";
- }
- leaf-list address-family {
- type identityref {
- base address-family;
- }
- description
- "Address family to be activated.";
- }
- description
- "BGP specific configuration.";
- }
- container static {
- when "../type = 'static'" {
- description
- "Only applies when protocol
- is static.";
- }
-
- container cascaded-lan-prefixes {
- list ipv4-lan-prefixes {
- if-feature ipv4;
- key "lan next-hop";
-
- leaf lan {
- type inet:ipv4-prefix;
- description
- "Lan prefixes.";
- }
- leaf lan-tag {
- type string;
- description
- "Internal tag to be used in vpn
- policies.";
- }
- leaf next-hop {
- type inet:ipv4-address;
- description
- "Nexthop address to use at customer
- side.";
- }
- description "
- List of LAN prefixes for
- the site.
- ";
- }
- list ipv6-lan-prefixes {
- if-feature ipv6;
- key "lan next-hop";
-
- leaf lan {
- type inet:ipv6-prefix;
- description
- "Lan prefixes.";
- }
- leaf lan-tag {
- type string;
- description
- "Internal tag to be used
- in vpn policies.";
- }
- leaf next-hop {
- type inet:ipv6-address;
- description
- "Nexthop address to use at
- customer side.";
- }
- description "
- List of LAN prefixes for the site.
- ";
- }
- description
- "LAN prefixes from the customer.";
- }
- description
- "Static routing
- specific configuration.";
- }
- container rip {
-
- when "../type = 'rip'" {
- description
- "Only applies when
- protocol is RIP.";
- }
- if-feature rtg-rip;
- leaf-list address-family {
- type identityref {
- base address-family;
- }
- description
- "Address family to be
- activated.";
- }
-
- description
- "RIP routing specific
- configuration.";
- }
-
-
- container vrrp {
-
- when "../type = 'vrrp'" {
- description
- "Only applies when
- protocol is VRRP.";
- }
- if-feature rtg-vrrp;
- leaf-list address-family {
- type identityref {
- base address-family;
- }
- description
- "Address family to be activated.";
- }
- description
- "VRRP routing specific configuration.";
- }
-
-
- description
- "List of routing protocols used
- on the site.
- Need to be augmented.";
- }
- description
- "Defines routing protocols.";
- }
- description
- "Grouping for routing protocols.";
- }
-
- grouping site-attachment-ip-connection {
- container ip-connection {
- container ipv4 {
- if-feature ipv4;
- leaf address-allocation-type {
- type identityref {
- base address-allocation-type;
- }
-
- default "static-address";
- description
- "Defines how addresses are allocated.
- ";
- }
-
- leaf number-of-dynamic-address {
- when
- "../address-allocation-type = 'pe-dhcp'"
- {
- description
- "Only applies when
- protocol allocation type is static";
- }
- type uint8;
- default 1;
- description
- "Describes the number of IP addresses the
- customer requires";
- }
- container addresses {
- when
- "../address-allocation-type = 'static-address'" {
- description
- "Only applies when
- protocol allocation type is static";
- }
- leaf provider-address {
- type inet:ipv4-address;
- description
- "Provider side address.";
- }
- leaf customer-address {
- type inet:ipv4-address;
- description
- "Customer side address.";
- }
- leaf mask {
- type uint8 {
- range "0..32";
- }
- description
- "Subnet mask expressed
- in bits";
- }
- description
- "Describes IP addresses used";
- }
- description
- "IPv4 specific parameters";
-
- }
- container ipv6 {
- if-feature ipv6;
- leaf address-allocation-type {
- type identityref {
- base address-allocation-type;
- }
- default "static-address";
- description
- "Defines how addresses are allocated.
- ";
- }
- leaf number-of-dynamic-address {
- when
- "../address-allocation-type = 'pe-dhcp'" {
- description
- "Only applies when
- protocol allocation type is static";
- }
- type uint8;
- default 1;
- description
- "Describes the number of IP addresses the
- customer requires";
- }
- container addresses {
- when
- "../address-allocation-type = 'static-address'" {
- description
- "Only applies when
- protocol allocation type is static";
- }
- leaf provider-address {
- type inet:ipv6-address;
- description
- "Provider side address.";
- }
- leaf customer-address {
- type inet:ipv6-address;
- description
- "Customer side address.";
- }
- leaf mask {
- type uint8 {
- range "0..128";
-
- }
- description
- "Subnet mask expressed
- in bits";
- }
- description
- "Describes IP addresses used";
- }
-
- description
- "IPv6 specific parameters";
-
- }
- container oam {
- container bfd {
- if-feature bfd;
- leaf bfd-enabled {
- type boolean;
- description
- "BFD activation";
- }
-
- choice holdtime {
- case profile {
- leaf profile-name {
- type string;
- description
- "Service provider well
- known profile.";
- }
- description
- "Service provider well
- known profile.";
- }
- case fixed {
- leaf fixed-value {
- type uint32;
- units msec;
- description
- "Expected holdtime
- expressed
- in msec.";
- }
- }
- description
- "Choice for holdtime flavor.";
- }
- description
- "Container for BFD.";
- }
- description
- "Define the OAM used on the connection.";
- }
- description
- "Defines connection parameters.";
- }
- description
- "This grouping defines IP connection parameters.";
- }
-
- grouping site-service-multicast {
- container multicast {
- if-feature multicast;
- leaf multicast-site-type {
- type enumeration {
- enum receiver-only {
- description
- "The site has only receivers.";
- }
- enum source-only {
- description
- "The site has only sources.";
- }
- enum source-receiver {
- description
- "The site has both
- sources & receivers.";
- }
- }
- default "source-receiver";
- description
- "Type of multicast site.";
- }
- container multicast-transport-protocol {
- leaf ipv4 {
- if-feature ipv4;
- type boolean;
- default true;
- description
- "Enables ipv4 multicast transport";
- }
- leaf ipv6 {
- if-feature ipv6;
- type boolean;
- default false;
- description
- "Enables ipv6 multicast transport";
- }
- description
- "Defines protocol to transport multicast.";
- }
- leaf protocol-type {
- type enumeration {
- enum host {
- description
- "
- Hosts are directly connected
- to the provider network.
- Host protocols like IGMP, MLD
- are required.
- ";
- }
- enum router {
- description
- "
- Hosts are behind a customer router.
- PIM will be implemented.
- ";
- }
- enum both {
- description
- "Some Hosts are behind a customer
- router and some others are directly
- connected to the provider network.
- Both host and routing protocols must be
- used. Typically IGMP and PIM will be
- implemented.
- ";
- }
- }
- default "both";
- description
- "Multicast protocol type to be used
- with the customer site.";
- }
-
- description
- "Multicast parameters for the site.";
- }
- description
- "Multicast parameters for the site.";
- }
-
- grouping site-management {
- container management {
- leaf type {
- type identityref {
- base management;
- }
- description
- "Management type of the connection.";
- }
- leaf management-transport {
- type identityref {
- base address-family;
- }
- description
- "Transport protocol used for management.";
- }
- leaf address {
- type inet:ip-address;
- description
- "Management address";
- }
-
- description
- "Management configuration";
- }
- description
- "Management parameters for the site.";
- }
-
- grouping site-vpn-flavor-profile {
- leaf site-vpn-flavor {
- type identityref {
- base site-vpn-flavor;
- }
- default site-vpn-flavor-single;
- description
- "Defines if the site
- is a single VPN site, or multiVPN or ...";
- }
- description
- "Grouping for site-vpn-flavor.";
- }
-
- grouping site-vpn-policy {
- container vpn-policy-list {
- list vpn-policy {
- key vpn-policy-id;
-
- leaf vpn-policy-id {
- type svc-id;
- description
- "Unique identifier for
- the VPN policy.";
- }
-
- list entries {
- key id;
-
- leaf id {
- type svc-id;
- description
- "Unique identifier for
- the policy entry.";
- }
- container filter {
- choice lan {
- case lan-prefix {
- container lan-prefixes {
- list ipv4-lan-prefixes {
- if-feature ipv4;
- key lan;
-
- leaf lan {
- type inet:ipv4-prefix;
- description
- "Lan prefixes.";
- }
- description "
- List of LAN prefixes
- for the site.
- ";
- }
- list ipv6-lan-prefixes {
- if-feature ipv6;
- key lan;
-
- leaf lan {
- type inet:ipv6-prefix;
- description
- "Lan prefixes.";
- }
- description "
- List of LAN prefixes
- for the site.
- ";
- }
- description
- "LAN prefixes from the customer.";
- }
- }
- case lan-tag {
- leaf-list lan-tag {
- type string;
- description
- "List of lan-tags to be matched.";
- }
- }
- description
- "Choice for LAN matching type";
- }
- description
- "If used, it permit to split site LANs
- among multiple VPNs.
- If no filter used, all the LANs will be
- part of the same VPNs with the same
- role.";
- }
- container vpn {
- leaf vpn-id {
- type leafref {
- path "/l3vpn-svc/vpn-services/vpn-svc/vpn-id";
- }
- mandatory true;
- description
- "Reference to an IPVPN.";
- }
- leaf site-role {
- type identityref {
- base site-role;
- }
- mandatory true;
- description
- "Role of the site in the IPVPN.";
- }
- description
- "List of VPNs the LAN is associated to.";
- }
- description
- "List of entries for export policy.";
- }
- description
- "List of VPN policies.";
- }
- description
- "VPN policy.";
- }
- description
- "VPN policy parameters for the site.";
- }
-
- grouping site-maximum-routes {
- container maximum-routes {
- list address-family {
- key af;
-
- leaf af {
- type identityref {
- base address-family;
- }
- description
- "Address-family.";
- }
- leaf maximum-routes {
- type uint32;
- description
- "Maximum prefixes the VRF can
- accept for this
- address-family.";
- }
- description
- "List of address families.";
- }
-
- description
- "Define maximum-routes for the VRF.";
- }
- description
- "Define maximum-routes for the site.";
- }
-
- grouping site-security {
- container security {
- uses site-security-authentication;
- uses site-security-encryption;
-
- description
- "Site specific security parameters.";
- }
- description
- "Grouping for security parameters.";
- }
-
- grouping site-service {
- container service {
- uses site-service-basic;
- uses site-service-qos-profile;
- uses site-service-mpls;
- uses site-service-multicast;
-
- description
- "Service parameters on the attachement.";
- }
- description
- "Grouping for service parameters.";
- }
-
- grouping transport-constraint-profile {
- list constraint-list {
- key constraint-type;
-
- leaf constraint-type {
- type identityref {
- base transport-constraint;
- }
- description
- "Constraint type to be applied.";
- }
- leaf constraint-opaque-value {
- type string;
- description
- "Opaque value that can be used to
- specify constraint parameters.";
- }
- description
- "List of constraints";
- }
- description
- "Grouping for transport constraint.";
- }
-
- grouping transport-constraints {
- container transport-constraints {
- if-feature traffic-engineering;
- container unicast-transport-constraints {
- list constraint {
- key constraint-id;
-
- leaf constraint-id {
- type svc-id;
- description
- "Defines an ID for the constraint
- rule.";
- }
-
- leaf site1 {
- type svc-id;
- description
- "The ID refers to one site end.";
- }
- leaf site2 {
- type svc-id;
- description
- "The ID refers to the other
- site end.";
- }
- uses transport-constraint-profile;
- description
- "List of constraints.
- Constraints are bidirectional.";
- }
- description
- "Unicast transport constraints.";
- }
- container multicast-transport-constraints {
- if-feature traffic-engineering-multicast;
- list constraint {
- key constraint-id;
-
- leaf constraint-id {
- type svc-id;
- description
- "Defines an ID for the constraint
- rule.";
- }
-
- leaf src-site {
- type svc-id;
- description
- "The ID refers to source site.";
- }
- leaf dst-site {
- type svc-id;
- description
- "The ID refers to the receiver
- site.";
- }
- uses transport-constraint-profile;
- description
- "List of constraints.
- Constraints are unidirectional.";
- }
- description
- "Multicast transport constraints.";
- }
- description
- "transport constraints.";
- }
- description
- "Grouping for transport constraints
- description.";
- }
-
- grouping vpn-extranet {
- container extranet-vpns {
- if-feature extranet-vpn;
- list extranet-vpn {
- key vpn-id;
-
- leaf vpn-id {
- type svc-id;
- description
- "Identifies the target VPN";
- }
- leaf local-sites-role {
- type identityref {
- base site-role;
- }
- description
- "This describes the role of the
- local sites in the target VPN topology.";
- }
- description
- "List of extranet VPNs the local
- VPN is attached to.";
- }
- description
- "Container for extranet vpn cfg.";
- }
- description
- "grouping for extranet VPN configuration.
- Extranet provides a way to interconnect all sites
- from two VPNs in a easy way.";
- }
-
- grouping site-attachment-availability {
- container availability {
- leaf access-priority {
- type uint32;
- default 1;
- description
- "Defines the priority for the access.
- The highest the priority value is,
- the highest the
- preference of the access is.";
- }
- description
- "Availability parameters
- (used for multihoming)";
- }
- description
- "Defines site availability parameters.";
- }
-
- grouping access-vpn-policy {
- container vpn-attachment {
- choice attachment-flavor {
- case vpn-policy-id {
- leaf vpn-policy-id {
- type leafref {
- path "/l3vpn-svc/sites/site/"+
- "vpn-policy-list/vpn-policy/"+
- "vpn-policy-id";
- }
- description
- "Reference to a VPN policy.";
- }
- }
- case vpn-id {
- leaf vpn-id {
- type leafref {
- path "/l3vpn-svc/vpn-services"+
- "/vpn-svc/vpn-id";
- }
- description
- "Reference to a VPN.";
- }
- leaf site-role {
- type identityref {
- base site-role;
- }
- mandatory true;
- description
- "Role of the site in the IPVPN.";
- }
- }
- mandatory true;
- description
- "Choice for VPN attachment flavor.";
- }
- description
- "Defines VPN attachment of a site.";
- }
- description
- "Defines the VPN attachment rules
- for a site logical access.";
- }
-
- grouping vpn-svc-cfg {
- leaf vpn-id {
- type svc-id;
- description
- "VPN identifier. Local administration meaning.";
- }
- leaf customer-name {
- type string;
- description
- "Name of the customer.";
- }
- leaf topology {
- type identityref {
- base vpn-topology;
- }
- default "any-to-any";
- description
- "VPN topology.";
- }
-
- uses vpn-service-cloud-access;
- uses vpn-service-multicast;
- uses vpn-service-mpls;
- uses transport-constraints;
- uses vpn-extranet;
-
- description
- "grouping for vpn-svc configuration.";
- }
-
- grouping site-top-level-cfg {
- uses operational-requirements;
- uses customer-location-info;
- uses site-diversity;
- uses site-management;
- uses site-vpn-policy;
- uses site-vpn-flavor-profile;
- uses site-maximum-routes;
- uses site-security;
- uses site-service;
- uses site-protection;
- uses site-routing;
-
- description
- "Grouping for site top level cfg.";
- }
-
- grouping site-network-access-top-level-cfg {
- leaf site-network-access-type {
- type identityref {
- base site-network-access-type;
- }
- default "point-to-point";
- description
- "Describes the type of connection, e.g. :
- point-to-point or multipoint";
- }
- uses access-diversity;
- uses site-attachment-bearer;
- uses site-attachment-ip-connection;
- uses site-security;
- uses site-service;
- uses site-routing;
- uses site-attachment-availability;
- uses access-vpn-policy;
-
- description
- "Grouping for site network access
- top level cfg.";
- }
-
- /* Main blocks */
-
- container l3vpn-svc {
- container vpn-services {
- list vpn-svc {
- key vpn-id;
-
- uses vpn-svc-cfg;
-
- description "
- List of VPN services.
-
- ";
- }
- description
- "top level container
- for the VPN services.";
- }
-
- container sites {
- list site {
- key site-id;
-
- leaf site-id {
- type svc-id;
- description
- "Identifier of the site.";
- }
-
- uses site-top-level-cfg;
- uses operational-requirements-ops;
-
- container site-network-accesses {
- list site-network-access {
- key site-network-access-id;
-
- leaf site-network-access-id {
- type svc-id;
- description
- "Identifier for the access";
- }
- uses site-network-access-top-level-cfg;
-
- description
- "List of accesses for a site.";
- }
- description
- "List of accesses for a site.";
- }
-
- description "List of sites.";
- }
- description
- "Container for sites";
- }
-
- description
- "Main container for L3VPN service configuration.";
- }
-}
\ No newline at end of file
diff --git a/models/l3vpn/src/main/yang/ietf-network-instance@2016-06-23.yang b/models/l3vpn/src/main/yang/ietf-network-instance@2016-06-23.yang
deleted file mode 100644
index 57eebdc..0000000
--- a/models/l3vpn/src/main/yang/ietf-network-instance@2016-06-23.yang
+++ /dev/null
@@ -1,241 +0,0 @@
-module ietf-network-instance {
-
- yang-version "1";
-
- // namespace
- namespace "urn:ietf:params:xml:ns:yang:ietf-network-instance";
-
- prefix "ni";
-
- // import some basic types
- import ietf-interfaces {
- prefix if;
- }
-
- import ietf-ip {
- prefix ip;
- }
-
- // meta
- organization "IETF Routing Area Working Group (rtgwg)";
-
- contact
- "Routing Area Working Group - <rtgwg@ietf.org>";
-
-
- description
- "This module is used to support multiple network instances
- within a single physical or virtual device. Network
- instances are commonly know as VRFs (virtual routing
- and forwarding) and VSIs (virtual switching instances).";
-
- revision "2016-06-23" {
- description
- "Initial revision.";
- reference "RFC TBD";
- }
-
- // extension statements
-
- feature bind-network-instance-name {
- description
- "Network Instance to which an interface instance is bound";
- }
-
- // identity statements
-
- identity network-instance-type {
- description
- "Base identity from which identities describing
- network instance types are derived.";
- }
-
- identity ipv4-interface-protocol-type {
- description
- "Base identity for derivation of IPv4 interface
- protocols";
- }
-
- identity ipv6-interface-protocol-type {
- description
- "Base identity for derivation of IPv6 interface
- protocols";
- }
-
- // typedef statements
-
- // grouping statements
-
- grouping interface-ip-common {
- description
- "interface-specific configuration for IP interfaces, IPv4 and
- IPv6";
-
- }
-
- grouping ipv4-interface-protocols {
- container ipv4-interface-protocols {
- list ipv4-interface-protocol {
- key "type";
- leaf type {
- type identityref {
- base ipv4-interface-protocol-type;
- }
- mandatory true;
- description
- "ARP, ICMP, VRRP, DHCP Client, etc.";
- }
- description
- "List of IPv4 protocols configured
- on an interface";
- }
- description
- "Container for list of IPv4 protocols configured
- on an interface";
- }
- description
- "Grouping for IPv4 protocols configured on an interface";
- }
-
- grouping ipv6-interface-protocols {
- description
- "Grouping for IPv6 protocols configured on
- an interface.";
- container ipv6-interface-protocols {
- description
- "Container for list of IPv6 protocols configured
- on an interface.";
- list ipv6-interface-protocol {
- key "type";
- description
- "List of IPv6 protocols configured
- on an interface";
- leaf type {
- type identityref {
- base ipv6-interface-protocol-type;
- }
- mandatory true;
- description
- "ND, ICMPv6, VRRP, DHCPv6 Client, etc.";
- }
- }
- }
- }
-
- grouping network-instance-policy {
- description
- "Network instance policies such as route
- distinguisher, route targets, VPLS ID and neighbor,
- Ethernet ID, etc. ";
- reference
- "RFC 4364 - BGP/MPLS Virtual Private Networks (VPNs)
- RFC 6074 - Provisioning, Auto-Discovery, and Signaling
- in Layer 2 Virtual Private Networks (L2VPNs)
- RFC 7432 - BGP MPLS-Based Ethernet VPN";
- container network-instance-policy {
- description "Network Instance Policy -- details TBD";
- }
- }
-
- // top level device definition statements
- container devices {
- list device {
- key deviceid;
- leaf deviceid {
- type string;
- }
- container network-instances {
- description "Network instances each of which have
- and protocol instantiations. For layer 3,
- this consistent with the routing-instance
- definition in ietf-routing";
- reference "draft-ietf-netmod-routing-cfg";
- list network-instance {
- key name;
- description "List of network-instances";
- leaf name {
- type string;
- description "device scoped
- identifier for the network
- instance";
- }
- leaf type {
- type identityref {
- base network-instance-type;
- }
- description
- "The network instance type -- details TBD
- Likely types include core, L3-VRF, VPLS,
- L2-cross-connect, L2-VSI, etc.";
- }
- leaf enabled {
- type boolean;
- default "true";
- description
- "Flag indicating whether or not the network
- instance is enabled.";
- }
- leaf description {
- type string;
- description
- "Description of the network instance
- and its intended purpose";
- }
- uses network-instance-policy;
- // leaf root {
- // type schema-mount;
- // description "Root for models supported per
- // network instance";
- // }
- }
- }
- }
- }
-
- // augment statements
- augment "/if:devices/if:device/if:interfaces/if:interface" {
- description
- "Add a node for the identification of the logical network
- instance (which is within the interface's identified logical
- network element) associated with the IP information
- configured on an interface";
-
- leaf bind-network-instance-name {
- type string;
- description
- "Network Instance to which an interface is bound";
- }
- }
-
- augment "/if:devices/if:device/if:interfaces/if:interface/ip:ipv4" {
- description
- "Add a node for the identification of the logical
- network instance (which is within the interface's
- identified physical or virtual device) associated with
- the IP information configured on an interface";
-
- leaf bind-network-instance-name {
- type string;
- description
- "Network Instance to which IPv4 interface is bound";
-
- }
- }
-
- augment "/if:devices/if:device/if:interfaces/if:interface/ip:ipv6" {
- description
- "Add a node for the identification of the logical
- network instance (which is within the interface's
- identified physical or virtual device) associated with
- the IP information configured on an interface";
-
- leaf bind-network-instance-name {
- type string;
- description
- "Network Instance to which IPv6 interface is bound";
-
- }
- }
- // rpc statements
- // notification statements
- }
\ No newline at end of file
diff --git a/models/l3vpn/src/main/yang/l3vpn-svc-ext@2016-07-30.yang b/models/l3vpn/src/main/yang/l3vpn-svc-ext@2016-07-30.yang
deleted file mode 100644
index e3fecb6..0000000
--- a/models/l3vpn/src/main/yang/l3vpn-svc-ext@2016-07-30.yang
+++ /dev/null
@@ -1,362 +0,0 @@
-module l3vpn-svc-ext {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:l3vpn:svc:ext";
- prefix "l3vpn-svc-ext";
-
- import ietf-inet-types { prefix inet; }
- import ietf-l3vpn-svc { prefix l3vpn; }
-
- revision 2016-07-30 {
- description
- "Eliminated warnings";
- }
-
- revision "2016-07-20" {
- description "Initial revision of extended l3vpn yang model";
- }
-
- typedef short-as-number {
- type inet:as-number {
- range 0..65535;
- }
- }
-
- typedef route-distinguisher {
- reference "https://tools.ietf.org/html/rfc4364#section-4.2";
- type union {
- type rd-ipv4;
- type rd-as;
- type rd-as2;
- }
- }
-
- typedef rd-ipv4 {
- type string {
- /* IPv4 : 2B number */
- pattern '((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
- + '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))'
- + ':'
- + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
- + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
- + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])';
- }
- }
-
- typedef rd-as {
- type string {
- /* 2B AS : 4B number */
- pattern '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
- + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
- + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])'
- + ':'
- + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
- + '[1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]|'
- + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
- + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-3][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
- + '4[0-1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|42[0-8][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
- + '429[0-3][0-9][0-9][0-9][0-9][0-9][0-9]|4294[0-8][0-9][0-9][0-9][0-9][0-9]|'
- + '42949[0-5][0-9][0-9][0-9][0-9]|429496[0-6][0-9][0-9][0-9]|4294967[0-1][0-9][0-9]|'
- + '42949672[0-8][0-9]|429496729[0-5])';
- }
- }
-
- typedef rd-as2 {
- type string {
- /* 4B AS : 2B number */
- pattern '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
- + '[1-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9]|'
- + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
- + '[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|[1-3][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
- + '4[0-1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|42[0-8][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|'
- + '429[0-3][0-9][0-9][0-9][0-9][0-9][0-9]|4294[0-8][0-9][0-9][0-9][0-9][0-9]|'
- + '42949[0-5][0-9][0-9][0-9][0-9]|429496[0-6][0-9][0-9][0-9]|4294967[0-1][0-9][0-9]|'
- + '42949672[0-8][0-9]|429496729[0-5])'
- + ':'
- + '([0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|'
- + '[1-5][0-9][0-9][0-9][0-9]|6[0-4][0-9][0-9][0-9]|'
- + '65[0-4][0-9][0-9]|655[0-2][0-9]|6553[0-5])';
- }
- }
-
- identity tc-demanded-tunnel {
- base l3vpn:transport-constraint;
- description "on-demand tunnel.";
- }
-
- grouping class-profile {
- list qos-class {
- key class-id;
- leaf class-id {
- type string;
- description
- "Identification of the
- class of service.
- This identifier is internal to
- the administration.";
- }
- leaf rate-limit {
- type uint8;
- units percent;
- description
- "To be used if class must
- be rate
- limited. Expressed as
- percentage of the svc-bw.";
- }
- leaf priority-level {
- type uint8;
- description
- "Defines the level of the
- class in
- term of priority queueing.
- The higher the level is the
- higher
- is the priority.";
- }
- leaf guaranteed-bw-percent {
- type uint8;
- units percent;
- description
- "To be used to define the
- guaranteed
- BW in percent of the svc-bw
- available at the priority-level.";
- }
- description
- "List of class of services.";
- }
- }
-
- augment "/l3vpn:l3vpn-svc/l3vpn:sites/l3vpn:site/l3vpn:site-network-accesses/l3vpn:site-network-access/l3vpn:service/l3vpn:qos/l3vpn:qos-profile/l3vpn:qos-profile" {
- case custom-unicom {
- container inbound-classes {
- uses class-profile;
- }
- container outbound-classes {
- uses class-profile;
- }
- }
- }
-
- grouping bearer-attachment-grouping {
- container bearer-attachment {
- leaf pe-name {
- type string;
- }
- leaf pe-mgmt-ip {
- type inet:ipv4-address;
- }
- description "attached PE";
- }
- }
-
- augment "/l3vpn:l3vpn-svc/l3vpn:sites/l3vpn:site/l3vpn:site-network-accesses/l3vpn:site-network-access/l3vpn:bearer" {
- uses bearer-attachment-grouping;
- }
-
- grouping requested-type-grouping {
- container requested-type-profile {
- choice requested-type-choice {
- case dot1q-case {
- container dot1q {
- leaf physical-if {
- description "physical interface name.";
- type string;
- }
- leaf vlan-id {
- type uint16 {
- range "1..4096";
- }
- }
- }
- }
- case physical-case {
- container physical {
- leaf physical-if {
- description "physical interface name.";
- type string;
- }
- }
- }
- }
- leaf circuit-id {
- description "circuit description for PE-CE port.";
- type string;
- }
- }
- }
-
- augment "/l3vpn:l3vpn-svc/l3vpn:sites/l3vpn:site/l3vpn:site-network-accesses/l3vpn:site-network-access/l3vpn:bearer/l3vpn:requested-type" {
- uses requested-type-grouping;
- }
-
- grouping bfd-grouping {
- leaf bfd-enabled {
- type boolean;
- description
- "BFD activation";
- }
- choice holdtime {
- case profile {
- leaf profile-name {
- type string;
- description
- "Service provider well
- known profile.";
- }
- description
- "Service provider well
- known profile.";
- }
- case fixed {
- leaf fixed-value {
- type uint32;
- units msec;
- description
- "Expected holdtime
- expressed
- in msec.";
- }
- }
- case dynamic {
- container dynamic-value {
- leaf interval {
- type uint16;
- units msec;
- default 500;
- }
- leaf multiplier {
- type uint16;
- default 3;
- }
- description
- "interval * multiplier is
- timeout value.";
- }
- }
- }
- }
-
- grouping bgp-profile {
- leaf as-override {
- type boolean;
- default false;
- }
- container soo {
- leaf soo-enabled {
- type boolean;
- }
- leaf soo-value {
- type string;
- }
- }
- container password {
- leaf password-enabled {
- type boolean;
- }
- leaf password-value {
- type string;
- }
- }
- container bgp-timer {
- leaf keep-alive {
- type uint16;
- default 60;
- units "seconds";
- }
- leaf hold-time {
- type uint16;
- default 180;
- units "seconds";
- }
- }
- container bfd {
- uses bfd-grouping;
- }
- }
-
- augment "/l3vpn:l3vpn-svc/l3vpn:sites/l3vpn:site/l3vpn:site-network-accesses/l3vpn:site-network-access/l3vpn:routing-protocols/l3vpn:routing-protocol/l3vpn:bgp" {
- uses bgp-profile;
- }
-
- augment "/l3vpn:l3vpn-svc/l3vpn:vpn-services/l3vpn:vpn-svc/l3vpn:transport-constraints/l3vpn:unicast-transport-constraints/l3vpn:constraint/l3vpn:constraint-list" {
- leaf constraint-opaque-value2 {
- type string;
- description
- "Opaque value that can be used to
- specify constraint parameters.";
- }
- }
-
- grouping route-ipv4-extended-community {
- reference "http://tools.ietf.org/html/rfc4360";
- leaf global-administrator {
- type inet:ipv4-address;
- }
- leaf local-administrator {
- type uint16;
- }
- }
-
- grouping extended-community {
- choice extended-community {
- reference "http://tools.ietf.org/html/rfc4360#section-4";
- default route-target-extended-community-case;
- case route-target-extended-community-case {
- container route-target-extended-community {
- leaf global-administrator {
- type short-as-number;
- }
- leaf local-administrator {
- type uint32;
- }
- }
- }
- case route-target-ipv4-case {
- container route-target-ipv4 {
- uses route-ipv4-extended-community;
- }
- }
- case route-target-extended-community-case2 {
- container route-target-extended-community2 {
- leaf global-administrator {
- type uint32;
- }
- leaf local-administrator {
- type uint16;
- }
- }
- }
- }
- }
-
- grouping rdrt-profile {
- choice site-role {
- case custom-case {
- container custom {
- list import-rt {
- key imrt-id;
- leaf imrt-id {
- type string;
- }
- uses extended-community;
- }
- list export-rt {
- key exrt-id;
- leaf exrt-id {
- type string;
- }
- uses extended-community;
- }
- leaf rd {
- type route-distinguisher;
- }
- }
- }
- }
- }
-
- augment "/l3vpn:l3vpn-svc/l3vpn:sites/l3vpn:site/l3vpn:site-network-accesses/l3vpn:site-network-access/l3vpn:vpn-attachment" {
- uses rdrt-profile;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/api/BUILD b/protocols/isis/api/BUILD
deleted file mode 100644
index 9e01912..0000000
--- a/protocols/isis/api/BUILD
+++ /dev/null
@@ -1,7 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
- "@io_netty_netty//jar",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisController.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisController.java
deleted file mode 100644
index 2253717..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisController.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.onosproject.isis.controller.topology.IsisLinkListener;
-import org.onosproject.isis.controller.topology.IsisRouterListener;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Representation of an ISIS controller.
- */
-public interface IsisController {
-
- /**
- * Registers a listener for router meta events.
- *
- * @param isisRouterListener ISIS router listener instance
- */
- void addRouterListener(IsisRouterListener isisRouterListener);
-
- /**
- * Unregisters a router listener.
- *
- * @param isisRouterListener ISIS router listener instance
- */
- void removeRouterListener(IsisRouterListener isisRouterListener);
-
- /**
- * Updates configuration of processes.
- *
- * @param processesNode json node represents process
- */
- void updateConfig(JsonNode processesNode);
-
- /**
- * Gets the all configured processes.
- *
- * @return list of process instances
- */
- List<IsisProcess> allConfiguredProcesses();
-
- /**
- * Registers a listener for ISIS message events.
- *
- * @param listener the listener to notify
- */
- void addLinkListener(IsisLinkListener listener);
-
- /**
- * Unregisters a link listener.
- *
- * @param listener the listener to unregister
- */
- void removeLinkListener(IsisLinkListener listener);
-
- /**
- * Gets the list of listeners registered for router events.
- *
- * @return list of listeners
- */
- Set<IsisRouterListener> listener();
-
- /**
- * Gets the list of listeners registered for link events.
- *
- * @return list of listeners
- */
- Set<IsisLinkListener> linkListener();
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisInterface.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisInterface.java
deleted file mode 100644
index 0ff30cb..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisInterface.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller;
-
-import org.jboss.netty.channel.Channel;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.MacAddress;
-
-import java.util.Set;
-
-/**
- * Representation of an ISIS interface.
- */
-public interface IsisInterface {
-
- /**
- * Returns interface index.
- *
- * @return interface index
- */
- int interfaceIndex();
-
- /**
- * Sets interface index.
- *
- * @param interfaceIndex interface index
- */
- void setInterfaceIndex(int interfaceIndex);
-
- /**
- * Returns the interface IP address.
- *
- * @return interface IP address
- */
- Ip4Address interfaceIpAddress();
-
- /**
- * Sets the interface IP address.
- *
- * @param interfaceIpAddress interface IP address interface IP address
- */
- void setInterfaceIpAddress(Ip4Address interfaceIpAddress);
-
- /**
- * Returns the network mask.
- *
- * @return network mask
- */
- byte[] networkMask();
-
- /**
- * Sets the network mask.
- *
- * @param networkMask network mask
- */
- void setNetworkMask(byte[] networkMask);
-
- /**
- * Sets the interface MAC address.
- *
- * @param interfaceMacAddress interface MAC address
- */
- void setInterfaceMacAddress(MacAddress interfaceMacAddress);
-
- /**
- * Returns the neighbors list.
- *
- * @return neighbors list
- */
- Set<MacAddress> neighbors();
-
- /**
- * Sets intermediate system name.
- *
- * @param intermediateSystemName intermediate system name
- */
- void setIntermediateSystemName(String intermediateSystemName);
-
- /**
- * Returns system ID.
- *
- * @return systemID system ID
- */
- String systemId();
-
- /**
- * Sets system ID.
- *
- * @param systemId system ID
- */
- void setSystemId(String systemId);
-
- /**
- * Returns LAN ID.
- *
- * @return LAN ID
- */
- String l1LanId();
-
- /**
- * Sets LAN ID.
- *
- * @param lanId LAN ID
- */
- void setL1LanId(String lanId);
-
- /**
- * Returns LAN ID.
- *
- * @return LAN ID
- */
- String l2LanId();
-
- /**
- * Sets LAN ID.
- *
- * @param lanId LAN ID
- */
- void setL2LanId(String lanId);
-
- /**
- * Sets ID length.
- *
- * @param idLength ID length
- */
- void setIdLength(int idLength);
-
- /**
- * Sets max area addresses.
- *
- * @param maxAreaAddresses max area addresses
- */
- void setMaxAreaAddresses(int maxAreaAddresses);
-
- /**
- * Returns reserved packet circuit type.
- *
- * @return reserved packet circuit type
- */
- int reservedPacketCircuitType();
-
- /**
- * Sets reserved packet circuit type.
- *
- * @param reservedPacketCircuitType reserved packet circuit type
- */
- void setReservedPacketCircuitType(int reservedPacketCircuitType);
-
- /**
- * Returns point to point or broadcast.
- *
- * @return 1 if point to point, 2 broadcast
- */
- IsisNetworkType networkType();
-
- /**
- * Sets point to point.
- *
- * @param networkType point to point
- */
- void setNetworkType(IsisNetworkType networkType);
-
- /**
- * Returns area address.
- *
- * @return area address
- */
- String areaAddress();
-
- /**
- * Sets area address.
- *
- * @param areaAddress area address
- */
- void setAreaAddress(String areaAddress);
-
- /**
- * Sets area length.
- *
- * @param areaLength area length
- */
- void setAreaLength(int areaLength);
-
- /**
- * Returns holding time.
- *
- * @return holding time
- */
- int holdingTime();
-
- /**
- * Sets holding time.
- *
- * @param holdingTime holding time
- */
- void setHoldingTime(int holdingTime);
-
- /**
- * Returns priority.
- *
- * @return priority
- */
- int priority();
-
- /**
- * Sets priority.
- *
- * @param priority priority
- */
- void setPriority(int priority);
-
- /**
- * Returns hello interval.
- *
- * @return hello interval
- */
- public int helloInterval();
-
- /**
- * Sets hello interval.
- *
- * @param helloInterval hello interval
- */
- void setHelloInterval(int helloInterval);
-
- /**
- * Starts the hello timer which sends hello packet every configured seconds.
- *
- * @param channel netty channel instance
- */
- void startHelloSender(Channel channel);
-
- /**
- * Stops the hello timer which sends hello packet every configured seconds.
- */
- void stopHelloSender();
-
- /**
- * Processes an ISIS message which is received on this interface.
- *
- * @param isisMessage ISIS message instance
- * @param isisLsdb ISIS LSDB instance
- * @param channel channel instance
- */
- void processIsisMessage(IsisMessage isisMessage, IsisLsdb isisLsdb, Channel channel);
-
- /**
- * Returns the interface state.
- *
- * @return interface state
- */
- IsisInterfaceState interfaceState();
-
- /**
- * Sets the interface state.
- *
- * @param interfaceState the interface state
- */
- void setInterfaceState(IsisInterfaceState interfaceState);
-
- /**
- * Returns the LSDB instance.
- *
- * @return LSDB instance
- */
- IsisLsdb isisLsdb();
-
- /**
- * Returns intermediate system name.
- *
- * @return intermediate system name
- */
- String intermediateSystemName();
-
- /**
- * Returns the ISIS neighbor instance if exists.
- *
- * @param isisNeighborMac mac address of the neighbor router
- * @return ISIS neighbor instance if exists else null
- */
- IsisNeighbor lookup(MacAddress isisNeighborMac);
-
- /**
- * Returns circuit ID.
- *
- * @return circuit ID
- */
- String circuitId();
-
- /**
- * Sets circuit ID.
- *
- * @param circuitId circuit ID
- */
- void setCircuitId(String circuitId);
-
- /**
- * Removes neighbor from the interface neighbor map.
- *
- * @param isisNeighbor ISIS neighbor instance
- */
- void removeNeighbor(IsisNeighbor isisNeighbor);
-
- /**
- * Removes all the neighbors.
- */
- void removeNeighbors();
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisInterfaceState.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisInterfaceState.java
deleted file mode 100644
index 8938518..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisInterfaceState.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Enum represents ISIS Interface state.
- */
-public enum IsisInterfaceState {
- /**
- * Represents interface is in "up" state.
- */
- UP(0),
- /**
- * Represents interface is in "initial" state.
- */
- INITIAL(1),
- /**
- * Represents interface is in "down" state.
- */
- DOWN(2);
-
- // Reverse lookup table
- private static final Map<Integer, IsisInterfaceState> LOOKUP = new HashMap<>();
-
- // Populate the lookup table on loading time
- static {
- for (IsisInterfaceState isisInterfaceState : EnumSet.allOf(IsisInterfaceState.class)) {
- LOOKUP.put(isisInterfaceState.value(), isisInterfaceState);
- }
- }
-
- private int value;
-
- /**
- * Creates an instance of ISIS interface type.
- *
- * @param value represents ISIS interface type
- */
- private IsisInterfaceState(int value) {
- this.value = value;
- }
-
- /**
- * Gets the enum instance from type value - reverse lookup purpose.
- *
- * @param interfaceStateTypeValue interface state type value
- * @return ISIS interface state type instance
- */
- public static IsisInterfaceState get(int interfaceStateTypeValue) {
- return LOOKUP.get(interfaceStateTypeValue);
- }
-
- /**
- * Gets the value representing interface state type.
- *
- * @return value represents interface state type
- */
- public int value() {
- return value;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLsdb.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLsdb.java
deleted file mode 100644
index 8480cb6..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLsdb.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Representation of an ISIS link state database.
- */
-public interface IsisLsdb {
-
- /**
- * Returns the ISIS LSDB.
- *
- * @return ISIS LSDB
- */
- IsisLsdb isisLsdb();
-
- /**
- * Initializes LSDB.
- */
- void initializeDb();
-
- /**
- * Returns the LSDB LSP key.
- *
- * @param systemId system ID
- * @return LSP key
- */
- String lspKey(String systemId);
-
- /**
- * Returns the sequence number.
- *
- * @param lspType L1 or L2 LSP
- * @return sequence number
- */
- int lsSequenceNumber(IsisPduType lspType);
-
- /**
- * Finds the LSP from LSDB.
- *
- * @param pduType L1 or L2 LSP
- * @param lspId LSP ID
- * @return LSP wrapper object
- */
- LspWrapper findLsp(IsisPduType pduType, String lspId);
-
- /**
- * Installs a new self-originated LSA in LSDB.
- * Return true if installing was successful else false.
- *
- * @param lsPdu PDU instance
- * @param isSelfOriginated true if self originated else false
- * @param isisInterface ISIS interface instance
- * @return true if successfully added
- */
- boolean addLsp(IsisMessage lsPdu, boolean isSelfOriginated, IsisInterface isisInterface);
-
- /**
- * Checks received LSP is latest, same or old.
- *
- * @param receivedLsp received LSP
- * @param lspFromDb existing LSP
- * @return "latest", "old" or "same"
- */
- String isNewerOrSameLsp(IsisMessage receivedLsp, IsisMessage lspFromDb);
-
- /**
- * Returns all LSPs (L1 and L2).
- *
- * @param excludeMaxAgeLsp exclude the max age LSPs
- * @return List of LSPs
- */
- List<LspWrapper> allLspHeaders(boolean excludeMaxAgeLsp);
-
- /**
- * Deletes the given LSP.
- *
- * @param lsp LSP instance
- */
- void deleteLsp(IsisMessage lsp);
-
- /**
- * Gets the neighbor database information.
- *
- * @return neighbor database information
- */
- Map<String, LspWrapper> getL1Db();
-
- /**
- * Gets the neighbor database information.
- *
- * @return neighbor database information
- */
- Map<String, LspWrapper> getL2Db();
-
- /**
- * Sets the level 1 link state sequence number.
- *
- * @param l1LspSeqNo link state sequence number
- */
- void setL1LspSeqNo(int l1LspSeqNo);
-
- /**
- * Sets the level 2 link state sequence number.
- *
- * @param l2LspSeqNo link state sequence number
- */
- void setL2LspSeqNo(int l2LspSeqNo);
- /**
- * Removes topology information when neighbor down.
- *
- * @param neighbor ISIS neighbor instance
- * @param isisInterface ISIS interface instance
- */
- void removeTopology(IsisNeighbor neighbor, IsisInterface isisInterface);
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLsdbAge.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLsdbAge.java
deleted file mode 100644
index 2d768c6..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLsdbAge.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller;
-
-/**
- * Representation of an ISIS link state database aging.
- */
-public interface IsisLsdbAge {
-
- /**
- * Starts the aging timer thread which gets invokes every second.
- */
- void startDbAging();
-
- /**
- * Returns the age counter.
- *
- * @return age counter
- */
- int ageCounter();
-
- /**
- * Returns the age counter rollover.
- *
- * @return age counter rollover
- */
- int ageCounterRollOver();
-
- /**
- * Returns the bin number.
- *
- * @param x can be either age or ageCounter
- * @return bin number
- */
- int age2Bin(int x);
-
- /**
- * Returns the LSP bin instance.
- *
- * @param binKey key to search
- * @return LSP bin instance
- */
- IsisLspBin getLspBin(int binKey);
-
- /**
- * Adds LSP to bin.
- *
- * @param binNumber key to store in bin
- * @param lspBin LSP bin instance
- */
- void addLspBin(int binNumber, IsisLspBin lspBin);
-
- /**
- * Removes LSP from bin.
- *
- * @param lspWrapper LSP wrapper instance
- */
- void removeLspFromBin(LspWrapper lspWrapper);
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLspBin.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLspBin.java
deleted file mode 100644
index 4c88d88..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLspBin.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller;
-
-import java.util.Map;
-
-/**
- * Representation of an ISIS LSP bin which is part of LSP aging process.
- */
-public interface IsisLspBin {
-
- /**
- * Returns all the LSPs in the bin.
- *
- * @return all LSPs in the bin
- */
- Map<String, LspWrapper> listOfLsp();
-
- /**
- * Adds LSP to bin for aging.
- *
- * @param lspKey key to add the LSP
- * @param lspWrapper LSP wrapper instance
- */
- void addIsisLsp(String lspKey, LspWrapper lspWrapper);
-
- /**
- * Removes LSP from bin.
- *
- * @param lspKey LSP key
- * @param lspWrapper LSP wrapper instance
- */
- void removeIsisLsp(String lspKey, LspWrapper lspWrapper);
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisMessage.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisMessage.java
deleted file mode 100644
index de823f2..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisMessage.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.MacAddress;
-
-/**
- * Representation of an ISIS Message.
- */
-public interface IsisMessage {
-
- /**
- * Returns the interface index on which the message received.
- *
- * @return interface index on which the message received
- */
- int interfaceIndex();
-
- /**
- * Sets the interface index on which the message received.
- *
- * @param interfaceIndex interface index on which the message received
- */
- void setInterfaceIndex(int interfaceIndex);
-
- /**
- * Returns the interface mac address on which the message received.
- *
- * @return interface mac address on which the message received
- */
- MacAddress interfaceMac();
-
- /**
- * Sets the interface mac address on which the message received.
- *
- * @param interfaceMac mac address on which the message received
- */
- void setInterfaceMac(MacAddress interfaceMac);
-
- /**
- * Returns the mac address of the message sender.
- *
- * @return mac address of the message sender
- */
- MacAddress sourceMac();
-
- /**
- * Sets the mac address of the message sender.
- *
- * @param sourceMac mac address of the message sender
- */
- void setSourceMac(MacAddress sourceMac);
-
- /**
- * Returns the type of ISIS PDU.
- *
- * @return ISIS PDU type instance
- */
- IsisPduType isisPduType();
-
- /**
- * Reads from channel buffer and initializes the type of PDU.
- *
- * @param channelBuffer channel buffer instance
- */
- void readFrom(ChannelBuffer channelBuffer);
-
- /**
- * Returns IsisMessage as byte array.
- *
- * @return ISIS message as bytes
- */
- byte[] asBytes();
-}
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisNeighbor.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisNeighbor.java
deleted file mode 100644
index 170f874..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisNeighbor.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller;
-
-import org.onlab.packet.MacAddress;
-
-/**
- * Representation of an ISIS neighbor.
- */
-public interface IsisNeighbor {
-
- /**
- * Returns the MAC address of neighbor.
- *
- * @return MAC address of neighbor
- */
- MacAddress neighborMacAddress();
-
- /**
- * Returns the neighbor interface state.
- *
- * @return neighbor interface state
- */
- IsisInterfaceState interfaceState();
-
- /**
- * Sets the neighbor interface state.
- *
- * @param interfaceState the neighbor interface state
- */
- void setNeighborState(IsisInterfaceState interfaceState);
-
- /**
- * Sets the LAN ID.
- *
- * @param l1LanId LAN ID
- */
- void setL1LanId(String l1LanId);
-
- /**
- * Sets the LAN ID.
- *
- * @param l2LanId LAN ID
- */
- void setL2LanId(String l2LanId);
-
- /**
- * Returns neighbor system ID.
- *
- * @return neighbor system ID
- */
- String neighborSystemId();
-
- /**
- * Returns neighbor circuit ID.
- *
- * @return neighbor circuit ID
- */
- byte localCircuitId();
-
- /**
- * Returns neighbor extended circuit ID.
- *
- * @return neighbor extended circuit ID
- */
- int localExtendedCircuitId();
-
- /**
- * Sets neighbor extended circuit ID.
- *
- * @param localExtendedCircuitId neighbor extended circuit ID
- */
- void setLocalExtendedCircuitId(int localExtendedCircuitId);
-
- /**
- * Returns Holding time of neighbor.
- *
- * @return Holding time of neighbor
- */
- int holdingTime();
-
- /**
- * Sets Holding time of neighbor.
- *
- * @param holdingTime Holding time of neighbor
- */
- void setHoldingTime(int holdingTime);
-
- /**
- * Starts the inactivity timer for this neighbor.
- */
- void startInactivityTimeCheck();
-
- /**
- * Stops the inactivity timer.
- */
- void stopInactivityTimeCheck();
-
- /**
- * Stops the holding time check timer.
- */
- void stopHoldingTimeCheck();
-
- /**
- * Returns router type.
- *
- * @return router type
- */
- IsisRouterType routerType();
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisNetworkType.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisNetworkType.java
deleted file mode 100644
index 7e21f3f..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisNetworkType.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Represents ISIS network types.
- */
-public enum IsisNetworkType {
- /**
- * Represents point-to-point network.
- */
- P2P(1),
- /**
- * Represents broadcast network.
- */
- BROADCAST(2);
- // Reverse lookup table
- private static final Map<Integer, IsisNetworkType> LOOKUP = new HashMap<>();
-
- // Populate the lookup table on loading time
- static {
- for (IsisNetworkType isisNetworkType : EnumSet.allOf(IsisNetworkType.class)) {
- LOOKUP.put(isisNetworkType.value(), isisNetworkType);
- }
- }
-
- private int value;
-
- /**
- * Creates an instance of ISIS network type.
- *
- * @param value represents ISIS network type
- */
- private IsisNetworkType(int value) {
- this.value = value;
- }
-
- /**
- * Gets the enum instance from type value - reverse lookup purpose.
- *
- * @param isisNetworkTypeValue interface network type value
- * @return ISIS interface network type instance
- */
- public static IsisNetworkType get(int isisNetworkTypeValue) {
- return LOOKUP.get(isisNetworkTypeValue);
- }
-
- /**
- * Gets the value representing network type.
- *
- * @return value represents network type
- */
- public int value() {
- return value;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisPduType.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisPduType.java
deleted file mode 100644
index 0169529..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisPduType.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Representation of ISIS PDU types.
- */
-public enum IsisPduType {
-
- /**
- * Represents Level-1 LAN hello packet.
- */
- L1HELLOPDU(15),
- /**
- * Represents Level-2 LAN hello packet.
- */
- L2HELLOPDU(16),
- /**
- * Represents point-to-point hello packet.
- */
- P2PHELLOPDU(17),
- /**
- * Represents Level-1 link state packet.
- */
- L1LSPDU(18),
- /**
- * Represents Level-2 link state packet.
- */
- L2LSPDU(20),
- /**
- * Represents Level-1 complete sequence number packet.
- */
- L1CSNP(24),
- /**
- * Represents Level-2 complete sequence number packet.
- */
- L2CSNP(25),
- /**
- * Represents Level-1 partial sequence number packet.
- */
- L1PSNP(26),
- /**
- * Represents Level-2 partial sequence number packet.
- */
- L2PSNP(27);
-
- // Reverse lookup table
- private static final Map<Integer, IsisPduType> LOOKUP = new HashMap<>();
-
- // Populate the lookup table on loading time
- static {
- for (IsisPduType isisPduType : EnumSet.allOf(IsisPduType.class)) {
- LOOKUP.put(isisPduType.value(), isisPduType);
- }
- }
-
- private int value;
-
- /**
- * Creates an instance of ISIS PDU type.
- *
- * @param value represents ISIS PDU type
- */
- private IsisPduType(int value) {
- this.value = value;
- }
-
- /**
- * Gets the enum instance from type value - reverse lookup purpose.
- *
- * @param pduTypeValue PDU type value
- * @return ISIS PDU type instance
- */
- public static IsisPduType get(int pduTypeValue) {
- return LOOKUP.get(pduTypeValue);
- }
-
- /**
- * Gets the value representing PDU type.
- *
- * @return value represents PDU type
- */
- public int value() {
- return value;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisProcess.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisProcess.java
deleted file mode 100644
index 2f11c96..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisProcess.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller;
-
-import java.util.List;
-
-/**
- * Representation of an ISIS process.
- */
-public interface IsisProcess {
-
- /**
- * Returns process ID.
- *
- * @return process ID
- */
- public String processId();
-
- /**
- * Sets process ID.
- *
- * @param processId process ID
- */
- void setProcessId(String processId);
-
- /**
- * Sets list of ISIS interfaces.
- *
- * @param isisInterfaceList list of ISIS interface details
- */
- void setIsisInterfaceList(List<IsisInterface> isisInterfaceList);
-
- /**
- * Returns list of ISIS interface details.
- *
- * @return list of ISIS interface details
- */
- List<IsisInterface> isisInterfaceList();
-}
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisRouterType.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisRouterType.java
deleted file mode 100644
index 1a4ada9..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisRouterType.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Representation of ISIS router types.
- */
-public enum IsisRouterType {
- /**
- * Represents ISIS L1 router.
- */
- L1(1),
- /**
- * Represents ISIS L2 router.
- */
- L2(2),
- /**
- * Represents ISIS L1/L2 router.
- */
- L1L2(3);
- // Reverse lookup table
- private static final Map<Integer, IsisRouterType> LOOKUP = new HashMap<>();
-
- // Populate the lookup table on loading time
- static {
- for (IsisRouterType isisRouterType : EnumSet.allOf(IsisRouterType.class)) {
- LOOKUP.put(isisRouterType.value(), isisRouterType);
- }
- }
-
- private int value;
-
- /**
- * Creates an instance of ISIS router type.
- *
- * @param value represents ISIS router type
- */
- private IsisRouterType(int value) {
- this.value = value;
- }
-
- /**
- * Gets the enum instance from type value - reverse lookup purpose.
- *
- * @param routerTypeValue router type value
- * @return ISIS router type instance
- */
- public static IsisRouterType get(int routerTypeValue) {
- return LOOKUP.get(routerTypeValue);
- }
-
- /**
- * Gets the value representing router type.
- *
- * @return value represents router type
- */
- public int value() {
- return value;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/LspWrapper.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/LspWrapper.java
deleted file mode 100644
index 9d5f124..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/LspWrapper.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller;
-
-/**
- * Representation of a LSP wrapper.
- */
-public interface LspWrapper {
-
- /**
- * Returns bin number into which the LSP wrapper is put for aging process.
- *
- * @return bin number
- */
- int binNumber();
-
- /**
- * Sets bin number into which the LSP wrapper is put for aging process.
- *
- * @param binNumber bin number
- */
- void setBinNumber(int binNumber);
-
- /**
- * Checks the contained LSP is self originated or not.
- *
- * @return true if self originated else false
- */
- boolean isSelfOriginated();
-
- /**
- * Sets the contained LSP is self originated or not.
- *
- * @param selfOriginated true if self originated else false
- */
- void setSelfOriginated(boolean selfOriginated);
-
- /**
- * Returns the LSP type.
- *
- * @return LSP type
- */
- IsisPduType lspType();
-
- /**
- * Returns the LSPs remaining life time.
- *
- * @return LSPs remaining life time.
- */
- int remainingLifetime();
-
- /**
- * Returns the age counter value when LSP was received.
- *
- * @return age counter value when LSP was received
- */
- int ageCounterWhenReceived();
-
- /**
- * Returns the age counter roll over value when LSP was added to wrapper instance.
- *
- * @return age counter roll over value when LSP was added to wrapper instance
- */
- int ageCounterRollOverWhenAdded();
-
- /**
- * Returns the LSP instance stored in wrapper.
- *
- * @return LSP instance stored in wrapper
- */
- IsisMessage lsPdu();
-
- /**
- * Sets LSPs remaining life time.
- *
- * @param remainingLifetime LSPs remaining life time
- */
- void setRemainingLifetime(int remainingLifetime);
-
- /**
- * Returns the age of LSP when received.
- *
- * @return age of LSP when received
- */
- int lspAgeReceived();
-
- /**
- * Returns the LSP processing string.
- *
- * @return lsp processing value for switch case
- */
- String lspProcessing();
-
- /**
- * Returns ISIS interface instance.
- *
- * @return ISIS interface instance
- */
- IsisInterface isisInterface();
-
- /**
- * Returns the current LSP age.
- *
- * @return LSP age
- */
- int currentAge();
-
- /**
- * Sets the LSP processing string based on LSP to process.
- *
- * @param lspProcessing "refreshLsp" or "maxageLsp" based on LSP to process
- */
- void setLspProcessing(String lspProcessing);
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/package-info.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/package-info.java
deleted file mode 100644
index 27b7015..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ISIS controller.
- */
-package org.onosproject.isis.controller;
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/DeviceInformation.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/DeviceInformation.java
deleted file mode 100644
index 68ae75b..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/DeviceInformation.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.topology;
-
-import org.onlab.packet.Ip4Address;
-
-/**
- * Representation of an ISIS device information.
- */
-public interface DeviceInformation {
-
- /**
- * Gets system id.
- *
- * @return system id
- */
- String systemId();
-
- /**
- * Sets system id.
- *
- * @param systemId system id
- */
- void setSystemId(String systemId);
-
- /**
- * Gets interface ids.
- *
- * @return interface ids
- */
- Ip4Address interfaceId();
-
- /**
- * Sets interface id.
- *
- * @param interfaceId interface id
- */
- void setInterfaceId(Ip4Address interfaceId);
-
- /**
- * Gets area id.
- *
- * @return area id
- */
- String areaId();
-
- /**
- * Sets area id.
- *
- * @param areaId area id
- */
- void setAreaId(String areaId);
-
- /**
- * Gets device information is already created or not.
- *
- * @return true if device information is already created else false
- */
- boolean isAlreadyCreated();
-
- /**
- * Sets device information is already created or not.
- *
- * @param alreadyCreated true if device information is already created else false
- */
- void setAlreadyCreated(boolean alreadyCreated);
-
- /**
- * Gets device is dis or not.
- *
- * @return true if device is dis else false
- */
- boolean isDis();
-
- /**
- * Sets device is dis or not.
- *
- * @param dis true if device is dr else false
- */
- void setDis(boolean dis);
-
- /**
- * Gets neighbor id.
- *
- * @return neighbor id
- */
- String neighborId();
-
- /**
- * Sets neighbor id.
- *
- * @param neighborId neighbor id
- */
- void setNeighborId(String neighborId);
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisAgent.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisAgent.java
deleted file mode 100644
index 07b0f15..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisAgent.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.isis.controller.topology;
-
-/**
- * Representation of an ISIS agent.
- * It is responsible for keeping track of the current set of routers
- * connected to the system.
- */
-public interface IsisAgent {
- /**
- * Adds a router that has just connected to the system.
- *
- * @param isisRouter the router id to add
- * @return true if added, false otherwise
- */
- boolean addConnectedRouter(IsisRouter isisRouter);
-
- /**
- * Removes the router which got disconnected from the system.
- *
- * @param isisRouter the router id to remove
- */
- void removeConnectedRouter(IsisRouter isisRouter);
-
- /**
- * Notifies that got a packet of link from network and need do processing.
- *
- * @param isisLink link instance
- */
- void addLink(IsisLink isisLink);
-
- /**
- * Notifies that got a packet of link from network and need do processing.
- *
- * @param isisLink link instance
- */
- void deleteLink(IsisLink isisLink);
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLink.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLink.java
deleted file mode 100644
index ff8e532..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLink.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.topology;
-
-import org.onlab.packet.Ip4Address;
-
-/**
- * Abstraction of an ISIS Link.
- */
-public interface IsisLink {
-
- /**
- * Returns the remote system ID.
- *
- * @return remote system ID
- */
- String remoteSystemId();
-
- /**
- * Returns the local system ID.
- *
- * @return local system ID
- */
- String localSystemId();
-
- /**
- * Returns IP address of the interface.
- *
- * @return IP address of the interface
- */
- Ip4Address interfaceIp();
-
- /**
- * Returns IP address of the neighbor.
- *
- * @return IP address of the neighbor
- */
- Ip4Address neighborIp();
-
- /**
- * Returns the link TED details.
- *
- * @return linkTed link TED
- */
- IsisLinkTed linkTed();
-
- /**
- * Sets remote system ID.
- *
- * @param remoteSystemId remote system ID
- */
- void setRemoteSystemId(String remoteSystemId);
-
- /**
- * Sets local system ID.
- *
- * @param localSystemId remote system ID
- */
- void setLocalSystemId(String localSystemId);
-
- /**
- * Sets IP address of the interface.
- *
- * @param interfaceIp IP address of the interface
- */
- void setInterfaceIp(Ip4Address interfaceIp);
-
- /**
- * Sets IP address of the neighbor.
- *
- * @param neighborIp IP address of the neighbor
- */
- void setNeighborIp(Ip4Address neighborIp);
-
- /**
- * Sets the link TED information.
- *
- * @param linkTed link TED
- */
- void setLinkTed(IsisLinkTed linkTed);
-}
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLinkListener.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLinkListener.java
deleted file mode 100644
index abf0b82..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLinkListener.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.topology;
-
-/**
- * Abstraction of an ISIS link listener.
- */
-public interface IsisLinkListener {
-
- /**
- * Notifies that we got a link from network.
- *
- * @param isisLink link instance
- */
- void addLink(IsisLink isisLink);
-
- /**
- * Notifies that a link got removed from network.
- *
- * @param isisLink link instance
- */
- void deleteLink(IsisLink isisLink);
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLinkTed.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLinkTed.java
deleted file mode 100644
index 8e1461d..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLinkTed.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.topology;
-
-import org.onlab.packet.Ip4Address;
-import org.onlab.util.Bandwidth;
-
-import java.util.List;
-
-/**
- * Representation of ISIS link traffic engineering parameters.
- */
-public interface IsisLinkTed {
-
- /**
- * Gets the administrative group.
- *
- * @return administrative group
- */
- int administrativeGroup();
-
- /**
- * Sets the administrative group.
- *
- * @param administrativeGroup administrative group
- */
- void setAdministrativeGroup(int administrativeGroup);
-
- /**
- * Provides the IPv4 interface address.
- *
- * @return IPv4 interface address
- */
- Ip4Address ipv4InterfaceAddress();
-
- /**
- * Sets the IPv4 interface address.
- *
- * @param interfaceAddress IPv4 interface address
- */
- void setIpv4InterfaceAddress(Ip4Address interfaceAddress);
-
- /**
- * Provides the IPv4 neighbor address.
- *
- * @return IPv4 neighbor address
- */
- Ip4Address ipv4NeighborAddress();
-
- /**
- * Sets the IPv4 neighbor address.
- *
- * @param neighborAddress IPv4 neighbor address
- */
- void setIpv4NeighborAddress(Ip4Address neighborAddress);
-
- /**
- * Gets the maximum link bandwidth.
- *
- * @return maximum link bandwidth
- */
- Bandwidth maximumLinkBandwidth();
-
- /**
- * Sets the maximum link bandwidth.
- *
- * @param bandwidth maximum link bandwidth
- */
- void setMaximumLinkBandwidth(Bandwidth bandwidth);
-
- /**
- * Provides max bandwidth that can be reservable on the link.
- *
- * @return max bandwidth reservable
- */
- Bandwidth maximumReservableLinkBandwidth();
-
- /**
- * Sets max bandwidth that can be reservable on the link.
- *
- * @param bandwidth max bandwidth that can be reservable on the link
- */
- void setMaximumReservableLinkBandwidth(Bandwidth bandwidth);
-
- /**
- * Amount of bandwidth unreserved on the link.
- *
- * @return unreserved bandwidth
- */
- List<Bandwidth> unreservedBandwidth();
-
- /**
- * Sets the bandwidth unreserved on the link.
- *
- * @param bandwidth bandwidth unreserved
- */
- void setUnreservedBandwidth(List<Bandwidth> bandwidth);
-
- /**
- * Provides Traffic Engineering metric for the link.
- *
- * @return Traffic Engineering Default metric
- */
- long teDefaultMetric();
-
- /**
- * Sets Traffic Engineering metric for the link.
- *
- * @param teMetric Traffic Engineering Default metric for the link
- */
- void setTeDefaultMetric(long teMetric);
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouter.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouter.java
deleted file mode 100644
index 7823ae4..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouter.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.topology;
-
-import org.onlab.packet.Ip4Address;
-
-/**
- * Abstraction of an ISIS Router.
- */
-public interface IsisRouter {
-
- /**
- * Returns system ID for the router.
- *
- * @return system ID of the router
- */
- String systemId();
-
- /**
- * Returns IP address of the interface.
- *
- * @return IP address of the interface
- */
- Ip4Address interfaceId();
-
- /**
- * Gets IP address of the interface.
- *
- * @param interfaceId IP address of the interface
- */
- void setInterfaceId(Ip4Address interfaceId);
-
- /**
- * Sets system ID of the Router.
- *
- * @param systemId system ID of the router
- */
- void setSystemId(String systemId);
-
- /**
- * Gets neighbours ID.
- *
- * @return neighbour ID
- */
- Ip4Address neighborRouterId();
-
- /**
- * Sets the neighbour Id.
- *
- * @param neighbourId neighbour Id
- */
- void setNeighborRouterId(Ip4Address neighbourId);
-
- /**
- * Gets if the router id DIS or not.
- *
- * @return true if the router is DIS else false
- */
- boolean isDis();
-
- /**
- * Sets if the router id DIS or not.
- *
- * @param dis true if the router is DIS else false
- */
- void setDis(boolean dis);
-}
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouterId.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouterId.java
deleted file mode 100644
index e45b659..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouterId.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.isis.controller.topology;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-/**
- * Represents an ISIS router id.
- */
-public class IsisRouterId {
-
- private static final String SCHEME = "l3";
- private static final long UNKNOWN = 0;
- private final String ipAddress;
-
- /**
- * Creates an instance of ISIS router id.
- *
- * @param ipAddress IP address of the router
- */
- public IsisRouterId(String ipAddress) {
- this.ipAddress = ipAddress;
- }
-
- /**
- * Creates an instance from ip address.
- *
- * @param ipAddress IP address
- * @return ISIS router id instance
- */
- public static IsisRouterId isisRouterId(String ipAddress) {
- return new IsisRouterId(ipAddress);
- }
-
- /**
- * Creates ISIS router id instance from the URI.
- *
- * @param uri device URI
- * @return ISIS router id instance
- */
- public static IsisRouterId isisRouterId(URI uri) {
- checkArgument(uri.getScheme().equals(SCHEME), "Unsupported URI scheme");
- return new IsisRouterId(uri.getSchemeSpecificPart());
- }
-
- /**
- * Returns device URI from the given router id.
- *
- * @param isisRouterId router id instance
- * @return device URI
- */
- public static URI uri(IsisRouterId isisRouterId) {
- return uri(isisRouterId.ipAddress());
- }
-
- /**
- * Returns device URI from the given IP address.
- *
- * @param ipAddress device IP address
- * @return device URI
- */
- public static URI uri(String ipAddress) {
- try {
- return new URI(SCHEME, ipAddress, null);
- } catch (URISyntaxException e) {
- return null;
- }
- }
-
- /**
- * Returns the IP address.
- *
- * @return IP address
- */
- public String ipAddress() {
- return ipAddress;
- }
-
- @Override
- public String toString() {
- return ipAddress;
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof IsisRouterId)) {
- return false;
- }
-
- IsisRouterId otherIsisRouterId = (IsisRouterId) other;
- return Objects.equals(ipAddress, otherIsisRouterId.ipAddress);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(ipAddress);
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouterListener.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouterListener.java
deleted file mode 100644
index d42b23e..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouterListener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.topology;
-
-/**
- * Abstraction of an ISIS Router Listener.
- * Allows for providers interested in switch events to be notified.
- */
-public interface IsisRouterListener {
-
- /**
- * Notifies that a router is added.
- *
- * @param isisRouter ISIS router instance
- */
- void routerAdded(IsisRouter isisRouter);
-
- /**
- * Notifies that a router is removed.
- *
- * @param isisRouter ISIS router instance
- */
- void routerRemoved(IsisRouter isisRouter);
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/LinkInformation.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/LinkInformation.java
deleted file mode 100644
index 573e5ef..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/LinkInformation.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.topology;
-
-import org.onlab.packet.Ip4Address;
-
-/**
- * Representation of an ISIS link information.
- */
-public interface LinkInformation {
-
- /**
- * Gets link id.
- *
- * @return link id
- */
- String linkId();
-
- /**
- * Sets link id.
- *
- * @param linkId link id
- */
- void setLinkId(String linkId);
-
- /**
- * Gets whether link information is already created or not.
- *
- * @return true if link information is already created else false
- */
- boolean isAlreadyCreated();
-
- /**
- * Sets link information is already created or not.
- *
- * @param alreadyCreated true if link information is already created else false
- */
- void setAlreadyCreated(boolean alreadyCreated);
-
-
- /**
- * Returns link destination ID.
- *
- * @return link destination ID
- */
- String linkDestinationId();
-
- /**
- * Sets link destination id.
- *
- * @param linkDestinationId link destination id
- */
- void setLinkDestinationId(String linkDestinationId);
-
- /**
- * Gets link source id.
- *
- * @return link source id
- */
- String linkSourceId();
-
- /**
- * Sets link source id.
- *
- * @param linkSourceId link source id
- */
- void setLinkSourceId(String linkSourceId);
-
- /**
- * Gets interface ip address.
- *
- * @return interface ip address
- */
- Ip4Address interfaceIp();
-
- /**
- * Sets interface ip address.
- *
- * @param interfaceIp interface ip address
- */
- void setInterfaceIp(Ip4Address interfaceIp);
-
- /**
- * Gets neighbor ip address.
- *
- * @return neighbor ip address
- */
- Ip4Address neighborIp();
-
- /**
- * Sets neighbor ip address.
- *
- * @param neighborIp neighbor ip address
- */
- void setNeighborIp(Ip4Address neighborIp);
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/TopologyForDeviceAndLink.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/TopologyForDeviceAndLink.java
deleted file mode 100644
index 3a61b2b..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/TopologyForDeviceAndLink.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.topology;
-
-import java.util.Map;
-
-/**
- * Represents IP topology for ISIS device and link details.
- */
-public interface TopologyForDeviceAndLink {
-
- /**
- * Gets the device information.
- *
- * @return device information
- */
- Map<String, DeviceInformation> deviceInformationMap();
-
- /**
- * Sets the device information.
- *
- * @param key system ID of the device as key
- * @param deviceInformationMap device information instance
- */
- void setDeviceInformationMap(String key, DeviceInformation deviceInformationMap);
-
- /**
- * Gets the link information.
- *
- * @return link information
- */
- Map<String, LinkInformation> linkInformationMap();
-
- /**
- * Sets link information.
- *
- * @param key system ID of the device as key
- * @param linkInformationMap link information instance
- */
- void setLinkInformationMap(String key, LinkInformation linkInformationMap);
-
- /**
- * Removes link information.
- *
- * @param key key used to remove from map
- */
- void removeLinkInformationMap(String key);
-
- /**
- * Removes device information.
- *
- * @param key key used to remove from map
- */
- void removeDeviceInformationMap(String key);
-
- /**
- * Removes links from linkInformationMap.
- *
- * @param linkId ID
- */
- void removeLinks(String linkId);
-
- /**
- * Gets deviceInformation as map.
- *
- * @return deviceInformationMap to delete from core
- */
- Map<String, DeviceInformation> deviceInformationMapToDelete();
-
- /**
- * Sets deviceInformation as map.
- *
- * @param key key used to add in map
- * @param deviceInformationMapToDelete device information to delete from map
- */
- void setDeviceInformationMapToDelete(String key, DeviceInformation deviceInformationMapToDelete);
-
- /**
- * Removes Device Information from deviceInformationMapToDelete.
- *
- * @param key key to remove from map
- */
- void removeDeviceInformationMapFromDeleteMap(String key);
-
- /**
- * Gets deviceInformation as map for Point-To-Point.
- *
- * @return deviceInformationMap
- */
- Map<String, DeviceInformation> deviceInformationMapForPointToPoint();
-
- /**
- * Sets deviceInformation as map for Point-To-Point..
- *
- * @param key key to add to map
- * @param deviceInformationMap device information map
- */
- void setDeviceInformationMapForPointToPoint(String key, DeviceInformation deviceInformationMap);
-
- /**
- * Gets linkInformation as map for PointToPoint.
- *
- * @return linkInformationMap
- */
- Map<String, LinkInformation> linkInformationMapForPointToPoint();
-
- /**
- * Sets linkInformation as map for PointToPoint.
- *
- * @param key key to add link information to map
- * @param linkInformationMap link information to add
- */
- void setLinkInformationMapForPointToPoint(String key, LinkInformation linkInformationMap);
-}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/package-info.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/package-info.java
deleted file mode 100644
index cc563b8..0000000
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ISIS topology provider.
- */
-package org.onosproject.isis.controller.topology;
\ No newline at end of file
diff --git a/protocols/isis/ctl/BUILD b/protocols/isis/ctl/BUILD
deleted file mode 100644
index 950f043..0000000
--- a/protocols/isis/ctl/BUILD
+++ /dev/null
@@ -1,9 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
- "@io_netty_netty//jar",
- "//protocols/isis/api:onos-protocols-isis-api",
- "//protocols/isis/isisio:onos-protocols-isis-isisio",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
deleted file mode 100644
index 381109e..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
+++ /dev/null
@@ -1,598 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.jboss.netty.bootstrap.ClientBootstrap;
-import org.jboss.netty.channel.AdaptiveReceiveBufferSizePredictor;
-import org.jboss.netty.channel.ChannelFuture;
-import org.jboss.netty.channel.ChannelFutureListener;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory;
-import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.TpPort;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisNetworkType;
-import org.onosproject.isis.controller.IsisProcess;
-import org.onosproject.isis.controller.IsisRouterType;
-import org.onosproject.isis.controller.topology.IsisAgent;
-import org.onosproject.isis.controller.topology.IsisLink;
-import org.onosproject.isis.controller.topology.IsisRouter;
-import org.onosproject.isis.io.util.IsisConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.NetworkInterface;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
-import static org.onlab.util.Tools.groupedThreads;
-
-/**
- * Representation of an ISIS controller.
- */
-public class Controller {
- protected static final int BUFFER_SIZE = 4 * 1024 * 1024;
- private static final Logger log = LoggerFactory.getLogger(Controller.class);
- private static final int RETRY_INTERVAL = 4;
- private final int peerWorkerThreads = 16;
- byte[] configPacket = null;
- private List<IsisProcess> processes = null;
- private IsisChannelHandler isisChannelHandler;
- private NioClientSocketChannelFactory peerExecFactory;
- private ClientBootstrap peerBootstrap = null;
- private TpPort isisPort = TpPort.tpPort(IsisConstants.SPORT);
- private ScheduledExecutorService connectExecutor = null;
- private int connectRetryCounter = 0;
- private int connectRetryTime;
- private ScheduledFuture future = null;
- private IsisAgent agent;
-
- /**
- * Deactivates ISIS controller.
- */
- public void isisDeactivate() {
- disconnectExecutor();
- processes = null;
- if (peerExecFactory != null) {
- peerExecFactory.shutdown();
- }
- }
-
- /**
- * Sets ISIS agent.
- *
- * @param agent ISIS agent instance
- */
- public void setAgent(IsisAgent agent) {
- this.agent = agent;
- }
-
-
- /**
- * Updates the processes configuration.
- *
- * @param jsonNode json node instance
- */
- public void updateConfig(JsonNode jsonNode) {
- log.debug("Controller::UpdateConfig called");
- configPacket = new byte[IsisConstants.CONFIG_LENGTH];
- byte numberOfInterface = 0; // number of interfaces to configure
-
- configPacket[0] = (byte) 0xFF; // its a conf packet - identifier
- List<IsisProcess> isisProcesses = getConfig(jsonNode);
- for (IsisProcess isisProcess : isisProcesses) {
- log.debug("IsisProcessDetails : " + isisProcess);
- for (IsisInterface isisInterface : isisProcess.isisInterfaceList()) {
- DefaultIsisInterface isisInterfaceImpl = (DefaultIsisInterface) isisInterface;
- log.debug("IsisInterfaceDetails : " + isisInterface);
- numberOfInterface++;
- configPacket[2 * numberOfInterface] = (byte) isisInterfaceImpl.interfaceIndex();
- if (isisInterface.networkType() == IsisNetworkType.BROADCAST &&
- isisInterfaceImpl.reservedPacketCircuitType() == IsisRouterType.L1.value()) {
- configPacket[(2 * numberOfInterface) + 1] = (byte) 0;
- } else if (isisInterface.networkType() == IsisNetworkType.BROADCAST &&
- isisInterfaceImpl.reservedPacketCircuitType() == IsisRouterType.L2.value()) {
- configPacket[(2 * numberOfInterface) + 1] = (byte) 1;
- } else if (isisInterface.networkType() == IsisNetworkType.P2P) {
- configPacket[(2 * numberOfInterface) + 1] = (byte) 2;
- } else if (isisInterface.networkType() == IsisNetworkType.BROADCAST &&
- isisInterfaceImpl.reservedPacketCircuitType() == IsisRouterType.L1L2.value()) {
- configPacket[(2 * numberOfInterface) + 1] = (byte) 3;
- }
- }
- }
- configPacket[1] = numberOfInterface;
- //First time configuration
- if (processes == null) {
- if (!isisProcesses.isEmpty()) {
- processes = isisProcesses;
- connectPeer();
- }
- } else {
- isisChannelHandler.updateInterfaceMap(isisProcesses);
- //Send the config packet
- isisChannelHandler.sentConfigPacket(configPacket);
- }
- }
-
- /**
- * Initializes the netty client channel connection.
- */
- private void initConnection() {
- if (peerBootstrap != null) {
- return;
- }
- peerBootstrap = createPeerBootStrap();
-
- peerBootstrap.setOption("reuseAddress", true);
- peerBootstrap.setOption("tcpNoDelay", true);
- peerBootstrap.setOption("keepAlive", true);
- peerBootstrap.setOption("receiveBufferSize", Controller.BUFFER_SIZE);
- peerBootstrap.setOption("receiveBufferSizePredictorFactory",
- new FixedReceiveBufferSizePredictorFactory(
- Controller.BUFFER_SIZE));
- peerBootstrap.setOption("receiveBufferSizePredictor",
- new AdaptiveReceiveBufferSizePredictor(64, 1024, 65536));
- peerBootstrap.setOption("child.keepAlive", true);
- peerBootstrap.setOption("child.tcpNoDelay", true);
- peerBootstrap.setOption("child.sendBufferSize", Controller.BUFFER_SIZE);
- peerBootstrap.setOption("child.receiveBufferSize", Controller.BUFFER_SIZE);
- peerBootstrap.setOption("child.receiveBufferSizePredictorFactory",
- new FixedReceiveBufferSizePredictorFactory(
- Controller.BUFFER_SIZE));
- peerBootstrap.setOption("child.reuseAddress", true);
-
- isisChannelHandler = new IsisChannelHandler(this, processes);
- ChannelPipelineFactory pfact = new IsisPipelineFactory(isisChannelHandler);
- peerBootstrap.setPipelineFactory(pfact);
- }
-
- /**
- * Creates peer boot strap.
- *
- * @return client bootstrap instance
- */
- private ClientBootstrap createPeerBootStrap() {
-
- if (peerWorkerThreads == 0) {
- peerExecFactory = new NioClientSocketChannelFactory(
- Executors.newCachedThreadPool(groupedThreads("onos/isis", "boss-%d")),
- Executors.newCachedThreadPool(groupedThreads("onos/isis", "worker-%d")));
- return new ClientBootstrap(peerExecFactory);
- } else {
- peerExecFactory = new NioClientSocketChannelFactory(
- Executors.newCachedThreadPool(groupedThreads("onos/isis", "boss-%d")),
- Executors.newCachedThreadPool(groupedThreads("onos/isis", "worker-%d")),
- peerWorkerThreads);
- return new ClientBootstrap(peerExecFactory);
- }
- }
-
- /**
- * Gets all configured processes.
- *
- * @return all configured processes
- */
- public List<IsisProcess> getAllConfiguredProcesses() {
- return processes;
- }
-
- /**
- * Gets the list of processes configured.
- *
- * @param json posted json
- * @return list of processes configured
- */
- private List<IsisProcess> getConfig(JsonNode json) {
- List<IsisProcess> isisProcessesList = new ArrayList<>();
- JsonNode jsonNodes = json;
- if (jsonNodes == null) {
- return isisProcessesList;
- }
- jsonNodes.forEach(jsonNode -> {
- List<IsisInterface> interfaceList = new ArrayList<>();
- for (JsonNode jsonNode1 : jsonNode.path(IsisConstants.INTERFACE)) {
- IsisInterface isisInterface = new DefaultIsisInterface();
- String index = jsonNode1.path(IsisConstants.INTERFACEINDEX).asText();
- if (isPrimitive(index)) {
- int input = Integer.parseInt(index);
- if (input < 1 || input > 255) {
- log.debug("Wrong interface index: {}", index);
- continue;
- }
- isisInterface.setInterfaceIndex(Integer.parseInt(index));
- } else {
- log.debug("Wrong interface index {}", index);
- continue;
- }
- Ip4Address ipAddress = getInterfaceIp(isisInterface.interfaceIndex());
- if (ipAddress != null && !ipAddress.equals(IsisConstants.DEFAULTIP)) {
- isisInterface.setInterfaceIpAddress(ipAddress);
- } else {
- log.debug("Wrong interface index {}. No matching interface in system.", index);
- continue;
- }
- MacAddress macAddress = getInterfaceMac(isisInterface.interfaceIndex());
- if (macAddress != null) {
- isisInterface.setInterfaceMacAddress(macAddress);
- } else {
- log.debug("Wrong interface index {}. No matching interface in system.", index);
- continue;
- }
- String mask = getInterfaceMask(isisInterface.interfaceIndex());
- if (mask != null) {
- try {
- isisInterface.setNetworkMask(InetAddress.getByName(mask).getAddress());
- } catch (UnknownHostException e) {
- log.debug("Wrong interface index {}. Error while getting network mask.", index);
- }
- } else {
- log.debug("Wrong interface index {}. Error while getting network mask.", index);
- continue;
- }
- isisInterface.setIntermediateSystemName(jsonNode1
- .path(IsisConstants.INTERMEDIATESYSTEMNAME)
- .asText());
- String systemId = jsonNode1.path(IsisConstants.SYSTEMID).asText();
- if (isValidSystemId(systemId)) {
- isisInterface.setSystemId(systemId);
- } else {
- log.debug("Wrong systemId: {} for interface index {}.", systemId, index);
- continue;
- }
- String circuitType = jsonNode1.path(IsisConstants.RESERVEDPACKETCIRCUITTYPE).asText();
- if (isPrimitive(circuitType)) {
- int input = Integer.parseInt(circuitType);
- if (input < 1 || input > 3) {
- log.debug("Wrong ReservedPacketCircuitType: {} for interface index {}.", circuitType, index);
- continue;
- }
- isisInterface.setReservedPacketCircuitType(input);
- } else {
- log.debug("Wrong ReservedPacketCircuitType: {} for interface index {}.", circuitType, index);
- continue;
- }
- String networkType = jsonNode1.path(IsisConstants.NETWORKTYPE).asText();
- if (isPrimitive(networkType)) {
- int input = Integer.parseInt(networkType);
- if (input < 1 || input > 2) {
- log.debug("Wrong networkType: {} for interface index {}.", networkType, index);
- continue;
- }
- isisInterface.setNetworkType(IsisNetworkType.get(input));
- } else {
- log.debug("Wrong networkType: {} for interface index {}.", networkType, index);
- continue;
- }
- String areaAddress = jsonNode1.path(IsisConstants.AREAADDRESS).asText();
- if (isPrimitive(areaAddress)) {
- if (areaAddress.length() > 7) {
- log.debug("Wrong areaAddress: {} for interface index {}.", areaAddress, index);
- continue;
- }
- isisInterface.setAreaAddress(areaAddress);
- } else {
- log.debug("Wrong areaAddress: {} for interface index {}.", areaAddress, index);
- continue;
- }
- String circuitId = jsonNode1.path(IsisConstants.CIRCUITID).asText();
- if (isPrimitive(circuitId)) {
- int input = Integer.parseInt(circuitId);
- if (input < 1) {
- log.debug("Wrong circuitId: {} for interface index {}.", circuitId, index);
- continue;
- }
- isisInterface.setCircuitId(circuitId);
- } else {
- log.debug("Wrong circuitId: {} for interface index {}.", circuitId, index);
- continue;
- }
- String holdingTime = jsonNode1.path(IsisConstants.HOLDINGTIME).asText();
- if (isPrimitive(holdingTime)) {
- int input = Integer.parseInt(holdingTime);
- if (input < 1 || input > 255) {
- log.debug("Wrong holdingTime: {} for interface index {}.", holdingTime, index);
- continue;
- }
- isisInterface.setHoldingTime(input);
- } else {
- log.debug("Wrong holdingTime: {} for interface index {}.", holdingTime, index);
- continue;
- }
- String helloInterval = jsonNode1.path(IsisConstants.HELLOINTERVAL).asText();
- if (isPrimitive(helloInterval)) {
- int interval = Integer.parseInt(helloInterval);
- if (interval > 0 && interval <= 255) {
- isisInterface.setHelloInterval(interval);
- } else {
- log.debug("Wrong hello interval: {} for interface index {}.", helloInterval, index);
- continue;
- }
- } else {
- log.debug("Wrong hello interval: {} for interface index {}.", helloInterval, index);
- continue;
- }
- interfaceList.add(isisInterface);
- }
- if (!interfaceList.isEmpty()) {
- IsisProcess process = new DefaultIsisProcess();
- process.setProcessId(jsonNode.path(IsisConstants.PROCESSESID).asText());
- process.setIsisInterfaceList(interfaceList);
- isisProcessesList.add(process);
- }
- });
-
- return isisProcessesList;
- }
-
- /**
- * Returns interface MAC by index.
- *
- * @param interfaceIndex interface index
- * @return interface IP by index
- */
- private MacAddress getInterfaceMac(int interfaceIndex) {
- MacAddress macAddress = null;
- try {
- NetworkInterface networkInterface = NetworkInterface.getByIndex(interfaceIndex);
- macAddress = MacAddress.valueOf(networkInterface.getHardwareAddress());
- } catch (Exception e) {
- log.debug("Error while getting Interface IP by index");
- return macAddress;
- }
-
- return macAddress;
- }
-
- /**
- * Returns interface IP by index.
- *
- * @param interfaceIndex interface index
- * @return interface IP by index
- */
- private Ip4Address getInterfaceIp(int interfaceIndex) {
- Ip4Address ipAddress = null;
- try {
- NetworkInterface networkInterface = NetworkInterface.getByIndex(interfaceIndex);
- Enumeration ipAddresses = networkInterface.getInetAddresses();
- while (ipAddresses.hasMoreElements()) {
- InetAddress address = (InetAddress) ipAddresses.nextElement();
- if (!address.isLinkLocalAddress()) {
- ipAddress = Ip4Address.valueOf(address.getAddress());
- break;
- }
- }
- } catch (Exception e) {
- log.debug("Error while getting Interface IP by index");
- return IsisConstants.DEFAULTIP;
- }
- return ipAddress;
- }
-
- /**
- * Returns interface MAC by index.
- *
- * @param interfaceIndex interface index
- * @return interface IP by index
- */
- private String getInterfaceMask(int interfaceIndex) {
- String subnetMask = null;
- try {
- Ip4Address ipAddress = getInterfaceIp(interfaceIndex);
- NetworkInterface networkInterface = NetworkInterface.getByInetAddress(
- InetAddress.getByName(ipAddress.toString()));
- Enumeration ipAddresses = networkInterface.getInetAddresses();
- int index = 0;
- while (ipAddresses.hasMoreElements()) {
- InetAddress address = (InetAddress) ipAddresses.nextElement();
- if (!address.isLinkLocalAddress()) {
- break;
- }
- index++;
- }
- int prfLen = networkInterface.getInterfaceAddresses().get(index).getNetworkPrefixLength();
- int shft = 0xffffffff << (32 - prfLen);
- int oct1 = ((byte) ((shft & 0xff000000) >> 24)) & 0xff;
- int oct2 = ((byte) ((shft & 0x00ff0000) >> 16)) & 0xff;
- int oct3 = ((byte) ((shft & 0x0000ff00) >> 8)) & 0xff;
- int oct4 = ((byte) (shft & 0x000000ff)) & 0xff;
- subnetMask = oct1 + "." + oct2 + "." + oct3 + "." + oct4;
- } catch (Exception e) {
- log.debug("Error while getting Interface network mask by index");
- return subnetMask;
- }
- return subnetMask;
- }
-
- /**
- * Checks if primitive or not.
- *
- * @param value input value
- * @return true if number else false
- */
- private boolean isPrimitive(String value) {
- boolean status = true;
- value = value.trim();
- if (value.length() < 1) {
- return false;
- }
- for (int i = 0; i < value.length(); i++) {
- char c = value.charAt(i);
- if (!Character.isDigit(c)) {
- status = false;
- break;
- }
- }
-
- return status;
- }
-
- /**
- * Checks if system id is valid or not.
- *
- * @param value input value
- * @return true if valid else false
- */
- private boolean isValidSystemId(String value) {
- value = value.trim();
- boolean status = true;
- if (value.length() != 14) {
- return false;
- }
- for (int i = 0; i < value.length(); i++) {
- char c = value.charAt(i);
- if (!Character.isDigit(c)) {
- if (!((i == 4 || i == 9) && c == '.')) {
- status = false;
- break;
- }
- }
- }
-
- return status;
- }
-
- /**
- * Disconnects the executor.
- */
- public void disconnectExecutor() {
- if (connectExecutor != null) {
- future.cancel(true);
- connectExecutor.shutdownNow();
- connectExecutor = null;
- }
- }
-
- /**
- * Connects to peer.
- */
- public void connectPeer() {
- scheduleConnectionRetry(this.connectRetryTime);
- }
-
- /**
- * Retry connection with exponential back-off mechanism.
- *
- * @param retryDelay retry delay
- */
- private void scheduleConnectionRetry(long retryDelay) {
- if (connectExecutor == null) {
- connectExecutor = Executors.newSingleThreadScheduledExecutor();
- }
- future = connectExecutor.schedule(new ConnectionRetry(), retryDelay, TimeUnit.MINUTES);
- }
-
- /**
- * Adds device details.
- *
- * @param isisRouter ISIS router instance
- */
- public void addDeviceDetails(IsisRouter isisRouter) {
- agent.addConnectedRouter(isisRouter);
- }
-
- /**
- * Removes device details.
- *
- * @param isisRouter Isis router instance
- */
- public void removeDeviceDetails(IsisRouter isisRouter) {
- agent.removeConnectedRouter(isisRouter);
- }
-
- /**
- * Adds link details.
- *
- * @param isisLink ISIS link instance
- */
- public void addLinkDetails(IsisLink isisLink) {
- agent.addLink(isisLink);
- }
-
- /**
- * Removes link details.
- *
- * @param isisLink ISIS link instance
- */
- public void removeLinkDetails(IsisLink isisLink) {
- agent.deleteLink(isisLink);
- }
-
- /**
- * Returns the isisAgent instance.
- *
- * @return agent
- */
- public IsisAgent agent() {
- return this.agent;
- }
-
- /**
- * Implements ISIS connection and manages connection to peer with back-off mechanism in case of failure.
- */
- class ConnectionRetry implements Runnable {
- @Override
- public void run() {
- log.debug("Connect to peer {}", IsisConstants.SHOST);
- initConnection();
- isisChannelHandler.sentConfigPacket(configPacket);
- InetSocketAddress connectToSocket = new InetSocketAddress(IsisConstants.SHOST, isisPort.toInt());
- try {
- peerBootstrap.connect(connectToSocket).addListener(new ChannelFutureListener() {
- @Override
- public void operationComplete(ChannelFuture future) throws Exception {
- if (!future.isSuccess()) {
- connectRetryCounter++;
- log.error("Connection failed, ConnectRetryCounter {} remote host {}", connectRetryCounter,
- IsisConstants.SHOST);
- /*
- * Reconnect to peer on failure is exponential till 4 mins, later on retry after every 4
- * mins.
- */
- if (connectRetryTime < RETRY_INTERVAL) {
- connectRetryTime = (connectRetryTime != 0) ? connectRetryTime * 2 : 1;
- }
- scheduleConnectionRetry(connectRetryTime);
- } else {
- //Send the config packet
- isisChannelHandler.sentConfigPacket(configPacket);
- connectRetryCounter++;
- log.info("Connected to remote host {}, Connect Counter {}", IsisConstants.SHOST,
- connectRetryCounter);
- disconnectExecutor();
-
- return;
- }
- }
- });
- } catch (Exception e) {
- log.info("Connect peer exception : " + e.toString());
- disconnectExecutor();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisController.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisController.java
deleted file mode 100644
index 1f17969..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisController.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.google.common.collect.Sets;
-import org.onosproject.isis.controller.IsisController;
-import org.onosproject.isis.controller.IsisProcess;
-import org.onosproject.isis.controller.topology.IsisAgent;
-import org.onosproject.isis.controller.topology.IsisLink;
-import org.onosproject.isis.controller.topology.IsisLinkListener;
-import org.onosproject.isis.controller.topology.IsisRouter;
-import org.onosproject.isis.controller.topology.IsisRouterListener;
-import org.onosproject.net.driver.DriverService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Represents ISIS controller implementation.
- */
-@Component(immediate = true, service = IsisController.class)
-public class DefaultIsisController implements IsisController {
-
- private static final Logger log = LoggerFactory.getLogger(DefaultIsisController.class);
- private final Controller controller = new Controller();
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DriverService driverService;
- protected Set<IsisRouterListener> isisRouterListener = new HashSet<>();
- protected Set<IsisLinkListener> isisLinkListener = Sets.newHashSet();
- protected IsisAgent agent = new InternalDeviceConfig();
-
- @Activate
- public void activate() {
- log.debug("ISISControllerImpl activate");
- controller.setAgent(agent);
- }
-
- @Deactivate
- public void deactivate() {
- controller.isisDeactivate();
- log.debug("ISISControllerImpl deActivate");
- }
-
- @Override
- public void addRouterListener(IsisRouterListener listener) {
- if (!isisRouterListener.contains(listener)) {
- this.isisRouterListener.add(listener);
- }
- }
-
- @Override
- public void removeRouterListener(IsisRouterListener listener) {
- this.isisRouterListener.remove(listener);
- }
-
- @Override
- public void addLinkListener(IsisLinkListener listener) {
- isisLinkListener.add(listener);
- }
-
- @Override
- public void removeLinkListener(IsisLinkListener listener) {
- isisLinkListener.remove(listener);
- }
-
- @Override
- public Set<IsisRouterListener> listener() {
- return isisRouterListener;
- }
-
- @Override
- public Set<IsisLinkListener> linkListener() {
- return isisLinkListener;
- }
-
- @Override
- public List<IsisProcess> allConfiguredProcesses() {
- List<IsisProcess> processes = controller.getAllConfiguredProcesses();
- return processes;
- }
-
- @Override
- public void updateConfig(JsonNode jsonNode) {
- log.debug("updateConfig::IsisList::processes::{}", jsonNode);
- try {
- controller.updateConfig(jsonNode);
- } catch (Exception e) {
- log.debug("Error::updateConfig::{}", e.getMessage());
- }
- }
-
- /**
- * Notifier for internal ISIS device and link changes.
- */
- private class InternalDeviceConfig implements IsisAgent {
- @Override
- public boolean addConnectedRouter(IsisRouter isisRouter) {
- for (IsisRouterListener l : listener()) {
- l.routerAdded(isisRouter);
- }
- return true;
- }
-
- @Override
- public void removeConnectedRouter(IsisRouter isisRouter) {
- for (IsisRouterListener l : listener()) {
- l.routerRemoved(isisRouter);
- }
- }
-
- @Override
- public void addLink(IsisLink isisLink) {
- for (IsisLinkListener l : linkListener()) {
- l.addLink(isisLink);
- }
- }
-
- @Override
- public void deleteLink(IsisLink isisLink) {
- for (IsisLinkListener l : linkListener()) {
- l.deleteLink(isisLink);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisInterface.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisInterface.java
deleted file mode 100644
index 2c2aa1a..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisInterface.java
+++ /dev/null
@@ -1,1130 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import org.jboss.netty.channel.Channel;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.MacAddress;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisInterfaceState;
-import org.onosproject.isis.controller.IsisLsdb;
-import org.onosproject.isis.controller.IsisMessage;
-import org.onosproject.isis.controller.IsisNeighbor;
-import org.onosproject.isis.controller.IsisNetworkType;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.controller.IsisRouterType;
-import org.onosproject.isis.controller.LspWrapper;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.pdu.Csnp;
-import org.onosproject.isis.io.isispacket.pdu.HelloPdu;
-import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-import org.onosproject.isis.io.isispacket.pdu.P2PHelloPdu;
-import org.onosproject.isis.io.isispacket.pdu.Psnp;
-import org.onosproject.isis.io.isispacket.tlv.AdjacencyStateTlv;
-import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
-import org.onosproject.isis.io.isispacket.tlv.LspEntriesTlv;
-import org.onosproject.isis.io.isispacket.tlv.LspEntry;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.isispacket.tlv.TlvType;
-import org.onosproject.isis.io.util.IsisConstants;
-import org.onosproject.isis.io.util.IsisUtil;
-import org.onosproject.isis.io.util.LspGenerator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Representation of an ISIS interface.
- */
-public class DefaultIsisInterface implements IsisInterface {
- private static final Logger log = LoggerFactory.getLogger(DefaultIsisInterface.class);
- boolean flagValue = false;
- private int interfaceIndex;
- private Ip4Address interfaceIpAddress;
- private byte[] networkMask;
- private MacAddress interfaceMacAddress;
- private String intermediateSystemName;
- private String systemId;
- private String l1LanId = IsisConstants.DEFAULTLANID;
- private String l2LanId = IsisConstants.DEFAULTLANID;
- private int idLength;
- private int maxAreaAddresses;
- private int reservedPacketCircuitType;
- private IsisNetworkType networkType;
- private String areaAddress;
- private int areaLength;
- private int holdingTime;
- private int priority;
- private String circuitId;
- private int helloInterval;
- private Map<MacAddress, IsisNeighbor> neighborList = new ConcurrentHashMap<>();
- private IsisHelloPduSender isisHelloPduSender = null;
- private ScheduledExecutorService exServiceHello = null;
- private IsisInterfaceState interfaceState = IsisInterfaceState.DOWN;
- private IsisLsdb isisLsdb = null;
- private List<Ip4Address> allConfiguredInterfaceIps = null;
- private Channel channel;
- private boolean helloSenderStarted = false;
-
- /**
- * Returns ISIS LSDB instance.
- *
- * @return ISIS LSDB instance
- */
- public IsisLsdb isisLsdb() {
- return isisLsdb;
- }
-
- /**
- * Sets all configured interface IPs.
- *
- * @param allConfiguredInterfaces all configured interface IPs
- */
- public void setAllConfiguredInterfaceIps(List<Ip4Address> allConfiguredInterfaces) {
- allConfiguredInterfaceIps = allConfiguredInterfaces;
- }
-
- /**
- * Removes neighbor from the interface neighbor map.
- *
- * @param isisNeighbor ISIS neighbor instance
- */
- public void removeNeighbor(IsisNeighbor isisNeighbor) {
- log.debug("Neighbor removed - {}", isisNeighbor.neighborMacAddress());
- isisNeighbor.stopHoldingTimeCheck();
- isisNeighbor.stopInactivityTimeCheck();
- neighborList.remove(isisNeighbor.neighborMacAddress());
- }
-
- /**
- * Removes all the neighbors.
- */
- public void removeNeighbors() {
- Set<MacAddress> neighbors = neighbors();
- for (MacAddress mac : neighbors) {
- removeNeighbor(lookup(mac));
- log.debug("Neighbor removed - {}", mac);
- }
- neighborList.clear();
- }
-
- /**
- * Returns the ISIS neighbor instance if exists.
- *
- * @param isisNeighborMac mac address of the neighbor router
- * @return ISIS neighbor instance if exists else null
- */
- public IsisNeighbor lookup(MacAddress isisNeighborMac) {
- return neighborList.get(isisNeighborMac);
- }
-
- /**
- * Returns the neighbors list.
- *
- * @return neighbors list
- */
- public Set<MacAddress> neighbors() {
- return neighborList.keySet();
- }
-
- /**
- * Returns channel instance.
- *
- * @return channel instance
- */
- public Channel channel() {
- return channel;
- }
-
- /**
- * Returns interface index.
- *
- * @return interface index
- */
- public int interfaceIndex() {
- return interfaceIndex;
- }
-
- /**
- * Set interface index.
- *
- * @param interfaceIndex interface index
- */
- public void setInterfaceIndex(int interfaceIndex) {
- this.interfaceIndex = interfaceIndex;
- }
-
- /**
- * Returns the interface IP address.
- *
- * @return interface IP address
- */
- public Ip4Address interfaceIpAddress() {
- return interfaceIpAddress;
- }
-
- /**
- * Sets the interface IP address.
- *
- * @param interfaceIpAddress interfaceIpAddress interface IP address
- */
- public void setInterfaceIpAddress(Ip4Address interfaceIpAddress) {
- this.interfaceIpAddress = interfaceIpAddress;
- }
-
- /**
- * Returns the network mask.
- *
- * @return network mask
- */
- public byte[] networkMask() {
- return networkMask;
- }
-
- /**
- * Sets the network mask.
- *
- * @param networkMask network mask
- */
- public void setNetworkMask(byte[] networkMask) {
- this.networkMask = networkMask;
- }
-
- /**
- * Returns the interface mac address.
- *
- * @return interface mac address
- */
- public MacAddress getInterfaceMacAddress() {
- return interfaceMacAddress;
- }
-
- /**
- * Sets the interface mac address.
- *
- * @param interfaceMacAddress interface mac address
- */
- public void setInterfaceMacAddress(MacAddress interfaceMacAddress) {
- this.interfaceMacAddress = interfaceMacAddress;
- }
-
- /**
- * Returns intermediate system name.
- *
- * @return intermediate system name
- */
- public String intermediateSystemName() {
- return intermediateSystemName;
- }
-
- /**
- * Sets intermediate system name.
- *
- * @param intermediateSystemName intermediate system name
- */
- public void setIntermediateSystemName(String intermediateSystemName) {
- this.intermediateSystemName = intermediateSystemName;
- }
-
- /**
- * Returns system ID.
- *
- * @return system ID
- */
- public String systemId() {
- return systemId;
- }
-
- /**
- * Sets system ID.
- *
- * @param systemId system ID
- */
- public void setSystemId(String systemId) {
- this.systemId = systemId;
- }
-
- /**
- * Returns LAN ID.
- *
- * @return LAN ID
- */
- public String l1LanId() {
- return l1LanId;
- }
-
- /**
- * Sets LAN ID.
- *
- * @param l1LanId LAN ID
- */
- public void setL1LanId(String l1LanId) {
- this.l1LanId = l1LanId;
- }
-
- /**
- * Returns LAN ID.
- *
- * @return LAN ID
- */
- public String l2LanId() {
- return l2LanId;
- }
-
- /**
- * Sets LAN ID.
- *
- * @param l2LanId LAN ID
- */
- public void setL2LanId(String l2LanId) {
- this.l2LanId = l2LanId;
- }
-
- /**
- * Returns ID length.
- *
- * @return ID length
- */
- public int getIdLength() {
-
- return ((idLength == 0) ? 6 : idLength);
- }
-
- /**
- * Sets ID length.
- *
- * @param idLength ID length
- */
- public void setIdLength(int idLength) {
- this.idLength = idLength;
- }
-
- /**
- * Returns max area addresses.
- *
- * @return max area addresses
- */
- public int getMaxAreaAddresses() {
-
- return maxAreaAddresses;
- }
-
- /**
- * Sets area max addresses.
- *
- * @param maxAreaAddresses max area addresses
- */
- public void setMaxAreaAddresses(int maxAreaAddresses) {
- this.maxAreaAddresses = maxAreaAddresses;
- }
-
- /**
- * Returns reserved packet circuit type.
- *
- * @return reserved packet circuit type
- */
- public int reservedPacketCircuitType() {
- return reservedPacketCircuitType;
- }
-
- /**
- * Sets reserved packet circuit type.
- *
- * @param reservedPacketCircuitType reserved packet circuit type
- */
- public void setReservedPacketCircuitType(int reservedPacketCircuitType) {
- this.reservedPacketCircuitType = reservedPacketCircuitType;
- }
-
- /**
- * Returns point to point.
- *
- * @return point to point
- */
- public IsisNetworkType networkType() {
- return networkType;
- }
-
- /**
- * Sets point to point or broadcast.
- *
- * @param networkType point to point or broadcast
- */
- public void setNetworkType(IsisNetworkType networkType) {
- this.networkType = networkType;
- }
-
- /**
- * Returns area address.
- *
- * @return area address
- */
- public String areaAddress() {
- return areaAddress;
- }
-
- /**
- * Sets area address.
- *
- * @param areaAddress area address
- */
- public void setAreaAddress(String areaAddress) {
- this.areaAddress = areaAddress;
- }
-
- /**
- * Returns area length.
- *
- * @return area length
- */
- public int getAreaLength() {
- return areaLength;
- }
-
- /**
- * Sets area length.
- *
- * @param areaLength area length
- */
- public void setAreaLength(int areaLength) {
- this.areaLength = areaLength;
- }
-
- /**
- * Returns holding time.
- *
- * @return holding time
- */
- public int holdingTime() {
- return holdingTime;
- }
-
- /**
- * Sets holding time.
- *
- * @param holdingTime holding time
- */
- public void setHoldingTime(int holdingTime) {
- this.holdingTime = holdingTime;
- }
-
- /**
- * Returns priority.
- *
- * @return priority
- */
- public int priority() {
- return priority;
- }
-
- /**
- * Sets priority.
- *
- * @param priority priority
- */
- public void setPriority(int priority) {
- this.priority = priority;
- }
-
- /**
- * Returns hello interval.
- *
- * @return hello interval
- */
- public int helloInterval() {
- return helloInterval;
- }
-
- /**
- * Sets hello interval.
- *
- * @param helloInterval hello interval
- */
- public void setHelloInterval(int helloInterval) {
- this.helloInterval = helloInterval;
- }
-
- /**
- * Returns the interface state.
- *
- * @return interface state
- */
- public IsisInterfaceState interfaceState() {
- return interfaceState;
- }
-
- /**
- * Sets the interface state.
- *
- * @param interfaceState the interface state
- */
- public void setInterfaceState(IsisInterfaceState interfaceState) {
- this.interfaceState = interfaceState;
- }
-
- /**
- * Returns the circuit ID.
- *
- * @return circuit ID
- */
- public String circuitId() {
- return circuitId;
- }
-
- /**
- * Sets the circuit ID.
- *
- * @param circuitId circuit ID
- */
- public void setCircuitId(String circuitId) {
- this.circuitId = circuitId;
- }
-
- /**
- * Processes received ISIS message.
- * When an ISIS message received it is handed over to this method.
- * Based on the type of the ISIS message received it will be handed over
- * to corresponding message handler methods.
- *
- * @param isisMessage received ISIS message
- * @param isisLsdb ISIS LSDB instance
- * @param channel channel
- */
- public void processIsisMessage(IsisMessage isisMessage, IsisLsdb isisLsdb, Channel channel) {
- log.debug("IsisInterfaceImpl::processIsisMessage...!!!");
- this.channel = channel;
-
- if (isisMessage.sourceMac().equals(interfaceMacAddress)) {
- log.debug("Received our own message {}...!!!", isisMessage.isisPduType());
- return;
- }
-
- if (isisMessage.isisPduType() == IsisPduType.P2PHELLOPDU && networkType.equals(IsisNetworkType.BROADCAST)) {
- return;
- } else if ((isisMessage.isisPduType() == IsisPduType.L1HELLOPDU ||
- isisMessage.isisPduType() == IsisPduType.L2HELLOPDU)
- && networkType.equals(IsisNetworkType.P2P)) {
- return;
- }
-
- if (this.isisLsdb == null) {
- this.isisLsdb = isisLsdb;
- }
-
- switch (isisMessage.isisPduType()) {
- case L1HELLOPDU:
- case L2HELLOPDU:
- processL1L2HelloPduMessage(isisMessage, channel);
- break;
- case P2PHELLOPDU:
- processP2pHelloPduMessage(isisMessage, channel);
- break;
- case L1LSPDU:
- case L2LSPDU:
- processLsPduMessage(isisMessage, channel);
- break;
- case L1CSNP:
- case L2CSNP:
- processCsnPduMessage(isisMessage, channel);
- break;
- case L1PSNP:
- case L2PSNP:
- processPsnPduMessage(isisMessage, channel);
- break;
- default:
- log.debug("Unknown packet to process...!!!");
- break;
- }
- }
-
- /**
- * Validates the received message.
- *
- * @param helloPdu ISIS message instance
- * @return true if valid ISIS message else false
- */
- public boolean validateHelloMessage(HelloPdu helloPdu) {
- boolean isValid = false;
-
- if ((helloPdu.circuitType() == IsisRouterType.L1.value() &&
- reservedPacketCircuitType == IsisRouterType.L2.value()) ||
- (helloPdu.circuitType() == IsisRouterType.L2.value() &&
- reservedPacketCircuitType == IsisRouterType.L1.value())) {
- return false;
- }
-
- //Local InterfaceAddress TLV and compare with the IP Interface address and check if they are in same subnet
- List<Ip4Address> interfaceIpAddresses = helloPdu.interfaceIpAddresses();
- Ip4Address neighborIp = (helloPdu.interfaceIpAddresses() != null) ?
- interfaceIpAddresses.get(0) : Ip4Address.valueOf("0.0.0.0");
- if (!IsisUtil.sameNetwork(interfaceIpAddress, neighborIp, networkMask)) {
- return false;
- }
-
- //Verify if it's in same area, Areas which the router belongs to
- if (helloPdu.circuitType() == IsisRouterType.L1.value()) {
- List<String> areas = helloPdu.areaAddress();
- for (String area : areas) {
- if (areaAddress.equals(area)) {
- isValid = true;
- }
- }
- } else if (helloPdu.circuitType() == IsisRouterType.L2.value() ||
- helloPdu.circuitType() == IsisRouterType.L1L2.value()) {
- isValid = true;
- }
-
- return isValid;
- }
-
- /**
- * Checks neighbor presents in the list or not.
- *
- * @param neighborMac neighbor MAc address
- * @return true if neighbor exist else false
- */
-
- private boolean isNeighborInList(MacAddress neighborMac) {
- return neighborList.containsKey(neighborMac);
- }
-
- /**
- * Adds neighbor in the list.
- *
- * @param neighbor neighbor MAC address
- * @return true if neighbor exist else false
- */
- private void addNeighbouringRouter(IsisNeighbor neighbor) {
- neighborList.put(neighbor.neighborMacAddress(), neighbor);
- }
-
- /**
- * Returns neighbor presents in the list.
- *
- * @param neighborMac neighbor MAc address
- * @return neighbor instance
- */
- private IsisNeighbor neighbouringRouter(MacAddress neighborMac) {
- return neighborList.get(neighborMac);
- }
-
- /**
- * Processes the L1 or L2 hello message.
- *
- * @param isisMessage hello message instance
- * @param channel channel instance
- */
- public void processL1L2HelloPduMessage(IsisMessage isisMessage, Channel channel) {
- log.debug("Enters processL1L2HelloPduMessage ...!!!");
- log.debug("IsisInterfaceImpl::processHelloMessage...!!!");
-
- L1L2HelloPdu helloPacket = (L1L2HelloPdu) isisMessage;
- log.debug("IsisInterfaceImpl::processHelloMessage::Interface Type {} ISISInterfaceState {} ",
- networkType, interfaceState);
-
- //If validate the area, network and max address
- if (!validateHelloMessage(helloPacket)) {
- return;
- }
-
- //Get the neighbor
- IsisNeighbor neighbor = neighbouringRouter(isisMessage.sourceMac());
- //Neighbor is not in list
- if (!isNeighborInList(isisMessage.sourceMac())) {
- neighbor = new DefaultIsisNeighbor(helloPacket, this);
- addNeighbouringRouter(neighbor);
- }
-
- neighbor.setHoldingTime(helloPacket.holdingTime());
- neighbor.stopInactivityTimeCheck();
- neighbor.startInactivityTimeCheck();
-
- //Assign the DIS
- String lanId = helloPacket.lanId();
-
- if (IsisPduType.L1HELLOPDU == helloPacket.isisPduType()) {
- buildUpdateAndSendSelfGeneratedLspIfDisChange(l1LanId, lanId, channel,
- IsisRouterType.get(helloPacket.circuitType()));
- l1LanId = lanId;
- neighbor.setL1LanId(lanId);
- //if a change in lanid
- } else if (IsisPduType.L2HELLOPDU == helloPacket.isisPduType()) {
- buildUpdateAndSendSelfGeneratedLspIfDisChange(l2LanId, lanId, channel,
- IsisRouterType.get(helloPacket.circuitType()));
- l2LanId = lanId;
- neighbor.setL2LanId(lanId);
- }
-
- //Check in neighbors list our MAC address present
- List<MacAddress> neighbors = helloPacket.neighborList();
- if (neighbors != null) {
- for (MacAddress macAddress : neighbors) {
- if (interfaceMacAddress.equals(macAddress)) {
- neighbor.setNeighborState(IsisInterfaceState.UP);
- //Build Self LSP add in LSDB and sent it.
- buildStoreAndSendSelfGeneratedLspIfNotExistInDb(channel,
- IsisRouterType.get(helloPacket.circuitType()));
- break;
- }
- }
- }
- }
-
- /**
- * Builds and store and send self generated LSP.
- *
- * @param channel netty channel instance
- */
- private void buildStoreAndSendSelfGeneratedLspIfNotExistInDb(Channel channel, IsisRouterType neighborRouterType) {
- this.channel = channel;
- //Check our LSP is present in DB. else create a self LSP and store it and sent it
- String lspKey = isisLsdb.lspKey(systemId);
- LspWrapper wrapper = null;
- if (reservedPacketCircuitType == IsisRouterType.L1.value()) {
- wrapper = isisLsdb.findLsp(IsisPduType.L1LSPDU, lspKey);
- if (wrapper == null) {
- LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L1LSPDU, allConfiguredInterfaceIps);
- isisLsdb.addLsp(lsp, true, this);
- sendLsp(lsp, channel);
- }
- } else if (reservedPacketCircuitType == IsisRouterType.L2.value()) {
- wrapper = isisLsdb.findLsp(IsisPduType.L2LSPDU, lspKey);
- if (wrapper == null) {
- LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L2LSPDU, allConfiguredInterfaceIps);
- isisLsdb.addLsp(lsp, true, this);
- sendLsp(lsp, channel);
- }
- } else if (reservedPacketCircuitType == IsisRouterType.L1L2.value()) {
- if ((neighborRouterType == IsisRouterType.L1 || neighborRouterType == IsisRouterType.L1L2)) {
-
- wrapper = isisLsdb.findLsp(IsisPduType.L1LSPDU, lspKey);
- if (wrapper == null) {
- LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L1LSPDU,
- allConfiguredInterfaceIps);
- isisLsdb.addLsp(lsp, true, this);
- sendLsp(lsp, channel);
- }
- }
-
- if ((neighborRouterType == IsisRouterType.L2 || neighborRouterType == IsisRouterType.L1L2)) {
- wrapper = isisLsdb.findLsp(IsisPduType.L2LSPDU, lspKey);
- if (wrapper == null) {
- LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L2LSPDU,
- allConfiguredInterfaceIps);
- isisLsdb.addLsp(lsp, true, this);
- sendLsp(lsp, channel);
- }
- }
- }
- }
-
- /**
- * Builds and update in DB and send self generated LSP.
- *
- * @param previousLanId previous DIS ID
- * @param latestLanId latest DIS ID
- * @param channel netty channel instance
- */
- private void buildUpdateAndSendSelfGeneratedLspIfDisChange(String previousLanId,
- String latestLanId, Channel channel,
- IsisRouterType neighborRouterType) {
- this.channel = channel;
- //If DIS change then build and sent LSP
- if (!previousLanId.equals(latestLanId)) {
- //Create a self LSP and Update it in DB and sent it
- String lspKey = isisLsdb.lspKey(systemId);
- if (reservedPacketCircuitType == IsisRouterType.L1.value()) {
- LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L1LSPDU, allConfiguredInterfaceIps);
- isisLsdb.addLsp(lsp, true, this);
- sendLsp(lsp, channel);
- } else if (reservedPacketCircuitType == IsisRouterType.L2.value() &&
- (neighborRouterType == IsisRouterType.L2 || neighborRouterType == IsisRouterType.L1L2)) {
- LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L2LSPDU, allConfiguredInterfaceIps);
- isisLsdb.addLsp(lsp, true, this);
- sendLsp(lsp, channel);
- } else if (reservedPacketCircuitType == IsisRouterType.L1L2.value()) {
- //L1 LSPDU
- if (neighborRouterType == IsisRouterType.L1 || neighborRouterType == IsisRouterType.L1L2) {
- LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L1LSPDU, allConfiguredInterfaceIps);
- isisLsdb.addLsp(lsp, true, this);
- sendLsp(lsp, channel);
- }
- //L1 LSPDU
- if (neighborRouterType == IsisRouterType.L2 || neighborRouterType == IsisRouterType.L1L2) {
- LsPdu lsp = new LspGenerator().getLsp(this, lspKey, IsisPduType.L2LSPDU, allConfiguredInterfaceIps);
- isisLsdb.addLsp(lsp, true, this);
- sendLsp(lsp, channel);
- }
- }
- }
-
- }
-
- /**
- * Sends LS PDU message to channel.
- *
- * @param lsp LS PDU message instance
- * @param channel channel instance
- */
- private void sendLsp(LsPdu lsp, Channel channel) {
- byte[] lspBytes = lsp.asBytes();
- lspBytes = IsisUtil.addLengthAndMarkItInReserved(lspBytes, IsisConstants.LENGTHPOSITION,
- IsisConstants.LENGTHPOSITION + 1,
- IsisConstants.RESERVEDPOSITION);
- lspBytes = IsisUtil.addChecksum(lspBytes, IsisConstants.CHECKSUMPOSITION,
- IsisConstants.CHECKSUMPOSITION + 1);
- //write to the channel
- if (channel != null && channel.isConnected() && channel.isOpen()) {
- channel.write(IsisUtil.framePacket(lspBytes, interfaceIndex));
- }
- }
-
- /**
- * Processes P2P hello message.
- *
- * @param isisMessage hello message instance
- * @param channel channel instance
- */
- public void processP2pHelloPduMessage(IsisMessage isisMessage, Channel channel) {
- log.debug("Enters processP2pHelloPduMessage ...!!!");
- P2PHelloPdu helloPacket = (P2PHelloPdu) isisMessage;
-
- log.debug("IsisInterfaceImpl::processHelloMessage::Interface Type {} OSPFInterfaceState {} ",
- networkType, interfaceState);
-
- //validate the area, network and max address
- if (!validateHelloMessage(helloPacket)) {
- return;
- }
-
- IsisNeighbor neighbor = null;
- List<IsisTlv> tlvs = ((P2PHelloPdu) isisMessage).tlvs();
- AdjacencyStateTlv stateTlv = null;
- for (IsisTlv tlv : tlvs) {
- if (tlv instanceof AdjacencyStateTlv) {
- stateTlv = (AdjacencyStateTlv) tlv;
- break;
- }
- }
-
- if (stateTlv == null) {
- neighbor = neighbouringRouter(isisMessage.sourceMac());
- if (neighbor == null) {
- neighbor = new DefaultIsisNeighbor(helloPacket, this);
- addNeighbouringRouter(neighbor);
- }
- neighbor.setNeighborState(IsisInterfaceState.DOWN);
- buildStoreAndSendSelfGeneratedLspIfNotExistInDb(channel, IsisRouterType.get(helloPacket.circuitType()));
- } else if (stateTlv.adjacencyType() == IsisInterfaceState.DOWN.value()) {
- neighbor = neighbouringRouter(isisMessage.sourceMac());
- if (neighbor == null) {
- neighbor = new DefaultIsisNeighbor(helloPacket, this);
- addNeighbouringRouter(neighbor);
- }
- neighbor.setLocalExtendedCircuitId(stateTlv.localCircuitId());
- } else if (stateTlv.adjacencyType() == IsisInterfaceState.INITIAL.value()) {
- //Neighbor already present in the list
- neighbor = neighbouringRouter(isisMessage.sourceMac());
- if (neighbor == null) {
- neighbor = new DefaultIsisNeighbor(helloPacket, this);
- addNeighbouringRouter(neighbor);
- }
- neighbor.setNeighborState(IsisInterfaceState.INITIAL);
- neighbor.setLocalExtendedCircuitId(stateTlv.localCircuitId());
- //interfaceState = IsisInterfaceState.UP;
- } else if (stateTlv.adjacencyType() == IsisInterfaceState.UP.value()) {
- //Build Self LSP add in LSDB and sent it.
- neighbor = neighbouringRouter(isisMessage.sourceMac());
- neighbor.setNeighborState(IsisInterfaceState.UP);
- neighbor.setLocalExtendedCircuitId(stateTlv.localCircuitId());
- buildStoreAndSendSelfGeneratedLspIfNotExistInDb(channel, IsisRouterType.get(helloPacket.circuitType()));
- }
- if (neighbor == null) {
- log.debug("neighbor object is null!!!!");
- return;
- }
-
- neighbor.setHoldingTime(helloPacket.holdingTime());
- neighbor.stopInactivityTimeCheck();
- neighbor.startInactivityTimeCheck();
- }
-
- /**
- * Processes LS PDU message.
- *
- * @param isisMessage LS pdu message instance
- * @param channel channel instance
- */
- public void processLsPduMessage(IsisMessage isisMessage, Channel channel) {
- log.debug("Enters processLsPduMessage ...!!!");
- IsisNeighbor neighbor = neighbouringRouter(isisMessage.sourceMac());
- if (networkType == IsisNetworkType.BROADCAST && neighbor == null) {
- return;
- }
-
- LsPdu lsPdu = (LsPdu) isisMessage;
- LspWrapper wrapper = isisLsdb.findLsp(lsPdu.isisPduType(), lsPdu.lspId());
- if (wrapper == null || isisLsdb.isNewerOrSameLsp(lsPdu, wrapper.lsPdu()).equalsIgnoreCase("latest")) {
- if (wrapper != null) { // verify if the LSA - is your own LSA - get system ID and compare LSP
- String lspKey = isisLsdb.lspKey(systemId);
- if (lsPdu.lspId().equals(lspKey)) {
- lsPdu.setSequenceNumber(lsPdu.sequenceNumber() + 1);
- if (lsPdu.pduType() == IsisPduType.L1LSPDU.value()) {
- // setting the ls sequence number
- isisLsdb.setL1LspSeqNo(lsPdu.sequenceNumber());
- } else if (lsPdu.pduType() == IsisPduType.L2LSPDU.value()) {
- // setting the ls sequence number
- isisLsdb.setL2LspSeqNo(lsPdu.sequenceNumber());
- }
- isisLsdb.addLsp(lsPdu, true, this);
- sendLsp(lsPdu, channel);
- } else {
- isisLsdb.addLsp(lsPdu, false, this);
- }
-
-
- } else {
- //not exist in the database or latest, then add it in database
- isisLsdb.addLsp(lsPdu, false, this);
- }
- }
-
- //If network type is P2P, acknowledge with a PSNP
- if (networkType() == IsisNetworkType.P2P) {
- IsisPduType psnpType = null;
- if (IsisPduType.get(lsPdu.pduType()) == IsisPduType.L1LSPDU) {
- psnpType = IsisPduType.L1PSNP;
- } else if (IsisPduType.get(lsPdu.pduType()) == IsisPduType.L2LSPDU) {
- psnpType = IsisPduType.L2PSNP;
- }
- IsisHeader isisHeader = new LspGenerator().getHeader(psnpType);
- Psnp psnp = new Psnp(isisHeader);
- psnp.setSourceId(lspKeyP2P(this.systemId));
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.LSPENTRY.value());
- tlvHeader.setTlvLength(0);
- LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader);
- LspEntry lspEntry = new LspEntry();
- lspEntry.setLspChecksum(lsPdu.checkSum());
- lspEntry.setLspId(lsPdu.lspId());
- lspEntry.setLspSequenceNumber(lsPdu.sequenceNumber());
- lspEntry.setRemainingTime(lsPdu.remainingLifeTime());
- lspEntriesTlv.addLspEntry(lspEntry);
- psnp.addTlv(lspEntriesTlv);
-
- //write it to channel buffer.
- byte[] psnpBytes = psnp.asBytes();
- psnpBytes = IsisUtil.addLengthAndMarkItInReserved(psnpBytes, IsisConstants.LENGTHPOSITION,
- IsisConstants.LENGTHPOSITION + 1,
- IsisConstants.RESERVEDPOSITION);
- flagValue = false;
- //write to the channel
- if (channel != null && channel.isConnected() && channel.isOpen()) {
- channel.write(IsisUtil.framePacket(psnpBytes, interfaceIndex));
- }
- }
- }
-
- /**
- * Processes PSN PDU message.
- * Checks for self originated LSP entries in PSNP message and sends the missing LSP.
- *
- * @param isisMessage PSN PDU message instance
- * @param channel channel instance
- */
- public void processPsnPduMessage(IsisMessage isisMessage, Channel channel) {
- log.debug("Enters processPsnPduMessage ...!!!");
- //If adjacency not formed don't process.
- IsisNeighbor neighbor = neighbouringRouter(isisMessage.sourceMac());
- if (networkType == IsisNetworkType.BROADCAST && neighbor == null) {
- return;
- }
-
- Psnp psnPacket = (Psnp) isisMessage;
- List<IsisTlv> isisTlvs = psnPacket.getAllTlv();
- Iterator iterator = isisTlvs.iterator();
- while (iterator.hasNext()) {
- IsisTlv isisTlv = (IsisTlv) iterator.next();
- if (isisTlv instanceof LspEntriesTlv) {
- LspEntriesTlv lspEntriesTlv = (LspEntriesTlv) isisTlv;
- List<LspEntry> lspEntryList = lspEntriesTlv.lspEntry();
- Iterator lspEntryListIterator = lspEntryList.iterator();
- while (lspEntryListIterator.hasNext()) {
- LspEntry lspEntry = (LspEntry) lspEntryListIterator.next();
- String lspKey = lspEntry.lspId();
- LspWrapper lspWrapper = isisLsdb.findLsp(psnPacket.isisPduType(), lspKey);
- if (lspWrapper != null) {
- if (lspWrapper.isSelfOriginated()) {
- //Sent the LSP
- sendLsp((LsPdu) lspWrapper.lsPdu(), channel);
- }
- }
- }
- }
- }
- }
-
- /**
- * Processes CSN PDU message.
- *
- * @param isisMessage CSN PDU message instance
- * @param channel channel instance
- */
- public void processCsnPduMessage(IsisMessage isisMessage, Channel channel) {
- log.debug("Enters processCsnPduMessage ...!!!");
- IsisNeighbor neighbor = neighbouringRouter(isisMessage.sourceMac());
- if (networkType == IsisNetworkType.BROADCAST && neighbor == null) {
- return;
- }
-
- Csnp csnPacket = (Csnp) isisMessage;
- IsisPduType psnPduType = (IsisPduType.L2CSNP.equals(csnPacket.isisPduType())) ?
- IsisPduType.L2PSNP : IsisPduType.L1PSNP;
- IsisPduType lsPduType = (IsisPduType.L2CSNP.equals(csnPacket.isisPduType())) ?
- IsisPduType.L2LSPDU : IsisPduType.L1LSPDU;
-
- List<LspEntry> lspEntryRequestList = new ArrayList<>();
- boolean selfOriginatedFound = false;
- List<IsisTlv> isisTlvs = csnPacket.getAllTlv();
- Iterator iterator = isisTlvs.iterator();
- while (iterator.hasNext()) {
- IsisTlv isisTlv = (IsisTlv) iterator.next();
- if (isisTlv instanceof LspEntriesTlv) {
- LspEntriesTlv lspEntriesTlv = (LspEntriesTlv) isisTlv;
- List<LspEntry> lspEntryList = lspEntriesTlv.lspEntry();
- Iterator lspEntryListIterator = lspEntryList.iterator();
- while (lspEntryListIterator.hasNext()) {
- LspEntry lspEntry = (LspEntry) lspEntryListIterator.next();
- String lspKey = lspEntry.lspId();
- LspWrapper lspWrapper = isisLsdb.findLsp(lsPduType, lspKey);
- if (lspWrapper != null) {
- LsPdu lsPdu = (LsPdu) lspWrapper.lsPdu();
- if (lspWrapper.isSelfOriginated()) {
- selfOriginatedFound = true;
- if (lspEntry.lspSequenceNumber() < lsPdu.sequenceNumber()) {
- sendLsp(lsPdu, channel);
- }
- } else {
- if (lsPdu.sequenceNumber() < lspEntry.lspSequenceNumber()) {
- lspEntryRequestList.add(lspEntry);
- flagValue = true;
- }
- }
- } else {
- lspEntryRequestList.add(lspEntry);
- flagValue = true;
- }
- }
- }
- }
- if (flagValue) {
- sendPsnPduMessage(lspEntryRequestList, psnPduType, channel);
- lspEntryRequestList.clear();
- }
-
- if (!selfOriginatedFound) {
- String lspKey = isisLsdb.lspKey(systemId);
- LspWrapper wrapper = isisLsdb.findLsp(lsPduType, lspKey);
- if (wrapper != null) {
- sendLsp((LsPdu) wrapper.lsPdu(), channel);
- }
- }
- }
-
- /**
- * Sends the partial sequence number PDU.
- *
- * @param lspEntryRequestList list of lsp entry request
- * @param isisPduType intermediate system PDU type
- * @param channel netty channel instance
- */
- private void sendPsnPduMessage(List<LspEntry> lspEntryRequestList, IsisPduType isisPduType, Channel channel) {
- IsisHeader isisHeader = new LspGenerator().getHeader(isisPduType);
- Psnp psnp = new Psnp(isisHeader);
- psnp.setSourceId(lspKeyP2P(this.systemId));
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.LSPENTRY.value());
- tlvHeader.setTlvLength(0);
- LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader);
- for (LspEntry lspEntry : lspEntryRequestList) {
- lspEntry.setLspChecksum(0);
- lspEntry.setLspSequenceNumber(0);
- lspEntry.setRemainingTime(0);
- lspEntriesTlv.addLspEntry(lspEntry);
- }
- psnp.addTlv(lspEntriesTlv);
- //write it to channel buffer.
- byte[] psnpBytes = psnp.asBytes();
- psnpBytes = IsisUtil.addLengthAndMarkItInReserved(psnpBytes, IsisConstants.LENGTHPOSITION,
- IsisConstants.LENGTHPOSITION + 1,
- IsisConstants.RESERVEDPOSITION);
- flagValue = false;
- //write to the channel
- if (channel != null && channel.isConnected() && channel.isOpen()) {
- channel.write(IsisUtil.framePacket(psnpBytes, interfaceIndex));
- }
- }
-
- /**
- * Gets the LSP key.
- *
- * @param systemId system ID
- * @return key
- */
- public String lspKeyP2P(String systemId) {
- StringBuilder lspKey = new StringBuilder();
- lspKey.append(systemId);
- lspKey.append(".00");
- return lspKey.toString();
- }
-
- /**
- * Starts the hello timer which sends hello packet every configured seconds.
- *
- * @param channel netty channel instance
- */
- public void startHelloSender(Channel channel) {
- log.debug("IsisInterfaceImpl::startHelloSender");
- if (!helloSenderStarted) {
- isisHelloPduSender = new IsisHelloPduSender(channel, this);
- exServiceHello = Executors.newSingleThreadScheduledExecutor();
- final ScheduledFuture<?> helloHandle =
- exServiceHello.scheduleAtFixedRate(isisHelloPduSender, 0,
- helloInterval, TimeUnit.SECONDS);
- helloSenderStarted = true;
- }
- }
-
- /**
- * Stops the hello timer which sends hello packet every configured seconds.
- */
- public void stopHelloSender() {
- log.debug("IsisInterfaceImpl::stopHelloSender");
- exServiceHello.shutdown();
- helloSenderStarted = false;
- }
-}
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java
deleted file mode 100644
index 4b5e938..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.MacAddress;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisInterfaceState;
-import org.onosproject.isis.controller.IsisNeighbor;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.controller.IsisRouterType;
-import org.onosproject.isis.io.isispacket.pdu.HelloPdu;
-import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
-import org.onosproject.isis.io.isispacket.pdu.P2PHelloPdu;
-import org.onosproject.isis.io.util.IsisConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Representation of an ISIS neighbor.
- * The first thing an ISIS router must do is find its neighbors and form adjacency.
- * Each neighbor that the router finds will be represented by this class.
- */
-public class DefaultIsisNeighbor implements IsisNeighbor {
- private static final Logger log = LoggerFactory.getLogger(DefaultIsisNeighbor.class);
- private String neighborAreaId;
- private String neighborSystemId;
- private Ip4Address interfaceIp;
- private MacAddress neighborMacAddress;
- private volatile int holdingTime;
- private int neighborDownInterval;
- private IsisRouterType routerType;
- private String l1LanId;
- private String l2LanId;
- private byte localCircuitId;
- private int localExtendedCircuitId;
- private IsisInterfaceState neighborState = IsisInterfaceState.INITIAL;
- private InternalInactivityTimeCheck inActivityTimeCheckTask;
- private ScheduledExecutorService exServiceInActivity;
- private InternalHoldingTimeCheck holdingTimeCheckTask;
- private ScheduledExecutorService exServiceHoldingTimeCheck;
- private boolean inActivityTimerScheduled = false;
- private IsisInterface isisInterface;
-
- /**
- * Creates an instance of ISIS neighbor.
- *
- * @param helloMessage hello message instance
- * @param isisInterface ISIS interface instance
- */
- public DefaultIsisNeighbor(HelloPdu helloMessage, IsisInterface isisInterface) {
- this.neighborMacAddress = helloMessage.sourceMac();
- List<String> areaAddresses = helloMessage.areaAddress();
- this.neighborAreaId = (areaAddresses != null) ? areaAddresses.get(0) : "";
- this.neighborSystemId = helloMessage.sourceId();
- List<Ip4Address> interfaceIpAddresses = helloMessage.interfaceIpAddresses();
- this.interfaceIp = (helloMessage.interfaceIpAddresses() != null) ?
- interfaceIpAddresses.get(0) : IsisConstants.DEFAULTIP;
- this.holdingTime = helloMessage.holdingTime();
- neighborDownInterval = holdingTime;
- this.routerType = IsisRouterType.get(helloMessage.circuitType());
- if (helloMessage instanceof L1L2HelloPdu) {
- if (IsisPduType.L1HELLOPDU == helloMessage.isisPduType()) {
- l1LanId = ((L1L2HelloPdu) helloMessage).lanId();
- } else if (IsisPduType.L2HELLOPDU == helloMessage.isisPduType()) {
- l2LanId = ((L1L2HelloPdu) helloMessage).lanId();
- }
- } else if (helloMessage instanceof P2PHelloPdu) {
- this.localCircuitId = ((P2PHelloPdu) helloMessage).localCircuitId();
- }
- this.isisInterface = isisInterface;
- startHoldingTimeCheck();
- log.debug("Neighbor added - {}", neighborMacAddress);
- }
-
- /**
- * Returns local extended circuit ID.
- *
- * @return local extended circuit ID
- */
- public int localExtendedCircuitId() {
- return localExtendedCircuitId;
- }
-
- /**
- * Sets local extended circuit ID.
- *
- * @param localExtendedCircuitId neighbor extended circuit ID
- */
- public void setLocalExtendedCircuitId(int localExtendedCircuitId) {
- this.localExtendedCircuitId = localExtendedCircuitId;
- }
-
- /**
- * Returns neighbor area ID.
- *
- * @return neighbor area ID
- */
- public String neighborAreaId() {
- return neighborAreaId;
- }
-
- /**
- * Sets neighbor area ID.
- *
- * @param neighborAreaId neighbor area ID
- */
- public void setNeighborAreaId(String neighborAreaId) {
- this.neighborAreaId = neighborAreaId;
- }
-
- /**
- * Returns neighbor system ID.
- *
- * @return neighbor system ID
- */
- public String neighborSystemId() {
- return neighborSystemId;
- }
-
- /**
- * Sets neighbor system ID.
- *
- * @param neighborSystemId neighbor system ID
- */
- public void setNeighborSystemId(String neighborSystemId) {
- this.neighborSystemId = neighborSystemId;
- }
-
- /**
- * Returns interface IP.
- *
- * @return interface IP
- */
- public Ip4Address interfaceIp() {
- return interfaceIp;
- }
-
- /**
- * Sets interface IP.
- *
- * @param interfaceIp IP
- */
- public void setInterfaceIp(Ip4Address interfaceIp) {
- this.interfaceIp = interfaceIp;
- }
-
- /**
- * Returns neighbor mac address.
- *
- * @return neighborMacAddress neighbor mac address
- */
- public MacAddress neighborMacAddress() {
- return neighborMacAddress;
- }
-
- /**
- * Sets neighbor mac address.
- *
- * @param neighborMacAddress mac address
- */
- public void setNeighborMacAddress(MacAddress neighborMacAddress) {
- this.neighborMacAddress = neighborMacAddress;
- }
-
- /**
- * Returns holding time.
- *
- * @return holding time
- */
- public int holdingTime() {
- return holdingTime;
- }
-
- /**
- * Sets holding time.
- *
- * @param holdingTime holding time
- */
- public void setHoldingTime(int holdingTime) {
- this.holdingTime = holdingTime;
- }
-
- /**
- * Returns router type.
- *
- * @return router type
- */
- public IsisRouterType routerType() {
- return routerType;
- }
-
- /**
- * Sets router type.
- *
- * @param routerType router type
- */
- public void setRouterType(IsisRouterType routerType) {
- this.routerType = routerType;
- }
-
- /**
- * Returns L1 lan ID.
- *
- * @return L1 lan ID
- */
- public String l1LanId() {
- return l1LanId;
- }
-
- /**
- * Sets L1 lan ID.
- *
- * @param l1LanId L1 lan ID
- */
- public void setL1LanId(String l1LanId) {
- this.l1LanId = l1LanId;
- }
-
- /**
- * Returns L2 lan ID.
- *
- * @return L2 lan ID
- */
- public String l2LanId() {
- return l2LanId;
- }
-
- /**
- * Sets L2 lan ID.
- *
- * @param l2LanId L2 lan ID
- */
- public void setL2LanId(String l2LanId) {
- this.l2LanId = l2LanId;
- }
-
- /**
- * Gets the neighbor interface state.
- *
- * @return neighbor interface state
- */
- public IsisInterfaceState interfaceState() {
- return neighborState;
- }
-
- /**
- * Sets the neighbor interface state.
- *
- * @param neighborState the neighbor interface state
- */
- public void setNeighborState(IsisInterfaceState neighborState) {
- this.neighborState = neighborState;
- }
-
- /**
- * Returns local circuit ID.
- *
- * @return local circuit ID
- */
- public byte localCircuitId() {
- return localCircuitId;
- }
-
- /**
- * Sets local circuit ID.
- *
- * @param localCircuitId local circuit ID
- */
- public void setLocalCircuitId(byte localCircuitId) {
- this.localCircuitId = localCircuitId;
- }
-
- /**
- * Returns neighbor state.
- *
- * @return neighbor state
- */
- public IsisInterfaceState neighborState() {
- return neighborState;
- }
-
- /**
- * Starts the holding time check timer.
- */
- public void startHoldingTimeCheck() {
- log.debug("IsisNeighbor::startHoldingTimeCheck");
- holdingTimeCheckTask = new InternalHoldingTimeCheck();
- exServiceHoldingTimeCheck = Executors.newSingleThreadScheduledExecutor();
- exServiceHoldingTimeCheck.scheduleAtFixedRate(holdingTimeCheckTask, 1,
- 1, TimeUnit.SECONDS);
- }
-
- /**
- * Stops the holding time check timer.
- */
- public void stopHoldingTimeCheck() {
- log.debug("IsisNeighbor::stopHoldingTimeCheck ");
- exServiceHoldingTimeCheck.shutdown();
- }
-
- /**
- * Starts the inactivity timer.
- */
- public void startInactivityTimeCheck() {
- if (!inActivityTimerScheduled) {
- log.debug("IsisNeighbor::startInactivityTimeCheck");
- inActivityTimeCheckTask = new InternalInactivityTimeCheck();
- exServiceInActivity = Executors.newSingleThreadScheduledExecutor();
- exServiceInActivity.scheduleAtFixedRate(inActivityTimeCheckTask, neighborDownInterval,
- neighborDownInterval, TimeUnit.SECONDS);
- inActivityTimerScheduled = true;
- }
- }
-
- /**
- * Stops the inactivity timer.
- */
- public void stopInactivityTimeCheck() {
- if (inActivityTimerScheduled) {
- log.debug("IsisNeighbor::stopInactivityTimeCheck ");
- exServiceInActivity.shutdown();
- inActivityTimerScheduled = false;
- }
- }
-
- /**
- * Called when neighbor is down.
- */
- public void neighborDown() {
- log.debug("Neighbor Down {} and NeighborSystemId {}", neighborMacAddress,
- neighborSystemId);
- stopInactivityTimeCheck();
- isisInterface.setL1LanId(IsisConstants.DEFAULTLANID);
- isisInterface.setL2LanId(IsisConstants.DEFAULTLANID);
-
- neighborState = IsisInterfaceState.DOWN;
- stopInactivityTimeCheck();
- stopHoldingTimeCheck();
- isisInterface.removeNeighbor(this);
-
- isisInterface.isisLsdb().removeTopology(this, isisInterface);
- }
-
- /**
- * Represents a Task which will do an inactivity time check.
- */
- private class InternalInactivityTimeCheck implements Runnable {
- /**
- * Creates an instance.
- */
- InternalInactivityTimeCheck() {
- }
-
- @Override
- public void run() {
- log.debug("Neighbor Not Heard till the past router dead interval .");
- neighborDown();
- }
- }
-
- /**
- * Represents a Task which will decrement holding time for this neighbor.
- */
- private class InternalHoldingTimeCheck implements Runnable {
- /**
- * Creates an instance.
- */
- InternalHoldingTimeCheck() {
- }
-
- @Override
- public void run() {
- holdingTime--;
- if (holdingTime <= 0) {
- log.debug("Calling neighbor down. Holding time is 0.");
- neighborDown();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisProcess.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisProcess.java
deleted file mode 100644
index ebe43ca..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisProcess.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisProcess;
-
-import java.util.List;
-
-/**
- * Represents of an ISIS process.
- */
-public class DefaultIsisProcess implements IsisProcess {
- private String processId;
- private List<IsisInterface> isisInterfaceList;
-
- /**
- * Gets process ID.
- *
- * @return process ID
- */
- public String processId() {
- return processId;
- }
-
- /**
- * Sets process ID.
- *
- * @param processId process ID
- */
- public void setProcessId(String processId) {
- this.processId = processId;
- }
-
- /**
- * Gets list of ISIS interface details.
- *
- * @return list of ISIS interface details
- */
- public List<IsisInterface> isisInterfaceList() {
- return isisInterfaceList;
- }
-
- /**
- * Sets list of ISIS interface details.
- *
- * @param isisInterfaceList list of ISIS interface details
- */
- public void setIsisInterfaceList(List<IsisInterface> isisInterfaceList) {
- this.isisInterfaceList = isisInterfaceList;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisChannelHandler.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisChannelHandler.java
deleted file mode 100644
index 937935b..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisChannelHandler.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelStateEvent;
-import org.jboss.netty.channel.ExceptionEvent;
-import org.jboss.netty.channel.MessageEvent;
-import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler;
-import org.jboss.netty.handler.timeout.ReadTimeoutException;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisLsdb;
-import org.onosproject.isis.controller.IsisMessage;
-import org.onosproject.isis.controller.IsisProcess;
-import org.onosproject.isis.controller.impl.lsdb.DefaultIsisLsdb;
-import org.onosproject.isis.exceptions.IsisParseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.nio.channels.ClosedChannelException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.ScheduledExecutorService;
-
-/**
- * Channel handler deals with the ISIS channel connection.
- * Also it dispatches messages to the appropriate handlers for processing.
- */
-public class IsisChannelHandler extends IdleStateAwareChannelHandler {
-
- private static final Logger log = LoggerFactory.getLogger(IsisChannelHandler.class);
- private static Map<Integer, Object> isisDb = null;
- private Channel channel = null;
- private Controller controller;
- private List<IsisProcess> processes = null;
- private List<ScheduledExecutorService> executorList = new ArrayList<>();
- private byte[] configPacket = null;
- private Map<Integer, IsisInterface> isisInterfaceMap = new ConcurrentHashMap<>();
- private IsisLsdb isisLsdb = new DefaultIsisLsdb();
- private List<Ip4Address> interfaceIps = new ArrayList<>();
-
- /**
- * Creates an instance of ISIS channel handler.
- *
- * @param controller controller instance
- * @param processes list of configured processes
- */
- public IsisChannelHandler(Controller controller, List<IsisProcess> processes) {
- this.controller = controller;
- this.processes = processes;
- ((DefaultIsisLsdb) isisLsdb).setController(this.controller);
- ((DefaultIsisLsdb) isisLsdb).setIsisInterface(isisInterfaceList());
- }
-
- private List<IsisInterface> isisInterfaceList() {
- List<IsisInterface> isisInterfaceList = new ArrayList<>();
- for (Integer key : isisInterfaceMap.keySet()) {
- isisInterfaceList.add(isisInterfaceMap.get(key));
- }
- return isisInterfaceList;
- }
-
- /**
- * Initializes the interface map with interface details.
- */
- public void initializeInterfaceMap() {
- for (IsisProcess process : processes) {
- for (IsisInterface isisInterface : process.isisInterfaceList()) {
- IsisInterface anInterface = isisInterfaceMap.get(isisInterface.interfaceIndex());
- if (anInterface == null) {
- isisInterfaceMap.put(isisInterface.interfaceIndex(), isisInterface);
- interfaceIps.add(isisInterface.interfaceIpAddress());
- }
- }
- }
- //Initializes the interface with all interface ip details - for ls pdu generation
- initializeInterfaceIpList();
- }
-
- /**
- * Updates the interface map with interface details.
- *
- * @param isisProcesses updated process instances
- */
- public void updateInterfaceMap(List<IsisProcess> isisProcesses) {
- for (IsisProcess isisUpdatedProcess : isisProcesses) {
- for (IsisInterface isisUpdatedInterface : isisUpdatedProcess.isisInterfaceList()) {
- IsisInterface isisInterface = isisInterfaceMap.get(isisUpdatedInterface.interfaceIndex());
- if (isisInterface == null) {
- isisInterfaceMap.put(isisUpdatedInterface.interfaceIndex(), isisUpdatedInterface);
- interfaceIps.add(isisUpdatedInterface.interfaceIpAddress());
- } else {
- if (!isisInterface.intermediateSystemName().equals(isisUpdatedInterface.intermediateSystemName())) {
- isisInterface.setIntermediateSystemName(isisUpdatedInterface.intermediateSystemName());
- }
- if (isisInterface.reservedPacketCircuitType() != isisUpdatedInterface.reservedPacketCircuitType()) {
- isisInterface.setReservedPacketCircuitType(isisUpdatedInterface.reservedPacketCircuitType());
- isisInterface.removeNeighbors();
- }
- if (!isisInterface.circuitId().equals(isisUpdatedInterface.circuitId())) {
- isisInterface.setCircuitId(isisUpdatedInterface.circuitId());
- }
- if (isisInterface.networkType() != isisUpdatedInterface.networkType()) {
- isisInterface.setNetworkType(isisUpdatedInterface.networkType());
- isisInterface.removeNeighbors();
- }
- if (!isisInterface.areaAddress().equals(isisUpdatedInterface.areaAddress())) {
- isisInterface.setAreaAddress(isisUpdatedInterface.areaAddress());
- }
- if (isisInterface.holdingTime() != isisUpdatedInterface.holdingTime()) {
- isisInterface.setHoldingTime(isisUpdatedInterface.holdingTime());
- }
- if (isisInterface.helloInterval() != isisUpdatedInterface.helloInterval()) {
- isisInterface.setHelloInterval(isisUpdatedInterface.helloInterval());
- isisInterface.stopHelloSender();
- isisInterface.startHelloSender(channel);
- }
-
- isisInterfaceMap.put(isisInterface.interfaceIndex(), isisInterface);
- }
- }
- }
- }
-
- /**
- * Initializes the interface with all interface ip details.
- */
- public void initializeInterfaceIpList() {
- for (IsisProcess process : processes) {
- for (IsisInterface isisInterface : process.isisInterfaceList()) {
- ((DefaultIsisInterface) isisInterface).setAllConfiguredInterfaceIps(interfaceIps);
- }
- }
- }
-
- /**
- * Initialize channel, start hello sender and initialize LSDB.
- */
- private void initialize() {
- log.debug("IsisChannelHandler initialize..!!!");
- if (configPacket != null) {
- log.debug("IsisChannelHandler initialize -> sentConfig packet of length ::"
- + configPacket.length);
- sentConfigPacket(configPacket);
- }
- initializeInterfaceMap();
- //start the hello timer
- startHelloSender();
- //Initialize Database
- isisLsdb.initializeDb();
- }
-
- @Override
- public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent evt) throws Exception {
- log.info("ISIS channelConnected from {}", evt.getChannel().getRemoteAddress());
- this.channel = evt.getChannel();
- initialize();
- }
-
- @Override
- public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent evt) {
- log.debug("IsisChannelHandler::channelDisconnected...!!!");
- if (controller != null) {
- controller.connectPeer();
- stopHelloSender();
- }
- }
-
- @Override
- public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
- if (e.getCause() instanceof ReadTimeoutException) {
- log.debug("Disconnecting device {} due to read timeout", e.getChannel().getRemoteAddress());
- return;
- } else if (e.getCause() instanceof ClosedChannelException) {
- log.debug("Channel for ISIS {} already closed", e.getChannel().getRemoteAddress());
- } else if (e.getCause() instanceof IOException) {
- log.debug("Disconnecting ISIS {} due to IO Error: {}", e.getChannel().getRemoteAddress(),
- e.getCause().getMessage());
- } else if (e.getCause() instanceof IsisParseException) {
- IsisParseException errMsg = (IsisParseException) e.getCause();
- byte errorCode = errMsg.errorCode();
- byte errorSubCode = errMsg.errorSubCode();
- log.debug("Error while parsing message from ISIS {}, ErrorCode {}",
- e.getChannel().getRemoteAddress(), errorCode);
- } else if (e.getCause() instanceof RejectedExecutionException) {
- log.debug("Could not process message: queue full");
- } else {
- log.debug("Error while processing message from ISIS {}, {}",
- e.getChannel().getRemoteAddress(), e.getCause().getMessage());
- }
- }
-
- @Override
- public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
- log.debug("IsisChannelHandler::messageReceived...!!!");
- Object message = e.getMessage();
- if (message instanceof List) {
- List<IsisMessage> isisMessageList = (List<IsisMessage>) message;
- log.debug("IsisChannelHandler::List of IsisMessages Size {}", isisMessageList.size());
-
- for (IsisMessage isisMessage : isisMessageList) {
- processIsisMessage(isisMessage, ctx);
- }
- }
- if (message instanceof IsisMessage) {
- IsisMessage isisMessage = (IsisMessage) message;
- log.debug("IsisChannelHandler::IsisMessages received...!!");
- processIsisMessage(isisMessage, ctx);
- }
- }
-
- /**
- * When an ISIS message received it is handed over to this method.
- * Based on the type of the ISIS message received it will be handed over
- * to corresponding message handler methods.
- *
- * @param isisMessage received ISIS message
- * @param ctx channel handler context instance.
- */
- public void processIsisMessage(IsisMessage isisMessage, ChannelHandlerContext ctx) {
- log.debug("IsisChannelHandler::processIsisMessage...!!!");
- int interfaceIndex = isisMessage.interfaceIndex();
- IsisInterface isisInterface = isisInterfaceMap.get(interfaceIndex);
- isisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
- }
-
- /**
- * Starts the hello timer which sends hello packet every configured seconds.
- */
- public void startHelloSender() {
- log.debug("IsisController::startHelloSender");
- Set<Integer> interfaceIndexes = isisInterfaceMap.keySet();
- for (Integer interfaceIndex : interfaceIndexes) {
- IsisInterface isisInterface = isisInterfaceMap.get(interfaceIndex);
- isisInterface.startHelloSender(channel);
- }
- }
-
- /**
- * Stops the hello timer.
- */
- public void stopHelloSender() {
- log.debug("ISISChannelHandler::stopHelloTimer ");
- log.debug("IsisController::startHelloSender");
- Set<Integer> interfaceIndexes = isisInterfaceMap.keySet();
- for (Integer interfaceIndex : interfaceIndexes) {
- IsisInterface isisInterface = isisInterfaceMap.get(interfaceIndex);
- isisInterface.stopHelloSender();
- }
- }
-
- /**
- * Sends the interface configuration packet to server.
- *
- * @param configPacket interface configuration
- */
- public void sentConfigPacket(byte[] configPacket) {
- if (channel != null && channel.isConnected() && channel.isOpen()) {
- channel.write(configPacket);
- log.debug("IsisChannelHandler sentConfigPacket packet sent..!!!");
- } else {
- log.debug("IsisChannelHandler sentConfigPacket channel not connected - re try..!!!");
- this.configPacket = configPacket;
- }
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisHelloPduSender.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisHelloPduSender.java
deleted file mode 100644
index c97b5a5..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisHelloPduSender.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.channel.Channel;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisNetworkType;
-import org.onosproject.isis.controller.IsisRouterType;
-import org.onosproject.isis.io.util.IsisUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Representation of an ISIS hello pdu sender task.
- */
-public class IsisHelloPduSender implements Runnable {
- private static final Logger log = LoggerFactory.getLogger(IsisHelloPduSender.class);
- private Channel channel = null;
- private IsisInterface isisInterface = null;
-
- /**
- * Creates an instance of Hello PDU Sender task.
- *
- * @param channel netty channel instance
- * @param isisInterface ISIS interface instance
- */
- public IsisHelloPduSender(Channel channel, IsisInterface isisInterface) {
- this.channel = channel;
- this.isisInterface = isisInterface;
- }
-
- @Override
- public void run() {
- if (channel != null && channel.isConnected() && channel.isOpen()) {
- try {
- byte[] helloPdu = null;
- byte[] interfaceIndex = {(byte) isisInterface.interfaceIndex()};
-
- if (isisInterface.networkType() == IsisNetworkType.P2P) {
- helloPdu = IsisUtil.getP2pHelloPdu(isisInterface, true);
- helloPdu = Bytes.concat(helloPdu, interfaceIndex);
- channel.write(helloPdu);
- } else if (isisInterface.networkType() == IsisNetworkType.BROADCAST) {
- switch (IsisRouterType.get(isisInterface.reservedPacketCircuitType())) {
- case L1:
- helloPdu = IsisUtil.getL1HelloPdu(isisInterface, true);
- helloPdu = Bytes.concat(helloPdu, interfaceIndex);
- channel.write(helloPdu);
- break;
- case L2:
- helloPdu = IsisUtil.getL2HelloPdu(isisInterface, true);
- helloPdu = Bytes.concat(helloPdu, interfaceIndex);
- channel.write(helloPdu);
- break;
- case L1L2:
- helloPdu = IsisUtil.getL1HelloPdu(isisInterface, true);
- helloPdu = Bytes.concat(helloPdu, interfaceIndex);
- channel.write(helloPdu);
-
- helloPdu = IsisUtil.getL2HelloPdu(isisInterface, true);
- helloPdu = Bytes.concat(helloPdu, interfaceIndex);
- channel.write(helloPdu);
- break;
- default:
- log.debug("IsisHelloPduSender::Unknown circuit type...!!!");
- break;
- }
- }
- } catch (Exception e) {
- log.debug("Exception @IsisHelloPduSender:: {}", e.getMessage());
- }
- }
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageDecoder.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageDecoder.java
deleted file mode 100644
index 7a69a5b..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageDecoder.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
-import org.onlab.packet.MacAddress;
-import org.onosproject.isis.controller.IsisMessage;
-import org.onosproject.isis.io.isispacket.IsisMessageReader;
-import org.onosproject.isis.io.util.IsisConstants;
-import org.onosproject.isis.io.util.IsisUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Decodes an ISIS message from a Channel, for use in a netty pipeline.
- */
-public class IsisMessageDecoder extends FrameDecoder {
-
- private static final Logger log = LoggerFactory.getLogger(IsisMessageDecoder.class);
-
- @Override
- protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
- log.debug("IsisMessageDecoder::Message received <:> length {}", buffer.readableBytes());
- if (!channel.isConnected()) {
- log.info("Channel is not connected.");
- return null;
- }
- IsisMessageReader messageReader = new IsisMessageReader();
- List<IsisMessage> isisMessageList = new LinkedList<>();
- int dataLength = buffer.readableBytes();
- while (buffer.readableBytes() >= IsisConstants.MINIMUM_FRAME_LEN) {
- ChannelBuffer payload = buffer.readBytes(IsisConstants.MINIMUM_FRAME_LEN);
- ChannelBuffer ethernetHeader = payload.readBytes(IsisUtil.ETHER_HEADER_LEN);
- //Read the Source MAC address from ethernet header at the 6th position
- MacAddress sourceMac = getSourceMac(ethernetHeader);
- //Strip 17 byte ethernet header and get the ISIS data buffer
- ChannelBuffer isisDataBuffer = payload.readBytes(payload.readableBytes());
- int readableBytes = isisDataBuffer.readableBytes();
- IsisMessage message = messageReader.readFromBuffer(isisDataBuffer);
- //Last 7 bytes is metadata. ie. interface MAC address and interface index.
- if (message != null) {
- if (isisDataBuffer.readableBytes() >= IsisConstants.METADATA_LEN) {
- //Sets the source MAC
- message.setSourceMac(sourceMac);
- isisDataBuffer.readerIndex(readableBytes - IsisConstants.METADATA_LEN);
- log.debug("IsisMessageDecoder::Reading metadata <:> length {}", isisDataBuffer.readableBytes());
- byte[] macBytes = new byte[IsisUtil.SIX_BYTES];
- isisDataBuffer.readBytes(macBytes, 0, IsisUtil.SIX_BYTES);
- MacAddress macAddress = MacAddress.valueOf(macBytes);
- int interfaceIndex = isisDataBuffer.readByte();
- message.setInterfaceMac(macAddress);
- message.setInterfaceIndex(interfaceIndex);
- }
- isisMessageList.add(message);
- }
- }
- return (!isisMessageList.isEmpty()) ? isisMessageList : null;
- }
-
- /**
- * Gets the source MAC address from the ethernet header.
- *
- * @param ethHeader ethernet header bytes
- * @return MAC address of the source router
- */
- private MacAddress getSourceMac(ChannelBuffer ethHeader) {
- //Source MAC is at position 6 to 11 (6 bytes)
- ethHeader.skipBytes(IsisUtil.SIX_BYTES);
- MacAddress sourceMac = MacAddress.valueOf(ethHeader.readBytes(IsisUtil.SIX_BYTES).array());
-
- return sourceMac;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageEncoder.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageEncoder.java
deleted file mode 100644
index 9f6ca66..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageEncoder.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Encodes an ISIS message for output into a ChannelBuffer, for use in a netty pipeline.
- */
-public class IsisMessageEncoder extends OneToOneEncoder {
- private static final Logger log = LoggerFactory.getLogger(IsisMessageEncoder.class);
-
- @Override
- protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
-
- byte[] byteMsg = (byte[]) msg;
- log.debug("Encoding isisMessage of length {}", byteMsg.length);
- ChannelBuffer channelBuffer = ChannelBuffers.buffer(byteMsg.length);
- channelBuffer.writeBytes(byteMsg);
-
- return channelBuffer;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisPipelineFactory.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisPipelineFactory.java
deleted file mode 100644
index d93ca5e..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisPipelineFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.Channels;
-
-/**
- * Creates a ChannelPipeline for a client-side ISIS channel.
- */
-public class IsisPipelineFactory implements ChannelPipelineFactory {
- private IsisChannelHandler isisChannelHandler;
-
- /**
- * Creates an instance of ISIS channel pipeline factory.
- *
- * @param isisChannelHandler ISIS channel handler instance
- */
- public IsisPipelineFactory(IsisChannelHandler isisChannelHandler) {
- this.isisChannelHandler = isisChannelHandler;
- }
-
- @Override
- public ChannelPipeline getPipeline() throws Exception {
- ChannelPipeline pipeline = Channels.pipeline();
- pipeline.addLast("encoder", new IsisMessageDecoder());
- pipeline.addLast("decoder", new IsisMessageEncoder());
- pipeline.addLast("handler", isisChannelHandler);
-
- return pipeline;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/LspEventConsumer.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/LspEventConsumer.java
deleted file mode 100644
index 56f2aef..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/LspEventConsumer.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
-* Copyright 2016-present Open Networking Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.onosproject.isis.controller.impl;
-
-import org.onlab.packet.Ip4Address;
-import org.onlab.util.Bandwidth;
-import org.onosproject.isis.controller.IsisNetworkType;
-import org.onosproject.isis.controller.LspWrapper;
-import org.onosproject.isis.controller.impl.topology.DefaultIsisLink;
-import org.onosproject.isis.controller.impl.topology.DefaultIsisLinkInformation;
-import org.onosproject.isis.controller.impl.topology.DefaultIsisLinkTed;
-import org.onosproject.isis.controller.impl.topology.DefaultIsisRouter;
-import org.onosproject.isis.controller.impl.topology.TopologyForDeviceAndLinkImpl;
-import org.onosproject.isis.controller.topology.IsisLink;
-import org.onosproject.isis.controller.topology.IsisLinkTed;
-import org.onosproject.isis.controller.topology.IsisRouter;
-import org.onosproject.isis.controller.topology.LinkInformation;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-import org.onosproject.isis.io.isispacket.tlv.IsExtendedReachability;
-import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
-import org.onosproject.isis.io.isispacket.tlv.NeighborForExtendedIs;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.AdministrativeGroup;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.InterfaceIpAddress;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumBandwidth;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumReservableBandwidth;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.NeighborIpAddress;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringMetric;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.UnreservedBandwidth;
-import org.onosproject.isis.io.util.IsisConstants;
-import org.onosproject.isis.io.util.IsisUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.BlockingQueue;
-
-/**
- * Representation of LSP event consumer.
- */
-public class LspEventConsumer implements Runnable {
- private static final Logger log = LoggerFactory.getLogger(LspEventConsumer.class);
- private BlockingQueue queue = null;
- private Controller controller = null;
- private TopologyForDeviceAndLinkImpl deviceAndLink = new TopologyForDeviceAndLinkImpl();
- private Map<String, IsisRouter> isisRouterDetails = new LinkedHashMap<>();
-
- /**
- * Creates an instance of this.
- *
- * @param queue blocking queue instance
- * @param controller controller instance
- */
- public LspEventConsumer(BlockingQueue queue, Controller controller) {
- this.queue = queue;
- this.controller = controller;
- }
-
- @Override
- public void run() {
- try {
- while (true) {
- if (!queue.isEmpty()) {
- LspWrapper wrapper = (LspWrapper) queue.take();
- LsPdu lsPdu = (LsPdu) wrapper.lsPdu();
- if (wrapper.lspProcessing().equals(IsisConstants.LSPREMOVED)) {
- callTopologyToRemoveInfo(lsPdu);
- } else if (wrapper.lspProcessing().equals(IsisConstants.LSPADDED)) {
- callTopologyToSendInfo(lsPdu, wrapper.isisInterface().networkType(),
- wrapper.isisInterface().systemId() + ".00");
- }
- }
- }
- } catch (Exception e) {
- log.debug("Error::LspsForProvider::{}", e.getMessage());
- }
- }
-
- /**
- * Sends topology information to core.
- *
- * @param lsPdu ls pdu instance
- * @param isisNetworkType ISIS network type
- * @param ownSystemId own system ID
- */
- private void callTopologyToSendInfo(LsPdu lsPdu, IsisNetworkType isisNetworkType,
- String ownSystemId) {
- if ((lsPdu.lspId().equals(ownSystemId + "-00"))) {
- return;
- }
- sendDeviceInfo(createDeviceInfo(lsPdu));
-
- for (IsisTlv isisTlv : lsPdu.tlvs()) {
- if (isisTlv instanceof IsExtendedReachability) {
- IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
- List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
- for (NeighborForExtendedIs teTlv : neighbours) {
- String neighbor = teTlv.neighborId();
- IsisRouter isisRouter = isisRouterDetails.get(neighbor);
- if (isisRouter != null) {
- IsisRouter sourceRouter = isisRouterDetails.get(IsisUtil.removeTailingZeros(lsPdu.lspId()));
- IsisRouter destinationRouter = isisRouter;
- if (sourceRouter.isDis()) {
- LinkInformation linkInformation = createLinkInfo(sourceRouter.systemId(),
- destinationRouter.systemId(),
- sourceRouter.interfaceId(),
- destinationRouter.interfaceId(), lsPdu);
- controller.addLinkDetails(createIsisLink(linkInformation, lsPdu));
- } else if (destinationRouter.isDis()) {
- LinkInformation linkInformation1 = createLinkInfo(destinationRouter.systemId(),
- sourceRouter.systemId(),
- destinationRouter.interfaceId(),
- sourceRouter.interfaceId(), lsPdu);
- controller.addLinkDetails(createIsisLink(linkInformation1, lsPdu));
- } else {
- LinkInformation linkInformation = createLinkInfo(sourceRouter.systemId(),
- destinationRouter.systemId(),
- sourceRouter.interfaceId(),
- destinationRouter.interfaceId(), lsPdu);
- controller.addLinkDetails(createIsisLink(linkInformation, lsPdu));
- LinkInformation linkInformation1 = createLinkInfo(destinationRouter.systemId(),
- sourceRouter.systemId(),
- destinationRouter.interfaceId(),
- sourceRouter.interfaceId(), lsPdu);
- controller.addLinkDetails(createIsisLink(linkInformation1, lsPdu));
- }
- }
- }
- }
- }
- }
-
- /**
- * Removes topology information from core.
- *
- * @param lsPdu ls pdu instance
- */
- private void callTopologyToRemoveInfo(LsPdu lsPdu) {
- String routerId = IsisUtil.removeTailingZeros(lsPdu.lspId());
- IsisRouter isisRouter = isisRouterDetails.get(routerId);
- removeDeviceInfo(isisRouter);
- removeLinkInfo(lsPdu);
- }
-
- /**
- * Sends the device information to topology provider.
- *
- * @param isisRouter ISIS router instance
- */
- private void sendDeviceInfo(IsisRouter isisRouter) {
- if (isisRouter.systemId() != null) {
- controller.addDeviceDetails(isisRouter);
- }
- }
-
- /**
- * Creates Device instance.
- *
- * @param lsPdu ISIS LSPDU instance
- * @return isisRouter isisRouter instance
- */
- public IsisRouter createDeviceInfo(LsPdu lsPdu) {
- IsisRouter isisRouter = createIsisRouter(lsPdu);
- if (isisRouter.systemId() != null) {
- isisRouterDetails.put(isisRouter.systemId(), isisRouter);
- }
- return isisRouter;
- }
-
- /**
- * Creates ISIS router instance.
- *
- * @param lsPdu lsp instance
- * @return isisRouter instance
- */
- private IsisRouter createIsisRouter(LsPdu lsPdu) {
- IsisRouter isisRouter = new DefaultIsisRouter();
- if (IsisUtil.checkIsDis(lsPdu.lspId())) {
- isisRouter.setDis(true);
- } else {
- isisRouter.setDis(false);
- }
- isisRouter.setSystemId(IsisUtil.removeTailingZeros(lsPdu.lspId()));
- for (IsisTlv isisTlv : lsPdu.tlvs()) {
- if (isisTlv instanceof IsExtendedReachability) {
- IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
- List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
- for (NeighborForExtendedIs teTlv : neighbours) {
- List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv();
- for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) {
- if (teSubTlv instanceof InterfaceIpAddress) {
- InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv;
- isisRouter.setInterfaceId(localIpAddress.localInterfaceIPAddress());
- } else if (teSubTlv instanceof NeighborIpAddress) {
- NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv;
- isisRouter.setNeighborRouterId(neighborIpAddress.neighborIPAddress());
- }
-
- }
- }
- }
- }
- if (isisRouter.interfaceId() == null) {
- isisRouter.setInterfaceId(IsisConstants.DEFAULTIP);
- }
- if (isisRouter.neighborRouterId() == null) {
- isisRouter.setNeighborRouterId(IsisConstants.DEFAULTIP);
- }
- return isisRouter;
- }
-
- /**
- * Creates link information.
- *
- * @param localSystemId local system ID
- * @param remoteSystemId remote system ID
- * @param interfaceIp interface address
- * @param neighborIp neighbor address
- * @param lsPdu link state PDU instance
- * @return link information instance
- */
- public LinkInformation createLinkInfo(String localSystemId, String remoteSystemId,
- Ip4Address interfaceIp, Ip4Address neighborIp,
- LsPdu lsPdu) {
-
- String linkId = "link:" + localSystemId + "-" + remoteSystemId;
- LinkInformation linkInformation = new DefaultIsisLinkInformation();
- linkInformation.setInterfaceIp(interfaceIp);
- linkInformation.setNeighborIp(neighborIp);
- linkInformation.setLinkId(linkId);
- linkInformation.setAlreadyCreated(false);
- linkInformation.setLinkDestinationId(remoteSystemId);
- linkInformation.setLinkSourceId(localSystemId);
-
- return linkInformation;
- }
-
- /**
- * Removes the device information from topology provider.
- *
- * @param isisRouter ISIS router instance
- */
- private void removeDeviceInfo(IsisRouter isisRouter) {
- if (isisRouter.systemId() != null) {
- controller.removeDeviceDetails(isisRouter);
- }
- isisRouterDetails.remove(isisRouter.systemId());
- }
-
-
- /**
- * Removes the link information from topology provider.
- *
- * @param lsPdu ls pdu instance
- */
- private void removeLinkInfo(LsPdu lsPdu) {
- Map<String, LinkInformation> linkInformationList = deviceAndLink.removeLinkInfo(lsPdu.lspId());
- for (String key : linkInformationList.keySet()) {
- LinkInformation linkInformation = linkInformationList.get(key);
- controller.removeLinkDetails(createIsisLink(linkInformation, lsPdu));
- }
- }
-
- /**
- * Creates ISIS link instance.
- *
- * @param linkInformation link information instance
- * @return isisLink instance
- */
- private IsisLink createIsisLink(LinkInformation linkInformation, LsPdu lsPdu) {
- IsisLink isisLink = new DefaultIsisLink();
- isisLink.setLocalSystemId(linkInformation.linkSourceId());
- isisLink.setRemoteSystemId(linkInformation.linkDestinationId());
- isisLink.setInterfaceIp(linkInformation.interfaceIp());
- isisLink.setNeighborIp(linkInformation.neighborIp());
- isisLink.setLinkTed(createIsisLinkTedInfo(lsPdu));
- return isisLink;
- }
-
- /**
- * Creates the ISIS link TED information.
- *
- * @param lsPdu link state PDU
- * @return isisLinkTed
- */
- public IsisLinkTed createIsisLinkTedInfo(LsPdu lsPdu) {
- IsisLinkTed isisLinkTed = new DefaultIsisLinkTed();
- for (IsisTlv isisTlv : lsPdu.tlvs()) {
- if (isisTlv instanceof IsExtendedReachability) {
- IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
- List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
- for (NeighborForExtendedIs teTlv : neighbours) {
- List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv();
- for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) {
- if (teSubTlv instanceof AdministrativeGroup) {
- AdministrativeGroup ag = (AdministrativeGroup) teSubTlv;
- isisLinkTed.setAdministrativeGroup(ag.administrativeGroup());
- }
- if (teSubTlv instanceof InterfaceIpAddress) {
- InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv;
- isisLinkTed.setIpv4InterfaceAddress(localIpAddress.localInterfaceIPAddress());
- }
- if (teSubTlv instanceof NeighborIpAddress) {
- NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv;
- isisLinkTed.setIpv4NeighborAddress(neighborIpAddress.neighborIPAddress());
- }
- if (teSubTlv instanceof TrafficEngineeringMetric) {
- TrafficEngineeringMetric teM = (TrafficEngineeringMetric) teSubTlv;
- isisLinkTed.setTeDefaultMetric(teM.getTrafficEngineeringMetricValue());
- }
- if (teSubTlv instanceof MaximumBandwidth) {
- MaximumBandwidth maxLinkBandwidth = (MaximumBandwidth) teSubTlv;
- isisLinkTed.setMaximumLinkBandwidth(
- Bandwidth.bps(maxLinkBandwidth.getMaximumBandwidthValue()));
- }
- if (teSubTlv instanceof MaximumReservableBandwidth) {
- MaximumReservableBandwidth maxReservableBw = (MaximumReservableBandwidth) teSubTlv;
- isisLinkTed.setMaximumReservableLinkBandwidth(
- Bandwidth.bps(maxReservableBw.getMaximumBandwidthValue()));
- }
- if (teSubTlv instanceof UnreservedBandwidth) {
- UnreservedBandwidth unReservedBandwidth = (UnreservedBandwidth) teSubTlv;
- List<Bandwidth> bandwidthList = new ArrayList<>();
- List<Float> unReservedBandwidthList = unReservedBandwidth.unReservedBandwidthValue();
- for (Float unReservedBandwidthFloatValue : unReservedBandwidthList) {
- Bandwidth bandwidth = Bandwidth.bps(unReservedBandwidthFloatValue);
- bandwidthList.add(bandwidth);
- }
- isisLinkTed.setUnreservedBandwidth(bandwidthList);
- }
- }
- }
- }
- }
- return isisLinkTed;
- }
-}
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
deleted file mode 100644
index 5caebd6..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl.lsdb;
-
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisLsdb;
-import org.onosproject.isis.controller.IsisLsdbAge;
-import org.onosproject.isis.controller.IsisLspBin;
-import org.onosproject.isis.controller.IsisMessage;
-import org.onosproject.isis.controller.IsisNeighbor;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.controller.IsisRouterType;
-import org.onosproject.isis.controller.LspWrapper;
-import org.onosproject.isis.controller.impl.Controller;
-import org.onosproject.isis.controller.impl.LspEventConsumer;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-import org.onosproject.isis.io.util.IsisConstants;
-import org.onosproject.isis.io.util.IsisUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * Representation of ISIS link state database.
- */
-public class DefaultIsisLsdb implements IsisLsdb {
- private static final Logger log = LoggerFactory.getLogger(DefaultIsisLsdb.class);
- private Map<String, LspWrapper> isisL1Db = new ConcurrentHashMap<>();
- private Map<String, LspWrapper> isisL2Db = new ConcurrentHashMap<>();
- private IsisLsdbAge lsdbAge = null;
- private Controller controller = null;
- private List<IsisInterface> isisInterfaceList = new ArrayList<>();
-
-
- private int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
- private int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
- private LspEventConsumer queueConsumer = null;
- private BlockingQueue<LspWrapper> lspForProviderQueue = new ArrayBlockingQueue<>(1024);
-
- /**
- * Creates an instance of ISIS LSDB.
- */
- public DefaultIsisLsdb() {
- lsdbAge = new DefaultIsisLsdbAge();
- }
-
- /**
- * Sets the controller instance.
- *
- * @param controller controller instance
- */
- public void setController(Controller controller) {
- this.controller = controller;
- }
-
- /**
- * Sets the list of IsisInterface instance.
- *
- * @param isisInterfaceList isisInterface instance
- */
- public void setIsisInterface(List<IsisInterface> isisInterfaceList) {
- this.isisInterfaceList = isisInterfaceList;
- }
-
- /**
- * Initializes the link state database.
- */
- public void initializeDb() {
- lsdbAge.startDbAging();
- queueConsumer = new LspEventConsumer(lspForProviderQueue, controller);
- new Thread(queueConsumer).start();
- }
-
- /**
- * Sets the level 1 link state sequence number.
- *
- * @param l1LspSeqNo link state sequence number
- */
- public void setL1LspSeqNo(int l1LspSeqNo) {
- this.l1LspSeqNo = l1LspSeqNo;
- }
-
- /**
- * Sets the level 2 link state sequence number.
- *
- * @param l2LspSeqNo link state sequence number
- */
- public void setL2LspSeqNo(int l2LspSeqNo) {
- this.l2LspSeqNo = l2LspSeqNo;
- }
-
- /**
- * Returns the LSDB LSP key.
- *
- * @param systemId system ID
- * @return key
- */
- public String lspKey(String systemId) {
- StringBuilder lspKey = new StringBuilder();
- lspKey.append(systemId);
- lspKey.append(".00");
- lspKey.append("-");
- lspKey.append("00");
-
- return lspKey.toString();
- }
-
- /**
- * Returns the neighbor L1 database information.
- *
- * @return neighbor L1 database information
- */
- public Map<String, LspWrapper> getL1Db() {
- return isisL1Db;
- }
-
- /**
- * Returns the neighbor L2 database information.
- *
- * @return neighbor L2 database information
- */
- public Map<String, LspWrapper> getL2Db() {
- return isisL2Db;
- }
-
- /**
- * Returns the LSDB instance.
- *
- * @return LSDB instance
- */
- public IsisLsdb isisLsdb() {
- return this;
- }
-
- /**
- * Returns all LSPs (L1 and L2).
- *
- * @param excludeMaxAgeLsp exclude the max age LSPs
- * @return List of LSPs
- */
- public List<LspWrapper> allLspHeaders(boolean excludeMaxAgeLsp) {
- List<LspWrapper> summaryList = new CopyOnWriteArrayList<>();
- addLspToHeaderList(summaryList, excludeMaxAgeLsp, isisL1Db);
- addLspToHeaderList(summaryList, excludeMaxAgeLsp, isisL2Db);
-
- return summaryList;
- }
-
- /**
- * Adds the LSPs to summary list.
- *
- * @param summaryList summary list
- * @param excludeMaxAgeLsp exclude max age LSP
- * @param lspMap map of LSP
- */
- private void addLspToHeaderList(List summaryList, boolean excludeMaxAgeLsp, Map lspMap) {
- Iterator slotVals = lspMap.values().iterator();
- while (slotVals.hasNext()) {
- LspWrapper wrapper = (LspWrapper) slotVals.next();
- if (excludeMaxAgeLsp) {
- //if current age of lsa is max age or lsa present in Max Age bin
- if (wrapper.remainingLifetime() != 0) {
- addToList(wrapper, summaryList);
- }
- } else {
- addToList(wrapper, summaryList);
- }
- }
- }
-
- /**
- * Adds the LSPWrapper to summary list.
- *
- * @param wrapper LSP wrapper instance
- * @param summList LSP summary list
- */
- private void addToList(LspWrapper wrapper, List summList) {
- //set the current age
- ((LsPdu) wrapper.lsPdu()).setRemainingLifeTime(wrapper.remainingLifetime());
- summList.add(wrapper);
- }
-
- /**
- * Finds the LSP from appropriate maps L1 or L2 based on type.
- *
- * @param pduType L1 or L2 LSP
- * @param lspId LSP ID
- * @return LSP wrapper object
- */
- public LspWrapper findLsp(IsisPduType pduType, String lspId) {
- LspWrapper lspWrapper = null;
-
- switch (pduType) {
- case L1LSPDU:
- lspWrapper = isisL1Db.get(lspId);
- break;
- case L2LSPDU:
- lspWrapper = isisL2Db.get(lspId);
- break;
- default:
- log.debug("Unknown LSP type..!!!");
- break;
- }
-
- //set the current age
- if (lspWrapper != null) {
- //set the current age
- ((DefaultLspWrapper) lspWrapper).lsPdu().setRemainingLifeTime(lspWrapper.remainingLifetime());
- }
-
- return lspWrapper;
- }
-
- /**
- * Installs a new self-originated LSP.
- *
- * @param isisMessage ISIS message
- * @param isSelfOriginated is the message self originated?
- * @param isisInterface ISIS interface
- * @return true if successfully added
- */
- public boolean addLsp(IsisMessage isisMessage, boolean isSelfOriginated, IsisInterface isisInterface) {
- LsPdu lspdu = (LsPdu) isisMessage;
- if (isSelfOriginated) {
- //Add length and checksum
- byte[] lspBytes = lspdu.asBytes();
- lspdu.setPduLength(lspBytes.length);
- lspBytes = IsisUtil.addChecksum(lspBytes, IsisConstants.CHECKSUMPOSITION,
- IsisConstants.CHECKSUMPOSITION + 1);
- byte[] checkSum = {lspBytes[IsisConstants.CHECKSUMPOSITION], lspBytes[IsisConstants.CHECKSUMPOSITION + 1]};
- lspdu.setCheckSum(ChannelBuffers.copiedBuffer(checkSum).readUnsignedShort());
- }
-
- DefaultLspWrapper lspWrapper = (DefaultLspWrapper) findLsp(lspdu.isisPduType(), lspdu.lspId());
- if (lspWrapper == null) {
- lspWrapper = new DefaultLspWrapper();
- }
-
- lspWrapper.setLspAgeReceived(IsisConstants.LSPMAXAGE - lspdu.remainingLifeTime());
- lspWrapper.setLspType(IsisPduType.get(lspdu.pduType()));
- lspWrapper.setLsPdu(lspdu);
- lspWrapper.setAgeCounterWhenReceived(lsdbAge.ageCounter());
- lspWrapper.setAgeCounterRollOverWhenAdded(lsdbAge.ageCounterRollOver());
- lspWrapper.setSelfOriginated(isSelfOriginated);
- lspWrapper.setIsisInterface(isisInterface);
- lspWrapper.setLsdbAge(lsdbAge);
- addLsp(lspWrapper, lspdu.lspId());
-
- log.debug("Added LSp In LSDB: {}", lspWrapper);
- try {
- if (!lspWrapper.isSelfOriginated()) {
- lspWrapper.setLspProcessing(IsisConstants.LSPADDED);
- lspForProviderQueue.put(lspWrapper);
- }
- } catch (Exception e) {
- log.debug("Added LSp In Blocking queue: {}", lspWrapper);
- }
- return true;
- }
-
- /**
- * Adds the LSP to L1 or L2 database.
- *
- * @param lspWrapper LSA wrapper instance
- * @param key key
- * @return True if added else false
- */
- private boolean addLsp(LspWrapper lspWrapper, String key) {
- //Remove the lsa from bin if exist.
- removeLspFromBin(lspWrapper);
-
- switch (lspWrapper.lsPdu().isisPduType()) {
- case L1LSPDU:
- isisL1Db.remove(key);
- isisL1Db.put(key, lspWrapper);
- break;
- case L2LSPDU:
- isisL2Db.remove(key);
- isisL2Db.put(key, lspWrapper);
- break;
- default:
- log.debug("Unknown LSP type to add..!!!");
- break;
- }
-
- //add it to bin
- Integer binNumber = lsdbAge.age2Bin(IsisConstants.LSPMAXAGE - lspWrapper.lspAgeReceived());
- IsisLspBin lspBin = lsdbAge.getLspBin(binNumber);
- if (lspBin != null) {
- //remove from existing
- lspWrapper.setBinNumber(binNumber);
- lspBin.addIsisLsp(key, lspWrapper);
- lsdbAge.addLspBin(binNumber, lspBin);
- log.debug("Added Type {} LSP to LSDB and LSABin[{}], Remaining life time of LSA {}",
- lspWrapper.lsPdu().isisPduType(),
- binNumber, lspWrapper.remainingLifetime());
- }
-
- return false;
- }
-
- /**
- * Removes LSP from Bin.
- *
- * @param lsaWrapper LSP wrapper instance
- */
- public void removeLspFromBin(LspWrapper lsaWrapper) {
- if (lsaWrapper != null) {
- lsdbAge.removeLspFromBin(lsaWrapper);
- }
- }
-
- /**
- * Returns new ,latest or old according to the type of ISIS message received.
- *
- * @param lsp1 LSP instance
- * @param lsp2 LSP instance
- * @return string status
- */
- public String isNewerOrSameLsp(IsisMessage lsp1, IsisMessage lsp2) {
- LsPdu receivedLsp = (LsPdu) lsp1;
- LsPdu lspFromDb = (LsPdu) lsp2;
- if (receivedLsp.sequenceNumber() > lspFromDb.sequenceNumber() ||
- receivedLsp.checkSum() != lspFromDb.checkSum()) {
- return "latest";
- } else if (receivedLsp.sequenceNumber() < lspFromDb.sequenceNumber()) {
- return "old";
- } else if (receivedLsp.sequenceNumber() == lspFromDb.sequenceNumber()) {
- return "same";
- }
-
- return "";
- }
-
- /**
- * Returns the sequence number.
- *
- * @param lspType type of LSP
- * @return sequence number
- */
- public int lsSequenceNumber(IsisPduType lspType) {
- switch (lspType) {
- case L1LSPDU:
- return l1LspSeqNo++;
- case L2LSPDU:
- return l2LspSeqNo++;
- default:
- return IsisConstants.STARTLSSEQUENCENUM;
- }
- }
-
- /**
- * Deletes the given LSP.
- *
- * @param lspMessage LSP instance
- */
- public void deleteLsp(IsisMessage lspMessage) {
- LsPdu lsp = (LsPdu) lspMessage;
- String lspKey = lsp.lspId();
- LspWrapper lspWrapper = findLsp(lspMessage.isisPduType(), lspKey);
- switch (lsp.isisPduType()) {
- case L1LSPDU:
- isisL1Db.remove(lspKey);
- break;
- case L2LSPDU:
- isisL2Db.remove(lspKey);
- break;
- default:
- log.debug("Unknown LSP type to remove..!!!");
- break;
- }
-
- try {
- lspWrapper.setLspProcessing(IsisConstants.LSPREMOVED);
- lspForProviderQueue.put(lspWrapper);
- } catch (Exception e) {
- log.debug("Added LSp In Blocking queue: {}", lspWrapper);
- }
- }
-
- /**
- * Removes topology information when neighbor down.
- *
- * @param neighbor ISIS neighbor instance
- * @param isisInterface ISIS interface instance
- */
- public void removeTopology(IsisNeighbor neighbor, IsisInterface isisInterface) {
- String lspKey = neighbor.neighborSystemId() + ".00-00";
- LspWrapper lspWrapper = null;
- switch (IsisRouterType.get(isisInterface.reservedPacketCircuitType())) {
- case L1:
- lspWrapper = findLsp(IsisPduType.L1LSPDU, lspKey);
- break;
- case L2:
- lspWrapper = findLsp(IsisPduType.L2LSPDU, lspKey);
- break;
- case L1L2:
- lspWrapper = findLsp(IsisPduType.L1LSPDU, lspKey);
- if (lspWrapper == null) {
- lspWrapper = findLsp(IsisPduType.L2LSPDU, lspKey);
- }
- break;
- default:
- log.debug("Unknown type");
- }
- try {
- if (lspWrapper != null) {
- lspWrapper.setLspProcessing(IsisConstants.LSPREMOVED);
- lspForProviderQueue.put(lspWrapper);
- }
- } catch (Exception e) {
- log.debug("Added LSp In Blocking queue: {}", lspWrapper);
- }
- }
-}
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAge.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAge.java
deleted file mode 100644
index 6ac3758..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAge.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl.lsdb;
-
-import org.onosproject.isis.controller.IsisLsdbAge;
-import org.onosproject.isis.controller.IsisLspBin;
-import org.onosproject.isis.controller.LspWrapper;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-import org.onosproject.isis.io.util.IsisConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Map;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Representation of ISIS link state database ageing process.
- */
-public class DefaultIsisLsdbAge implements IsisLsdbAge {
- private static final Logger log = LoggerFactory.getLogger(DefaultIsisLsdbAge.class);
- protected int ageCounter = 0;
- private InternalAgeTimer dbAgeTimer;
- private ScheduledExecutorService exServiceage;
- private Integer maxBins = IsisConstants.LSPMAXAGE;
- private Map<Integer, IsisLspBin> ageBins = new ConcurrentHashMap<>(maxBins);
- private int ageCounterRollOver = 0;
- private IsisLspQueueConsumer queueConsumer = null;
- private BlockingQueue<LspWrapper> lsaQueue = new ArrayBlockingQueue<>(1024);
- private boolean timerStarted = false;
-
- /**
- * Creates an instance of LSDB age.
- */
- public DefaultIsisLsdbAge() {
- // create LSBin's in the HashMap.
- for (int i = 0; i < maxBins; i++) {
- IsisLspBin lspBin = new DefaultIsisLspBin(i);
- ageBins.put(i, lspBin);
- }
- }
-
- /**
- * Returns age counter.
- *
- * @return age counter
- */
- public int ageCounter() {
- return ageCounter;
- }
-
- /**
- * Returns age counter roll over.
- *
- * @return age counter roll over
- */
- public int ageCounterRollOver() {
-
- return ageCounterRollOver;
- }
-
- /**
- * Adds LSP to LS bin for ageing.
- *
- * @param binNumber key to store in bin
- * @param lspBin LSP bin instance
- */
- public void addLspBin(int binNumber, IsisLspBin lspBin) {
- if (!ageBins.containsKey(binNumber)) {
- ageBins.put(binNumber, lspBin);
- }
- }
-
- /**
- * Returns LSP from Bin.
- *
- * @param binKey key
- * @return bin instance
- */
- public IsisLspBin getLspBin(int binKey) {
-
- return ageBins.get(binKey);
- }
-
- /**
- * Removes LSP from Bin.
- *
- * @param lspWrapper wrapper instance
- */
- public void removeLspFromBin(LspWrapper lspWrapper) {
- if (ageBins.containsKey(lspWrapper.binNumber())) {
- IsisLspBin lsaBin = ageBins.get(lspWrapper.binNumber());
- lsaBin.removeIsisLsp(((LsPdu) lspWrapper.lsPdu()).lspId(), lspWrapper);
- }
- }
-
- /**
- * Returns the bin number.
- *
- * @param age Can be either age or ageCounter
- * @return bin number.
- */
- public int age2Bin(int age) {
- if (age <= ageCounter) {
- return (ageCounter - age);
- } else {
- return ((IsisConstants.LSPMAXAGE - 1) + (ageCounter - age));
- }
- }
-
- /**
- * Starts the aging timer and queue consumer.
- */
- public void startDbAging() {
- if (!timerStarted) {
- startDbAgeTimer();
- queueConsumer = new IsisLspQueueConsumer(lsaQueue);
- new Thread(queueConsumer).start();
- timerStarted = true;
- }
- }
-
- /**
- * Starts DB aging task.
- */
- private void startDbAgeTimer() {
- dbAgeTimer = new InternalAgeTimer();
- //from 1 sec
- exServiceage = Executors.newSingleThreadScheduledExecutor();
- exServiceage.scheduleAtFixedRate(dbAgeTimer, 1, 1, TimeUnit.SECONDS);
- }
-
- /**
- * Gets called every second as part of the aging process.
- */
- public void ageLsp() {
- refreshLsa();
- maxAgeLsa();
-
- if (ageCounter == IsisConstants.LSPMAXAGE) {
- ageCounter = 0;
- ageCounterRollOver++;
- } else {
- ageCounter++;
- }
- }
-
- /**
- * If the LSP have completed the MaxAge - they are moved called stop aging.
- */
- public void maxAgeLsa() {
- if (ageCounter == 0) {
- return;
- }
- //Get from Age Bins
- IsisLspBin lspBin = ageBins.get(ageCounter - 1);
- if (lspBin == null) {
- return;
- }
- Map lspBinMap = lspBin.listOfLsp();
- for (Object key : lspBinMap.keySet()) {
- LspWrapper lspWrapper = (LspWrapper) lspBinMap.get((String) key);
- if (lspWrapper.currentAge() == IsisConstants.LSPMAXAGE) {
- lspWrapper.setLspProcessing(IsisConstants.MAXAGELSP);
- log.debug("Lsp picked for maxage removal. Age Counter: {}, AgeCounterRollover: {}, " +
- "AgeCounterRollover WhenAddedToDb: {}, LSA Type: {}, LSA Key: {}",
- ageCounter, ageCounterRollOver, lspWrapper.currentAge(),
- lspWrapper.lsPdu().isisPduType(), key);
- //add it to lspQueue for processing
- try {
- lsaQueue.put(lspWrapper);
- //remove from bin
- lspBin.removeIsisLsp((String) key, lspWrapper);
- } catch (InterruptedException e) {
- log.debug("Error::LSDBAge::maxAgeLsp::{}", e.getMessage());
- }
- }
- }
-
- }
-
- /*
- * If the LSP is in age bin of 900s- it's pushed into refresh list.
- */
- public void refreshLsa() {
- int binNumber;
- if (ageCounter < IsisConstants.LSPREFRESH) {
- binNumber = ageCounter + IsisConstants.LSPREFRESH;
- } else {
- binNumber = ageCounter - IsisConstants.LSPREFRESH;
- }
- if (binNumber >= IsisConstants.LSPMAXAGE) {
- binNumber = binNumber - IsisConstants.LSPMAXAGE;
- }
- IsisLspBin lspBin = ageBins.get(binNumber);
- if (lspBin == null) {
- return;
- }
- Map lspBinMap = lspBin.listOfLsp();
- for (Object key : lspBinMap.keySet()) {
- LspWrapper lsp = (LspWrapper) lspBinMap.get((String) key);
- try {
- if (lsp.isSelfOriginated()) {
- log.debug("Lsp picked for refreshLsp. binNumber: {}, LSA Type: {}, LSA Key: {}",
- binNumber, lsp.lspType(), key);
- lsp.setLspProcessing(IsisConstants.REFRESHLSP);
- lsaQueue.put(lsp);
- //remove from bin
- lspBin.removeIsisLsp((String) key, lsp);
- }
- } catch (InterruptedException e) {
- log.debug("Error::LSDBAge::refreshLsp::{}", e.getMessage());
- }
- }
- }
-
- /**
- * Runnable task which runs every second and calls aging process.
- */
- private class InternalAgeTimer implements Runnable {
-
- /**
- * Creates an instance of age timer task.
- */
- InternalAgeTimer() {
- log.debug("Starts::IsisLsdbAge::AgeTimer...!!! ");
- }
-
- @Override
- public void run() {
- ageLsp();
- }
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBin.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBin.java
deleted file mode 100644
index 605eb5f..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBin.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl.lsdb;
-
-import com.google.common.base.MoreObjects;
-import org.onosproject.isis.controller.IsisLspBin;
-import org.onosproject.isis.controller.LspWrapper;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Representation of LSP bin, where an LSP is stored for Aging.
- * A bin is identified by a bin number and can have one or more LSPs
- * store in a particular bin location
- */
-public class DefaultIsisLspBin implements IsisLspBin {
- private int binNumber;
- private Map<String, LspWrapper> listOfLsp = new ConcurrentHashMap<>();
-
- /**
- * Creates ISIS LSP bin instance.
- *
- * @param binNumber bin number
- */
- public DefaultIsisLspBin(int binNumber) {
- this.binNumber = binNumber;
- }
-
- /**
- * Adds the LSP to wrapper.
- *
- * @param lspKey key to add the LSP
- * @param lspWrapper LSP wrapper instance
- */
- public void addIsisLsp(String lspKey, LspWrapper lspWrapper) {
- if (!listOfLsp.containsKey(lspKey)) {
- listOfLsp.put(lspKey, lspWrapper);
- lspWrapper.setBinNumber(this.binNumber);
- }
- }
-
- /**
- * Returns the LSP wrapper.
- *
- * @param lspKey LSP key
- * @return LSP wrapper
- */
- public LspWrapper isisLsp(String lspKey) {
- return listOfLsp.get(lspKey);
- }
-
- /**
- * Removes ISIS LSP from database.
- *
- * @param lspKey LSP key
- * @param lspWrapper LSP wrapper instance
- */
- public void removeIsisLsp(String lspKey, LspWrapper lspWrapper) {
- if (listOfLsp.containsKey(lspKey)) {
- listOfLsp.remove(lspKey);
- }
- }
-
- /**
- * Returns all LSP wrappers.
- *
- * @return all LSP wrappers
- */
- public Map<String, LspWrapper> listOfLsp() {
- return listOfLsp;
- }
-
- /**
- * Returns the bin number.
- *
- * @return the bin number
- */
- public int binNumber() {
- return binNumber;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("binNumber", binNumber)
- .add("listOfLsp", listOfLsp)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapper.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapper.java
deleted file mode 100644
index 864b08e..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapper.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl.lsdb;
-
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisLsdbAge;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.controller.LspWrapper;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-import org.onosproject.isis.io.util.IsisConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Representation of LSP wrapper where the LSPs are stored with metadata.
- */
-public class DefaultLspWrapper implements LspWrapper {
- private static final Logger log = LoggerFactory.getLogger(DefaultLspWrapper.class);
- private int binNumber = -1;
- private boolean selfOriginated = false;
- private IsisPduType lspType;
- private int lspAgeReceived;
- private int ageCounterWhenReceived;
- private LsPdu lsPdu;
- private IsisLsdbAge lsdbAge;
- private int ageCounterRollOverWhenAdded;
- private int remainingLifetime;
- private IsisInterface isisInterface;
- private String lspProcessing;
-
- /**
- * Returns "refreshLsp" or "maxageLsp" based on LSP to process.
- *
- * @return LSP processing string
- */
- public String lspProcessing() {
- return lspProcessing;
- }
-
- /**
- * Sets LSP processing "refreshLsp" or "maxageLsp" based on LSP to process.
- *
- * @param lspProcessing "refreshLsp" or "maxageLsp" based on LSP to process
- */
- public void setLspProcessing(String lspProcessing) {
- this.lspProcessing = lspProcessing;
- }
-
- /**
- * Returns LSP age received.
- *
- * @return LSP age received
- */
- public int lspAgeReceived() {
- return lspAgeReceived;
- }
-
- /**
- * Sets LSP age received.
- *
- * @param lspAgeReceived LSP age received.
- */
- public void setLspAgeReceived(int lspAgeReceived) {
- this.lspAgeReceived = lspAgeReceived;
- }
-
- /**
- * Returns ISIS interface instance.
- *
- * @return ISIS interface instance
- */
- public IsisInterface isisInterface() {
- return isisInterface;
- }
-
- /**
- * Sets ISIS interface.
- *
- * @param isisInterface ISIS interface instance
- */
- public void setIsisInterface(IsisInterface isisInterface) {
- this.isisInterface = isisInterface;
- }
-
- /**
- * Returns age counter when received.
- *
- * @return age counter when received
- */
- public int ageCounterWhenReceived() {
-
- return ageCounterWhenReceived;
- }
-
- /**
- * Sets age counter when received.
- *
- * @param ageCounterWhenReceived age counter when received
- */
- public void setAgeCounterWhenReceived(int ageCounterWhenReceived) {
- this.ageCounterWhenReceived = ageCounterWhenReceived;
- }
-
- /**
- * Returns age counter roll over.
- *
- * @return age counter roll over
- */
- public int ageCounterRollOverWhenAdded() {
- return ageCounterRollOverWhenAdded;
- }
-
- /**
- * Sets age counter roll over when added.
- *
- * @param ageCounterRollOverWhenAdded age counter roll over when added
- */
- public void setAgeCounterRollOverWhenAdded(int ageCounterRollOverWhenAdded) {
- this.ageCounterRollOverWhenAdded = ageCounterRollOverWhenAdded;
- }
-
- /**
- * Returns bin number.
- *
- * @return bin number
- */
- public int binNumber() {
- return binNumber;
- }
-
- /**
- * Sets bin number.
- *
- * @param binNumber bin number
- */
- public void setBinNumber(int binNumber) {
- this.binNumber = binNumber;
- }
-
- /**
- * Returns true if self originated.
- *
- * @return true if self originated.
- */
- public boolean isSelfOriginated() {
- return selfOriginated;
- }
-
- /**
- * Sets true if self originated.
- *
- * @param selfOriginated true if self originated else false
- */
- public void setSelfOriginated(boolean selfOriginated) {
- this.selfOriginated = selfOriginated;
- }
-
- /**
- * Returns ISIS PDU type.
- *
- * @return ISIS PDU type
- */
- public IsisPduType lspType() {
- return lspType;
- }
-
- /**
- * Sets ISIS PDU type.
- *
- * @param lspType ISIS PDU type
- */
- public void setLspType(IsisPduType lspType) {
- this.lspType = lspType;
- }
-
- /**
- * Returns LSPDU which the wrapper contains.
- *
- * @return LSPDU which the wrapper contains
- */
- public LsPdu lsPdu() {
- return lsPdu;
- }
-
- /**
- * Sets LSPDU which the wrapper contains.
- *
- * @param lsPdu LSPDU which the wrapper contains
- */
- public void setLsPdu(LsPdu lsPdu) {
- this.lsPdu = lsPdu;
- }
-
- /**
- * Returns ISIS LSDB age.
- *
- * @return ISIS LSDB age
- */
- public IsisLsdbAge lsdbAge() {
- return lsdbAge;
- }
-
- /**
- * Sets LSDB age.
- *
- * @param lsdbAge LSDB age
- */
- public void setLsdbAge(IsisLsdbAge lsdbAge) {
- this.lsdbAge = lsdbAge;
- }
-
- /**
- * Returns the current LSP Age.
- *
- * @return LSP age
- */
- public int currentAge() {
-
- int currentAge = 0;
- //ls age received
- if (lsdbAge.ageCounter() >= ageCounterWhenReceived) {
- if (!selfOriginated) {
- if (ageCounterRollOverWhenAdded == lsdbAge.ageCounterRollOver()) {
- currentAge = lspAgeReceived + (lsdbAge.ageCounter() - ageCounterWhenReceived);
- } else {
- return IsisConstants.LSPMAXAGE;
- }
- } else {
- currentAge = lspAgeReceived + (lsdbAge.ageCounter() - ageCounterWhenReceived);
- }
- } else {
- currentAge = lspAgeReceived + ((IsisConstants.LSPMAXAGE + lsdbAge.ageCounter())
- - ageCounterWhenReceived);
- }
-
- if (currentAge >= IsisConstants.LSPMAXAGE) {
- return IsisConstants.LSPMAXAGE;
- } else if ((currentAge == lspAgeReceived) && ageCounterRollOverWhenAdded
- != lsdbAge.ageCounterRollOver()) {
- return IsisConstants.LSPMAXAGE;
- }
-
- return currentAge;
- }
-
-
-
- /**
- * Returns remaining time.
- *
- * @return remaining time
- */
- public int remainingLifetime() {
- //Calculate the remaining lifetime
- remainingLifetime = IsisConstants.LSPMAXAGE - currentAge();
- return remainingLifetime;
- }
-
- /**
- * Sets remaining life time.
- *
- * @param remainingLifetime LSPs remaining life time
- */
- public void setRemainingLifetime(int remainingLifetime) {
- this.remainingLifetime = remainingLifetime;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java
deleted file mode 100644
index ddee647..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl.lsdb;
-
-import org.jboss.netty.channel.Channel;
-import org.onosproject.isis.controller.IsisLsdb;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.controller.LspWrapper;
-import org.onosproject.isis.controller.impl.DefaultIsisInterface;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-import org.onosproject.isis.io.util.IsisConstants;
-import org.onosproject.isis.io.util.IsisUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.BlockingQueue;
-
-/**
- * Representation of LSP queue consumer.
- */
-public class IsisLspQueueConsumer implements Runnable {
- private static final Logger log = LoggerFactory.getLogger(IsisLspQueueConsumer.class);
- private BlockingQueue queue = null;
-
- /**
- * Creates an instance of LSP queue consumer.
- *
- * @param queue queue instance
- */
- public IsisLspQueueConsumer(BlockingQueue queue) {
- this.queue = queue;
- }
-
- /**
- * Gets the LSP wrapper instance from queue and process it.
- */
- @Override
- public void run() {
- log.debug("LSPQueueConsumer:run...!!!");
- try {
- while (true) {
- if (!queue.isEmpty()) {
- LspWrapper wrapper = (LspWrapper) queue.take();
- String lspProcessing = wrapper.lspProcessing();
- switch (lspProcessing) {
- case IsisConstants.REFRESHLSP:
- log.debug("LSPQueueConsumer: Message - " + IsisConstants.REFRESHLSP +
- " consumed.");
- processRefreshLsp(wrapper);
- break;
- case IsisConstants.MAXAGELSP:
- log.debug("LSPQueueConsumer: Message - " + IsisConstants.MAXAGELSP +
- " consumed.");
- processMaxAgeLsa(wrapper);
- break;
- default:
- log.debug("Unknown command to process the LSP in queue ...!!!");
- break;
- }
- }
- }
- } catch (Exception e) {
- log.debug("Error::LSPQueueConsumer::{}", e.getMessage());
- }
- }
-
- /**
- * Process refresh LSP.
- *
- * @param wrapper LSP wrapper instance
- */
- private void processRefreshLsp(LspWrapper wrapper) {
- if (wrapper.isSelfOriginated()) { //self originated
- DefaultIsisInterface isisInterface = (DefaultIsisInterface) wrapper.isisInterface();
- Channel channel = isisInterface.channel();
- if (channel != null && channel.isConnected()) {
- LsPdu lsPdu = (LsPdu) wrapper.lsPdu();
- lsPdu.setSequenceNumber(isisInterface.isisLsdb().lsSequenceNumber(
- IsisPduType.get(lsPdu.pduType())));
- lsPdu.setRemainingLifeTime(IsisConstants.LSPMAXAGE);
- byte[] lspBytes = lsPdu.asBytes();
- lspBytes = IsisUtil.addLengthAndMarkItInReserved(lspBytes, IsisConstants.LENGTHPOSITION,
- IsisConstants.LENGTHPOSITION + 1,
- IsisConstants.RESERVEDPOSITION);
- lspBytes = IsisUtil.addChecksum(lspBytes, IsisConstants.CHECKSUMPOSITION,
- IsisConstants.CHECKSUMPOSITION + 1);
- //write to the channel
- channel.write(IsisUtil.framePacket(lspBytes, isisInterface.interfaceIndex()));
- // Updating the database with resetting remaining life time to default.
- IsisLsdb isisDb = isisInterface.isisLsdb();
- isisDb.addLsp(lsPdu, true, isisInterface);
- log.debug("LSPQueueConsumer: processRefreshLsp - Flooded SelfOriginated LSP {}",
- wrapper.lsPdu());
- }
- }
- }
-
- /**
- * Process max age LSP.
- *
- * @param wrapper LSP wrapper instance
- */
- private void processMaxAgeLsa(LspWrapper wrapper) {
- //set the destination
- DefaultIsisInterface isisInterface = (DefaultIsisInterface) wrapper.isisInterface();
- if (isisInterface != null) {
- //delete from db
- LsPdu lsPdu = (LsPdu) wrapper.lsPdu();
- IsisLsdb isisDb = isisInterface.isisLsdb();
- isisDb.deleteLsp(lsPdu);
- log.debug("LSPQueueConsumer: processMaxAgeLsp - Removed-Max Age LSP {}",
- wrapper.lsPdu());
- }
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/package-info.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/package-info.java
deleted file mode 100644
index 5fe5451..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ISIS controller LSDB and related functionality.
- */
-package org.onosproject.isis.controller.impl.lsdb;
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/package-info.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/package-info.java
deleted file mode 100644
index 1dc02f0..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ISIS controller.
- */
-package org.onosproject.isis.controller.impl;
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLink.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLink.java
deleted file mode 100644
index 9c1e1c4..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLink.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.isis.controller.impl.topology;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.isis.controller.topology.IsisLink;
-import org.onosproject.isis.controller.topology.IsisLinkTed;
-
-/**
- * Representation of an ISIS Link.
- */
-public class DefaultIsisLink implements IsisLink {
-
- private String remoteSystemId;
- private String localSystemId;
- private Ip4Address interfaceIp;
- private Ip4Address neighborIp;
- private IsisLinkTed linkTed;
-
- @Override
- public String remoteSystemId() {
- return this.remoteSystemId;
- }
-
- @Override
- public String localSystemId() {
- return this.localSystemId;
- }
-
- @Override
- public Ip4Address interfaceIp() {
- return this.interfaceIp;
- }
-
- @Override
- public Ip4Address neighborIp() {
- return this.neighborIp;
- }
-
- @Override
- public IsisLinkTed linkTed() {
- return this.linkTed;
- }
-
- @Override
- public void setRemoteSystemId(String remoteSystemId) {
- this.remoteSystemId = remoteSystemId;
- }
-
- @Override
- public void setLocalSystemId(String localSystemId) {
- this.localSystemId = localSystemId;
- }
-
- @Override
- public void setInterfaceIp(Ip4Address interfaceIp) {
- this.interfaceIp = interfaceIp;
- }
-
- @Override
- public void setNeighborIp(Ip4Address neighborIp) {
- this.neighborIp = neighborIp;
- }
-
- @Override
- public void setLinkTed(IsisLinkTed linkTed) {
- this.linkTed = linkTed;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("remoteSystemId", remoteSystemId)
- .add("localSystemId", localSystemId)
- .add("interfaceIp", interfaceIp)
- .add("neighborIp", neighborIp)
- .add("linkTed", linkTed)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- DefaultIsisLink that = (DefaultIsisLink) o;
- return Objects.equal(remoteSystemId, that.remoteSystemId) &&
- Objects.equal(localSystemId, that.localSystemId) &&
- Objects.equal(interfaceIp, that.interfaceIp) &&
- Objects.equal(neighborIp, that.neighborIp) &&
- Objects.equal(linkTed, that.linkTed);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(remoteSystemId, localSystemId, interfaceIp, neighborIp, linkTed);
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLinkInformation.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLinkInformation.java
deleted file mode 100644
index 815257c..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLinkInformation.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl.topology;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.isis.controller.topology.LinkInformation;
-
-/**
- * Representation of an ISIS link information..
- */
-public class DefaultIsisLinkInformation implements LinkInformation {
-
- String linkId;
- String linkSourceId;
- String linkDestinationId;
- Ip4Address interfaceIp;
- Ip4Address neighborIp;
- boolean alreadyCreated;
-
- /**
- * Gets link id.
- *
- * @return link id
- */
- public String linkId() {
- return linkId;
- }
-
- /**
- * Sets link id.DefaultIsisDeviceInformation.
- *
- * @param linkId link id
- */
- public void setLinkId(String linkId) {
- this.linkId = linkId;
- }
-
- /**
- * Gets is already created or not.
- *
- * @return true if already created else false
- */
- public boolean isAlreadyCreated() {
- return alreadyCreated;
- }
-
- /**
- * Sets is already created or not.
- *
- * @param alreadyCreated true or false
- */
- public void setAlreadyCreated(boolean alreadyCreated) {
- this.alreadyCreated = alreadyCreated;
- }
-
- /**
- * Gets link destination id.
- *
- * @return link destination id
- */
- public String linkDestinationId() {
- return linkDestinationId;
- }
-
- /**
- * Sets link destination id.
- *
- * @param linkDestinationId link destination id
- */
- public void setLinkDestinationId(String linkDestinationId) {
- this.linkDestinationId = linkDestinationId;
- }
-
- /**
- * Gets link source id.
- *
- * @return link source id
- */
- public String linkSourceId() {
- return linkSourceId;
- }
-
- /**
- * Sets link source id.
- *
- * @param linkSourceId link source id
- */
- public void setLinkSourceId(String linkSourceId) {
- this.linkSourceId = linkSourceId;
- }
-
- /**
- * Gets interface IP address.
- *
- * @return interface IP address
- */
- public Ip4Address interfaceIp() {
- return interfaceIp;
- }
-
- /**
- * Sets interface IP address.
- *
- * @param interfaceIp interface IP address
- */
- public void setInterfaceIp(Ip4Address interfaceIp) {
- this.interfaceIp = interfaceIp;
- }
-
- @Override
- public Ip4Address neighborIp() {
- return this.neighborIp;
- }
-
- @Override
- public void setNeighborIp(Ip4Address neighborIp) {
- this.neighborIp = neighborIp;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("linkId", linkId)
- .add("linkSourceId", linkSourceId)
- .add("linkDestinationId", linkDestinationId)
- .add("interfaceIp", interfaceIp)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- DefaultIsisLinkInformation that = (DefaultIsisLinkInformation) o;
- return Objects.equal(linkId, that.linkId) &&
- Objects.equal(linkSourceId, that.linkSourceId) &&
- Objects.equal(linkDestinationId, that.linkDestinationId) &&
- Objects.equal(interfaceIp, that.interfaceIp);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(linkId, linkSourceId, linkDestinationId,
- interfaceIp);
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLinkTed.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLinkTed.java
deleted file mode 100644
index a7fcfa6..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLinkTed.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl.topology;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import org.onlab.packet.Ip4Address;
-import org.onlab.util.Bandwidth;
-import org.onosproject.isis.controller.topology.IsisLinkTed;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of an ISIS device information.
- */
-public class DefaultIsisLinkTed implements IsisLinkTed {
- private int administrativeGroup;
- private Ip4Address ipv4InterfaceAddress;
- private Ip4Address ipv4NeighborAddress;
- private Bandwidth maximumLinkBandwidth;
- private Bandwidth maximumReservableLinkBandwidth;
- private List<Bandwidth> unreservedBandwidth = new ArrayList<>();
- private long teDefaultMetric;
-
- @Override
- public int administrativeGroup() {
- return administrativeGroup;
- }
-
- @Override
- public void setAdministrativeGroup(int administrativeGroup) {
- this.administrativeGroup = administrativeGroup;
- }
-
- @Override
- public Ip4Address ipv4InterfaceAddress() {
- return ipv4InterfaceAddress;
- }
-
- @Override
- public void setIpv4InterfaceAddress(Ip4Address interfaceAddress) {
- this.ipv4InterfaceAddress = interfaceAddress;
- }
-
- @Override
- public Ip4Address ipv4NeighborAddress() {
- return ipv4NeighborAddress;
- }
-
- @Override
- public void setIpv4NeighborAddress(Ip4Address neighborAddress) {
- this.ipv4NeighborAddress = neighborAddress;
- }
-
- @Override
- public Bandwidth maximumLinkBandwidth() {
- return maximumLinkBandwidth;
- }
-
- @Override
- public void setMaximumLinkBandwidth(Bandwidth bandwidth) {
- this.maximumLinkBandwidth = bandwidth;
- }
-
- @Override
- public Bandwidth maximumReservableLinkBandwidth() {
- return maximumReservableLinkBandwidth;
- }
-
- @Override
- public void setMaximumReservableLinkBandwidth(Bandwidth bandwidth) {
- this.maximumReservableLinkBandwidth = bandwidth;
- }
-
- @Override
- public List<Bandwidth> unreservedBandwidth() {
- return this.unreservedBandwidth;
- }
-
- @Override
- public void setUnreservedBandwidth(List<Bandwidth> bandwidth) {
- this.unreservedBandwidth.addAll(bandwidth);
- }
-
- @Override
- public long teDefaultMetric() {
- return teDefaultMetric;
- }
-
- @Override
- public void setTeDefaultMetric(long teMetric) {
- this.teDefaultMetric = teMetric;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("administrativeGroup", administrativeGroup)
- .add("ipv4InterfaceAddress", ipv4InterfaceAddress)
- .add("ipv4NeighborAddress", ipv4NeighborAddress)
- .add("maximumLinkBandwidth", maximumLinkBandwidth)
- .add("maximumReservableLinkBandwidth", maximumReservableLinkBandwidth)
- .add("teDefaultMetric", teDefaultMetric)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- DefaultIsisLinkTed that = (DefaultIsisLinkTed) o;
- return Objects.equal(administrativeGroup, that.administrativeGroup) &&
- Objects.equal(ipv4InterfaceAddress, that.ipv4InterfaceAddress) &&
- Objects.equal(ipv4NeighborAddress, that.ipv4NeighborAddress) &&
- Objects.equal(maximumLinkBandwidth, that.maximumLinkBandwidth) &&
- Objects.equal(maximumReservableLinkBandwidth,
- that.maximumReservableLinkBandwidth) &&
- Objects.equal(teDefaultMetric, that.teDefaultMetric);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(administrativeGroup, ipv4InterfaceAddress,
- ipv4NeighborAddress, maximumLinkBandwidth, teDefaultMetric);
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisRouter.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisRouter.java
deleted file mode 100644
index ec7b5c2..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisRouter.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.isis.controller.impl.topology;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.isis.controller.topology.IsisRouter;
-
-/**
- * Representation of an ISIS Router.
- */
-public class DefaultIsisRouter implements IsisRouter {
-
- private String systemId;
- private Ip4Address neighborRouterId;
- private Ip4Address interfaceId;
- private boolean isDis;
-
- /**
- * Gets the system ID.
- *
- * @return systemId system ID
- */
- public String systemId() {
- return systemId;
- }
-
- /**
- * Sets IP address of the Router.
- *
- * @param systemId system identifier of the router
- */
- public void setSystemId(String systemId) {
- this.systemId = systemId;
- }
-
- /**
- * Gets IP address of the interface.
- *
- * @return IP address of the interface
- */
- public Ip4Address interfaceId() {
- return interfaceId;
- }
-
- /**
- * Gets IP address of the interface.
- *
- * @param interfaceId IP address of the interface
- */
- public void setInterfaceId(Ip4Address interfaceId) {
- this.interfaceId = interfaceId;
- }
-
- /**
- * Gets neighbor's Router id.
- *
- * @return neighbor's Router id
- */
- public Ip4Address neighborRouterId() {
- return neighborRouterId;
- }
-
- /**
- * Sets neighbor's Router id.
- *
- * @param advertisingRouterId neighbor's Router id
- */
- public void setNeighborRouterId(Ip4Address advertisingRouterId) {
- this.neighborRouterId = advertisingRouterId;
- }
-
- /**
- * Gets if DR or not.
- *
- * @return true if DR else false
- */
- public boolean isDis() {
- return isDis;
- }
-
- /**
- * Sets dis or not.
- *
- * @param dis true if DIS else false
- */
- public void setDis(boolean dis) {
- isDis = dis;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("systemId", systemId)
- .add("neighborRouterId", neighborRouterId)
- .add("interfaceId", interfaceId)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- DefaultIsisRouter that = (DefaultIsisRouter) o;
- return Objects.equal(systemId, that.systemId) &&
- Objects.equal(neighborRouterId, that.neighborRouterId) &&
- Objects.equal(interfaceId, that.interfaceId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(systemId, neighborRouterId, interfaceId);
- }
-}
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/TopologyForDeviceAndLinkImpl.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/TopologyForDeviceAndLinkImpl.java
deleted file mode 100644
index 3c52308..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/TopologyForDeviceAndLinkImpl.java
+++ /dev/null
@@ -1,491 +0,0 @@
-/*
-* Copyright 2016-present Open Networking Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.onosproject.isis.controller.impl.topology;
-
-import org.onlab.util.Bandwidth;
-import org.onosproject.isis.controller.topology.DeviceInformation;
-import org.onosproject.isis.controller.topology.IsisRouter;
-import org.onosproject.isis.controller.topology.LinkInformation;
-import org.onosproject.isis.controller.topology.TopologyForDeviceAndLink;
-import org.onosproject.isis.controller.topology.IsisLinkTed;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-import org.onosproject.isis.io.isispacket.tlv.IsExtendedReachability;
-import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
-import org.onosproject.isis.io.isispacket.tlv.NeighborForExtendedIs;
-
-import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.InterfaceIpAddress;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.NeighborIpAddress;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.AdministrativeGroup;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringMetric;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.UnreservedBandwidth;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumReservableBandwidth;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumBandwidth;
-import org.onosproject.isis.io.util.IsisConstants;
-import org.onosproject.isis.io.util.IsisUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Represents device and link topology information.
- */
-public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink {
-
- private static final Logger log = LoggerFactory.getLogger(TopologyForDeviceAndLinkImpl.class);
- private Map<String, DeviceInformation> deviceInformationMap = new LinkedHashMap<>();
- private Map<String, IsisRouter> isisRouterDetails = new LinkedHashMap<>();
- private Map<String, DeviceInformation> deviceInformationMapForPointToPoint = new LinkedHashMap<>();
- private Map<String, DeviceInformation> deviceInformationMapToDelete = new LinkedHashMap<>();
- private Map<String, LinkInformation> addedLinkInformationMap = new LinkedHashMap<>();
-
- /**
- * Gets device information.
- *
- * @return device information
- */
- public Map<String, DeviceInformation> deviceInformationMap() {
- return deviceInformationMap;
- }
-
- /**
- * Gets ISIS router list information.
- *
- * @return router information
- */
- public Map<String, IsisRouter> isisDeviceList() {
- return isisRouterDetails;
- }
-
- /**
- * Sets device information.
- *
- * @param key key used to add in map
- * @param deviceInformationMap device information instance
- */
- public void setDeviceInformationMap(String key, DeviceInformation deviceInformationMap) {
- if (deviceInformationMap != null) {
- this.deviceInformationMap.put(key, deviceInformationMap);
- }
-
- }
-
- /**
- * Gets deviceInformation as map for Point-To-Point.
- *
- * @return deviceInformationMap
- */
- public Map<String, DeviceInformation> deviceInformationMapForPointToPoint() {
- return deviceInformationMapForPointToPoint;
- }
-
- /**
- * Sets deviceInformation as map for Point-To-Point..
- *
- * @param key key used to add in map
- * @param deviceInformationMap device information instance
- */
- public void setDeviceInformationMapForPointToPoint(String key, DeviceInformation deviceInformationMap) {
- if (deviceInformationMap != null) {
- this.deviceInformationMapForPointToPoint.put(key, deviceInformationMap);
- }
-
- }
-
- /**
- * Gets deviceInformation as map.
- *
- * @return deviceInformationMap to delete from core
- */
- public Map<String, DeviceInformation> deviceInformationMapToDelete() {
- return deviceInformationMapToDelete;
- }
-
- /**
- * Sets device information for removal.
- *
- * @param key ket used to add in map
- * @param deviceInformationMapToDelete map from device information to remove
- */
- public void setDeviceInformationMapToDelete(String key, DeviceInformation deviceInformationMapToDelete) {
- if (deviceInformationMapToDelete != null) {
- this.deviceInformationMapToDelete.put(key, deviceInformationMapToDelete);
- }
- }
-
- /**
- * Removes Device Information.
- *
- * @param key ket used to remove from map
- */
- public void removeDeviceInformationMapFromDeleteMap(String key) {
- removeDeviceInformationMap(key);
- if (this.deviceInformationMapToDelete.containsKey(key)) {
- this.deviceInformationMapToDelete.remove(key);
- }
- }
-
- /**
- * Gets Device Information.
- *
- * @param key system id as key to store in map
- * @return Device Information
- */
- public DeviceInformation deviceInformation(String key) {
- DeviceInformation deviceInformation = this.deviceInformationMap.get(key);
- return deviceInformation;
- }
-
- /**
- * Removes Device Information from map.
- *
- * @param key key used to remove from map
- */
- public void removeDeviceInformationMap(String key) {
- if (this.deviceInformationMap.containsKey(key)) {
- this.deviceInformationMap.remove(key);
- }
- }
-
- @Override
- public void removeLinks(String linkId) {
- this.addedLinkInformationMap.remove(linkId);
- }
-
- /**
- * Gets link information as map.
- *
- * @return link information as map
- */
- public Map<String, LinkInformation> linkInformationMap() {
- return addedLinkInformationMap;
- }
-
- private LinkInformation getLinkInformation(String key) {
- LinkInformation linkInformation = this.addedLinkInformationMap.get(key);
- return linkInformation;
- }
-
- /**
- * Sets link information in map.
- *
- * @param key key used to add in map
- * @param linkInformationMap link information instance
- */
- public void setLinkInformationMap(String key, LinkInformation linkInformationMap) {
- if (!this.addedLinkInformationMap.containsKey(key)) {
- this.addedLinkInformationMap.put(key, linkInformationMap);
- }
- }
-
- /**
- * Gets linkInformation as map for PointToPoint.
- *
- * @return linkInformationMap
- */
- public Map<String, LinkInformation> linkInformationMapForPointToPoint() {
- return addedLinkInformationMap;
- }
-
- /**
- * Sets linkInformation as map for PointToPoint.
- *
- * @param key key used to add in map
- * @param linkInformationMap link information instance
- */
- public void setLinkInformationMapForPointToPoint(String key, LinkInformation linkInformationMap) {
- if (!this.addedLinkInformationMap.containsKey(key)) {
- this.addedLinkInformationMap.put(key, linkInformationMap);
- }
- }
-
- /**
- * Removes Link Information from linkInformationMap.
- *
- * @param key key used to remove in map
- */
- public void removeLinkInformationMap(String key) {
- if (this.addedLinkInformationMap.containsKey(key)) {
- this.addedLinkInformationMap.remove(key);
- }
- }
-
- /**
- * Returns the ISIS router instance.
- *
- * @param systemId system ID to get router details
- * @return ISIS router instance
- */
- public IsisRouter isisRouter(String systemId) {
- String routerId = IsisUtil.removeTailingZeros(systemId);
- IsisRouter isisRouter = isisRouterDetails.get(routerId);
- if (isisRouter != null) {
- return isisRouter;
- } else {
- log.debug("IsisRouter is not available");
- IsisRouter isisRouterCheck = new DefaultIsisRouter();
- isisRouterCheck.setSystemId(routerId);
- return isisRouterCheck;
- }
- }
-
- /**
- * Removes the ISIS router instance from map.
- *
- * @param systemId system ID to remove router details
- */
- public void removeRouter(String systemId) {
- String routerId = IsisUtil.removeTailingZeros(systemId);
- isisRouterDetails.remove(systemId);
- }
-
- /**
- * Creates Device instance.
- *
- * @param lsPdu ISIS LSPDU instance
- * @return isisRouter isisRouter instance
- */
- public IsisRouter createDeviceInfo(LsPdu lsPdu) {
- IsisRouter isisRouter = createIsisRouter(lsPdu);
-
- if (isisRouter.systemId() != null) {
- if (isisRouter.interfaceId() == null && isisRouter.neighborRouterId() == null) {
- isisRouter.setInterfaceId(IsisConstants.DEFAULTIP);
- isisRouter.setNeighborRouterId(IsisConstants.DEFAULTIP);
- isisRouterDetails.put(isisRouter.systemId(), isisRouter);
- }
- }
- return isisRouter;
- }
-
- /**
- * Removes Device and Link instance.
- *
- * @param lsPdu ISIS LSPDU instance
- * @return isisRouter isisRouter instance
- */
- /*
- public IsisRouter removeDeviceAndLinkInfo(LsPdu lsPdu) {
- IsisRouter isisRouter = createIsisRouter(lsPdu);
- return isisRouter;
- }*/
-
- /**
- * Creates link information.
- *
- * @param lsPdu ls pdu instance
- * @param ownSystemId system ID
- * @return link information
- */
- public Map<String, LinkInformation> createLinkInfo(LsPdu lsPdu, String ownSystemId) {
- for (IsisTlv isisTlv : lsPdu.tlvs()) {
- if (isisTlv instanceof IsExtendedReachability) {
- IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
- List<NeighborForExtendedIs> neighborForExtendedIsList = isExtendedReachability.neighbours();
- for (NeighborForExtendedIs neighbor : neighborForExtendedIsList) {
- String neighbourId = neighbor.neighborId();
- String routerId = IsisUtil.removeTailingZeros(lsPdu.lspId());
- if (!(neighbourId.equals(ownSystemId))) {
- IsisRouter isisRouter = isisRouterDetails.get(neighbourId);
- if (isisRouter != null) {
- String linkId = "link:" + routerId + "-" + neighbourId;
- addedLinkInformationMap.put(linkId, createLinkInformation(lsPdu, linkId,
- routerId, neighbourId));
- } else {
- createIsisRouterDummy(neighbourId);
- String linkId = "link:" + routerId + "-" + neighbourId;
- LinkInformation linkInformation = createLinkInformation(lsPdu, linkId,
- routerId, neighbourId);
- linkInformation.setAlreadyCreated(true);
- addedLinkInformationMap.put(linkId, linkInformation);
- }
- }
-
- }
- }
- }
- return addedLinkInformationMap;
- }
-
- /**
- * Removes link information.
- *
- * @param systemId system ID to remove link information
- * @return updated link information
- */
- public Map<String, LinkInformation> removeLinkInfo(String systemId) {
- String routerId = IsisUtil.removeTailingZeros(systemId);
- Map<String, LinkInformation> removeLinkInformationMap = new LinkedHashMap<>();
- for (String key : addedLinkInformationMap.keySet()) {
- if (key.contains(routerId)) {
- removeLinkInformationMap.put(key, addedLinkInformationMap.get(key));
- }
- }
- return removeLinkInformationMap;
- }
-
- /**
- * Creates link information.
- *
- * @param lsPdu link state pdu
- * @param linkId link id
- * @param localRouter local router system id
- * @param neighborId destination router system id
- * @return linkInformation instance
- */
- private LinkInformation createLinkInformation(LsPdu lsPdu, String linkId, String localRouter, String neighborId) {
- LinkInformation linkInformation = new DefaultIsisLinkInformation();
- IsisRouter isisRouter = isisRouterDetails.get(neighborId);
- for (IsisTlv isisTlv : lsPdu.tlvs()) {
- if (isisTlv instanceof IsExtendedReachability) {
- IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
- List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
- for (NeighborForExtendedIs teTlv : neighbours) {
- List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv();
- for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) {
- if (teSubTlv instanceof InterfaceIpAddress) {
- InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv;
- linkInformation.setInterfaceIp(localIpAddress.localInterfaceIPAddress());
- } else if (teSubTlv instanceof NeighborIpAddress) {
- NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv;
- linkInformation.setNeighborIp(neighborIpAddress.neighborIPAddress());
- }
-
- }
- }
- }
- }
- linkInformation.setLinkId(linkId);
- linkInformation.setAlreadyCreated(false);
- linkInformation.setLinkDestinationId(neighborId);
- linkInformation.setLinkSourceId(localRouter);
- return linkInformation;
- }
-
- /**
- * Creates ISIS router instance.
- *
- * @param lsPdu lsp instance
- * @return isisRouter instance
- */
- private IsisRouter createIsisRouter(LsPdu lsPdu) {
- IsisRouter isisRouter = new DefaultIsisRouter();
- if (IsisUtil.checkIsDis(lsPdu.lspId())) {
- isisRouter.setDis(true);
- } else {
- isisRouter.setDis(false);
- }
- isisRouter.setSystemId(IsisUtil.removeTailingZeros(lsPdu.lspId()));
- for (IsisTlv isisTlv : lsPdu.tlvs()) {
- if (isisTlv instanceof IsExtendedReachability) {
- IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
- List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
- for (NeighborForExtendedIs teTlv : neighbours) {
- List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv();
- for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) {
- if (teSubTlv instanceof InterfaceIpAddress) {
- InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv;
- isisRouter.setInterfaceId(localIpAddress.localInterfaceIPAddress());
- } else if (teSubTlv instanceof NeighborIpAddress) {
- NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv;
- isisRouter.setNeighborRouterId(neighborIpAddress.neighborIPAddress());
- }
-
- }
- }
- }
- }
- return isisRouter;
- }
-
- /**
- * Creates ISIS router instance.
- *
- * @param systemId system ID
- * @return isisRouter instance
- */
- private IsisRouter createIsisRouterDummy(String systemId) {
- IsisRouter isisRouter = new DefaultIsisRouter();
- isisRouter.setSystemId(systemId);
- isisRouter.setDis(false);
- isisRouter.setInterfaceId(IsisConstants.DEFAULTIP);
- isisRouter.setNeighborRouterId(IsisConstants.DEFAULTIP);
-
- return isisRouter;
- }
-
- /**
- * Creates the ISIS link TED information.
- *
- * @param lsPdu link state PDU
- * @return isisLinkTed
- */
- public IsisLinkTed createIsisLinkTedInfo(LsPdu lsPdu) {
- IsisLinkTed isisLinkTed = new DefaultIsisLinkTed();
- for (IsisTlv isisTlv : lsPdu.tlvs()) {
- if (isisTlv instanceof IsExtendedReachability) {
- IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
- List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
- for (NeighborForExtendedIs teTlv : neighbours) {
- List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv();
- for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) {
- if (teSubTlv instanceof AdministrativeGroup) {
- AdministrativeGroup ag = (AdministrativeGroup) teSubTlv;
- isisLinkTed.setAdministrativeGroup(ag.administrativeGroup());
- }
- if (teSubTlv instanceof InterfaceIpAddress) {
- InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv;
- isisLinkTed.setIpv4InterfaceAddress(localIpAddress.localInterfaceIPAddress());
- }
- if (teSubTlv instanceof NeighborIpAddress) {
- NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv;
- isisLinkTed.setIpv4NeighborAddress(neighborIpAddress.neighborIPAddress());
- }
- if (teSubTlv instanceof TrafficEngineeringMetric) {
- TrafficEngineeringMetric teM = (TrafficEngineeringMetric) teSubTlv;
- isisLinkTed.setTeDefaultMetric(teM.getTrafficEngineeringMetricValue());
- }
- if (teSubTlv instanceof MaximumBandwidth) {
- MaximumBandwidth maxLinkBandwidth = (MaximumBandwidth) teSubTlv;
- isisLinkTed.setMaximumLinkBandwidth(
- Bandwidth.bps(maxLinkBandwidth.getMaximumBandwidthValue()));
- }
- if (teSubTlv instanceof MaximumReservableBandwidth) {
- MaximumReservableBandwidth maxReservableBw = (MaximumReservableBandwidth) teSubTlv;
- isisLinkTed.setMaximumReservableLinkBandwidth(
- Bandwidth.bps(maxReservableBw.getMaximumBandwidthValue()));
- }
- if (teSubTlv instanceof UnreservedBandwidth) {
- UnreservedBandwidth unReservedBandwidth = (UnreservedBandwidth) teSubTlv;
- List<Bandwidth> bandwidthList = new ArrayList<>();
- List<Float> unReservedBandwidthList = unReservedBandwidth.unReservedBandwidthValue();
- for (Float unReservedBandwidthFloatValue : unReservedBandwidthList) {
- Bandwidth bandwidth = Bandwidth.bps(unReservedBandwidthFloatValue);
- bandwidthList.add(bandwidth);
- }
- isisLinkTed.setUnreservedBandwidth(bandwidthList);
- }
- }
- }
- }
- }
- return isisLinkTed;
- }
-}
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/package-info.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/package-info.java
deleted file mode 100644
index 8175b80..0000000
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ISIS controller topology.
- */
-package org.onosproject.isis.controller.impl.topology;
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/ControllerTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/ControllerTest.java
deleted file mode 100644
index a5396605..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/ControllerTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.isis.controller.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for ControllerTest.
- */
-public class ControllerTest {
-
- private Controller controller;
- private ObjectMapper mapper;
- private JsonNode jsonNode;
- private JsonNode jsonNode1;
- private String jsonString = "{" +
- " \"processes\": [{" +
- " \"processId\": \"4.4.4.4\"," +
- " \"interface\": [{" +
- " \"interfaceIndex\": \"2\"," +
- " \"macAddress\": \"08:00:27:b7:ab:bf\"," +
- " \"interfaceIp\": \"192.168.56.101\"," +
- " \"networkMask\": \"255.255.255.224\"," +
- " \"intermediateSystemName\": \"ROUTERONE\"," +
- " \"systemId\": \"2929.2929.2929\"," +
- " \"lanId\": \"0000.0000.0000.00\"," +
- " \"idLength\": \"0\"," +
- " \"maxAreaAddresses\": \"3\"," +
- " \"reservedPacketCircuitType\": \"1\"," +
- " \"circuitId\": \"10\"," +
- " \"networkType\": \"2\"," +
- " \"areaAddress\": \"490000\"," +
- " \"areaLength\": \"3\"," +
- " \"lspId\": \"1313131313130000\"," +
- " \"holdingTime\": \"50\"," +
- " \"helloInterval\": \"10\"," +
- " \"priority\": \"0\"" +
- " }]" +
- " }]" +
- "}";
- private String jsonString1 = "{" +
- " \"processes\": {" +
- " \"interface\": [{" +
- " \"interfaceIndex\": \"2\"," +
- " \"interfaceIp\": \"100.100.100.100\"," +
- " \"macAddress\": \"08:00:27:b7:ab:bf\"," +
- " \"networkMask\": \"255.255.255.224\"," +
- " \"intermediateSystemName\": \"ROUTERONE\"," +
- " \"systemId\": \"2929.2929.2929\"," +
- " \"lanId\": \"0000.0000.0000.00\"," +
- " \"idLength\": \"0\"," +
- " \"maxAreaAddresses\": \"3\"," +
- " \"reservedPacketCircuitType\": \"1\"," +
- " \"circuitId\": \"10\"," +
- " \"networkType\": \"2\"," +
- " \"areaAddress\": \"490000\"," +
- " \"areaLength\": \"3\"," +
- " \"lspId\": \"1313131313130000\"," +
- " \"holdingTime\": \"50\"," +
- " \"helloInterval\": \"10\"," +
- " \"priority\": \"0\"" +
- " }]" +
- " }" +
- "}";
-
- @Before
- public void setUp() throws Exception {
- controller = new Controller();
- mapper = new ObjectMapper();
- jsonNode = mapper.readTree(jsonString);
- jsonNode1 = mapper.readTree(jsonString1);
- }
-
- @After
- public void tearDown() throws Exception {
- controller = null;
- }
-
- /**
- * Tests isisDeactivate() method.
- */
- @Test
- public void testIsisDeactivate() throws Exception {
- controller.isisDeactivate();
- assertThat(controller, is(notNullValue()));
- }
-
- /**
- * Tests getAllConfiguredProcesses() method.
- */
- @Test
- public void testGetAllConfiguredProcesses() throws Exception {
- controller.getAllConfiguredProcesses();
- assertThat(controller, is(notNullValue()));
- }
-
- /**
- * Tests updateConfig() method.
- */
- @Test
- public void testUpdateConfig() throws Exception {
- jsonNode.path("interface");
- controller.updateConfig(jsonNode);
- assertThat(controller, is(notNullValue()));
-
- controller.updateConfig(jsonNode1);
- assertThat(controller, is(notNullValue()));
- }
-
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisControllerTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisControllerTest.java
deleted file mode 100644
index 1ae1e58..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisControllerTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.controller.topology.IsisRouterListener;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test case for DefaultIsisController.
- */
-public class DefaultIsisControllerTest {
- private ObjectMapper mapper;
- private JsonNode jsonNode;
- private DefaultIsisController defaultIsisController;
- private String jsonString = "{" +
- " \"processes\": [{" +
- " \"processId\": \"4.4.4.4\"," +
- " \"interface\": [{" +
- " \"interfaceIndex\": \"2\"," +
- " \"macAddress\": \"08:00:27:b7:ab:bf\"," +
- " \"interfaceIp\": \"192.168.56.101\"," +
- " \"networkMask\": \"255.255.255.224\"," +
- " \"intermediateSystemName\": \"ROUTERONE\"," +
- " \"systemId\": \"2929.2929.2929\"," +
- " \"lanId\": \"0000.0000.0000.00\"," +
- " \"idLength\": \"0\"," +
- " \"maxAreaAddresses\": \"3\"," +
- " \"reservedPacketCircuitType\": \"1\"," +
- " \"circuitId\": \"10\"," +
- " \"networkType\": \"2\"," +
- " \"areaAddress\": \"490000\"," +
- " \"areaLength\": \"3\"," +
- " \"lspId\": \"1313131313130000\"," +
- " \"holdingTime\": \"50\"," +
- " \"helloInterval\": \"10\"," +
- " \"priority\": \"0\"" +
- " }]" +
- " }]" +
- "}";
-
- private IsisRouterListener isisRouterListener;
-
- @Before
- public void setUp() throws Exception {
- defaultIsisController = new DefaultIsisController();
- mapper = new ObjectMapper();
- jsonNode = mapper.readTree(jsonString);
- isisRouterListener = EasyMock.createNiceMock(IsisRouterListener.class);
- }
-
- @After
- public void tearDown() throws Exception {
- defaultIsisController = null;
- }
-
- /**
- * Tests activate() method.
- */
- @Test
- public void testActivate() throws Exception {
- defaultIsisController.activate();
- assertThat(defaultIsisController, is(notNullValue()));
- }
-
- /**
- * Tests deactivate() method.
- */
- @Test()
- public void testDeactivate() throws Exception {
- defaultIsisController.activate();
- defaultIsisController.deactivate();
- assertThat(defaultIsisController, is(notNullValue()));
- }
-
- /**
- * Tests allConfiguredProcesses() method.
- */
- @Test
- public void testAllConfiguredProcesses() throws Exception {
- defaultIsisController.allConfiguredProcesses();
- assertThat(defaultIsisController, is(notNullValue()));
- }
-
- /**
- * Tests updateConfig() method.
- */
- @Test
- public void testUpdateConfig() throws Exception {
- defaultIsisController.updateConfig(jsonNode);
- assertThat(defaultIsisController, is(notNullValue()));
- }
-
- /**
- * Tests addRouterListener() method.
- */
- @Test
- public void testaddRouterListener() throws Exception {
- defaultIsisController.addRouterListener(isisRouterListener);
- assertThat(defaultIsisController, is(notNullValue()));
- }
-
- /**
- * Tests removeRouterListener() method.
- */
- @Test
- public void testremoveRouterListener() throws Exception {
- defaultIsisController.removeRouterListener(isisRouterListener);
- assertThat(defaultIsisController, is(notNullValue()));
- }
-}
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisInterfaceTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisInterfaceTest.java
deleted file mode 100644
index 1818c48..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisInterfaceTest.java
+++ /dev/null
@@ -1,877 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.MacAddress;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisInterfaceState;
-import org.onosproject.isis.controller.IsisLsdb;
-import org.onosproject.isis.controller.IsisMessage;
-import org.onosproject.isis.controller.IsisNeighbor;
-import org.onosproject.isis.controller.IsisNetworkType;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.controller.IsisRouterType;
-import org.onosproject.isis.controller.impl.lsdb.DefaultIsisLsdb;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.pdu.Csnp;
-import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-import org.onosproject.isis.io.isispacket.pdu.P2PHelloPdu;
-import org.onosproject.isis.io.isispacket.pdu.Psnp;
-import org.onosproject.isis.io.isispacket.tlv.AdjacencyStateTlv;
-import org.onosproject.isis.io.isispacket.tlv.AreaAddressTlv;
-import org.onosproject.isis.io.isispacket.tlv.LspEntriesTlv;
-import org.onosproject.isis.io.isispacket.tlv.LspEntry;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.isispacket.tlv.TlvType;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test case for DefaultIsisInterface.
- */
-public class DefaultIsisInterfaceTest {
- private final MacAddress macAddress = MacAddress.valueOf("AA:BB:CC:DD:EE:FF");
- private final MacAddress macAddress1 = MacAddress.valueOf("AA:CC:CC:DD:EE:FF");
- private final Ip4Address ip4Address = Ip4Address.valueOf("10.10.0.0");
- private final byte[] mask = {
- (byte) 255, (byte) 255, (byte) 255, (byte) 224
- };
- private final byte[] mask1 = {
- (byte) 0, (byte) 0, (byte) 0, (byte) 0
- };
- private final String intSysName = "ROUTER";
- private final String sysId = "1111.1111.1111";
- private final String areaAddr = "49.002";
- private final byte[] csnpBytes = {
- 0, 67, 18, 52, 18, 52, 0,
- 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1,
- -1, -1, 9, 32, 4, -81, 18, 52, 18, 52, 0, 18, 0, 0, 0,
- 0, 0, 41, -92, -30, 4, -81, 41, 41, 41, 41, 41, 41, 0,
- 0, 0, 0, 0, 1, 91, 126
- };
- private IsisInterfaceState resultIfState;
- private DefaultIsisInterface defaultIsisInterface;
- private IsisHeader isisHeader;
- private IsisInterface isisInterface;
- private Set<MacAddress> resultSet;
- private int resultInt;
- private IsisLsdb resultLsdb;
- private IsisNeighbor resultNeighborList;
- private Ip4Address resultIPv4Addr;
- private MacAddress resultMacAddr;
- private byte[] resultByteArr;
- private String resultStr;
- private IsisNetworkType resultNwType;
- private List<Ip4Address> ip4Addresses = new ArrayList<>();
- private DefaultIsisNeighbor defaultIsisNeighbor;
- private IsisNeighbor result;
- private IsisLsdb result1;
- private Set<MacAddress> result2;
- private Channel result3;
- private IsisMessage isisMessage;
- private IsisLsdb isisLsdb;
- private Channel channel;
- private L1L2HelloPdu helloPdu;
- private LsPdu lsPdu;
- private Csnp csnp;
- private Psnp psnp;
- private P2PHelloPdu p2PHelloPdu;
- private boolean result4;
- private String result5;
-
- @Before
- public void setUp() throws Exception {
- channel = EasyMock.createNiceMock(Channel.class);
- defaultIsisInterface = new DefaultIsisInterface();
- defaultIsisInterface.setInterfaceMacAddress(macAddress);
- isisHeader = new IsisHeader();
- isisHeader.setIrpDiscriminator((byte) 1);
- helloPdu = new L1L2HelloPdu(isisHeader);
- isisInterface = new DefaultIsisInterface();
- defaultIsisNeighbor = new DefaultIsisNeighbor(helloPdu, isisInterface);
- defaultIsisNeighbor.setNeighborMacAddress(macAddress);
- isisLsdb = new DefaultIsisLsdb();
- }
-
- @After
- public void tearDown() throws Exception {
- defaultIsisInterface = null;
- helloPdu = null;
- isisInterface = null;
- resultNeighborList = null;
- }
-
- /**
- * Tests interfaceIndex() getter method.
- */
- @Test
- public void testInterfaceIndex() throws Exception {
- defaultIsisInterface.setInterfaceIndex(2);
- resultInt = defaultIsisInterface.interfaceIndex();
- assertThat(resultInt, is(2));
- }
-
- /**
- * Tests interfaceIndex() setter method.
- */
- @Test
- public void testSetInterfaceIndex() throws Exception {
- defaultIsisInterface.setInterfaceIndex(2);
- resultInt = defaultIsisInterface.interfaceIndex();
- assertThat(resultInt, is(2));
-
- }
-
- /**
- * Tests interfaceIpAddress() getter method.
- */
- @Test
- public void testInterfaceIpAddress() throws Exception {
- defaultIsisInterface.setInterfaceIpAddress(ip4Address);
- resultIPv4Addr = defaultIsisInterface.interfaceIpAddress();
- assertThat(resultIPv4Addr, is(ip4Address));
- }
-
- /**
- * Tests interfaceIpAddress() setter method.
- */
- @Test
- public void testSetInterfaceIpAddress() throws Exception {
- defaultIsisInterface.setInterfaceIpAddress(ip4Address);
- resultIPv4Addr = defaultIsisInterface.interfaceIpAddress();
- assertThat(resultIPv4Addr, is(ip4Address));
- }
-
- /**
- * Tests networkMask() getter method.
- */
- @Test
- public void testNetworkMask() throws Exception {
- defaultIsisInterface.setNetworkMask(mask);
- resultByteArr = defaultIsisInterface.networkMask();
- assertThat(resultByteArr, is(mask));
- }
-
- /**
- * Tests networkMask() setter method.
- */
- @Test
- public void testSetNetworkMask() throws Exception {
- defaultIsisInterface.setNetworkMask(mask);
- resultByteArr = defaultIsisInterface.networkMask();
- assertThat(resultByteArr, is(mask));
- }
-
- /**
- * Tests getInterfaceMacAddress() getter method.
- */
- @Test
- public void testGetInterfaceMacAddress() throws Exception {
- defaultIsisInterface.setInterfaceMacAddress(macAddress);
- resultMacAddr = defaultIsisInterface.getInterfaceMacAddress();
- assertThat(resultMacAddr, is(macAddress));
- }
-
- /**
- * Tests getInterfaceMacAddress() setter method.
- */
- @Test
- public void testSetInterfaceMacAddress() throws Exception {
- defaultIsisInterface.setInterfaceMacAddress(macAddress);
- resultMacAddr = defaultIsisInterface.getInterfaceMacAddress();
- assertThat(resultMacAddr, is(macAddress));
- }
-
- /**
- * Tests intermediateSystemName() getter method.
- */
- @Test
- public void testIntermediateSystemName() throws Exception {
- defaultIsisInterface.setIntermediateSystemName(intSysName);
- resultStr = defaultIsisInterface.intermediateSystemName();
- assertThat(resultStr, is(intSysName));
- }
-
- /**
- * Tests intermediateSystemName() setter method.
- */
- @Test
- public void testSetIntermediateSystemName() throws Exception {
- defaultIsisInterface.setIntermediateSystemName(intSysName);
- resultStr = defaultIsisInterface.intermediateSystemName();
- assertThat(resultStr, is(intSysName));
- }
-
- /**
- * Tests systemId() getter method.
- */
- @Test
- public void testSystemId() throws Exception {
- defaultIsisInterface.setSystemId(sysId);
- resultStr = defaultIsisInterface.systemId();
- assertThat(resultStr, is(sysId));
- }
-
- /**
- * Tests systemId() setter method.
- */
- @Test
- public void testSetSystemId() throws Exception {
- defaultIsisInterface.setSystemId(sysId);
- resultStr = defaultIsisInterface.systemId();
- assertThat(resultStr, is(sysId));
- }
-
- /**
- * Tests l1LanId() getter method.
- */
- @Test
- public void testL1LanId() throws Exception {
- defaultIsisInterface.setL1LanId(sysId);
- resultStr = defaultIsisInterface.l1LanId();
- assertThat(resultStr, is(sysId));
- }
-
- /**
- * Tests l1LanId() setter method.
- */
- @Test
- public void testSetL1LanId() throws Exception {
- defaultIsisInterface.setL1LanId(sysId);
- resultStr = defaultIsisInterface.l1LanId();
- assertThat(resultStr, is(sysId));
- }
-
- /**
- * Tests l2LanId() getter method.
- */
- @Test
- public void testL2LanId() throws Exception {
- defaultIsisInterface.setL2LanId(sysId);
- resultStr = defaultIsisInterface.l2LanId();
- assertThat(resultStr, is(sysId));
- }
-
- /**
- * Tests l2LanId() setter method.
- */
- @Test
- public void testSetL2LanId() throws Exception {
- defaultIsisInterface.setL2LanId(sysId);
- resultStr = defaultIsisInterface.l2LanId();
- assertThat(resultStr, is(sysId));
- }
-
- /**
- * Tests getIdLength() getter method.
- */
- @Test
- public void testGetIdLength() throws Exception {
- defaultIsisInterface.setIdLength(8);
- resultInt = defaultIsisInterface.getIdLength();
- assertThat(resultInt, is(8));
- }
-
- /**
- * Tests getIdLength() setter method.
- */
- @Test
- public void testSetIdLength() throws Exception {
- defaultIsisInterface.setIdLength(8);
- resultInt = defaultIsisInterface.getIdLength();
- assertThat(resultInt, is(8));
- }
-
- /**
- * Tests getMaxAreaAddresses() getter method.
- */
- @Test
- public void testGetMaxAreaAddresses() throws Exception {
- defaultIsisInterface.setMaxAreaAddresses(3);
- resultInt = defaultIsisInterface.getMaxAreaAddresses();
- assertThat(resultInt, is(3));
- }
-
- /**
- * Tests getMaxAreaAddresses() setter method.
- */
- @Test
- public void testSetMaxAreaAddresses() throws Exception {
- defaultIsisInterface.setMaxAreaAddresses(3);
- resultInt = defaultIsisInterface.getMaxAreaAddresses();
- assertThat(resultInt, is(3));
- }
-
- /**
- * Tests setReservedPacketCircuitType() getter method.
- */
- @Test
- public void testReservedPacketCircuitType() throws Exception {
- defaultIsisInterface.setReservedPacketCircuitType(1);
- resultInt = defaultIsisInterface.reservedPacketCircuitType();
- assertThat(resultInt, is(1));
- }
-
- /**
- * Tests setReservedPacketCircuitType() setter method.
- */
- @Test
- public void testSetReservedPacketCircuitType() throws Exception {
- defaultIsisInterface.setReservedPacketCircuitType(1);
- resultInt = defaultIsisInterface.reservedPacketCircuitType();
- assertThat(resultInt, is(1));
- }
-
- /**
- * Tests networkType() getter method.
- */
- @Test
- public void testNetworkType() throws Exception {
- defaultIsisInterface.setNetworkType(IsisNetworkType.BROADCAST);
- resultNwType = defaultIsisInterface.networkType();
- assertThat(resultNwType, is(IsisNetworkType.BROADCAST));
- }
-
- /**
- * Tests networkType() setter method.
- */
- @Test
- public void testSetNetworkType() throws Exception {
- defaultIsisInterface.setNetworkType(IsisNetworkType.BROADCAST);
- resultNwType = defaultIsisInterface.networkType();
- assertThat(resultNwType, is(IsisNetworkType.BROADCAST));
- }
-
- /**
- * Tests areaAddress() getter method.
- */
- @Test
- public void testAreaAddress() throws Exception {
- defaultIsisInterface.setAreaAddress(areaAddr);
- resultStr = defaultIsisInterface.areaAddress();
- assertThat(resultStr, is(areaAddr));
- }
-
- /**
- * Tests areaAddress() setter method.
- */
- @Test
- public void testSetAreaAddress() throws Exception {
- defaultIsisInterface.setAreaAddress(areaAddr);
- resultStr = defaultIsisInterface.areaAddress();
- assertThat(resultStr, is(areaAddr));
- }
-
- /**
- * Tests getAreaLength() getter method.
- */
-
- @Test
- public void testGetAreaLength() throws Exception {
- defaultIsisInterface.setAreaLength(3);
- resultInt = defaultIsisInterface.getAreaLength();
- assertThat(resultInt, is(3));
- }
-
- /**
- * Tests getAreaLength() setter method.
- */
- @Test
- public void testSetAreaLength() throws Exception {
- defaultIsisInterface.setAreaLength(3);
- resultInt = defaultIsisInterface.getAreaLength();
- assertThat(resultInt, is(3));
- }
-
- /**
- * Tests holdingTime() getter method.
- */
- @Test
- public void testHoldingTime() throws Exception {
- defaultIsisInterface.setHoldingTime(10);
- resultInt = defaultIsisInterface.holdingTime();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests holdingTime() setter method.
- */
- @Test
- public void testSetHoldingTime() throws Exception {
- defaultIsisInterface.setHoldingTime(10);
- resultInt = defaultIsisInterface.holdingTime();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests priority() getter method.
- */
- @Test
- public void testPriority() throws Exception {
- defaultIsisInterface.setPriority(1);
- resultInt = defaultIsisInterface.priority();
- assertThat(resultInt, is(1));
- }
-
- /**
- * Tests priority() setter method.
- */
- @Test
- public void testSetPriority() throws Exception {
- defaultIsisInterface.setPriority(1);
- resultInt = defaultIsisInterface.priority();
- assertThat(resultInt, is(1));
- }
-
- /**
- * Tests helloInterval() getter method.
- */
- @Test
- public void testHelloInterval() throws Exception {
- defaultIsisInterface.setHelloInterval(10);
- resultInt = defaultIsisInterface.helloInterval();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests helloInterval() setter method.
- */
- @Test
- public void testSetHelloInterval() throws Exception {
- defaultIsisInterface.setHelloInterval(10);
- resultInt = defaultIsisInterface.helloInterval();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests interfaceState() getter method.
- */
- @Test
- public void testInterfaceState() throws Exception {
- defaultIsisInterface.setInterfaceState(IsisInterfaceState.UP);
- resultIfState = defaultIsisInterface.interfaceState();
- assertThat(resultIfState, is(IsisInterfaceState.UP));
- }
-
- /**
- * Tests interfaceState() setter method.
- */
- @Test
- public void testSetInterfaceState() throws Exception {
- defaultIsisInterface.setInterfaceState(IsisInterfaceState.UP);
- resultIfState = defaultIsisInterface.interfaceState();
- assertThat(resultIfState, is(IsisInterfaceState.UP));
- }
-
- /**
- * Tests setCircuitId() getter method.
- */
- @Test
- public void testCircuitId() throws Exception {
- defaultIsisInterface.setCircuitId(sysId);
- resultStr = defaultIsisInterface.circuitId();
- assertThat(resultStr, is(sysId));
- }
-
- /**
- * Tests setCircuitId() setter method.
- */
- @Test
- public void testSetCircuitId() throws Exception {
- defaultIsisInterface.setCircuitId(sysId);
- resultStr = defaultIsisInterface.circuitId();
- assertThat(resultStr, is(sysId));
- }
-
- /**
- * Tests setAllConfiguredInterfaceIps() setter method.
- */
- @Test
- public void testSetAllConfiguredInterfaceIps() throws Exception {
- ip4Addresses.add(ip4Address);
- defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests setAllConfiguredInterfaceIps() method.
- */
- @Test
- public void testRemoveNeighbor() throws Exception {
- defaultIsisInterface.removeNeighbor(defaultIsisNeighbor);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests lookup() method.
- */
- @Test
- public void testLookup() throws Exception {
- result = defaultIsisInterface.lookup(defaultIsisNeighbor.neighborMacAddress());
- assertThat(result, is(nullValue()));
- }
-
- /**
- * Tests isisLsdb() method.
- */
- @Test
- public void testIsisLsdb() throws Exception {
- result1 = defaultIsisInterface.isisLsdb();
- assertThat(result1, is(nullValue()));
- }
-
- /**
- * Tests neighbors() method.
- */
- @Test
- public void testNeighbors() throws Exception {
- result2 = defaultIsisInterface.neighbors();
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests channel() method.
- */
- @Test
- public void testChannel() throws Exception {
- result3 = defaultIsisInterface.channel();
- assertThat(result3, is(nullValue()));
- }
-
- /**
- * Tests processIsisMessage() method.
- */
- @Test
- public void testProcessIsisMessage() throws Exception {
- helloPdu = new L1L2HelloPdu(isisHeader);
- helloPdu.setSourceMac(macAddress1);
- helloPdu.setIsisPduType(IsisPduType.L2HELLOPDU.value());
- defaultIsisInterface.setNetworkType(IsisNetworkType.BROADCAST);
- isisMessage = helloPdu;
- defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests processIsisMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessIsisMessage1() throws Exception {
- lsPdu = new LsPdu(isisHeader);
- lsPdu.setSourceMac(macAddress1);
- lsPdu.setIsisPduType(IsisPduType.L2LSPDU.value());
- isisMessage = lsPdu;
- defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests processIsisMessage() method.
- */
- @Test
- public void testProcessIsisMessage2() throws Exception {
- csnp = new Csnp(isisHeader);
- csnp.setSourceMac(macAddress1);
- csnp.setIsisPduType(IsisPduType.L2CSNP.value());
- isisMessage = csnp;
- defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests processIsisMessage() method.
- */
- @Test
- public void testProcessIsisMessage3() throws Exception {
- psnp = new Psnp(isisHeader);
- psnp.setSourceMac(macAddress1);
- psnp.setIsisPduType(IsisPduType.L2PSNP.value());
- isisMessage = psnp;
- defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests processIsisMessage() method.
- */
- @Test
- public void testProcessIsisMessage4() throws Exception {
- p2PHelloPdu = new P2PHelloPdu(isisHeader);
- p2PHelloPdu.setSourceMac(macAddress1);
- p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
- defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
- isisMessage = p2PHelloPdu;
- defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests validateHelloMessage() method.
- */
- @Test
- public void testValidateHelloMessage() throws Exception {
- helloPdu = new L1L2HelloPdu(isisHeader);
- result4 = defaultIsisInterface.validateHelloMessage(helloPdu);
- assertThat(result4, is(false));
- }
-
- /**
- * Tests processL1L2HelloPduMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessL1L2HelloPduMessage() throws Exception {
- helloPdu = new L1L2HelloPdu(isisHeader);
- helloPdu.setSourceMac(macAddress1);
- helloPdu.setCircuitType((byte) IsisRouterType.L2.value());
- defaultIsisInterface.processL1L2HelloPduMessage(helloPdu, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests processP2pHelloPduMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessP2pHelloPduMessagee() throws Exception {
- defaultIsisInterface.setSystemId(sysId);
- p2PHelloPdu = new P2PHelloPdu(isisHeader);
- p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
- p2PHelloPdu.setSourceMac(macAddress1);
- p2PHelloPdu.setCircuitType((byte) IsisRouterType.L2.value());
- defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
- defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests processP2pHelloPduMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessP2pHelloPduMessagee1() throws Exception {
- defaultIsisInterface.setSystemId(sysId);
- p2PHelloPdu = new P2PHelloPdu(isisHeader);
- p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
- p2PHelloPdu.setSourceMac(macAddress1);
- p2PHelloPdu.setCircuitType((byte) IsisRouterType.L2.value());
- defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
- defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L2.value());
- defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
- defaultIsisInterface.setInterfaceIpAddress(ip4Address);
- defaultIsisInterface.setNetworkMask(mask1);
- defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests processP2pHelloPduMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessP2pHelloPduMessagee2() throws Exception {
- defaultIsisInterface.setSystemId(sysId);
- p2PHelloPdu = new P2PHelloPdu(isisHeader);
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
- AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
- areaAddressTlv.addAddress(areaAddr);
- p2PHelloPdu.addTlv(areaAddressTlv);
- p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
- p2PHelloPdu.setSourceMac(macAddress1);
- p2PHelloPdu.setCircuitType((byte) IsisRouterType.L1.value());
- defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
- defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L1.value());
- defaultIsisInterface.setAreaAddress(areaAddr);
- defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
- defaultIsisInterface.setInterfaceIpAddress(ip4Address);
- defaultIsisInterface.setNetworkMask(mask1);
- defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests processP2pHelloPduMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessP2pHelloPduMessagee3() throws Exception {
- defaultIsisInterface.setSystemId(sysId);
- p2PHelloPdu = new P2PHelloPdu(isisHeader);
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.ADJACENCYSTATE.value());
- AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader);
- adjacencyStateTlv.setNeighborSystemId(sysId);
- adjacencyStateTlv.setAdjacencyType((byte) IsisInterfaceState.DOWN.value());
- p2PHelloPdu.addTlv(adjacencyStateTlv);
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
- AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
- areaAddressTlv.addAddress(areaAddr);
- p2PHelloPdu.addTlv(areaAddressTlv);
- p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
- p2PHelloPdu.setSourceMac(macAddress1);
- p2PHelloPdu.setCircuitType((byte) IsisRouterType.L1.value());
- defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
- defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L1.value());
- defaultIsisInterface.setAreaAddress(areaAddr);
- defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
- defaultIsisInterface.setInterfaceIpAddress(ip4Address);
- defaultIsisInterface.setNetworkMask(mask1);
- defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests processP2pHelloPduMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessP2pHelloPduMessagee4() throws Exception {
- defaultIsisInterface.setSystemId(sysId);
- p2PHelloPdu = new P2PHelloPdu(isisHeader);
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.ADJACENCYSTATE.value());
- AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader);
- adjacencyStateTlv.setNeighborSystemId(sysId);
- adjacencyStateTlv.setAdjacencyType((byte) IsisInterfaceState.INITIAL.value());
- p2PHelloPdu.addTlv(adjacencyStateTlv);
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
- AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
- areaAddressTlv.addAddress(areaAddr);
- p2PHelloPdu.addTlv(areaAddressTlv);
- p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
- p2PHelloPdu.setSourceMac(macAddress1);
- p2PHelloPdu.setCircuitType((byte) IsisRouterType.L1.value());
- defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
- defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L1L2.value());
- defaultIsisInterface.setAreaAddress(areaAddr);
- defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
- defaultIsisInterface.setInterfaceIpAddress(ip4Address);
- defaultIsisInterface.setNetworkMask(mask1);
- defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- @Test(expected = Exception.class)
- public void testProcessP2pHelloPduMessagee5() throws Exception {
- defaultIsisInterface.setSystemId(sysId);
- p2PHelloPdu = new P2PHelloPdu(isisHeader);
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.ADJACENCYSTATE.value());
- AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader);
- adjacencyStateTlv.setNeighborSystemId(sysId);
- adjacencyStateTlv.setAdjacencyType((byte) IsisInterfaceState.UP.value());
- p2PHelloPdu.addTlv(adjacencyStateTlv);
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
- AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
- areaAddressTlv.addAddress(areaAddr);
- p2PHelloPdu.addTlv(areaAddressTlv);
- p2PHelloPdu.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
- p2PHelloPdu.setSourceMac(macAddress1);
- p2PHelloPdu.setCircuitType((byte) IsisRouterType.L2.value());
- defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
- defaultIsisInterface.setReservedPacketCircuitType(IsisRouterType.L1L2.value());
- defaultIsisInterface.setAreaAddress(areaAddr);
- defaultIsisInterface.setAllConfiguredInterfaceIps(ip4Addresses);
- defaultIsisInterface.setInterfaceIpAddress(ip4Address);
- defaultIsisInterface.setNetworkMask(mask1);
- defaultIsisInterface.processIsisMessage(p2PHelloPdu, isisLsdb, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests startHelloSender() method.
- */
- @Test(expected = Exception.class)
- public void testStartHelloSender() throws Exception {
- defaultIsisInterface.startHelloSender(channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests lspKeyP2P() method.
- */
- @Test
- public void testLspKeyP2P() throws Exception {
- result5 = defaultIsisInterface.lspKeyP2P(sysId);
- assertThat(result5, is(notNullValue()));
- }
-
- /**
- * Tests processLsPduMessage() method.
- */
- @Test
- public void testProcessLsPduMessage() throws Exception {
- lsPdu = new LsPdu(isisHeader);
- lsPdu.setSourceMac(macAddress1);
- lsPdu.setIsisPduType(IsisPduType.L2LSPDU.value());
- lsPdu.setLspId(sysId);
- isisMessage = lsPdu;
- defaultIsisInterface.setNetworkType(IsisNetworkType.P2P);
- defaultIsisInterface.setSystemId(sysId);
- defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests processPsnPduMessage() method.
- */
- @Test
- public void testProcessPsnPduMessage() throws Exception {
- psnp = new Psnp(isisHeader);
- psnp.setSourceMac(macAddress1);
- psnp.setIsisPduType(IsisPduType.L2PSNP.value());
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.LSPENTRY.value());
- tlvHeader.setTlvLength(0);
- LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader);
- LspEntry lspEntry = new LspEntry();
- lspEntry.setLspChecksum(0);
- lspEntry.setLspSequenceNumber(0);
- lspEntry.setRemainingTime(0);
- lspEntriesTlv.addLspEntry(lspEntry);
- psnp.addTlv(lspEntriesTlv);
- isisMessage = psnp;
- defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-
- /**
- * Tests processCsnPduMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessCsnPduMessage() throws Exception {
- ChannelBuffer channelBuffer = ChannelBuffers.copiedBuffer(csnpBytes);
- csnp = new Csnp(isisHeader);
- csnp.readFrom(channelBuffer);
- csnp.setSourceMac(macAddress1);
- csnp.setIsisPduType(IsisPduType.L2CSNP.value());
- isisMessage = csnp;
- defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel);
- assertThat(defaultIsisInterface, is(notNullValue()));
- }
-}
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisNeighborTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisNeighborTest.java
deleted file mode 100644
index b79e79d1..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisNeighborTest.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.MacAddress;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisInterfaceState;
-import org.onosproject.isis.controller.IsisMessage;
-import org.onosproject.isis.controller.IsisRouterType;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.pdu.HelloPdu;
-import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for DefaultIsisNeighbor.
- */
-public class DefaultIsisNeighborTest {
-
- private final String areaId = "490001";
- private final String systemId = "2929.2929.2929";
- private final String lanId = "0000.0000.0000.00";
- private DefaultIsisNeighbor isisNeighbor;
- private IsisInterface isisInterface;
- private IsisMessage isisMessage;
- private IsisHeader isisHeader;
- private int result;
- private String result1;
- private Ip4Address interfaceIp = Ip4Address.valueOf("10.10.10.10");
- private Ip4Address result2;
- private MacAddress macAddress = MacAddress.valueOf("a4:23:05:00:00:00");
- private MacAddress result3;
- private IsisRouterType isisRouterType;
- private IsisInterfaceState isisInterfaceState;
- private byte result4;
-
- @Before
- public void setUp() throws Exception {
- isisHeader = new IsisHeader();
- isisMessage = new L1L2HelloPdu(isisHeader);
- isisInterface = new DefaultIsisInterface();
- isisNeighbor = new DefaultIsisNeighbor((HelloPdu) isisMessage, isisInterface);
- }
-
- @After
- public void tearDown() throws Exception {
- isisHeader = null;
- isisMessage = null;
- isisInterface = null;
- isisNeighbor = null;
- }
-
- /**
- * Tests localExtendedCircuitId() getter method.
- */
- @Test
- public void testLocalExtendedCircuitId() throws Exception {
- isisNeighbor.setLocalExtendedCircuitId(1);
- result = isisNeighbor.localExtendedCircuitId();
- assertThat(result, is(1));
- }
-
- /**
- * Tests localExtendedCircuitId() setter method.
- */
- @Test
- public void testSetLocalExtendedCircuitId() throws Exception {
- isisNeighbor.setLocalExtendedCircuitId(1);
- result = isisNeighbor.localExtendedCircuitId();
- assertThat(result, is(1));
- }
-
- /**
- * Tests neighborAreaId() getter method.
- */
- @Test
- public void testNeighborAreaId() throws Exception {
- isisNeighbor.setNeighborAreaId(areaId);
- result1 = isisNeighbor.neighborAreaId();
- assertThat(result1, is(areaId));
- }
-
- /**
- * Tests neighborAreaId() setter method.
- */
- @Test
- public void testSetNeighborAreaId() throws Exception {
- isisNeighbor.setNeighborAreaId(areaId);
- result1 = isisNeighbor.neighborAreaId();
- assertThat(result1, is(areaId));
- }
-
- /**
- * Tests neighborSystemId() getter method.
- */
- @Test
- public void testNeighborSystemId() throws Exception {
- isisNeighbor.setNeighborSystemId(systemId);
- result1 = isisNeighbor.neighborSystemId();
- assertThat(result1, is(systemId));
- }
-
- /**
- * Tests neighborSystemId() setter method.
- */
- @Test
- public void testSetNeighborSystemId() throws Exception {
- isisNeighbor.setNeighborSystemId(systemId);
- result1 = isisNeighbor.neighborSystemId();
- assertThat(result1, is(systemId));
- }
-
- /**
- * Tests interfaceIp() getter method.
- */
- @Test
- public void testInterfaceIp() throws Exception {
- isisNeighbor.setInterfaceIp(interfaceIp);
- result2 = isisNeighbor.interfaceIp();
- assertThat(result2, is(interfaceIp));
- }
-
- /**
- * Tests interfaceIp() setter method.
- */
- @Test
- public void testSetInterfaceIp() throws Exception {
- isisNeighbor.setInterfaceIp(interfaceIp);
- result2 = isisNeighbor.interfaceIp();
- assertThat(result2, is(interfaceIp));
- }
-
- /**
- * Tests neighborMacAddress() getter method.
- */
- @Test
- public void testNeighborMacAddress() throws Exception {
- isisNeighbor.setNeighborMacAddress(macAddress);
- result3 = isisNeighbor.neighborMacAddress();
- assertThat(result3, is(macAddress));
- }
-
- /**
- * Tests neighborMacAddress() setter method.
- */
- @Test
- public void testSetNeighborMacAddress() throws Exception {
- isisNeighbor.setNeighborMacAddress(macAddress);
- result3 = isisNeighbor.neighborMacAddress();
- assertThat(result3, is(macAddress));
- }
-
- /**
- * Tests holdingTime() getter method.
- */
- @Test
- public void testHoldingTime() throws Exception {
- isisNeighbor.setHoldingTime(1);
- result = isisNeighbor.holdingTime();
- assertThat(result, is(1));
- }
-
- /**
- * Tests holdingTime() setter method.
- */
- @Test
- public void testSetHoldingTime() throws Exception {
- isisNeighbor.setHoldingTime(1);
- result = isisNeighbor.holdingTime();
- assertThat(result, is(1));
- }
-
- /**
- * Tests routerType() getter method.
- */
- @Test
- public void testRouterType() throws Exception {
- isisNeighbor.setRouterType(IsisRouterType.L1);
- isisRouterType = isisNeighbor.routerType();
- assertThat(isisRouterType, is(IsisRouterType.L1));
- }
-
- /**
- * Tests routerType() setter method.
- */
- @Test
- public void testSetRouterType() throws Exception {
- isisNeighbor.setRouterType(IsisRouterType.L1);
- isisRouterType = isisNeighbor.routerType();
- assertThat(isisRouterType, is(IsisRouterType.L1));
- }
-
- /**
- * Tests l1LanId() getter method.
- */
- @Test
- public void testL1LanId() throws Exception {
- isisNeighbor.setL1LanId(systemId);
- result1 = isisNeighbor.l1LanId();
- assertThat(result1, is(systemId));
- }
-
- /**
- * Tests l1LanId() setter method.
- */
- @Test
- public void testSetL1LanId() throws Exception {
- isisNeighbor.setL1LanId(lanId);
- result1 = isisNeighbor.l1LanId();
- assertThat(result1, is(lanId));
- }
-
- /**
- * Tests l2LanId() getter method.
- */
- @Test
- public void testL2LanId() throws Exception {
- isisNeighbor.setL2LanId(lanId);
- result1 = isisNeighbor.l2LanId();
- assertThat(result1, is(lanId));
- }
-
- /**
- * Tests l2LanId() setter method.
- */
- @Test
- public void testSetL2LanId() throws Exception {
- isisNeighbor.setL2LanId(lanId);
- result1 = isisNeighbor.l2LanId();
- assertThat(result1, is(lanId));
- }
-
- /**
- * Tests neighborState() getter method.
- */
- @Test
- public void testInterfaceState() throws Exception {
- isisNeighbor.setNeighborState(IsisInterfaceState.DOWN);
- isisInterfaceState = isisNeighbor.neighborState();
- assertThat(isisInterfaceState, is(IsisInterfaceState.DOWN));
- }
-
- /**
- * Tests neighborState() setter method.
- */
- @Test
- public void testSetNeighborState() throws Exception {
- isisNeighbor.setNeighborState(IsisInterfaceState.DOWN);
- isisInterfaceState = isisNeighbor.neighborState();
- assertThat(isisInterfaceState, is(IsisInterfaceState.DOWN));
- }
-
- /**
- * Tests localCircuitId() getter method.
- */
- @Test
- public void testLocalCircuitId() throws Exception {
- isisNeighbor.setLocalCircuitId((byte) 1);
- result4 = isisNeighbor.localCircuitId();
- assertThat(result4, is((byte) 1));
- }
-
- /**
- * Tests localCircuitId() setter method.
- */
- @Test
- public void testSetLocalCircuitId() throws Exception {
- isisNeighbor.setLocalCircuitId((byte) 1);
- result4 = isisNeighbor.localCircuitId();
- assertThat(result4, is((byte) 1));
- }
-
- /**
- * Tests neighborState() getter method.
- */
- @Test
- public void testNeighborState() throws Exception {
- isisNeighbor.setNeighborState(IsisInterfaceState.DOWN);
- isisInterfaceState = isisNeighbor.neighborState();
- assertThat(isisInterfaceState, is(IsisInterfaceState.DOWN));
- }
-
- /**
- * Tests startHoldingTimeCheck() method.
- */
- @Test
- public void testStartHoldingTimeCheck() throws Exception {
- isisNeighbor.startHoldingTimeCheck();
- assertThat(isisNeighbor, is(notNullValue()));
- }
-
- /**
- * Tests stopHoldingTimeCheck() method.
- */
- @Test
- public void testStopHoldingTimeCheck() throws Exception {
- isisNeighbor.stopHoldingTimeCheck();
- assertThat(isisNeighbor, is(notNullValue()));
- }
-
- /**
- * Tests startInactivityTimeCheck() method.
- */
- @Test(expected = Exception.class)
- public void testStartInactivityTimeCheck() throws Exception {
- isisNeighbor.startInactivityTimeCheck();
- assertThat(isisNeighbor, is(notNullValue()));
- }
-
- /**
- * Tests startInactivityTimeCheck() method.
- */
- @Test(expected = Exception.class)
- public void testStopInactivityTimeCheck() throws Exception {
- isisNeighbor.startInactivityTimeCheck();
- assertThat(isisNeighbor, is(notNullValue()));
- }
-
- /**
- * Tests neighborDown() method.
- */
- @Test(expected = Exception.class)
- public void testNeighborDown() throws Exception {
- isisNeighbor.neighborDown();
- assertThat(isisNeighbor, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisProcessTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisProcessTest.java
deleted file mode 100644
index 08507f5..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisProcessTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisProcess;
-
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for DefaultIsisProcess.
- */
-public class DefaultIsisProcessTest {
-
- private final String processId = "1";
- private IsisProcess isisProcess;
- private String result;
- private IsisProcess defaultIsisProcess;
- private IsisInterface isisInterface;
- private List<IsisInterface> isisInterfaceList;
- private List<IsisInterface> result1;
-
- @Before
- public void setUp() throws Exception {
- isisProcess = new DefaultIsisProcess();
- isisInterface = EasyMock.createNiceMock(DefaultIsisInterface.class);
- defaultIsisProcess = new DefaultIsisProcess();
- }
-
- @After
- public void tearDown() throws Exception {
- isisProcess = null;
- }
-
- /**
- * Tests processId() setter method.
- */
- @Test
- public void testProcessId() throws Exception {
- isisProcess.setProcessId(processId);
- result = isisProcess.processId();
- assertThat(result, is(processId));
- }
-
- /**
- * Tests processId() getter method.
- */
- @Test
- public void testSetProcessId() throws Exception {
- isisProcess.setProcessId(processId);
- result = isisProcess.processId();
- assertThat(result, is(processId));
- }
-
- /**
- * Tests isisInterfaceList() setter method.
- */
- @Test
- public void testIsisInterfaceList() throws Exception {
- isisProcess.setIsisInterfaceList(isisInterfaceList);
- result1 = isisProcess.isisInterfaceList();
- assertThat(result1, is(nullValue()));
- }
-
- /**
- * Tests isisInterfaceList() getter method.
- */
- @Test
- public void testSetIsisInterfaceList() throws Exception {
- isisProcess.setIsisInterfaceList(isisInterfaceList);
- result1 = isisProcess.isisInterfaceList();
- assertThat(result1, is(nullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisChannelHandlerTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisChannelHandlerTest.java
deleted file mode 100644
index 468036e..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisChannelHandlerTest.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelStateEvent;
-import org.jboss.netty.channel.ExceptionEvent;
-import org.jboss.netty.channel.MessageEvent;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisMessage;
-import org.onosproject.isis.controller.IsisNetworkType;
-import org.onosproject.isis.controller.IsisProcess;
-import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for IsisChannelHandler.
- */
-public class IsisChannelHandlerTest {
-
- private final String processId = "1";
- private final byte[] config = {0, 0, 0, 0, 0, 0, 0};
- private IsisChannelHandler isisChannelHandler;
- private Controller controller;
- private IsisProcess isisProcess;
- private List<IsisProcess> isisProcessList = new ArrayList();
- private ChannelHandlerContext channelHandlerContext;
- private ChannelStateEvent channelStateEvent;
- private ExceptionEvent exceptionEvent;
- private MessageEvent messageEvent;
- private IsisMessage isisMessage;
- private List<IsisInterface> isisInterfaceList = new ArrayList<>();
- private Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10");
-
- @Before
- public void setUp() throws Exception {
- controller = EasyMock.createNiceMock(Controller.class);
- isisProcess = EasyMock.createNiceMock(IsisProcess.class);
- channelHandlerContext = EasyMock.createNiceMock(ChannelHandlerContext.class);
- channelStateEvent = EasyMock.createNiceMock(ChannelStateEvent.class);
- exceptionEvent = EasyMock.createNiceMock(ExceptionEvent.class);
- messageEvent = EasyMock.createNiceMock(MessageEvent.class);
- isisMessage = EasyMock.createNiceMock(L1L2HelloPdu.class);
- isisMessage.setInterfaceIndex(2);
- isisChannelHandler = new IsisChannelHandler(controller, isisProcessList);
- }
-
- @After
- public void tearDown() throws Exception {
- isisChannelHandler = null;
- }
-
- /**
- * Tests initializeInterfaceMap() method.
- */
- @Test
- public void testInitializeInterfaceMap() throws Exception {
- isisChannelHandler.initializeInterfaceMap();
- assertThat(isisChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests updateInterfaceMap() method.
- */
- @Test(expected = Exception.class)
- public void testUpdateInterfaceMap() throws Exception {
- IsisInterface isisInterface = new DefaultIsisInterface();
- IsisInterface isisInterface1 = new DefaultIsisInterface();
- isisInterface.setInterfaceIpAddress(ip4Address);
- isisInterface.setInterfaceIndex(1);
- isisInterfaceList.add(isisInterface);
- IsisProcess isisProcess = new DefaultIsisProcess();
- isisProcess.setIsisInterfaceList(isisInterfaceList);
- isisProcessList.add(isisProcess);
- isisChannelHandler.updateInterfaceMap(isisProcessList);
- assertThat(isisChannelHandler, is(notNullValue()));
- isisProcessList = new ArrayList<>();
- isisInterface1.setInterfaceIpAddress(ip4Address);
- isisInterface1.setInterfaceIndex(1);
- isisInterface1.setInterfaceIpAddress(ip4Address);
- isisInterface1.setInterfaceIndex(1);
- isisInterface1.setSystemId("9999.9999.9999");
- isisInterface1.setIntermediateSystemName("router");
- isisInterface1.setReservedPacketCircuitType(3);
- isisInterface1.setCircuitId("10");
- isisInterface1.setNetworkType(IsisNetworkType.BROADCAST);
- isisInterface1.setAreaAddress("490001");
- isisInterface1.setHoldingTime(50);
- isisInterface1.setHelloInterval(10);
- isisInterfaceList.add(isisInterface1);
- isisProcess.setIsisInterfaceList(isisInterfaceList);
- isisProcessList.add(isisProcess);
- isisChannelHandler.updateInterfaceMap(isisProcessList);
- assertThat(isisChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests initializeInterfaceIpList() method.
- */
- @Test
- public void testInitializeInterfaceIpList() throws Exception {
- isisChannelHandler.initializeInterfaceIpList();
- assertThat(isisChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests channelConnected() method.
- */
- @Test(expected = Exception.class)
- public void testChannelConnected() throws Exception {
- isisChannelHandler.channelConnected(channelHandlerContext, channelStateEvent);
- assertThat(isisChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests channelDisconnected() method.
- */
- @Test
- public void testChannelDisconnected() throws Exception {
- isisChannelHandler.channelDisconnected(channelHandlerContext, channelStateEvent);
- assertThat(isisChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests exceptionCaught() method.
- */
- @Test(expected = Exception.class)
- public void testExceptionCaught() throws Exception {
- isisChannelHandler.exceptionCaught(channelHandlerContext, exceptionEvent);
- assertThat(isisChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests messageReceived() method.
- */
- @Test
- public void testMessageReceived() throws Exception {
- isisChannelHandler.messageReceived(channelHandlerContext, messageEvent);
- assertThat(isisChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests processIsisMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessIsisMessage() throws Exception {
- isisChannelHandler.processIsisMessage(isisMessage, channelHandlerContext);
- assertThat(isisChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests startHelloSender() method.
- */
- @Test
- public void testStartHelloSender() throws Exception {
- isisChannelHandler.startHelloSender();
- assertThat(isisChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests stopHelloSender() method.
- */
- @Test
- public void testStopHelloSender() throws Exception {
- isisChannelHandler.stopHelloSender();
- assertThat(isisChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests sentConfigPacket() method.
- */
- @Test
- public void testSentConfigPacket() throws Exception {
- isisChannelHandler.sentConfigPacket(config);
- assertThat(isisChannelHandler, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisHelloPduSenderTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisHelloPduSenderTest.java
deleted file mode 100644
index 1b2da30..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisHelloPduSenderTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.channel.Channel;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.isis.controller.IsisNetworkType;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for IsisHelloPduSender.
- */
-public class IsisHelloPduSenderTest {
- private final String systemId = "1234.1234.1234";
- private final String areaId = "490001";
- private final String circuitId = "0";
- private final String lanId = "0000.0000.0000.00";
- private Channel channel;
- private DefaultIsisInterface isisInterface;
- private DefaultIsisInterface isisInterface1;
- private IsisHelloPduSender isisHelloPduSender;
- private IsisHelloPduSender isisHelloPduSender1;
- private Ip4Address interfaceAddress = Ip4Address.valueOf("10.10.10.10");
-
- @Before
- public void setUp() throws Exception {
- channel = EasyMock.createNiceMock(Channel.class);
- isisInterface = new DefaultIsisInterface();
- isisInterface1 = new DefaultIsisInterface();
- }
-
- @After
- public void tearDown() throws Exception {
- channel = null;
- isisInterface = null;
- }
-
- /**
- * Tests run() method.
- */
- @Test(expected = Exception.class)
- public void testRun() throws Exception {
- isisInterface.setNetworkType(IsisNetworkType.P2P);
- isisInterface.setCircuitId(circuitId);
- isisInterface.setSystemId(systemId);
- isisInterface.setAreaAddress("490001");
- isisInterface.setInterfaceIpAddress(interfaceAddress);
- isisHelloPduSender = new IsisHelloPduSender(channel, isisInterface);
- isisHelloPduSender.run();
- assertThat(isisHelloPduSender, is(notNullValue()));
-
- isisInterface1.setNetworkType(IsisNetworkType.BROADCAST);
- isisInterface1.setCircuitId(circuitId);
- isisInterface1.setSystemId(systemId);
- isisInterface1.setAreaAddress(areaId);
- isisInterface1.setInterfaceIpAddress(interfaceAddress);
- isisInterface1.setReservedPacketCircuitType(1);
- isisInterface1.setL1LanId(lanId);
- isisHelloPduSender1 = new IsisHelloPduSender(channel, isisInterface1);
- isisHelloPduSender1.run();
- assertThat(isisHelloPduSender1, is(notNullValue()));
-
- isisInterface1.setNetworkType(IsisNetworkType.BROADCAST);
- isisInterface1.setCircuitId(circuitId);
- isisInterface1.setSystemId(systemId);
- isisInterface1.setAreaAddress(areaId);
- isisInterface1.setInterfaceIpAddress(interfaceAddress);
- isisInterface1.setReservedPacketCircuitType(2);
- isisInterface1.setL2LanId(lanId);
- isisHelloPduSender1 = new IsisHelloPduSender(channel, isisInterface1);
- isisHelloPduSender1.run();
- assertThat(isisHelloPduSender1, is(notNullValue()));
-
- isisInterface1.setNetworkType(IsisNetworkType.BROADCAST);
- isisInterface1.setCircuitId(circuitId);
- isisInterface1.setSystemId(systemId);
- isisInterface1.setAreaAddress(areaId);
- isisInterface1.setInterfaceIpAddress(interfaceAddress);
- isisInterface1.setReservedPacketCircuitType(3);
- isisInterface1.setL1LanId(lanId);
- isisInterface1.setL2LanId(lanId);
- isisHelloPduSender1 = new IsisHelloPduSender(channel, isisInterface1);
- isisHelloPduSender1.run();
- assertThat(isisHelloPduSender1, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageDecoderTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageDecoderTest.java
deleted file mode 100644
index a370bfe..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageDecoderTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import com.google.common.primitives.Bytes;
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for IsisMessageDecoder.
- */
-public class IsisMessageDecoderTest {
-
- private final byte[] hello = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- -125, 20, 1, 0, 17, 1, 0, 0,
- 2, 51, 51, 51, 51, 51, 51, 0, 100, 5, -39, -126, 1, 4, 3,
- 73, 0, 0, -127, 1, -52, -124, 4, -64, -88, 56, 102
- };
- private final byte[] array2 = {0, 0, 0, 0, 0, 0, 0};
- private final String id = "127.0.0.1";
- private byte[] array1;
- private IsisMessageDecoder isisMessageDecoder;
- private ChannelHandlerContext ctx;
- private Channel channel;
- private SocketAddress socketAddress;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- isisMessageDecoder = new IsisMessageDecoder();
- }
-
- @After
- public void tearDown() throws Exception {
- isisMessageDecoder = null;
- }
-
- @Test
- public void testDecode() throws Exception {
- channel = EasyMock.createMock(Channel.class);
- socketAddress = InetSocketAddress.createUnresolved(id, 7000);
- byte[] array = IsisUtil.getPaddingTlvs(hello.length - 17);
- array1 = Bytes.concat(hello, array);
- channelBuffer = ChannelBuffers.copiedBuffer(Bytes.concat(hello, array));
- assertThat(isisMessageDecoder.decode(ctx, channel, channelBuffer), is(nullValue()));
- }
-}
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageEncoderTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageEncoderTest.java
deleted file mode 100644
index b976b11..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisMessageEncoderTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import com.google.common.primitives.Bytes;
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for IsisMessageEncoder.
- */
-public class IsisMessageEncoderTest {
-
- private final String id = "127.0.0.1";
- private final byte[] hello = {
- -125, 20, 1, 0, 17, 1, 0, 0,
- 2, 51, 51, 51, 51, 51, 51, 0, 100, 5, -39, -126, 1, 4, 3,
- 73, 0, 0, -127, 1, -52, -124, 4, -64, -88, 56, 102
- };
- private IsisMessageEncoder isisMessageEncoder;
- private ChannelHandlerContext ctx;
- private Channel channel;
- private SocketAddress socketAddress;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- channel = EasyMock.createMock(Channel.class);
- isisMessageEncoder = new IsisMessageEncoder();
- }
-
- @After
- public void tearDown() throws Exception {
- channel = null;
- isisMessageEncoder = null;
- }
-
- /**
- * Tests encode() method.
- */
- @Test
- public void testEncode() throws Exception {
- socketAddress = InetSocketAddress.createUnresolved(id, 7000);
- byte[] array = IsisUtil.getPaddingTlvs(hello.length);
- channelBuffer = ChannelBuffers.copiedBuffer(Bytes.concat(hello, array));
- assertThat(isisMessageEncoder.encode(ctx, channel, channelBuffer.array()),
- is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisPipelineFactoryTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisPipelineFactoryTest.java
deleted file mode 100644
index 29b06f9..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/IsisPipelineFactoryTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl;
-
-import org.jboss.netty.channel.ChannelPipeline;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisProcess;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for IsisPipelineFactory.
- */
-public class IsisPipelineFactoryTest {
-
- private IsisPipelineFactory isisPipelineFactory;
- private IsisChannelHandler isisChannelHandler;
- private List<IsisProcess> isisProcessList = new ArrayList<>();
- private Controller controller;
- private ChannelPipeline channelPipeline;
- private DefaultIsisProcess isisProcess;
- private String processId = "1";
- private DefaultIsisInterface isisInterface;
- private List<IsisInterface> isisInterfaces = new ArrayList<>();
-
- @Before
- public void setUp() throws Exception {
- controller = new Controller();
- isisProcess = new DefaultIsisProcess();
- isisInterface = new DefaultIsisInterface();
- isisInterfaces.add(isisInterface);
- isisProcess.setIsisInterfaceList(isisInterfaces);
- isisProcess.setProcessId(processId);
- isisProcessList.add(isisProcess);
- isisChannelHandler = new IsisChannelHandler(controller, isisProcessList);
- isisPipelineFactory = new IsisPipelineFactory(isisChannelHandler);
- }
-
- @After
- public void tearDown() throws Exception {
- controller = null;
- isisChannelHandler = null;
- isisPipelineFactory = null;
- }
-
- /**
- * Tests getPipeline() method.
- */
- @Test
- public void testGetPipeline() throws Exception {
- channelPipeline = isisPipelineFactory.getPipeline();
- assertThat(channelPipeline, is(instanceOf(ChannelPipeline.class)));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAgeTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAgeTest.java
deleted file mode 100644
index 51388ac..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAgeTest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl.lsdb;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.controller.IsisLspBin;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test case for DefaultIsisLsdbAge.
- */
-public class DefaultIsisLsdbAgeTest {
- private DefaultIsisLsdbAge defaultIsisLsdbAge;
- private IsisLspBin isisLspBin;
- private int resultInt;
- private IsisLspBin resultLspBin;
- private DefaultLspWrapper lspWrapper;
- private LsPdu lsPdu;
- private IsisHeader isisHeader;
- private String lspId = "1234.1234.1234";
-
- @Before
- public void setUp() throws Exception {
- defaultIsisLsdbAge = new DefaultIsisLsdbAge();
- isisLspBin = new DefaultIsisLspBin(1);
- lspWrapper = new DefaultLspWrapper();
- lspWrapper.setBinNumber(1);
- isisHeader = new IsisHeader();
- lsPdu = new LsPdu(isisHeader);
- lsPdu.setLspId(lspId);
- lspWrapper.setLsPdu(lsPdu);
- }
-
- @After
- public void tearDown() throws Exception {
- defaultIsisLsdbAge = null;
- isisLspBin = null;
- }
-
- /**
- * Tests ageCounter() method.
- */
- @Test
- public void testAgeCounter() throws Exception {
- resultInt = defaultIsisLsdbAge.ageCounter();
- assertThat(resultInt, is(0));
- }
-
- /**
- * Tests ageCounterRollOver() method.
- */
- @Test
- public void testAgeCounterRollOver() throws Exception {
- resultInt = defaultIsisLsdbAge.ageCounterRollOver();
- assertThat(resultInt, is(0));
- }
-
- /**
- * Tests addLspBin() method.
- */
- @Test
- public void testAddLspBin() throws Exception {
- defaultIsisLsdbAge.addLspBin(1400, isisLspBin);
- resultLspBin = defaultIsisLsdbAge.getLspBin(1);
- assertThat(resultLspBin, is(notNullValue()));
- }
-
- /**
- * Tests getLspBin() method.
- */
- @Test
- public void testGetLspBin() throws Exception {
- defaultIsisLsdbAge.addLspBin(1, isisLspBin);
- resultLspBin = defaultIsisLsdbAge.getLspBin(1);
- assertThat(resultLspBin, is(notNullValue()));
- }
-
- /**
- * Tests removeLspFromBin() method.
- */
- @Test
- public void testRemoveLspFromBin() throws Exception {
- defaultIsisLsdbAge.addLspBin(1400, isisLspBin);
- defaultIsisLsdbAge.removeLspFromBin(lspWrapper);
- assertThat(resultLspBin, is(nullValue()));
- }
-
- /**
- * Tests age2Bin() method.
- */
- @Test
- public void testAge2Bin() throws Exception {
- defaultIsisLsdbAge.age2Bin(1);
- assertThat(defaultIsisLsdbAge, is(notNullValue()));
-
- defaultIsisLsdbAge.age2Bin(-1);
- assertThat(defaultIsisLsdbAge, is(notNullValue()));
- }
-
- /**
- * Tests startDbAging() method.
- */
- @Test
- public void testStartDbAging() throws Exception {
- defaultIsisLsdbAge.startDbAging();
- assertThat(defaultIsisLsdbAge, is(notNullValue()));
- }
-
- /**
- * Tests ageLsp() method.
- */
- @Test
- public void testAgeLsp() throws Exception {
- defaultIsisLsdbAge.age2Bin(1);
- defaultIsisLsdbAge.startDbAging();
- defaultIsisLsdbAge.ageLsp();
- assertThat(defaultIsisLsdbAge, is(notNullValue()));
- }
-
- /**
- * Tests maxAgeLsa() method.
- */
- @Test
- public void testMaxAgeLsa() throws Exception {
- defaultIsisLsdbAge.age2Bin(1);
- defaultIsisLsdbAge.startDbAging();
- defaultIsisLsdbAge.maxAgeLsa();
- assertThat(defaultIsisLsdbAge, is(notNullValue()));
-
- defaultIsisLsdbAge.age2Bin(1400);
- defaultIsisLsdbAge.startDbAging();
- defaultIsisLsdbAge.maxAgeLsa();
- assertThat(defaultIsisLsdbAge, is(notNullValue()));
- }
-
- /**
- * Tests refreshLsa() method.
- */
- @Test
- public void testRefreshLsa() throws Exception {
- defaultIsisLsdbAge.age2Bin(1);
- defaultIsisLsdbAge.startDbAging();
- defaultIsisLsdbAge.refreshLsa();
- assertThat(defaultIsisLsdbAge, is(notNullValue()));
-
- defaultIsisLsdbAge.age2Bin(1400);
- defaultIsisLsdbAge.startDbAging();
- defaultIsisLsdbAge.refreshLsa();
- assertThat(defaultIsisLsdbAge, is(notNullValue()));
- }
-}
-
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbTest.java
deleted file mode 100644
index de19862..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbTest.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl.lsdb;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.controller.IsisLsdb;
-import org.onosproject.isis.controller.IsisLsdbAge;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.controller.LspWrapper;
-import org.onosproject.isis.controller.impl.DefaultIsisInterface;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.pdu.AttachedToOtherAreas;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-import org.onosproject.isis.io.util.IsisConstants;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test case for DefaultIsisLsdb.
- */
-public class DefaultIsisLsdbTest {
- private final int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
- private final int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
- private final String srcId = "1111.1111.1111";
- private DefaultIsisLsdb defaultIsisLsdb;
- private IsisLsdbAge lsdbAge = null;
- private int resultInt;
- private Map<String, LspWrapper> resultMap = new ConcurrentHashMap<>();
- private IsisLsdb resultLsdb;
- private LspWrapper resultLspWrapper;
- private List<LspWrapper> lspWrapperList;
- private LsPdu lsPdu;
- private IsisHeader isisHeader;
- private DefaultIsisInterface defaultIsisInterface;
- private String lspId = "1234.1234.1234.00-00";
- private String result;
-
- @Before
- public void setUp() throws Exception {
- defaultIsisInterface = new DefaultIsisInterface();
- isisHeader = new IsisHeader();
- lsPdu = new LsPdu(isisHeader);
- lsPdu.setLspId(lspId);
- lsPdu.setAttachedToOtherAreas(AttachedToOtherAreas.DEFAULTMETRIC);
- lsPdu.setIsisPduType(IsisPduType.L1LSPDU.value());
- defaultIsisLsdb = new DefaultIsisLsdb();
- }
-
- @After
- public void tearDown() throws Exception {
- defaultIsisLsdb = null;
- }
-
- /**
- * Tests initializeDb() method.
- */
- @Test
- public void testInitializeDb() throws Exception {
- defaultIsisLsdb.initializeDb();
- assertThat(lsdbAge, is(nullValue()));
- }
-
- /**
- * Tests setL1LspSeqNo() method.
- */
- @Test
- public void testSetL1LspSeqNo() throws Exception {
- defaultIsisLsdb.setL1LspSeqNo(l1LspSeqNo);
- assertThat(defaultIsisLsdb, is(notNullValue()));
- }
-
- /**
- * Tests setL2LspSeqNo() method.
- */
- @Test
- public void testSetL2LspSeqNo() throws Exception {
- defaultIsisLsdb.setL2LspSeqNo(l2LspSeqNo);
- assertThat(defaultIsisLsdb, is(notNullValue()));
- }
-
- /**
- * Tests setL2LspSeqNo() method.
- */
- @Test
- public void testLspKey() throws Exception {
- defaultIsisLsdb.lspKey(srcId);
- assertThat(defaultIsisLsdb, is(notNullValue()));
- }
-
- /**
- * Tests setL2LspSeqNo() method.
- */
- @Test
- public void testGetL1Db() throws Exception {
- resultMap = defaultIsisLsdb.getL1Db();
- assertThat(resultMap.isEmpty(), is(true));
- }
-
- /**
- * Tests setL2LspSeqNo() method.
- */
- @Test
- public void testGetL2Db() throws Exception {
- resultMap = defaultIsisLsdb.getL2Db();
- assertThat(resultMap.isEmpty(), is(true));
- }
-
- /**
- * Tests setL2LspSeqNo() method.
- */
- @Test
- public void testIsisLsdb() throws Exception {
- resultLsdb = defaultIsisLsdb.isisLsdb();
- assertThat(resultLsdb, is(notNullValue()));
- }
-
- /**
- * Tests findLsp() method.
- */
- @Test
- public void testFindLsp() throws Exception {
- resultLspWrapper = defaultIsisLsdb.findLsp(IsisPduType.L1HELLOPDU, srcId);
- assertThat(resultLspWrapper, is(nullValue()));
- }
-
- /**
- * Tests allLspHeaders() method.
- */
- @Test
- public void testAllLspHeaders() throws Exception {
- defaultIsisLsdb.addLsp(lsPdu, false, defaultIsisInterface);
- lspWrapperList = defaultIsisLsdb.allLspHeaders(true);
- assertThat(lspWrapperList, is(notNullValue()));
-
- defaultIsisLsdb.addLsp(lsPdu, true, defaultIsisInterface);
- lspWrapperList = defaultIsisLsdb.allLspHeaders(true);
- assertThat(lspWrapperList, is(notNullValue()));
- }
-
- /**
- * Tests isNewerOrSameLsp() method.
- */
- @Test
- public void testIsNewerOrSameLsp() throws Exception {
- result = defaultIsisLsdb.isNewerOrSameLsp(lsPdu, lsPdu);
- assertThat(result, is("same"));
- }
-
- /**
- * Tests lsSequenceNumber() method.
- */
- @Test
- public void testLsSequenceNumber() throws Exception {
- resultInt = defaultIsisLsdb.lsSequenceNumber(IsisPduType.L1LSPDU);
- assertThat(resultInt, is(1));
-
- resultInt = defaultIsisLsdb.lsSequenceNumber(IsisPduType.L2LSPDU);
- assertThat(resultInt, is(1));
-
- resultInt = defaultIsisLsdb.lsSequenceNumber(IsisPduType.L1CSNP);
- assertThat(resultInt, is(1));
- }
-
- /**
- * Tests deleteLsp() method.
- */
- @Test
- public void testdeleteLsp() throws Exception {
- defaultIsisLsdb.deleteLsp(lsPdu);
- assertThat(defaultIsisLsdb, is(notNullValue()));
-
- lsPdu.setIsisPduType(IsisPduType.L2LSPDU.value());
- defaultIsisLsdb.deleteLsp(lsPdu);
- assertThat(defaultIsisLsdb, is(notNullValue()));
-
- lsPdu.setIsisPduType(IsisPduType.L1CSNP.value());
- defaultIsisLsdb.deleteLsp(lsPdu);
- assertThat(defaultIsisLsdb, is(notNullValue()));
- }
-}
-
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBinTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBinTest.java
deleted file mode 100644
index 9ed993c..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBinTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl.lsdb;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.controller.LspWrapper;
-
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test case for DefaultIsisLspBin.
- */
-public class DefaultIsisLspBinTest {
-
- private DefaultIsisLspBin defaultIsisLspBin;
- private int result;
- private String key = "1";
- private LspWrapper lspWrapper;
- private LspWrapper result1;
- private Map<String, LspWrapper> listOfLsp;
-
- @Before
- public void setUp() throws Exception {
- defaultIsisLspBin = new DefaultIsisLspBin(1);
- lspWrapper = new DefaultLspWrapper();
- }
-
- @After
- public void tearDown() throws Exception {
- defaultIsisLspBin = null;
- }
-
- /**
- * Tests addIsisLsp() method.
- */
- @Test
- public void testAddIsisLsp() throws Exception {
- defaultIsisLspBin.addIsisLsp(key, lspWrapper);
- assertThat(defaultIsisLspBin, is(notNullValue()));
- }
-
- /**
- * Tests isisLsp() method.
- */
- @Test
- public void testIsisLsp() throws Exception {
- defaultIsisLspBin.addIsisLsp(key, lspWrapper);
- result1 = defaultIsisLspBin.isisLsp(key);
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests removeIsisLsp() method.
- */
- @Test
- public void testRemoveIsisLsp() throws Exception {
- defaultIsisLspBin.addIsisLsp(key, lspWrapper);
- defaultIsisLspBin.removeIsisLsp(key, lspWrapper);
- assertThat(defaultIsisLspBin, is(notNullValue()));
- }
-
- /**
- * Tests listOfLsp() method.
- */
- @Test
- public void testListOfLsp() throws Exception {
- defaultIsisLspBin.addIsisLsp(key, lspWrapper);
- listOfLsp = defaultIsisLspBin.listOfLsp();
- assertThat(listOfLsp.size(), is(1));
- }
-
- /**
- * Tests binNumber() method.
- */
- @Test
- public void testBinNumber() throws Exception {
- result = defaultIsisLspBin.binNumber();
- assertThat(result, is(1));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(defaultIsisLspBin.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapperTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapperTest.java
deleted file mode 100644
index d495522..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapperTest.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl.lsdb;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisLsdbAge;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.controller.impl.DefaultIsisInterface;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test case for DefaultLspWrapper.
- */
-public class DefaultLspWrapperTest {
-
- private DefaultLspWrapper defaultLspWrapper;
- private String processing = "processing";
- private String result;
- private int result1;
- private IsisInterface isisInterface;
- private IsisInterface result2;
- private IsisPduType isisPduType;
- private boolean result3;
- private LsPdu lsPdu;
- private LsPdu pdu;
- private DefaultIsisLsdbAge defaultIsisLsdbAge;
- private IsisLsdbAge lsdbAge;
-
- @Before
- public void setUp() throws Exception {
- defaultLspWrapper = new DefaultLspWrapper();
- isisInterface = new DefaultIsisInterface();
- pdu = new LsPdu(new IsisHeader());
- defaultIsisLsdbAge = new DefaultIsisLsdbAge();
- defaultIsisLsdbAge.startDbAging();
- }
-
- @After
- public void tearDown() throws Exception {
- defaultLspWrapper = null;
- }
-
- /**
- * Tests lspProcessing() getter method.
- */
- @Test
- public void testLspProcessing() throws Exception {
- defaultLspWrapper.setLspProcessing(processing);
- result = defaultLspWrapper.lspProcessing();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests lspProcessing() setter method.
- */
- @Test
- public void testSetLspProcessing() throws Exception {
- defaultLspWrapper.setLspProcessing(processing);
- result = defaultLspWrapper.lspProcessing();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests lspAgeReceived() getter method.
- */
- @Test
- public void testLspAgeReceived() throws Exception {
- defaultLspWrapper.setLspAgeReceived(1);
- result1 = defaultLspWrapper.lspAgeReceived();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests lspAgeReceived() setter method.
- */
- @Test
- public void testSetLspAgeReceived() throws Exception {
- defaultLspWrapper.setLspAgeReceived(1);
- result1 = defaultLspWrapper.lspAgeReceived();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests lspAgeReceived() getter method.
- */
- @Test
- public void testIsisInterface() throws Exception {
- defaultLspWrapper.setIsisInterface(isisInterface);
- result2 = defaultLspWrapper.isisInterface();
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests lspAgeReceived() getter method.
- */
- @Test
- public void testSetIsisInterface() throws Exception {
- defaultLspWrapper.setIsisInterface(isisInterface);
- result2 = defaultLspWrapper.isisInterface();
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests ageCounterWhenReceived() getter method.
- */
- @Test
- public void testAgeCounterWhenReceived() throws Exception {
- defaultLspWrapper.setAgeCounterWhenReceived(1);
- result1 = defaultLspWrapper.ageCounterWhenReceived();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests ageCounterWhenReceived() setter method.
- */
- @Test
- public void testSetAgeCounterWhenReceived() throws Exception {
- defaultLspWrapper.setAgeCounterWhenReceived(1);
- result1 = defaultLspWrapper.ageCounterWhenReceived();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests ageCounterRollOverWhenAdded() getter method.
- */
- @Test
- public void testAgeCounterRollOverWhenAdded() throws Exception {
- defaultLspWrapper.setAgeCounterRollOverWhenAdded(1);
- result1 = defaultLspWrapper.ageCounterRollOverWhenAdded();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests ageCounterRollOverWhenAdded() setter method.
- */
- @Test
- public void testSetAgeCounterRollOverWhenAdded() throws Exception {
- defaultLspWrapper.setAgeCounterRollOverWhenAdded(1);
- result1 = defaultLspWrapper.ageCounterRollOverWhenAdded();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests lspType() getter method.
- */
- @Test
- public void testLspType() throws Exception {
- defaultLspWrapper.setLspType(IsisPduType.L1LSPDU);
- isisPduType = defaultLspWrapper.lspType();
- assertThat(isisPduType, is(IsisPduType.L1LSPDU));
- }
-
- /**
- * Tests lspType() setter method.
- */
- @Test
- public void testSetLspType() throws Exception {
- defaultLspWrapper.setLspType(IsisPduType.L1LSPDU);
- isisPduType = defaultLspWrapper.lspType();
- assertThat(isisPduType, is(IsisPduType.L1LSPDU));
- }
-
- /**
- * Tests isSelfOriginated() getter method.
- */
- @Test
- public void testIsSelfOriginated() throws Exception {
- defaultLspWrapper.setSelfOriginated(true);
- result3 = defaultLspWrapper.isSelfOriginated();
- assertThat(result3, is(true));
- }
-
- /**
- * Tests isSelfOriginated() setter method.
- */
- @Test
- public void testSetSelfOriginated() throws Exception {
- defaultLspWrapper.setSelfOriginated(true);
- result3 = defaultLspWrapper.isSelfOriginated();
- assertThat(result3, is(true));
- }
-
- /**
- * Tests binNumber() getter method.
- */
- @Test
- public void testBinNumber() throws Exception {
- defaultLspWrapper.setBinNumber(1);
- result1 = defaultLspWrapper.binNumber();
- assertThat(result1, is(1));
- }
-
- /**
- * Tests binNumber() setter method.
- */
- @Test
- public void testSetBinNumber() throws Exception {
- defaultLspWrapper.setBinNumber(1);
- result1 = defaultLspWrapper.binNumber();
- assertThat(result1, is(1));
- }
-
- /**
- * Tests lsPdu() getter method.
- */
- @Test
- public void testLsPdu() throws Exception {
- defaultLspWrapper.setLsPdu(pdu);
- lsPdu = defaultLspWrapper.lsPdu();
- assertThat(lsPdu, is(pdu));
- }
-
- /**
- * Tests lsPdu() setter method.
- */
- @Test
- public void testSetLsPdu() throws Exception {
- defaultLspWrapper.setLsPdu(pdu);
- lsPdu = defaultLspWrapper.lsPdu();
- assertThat(lsPdu, is(pdu));
- }
-
- /**
- * Tests lsdbAge() getter method.
- */
- @Test
- public void testlsdbAge() throws Exception {
- defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge);
- lsdbAge = defaultLspWrapper.lsdbAge();
- assertThat(lsdbAge, is(defaultIsisLsdbAge));
- }
-
- /**
- * Tests lsdbAge() setter method.
- */
- @Test
- public void testSetLsdbAge() throws Exception {
- defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge);
- lsdbAge = defaultLspWrapper.lsdbAge();
- assertThat(lsdbAge, is(defaultIsisLsdbAge));
- }
-
- /**
- * Tests remainingLifetime() getter method.
- */
- @Test
- public void testRemainingLifetime() throws Exception {
- defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge);
- defaultLspWrapper.setAgeCounterWhenReceived(1);
- defaultLspWrapper.currentAge();
- defaultLspWrapper.setRemainingLifetime(1);
- result1 = defaultLspWrapper.remainingLifetime();
- assertThat(result1, is(1));
- }
-
- /**
- * Tests remainingLifetime() setter method.
- */
- @Test
- public void testSetRemainingLifetime() throws Exception {
- defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge);
- defaultLspWrapper.setAgeCounterWhenReceived(1);
- defaultLspWrapper.currentAge();
- defaultLspWrapper.setRemainingLifetime(1);
- result1 = defaultLspWrapper.remainingLifetime();
- assertThat(result1, is(1));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumerTest.java b/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumerTest.java
deleted file mode 100644
index 98684ad..0000000
--- a/protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumerTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.controller.impl.lsdb;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.controller.impl.DefaultIsisInterface;
-
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test case for IsisLspQueueConsumer.
- */
-public class IsisLspQueueConsumerTest {
-
- private IsisLspQueueConsumer isisLspQueueConsumer;
- private BlockingQueue blockingQueue = new ArrayBlockingQueue(1024);
- private DefaultLspWrapper lspWrapper;
- private DefaultLspWrapper lspWrapper1;
- private SocketAddress socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 7000);
-
- @Before
- public void setUp() throws Exception {
- lspWrapper = new DefaultLspWrapper();
- lspWrapper.setLspProcessing("refreshLsp");
- lspWrapper.setSelfOriginated(true);
- lspWrapper.setIsisInterface(new DefaultIsisInterface());
- lspWrapper1 = new DefaultLspWrapper();
- lspWrapper1.setLspProcessing("maxAgeLsp");
- lspWrapper1.setIsisInterface(new DefaultIsisInterface());
- blockingQueue.add(lspWrapper);
- blockingQueue.add(lspWrapper1);
- isisLspQueueConsumer = new IsisLspQueueConsumer(blockingQueue);
- }
-
- @After
- public void tearDown() throws Exception {
- isisLspQueueConsumer = null;
- }
-
- /**
- * Tests run() method.
- */
- @Test
- public void testRun() throws Exception {
- isisLspQueueConsumer.run();
- assertThat(isisLspQueueConsumer, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/BUILD b/protocols/isis/isisio/BUILD
deleted file mode 100644
index 1aabfcf..0000000
--- a/protocols/isis/isisio/BUILD
+++ /dev/null
@@ -1,8 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + NETTY + JAXB + [
- "@io_netty_netty//jar",
- "//protocols/isis/api:onos-protocols-isis-api",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/exceptions/IsisErrorType.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/exceptions/IsisErrorType.java
deleted file mode 100644
index d2ae7f7..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/exceptions/IsisErrorType.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.exceptions;
-
-/**
- * Defines all error codes and error sub codes.
- */
-public final class IsisErrorType {
-
- //Represents an invalid ISIS message header
- public static final byte MESSAGE_HEADER_ERROR = 1;
- //Represents an invalid ISIS message body
- public static final byte ISIS_MESSAGE_ERROR = 2;
- //Message Header error sub codes
- //Represents an invalid ISIS message length
- public static final byte BAD_MESSAGE_LENGTH = 3;
- //Represents an invalid ISIS message
- public static final byte BAD_MESSAGE = 4;
-
- /**
- * Creates an instance of ISIS error type.
- */
- private IsisErrorType() {
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/exceptions/IsisParseException.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/exceptions/IsisParseException.java
deleted file mode 100644
index 8da0522..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/exceptions/IsisParseException.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.exceptions;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Representation of a custom exception for ISIS.
- */
-public class IsisParseException extends Exception {
-
- private static final long serialVersionUID = 1L;
- private byte errorCode;
- private byte errorSubCode;
-
- /**
- * Creates a new ISIS exception.
- */
- public IsisParseException() {
- super();
- }
-
- /**
- * Creates a new ISIS exception based on the given arguments.
- *
- * @param message the detail of exception in string
- * @param cause underlying cause of the error
- */
- public IsisParseException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Creates a new ISIS exception for the given message.
- *
- * @param message the detail of exception in string
- */
- public IsisParseException(final String message) {
- super(message);
- }
-
- /**
- * Creates a new ISIS exception from throwable instance.
- *
- * @param cause underlying cause of the error
- */
- public IsisParseException(final Throwable cause) {
- super(cause);
- }
-
- /**
- * Creates a new ISIS exception from error code and error sub code.
- *
- * @param errorCode error code of ISIS message
- * @param errorSubCode error sub code of ISIS message
- */
- public IsisParseException(final byte errorCode, final byte errorSubCode) {
- super();
- this.errorCode = errorCode;
- this.errorSubCode = errorSubCode;
- }
-
- /**
- * Returns error code for this exception.
- *
- * @return error code for this exception
- */
- public byte errorCode() {
- return this.errorCode;
- }
-
- /**
- * Returns error sub code for this exception.
- *
- * @return error sub code for this exception
- */
- public byte errorSubCode() {
- return this.errorSubCode;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("errorCode", errorCode)
- .add("errorSubCode", errorSubCode)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/exceptions/package-info.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/exceptions/package-info.java
deleted file mode 100644
index 645a6da..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/exceptions/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ISIS protocol exceptions.
- */
-package org.onosproject.isis.exceptions;
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/IsisHeader.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/IsisHeader.java
deleted file mode 100644
index a80eac0..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/IsisHeader.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.MacAddress;
-import org.onosproject.isis.controller.IsisMessage;
-import org.onosproject.isis.controller.IsisPduType;
-
-/**
- * Representation of ISIS message header.
- */
-public class IsisHeader implements IsisMessage {
-
- private MacAddress sourceMac;
- private int interfaceIndex;
- private MacAddress interfaceMac;
- private int isisPduType;
- private byte irpDiscriminator;
- private byte pduHeaderLength;
- private byte version2;
- private byte idLength;
- private byte version;
- private byte reserved;
- private byte maximumAreaAddresses;
-
- /**
- * Returns the interface index on which the message received.
- *
- * @return interface index on which the message received
- */
- public int interfaceIndex() {
- return interfaceIndex;
- }
-
- /**
- * Sets the interface index on which the message received.
- *
- * @param interfaceIndex interface index on which the message received
- */
- public void setInterfaceIndex(int interfaceIndex) {
- this.interfaceIndex = interfaceIndex;
- }
-
- /**
- * Returns the interface mac address on which the message received.
- *
- * @return interface mac address on which the message received
- */
- public MacAddress interfaceMac() {
- return interfaceMac;
- }
-
- /**
- * Returns the mac address of the message sender.
- *
- * @return mac address of the message sender
- */
- public MacAddress sourceMac() {
- return sourceMac;
- }
-
- /**
- * Sets the mac address of the message sender.
- *
- * @param sourceMac mac address of the message sender
- */
- public void setSourceMac(MacAddress sourceMac) {
- this.sourceMac = sourceMac;
- }
-
- /**
- * Sets the interface mac address on which the message received.
- *
- * @param interfaceMac mac address on which the message received
- */
- public void setInterfaceMac(MacAddress interfaceMac) {
- this.interfaceMac = interfaceMac;
- }
-
- /**
- * Returns the version of TLV header.
- *
- * @return version version of TLV header
- */
- public byte version2() {
- return version2;
- }
-
- /**
- * Sets the version of TLV header.
- *
- * @param version2 version of TLV header
- */
- public void setVersion2(byte version2) {
- this.version2 = version2;
- }
-
- /**
- * Returns maximum area address.
- *
- * @return maximum area address
- */
- public byte maximumAreaAddresses() {
- return maximumAreaAddresses;
- }
-
- /**
- * Sets maximum area address.
- *
- * @param maximumAreaAddresses maximum area address
- */
- public void setMaximumAreaAddresses(byte maximumAreaAddresses) {
- this.maximumAreaAddresses = maximumAreaAddresses;
- }
-
- /**
- * Returns reserved field value on which data received.
- *
- * @return reserved
- */
- public byte reserved() {
- return reserved;
- }
-
- /**
- * Sets reserved.
- *
- * @param reserved reserved
- */
- public void setReserved(byte reserved) {
- this.reserved = reserved;
- }
-
- /**
- * Returns version.
- *
- * @return version
- */
- public byte version() {
- return version;
- }
-
- /**
- * Returns ID length.
- *
- * @return ID length
- */
- public byte idLength() {
- return idLength;
- }
-
- /**
- * Sets ID length.
- *
- * @param idLength ID length
- */
- public void setIdLength(byte idLength) {
- this.idLength = idLength;
- }
-
- /**
- * Returns the PDU type.
- *
- * @return PDU type
- */
- public int pduType() {
-
- return this.isisPduType;
- }
-
- /**
- * Sets PDU type.
- *
- * @param isisPduType PDU type
- */
- public void setIsisPduType(int isisPduType) {
- this.isisPduType = isisPduType;
- }
-
- /**
- * Sets protocol ID.
- *
- * @param version protocol ID
- */
- public void setVersion(byte version) {
- this.version = version;
- }
-
- /**
- * Returns length indicator.
- *
- * @return length indicator
- */
- public byte pduHeaderLength() {
- return pduHeaderLength;
- }
-
- /**
- * Sets length indicator.
- *
- * @param pduHeaderLength length indicator
- */
- public void setPduHeaderLength(byte pduHeaderLength) {
- this.pduHeaderLength = pduHeaderLength;
- }
-
- /**
- * Returns IRP discriminator.
- *
- * @return IRP discriminator
- */
- public byte irpDiscriminator() {
- return irpDiscriminator;
- }
-
- /**
- * Sets IRP discriminator.
- *
- * @param irpDiscriminator IRP discriminator
- */
- public void setIrpDiscriminator(byte irpDiscriminator) {
-
- this.irpDiscriminator = irpDiscriminator;
- }
-
- @Override
- public IsisPduType isisPduType() {
-
- return IsisPduType.get(this.isisPduType);
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- //implemented in the sub classes
- }
-
- @Override
- public byte[] asBytes() {
- return null;
- }
-
- /**
- * Populates ISIS header.
- *
- * @param isisHeader ISIS header
- */
- public void populateHeader(IsisHeader isisHeader) {
- this.setIrpDiscriminator(isisHeader.irpDiscriminator());
- this.setPduHeaderLength(isisHeader.pduHeaderLength());
- this.setVersion(isisHeader.version());
- this.setIdLength(isisHeader.idLength());
- this.setIsisPduType(isisHeader.pduType());
- this.setVersion2(isisHeader.version2());
- this.setReserved(isisHeader.reserved());
- this.setMaximumAreaAddresses(isisHeader.maximumAreaAddresses());
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/IsisMessageReader.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/IsisMessageReader.java
deleted file mode 100644
index 883a892..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/IsisMessageReader.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.controller.IsisMessage;
-import org.onosproject.isis.exceptions.IsisErrorType;
-import org.onosproject.isis.exceptions.IsisParseException;
-import org.onosproject.isis.io.isispacket.pdu.Csnp;
-import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-import org.onosproject.isis.io.isispacket.pdu.P2PHelloPdu;
-import org.onosproject.isis.io.isispacket.pdu.Psnp;
-import org.onosproject.isis.io.util.IsisConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Represents ISIS message reader.
- */
-public class IsisMessageReader {
-
- private static final Logger log = LoggerFactory.getLogger(IsisMessageReader.class);
-
- /**
- * Reads from ISIS packet from buffer.
- *
- * @param channelBuffer buffer
- * @return ISIS message
- * @throws IsisParseException exception
- */
- public IsisMessage readFromBuffer(ChannelBuffer channelBuffer) throws IsisParseException {
-
- int dataLength = channelBuffer.readableBytes();
- log.debug("IsisMessageReader::readFromBuffer Data length {}", dataLength);
- if (channelBuffer.readableBytes() < IsisConstants.PDU_LENGTH) {
- log.debug("Packet should have minimum length...");
- throw new IsisParseException(IsisErrorType.MESSAGE_HEADER_ERROR, IsisErrorType.BAD_MESSAGE_LENGTH);
- }
- IsisHeader isisHeader = getIsisHeader(channelBuffer);
- int totalLength = 0;
- IsisMessage isisMessage = null;
- switch (isisHeader.isisPduType()) {
- case L1HELLOPDU:
- case L2HELLOPDU:
- isisMessage = new L1L2HelloPdu(isisHeader);
- totalLength = channelBuffer.getShort(IsisConstants.PDULENGTHPOSITION);
- break;
- case P2PHELLOPDU:
- isisMessage = new P2PHelloPdu(isisHeader);
- totalLength = channelBuffer.getShort(IsisConstants.PDULENGTHPOSITION);
- break;
- case L1LSPDU:
- case L2LSPDU:
- isisMessage = new LsPdu(isisHeader);
- totalLength = channelBuffer.getShort(8);
- break;
- case L1CSNP:
- case L2CSNP:
- isisMessage = new Csnp(isisHeader);
- totalLength = channelBuffer.getShort(8);
- break;
- case L1PSNP:
- case L2PSNP:
- isisMessage = new Psnp(isisHeader);
- totalLength = channelBuffer.getShort(8);
- break;
- default:
- log.debug("Message Reader[Decoder] - Unknown PDU type..!!!");
- break;
- }
-
- if (isisMessage != null) {
- try {
- int bodyLength = totalLength - IsisConstants.COMMONHEADERLENGTH;
- isisMessage.readFrom(channelBuffer.readBytes(bodyLength));
-
- } catch (Exception e) {
- throw new IsisParseException(IsisErrorType.ISIS_MESSAGE_ERROR,
- IsisErrorType.BAD_MESSAGE);
- }
-
- }
-
- return isisMessage;
- }
-
- /**
- * Gets ISIS header.
- *
- * @param channelBuffer ISIS header
- * @return ISIS header
- */
- private IsisHeader getIsisHeader(ChannelBuffer channelBuffer) {
-
- IsisHeader isisHeader = new IsisHeader();
- isisHeader.setIrpDiscriminator(channelBuffer.readByte());
- isisHeader.setPduHeaderLength(channelBuffer.readByte());
- isisHeader.setVersion(channelBuffer.readByte());
- isisHeader.setIdLength(channelBuffer.readByte());
- isisHeader.setIsisPduType(channelBuffer.readByte());
- isisHeader.setVersion2(channelBuffer.readByte());
- isisHeader.setReserved(channelBuffer.readByte());
- isisHeader.setMaximumAreaAddresses(channelBuffer.readByte());
-
- return isisHeader;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/package-info.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/package-info.java
deleted file mode 100644
index c359bf7..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ISIS protocol.
- */
-package org.onosproject.isis.io.isispacket;
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/AttachedToOtherAreas.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/AttachedToOtherAreas.java
deleted file mode 100644
index 72e8c0f..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/AttachedToOtherAreas.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.pdu;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Representation of attached to other areas.
- */
-public enum AttachedToOtherAreas {
- DEFAULTMETRIC(1),
- DELAYMETRIC(2),
- EXPENSEMETRIC(4),
- ERRORMETRIC(8),
- NONE(0);
- // Reverse lookup table
- private static final Map<Integer, AttachedToOtherAreas> LOOKUP = new HashMap<>();
-
- // Populate the lookup table on loading time
- static {
- for (AttachedToOtherAreas attachedToOtherAreas :
- EnumSet.allOf(AttachedToOtherAreas.class)) {
- LOOKUP.put(attachedToOtherAreas.value(), attachedToOtherAreas);
- }
- }
-
- private int value;
-
- /**
- * Returns the attached to other areas value.
- *
- * @param value attached to other areas value
- */
- AttachedToOtherAreas(int value) {
- this.value = value;
- }
-
- /**
- * Returns the value for attached to other areas from pdu type value.
- *
- * @param pduTypeValue to get attached areas value
- * @return attachedToOtherAreas value of the enum
- */
- public static AttachedToOtherAreas get(int pduTypeValue) {
- return LOOKUP.get(pduTypeValue);
- }
-
- /**
- * Returns the value representing PDU type.
- *
- * @return value represents PDU type
- */
- public int value() {
- return value;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/Csnp.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/Csnp.java
deleted file mode 100644
index 09ccefa..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/Csnp.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.pdu;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
-import org.onosproject.isis.io.isispacket.tlv.TlvFinder;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.isispacket.tlv.TlvType;
-import org.onosproject.isis.io.isispacket.tlv.TlvsToBytes;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of complete sequence number PDU.
- */
-public class Csnp extends IsisHeader {
-
- /*
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Intra-domain Routing Protocol Discriminator |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Length Indicator |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version/Protocol ID Extension |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ID Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | R | R | R | PDU Type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Reserved |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Maximum area address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | PDU Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Source ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Start LSP ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | End LSP ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Variable Lengths Fields |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- CSNP Message Format
- REFERENCE : ISO/IEC 10589
- */
- private int pduLength;
- private String sourceId;
- private String startLspId;
- private String endLspId;
- private List<IsisTlv> variableLengths = new ArrayList<>();
-
- /**
- * Creates the instance for this class.
- *
- * @param isisHeader ISIS header
- */
- public Csnp(IsisHeader isisHeader) {
- populateHeader(isisHeader);
- }
-
- /**
- * Returns the list of all tlvs.
- *
- * @return variableLengths list of tlvs
- */
- public List<IsisTlv> getAllTlv() {
- return variableLengths;
- }
-
- /**
- * Returns the source ID of csnp.
- *
- * @return sourceId source ID
- */
- public String sourceId() {
- return sourceId;
- }
-
- /**
- * Sets the source ID for csnp.
- *
- * @param sourceId source ID
- */
- public void setSourceId(String sourceId) {
- this.sourceId = sourceId;
- }
-
- /**
- * Returns the initial link state packet ID of csnp.
- *
- * @return startLspId start link state packet ID
- */
- public String startLspId() {
- return startLspId;
- }
-
- /**
- * Sets the initial link state packet ID for csnp.
- *
- * @param startLspId start link state packet ID
- */
- public void setStartLspId(String startLspId) {
- this.startLspId = startLspId;
- }
-
- /**
- * Returns the end link state packet ID of csnp.
- *
- * @return endLspId end link state packet ID of csnp.
- */
- public String endLspId() {
- return endLspId;
- }
-
- /**
- * Sets the end link state packet ID for csnp.
- *
- * @param endLspId end link state packet ID of csnp.
- */
- public void setEndLspId(String endLspId) {
- this.endLspId = endLspId;
- }
-
- /**
- * Returns the packet data unit length of link state packet.
- * Entire length of this PDU, in octets
- *
- * @return pduLength packet date unit length
- */
- public int pduLength() {
- return pduLength;
- }
-
- /**
- * Sets the packet data unit length for link state packet.
- * Entire Length of this PDU, in octets
- *
- * @param pduLength packet data length
- */
- public void setPduLength(int pduLength) {
- this.pduLength = pduLength;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- this.setPduLength(channelBuffer.readUnsignedShort());
- //source id + 1 value
- byte[] tempByteArray = new byte[IsisUtil.ID_PLUS_ONE_BYTE];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_ONE_BYTE);
- this.setSourceId(IsisUtil.systemIdPlus(tempByteArray));
- //start lsp id + 2 value
- tempByteArray = new byte[IsisUtil.ID_PLUS_TWO_BYTE];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_TWO_BYTE);
- this.setStartLspId(IsisUtil.systemIdPlus(tempByteArray));
- //end lsp id + 2 value
- tempByteArray = new byte[IsisUtil.ID_PLUS_TWO_BYTE];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_TWO_BYTE);
- this.setEndLspId(IsisUtil.systemIdPlus(tempByteArray));
- //tlv here
- while (channelBuffer.readableBytes() > 0) {
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(channelBuffer.readUnsignedByte());
- tlvHeader.setTlvLength(channelBuffer.readUnsignedByte());
- TlvType tlvValue = TlvType.get(tlvHeader.tlvType());
- if (tlvValue != null) {
- IsisTlv tlv = TlvFinder.findTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength()));
- if (tlv != null) {
- this.variableLengths.add(tlv);
- }
- } else {
- channelBuffer.readBytes(tlvHeader.tlvLength());
- }
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] csnpMessage = null;
- byte[] isisPduHeader = isisPduHeader();
- byte[] csnpBody = completeSequenceNumberPduBody();
- csnpMessage = Bytes.concat(isisPduHeader, csnpBody);
- return csnpMessage;
- }
-
- /**
- * Builds ISIS PDU header for complete sequence numbers PDU.
- *
- * @return isisPduHeader ISIS PDU header
- */
- public byte[] isisPduHeader() {
- List<Byte> headerList = new ArrayList<>();
- headerList.add(this.irpDiscriminator());
- headerList.add((byte) IsisUtil.getPduHeaderLength(this.pduType()));
- headerList.add(this.version());
- headerList.add(this.idLength());
- headerList.add((byte) this.pduType());
- headerList.add(this.version2());
- headerList.add(this.reserved());
- headerList.add(this.maximumAreaAddresses());
- return Bytes.toArray(headerList);
- }
-
- /**
- * Builds complete sequence numbers PDU body.
- *
- * @return bodyList complete sequence numbers PDU body
- */
- public byte[] completeSequenceNumberPduBody() {
- List<Byte> bodyList = new ArrayList<>();
- bodyList.addAll(Bytes.asList(IsisUtil.convertToTwoBytes(this.pduLength())));
- bodyList.addAll(IsisUtil.sourceAndLanIdToBytes(this.sourceId()));
- bodyList.addAll(IsisUtil.sourceAndLanIdToBytes(this.startLspId()));
- bodyList.addAll(IsisUtil.sourceAndLanIdToBytes(this.endLspId()));
- for (IsisTlv isisTlv : variableLengths) {
- bodyList.addAll(TlvsToBytes.tlvToBytes(isisTlv));
- }
- return Bytes.toArray(bodyList);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("pduLength", pduLength)
- .add("sourceId", sourceId)
- .add("startLspId", startLspId)
- .add("endLspId", endLspId)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- Csnp that = (Csnp) o;
- return Objects.equal(pduLength, that.pduLength) &&
- Objects.equal(sourceId, that.sourceId) &&
- Objects.equal(startLspId, that.startLspId) &&
- Objects.equal(endLspId, that.endLspId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(pduLength, sourceId, startLspId, endLspId);
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/HelloPdu.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/HelloPdu.java
deleted file mode 100644
index 05e6448..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/HelloPdu.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.pdu;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.MacAddress;
-import org.onosproject.isis.controller.IsisInterfaceState;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.tlv.AdjacencyStateTlv;
-import org.onosproject.isis.io.isispacket.tlv.AreaAddressTlv;
-import org.onosproject.isis.io.isispacket.tlv.IpInterfaceAddressTlv;
-import org.onosproject.isis.io.isispacket.tlv.IsisNeighborTlv;
-import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of ISIS hello PDU.
- */
-public abstract class HelloPdu extends IsisHeader {
-
- protected List<IsisTlv> variableLengths = new ArrayList<>();
- private byte circuitType;
- private String sourceId;
- private int holdingTime;
- private int pduLength;
-
- public void addTlv(IsisTlv isisTlv) {
- variableLengths.add(isisTlv);
- }
-
- /**
- * Returns the variable lengths.
- *
- * @return variable lengths
- */
- public List<IsisTlv> tlvs() {
- return variableLengths;
- }
-
- /**
- * Returns the list of area addresses.
- *
- * @return areaAddresses area addresses
- */
- public List<String> areaAddress() {
- List<String> areaAddresses = null;
- for (IsisTlv tlv : tlvs()) {
- if (tlv instanceof AreaAddressTlv) {
- areaAddresses = ((AreaAddressTlv) tlv).areaAddress();
- }
- }
- return areaAddresses;
- }
-
- /**
- * Returns the list of interface IP addresses.
- *
- * @return interfaceIpAddresses list of interface IP addresses
- */
- public List<Ip4Address> interfaceIpAddresses() {
- List<Ip4Address> interfaceIpAddresses = null;
- for (IsisTlv tlv : tlvs()) {
- if (tlv instanceof IpInterfaceAddressTlv) {
- interfaceIpAddresses = ((IpInterfaceAddressTlv) tlv).interfaceAddress();
- }
- }
- return interfaceIpAddresses;
- }
-
- /**
- * Returns the list of neighbor list.
- *
- * @return macAddresses list of neighbor MAC address
- */
- public List<MacAddress> neighborList() {
- List<MacAddress> macAddresses = null;
- for (IsisTlv tlv : tlvs()) {
- if (tlv instanceof IsisNeighborTlv) {
- macAddresses = ((IsisNeighborTlv) tlv).neighbor();
- }
- }
- return macAddresses;
- }
-
- /**
- * Returns the adjacency state.
- *
- * @return interfaceState adjacency state
- */
- public IsisInterfaceState adjacencyState() {
- IsisInterfaceState interfaceState = null;
- for (IsisTlv tlv : tlvs()) {
- if (tlv instanceof AdjacencyStateTlv) {
- interfaceState = IsisInterfaceState.get(((AdjacencyStateTlv) tlv).adjacencyType());
- break;
- }
- }
- return interfaceState;
- }
-
- /**
- * Returns the source ID.
- *
- * @return sourceId source ID
- */
- public String sourceId() {
- return sourceId;
- }
-
- /**
- * Sets source ID.
- *
- * @param sourceId source ID
- */
- public void setSourceId(String sourceId) {
- this.sourceId = sourceId;
- }
-
- /**
- * Returns the PDU length.
- *
- * @return pduLength PDU length
- */
- public int pduLength() {
- return pduLength;
- }
-
- /**
- * Sets the PDU length.
- *
- * @param pduLength PDU length
- */
- public void setPduLength(int pduLength) {
- this.pduLength = pduLength;
- }
-
- /**
- * Returns the holding time.
- *
- * @return holdingTime holding time
- */
- public int holdingTime() {
- return holdingTime;
- }
-
- /**
- * Sets the holding time.
- *
- * @param holdingTime holding time
- */
- public void setHoldingTime(int holdingTime) {
- this.holdingTime = holdingTime;
- }
-
- /**
- * Returns the circuit type.
- *
- * @return circuitType circuit type
- */
- public byte circuitType() {
- return circuitType;
- }
-
- /**
- * Sets the circuit type.
- *
- * @param circuitType circuit type
- */
- public void setCircuitType(byte circuitType) {
- this.circuitType = circuitType;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("circuitType", circuitType)
- .add("sourceId", sourceId)
- .add("holdingTime", holdingTime)
- .add("pduLength", pduLength)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- HelloPdu that = (HelloPdu) o;
- return Objects.equal(circuitType, that.circuitType) &&
- Objects.equal(sourceId, that.sourceId) &&
- Objects.equal(holdingTime, that.holdingTime) &&
- Objects.equal(pduLength, that.pduLength);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(circuitType, sourceId, holdingTime, pduLength);
- }
-}
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/L1L2HelloPdu.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/L1L2HelloPdu.java
deleted file mode 100644
index 53a82a8..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/L1L2HelloPdu.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.pdu;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
-import org.onosproject.isis.io.isispacket.tlv.TlvFinder;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.isispacket.tlv.TlvType;
-import org.onosproject.isis.io.isispacket.tlv.TlvsToBytes;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of L1L2 hello PDU.
- */
-public class L1L2HelloPdu extends HelloPdu {
-
- /*
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Intra-domain Routing Protocol Discriminator |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Length Indicator |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version/Protocol ID Extension |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ID Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | R | R | R | PDU Type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Reserved |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Maximum area address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Circuit Type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Source ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Holding Time |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | PDU Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | PDU Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | R | Priority |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LAN ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Variable Lengths Fields |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Hello Message Format
- REFERENCE : ISO/IEC 10589
- */
-
- private byte priority;
- private String lanId;
-
- /**
- * Parametrized constructor.
- *
- * @param isisHeader ISIs header
- */
- public L1L2HelloPdu(IsisHeader isisHeader) {
- populateHeader(isisHeader);
- }
-
- /**
- * Returns the LAN ID.
- *
- * @return LAN ID
- */
-
- public String lanId() {
- return lanId;
- }
-
- /**
- * Sets the LAN ID.
- *
- * @param lanId LAN ID
- */
- public void setLanId(String lanId) {
- this.lanId = lanId;
- }
-
- /**
- * Returns the priority.
- *
- * @return priority
- */
- public byte priority() {
- return priority;
- }
-
- /**
- * Sets priority.
- *
- * @param priority priority
- */
- public void setPriority(byte priority) {
- this.priority = priority;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- this.setCircuitType(channelBuffer.readByte());
- //sorce id
- byte[] tempByteArray = new byte[IsisUtil.ID_SIX_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_SIX_BYTES);
- this.setSourceId(IsisUtil.systemId(tempByteArray));
- this.setHoldingTime(channelBuffer.readUnsignedShort());
- this.setPduLength(channelBuffer.readUnsignedShort());
- this.setPriority(channelBuffer.readByte());
- //landid id + 1 value
- tempByteArray = new byte[IsisUtil.ID_PLUS_ONE_BYTE];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_ONE_BYTE);
- this.setLanId(IsisUtil.systemIdPlus(tempByteArray));
- //tlv here
- while (channelBuffer.readableBytes() > 0) {
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(channelBuffer.readUnsignedByte());
- tlvHeader.setTlvLength(channelBuffer.readUnsignedByte());
- TlvType tlvType = TlvType.get(tlvHeader.tlvType());
- if (tlvType != null) {
- IsisTlv tlv = TlvFinder.findTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength()));
- if (tlv != null) {
- this.variableLengths.add(tlv);
- }
- } else {
- channelBuffer.readBytes(tlvHeader.tlvLength());
- }
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] helloMessage = null;
- byte[] helloHeader = l1l2IsisPduHeader();
- byte[] helloBody = l1l2HelloPduBody();
- helloMessage = Bytes.concat(helloHeader, helloBody);
- return helloMessage;
- }
-
- /**
- * Parse the ISIS L1L2 PDU header.
- *
- * @return ISIS L1L2 PDU header
- */
- public byte[] l1l2IsisPduHeader() {
- List<Byte> headerLst = new ArrayList<>();
- headerLst.add(this.irpDiscriminator());
- headerLst.add((byte) IsisUtil.getPduHeaderLength(this.pduType()));
- headerLst.add(this.version());
- headerLst.add(this.idLength());
- headerLst.add((byte) this.pduType());
- headerLst.add(this.version2());
- headerLst.add(this.reserved());
- headerLst.add(this.maximumAreaAddresses());
- return Bytes.toArray(headerLst);
- }
-
- /**
- * Parse the ISIS L1L2 PDU body.
- *
- * @return ISIS L1L2 PDU body
- */
- public byte[] l1l2HelloPduBody() {
- List<Byte> bodyLst = new ArrayList<>();
-
- bodyLst.add(this.circuitType());
- bodyLst.addAll(IsisUtil.sourceAndLanIdToBytes(this.sourceId()));
- bodyLst.addAll(Bytes.asList(IsisUtil.convertToTwoBytes(this.holdingTime())));
- bodyLst.addAll(Bytes.asList(IsisUtil.convertToTwoBytes(this.pduLength())));
- bodyLst.add(this.priority);
- bodyLst.addAll(IsisUtil.sourceAndLanIdToBytes(this.lanId()));
- for (IsisTlv isisTlv : variableLengths) {
- bodyLst.addAll(TlvsToBytes.tlvToBytes(isisTlv));
- }
- return Bytes.toArray(bodyLst);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("priority", priority)
- .add("lanId", lanId)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- L1L2HelloPdu that = (L1L2HelloPdu) o;
- return Objects.equal(priority, that.priority) &&
- Objects.equal(lanId, that.lanId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(priority, lanId);
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/LsPdu.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/LsPdu.java
deleted file mode 100644
index b1c8474..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/LsPdu.java
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.isis.io.isispacket.pdu;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
-import org.onosproject.isis.io.isispacket.tlv.TlvFinder;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.isispacket.tlv.TlvType;
-import org.onosproject.isis.io.isispacket.tlv.TlvsToBytes;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of an ISIS Link State packet.
- * Each Link State packet carries a collection of TLVs
- * Several TLVs may be included in a single packet.
- */
-public class LsPdu extends IsisHeader {
-
- /*
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Intra-domain Routing Protocol Discriminator |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Length Indicator |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version/Protocol ID Extension |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ID Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | R | R | R | PDU Type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Reserved |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Maximum area address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | PDU Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Remaining Lifetime |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LSP ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | PDU Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Sequence Number |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Checksum |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | P | ATT | LSPDBOL | IS Type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Variable Lengths Fields |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- LS PDU Format
- REFERENCE : ISO/IEC 10589
- */
- private int pduLength;
- private int remainingLifeTime;
- private String lspId;
- private int sequenceNumber;
- private int checkSum;
- private boolean partitionRepair;
- private AttachedToOtherAreas attachedToOtherAreas;
- private boolean lspDbol;
- private byte typeBlock;
- private byte intermediateSystemType;
- private List<IsisTlv> variableLengths = new ArrayList<>();
-
- /**
- * Creates an instance of Link State packet.
- *
- * @param isisHeader isis header details
- */
- public LsPdu(IsisHeader isisHeader) {
- populateHeader(isisHeader);
- }
-
- /**
- * Returns the ISIS tlvs.
- *
- * @return tlvs
- */
- public List<IsisTlv> tlvs() {
- return this.variableLengths;
- }
-
- /**
- * Adds the isis tlv to the list for the link state PDU.
- *
- * @param isisTlv isis tlv
- */
- public void addTlv(IsisTlv isisTlv) {
- variableLengths.add(isisTlv);
- }
-
- /**
- * Returns the remaining time of the link state pdu.
- * Number of seconds before LSP considered expired
- *
- * @return remainingTime remaining time
- */
- public int remainingLifeTime() {
- return remainingLifeTime;
- }
-
- /**
- * Sets the remaining time for the link state pdu.
- *
- * @param remainingLifeTime remaining time
- */
- public void setRemainingLifeTime(int remainingLifeTime) {
- this.remainingLifeTime = remainingLifeTime;
- }
-
- /**
- * Returns the link state database overload.
- *
- * @return lspdbol link state database overload
- */
- public boolean lspDbol() {
- return lspDbol;
- }
-
- /**
- * Sets the link state database overload for this pdu.
- *
- * @param lspDbol link state database overload
- */
- public void setLspDbol(boolean lspDbol) {
- this.lspDbol = lspDbol;
- }
-
- /**
- * Returns the type block.
- *
- * @return type block
- */
- public byte typeBlock() {
- return typeBlock;
- }
-
- /**
- * Sets the type block.
- *
- * @param typeBlock type block
- */
- public void setTypeBlock(byte typeBlock) {
- this.typeBlock = typeBlock;
- }
-
- /**
- * Returns the sequence number of LSP.
- *
- * @return sequenceNumber sequence number
- */
- public int sequenceNumber() {
- return sequenceNumber;
- }
-
- /**
- * Sets the sequence nubmer for LSP.
- *
- * @param sequenceNumber sequence number
- */
- public void setSequenceNumber(int sequenceNumber) {
- this.sequenceNumber = sequenceNumber;
- }
-
- /**
- * Returns the checksum of LSP from Source ID to end.
- *
- * @return checkSum check sum
- */
- public int checkSum() {
- return checkSum;
- }
-
- /**
- * Sets the checksum for LSP from Source ID to end.
- *
- * @param checkSum check sum
- */
- public void setCheckSum(int checkSum) {
- this.checkSum = checkSum;
- }
-
- /**
- * Returns the partition repair value of the intermediate system.
- *
- * @return partitionRepair partition repair
- */
- public boolean partitionRepair() {
- return partitionRepair;
- }
-
- /**
- * Sets partition repair value for the intermediate system.
- *
- * @param partitionRepair partition repair
- */
- public void setPartitionRepair(boolean partitionRepair) {
- this.partitionRepair = partitionRepair;
- }
-
- /**
- * Returns the value of intermediate system attached field.
- * return values based on type Default Metric, Delay Metric, Expense Metric, Error Metric
- *
- * @return attachedToOtherAreas attached to other areas
- */
- public AttachedToOtherAreas attachedToOtherAreas() {
- return attachedToOtherAreas;
- }
-
- /**
- * Sets the value for intermediate system attached field.
- * it will pass values based on type Default Metric, Delay Metric, Expense Metric, Error Metric
- *
- * @param attachedToOtherAreas attached to other areas
- */
- public void setAttachedToOtherAreas(AttachedToOtherAreas attachedToOtherAreas) {
- this.attachedToOtherAreas = attachedToOtherAreas;
- }
-
- /**
- * Returns the intermediate system type.
- * type will be level 1 or level 2
- *
- * @return intermediateSystemType intermediate system type
- */
- public byte intermediateSystemType() {
- return intermediateSystemType;
- }
-
- /**
- * Sets the value for intermediate system.
- * type will be level 1 or level 2
- *
- * @param intermediateSystemType intermediate system type
- */
- public void setIntermediateSystemType(byte intermediateSystemType) {
- this.intermediateSystemType = intermediateSystemType;
- }
-
- /**
- * Returns the link state ID of link state packet.
- * System ID of the source of link state PDU
- *
- * @return lspId link state packet ID
- */
- public String lspId() {
- return lspId;
- }
-
- /**
- * Sets the link state ID for link state packet.
- * System ID of the source of link state PDU
- *
- * @param lspId link state packet ID
- */
- public void setLspId(String lspId) {
- this.lspId = lspId;
- }
-
- /**
- * Returns the packet data unit length of link state packet.
- * Entire length of this PDU, in octets
- *
- * @return pduLength packet data unit length
- */
- public int pduLength() {
- return pduLength;
- }
-
- /**
- * Sets the packet data unit length for link state packet.
- * Entire Length of this PDU, in octets
- *
- * @param pduLength packet data length
- */
- public void setPduLength(int pduLength) {
- this.pduLength = pduLength;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
-
- this.setPduLength(channelBuffer.readUnsignedShort());
- this.setRemainingLifeTime(channelBuffer.readUnsignedShort());
- //lsp id + 2 value
- byte[] tempByteArray = new byte[IsisUtil.ID_PLUS_TWO_BYTE];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_TWO_BYTE);
- this.setLspId(IsisUtil.systemIdPlus(tempByteArray));
- //sequence number 4
- this.setSequenceNumber(channelBuffer.readInt());
- this.setCheckSum(channelBuffer.readUnsignedShort());
- int typeTemp = channelBuffer.readUnsignedByte();
- byte isTypeByte = (byte) typeTemp;
- String tempValue = String.format("%8s", Integer.toBinaryString(isTypeByte & 0xFF)).replace(' ', '0');
- int pBit = Integer.parseInt(new Character(tempValue.charAt(0)).toString());
- if (pBit == 1) {
- this.setPartitionRepair(true);
- } else {
- this.setPartitionRepair(false);
- }
- int attValue = Integer.parseInt(tempValue.substring(1, 5), 2);
- switch (AttachedToOtherAreas.get(attValue)) {
- case DEFAULTMETRIC:
- this.setAttachedToOtherAreas(AttachedToOtherAreas.DEFAULTMETRIC);
- break;
- case DELAYMETRIC:
- this.setAttachedToOtherAreas(AttachedToOtherAreas.DELAYMETRIC);
- break;
- case EXPENSEMETRIC:
- this.setAttachedToOtherAreas(AttachedToOtherAreas.EXPENSEMETRIC);
- break;
- case ERRORMETRIC:
- this.setAttachedToOtherAreas(AttachedToOtherAreas.ERRORMETRIC);
- break;
- case NONE:
- this.setAttachedToOtherAreas(AttachedToOtherAreas.NONE);
- break;
- default:
- break;
- }
- int lspdbol = Integer.parseInt(new Character(tempValue.charAt(5)).toString());
- if (lspdbol == 1) {
- this.setLspDbol(true);
- } else {
- this.setLspDbol(false);
- }
- int isType = Integer.parseInt(tempValue.substring(6, 8), 2);
- byte isTypeByteValue = (byte) isType;
- this.setIntermediateSystemType(isTypeByteValue);
- //tlv here
- while (channelBuffer.readableBytes() > 0) {
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(channelBuffer.readUnsignedByte());
- tlvHeader.setTlvLength(channelBuffer.readUnsignedByte());
- TlvType tlvValue = TlvType.get(tlvHeader.tlvType());
- if (tlvValue != null) {
- IsisTlv tlv = TlvFinder.findTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength()));
- if (tlv != null) {
- this.variableLengths.add(tlv);
- }
- } else {
- channelBuffer.readBytes(tlvHeader.tlvLength());
- }
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] lspMessage = null;
- byte[] helloHeader = l1l2IsisPduHeader();
- byte[] lspBody = l1l2LsPduBody();
- lspMessage = Bytes.concat(helloHeader, lspBody);
- return lspMessage;
- }
-
- /**
- * Builds ISIS PDU header from ISIS message.
- *
- * @return headerList ISIS PDU header
- */
- public byte[] l1l2IsisPduHeader() {
- List<Byte> headerList = new ArrayList<>();
- headerList.add(this.irpDiscriminator());
- headerList.add((byte) IsisUtil.getPduHeaderLength(this.pduType()));
- headerList.add(this.version());
- headerList.add(this.idLength());
- headerList.add((byte) this.pduType());
- headerList.add(this.version2());
- headerList.add(this.reserved());
- headerList.add(this.maximumAreaAddresses());
- return Bytes.toArray(headerList);
- }
-
- /**
- * Builds link state PDU body from ISIS message.
- *
- * @return bodyList link state PDU body
- */
- public byte[] l1l2LsPduBody() {
- List<Byte> bodyList = new ArrayList<>();
- bodyList.addAll(Bytes.asList(IsisUtil.convertToTwoBytes(this.pduLength())));
- bodyList.addAll(Bytes.asList(IsisUtil.convertToTwoBytes(this.remainingLifeTime())));
- bodyList.addAll(IsisUtil.sourceAndLanIdToBytes(this.lspId()));
- bodyList.addAll(Bytes.asList(IsisUtil.convertToFourBytes(this.sequenceNumber())));
- bodyList.addAll(Bytes.asList(IsisUtil.convertToTwoBytes(this.checkSum())));
- String temString = "";
- if (this.partitionRepair()) {
- temString = "1" + temString;
- } else {
- temString = "0" + temString;
- }
- switch (this.attachedToOtherAreas()) {
- case ERRORMETRIC:
- temString = temString + "1000";
- break;
- case EXPENSEMETRIC:
- temString = temString + "0100";
- break;
- case DELAYMETRIC:
- temString = temString + "0010";
- break;
- case DEFAULTMETRIC:
- temString = temString + "0001";
- break;
- case NONE:
- temString = temString + "0000";
- break;
- default:
- break;
- }
- if (this.lspDbol()) {
- temString = temString + "1";
- } else {
- temString = temString + "0";
- }
- String isType = Integer.toBinaryString(this.intermediateSystemType());
- if (isType.length() % 2 != 0) {
- isType = "0" + isType;
- }
- temString = temString + isType;
- bodyList.add((byte) Integer.parseInt(temString, 2));
- for (IsisTlv isisTlv : variableLengths) {
- bodyList.addAll(TlvsToBytes.tlvToBytes(isisTlv));
- }
- return Bytes.toArray(bodyList);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("pduLength", pduLength)
- .add("remainingLifeTime", remainingLifeTime)
- .add("lspId", lspId)
- .add("sequenceNumber", sequenceNumber)
- .add("checkSum", checkSum)
- .add("partitionRepair", partitionRepair)
- .add("lspDbol", lspDbol)
- .add("typeBlock", typeBlock)
- .add("intermediateSystemType", intermediateSystemType)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- LsPdu that = (LsPdu) o;
- return Objects.equal(pduLength, that.pduLength) &&
- Objects.equal(remainingLifeTime, that.remainingLifeTime) &&
- Objects.equal(lspId, that.lspId) &&
- Objects.equal(sequenceNumber, that.sequenceNumber) &&
- Objects.equal(checkSum, that.checkSum) &&
- Objects.equal(partitionRepair, that.partitionRepair) &&
- Objects.equal(lspDbol, that.lspDbol) &&
- Objects.equal(typeBlock, that.typeBlock) &&
- Objects.equal(intermediateSystemType, that.intermediateSystemType);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(pduLength, remainingLifeTime, lspId, sequenceNumber,
- checkSum, partitionRepair, lspDbol, typeBlock, intermediateSystemType);
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/P2PHelloPdu.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/P2PHelloPdu.java
deleted file mode 100644
index 15644d6..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/P2PHelloPdu.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.pdu;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
-import org.onosproject.isis.io.isispacket.tlv.TlvFinder;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.isispacket.tlv.TlvType;
-import org.onosproject.isis.io.isispacket.tlv.TlvsToBytes;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of P2P hello.
- */
-public class P2PHelloPdu extends HelloPdu {
- /*
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Intra-domain Routing Protocol Discriminator |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Length Indicator |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version/Protocol ID Extension |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ID Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | R | R | R | PDU Type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Reserved |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Maximum area address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Circuit Type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Source ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Holding Time |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | PDU Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Local Circuit Id |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Variable Lengths Fields |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- P2P Hello Message Format
- REFERENCE : ISO/IEC 10589
- */
- private byte localCircuitId;
-
- /**
- * Sets the ISIS header.
- *
- * @param isisHeader isisHeader
- */
- public P2PHelloPdu(IsisHeader isisHeader) {
- populateHeader(isisHeader);
- }
-
- /**
- * Returns the local circuit ID.
- *
- * @return Local circuit ID
- */
- public byte localCircuitId() {
- return localCircuitId;
- }
-
- /**
- * Sets the local circuit ID.
- *
- * @param localCircuitId Local circuit ID
- */
- public void setLocalCircuitId(byte localCircuitId) {
- this.localCircuitId = localCircuitId;
- }
-
- /**
- * Sets the variable lengths.
- *
- * @param variableLengths variable lengths.
- */
- public void setVariableLengths(List<IsisTlv> variableLengths) {
- this.variableLengths = variableLengths;
- }
-
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- this.setCircuitType(channelBuffer.readByte());
- //source id
- byte[] tempByteArray = new byte[IsisUtil.ID_SIX_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_SIX_BYTES);
- this.setSourceId(IsisUtil.systemId(tempByteArray));
- this.setHoldingTime(channelBuffer.readUnsignedShort());
- this.setPduLength(channelBuffer.readUnsignedShort());
- this.setLocalCircuitId((byte) channelBuffer.readUnsignedByte());
- while (channelBuffer.readableBytes() > 0) {
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(channelBuffer.readUnsignedByte());
- tlvHeader.setTlvLength(channelBuffer.readUnsignedByte());
- TlvType tlvType = TlvType.get(tlvHeader.tlvType());
- if (tlvType != null) {
- IsisTlv tlv = TlvFinder.findTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength()));
- if (tlv != null) {
- this.variableLengths.add(tlv);
- }
- } else {
- channelBuffer.readBytes(tlvHeader.tlvLength());
- }
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] helloMessage = null;
- byte[] helloHeader = p2PHeader();
- byte[] helloBody = p2P2HelloPduBody();
- helloMessage = Bytes.concat(helloHeader, helloBody);
- return helloMessage;
- }
-
- /**
- * Builds the point to point header.
- *
- * @return headerList point to point header
- */
- public byte[] p2PHeader() {
- List<Byte> headerList = new ArrayList<>();
- headerList.add(this.irpDiscriminator());
- headerList.add((byte) IsisUtil.getPduHeaderLength(this.pduType()));
- headerList.add(this.version());
- headerList.add(this.idLength());
- headerList.add((byte) this.pduType());
- headerList.add(this.version2());
- headerList.add(this.reserved());
- headerList.add(this.maximumAreaAddresses());
- return Bytes.toArray(headerList);
- }
-
- /**
- * Builds the point to point hello PDU body.
- *
- * @return bodyList point to point hello PDU body
- */
- public byte[] p2P2HelloPduBody() {
- List<Byte> bodyList = new ArrayList<>();
- bodyList.add(this.circuitType());
- bodyList.addAll(IsisUtil.sourceAndLanIdToBytes(this.sourceId()));
- bodyList.addAll(Bytes.asList(IsisUtil.convertToTwoBytes(this.holdingTime())));
- bodyList.addAll(Bytes.asList(IsisUtil.convertToTwoBytes(this.pduLength())));
- bodyList.add((byte) this.localCircuitId());
- for (IsisTlv isisTlv : variableLengths) {
- bodyList.addAll(TlvsToBytes.tlvToBytes(isisTlv));
- }
- return Bytes.toArray(bodyList);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("localCircuitId", localCircuitId)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- P2PHelloPdu that = (P2PHelloPdu) o;
- return Objects.equal(localCircuitId, that.localCircuitId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(localCircuitId);
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/Psnp.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/Psnp.java
deleted file mode 100644
index 2d29a7c..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/Psnp.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.pdu;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
-import org.onosproject.isis.io.isispacket.tlv.TlvFinder;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.isispacket.tlv.TlvType;
-import org.onosproject.isis.io.isispacket.tlv.TlvsToBytes;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of partial sequence number PDU.
- */
-public class Psnp extends IsisHeader {
- /*
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Intradomain Routing Protocol Discriminator |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Length Indicator |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version/Protocol ID Extension |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ID Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | R | R | R | PDU Type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Reserved |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Maximum area address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | PDU Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Source ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Start LSP ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | End LSP ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Variable Lengths Fields |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Hello Message Format
- REFERENCE : ISO/IEC 10589
- */
- private int pduLength;
- private String sourceId;
- private List<IsisTlv> variableLengths = new ArrayList<>();
-
- /**
- * Creates the instance for this class.
- *
- * @param isisHeader ISIS header
- */
- public Psnp(IsisHeader isisHeader) {
- populateHeader(isisHeader);
- }
-
- /**
- * Adds the TLV to list.
- *
- * @param isisTlv ISIS TLV instance
- */
- public void addTlv(IsisTlv isisTlv) {
- variableLengths.add(isisTlv);
- }
-
- /**
- * Returns the list of all tlvs.
- *
- * @return variableLengths list of tlvs
- */
- public List<IsisTlv> getAllTlv() {
- return variableLengths;
- }
-
- /**
- * Returns the source ID of csnp.
- *
- * @return sourceId source ID
- */
- public String sourceId() {
- return sourceId;
- }
-
- /**
- * Sets the source ID for csnp.
- *
- * @param sourceId source ID
- */
- public void setSourceId(String sourceId) {
- this.sourceId = sourceId;
- }
-
- /**
- * Returns the packet data unit length of link state packet.
- * Entire length of this PDU, in octets
- *
- * @return pduLength packte date unit length
- */
- public int pduLength() {
- return pduLength;
- }
-
- /**
- * Sets the packet data unit length for link state packet.
- * Entire Length of this PDU, in octets
- *
- * @param pduLength packte data length
- */
- public void setPduLength(int pduLength) {
- this.pduLength = pduLength;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- this.setPduLength(channelBuffer.readUnsignedShort());
- //source id + 2 value
- byte[] tempByteArray = new byte[IsisUtil.ID_PLUS_ONE_BYTE];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_ONE_BYTE);
- this.setSourceId(IsisUtil.systemIdPlus(tempByteArray));
- //tlv here
- while (channelBuffer.readableBytes() > 0) {
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(channelBuffer.readUnsignedByte());
- tlvHeader.setTlvLength(channelBuffer.readUnsignedByte());
- TlvType tlvValue = TlvType.get(tlvHeader.tlvType());
- if (tlvValue != null) {
- IsisTlv tlv = TlvFinder.findTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength()));
- if (tlv != null) {
- this.variableLengths.add(tlv);
- }
- } else {
- channelBuffer.readBytes(tlvHeader.tlvLength());
- }
- }
- }
-
-
- @Override
- public byte[] asBytes() {
- byte[] psnpMessage = null;
- byte[] isisPduHeader = isisPduHeader();
- byte[] psnpBody = partialSequenceNumberPduBody();
- psnpMessage = Bytes.concat(isisPduHeader, psnpBody);
- return psnpMessage;
- }
-
- /**
- * Builds the ISIS PDU header.
- *
- * @return headerList ISIS PDU header
- */
- public byte[] isisPduHeader() {
- List<Byte> headerList = new ArrayList<>();
- headerList.add(this.irpDiscriminator());
- headerList.add((byte) IsisUtil.getPduHeaderLength(this.pduType()));
- headerList.add(this.version());
- headerList.add(this.idLength());
- headerList.add((byte) this.pduType());
- headerList.add(this.version2());
- headerList.add(this.reserved());
- headerList.add(this.maximumAreaAddresses());
- return Bytes.toArray(headerList);
- }
-
- /**
- * Builds the partial sequence number PDU body.
- *
- * @return bodyList partial sequence number PDU body
- */
- public byte[] partialSequenceNumberPduBody() {
- List<Byte> bodyList = new ArrayList<>();
- bodyList.addAll(Bytes.asList(IsisUtil.convertToTwoBytes(this.pduLength())));
- bodyList.addAll(IsisUtil.sourceAndLanIdToBytes(this.sourceId()));
- for (IsisTlv isisTlv : variableLengths) {
- bodyList.addAll(TlvsToBytes.tlvToBytes(isisTlv));
- }
- return Bytes.toArray(bodyList);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("pduLength", pduLength)
- .add("sourceId", sourceId)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- Psnp that = (Psnp) o;
- return Objects.equal(pduLength, that.pduLength);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(sourceId, pduLength);
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/package-info.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/package-info.java
deleted file mode 100644
index 471e49c..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the isis protocol.
- */
-package org.onosproject.isis.io.isispacket.pdu;
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/AdjacencyStateTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/AdjacencyStateTlv.java
deleted file mode 100644
index 08a98fb..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/AdjacencyStateTlv.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
-* Copyright 2016-present Open Networking Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of adjacency state TLV of P2P neighbor.
- */
-public class AdjacencyStateTlv extends TlvHeader implements IsisTlv {
-
- private byte adjacencyType;
- private int localCircuitId;
- private String neighborSystemId;
- private int neighborLocalCircuitId;
-
- /**
- * Creates an instance of adjacency state TLV..
- *
- * @param tlvHeader TLV header
- */
- public AdjacencyStateTlv(TlvHeader tlvHeader) {
- this.setTlvType(tlvHeader.tlvType());
- this.setTlvLength(tlvHeader.tlvLength());
- }
-
- /**
- * Returns local circuit ID for adjacency state TLV.
- *
- * @return local circuit ID
- */
- public int localCircuitId() {
- return localCircuitId;
- }
-
- /**
- * Sets local circuit ID for adjacency state TLV.
- *
- * @param localCircuitId local circuit Id
- */
- public void setLocalCircuitId(int localCircuitId) {
- this.localCircuitId = localCircuitId;
- }
-
- /**
- * Returns neighbor system ID for adjacency state TLV.
- *
- * @return neighbor system ID
- */
- public String neighborSystemId() {
- return neighborSystemId;
- }
-
- /**
- * Sets neighbor system ID for adjacency state TLV.
- *
- * @param neighborSystemId neighbor system ID
- */
- public void setNeighborSystemId(String neighborSystemId) {
- this.neighborSystemId = neighborSystemId;
- }
-
- /**
- * Returns neighbor local circuit ID for adjacency state TLV.
- *
- * @return neighbor local circuit ID
- */
- public int neighborLocalCircuitId() {
- return neighborLocalCircuitId;
- }
-
- /**
- * Sets neighbor local circuit ID for adjacency state TLV.
- *
- * @param neighborLocalCircuitId neighbor local circuit ID
- */
- public void setNeighborLocalCircuitId(int neighborLocalCircuitId) {
- this.neighborLocalCircuitId = neighborLocalCircuitId;
- }
-
- /**
- * Returns adjacency type of adjacency state TLV.
- *
- * @return adjacency type
- */
- public byte adjacencyType() {
- return adjacencyType;
- }
-
- /**
- * Sets adjacency type for adjacency state TLV.
- *
- * @param adjacencyType adjacency type
- */
- public void setAdjacencyType(byte adjacencyType) {
- this.adjacencyType = adjacencyType;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- this.setAdjacencyType(channelBuffer.readByte());
- this.setLocalCircuitId(channelBuffer.readInt());
- if (channelBuffer.readableBytes() > 0) {
- byte[] tempByteArray = new byte[IsisUtil.ID_SIX_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_SIX_BYTES);
- this.setNeighborSystemId(IsisUtil.systemId(tempByteArray));
- this.setNeighborLocalCircuitId(channelBuffer.readInt());
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] bytes = null;
- byte[] tlvHeader = tlvHeaderAsByteArray();
- byte[] tlvBody = tlvBodyAsBytes();
- tlvHeader[1] = (byte) tlvBody.length;
- bytes = Bytes.concat(tlvHeader, tlvBody);
- return bytes;
- }
-
- /**
- * Returns adjacency type TLV body as byte array.
- *
- * @return byteArray TLV body of area address TLV
- */
- private byte[] tlvBodyAsBytes() {
- List<Byte> bytes = new ArrayList<>();
- bytes.add(this.adjacencyType);
- bytes.addAll(Bytes.asList(IsisUtil.convertToFourBytes(this.localCircuitId)));
- if (this.neighborSystemId != null) {
- bytes.addAll(IsisUtil.sourceAndLanIdToBytes(this.neighborSystemId));
- bytes.addAll(Bytes.asList(IsisUtil.convertToFourBytes(this.neighborLocalCircuitId)));
- }
- return Bytes.toArray(bytes);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("adjacencyType", adjacencyType)
- .add("localCircuitId", localCircuitId)
- .add("neighborSystemId", neighborSystemId)
- .add("neighborLocalCircuitId", neighborLocalCircuitId)
- .toString();
- }
-}
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/AreaAddressTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/AreaAddressTlv.java
deleted file mode 100644
index 88ad3b9..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/AreaAddressTlv.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of area address TLV.
- */
-public class AreaAddressTlv extends TlvHeader implements IsisTlv {
-
- private List<String> areaAddress = new ArrayList<>();
-
- /**
- * Creates an instance of area address TLV.
- *
- * @param tlvHeader TLV header
- */
- public AreaAddressTlv(TlvHeader tlvHeader) {
- this.setTlvType(tlvHeader.tlvType());
- this.setTlvLength(tlvHeader.tlvLength());
- }
-
- /**
- * Adds the area address to the area address TLV.
- *
- * @param areaAddress area address
- */
- public void addAddress(String areaAddress) {
- this.areaAddress.add(areaAddress);
- }
-
- /**
- * Returns the area address of area address TLV.
- *
- * @return areaAddress area address
- */
- public List<String> areaAddress() {
- return this.areaAddress;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- while (channelBuffer.readableBytes() > 0) {
- int addressLength = channelBuffer.readByte();
- byte[] addressbytes = new byte[addressLength];
- channelBuffer.readBytes(addressbytes, 0, addressLength);
- String areaAddress = IsisUtil.areaAddress(addressbytes);
- this.areaAddress.add(areaAddress);
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] bytes = null;
- byte[] tlvHeader = tlvHeaderAsByteArray();
- byte[] tlvBody = tlvBodyAsBytes();
- tlvHeader[1] = (byte) tlvBody.length;
- bytes = Bytes.concat(tlvHeader, tlvBody);
- return bytes;
- }
-
- /**
- * Returns TLV body of area address TLV.
- *
- * @return byteArray TLV body of area address TLV
- */
- private byte[] tlvBodyAsBytes() {
- List<Byte> bytes = new ArrayList<>();
- for (String areaAddress : this.areaAddress) {
- bytes.add((byte) (areaAddress.length() / 2));
- bytes.addAll(IsisUtil.areaAddressToBytes(areaAddress));
- }
- return Bytes.toArray(bytes);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("areaAddress", areaAddress)
- .toString();
- }
-}
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/HostNameTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/HostNameTlv.java
deleted file mode 100644
index b942da2..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/HostNameTlv.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Representation of host name TLV.
- */
-public class HostNameTlv extends TlvHeader {
- private String hostName;
-
- /**
- * Creates an instance of host name TLV.
- *
- * @param tlvHeader TLV header
- */
- public HostNameTlv(TlvHeader tlvHeader) {
- this.setTlvType(tlvHeader.tlvType());
- this.setTlvLength(tlvHeader.tlvLength());
-
- }
-
- /**
- * Returns host name of host name TLV.
- *
- * @return host name
- */
- public String hostName() {
- return hostName;
- }
-
- /**
- * Sets host name for host name TLV.
- *
- * @param hostName host name.
- */
- public void setHostName(String hostName) {
- this.hostName = hostName;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- byte[] addressbytes = new byte[this.tlvLength()];
- channelBuffer.readBytes(addressbytes, 0, this.tlvLength());
- this.hostName = new String(addressbytes);
- }
-
- @Override
- public byte[] asBytes() {
- byte[] bytes = null;
- byte[] tlvHeader = tlvHeaderAsByteArray();
- byte[] tlvBody = tlvBodyAsBytes();
- tlvHeader[1] = (byte) tlvBody.length;
- bytes = Bytes.concat(tlvHeader, tlvBody);
- return bytes;
- }
-
- /**
- * Returns TLV body of host name TLV.
- *
- * @return byteArray TLV body of host name TLV
- */
- private byte[] tlvBodyAsBytes() {
- byte[] bytes = this.hostName.getBytes();
- return bytes;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("hostName", hostName)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IdrpInformationTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IdrpInformationTlv.java
deleted file mode 100644
index 70e38ec..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IdrpInformationTlv.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Representation of IDRP information TLV.
- */
-public class IdrpInformationTlv extends TlvHeader implements IsisTlv {
-
- private byte irdpInformationType;
- private int externalInformation;
-
- /**
- * Creates an instance of IDRP information TLV.
- *
- * @param tlvHeader TLV header
- */
- public IdrpInformationTlv(TlvHeader tlvHeader) {
- this.setTlvType(tlvHeader.tlvType());
- this.setTlvLength(tlvHeader.tlvLength());
- }
-
- /**
- * Returns the external information of IDRP information TLV.
- *
- * @return external information
- */
- public int externalInformation() {
- return externalInformation;
- }
-
- /**
- * Sets the external information for IDRP information TLV.
- *
- * @param externalInformation external information
- */
- public void setExternalInformation(int externalInformation) {
- this.externalInformation = externalInformation;
- }
-
- /**
- * Returns the IDRP information of IDRP information TLV.
- *
- * @return IDRP information type
- */
- public byte irdpInformationType() {
- return irdpInformationType;
- }
-
- /**
- * Sets the IDRP information for IDRP information TLV.
- *
- * @param irdpInformationType IDRP information type
- */
- public void setIrdpInformationType(byte irdpInformationType) {
- this.irdpInformationType = irdpInformationType;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- //TODO
- }
-
-
- @Override
- public byte[] asBytes() {
- //TODO
- return null;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("externalInformation", externalInformation)
- .add("irdpInformationType", irdpInformationType)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IpExtendedReachabilityTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IpExtendedReachabilityTlv.java
deleted file mode 100644
index 58eb578..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IpExtendedReachabilityTlv.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvFinder;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvToBytes;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvType;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of IP extended reachability TLV.
- */
-public class IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv {
-
- private boolean down;
- private boolean subTlvPresence;
- private int prefixLength;
- private int metric;
- private byte subTlvLength;
- private String prefix;
- private List<TrafficEngineeringSubTlv> trafEnginSubTlv = new ArrayList<>();
-
- /**
- * Creates an instance of IP external reachability TLV.
- *
- * @param tlvHeader TLV header
- */
- public IpExtendedReachabilityTlv(TlvHeader tlvHeader) {
- this.setTlvType(tlvHeader.tlvType());
- this.setTlvLength(tlvHeader.tlvLength());
- }
-
- /**
- * Returns list of traffic engineering sub tlvs.
- *
- * @return trafEnginSubTlv
- */
- public List<TrafficEngineeringSubTlv> teTlvs() {
- return this.trafEnginSubTlv;
- }
-
- /**
- * Returns the prefix of IP external reachability TLV.
- *
- * @return prefix
- */
- public String prefix() {
- return prefix;
- }
-
- /**
- * Sets the prefix of IP external reachability TLV.
- *
- * @param prefix prefix
- */
- public void setPrefix(String prefix) {
- this.prefix = prefix;
- }
-
- /**
- * Returns if down true else false of IP external reachability TLV.
- *
- * @return if down true else false
- */
- public boolean isDown() {
- return down;
- }
-
- /**
- * Sets if down true else false of IP external reachability TLV.
- *
- * @param upOrDown if down true else false
- */
- public void setDown(boolean upOrDown) {
- this.down = upOrDown;
- }
-
- /**
- * Returns true if sub TLV present else false of IP external reachability TLV.
- *
- * @return true if present else false
- */
- public boolean isSubTlvPresence() {
- return subTlvPresence;
- }
-
- /**
- * Sets true if sub TLV present else false of IP external reachability TLV.
- *
- * @param subTlvPresence true if present else false
- */
- public void setSubTlvPresence(boolean subTlvPresence) {
- this.subTlvPresence = subTlvPresence;
- }
-
- /**
- * Sets the prefix length of IP external reachability TLV.
- *
- * @return prefix length
- */
- public int prefixLength() {
- return prefixLength;
- }
-
- /**
- * Returns the prefix length of IP external reachability TLV.
- *
- * @param prefixLength the prefix length of IP external reachability TLV
- */
- public void setPrefixLength(int prefixLength) {
- this.prefixLength = prefixLength;
- }
-
- /**
- * Adds the traffic engineering sub TLV to IP external reachability TLV.
- *
- * @param trafEnginSubTlv traffic engineering sub TLV
- */
- public void addSubTlv(TrafficEngineeringSubTlv trafEnginSubTlv) {
- this.trafEnginSubTlv.add(trafEnginSubTlv);
- }
-
- /**
- * Returns the sub TLV length of IP external reachability TLV.
- *
- * @return sub TLV length
- */
- public byte subTlvLength() {
- return subTlvLength;
- }
-
- /**
- * Sets the sub TLV length for IP external reachability TLV.
- *
- * @param subTlvLength sub TLV length
- */
- public void setSubTlvLength(byte subTlvLength) {
- this.subTlvLength = subTlvLength;
- }
-
- /**
- * Returns metric of IP external reachability TLV.
- *
- * @return metric
- */
- public int metric() {
- return metric;
- }
-
- /**
- * Sets default metric for IP external reachability TLV.
- *
- * @param metric default metric
- */
- public void setMetric(int metric) {
- this.metric = metric;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- this.setMetric(channelBuffer.readInt());
- int controlInfo = channelBuffer.readByte();
- byte[] tempByteArray = null;
-
- String string = IsisUtil.toEightBitBinary(Integer.toBinaryString(controlInfo));
- if (string.charAt(0) == '0') {
- this.setDown(false);
- }
- if (string.charAt(1) == '1') {
- this.setSubTlvPresence(true);
- }
- this.setPrefixLength(Integer.parseInt(string.substring(2, string.length()), 2));
- if (this.prefixLength >= 0 && this.prefixLength <= 8) {
- channelBuffer.readByte();
- } else if (this.prefixLength >= 8 && this.prefixLength <= 16) {
- tempByteArray = new byte[IsisUtil.TWO_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.TWO_BYTES);
- this.setPrefix(IsisUtil.prefixConversion(tempByteArray));
- } else if (this.prefixLength >= 17 && this.prefixLength <= 24) {
- tempByteArray = new byte[IsisUtil.THREE_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.THREE_BYTES);
- this.setPrefix(IsisUtil.prefixConversion(tempByteArray));
- } else if (this.prefixLength >= 24 && this.prefixLength <= 32) {
- tempByteArray = new byte[IsisUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES);
- this.setPrefix(IsisUtil.prefixConversion(tempByteArray));
- }
- if (this.isSubTlvPresence()) {
- this.setSubTlvLength(channelBuffer.readByte());
- while (channelBuffer.readableBytes() > 0) {
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(channelBuffer.readByte());
- tlvHeader.setTlvLength(channelBuffer.readByte());
- SubTlvType tlvValue = SubTlvType.get(tlvHeader.tlvType());
- if (tlvValue != null) {
- TrafficEngineeringSubTlv subTlv =
- SubTlvFinder.findSubTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength()));
- if (subTlv != null) {
- this.addSubTlv(subTlv);
- }
- } else {
- channelBuffer.readBytes(tlvHeader.tlvLength());
- }
- }
- }
- }
-
-
- @Override
- public byte[] asBytes() {
- byte[] bytes = null;
- byte[] tlvHeader = tlvHeaderAsByteArray();
- byte[] tlvBody = tlvBodyAsBytes();
- tlvHeader[1] = (byte) tlvBody.length;
- bytes = Bytes.concat(tlvHeader, tlvBody);
-
- return bytes;
- }
-
- /**
- * Returns TLV body of IP external reachability TLV.
- *
- * @return byteArray TLV body of IP external reachability TLV.
- */
- private byte[] tlvBodyAsBytes() {
- List<Byte> bodyLst = new ArrayList<>();
- bodyLst.addAll(Bytes.asList(IsisUtil.convertToFourBytes(this.metric())));
- String controlInfo = "";
- if (this.isDown()) {
- controlInfo = controlInfo + "1";
- } else {
- controlInfo = controlInfo + "0";
- }
- if (this.isSubTlvPresence()) {
- controlInfo = controlInfo + "1";
- } else {
- controlInfo = controlInfo + "0";
- }
- String prefixLength = IsisUtil.toEightBitBinary(Integer.toBinaryString(this.prefixLength()));
- controlInfo = controlInfo + prefixLength.substring(2, prefixLength.length());
- bodyLst.add(Byte.parseByte(controlInfo, 2));
- if (this.isSubTlvPresence()) {
- bodyLst.add(this.subTlvLength());
- for (TrafficEngineeringSubTlv trafficEngineeringSubTlv : this.trafEnginSubTlv) {
- bodyLst.addAll(SubTlvToBytes.tlvToBytes(trafficEngineeringSubTlv));
- }
- }
- bodyLst.addAll(Bytes.asList(IsisUtil.prefixToBytes(this.prefix())));
-
- return Bytes.toArray(bodyLst);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("down", down)
- .add("subTlvPresence", subTlvPresence)
- .add("prefixLength", prefixLength)
- .add("metric", metric)
- .add("subTlvLength", subTlvLength)
- .add("prefix", prefix)
- .add("trafEnginSubTlv", trafEnginSubTlv)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IpInterfaceAddressTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IpInterfaceAddressTlv.java
deleted file mode 100644
index 3b1e63f..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IpInterfaceAddressTlv.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of IP interface address TLV.
- */
-public class IpInterfaceAddressTlv extends TlvHeader implements IsisTlv {
-
- private List<Ip4Address> interfaceAddress = new ArrayList<>();
-
- /**
- * Creates an instance of IP interface address TLV.
- *
- * @param tlvHeader TLV header
- */
- public IpInterfaceAddressTlv(TlvHeader tlvHeader) {
-
- this.setTlvType(tlvHeader.tlvType());
- this.setTlvLength(tlvHeader.tlvLength());
-
- }
-
- /**
- * Adds the interface address to IP interface address TLV.
- *
- * @param interfaceAddress interface address
- */
- public void addInterfaceAddres(Ip4Address interfaceAddress) {
- this.interfaceAddress.add(interfaceAddress);
- }
-
- /**
- * Returns the interface address of IP interface address TLV.
- *
- * @return interface address
- */
- public List<Ip4Address> interfaceAddress() {
- return interfaceAddress;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- while (channelBuffer.readableBytes() >= 4) {
- byte[] addressbytes = new byte[IsisUtil.FOUR_BYTES];
- channelBuffer.readBytes(addressbytes, 0, IsisUtil.FOUR_BYTES);
- this.interfaceAddress.add(Ip4Address.valueOf(addressbytes));
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] bytes = null;
- byte[] tlvHeader = tlvHeaderAsByteArray();
- byte[] tlvBody = tlvBodyAsBytes();
- tlvHeader[1] = (byte) tlvBody.length;
- bytes = Bytes.concat(tlvHeader, tlvBody);
- return bytes;
- }
-
- /**
- * Returns TLV body of IP interface address TLV.
- *
- * @return byteArray TLV body of IP interface address TLV
- */
- private byte[] tlvBodyAsBytes() {
- List<Byte> bytes = new ArrayList<>();
- for (Ip4Address ip4Address : this.interfaceAddress) {
- bytes.addAll(Bytes.asList(ip4Address.toOctets()));
- }
- return Bytes.toArray(bytes);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("interfaceAddress", interfaceAddress)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IpInternalReachabilityTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IpInternalReachabilityTlv.java
deleted file mode 100644
index 75d4738..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IpInternalReachabilityTlv.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of IP internal reachability TLV.
- */
-public class IpInternalReachabilityTlv extends TlvHeader implements IsisTlv {
- private List<MetricOfInternalReachability> metricOfInternalReachability = new ArrayList<>();
-
- /**
- * Creates an instance of IP internal reachability TLV.
- *
- * @param tlvHeader TLV header
- */
- public IpInternalReachabilityTlv(TlvHeader tlvHeader) {
- this.setTlvType(tlvHeader.tlvType());
- this.setTlvLength(tlvHeader.tlvLength());
- }
-
- /**
- * Adds the metric of internal reachability to internal reachability TLV.
- *
- * @param metricValue metric of internal reachability
- */
- public void addInternalReachabilityMetric(MetricOfInternalReachability metricValue) {
- this.metricOfInternalReachability.add(metricValue);
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- while (channelBuffer.readableBytes() > 0) {
- MetricOfInternalReachability metricOfInternalReachability = new MetricOfInternalReachability();
- metricOfInternalReachability.readFrom(channelBuffer);
- this.metricOfInternalReachability.add(metricOfInternalReachability);
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] bytes = null;
- byte[] tlvHeader = tlvHeaderAsByteArray();
- byte[] tlvBody = tlvBodyAsBytes();
- tlvHeader[1] = (byte) tlvBody.length;
- bytes = Bytes.concat(tlvHeader, tlvBody);
- return bytes;
- }
-
- /**
- * Returns TLV body of internal reachability TLV.
- *
- * @return byteArray TLV body of area address TLV
- */
- private byte[] tlvBodyAsBytes() {
- List<Byte> bytes = new ArrayList<>();
- for (MetricOfInternalReachability metricOfInternalReachability :
- this.metricOfInternalReachability) {
- bytes.addAll(Bytes.asList(metricOfInternalReachability.asBytes()));
- }
- return Bytes.toArray(bytes);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("metricOfInternalReachability", metricOfInternalReachability)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsExtendedReachability.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsExtendedReachability.java
deleted file mode 100644
index 3398045..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsExtendedReachability.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
-* Copyright 2016-present Open Networking Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of IS extended reachability TLV.
- */
-public class IsExtendedReachability extends TlvHeader implements IsisTlv {
-
- private List<NeighborForExtendedIs> neighbors = new ArrayList<>();
-
- /**
- * Creates an instance of IP external reachability TLV.
- *
- * @param tlvHeader TLV header
- */
- public IsExtendedReachability(TlvHeader tlvHeader) {
- this.setTlvType(tlvHeader.tlvType());
- this.setTlvLength(tlvHeader.tlvLength());
- }
-
- /**
- * Returns neighbor list.
- *
- * @return neighbor list
- */
- public List<NeighborForExtendedIs> neighbours() {
- return neighbors;
- }
-
- /**
- * Adds the neighbor for extended IS instance to IS extended reachability TLV.
- *
- * @param neighbor neighbor for extended IS instance
- */
- public void addNeighbor(NeighborForExtendedIs neighbor) {
- this.neighbors.add(neighbor);
- }
-
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- while (channelBuffer.readableBytes() >= (IsisUtil.EIGHT_BYTES + IsisUtil.THREE_BYTES)) {
- NeighborForExtendedIs extendedIs = new NeighborForExtendedIs();
- extendedIs.readFrom(channelBuffer);
- this.addNeighbor(extendedIs);
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] bytes = null;
- byte[] tlvHeader = tlvHeaderAsByteArray();
- byte[] tlvBody = tlvBodyAsBytes();
- tlvHeader[1] = (byte) tlvBody.length;
- bytes = Bytes.concat(tlvHeader, tlvBody);
- return bytes;
- }
-
- /**
- * Returns TLV body of IS extended reachability TLV.
- *
- * @return byteArray TLV body of IS extended reachability TLV.
- */
- private byte[] tlvBodyAsBytes() {
- List<Byte> byteList = new ArrayList<>();
- for (NeighborForExtendedIs neighbor : this.neighbors) {
- byteList.addAll(Bytes.asList(neighbor.neighborBodyAsbytes()));
- }
- return Bytes.toArray(byteList);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("neighbors", neighbors)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsReachabilityTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsReachabilityTlv.java
deleted file mode 100644
index ffc75e1..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsReachabilityTlv.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of IS reachability TLV.
- */
-public class IsReachabilityTlv extends TlvHeader {
-
- private int reserved;
- private List<MetricsOfReachability> metricsOfReachabilities = new ArrayList<>();
-
- /**
- * Creates an instance of IS reachability TLV.
- *
- * @param tlvHeader TLV header
- */
- public IsReachabilityTlv(TlvHeader tlvHeader) {
- this.setTlvType(tlvHeader.tlvType());
- this.setTlvLength(tlvHeader.tlvLength());
- }
-
- /**
- * Returns the reserved value of IS reachability TLV.
- *
- * @return reserved
- */
- public int reserved() {
- return reserved;
- }
-
- /**
- * Sets the reserved value for IS reachability TLV.
- *
- * @param reserved reserved
- */
- public void setReserved(int reserved) {
- this.reserved = reserved;
- }
-
- /**
- * Adds the metric of reachability to IS reachability TLV..
- *
- * @param metricsOfReachability metric of reachability
- */
- public void addMeticsOfReachability(MetricsOfReachability metricsOfReachability) {
- this.metricsOfReachabilities.add(metricsOfReachability);
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- this.setReserved(channelBuffer.readByte());
- while (channelBuffer.readableBytes() > 0) {
- MetricsOfReachability metricsOfReachability = new MetricsOfReachability();
- metricsOfReachability.readFrom(channelBuffer);
- this.metricsOfReachabilities.add(metricsOfReachability);
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] bytes = null;
- byte[] tlvHeader = tlvHeaderAsByteArray();
- byte[] tlvBody = tlvBodyAsBytes();
- tlvHeader[1] = (byte) tlvBody.length;
- bytes = Bytes.concat(tlvHeader, tlvBody);
- return bytes;
- }
-
- /**
- * Returns TLV body of IS reachability TLV.
- *
- * @return byteArray TLV body of area address TLV
- */
- private byte[] tlvBodyAsBytes() {
- List<Byte> bytes = new ArrayList<>();
- bytes.add((byte) this.reserved());
- for (MetricsOfReachability metricsOfReachability : this.metricsOfReachabilities) {
- bytes.addAll(Bytes.asList(metricsOfReachability.asBytes()));
- }
- return Bytes.toArray(bytes);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("metricsOfReachabilities", metricsOfReachabilities)
- .toString();
- }
-}
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsisNeighborTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsisNeighborTlv.java
deleted file mode 100644
index d58d536..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsisNeighborTlv.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.MacAddress;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of ISIS neighbor TLV.
- */
-public class IsisNeighborTlv extends TlvHeader implements IsisTlv {
-
- private List<MacAddress> neighbor = new ArrayList<>();
-
- /**
- * Creates an instance of ISIS neighbor TLV.
- *
- * @param tlvHeader TLV header
- */
- public IsisNeighborTlv(TlvHeader tlvHeader) {
- this.setTlvType(tlvHeader.tlvType());
- this.setTlvLength(tlvHeader.tlvLength());
- }
-
- /**
- * Adds the MAC address of the neighbor to ISIS neighbor TLV.
- *
- * @param macAddress MAC address
- */
- public void addNeighbor(MacAddress macAddress) {
- neighbor.add(macAddress);
- }
-
- /**
- * Returns the MAC address of the ISIS neighbor TLV.
- *
- * @return neighbor
- */
- public List<MacAddress> neighbor() {
- return this.neighbor;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- while (channelBuffer.readableBytes() >= 6) {
- byte[] addressbytes = new byte[IsisUtil.SIX_BYTES];
- channelBuffer.readBytes(addressbytes, 0, IsisUtil.SIX_BYTES);
- this.neighbor.add(MacAddress.valueOf(addressbytes));
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] bytes = null;
- byte[] tlvHeader = tlvHeaderAsByteArray();
- byte[] tlvBody = tlvBodyAsBytes();
- tlvHeader[1] = (byte) tlvBody.length;
- bytes = Bytes.concat(tlvHeader, tlvBody);
- return bytes;
- }
-
- /**
- * Returns TLV body of ISIS neighbor TLV.
- *
- * @return byteArray TLV body of area address TLV
- */
- private byte[] tlvBodyAsBytes() {
- List<Byte> bytes = new ArrayList<>();
- for (MacAddress macAddress : this.neighbor) {
- bytes.addAll(Bytes.asList(macAddress.toBytes()));
- }
- return Bytes.toArray(bytes);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("neighbor", neighbor)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsisTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsisTlv.java
deleted file mode 100644
index 336d053..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsisTlv.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-/**
- * Representation of ISIS TLV.
- */
-public interface IsisTlv {
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/LspEntriesTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/LspEntriesTlv.java
deleted file mode 100644
index e1cccb4..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/LspEntriesTlv.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of LSP entries TLV.
- */
-public class LspEntriesTlv extends TlvHeader implements IsisTlv {
- private List<LspEntry> lspEntryList = new ArrayList<>();
-
- /**
- * Creates an instance of LSP entries TLV.
- *
- * @param tlvHeader TLV header
- */
- public LspEntriesTlv(TlvHeader tlvHeader) {
- this.setTlvType(tlvHeader.tlvType());
- this.setTlvLength(tlvHeader.tlvLength());
- }
-
- /**
- * Returns the LSP entry of LSP entries TLV.
- *
- * @return LSP entries
- */
- public List<LspEntry> lspEntry() {
- return lspEntryList;
- }
-
- /**
- * Adds the the LSP entry to LSP entries TLV.
- *
- * @param lspEntry LSP entry
- */
- public void addLspEntry(LspEntry lspEntry) {
- this.lspEntryList.add(lspEntry);
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- while (channelBuffer.readableBytes() >= (IsisUtil.EIGHT_BYTES * 2)) {
- LspEntry lspEntry = new LspEntry();
- lspEntry.readFrom(channelBuffer.readBytes(IsisUtil.EIGHT_BYTES * 2));
- lspEntryList.add(lspEntry);
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] bytes = null;
- byte[] tlvHeader = tlvHeaderAsByteArray();
- byte[] tlvBody = tlvBodyAsBytes();
- tlvHeader[1] = (byte) tlvBody.length;
- bytes = Bytes.concat(tlvHeader, tlvBody);
- return bytes;
- }
-
- /**
- * Returns TLV body of LSP entries TLV.
- *
- * @return byteArray TLV body of LSP entries TLV
- */
- private byte[] tlvBodyAsBytes() {
- List<Byte> bytes = new ArrayList<>();
- for (LspEntry lspEntry : lspEntryList) {
- bytes.addAll(Bytes.asList(lspEntry.lspEntryAsBytes()));
- }
- return Bytes.toArray(bytes);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("lspEntryList", lspEntryList)
- .toString();
- }
-}
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/LspEntry.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/LspEntry.java
deleted file mode 100644
index 655c91b..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/LspEntry.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of LSP entry.
- */
-public class LspEntry {
-
- private int lspSequenceNumber;
- private int lspChecksum;
- private int remainingTime;
- private String lspId;
-
-
- /**
- * Returns LSP sequence number of LSP entry.
- *
- * @return LSP sequence number
- */
- public int lspSequenceNumber() {
- return lspSequenceNumber;
- }
-
- /**
- * Sets LSP sequenceNumber for LSP entry.
- *
- * @param lspSequenceNumber lspSequenceNumber
- */
- public void setLspSequenceNumber(int lspSequenceNumber) {
- this.lspSequenceNumber = lspSequenceNumber;
- }
-
- /**
- * Returns LSP checksum of LSP entry.
- *
- * @return LSP checksum
- */
- public int lspChecksum() {
- return lspChecksum;
- }
-
- /**
- * Sets LSP checksum for LSP entry.
- *
- * @param lspChecksum LSP checksum
- */
- public void setLspChecksum(int lspChecksum) {
- this.lspChecksum = lspChecksum;
- }
-
- /**
- * Returns remaining time of LSP entry.
- *
- * @return remaining time
- */
- public int remainingTime() {
- return remainingTime;
- }
-
- /**
- * Sets remaining time for LSP entry.
- *
- * @param remainingTime remaining time
- */
- public void setRemainingTime(int remainingTime) {
- this.remainingTime = remainingTime;
- }
-
- /**
- * Returns LSP ID of LSP entry.
- *
- * @return LSP ID
- */
- public String lspId() {
- return lspId;
- }
-
- /**
- * Sets LSP ID for LSp entry.
- *
- * @param lspId LSP ID
- */
- public void setLspId(String lspId) {
- this.lspId = lspId;
- }
-
- /**
- * Sets the LSP entry values for LSP entry from byte buffer.
- *
- * @param channelBuffer channel Buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- this.setRemainingTime(channelBuffer.readUnsignedShort());
- byte[] tempByteArray = new byte[IsisUtil.ID_PLUS_TWO_BYTE];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_TWO_BYTE);
- this.setLspId(IsisUtil.systemIdPlus(tempByteArray));
- this.setLspSequenceNumber(channelBuffer.readInt());
- this.setLspChecksum(channelBuffer.readUnsignedShort());
- }
-
- /**
- * Returns LSP entry values as bytes of LSP entry.
- *
- * @return byteArray LSP entry values as bytes of LSP entry
- */
- public byte[] lspEntryAsBytes() {
- List<Byte> bytes = new ArrayList<>();
- bytes.addAll(Bytes.asList(IsisUtil.convertToTwoBytes(this.remainingTime())));
- bytes.addAll(IsisUtil.sourceAndLanIdToBytes(this.lspId()));
- bytes.addAll(Bytes.asList(IsisUtil.convertToFourBytes(this.lspSequenceNumber())));
- bytes.addAll(Bytes.asList(IsisUtil.convertToTwoBytes(this.lspChecksum())));
- return Bytes.toArray(bytes);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("lspSequenceNumber", lspSequenceNumber)
- .add("lspChecksum", lspChecksum)
- .add("remainingTime", remainingTime)
- .add("lspId", lspId)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/MetricOfInternalReachability.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/MetricOfInternalReachability.java
deleted file mode 100644
index eb8f6d2..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/MetricOfInternalReachability.java
+++ /dev/null
@@ -1,452 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of metric of internal reachability.
- */
-public class MetricOfInternalReachability {
- private Ip4Address ipAddress;
- private Ip4Address subnetAddress;
- private byte defaultMetric;
- private byte delayMetric;
- private byte expenseMetric;
- private byte errorMetric;
- private boolean delayMetricSupported;
- private boolean expenseMetricSupported;
- private boolean errorMetricSupported;
- private boolean defaultIsInternal;
- private boolean defaultDistributionDown;
- private boolean delayIsInternal;
- private boolean expenseIsInternal;
- private boolean errorIsInternal;
-
- /**
- * Returns the IP address of metric of internal reachability.
- *
- * @return ipAddress IP address of metric of internal reachability
- */
- public Ip4Address getIpAddress() {
- return ipAddress;
- }
-
- /**
- * Sets the IP address for metric of internal reachability.
- *
- * @param ipAddress ip address
- */
- public void setIpAddress(Ip4Address ipAddress) {
- this.ipAddress = ipAddress;
- }
-
- /**
- * Returns the subnet address of metric of internal reachability.
- *
- * @return subnetAddress subnet address of metric of internal reachability
- */
- public Ip4Address getSubnetAddress() {
- return subnetAddress;
- }
-
- /**
- * Sets the subnet address for metric of internal reachability.
- *
- * @param subnetAddress subnet address
- */
- public void setSubnetAddress(Ip4Address subnetAddress) {
- this.subnetAddress = subnetAddress;
- }
-
- /**
- * Returns error metric is internal or not.
- *
- * @return true if internal else false
- */
- public boolean isErrorIsInternal() {
- return errorIsInternal;
- }
-
- /**
- * Sets error metric is internal or not.
- *
- * @param errorIsInternal true if internal else false
- */
- public void setErrorIsInternal(boolean errorIsInternal) {
- this.errorIsInternal = errorIsInternal;
- }
-
- /**
- * Returns expense metric is internal or not.
- *
- * @return true if internal else false
- */
- public boolean isExpenseIsInternal() {
- return expenseIsInternal;
- }
-
- /**
- * Sets expense metric is internal or not.
- *
- * @param expenseIsInternal true if internal else false
- */
- public void setExpenseIsInternal(boolean expenseIsInternal) {
- this.expenseIsInternal = expenseIsInternal;
- }
-
- /**
- * Returns delays metric is internal or not.
- *
- * @return true if internal else false
- */
- public boolean isDelayIsInternal() {
- return delayIsInternal;
- }
-
- /**
- * Sets delay metric is internal or not.
- *
- * @param delayIsInternal true if internal else false
- */
- public void setDelayIsInternal(boolean delayIsInternal) {
- this.delayIsInternal = delayIsInternal;
- }
-
- /**
- * Returns is default distribution is up or down.
- *
- * @return true if down else false
- */
- public boolean isDefaultDistributionDown() {
- return defaultDistributionDown;
- }
-
- /**
- * Sets default distribution is up or down.
- *
- * @param defaultDistributionDown true if down else false
- */
- public void setDefaultDistributionDown(boolean defaultDistributionDown) {
- this.defaultDistributionDown = defaultDistributionDown;
- }
-
- /**
- * Returns is default metric is internal or not.
- *
- * @return true if internal else false
- */
- public boolean isDefaultIsInternal() {
- return defaultIsInternal;
- }
-
- /**
- * Sets default metric is internal or not.
- *
- * @param defaultIsInternal true is internal else false
- */
- public void setDefaultIsInternal(boolean defaultIsInternal) {
- this.defaultIsInternal = defaultIsInternal;
- }
-
- /**
- * Returns error metric is supported or not.
- *
- * @return true if supported else false
- */
- public boolean isErrorMetricSupported() {
- return errorMetricSupported;
- }
-
- /**
- * Sets error metric is supported or not.
- *
- * @param errorMetricSupported true if supported else false
- */
- public void setErrorMetricSupported(boolean errorMetricSupported) {
- this.errorMetricSupported = errorMetricSupported;
- }
-
- /**
- * Returns expense metric is supported or not.
- *
- * @return true if supported else false
- */
- public boolean isExpenseMetricSupported() {
- return expenseMetricSupported;
- }
-
- /**
- * Sets expense metric is supported or not.
- *
- * @param expenseMetricSupported true if supported else false
- */
- public void setExpenseMetricSupported(boolean expenseMetricSupported) {
- this.expenseMetricSupported = expenseMetricSupported;
- }
-
- /**
- * Returns delay metric is supported or not.
- *
- * @return true if supported else false
- */
- public boolean isDelayMetricSupported() {
- return delayMetricSupported;
- }
-
- /**
- * Sets delay metric is supported or not.
- *
- * @param delayMetricSupported true if supported else false
- */
- public void setDelayMetricSupported(boolean delayMetricSupported) {
- this.delayMetricSupported = delayMetricSupported;
- }
-
- /**
- * Returns error metric of metric of internal reachability.
- *
- * @return errorMetric error metric
- */
- public byte errorMetric() {
- return errorMetric;
- }
-
- /**
- * Sets error metric for metric of internal reachability.
- *
- * @param errorMetric error metric
- */
- public void setErrorMetric(byte errorMetric) {
- this.errorMetric = errorMetric;
- }
-
- /**
- * Returns expense metric of metric of internal reachability.
- *
- * @return expense metric
- */
- public byte expenseMetric() {
- return expenseMetric;
- }
-
- /**
- * Sets expense metric for metric of internal reachability.
- *
- * @param expenseMetric expense metric
- */
- public void setExpenseMetric(byte expenseMetric) {
- this.expenseMetric = expenseMetric;
- }
-
- /**
- * Returns delay metric of metric of internal reachability.
- *
- * @return delay metric
- */
- public byte delayMetric() {
- return delayMetric;
- }
-
- /**
- * Sets delay metric for metric of internal reachability.
- *
- * @param delayMetric delay metric
- */
- public void setDelayMetric(byte delayMetric) {
- this.delayMetric = delayMetric;
- }
-
- /**
- * Returns default metric of metric of internal reachability.
- *
- * @return default metric
- */
- public byte defaultMetric() {
- return defaultMetric;
- }
-
- /**
- * Sets default metric for metric of internal reachability.
- *
- * @param defaultMetric default metric
- */
- public void setDefaultMetric(byte defaultMetric) {
- this.defaultMetric = defaultMetric;
- }
-
- /**
- * Sets the metric of internal reachability
- * values for metric of internal reachability from byte buffer.
- *
- * @param channelBuffer channel Buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- byte metric = channelBuffer.readByte();
- this.setDefaultMetric(metric);
- String metricInBinary = Integer.toBinaryString(Byte.toUnsignedInt(metric));
- metricInBinary = IsisUtil.toEightBitBinary(metricInBinary);
- if (metricInBinary.charAt(1) == 0) {
- this.setDefaultIsInternal(true);
- } else {
- this.setDefaultIsInternal(false);
- }
- if (metricInBinary.charAt(0) == 0) {
- this.setDefaultDistributionDown(true);
- } else {
- this.setDefaultDistributionDown(false);
- }
- byte delayMetric = channelBuffer.readByte();
- metricInBinary = Integer.toBinaryString(Byte.toUnsignedInt(delayMetric));
- metricInBinary = IsisUtil.toEightBitBinary(metricInBinary);
- this.setDelayMetric(Byte.parseByte(metricInBinary.substring(5, metricInBinary.length()), 2));
- if (metricInBinary.charAt(1) == 0) {
- this.setDelayIsInternal(true);
- } else {
- this.setDelayIsInternal(false);
- }
- if (metricInBinary.charAt(0) == 0) {
- this.setDelayMetricSupported(true);
- } else {
- this.setDelayMetricSupported(false);
- }
- byte expenseMetric = channelBuffer.readByte();
- metricInBinary = Integer.toBinaryString(Byte.toUnsignedInt(expenseMetric));
- metricInBinary = IsisUtil.toEightBitBinary(metricInBinary);
- this.setExpenseMetric(Byte.parseByte(metricInBinary.substring(5, metricInBinary.length()), 2));
- if (metricInBinary.charAt(1) == 0) {
- this.setExpenseIsInternal(true);
- } else {
- this.setExpenseIsInternal(false);
- }
- if (metricInBinary.charAt(0) == 0) {
- this.setExpenseMetricSupported(true);
- } else {
- this.setExpenseMetricSupported(false);
- }
- byte errorMetric = channelBuffer.readByte();
- metricInBinary = Integer.toBinaryString(Byte.toUnsignedInt(errorMetric));
- metricInBinary = IsisUtil.toEightBitBinary(metricInBinary);
- this.setErrorMetric(Byte.parseByte(metricInBinary.substring(5, metricInBinary.length()), 2));
- if (metricInBinary.charAt(1) == 0) {
- this.setErrorIsInternal(true);
- } else {
- this.setErrorIsInternal(false);
- }
- if (metricInBinary.charAt(0) == 0) {
- this.setErrorMetricSupported(true);
- } else {
- this.setErrorMetricSupported(false);
- }
-
- byte[] tempByteArray = new byte[IsisUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES);
- this.setIpAddress(Ip4Address.valueOf(tempByteArray));
-
- tempByteArray = new byte[IsisUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES);
- this.setSubnetAddress(Ip4Address.valueOf(tempByteArray));
- }
-
- /**
- * Returns metric of internal reachability values as bytes of metric of internal reachability.
- *
- * @return byteArray metric of internal reachability values as bytes of metric of internal reachability
- */
- public byte[] asBytes() {
- List<Byte> bytes = new ArrayList<>();
- bytes.add(this.defaultMetric());
- int temp = this.delayMetric();
- String hsbBits = "";
- if (this.isDelayMetricSupported()) {
- hsbBits = "0" + hsbBits;
- } else {
- hsbBits = "1" + hsbBits;
- }
- if (this.isDelayIsInternal()) {
- hsbBits = hsbBits + "0";
- } else {
- hsbBits = hsbBits + "1";
- }
- hsbBits = hsbBits + "00";
- String binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp));
- bytes.add((byte) Integer.parseInt(binary, 2));
-
- temp = this.expenseMetric();
- hsbBits = "";
- if (this.isExpenseMetricSupported()) {
- hsbBits = "0" + hsbBits;
- } else {
- hsbBits = "1" + hsbBits;
- }
- if (this.isExpenseIsInternal()) {
- hsbBits = hsbBits + "0";
- } else {
- hsbBits = hsbBits + "1";
- }
- hsbBits = hsbBits + "00";
- binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp));
- bytes.add((byte) Integer.parseInt(binary, 2));
-
- temp = this.errorMetric();
- hsbBits = "";
- if (this.isErrorMetricSupported()) {
- hsbBits = "0" + hsbBits;
- } else {
- hsbBits = "1" + hsbBits;
- }
- if (this.isExpenseIsInternal()) {
- hsbBits = hsbBits + "0";
- } else {
- hsbBits = hsbBits + "1";
- }
- hsbBits = hsbBits + "00";
- binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp));
- bytes.add((byte) Integer.parseInt(binary, 2));
-
- bytes.addAll(Bytes.asList(this.getIpAddress().toOctets()));
- bytes.addAll(Bytes.asList(this.getSubnetAddress().toOctets()));
- return Bytes.toArray(bytes);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("ipAddress", ipAddress)
- .add("subnetAddress", subnetAddress)
- .add("defaultMetric", defaultMetric)
- .add("delayMetric", delayMetric)
- .add("expenseMetric", expenseMetric)
- .add("errorMetric", errorMetric)
- .add("delayMetricSupported", delayMetricSupported)
- .add("expenseMetricSupported", expenseMetricSupported)
- .add("errorMetricSupported", errorMetricSupported)
- .add("defaultIsInternal", defaultIsInternal)
- .add("defaultDistributionDown", defaultDistributionDown)
- .add("delayIsInternal", delayIsInternal)
- .add("expenseIsInternal", expenseIsInternal)
- .add("errorIsInternal", errorIsInternal)
- .toString();
- }
-}
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/MetricsOfReachability.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/MetricsOfReachability.java
deleted file mode 100644
index bafc94b..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/MetricsOfReachability.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of metric of reachability.
- */
-public class MetricsOfReachability {
- private final String value1 = "10000000";
- private final String value2 = "00000000";
- private String neighborId;
- private byte defaultMetric;
- private byte delayMetric;
- private byte expenseMetric;
- private byte errorMetric;
- private boolean delayMetricSupported;
- private boolean expenseMetricSupported;
- private boolean errorMetricSupported;
- private boolean defaultIsInternal;
- private boolean delayIsInternal;
- private boolean expenseIsInternal;
- private boolean errorIsInternal;
-
- /**
- * Returns delay metric is internal or not.
- *
- * @return true if internal else false
- */
- public boolean isDelayIsInternal() {
- return delayIsInternal;
- }
-
- /**
- * Sets delay metric is internal or not.
- *
- * @param delayIsInternal true if internal else false
- */
- public void setDelayIsInternal(boolean delayIsInternal) {
- this.delayIsInternal = delayIsInternal;
- }
-
- /**
- * Returns expense metric is internal or not.
- *
- * @return true if internal else false
- */
- public boolean isExpenseIsInternal() {
- return expenseIsInternal;
- }
-
- /**
- * Sets expense metric is internal or not.
- *
- * @param expenseIsInternal true if internal else false
- */
- public void setExpenseIsInternal(boolean expenseIsInternal) {
- this.expenseIsInternal = expenseIsInternal;
- }
-
- /**
- * Returns error metric is internal or not.
- *
- * @return true if internal else false
- */
- public boolean isErrorIsInternal() {
- return errorIsInternal;
- }
-
- /**
- * Sets error metric is internal or not.
- *
- * @param errorIsInternal true if internal else false
- */
- public void setErrorIsInternal(boolean errorIsInternal) {
- this.errorIsInternal = errorIsInternal;
- }
-
- /**
- * Returns default metric is internal or not.
- *
- * @return true if internal else false
- */
- public boolean isDefaultIsInternal() {
- return defaultIsInternal;
- }
-
- /**
- * Sets default metric is internal or not.
- *
- * @param defaultIsInternal true if internal else false
- */
- public void setDefaultIsInternal(boolean defaultIsInternal) {
- this.defaultIsInternal = defaultIsInternal;
- }
-
- /**
- * Returns delay metric is supported or not.
- *
- * @return true if supported else false
- */
- public boolean isDelayMetricSupported() {
- return delayMetricSupported;
- }
-
- /**
- * Sets delay metric is supported or not.
- *
- * @param delayMetricSupported true if supported else false
- */
- public void setDelayMetricSupported(boolean delayMetricSupported) {
- this.delayMetricSupported = delayMetricSupported;
- }
-
- /**
- * Returns expense metric is supported or not.
- *
- * @return true if supported else false
- */
- public boolean isExpenseMetricSupported() {
- return expenseMetricSupported;
- }
-
- /**
- * Sets expense metric is supported or not.
- *
- * @param expenseMetricSupported true if supported else false
- */
- public void setExpenseMetricSupported(boolean expenseMetricSupported) {
- this.expenseMetricSupported = expenseMetricSupported;
- }
-
- /**
- * Returns error metric is supported or not.
- *
- * @return true if supported else false
- */
- public boolean isErrorMetricSupported() {
- return errorMetricSupported;
- }
-
- /**
- * Sets error metric is supported or not.
- *
- * @param errorMetricSupported true if supported else false
- */
- public void setErrorMetricSupported(boolean errorMetricSupported) {
- this.errorMetricSupported = errorMetricSupported;
- }
-
- /**
- * Returns neighbor ID of metric of reachability.
- *
- * @return neighbor ID
- */
- public String neighborId() {
- return neighborId;
- }
-
- /**
- * Sets neighbor ID for metric of reachability.
- *
- * @param neighborId neighbor ID
- */
- public void setNeighborId(String neighborId) {
- this.neighborId = neighborId;
- }
-
-
- /**
- * Returns default metric of metric of reachability.
- *
- * @return default metric
- */
- public byte defaultMetric() {
- return defaultMetric;
- }
-
- /**
- * Sets default metric for of reachability.
- *
- * @param defaultMetric default metric
- */
- public void setDefaultMetric(byte defaultMetric) {
- this.defaultMetric = defaultMetric;
- }
-
- /**
- * Returns delay metric of metric of reachability.
- *
- * @return delay metric
- */
- public byte delayMetric() {
- return delayMetric;
- }
-
- /**
- * Sets delay metric for metric of reachability.
- *
- * @param delayMetric delay metric
- */
- public void setDelayMetric(byte delayMetric) {
- this.delayMetric = delayMetric;
- }
-
- /**
- * Returns Expense metric of metric of reachability.
- *
- * @return Expense metric
- */
- public byte expenseMetric() {
- return expenseMetric;
- }
-
- /**
- * Sets Expense metric for metric of reachability.
- *
- * @param expenseMetric Expense metric
- */
- public void setExpenseMetric(byte expenseMetric) {
- this.expenseMetric = expenseMetric;
- }
-
- /**
- * Returns Error metric of metric of reachability.
- *
- * @return Error metric
- */
- public byte errorMetric() {
- return errorMetric;
- }
-
- /**
- * Sets Error metric for metric of reachability.
- *
- * @param errorMetric Error metric
- */
- public void setErrorMetric(byte errorMetric) {
- this.errorMetric = errorMetric;
- }
-
- /**
- * Sets the metric of reachability values for metric of reachability from byte buffer.
- *
- * @param channelBuffer channel Buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- byte metric = channelBuffer.readByte();
- String metricInBinary = Integer.toBinaryString(Byte.toUnsignedInt(metric));
- metricInBinary = IsisUtil.toEightBitBinary(metricInBinary);
- this.setDefaultMetric(metric);
- this.setDelayMetric(metric);
- this.setExpenseMetric(metric);
- this.setErrorMetric(metric);
- this.setDelayMetric(metric);
- if (metricInBinary.charAt(0) == 0) {
- this.setDefaultIsInternal(true);
- } else {
- this.setDefaultIsInternal(false);
- }
- if (metricInBinary.charAt(0) == 0) {
- this.setDelayMetricSupported(true);
- this.setExpenseMetricSupported(true);
- this.setErrorMetricSupported(true);
- } else {
- this.setDelayMetricSupported(false);
- this.setExpenseMetricSupported(false);
- this.setErrorMetricSupported(false);
- }
- byte temp = channelBuffer.readByte();
- String internalBit = Integer.toBinaryString(Byte.toUnsignedInt(temp));
- internalBit = IsisUtil.toEightBitBinary(internalBit);
- if (internalBit.charAt(1) == 0) {
- this.setDelayIsInternal(true);
- }
- temp = channelBuffer.readByte();
- internalBit = Integer.toBinaryString(Byte.toUnsignedInt(temp));
- internalBit = IsisUtil.toEightBitBinary(internalBit);
- if (internalBit.charAt(1) == 0) {
- this.setExpenseIsInternal(true);
- }
- temp = channelBuffer.readByte();
- internalBit = Integer.toBinaryString(Byte.toUnsignedInt(temp));
- internalBit = IsisUtil.toEightBitBinary(internalBit);
- if (internalBit.charAt(1) == 0) {
- this.setErrorIsInternal(true);
- }
- byte[] tempByteArray = new byte[IsisUtil.ID_PLUS_ONE_BYTE];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_ONE_BYTE);
- this.setNeighborId(IsisUtil.systemIdPlus(tempByteArray));
- }
-
- /**
- * Returns metric of reachability values as bytes of metric of reachability.
- *
- * @return byteArray metric of reachability values as bytes of metric of reachability
- */
- public byte[] asBytes() {
- List<Byte> bytes = new ArrayList<>();
- bytes.add((byte) this.defaultMetric());
- if (this.isDelayIsInternal()) {
- bytes.add((byte) Integer.parseInt(value1));
- } else {
- bytes.add((byte) Integer.parseInt(value2));
- }
- if (this.isExpenseIsInternal()) {
- bytes.add((byte) Integer.parseInt(value1));
- } else {
- bytes.add((byte) Integer.parseInt(value2));
- }
- if (this.isErrorIsInternal()) {
- bytes.add((byte) Integer.parseInt(value1));
- } else {
- bytes.add((byte) Integer.parseInt(value2));
- }
- bytes.addAll(IsisUtil.sourceAndLanIdToBytes(this.neighborId()));
- return Bytes.toArray(bytes);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("neighborId", neighborId)
- .add("defaultMetric", defaultMetric)
- .add("delayMetric", delayMetric)
- .add("expenseMetric", expenseMetric)
- .add("errorMetric", errorMetric)
- .add("delayMetricSupported", delayMetricSupported)
- .add("expenseMetricSupported", expenseMetricSupported)
- .add("errorMetricSupported", errorMetricSupported)
- .add("defaultIsInternal", defaultIsInternal)
- .add("delayIsInternal", delayIsInternal)
- .add("expenseIsInternal", expenseIsInternal)
- .add("errorIsInternal", errorIsInternal)
- .toString();
- }
-}
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/NeighborForExtendedIs.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/NeighborForExtendedIs.java
deleted file mode 100644
index b248dec..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/NeighborForExtendedIs.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvFinder;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvToBytes;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvType;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of IS extended reachability neighbors.
- */
-public class NeighborForExtendedIs {
-
- private String neighborId;
- private int metric;
- private List<TrafficEngineeringSubTlv> teSubTlv = new ArrayList<>();
-
- /**
- * Returns neighbor ID.
- *
- * @return neighbor ID
- */
- public String neighborId() {
- return neighborId;
- }
-
- /**
- * Returns list of sub tlvs.
- *
- * @return teSubTlv list of sub tlvs
- */
- public List<TrafficEngineeringSubTlv> teSubTlv() {
- return teSubTlv;
- }
-
- /**
- * Sets neighbor ID.
- *
- * @param neighborId neighbor ID
- */
- public void setNeighborId(String neighborId) {
- this.neighborId = neighborId;
- }
-
- /**
- * Returns metric.
- *
- * @return metric
- */
- public int metric() {
- return metric;
- }
-
- /**
- * Sets metric.
- *
- * @param metric metric
- */
- public void setMetric(int metric) {
- this.metric = metric;
- }
-
- /**
- * Adds the TE for extended IS instance to IS extended reachability TLV.
- *
- * @param trafficEngineeringSubTlv TE for extended IS instance
- */
- public void addSubTlv(TrafficEngineeringSubTlv trafficEngineeringSubTlv) {
- this.teSubTlv.add(trafficEngineeringSubTlv);
- }
-
- /**
- * Reads from the channel buffer and populate this instance.
- *
- * @param channelBuffer channel buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- byte[] tempByteArray = new byte[IsisUtil.ID_PLUS_ONE_BYTE];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_ONE_BYTE);
- this.setNeighborId(IsisUtil.systemIdPlus(tempByteArray));
- this.setMetric(channelBuffer.readUnsignedMedium());
- int nTlvPresent = channelBuffer.readByte();
- if (nTlvPresent > 0) {
- /* ntlvPresent=0 infers that all Sub TLVs,
- for a particular neighbor,
- have been parsed and the loop has to be terminated
- */
- while (channelBuffer.readableBytes() > IsisUtil.TWO_BYTES && nTlvPresent > 0) {
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(channelBuffer.readByte());
- tlvHeader.setTlvLength(channelBuffer.readByte());
- SubTlvType tlvValue = SubTlvType.get(tlvHeader.tlvType());
- int tlvLength = tlvHeader.tlvLength();
- if (tlvValue != null) {
- if (channelBuffer.readableBytes() >= tlvLength) {
- TrafficEngineeringSubTlv subTlv =
- SubTlvFinder.findSubTlv(tlvHeader, channelBuffer.readBytes(tlvHeader.tlvLength()));
- if (subTlv != null) {
- this.addSubTlv(subTlv);
- }
- /*As one Sub TLV is parsed, its length is
- subtracted from total length to be read
- */
- nTlvPresent = nTlvPresent - (tlvLength + IsisUtil.TWO_BYTES);
- }
- } else {
- if (channelBuffer.readableBytes() >= tlvLength) {
- channelBuffer.readBytes(tlvLength);
- /*As one Sub TLV is parsed, its length is
- subtracted from total length to be read
- */
- nTlvPresent = nTlvPresent - (tlvLength + IsisUtil.TWO_BYTES);
- }
- }
- }
- }
- }
-
- /**
- * Returns neighbor details of IS extended reachability TLV.
- *
- * @return neighbor details of IS extended reachability TLV.
- */
- public byte[] neighborBodyAsbytes() {
- List<Byte> byteList = new ArrayList<>();
- byteList.addAll(IsisUtil.sourceAndLanIdToBytes(this.neighborId()));
- byteList.addAll(Bytes.asList(IsisUtil.convertToThreeBytes(this.metric())));
- if (!this.teSubTlv.isEmpty()) {
- for (TrafficEngineeringSubTlv trafficEngineeringSubTlv : this.teSubTlv) {
- byteList.addAll(SubTlvToBytes.tlvToBytes(trafficEngineeringSubTlv));
- }
- }
- return Bytes.toArray(byteList);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("neighborId", neighborId)
- .add("metric", metric)
- .add("teSubTlv", teSubTlv)
- .toString();
- }
-}
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/PaddingTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/PaddingTlv.java
deleted file mode 100644
index ef51e54..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/PaddingTlv.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of padding TLV.
- */
-public class PaddingTlv extends TlvHeader implements IsisTlv {
- private List<Byte> paddings = new ArrayList<>();
-
- /**
- * Creates an instance of padding TLV.
- *
- * @param tlvHeader TLV header
- */
- public PaddingTlv(TlvHeader tlvHeader) {
- this.setTlvType(tlvHeader.tlvType());
- this.setTlvLength(tlvHeader.tlvLength());
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- while (channelBuffer.readableBytes() > 0) {
- this.paddings.add(channelBuffer.readByte());
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] bytes = null;
-
- byte[] tlvHeader = tlvHeaderAsByteArray();
- byte[] tlvBody = tlvBodyAsBytes();
- tlvHeader[1] = (byte) tlvBody.length;
- bytes = Bytes.concat(tlvHeader, tlvBody);
-
- return bytes;
- }
-
- /**
- * Returns TLV body of padding TLV.
- *
- * @return byteArray TLV body of padding TLV
- */
- private byte[] tlvBodyAsBytes() {
- byte[] areaArea = new byte[this.tlvLength()];
- return areaArea;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("paddings", paddings)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/ProtocolSupportedTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/ProtocolSupportedTlv.java
deleted file mode 100644
index ded4ae1..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/ProtocolSupportedTlv.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of protocol supported TLV.
- */
-public class ProtocolSupportedTlv extends TlvHeader implements IsisTlv {
-
- private List<Byte> protocolSupported = new ArrayList<>();
-
- /**
- * Creates an instance of protocol supported TLV.
- *
- * @param tlvHeader TLV header
- */
- public ProtocolSupportedTlv(TlvHeader tlvHeader) {
-
- this.setTlvType(tlvHeader.tlvType());
- this.setTlvLength(tlvHeader.tlvLength());
-
- }
-
- /**
- * Adds the protocol supported to protocol supported TLV.
- *
- * @param protocolValue protocol supported
- */
- public void addProtocolSupported(byte protocolValue) {
- protocolSupported.add(protocolValue);
- }
-
- /**
- * Returns protocols supported of protocol supported TLV.
- *
- * @return protocol supported
- */
- public List<Byte> protocolSupported() {
- return this.protocolSupported;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) {
- while (channelBuffer.readableBytes() > 0) {
- this.protocolSupported.add(channelBuffer.readByte());
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] bytes = null;
-
- byte[] tlvHeader = tlvHeaderAsByteArray();
- byte[] tlvBody = tlvBodyAsBytes();
- tlvHeader[1] = (byte) tlvBody.length;
- bytes = Bytes.concat(tlvHeader, tlvBody);
- return bytes;
- }
-
- /**
- * Gets TLV body of protocol supported TLV.
- *
- * @return byteArray TLV body of protocol supported TLV
- */
- private byte[] tlvBodyAsBytes() {
- List<Byte> bytes = new ArrayList<>();
- for (byte byt : this.protocolSupported) {
- bytes.add(byt);
- }
- byte[] byteArray = new byte[bytes.size()];
- int i = 0;
- for (byte byt : bytes) {
- byteArray[i++] = byt;
- }
- return byteArray;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("protocolSupported", protocolSupported)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/TlvFinder.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/TlvFinder.java
deleted file mode 100644
index 059f91e..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/TlvFinder.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Representation of TLV Finder.
- */
-public class TlvFinder extends TlvHeader {
-
- /**
- * Sets the value for TLV header.
- *
- * @param tlvHeader tlvHeader
- * @param channelBuffer byteBuf
- * @return isisTlv
- */
- public static IsisTlv findTlv(TlvHeader tlvHeader, ChannelBuffer channelBuffer) {
-
- IsisTlv isisTlv = null;
- switch (TlvType.get(tlvHeader.tlvType())) {
- case AREAADDRESS:
- AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
- areaAddressTlv.readFrom(channelBuffer);
- isisTlv = areaAddressTlv;
- break;
- case AUTHENTICATION:
- //TODO
- break;
- case EXTENDEDISREACHABILITY:
- IsExtendedReachability isExtendedReachability =
- new IsExtendedReachability(tlvHeader);
- isExtendedReachability.readFrom(channelBuffer);
- isisTlv = isExtendedReachability;
- break;
- case HOSTNAME:
- HostNameTlv hostNameTlv = new HostNameTlv(tlvHeader);
- hostNameTlv.readFrom(channelBuffer);
- isisTlv = hostNameTlv;
- break;
- case IDRPINFORMATION:
- IdrpInformationTlv idrpInformationTlv = new IdrpInformationTlv(tlvHeader);
- idrpInformationTlv.readFrom(channelBuffer);
- isisTlv = idrpInformationTlv;
- break;
- case IPEXTENDEDREACHABILITY:
- IpExtendedReachabilityTlv iperTlv = new IpExtendedReachabilityTlv(tlvHeader);
- iperTlv.readFrom(channelBuffer);
- isisTlv = iperTlv;
- break;
- case IPINTERFACEADDRESS:
- IpInterfaceAddressTlv ipTlv = new IpInterfaceAddressTlv(tlvHeader);
- ipTlv.readFrom(channelBuffer);
- isisTlv = ipTlv;
- break;
- case IPINTERNALREACHABILITY:
- IpInternalReachabilityTlv iprTlv = new IpInternalReachabilityTlv(tlvHeader);
- iprTlv.readFrom(channelBuffer);
- isisTlv = iprTlv;
- break;
- case ISALIAS:
- break;
- case PROTOCOLSUPPORTED:
- ProtocolSupportedTlv psTlv = new ProtocolSupportedTlv(tlvHeader);
- psTlv.readFrom(channelBuffer);
- isisTlv = psTlv;
- break;
- case ISREACHABILITY:
- IsReachabilityTlv isrTlv = new IsReachabilityTlv(tlvHeader);
- isrTlv.readFrom(channelBuffer);
- isisTlv = isrTlv;
- break;
- case ISNEIGHBORS:
- IsisNeighborTlv isisNeighborTlv = new IsisNeighborTlv(tlvHeader);
- isisNeighborTlv.readFrom(channelBuffer);
- isisTlv = isisNeighborTlv;
- break;
- case LSPENTRY:
- LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader);
- lspEntriesTlv.readFrom(channelBuffer);
- isisTlv = lspEntriesTlv;
- break;
- case PADDING:
- PaddingTlv paddingTlv = new PaddingTlv(tlvHeader);
- paddingTlv.readFrom(channelBuffer);
- isisTlv = paddingTlv;
- break;
- case ADJACENCYSTATE:
- AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader);
- adjacencyStateTlv.readFrom(channelBuffer);
- isisTlv = adjacencyStateTlv;
- break;
- default:
- break;
- }
- return isisTlv;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/TlvHeader.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/TlvHeader.java
deleted file mode 100644
index 68bda54..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/TlvHeader.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of TLV header.
- */
-public class TlvHeader implements IsisTlv {
- private int tlvType;
- private int tlvLength;
-
- /**
- * Returns TLV length of TLV.
- *
- * @return TLV length
- */
- public int tlvLength() {
- return tlvLength;
- }
-
- /**
- * Sets TLV length for TLV.
- *
- * @param tlvLength TLV length
- */
- public void setTlvLength(int tlvLength) {
- this.tlvLength = tlvLength;
- }
-
- /**
- * Returns TLV type of TLV.
- *
- * @return TLV type
- */
- public int tlvType() {
- return tlvType;
- }
-
- /**
- * Sets TLV type for TLV.
- *
- * @param tlvType TLV type
- */
- public void setTlvType(int tlvType) {
- this.tlvType = tlvType;
- }
-
- /**
- * Sets TLV values from channel buffer.
- *
- * @param channelBuffer channel Buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- //implemented in sub classes
- }
-
-
- /**
- * Returns TLV as byte array.
- *
- * @return byteArray TLV body of area address TLV
- */
- public byte[] asBytes() {
- return null;
- }
-
- /**
- * Returns TLV header of TLV as bytes.
- *
- * @return TLV header as bytes
- */
- public byte[] tlvHeaderAsByteArray() {
- List<Byte> headerLst = new ArrayList<>();
- headerLst.add((byte) this.tlvType);
- headerLst.add((byte) this.tlvLength);
- return Bytes.toArray(headerLst);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("tlvType", tlvType)
- .add("tlvLength", tlvLength)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/TlvType.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/TlvType.java
deleted file mode 100644
index bf609c8..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/TlvType.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Representation of various values for TLV types.
- */
-public enum TlvType {
- AREAADDRESS(1),
- ISREACHABILITY(2),
- ISNEIGHBORS(6),
- PADDING(8),
- LSPENTRY(9),
- AUTHENTICATION(10),
- HOSTNAME(137),
- EXTENDEDISREACHABILITY(22),
- ISALIAS(24),
- IPINTERNALREACHABILITY(128),
- PROTOCOLSUPPORTED(129),
- IPEXTERNALREACHABILITY(130),
- IPEXTENDEDREACHABILITY(135),
- IDRPINFORMATION(131),
- IPINTERFACEADDRESS(132),
- ADJACENCYSTATE(240);
-
- // Reverse lookup table
- private static final Map<Integer, TlvType> LOOKUP = new HashMap<>();
-
- // Populate the lookup table on loading time
- static {
- for (TlvType isisTlvType : EnumSet.allOf(TlvType.class)) {
- LOOKUP.put(isisTlvType.value(), isisTlvType);
- }
- }
-
- private int value;
-
- /**
- * Sets the TLV type value.
- *
- * @param value value.
- */
- TlvType(int value) {
- this.value = value;
- }
-
- /**
- * Gets the enum instance from type value - reverse lookup purpose.
- *
- * @param tlvTypeValue TLV type value
- * @return ISIS TLV type instance
- */
- public static TlvType get(int tlvTypeValue) {
- return LOOKUP.get(tlvTypeValue);
- }
-
- /**
- * Gets value.
- *
- * @return value
- */
- public int value() {
- return value;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/TlvsToBytes.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/TlvsToBytes.java
deleted file mode 100644
index 659ef57..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/TlvsToBytes.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import com.google.common.primitives.Bytes;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of conversion of TLV's to bytes.
- */
-public final class TlvsToBytes {
-
- private static final Logger log = LoggerFactory.getLogger(TlvsToBytes.class);
-
- /**
- * Creates an instance.
- */
- private TlvsToBytes() {
- }
-
- /**
- * Sets the ISIS TLV and returns in the form of bytes.
- *
- * @param isisTlv isisTlv.
- * @return tlvBytes
- */
- public static List<Byte> tlvToBytes(IsisTlv isisTlv) {
- List<Byte> tlvBytes = new ArrayList<>();
- if (isisTlv instanceof AreaAddressTlv) {
- AreaAddressTlv areaAddressTlv = (AreaAddressTlv) isisTlv;
- tlvBytes.addAll(Bytes.asList(areaAddressTlv.asBytes()));
- } else if (isisTlv instanceof IpInterfaceAddressTlv) {
- IpInterfaceAddressTlv ipInterfaceAddressTlv = (IpInterfaceAddressTlv) isisTlv;
- tlvBytes.addAll(Bytes.asList(ipInterfaceAddressTlv.asBytes()));
- } else if (isisTlv instanceof ProtocolSupportedTlv) {
- ProtocolSupportedTlv protocolSupportedTlv = (ProtocolSupportedTlv) isisTlv;
- tlvBytes.addAll(Bytes.asList(protocolSupportedTlv.asBytes()));
- } else if (isisTlv instanceof PaddingTlv) {
- PaddingTlv paddingTlv = (PaddingTlv) isisTlv;
- tlvBytes.addAll(Bytes.asList(paddingTlv.asBytes()));
- } else if (isisTlv instanceof IsisNeighborTlv) {
- IsisNeighborTlv isisNeighborTlv = (IsisNeighborTlv) isisTlv;
- tlvBytes.addAll(Bytes.asList(isisNeighborTlv.asBytes()));
- } else if (isisTlv instanceof AdjacencyStateTlv) {
- AdjacencyStateTlv isisAdjacencyState
- = (AdjacencyStateTlv) isisTlv;
- tlvBytes.addAll(Bytes.asList(isisAdjacencyState.asBytes()));
- } else if (isisTlv instanceof HostNameTlv) {
- HostNameTlv hostNameTlv
- = (HostNameTlv) isisTlv;
- tlvBytes.addAll(Bytes.asList(hostNameTlv.asBytes()));
- } else if (isisTlv instanceof IpExtendedReachabilityTlv) {
- IpExtendedReachabilityTlv ipExtendedReachabilityTlv
- = (IpExtendedReachabilityTlv) isisTlv;
- tlvBytes.addAll(Bytes.asList(ipExtendedReachabilityTlv.asBytes()));
- } else if (isisTlv instanceof IpInternalReachabilityTlv) {
- IpInternalReachabilityTlv ipInternalReachabilityTlv
- = (IpInternalReachabilityTlv) isisTlv;
- tlvBytes.addAll(Bytes.asList(ipInternalReachabilityTlv.asBytes()));
- } else if (isisTlv instanceof IsReachabilityTlv) {
- IsReachabilityTlv isReachabilityTlv
- = (IsReachabilityTlv) isisTlv;
- tlvBytes.addAll(Bytes.asList(isReachabilityTlv.asBytes()));
- } else if (isisTlv instanceof LspEntriesTlv) {
- LspEntriesTlv lspEntriesTlv
- = (LspEntriesTlv) isisTlv;
- tlvBytes.addAll(Bytes.asList(lspEntriesTlv.asBytes()));
- } else if (isisTlv instanceof IsExtendedReachability) {
- IsExtendedReachability isExtendedReachability
- = (IsExtendedReachability) isisTlv;
- tlvBytes.addAll(Bytes.asList(isExtendedReachability.asBytes()));
- } else {
- log.debug("TlvsToBytes::UNKNOWN TLV TYPE ::TlvsToBytes ");
- }
- return tlvBytes;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/package-info.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/package-info.java
deleted file mode 100644
index 9b03aa5..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ISIS protocol.
- */
-package org.onosproject.isis.io.isispacket.tlv;
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/AdministrativeGroup.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/AdministrativeGroup.java
deleted file mode 100644
index eaba07b..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/AdministrativeGroup.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.util.IsisUtil;
-
-
-/**
- * Representation of an administrative group.
- */
-public class AdministrativeGroup extends TlvHeader implements TrafficEngineeringSubTlv {
-
- private int administrativeGroup;
-
- /**
- * Creates an administrative group instance.
- *
- * @param header Tlv Header instance
- */
- public AdministrativeGroup(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Returns administrative group value.
- *
- * @return administrative group value
- */
- public int administrativeGroup() {
- return administrativeGroup;
- }
-
- /**
- * Sets administrative group value.
- *
- * @param administrativeGroup value
- */
- public void setAdministrativeGroup(int administrativeGroup) {
- this.administrativeGroup = administrativeGroup;
- }
-
- /**
- * Returns administrative group value.
- *
- * @return administrativeGroup value
- */
- public int getAdministrativeGroupValue() {
- return this.administrativeGroup;
- }
-
- /**
- * Reads bytes from channel buffer.
- *
- * @param channelBuffer Channel buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- byte[] tempByteArray = new byte[tlvLength()];
- channelBuffer.readBytes(tempByteArray, 0, tlvLength());
- this.setAdministrativeGroup(IsisUtil.byteToInteger(tempByteArray));
- }
-
- /**
- * Returns administrative group as byte array.
- *
- * @return administrative group instance as byte array
- */
- public byte[] asBytes() {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = tlvHeaderAsByteArray();
- byte[] linkSubTlvBody = tlvBodyAsBytes();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
-
- return linkSubType;
- }
-
- /**
- * Returns administrative group body as byte array.
- *
- * @return byte array of sub tlv administrative group
- */
- public byte[] tlvBodyAsBytes() {
-
- byte[] linkSubTypeBody;
- linkSubTypeBody = IsisUtil.convertToFourBytes(this.administrativeGroup);
-
- return linkSubTypeBody;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("administrativeGroup", administrativeGroup)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddress.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddress.java
deleted file mode 100644
index e9bba29..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddress.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
-* Copyright 2016-present Open Networking Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.util.IsisUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of interface ip address TE value.
- */
-public class InterfaceIpAddress extends TlvHeader implements TrafficEngineeringSubTlv {
- private static final Logger log =
- LoggerFactory.getLogger(NeighborIpAddress.class);
- private Ip4Address localInterfaceIPAddress;
-
- /**
- * Creates an instance of local interface ip address.
- *
- * @param header tlv header instance
- */
- public InterfaceIpAddress(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Adds local interface ip address.
- *
- * @param localAddress ip address
- */
- public void setIpAddress(Ip4Address localAddress) {
- this.localInterfaceIPAddress = localAddress;
- }
-
- /**
- * Gets local interface ip address.
- *
- * @return localAddress ip address
- */
- public Ip4Address localInterfaceIPAddress() {
- return localInterfaceIPAddress;
- }
-
- /**
- * Reads bytes from channel buffer.
- *
- * @param channelBuffer channel buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- while (channelBuffer.readableBytes() >= IsisUtil.FOUR_BYTES) {
- byte[] tempByteArray = new byte[IsisUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES);
- this.setIpAddress(Ip4Address.valueOf(tempByteArray));
-
- }
- }
-
- /**
- * Gets local interface ip address as byte array.
- *
- * @return local interface ip address as byte array
- */
- public byte[] asBytes() {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = tlvHeaderAsByteArray();
- byte[] linkSubTlvBody = tlvBodyAsBytes();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
-
- return linkSubType;
- }
-
- /**
- * Gets byte array of local interface ip address.
- *
- * @return byte array of local interface ip address
- */
- public byte[] tlvBodyAsBytes() {
-
- List<Byte> linkSubTypeBody = new ArrayList<>();
-
- linkSubTypeBody.addAll(Bytes.asList(this.localInterfaceIPAddress.toOctets()));
-
-
- return Bytes.toArray(linkSubTypeBody);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("localInterfaceIPAddress", localInterfaceIPAddress)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumBandwidth.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumBandwidth.java
deleted file mode 100644
index e645577..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumBandwidth.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.util.IsisUtil;
-
-
-/**
- * Representation of maximum bandwidth TE value.
- */
-public class MaximumBandwidth extends TlvHeader implements TrafficEngineeringSubTlv {
- private float maximumBandwidth;
-
- /**
- * Creates an instance of maximum bandwidth.
- *
- * @param header TLV header instance
- */
- public MaximumBandwidth(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Sets value of maximum bandwidth.
- *
- * @param maximumBandwidth value of maximum bandwidth
- */
- public void setMaximumBandwidth(float maximumBandwidth) {
- this.maximumBandwidth = maximumBandwidth;
- }
-
- /**
- * Returns value of maximum bandwidth.
- *
- * @return maximumBandwidth value of maximum bandwidth
- */
- public float getMaximumBandwidthValue() {
- return this.maximumBandwidth;
- }
-
- /**
- * Reads bytes from channel buffer.
- *
- * @param channelBuffer channel buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- byte[] tempByteArray = new byte[tlvLength()];
- channelBuffer.readBytes(tempByteArray, 0, tlvLength());
- int maxBandwidth = (IsisUtil.byteToInteger(tempByteArray));
- this.setMaximumBandwidth(Float.intBitsToFloat(maxBandwidth));
- }
-
- /**
- * Returns byte array of maximum bandwidth sub tlv.
- *
- * @return byte array of maximum bandwidth sub tlv
- */
- public byte[] asBytes() {
- byte[] linkSubType = null;
- byte[] linkSubTlvHeader = tlvHeaderAsByteArray();
- byte[] linkSubTlvBody = tlvBodyAsBytes();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
-
- return linkSubType;
- }
-
- /**
- * Returns maximum bandwidth sub tlv byte array.
- *
- * @return byte array of maximum bandwidth sub tlv
- */
- public byte[] tlvBodyAsBytes() {
- byte[] linkSubTypeBody;
- linkSubTypeBody = IsisUtil.convertToFourBytes(Float.floatToIntBits(this.maximumBandwidth));
- return linkSubTypeBody;
- }
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("maximumBandwidth", maximumBandwidth)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumReservableBandwidth.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumReservableBandwidth.java
deleted file mode 100644
index 80bf9a9..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumReservableBandwidth.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.util.IsisUtil;
-
-
-/**
- * Representation of maximum reservable bandwidth TE value.
- */
-public class MaximumReservableBandwidth extends TlvHeader implements TrafficEngineeringSubTlv {
- private float maximumReservableBandwidth;
-
- /**
- * Creates an instance of maximum reservable bandwidth.
- *
- * @param header TLV header
- */
- public MaximumReservableBandwidth(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Sets value of maximum reversible bandwidth.
- *
- * @param maximumBandwidth maximum reversible bandwidth
- */
- public void setMaximumBandwidth(float maximumBandwidth) {
- this.maximumReservableBandwidth = maximumBandwidth;
- }
-
- /**
- * Returns value of maximum reversible bandwidth.
- *
- * @return maximumBandwidth maximum reversible bandwidth
- */
- public float getMaximumBandwidthValue() {
- return this.maximumReservableBandwidth;
- }
-
- /**
- * Reads bytes from channel buffer.
- *
- * @param channelBuffer channel buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- byte[] tempByteArray = new byte[tlvLength()];
- channelBuffer.readBytes(tempByteArray, 0, tlvLength());
- int maxBandwidth = (IsisUtil.byteToInteger(tempByteArray));
- this.setMaximumBandwidth(Float.intBitsToFloat(maxBandwidth));
- }
-
- /**
- * Returns byte array of maximum reservable bandwidth.
- *
- * @return byte array of maximum reservable bandwidth
- */
- public byte[] asBytes() {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = tlvHeaderAsByteArray();
- byte[] linkSubTlvBody = tlvBodyAsBytes();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
- return linkSubType;
-
- }
-
- /**
- * Returns maximum reservable bandwidth sub tlv body as byte array.
- *
- * @return byte of maximum reservable bandwidth sub tlv body
- */
- public byte[] tlvBodyAsBytes() {
- byte[] linkSubTypeBody;
- linkSubTypeBody = IsisUtil.convertToFourBytes(Float.floatToIntBits(this.maximumReservableBandwidth));
-
- return linkSubTypeBody;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("maximumReservableBandwidth", maximumReservableBandwidth)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/NeighborIpAddress.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/NeighborIpAddress.java
deleted file mode 100644
index 0de53f1..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/NeighborIpAddress.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
-* Copyright 2016-present Open Networking Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.util.IsisUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of neighbor ip address TE value.
- */
-public class NeighborIpAddress extends TlvHeader implements TrafficEngineeringSubTlv {
- private static final Logger log =
- LoggerFactory.getLogger(NeighborIpAddress.class);
- private Ip4Address neighborIPAddress;
-
- /**
- * Creates an instance of neighbor ip address.
- *
- * @param header tlv header instance
- */
- public NeighborIpAddress(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Sets the neighbor ip address.
- *
- * @param neighborIPAddress ip address
- */
- public void setIpAddress(Ip4Address neighborIPAddress) {
- this.neighborIPAddress = neighborIPAddress;
- }
-
- /**
- * Gets the neighbor ip address.
- *
- * @return neighbor ip address
- */
- public Ip4Address neighborIPAddress() {
- return neighborIPAddress;
- }
-
- /**
- * Reads bytes from channel buffer.
- *
- * @param channelBuffer channel buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- while (channelBuffer.readableBytes() >= IsisUtil.FOUR_BYTES) {
- byte[] tempByteArray = new byte[IsisUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES);
- this.setIpAddress(Ip4Address.valueOf(tempByteArray));
-
- }
- }
-
- /**
- * Gets the neighbor ip address as byte array.
- *
- * @return neighbor ip address as byte array
- */
- public byte[] asBytes() {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = tlvHeaderAsByteArray();
- byte[] linkSubTlvBody = tlvBodyAsBytes();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
-
- return linkSubType;
- }
-
- /**
- * Gets byte array of neighborIPAddress.
- *
- * @return byte array of neighborIPAddress
- */
- public byte[] tlvBodyAsBytes() {
-
- List<Byte> linkSubTypeBody = new ArrayList<>();
-
- linkSubTypeBody.addAll(Bytes.asList(this.neighborIPAddress.toOctets()));
-
-
- return Bytes.toArray(linkSubTypeBody);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- NeighborIpAddress that = (NeighborIpAddress) o;
- return Objects.equal(neighborIPAddress, that.neighborIPAddress);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(neighborIPAddress);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("localInterfaceIPAddress", neighborIPAddress)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvFinder.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvFinder.java
deleted file mode 100644
index 782d5bd..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvFinder.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-
-/**
- * Representation of sub tlv finder.
- */
-public final class SubTlvFinder {
- /**
- * Creates an instance.
- */
- private SubTlvFinder() {
-
- }
-
- /**
- * Sets the value for TLV header and to find sub TLV and populate.
- *
- * @param tlvHeader tlvHeader
- * @param channelBuffer byteBuf
- * @return subTlv traffic engineering sub tlv
- */
- public static TrafficEngineeringSubTlv findSubTlv(TlvHeader tlvHeader, ChannelBuffer channelBuffer) {
-
- TrafficEngineeringSubTlv subTlv = null;
-
- switch (SubTlvType.get(tlvHeader.tlvType())) {
- case ADMINISTRATIVEGROUP:
- AdministrativeGroup administrativeGroup = new AdministrativeGroup(tlvHeader);
- administrativeGroup.readFrom(channelBuffer);
- subTlv = administrativeGroup;
- break;
- case MAXIMUMBANDWIDTH:
- MaximumBandwidth maximumBandwidth = new MaximumBandwidth(tlvHeader);
- maximumBandwidth.readFrom(channelBuffer);
- subTlv = maximumBandwidth;
- break;
- case MAXIMUMRESERVABLEBANDWIDTH:
- MaximumReservableBandwidth maxResBandwidth = new MaximumReservableBandwidth(tlvHeader);
- maxResBandwidth.readFrom(channelBuffer);
- subTlv = maxResBandwidth;
- break;
- case TRAFFICENGINEERINGMETRIC:
- TrafficEngineeringMetric teMetric = new TrafficEngineeringMetric(tlvHeader);
- teMetric.readFrom(channelBuffer);
- subTlv = teMetric;
- break;
- case UNRESERVEDBANDWIDTH:
- UnreservedBandwidth unreservedBandwidth = new UnreservedBandwidth(tlvHeader);
- unreservedBandwidth.readFrom(channelBuffer);
- subTlv = unreservedBandwidth;
- break;
- case INTERFACEADDRESS:
- InterfaceIpAddress ipInterfaceAddressTlv = new InterfaceIpAddress(tlvHeader);
- ipInterfaceAddressTlv.readFrom(channelBuffer);
- subTlv = ipInterfaceAddressTlv;
- break;
- case NEIGHBORADDRESS:
- NeighborIpAddress ipNeighborAddressTlv = new NeighborIpAddress(tlvHeader);
- ipNeighborAddressTlv.readFrom(channelBuffer);
- subTlv = ipNeighborAddressTlv;
- break;
- default:
- //TODO
- break;
- }
- return subTlv;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytes.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytes.java
deleted file mode 100644
index a7bb08f..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytes.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import com.google.common.primitives.Bytes;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of conversion of TLV's to bytes.
- */
-public final class SubTlvToBytes {
-
- private static final Logger log = LoggerFactory.getLogger(SubTlvToBytes.class);
-
- /**
- * Creates an instance.
- */
- private SubTlvToBytes() {
- //private constructor
- }
-
- /**
- * Sets the ISIS sub TLV and returns in the form of bytes.
- *
- * @param subTlv isisTlv.
- * @return subTlvBytes
- */
- public static List<Byte> tlvToBytes(TrafficEngineeringSubTlv subTlv) {
-
- List<Byte> subTlvBytes = new ArrayList<>();
- if (subTlv instanceof AdministrativeGroup) {
- AdministrativeGroup administrativeGroup = (AdministrativeGroup) subTlv;
- subTlvBytes.addAll(Bytes.asList(administrativeGroup.asBytes()));
- } else if (subTlv instanceof MaximumBandwidth) {
- MaximumBandwidth maximumBandwidth = (MaximumBandwidth) subTlv;
- subTlvBytes.addAll(Bytes.asList(maximumBandwidth.asBytes()));
- } else if (subTlv instanceof MaximumReservableBandwidth) {
- MaximumReservableBandwidth maximumReservableBandwidth = (MaximumReservableBandwidth) subTlv;
- subTlvBytes.addAll(Bytes.asList(maximumReservableBandwidth.asBytes()));
- } else if (subTlv instanceof TrafficEngineeringMetric) {
- TrafficEngineeringMetric trafficEngineeringMetric = (TrafficEngineeringMetric) subTlv;
- subTlvBytes.addAll(Bytes.asList(trafficEngineeringMetric.asBytes()));
- } else if (subTlv instanceof UnreservedBandwidth) {
- UnreservedBandwidth unreservedBandwidth = (UnreservedBandwidth) subTlv;
- subTlvBytes.addAll(Bytes.asList(unreservedBandwidth.asBytes()));
- } else if (subTlv instanceof NeighborIpAddress) {
- NeighborIpAddress interfaceIpAddress = (NeighborIpAddress) subTlv;
- subTlvBytes.addAll(Bytes.asList(interfaceIpAddress.asBytes()));
- } else {
- log.debug("TlvsToBytes::UNKNOWN TLV TYPE ::TlvsToBytes ");
- }
-
- return subTlvBytes;
- }
-}
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvType.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvType.java
deleted file mode 100644
index 98d43b3..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvType.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Representation of sub tlv type.
- */
-public enum SubTlvType {
- /**
- * Represents traffic engineering administrative group TLV.
- */
- ADMINISTRATIVEGROUP(3),
- /**
- * Represents traffic engineering maximum bandwidth TLV.
- */
- MAXIMUMBANDWIDTH(9),
- /**
- * Represents traffic engineering maximum reservable bandwidth TLV.
- */
- MAXIMUMRESERVABLEBANDWIDTH(10),
- /**
- * Represents traffic engineering metric TLV.
- */
- TRAFFICENGINEERINGMETRIC(18),
- /**
- * Represents traffic engineering interface address TLV.
- */
- INTERFACEADDRESS(6),
- /**
- * Represents traffic engineering neighbor address TLV.
- */
- NEIGHBORADDRESS(8),
- /**
- * Represents traffic engineering unreserved bandwidth TLV.
- */
- UNRESERVEDBANDWIDTH(11);
-
- // Reverse lookup table
- private static final Map<Integer, SubTlvType> LOOKUP = new HashMap<>();
-
- // Populate the lookup table on loading time
- static {
- for (SubTlvType subTlvType : EnumSet.allOf(SubTlvType.class)) {
- LOOKUP.put(subTlvType.value(), subTlvType);
- }
- }
-
- private int value;
-
- /**
- * Sets the sub TLV type value.
- *
- * @param value value.
- */
- SubTlvType(int value) {
- this.value = value;
- }
-
- /**
- * Returns the enum instance from type value - reverse lookup purpose.
- *
- * @param subTlvTypeValue TLV type value
- * @return ISIS sub TLV type instance
- */
- public static SubTlvType get(int subTlvTypeValue) {
- return LOOKUP.get(subTlvTypeValue);
- }
-
- /**
- * Returns value.
- *
- * @return value
- */
- public int value() {
- return value;
- }
-}
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/TrafficEngineeringMetric.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/TrafficEngineeringMetric.java
deleted file mode 100644
index fa91d79..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/TrafficEngineeringMetric.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.util.IsisUtil;
-
-/**
- * Representation of traffic engineering metric TE value.
- */
-public class TrafficEngineeringMetric extends TlvHeader implements TrafficEngineeringSubTlv {
- private long trafficEngineeringMetric;
-
- /**
- * Creates an instance of traffic engineering metric .
- *
- * @param header tlv header instance
- */
- public TrafficEngineeringMetric(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Sets TE metric value.
- *
- * @param trafficEngineeringMetric value of trafficEngineeringMetric
- */
- public void setTrafficEngineeringMetric(long trafficEngineeringMetric) {
- this.trafficEngineeringMetric = trafficEngineeringMetric;
- }
-
- /**
- * Returns TE metric value.
- *
- * @return value of traffic engineering metric
- */
- public long getTrafficEngineeringMetricValue() {
- return this.trafficEngineeringMetric;
- }
-
- /**
- * Reads bytes from channel buffer .
- *
- * @param channelBuffer channel buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- byte[] tempByteArray = new byte[tlvLength()];
- channelBuffer.readBytes(tempByteArray, 0, tlvLength());
- this.setTrafficEngineeringMetric(IsisUtil.byteToLong(tempByteArray));
- }
-
- /**
- * Returns instance as byte array.
- *
- * @return instance as byte array
- */
- public byte[] asBytes() {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = tlvHeaderAsByteArray();
- byte[] linkSubTlvBody = tlvBodyAsBytes();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
-
- return linkSubType;
- }
-
- /**
- * Returns trafficEngineeringMetric as byte array .
- *
- * @return byte array of trafficEngineeringMetric
- */
- public byte[] tlvBodyAsBytes() {
-
- byte[] linkSubTypeBody;
- linkSubTypeBody = IsisUtil.convertToFourBytes(this.trafficEngineeringMetric);
-
- return linkSubTypeBody;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("trafficEngineeringMetric", trafficEngineeringMetric)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/TrafficEngineeringSubTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/TrafficEngineeringSubTlv.java
deleted file mode 100644
index 0eb7071..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/TrafficEngineeringSubTlv.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-/**
- * Representation of traffic engineering sub tlv.
- */
-public interface TrafficEngineeringSubTlv {
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/UnreservedBandwidth.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/UnreservedBandwidth.java
deleted file mode 100644
index 3e654a2..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/UnreservedBandwidth.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of an unreserved band width TE value.
- */
-public class UnreservedBandwidth extends TlvHeader implements TrafficEngineeringSubTlv {
- private List<Float> unReservedBandwidth = new ArrayList<>();
-
- /**
- * Creates an instance of unreserved band width.
- *
- * @param header tlv header instance
- */
- public UnreservedBandwidth(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Adds value of un reserved bandwidth .
- *
- * @param unreservedBandwidth value of un reserved bandwidth
- */
- public void addUnReservedBandwidth(float unreservedBandwidth) {
- this.unReservedBandwidth.add(unreservedBandwidth);
- }
-
- /**
- * Returns list of un reserved bandwidth .
- *
- * @return List of un reserved bandwidth
- */
- public List<Float> unReservedBandwidthValue() {
- return this.unReservedBandwidth;
- }
-
- /**
- * Reads bytes from channel buffer .
- *
- * @param channelBuffer channel buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- while (channelBuffer.readableBytes() >= IsisUtil.FOUR_BYTES) {
- int maxReversibleBandwidth = channelBuffer.readInt();
- this.addUnReservedBandwidth(Float.intBitsToFloat(maxReversibleBandwidth));
- }
- }
-
- /**
- * Returns instance as byte array.
- *
- * @return instance as byte array
- */
- public byte[] asBytes() {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = tlvHeaderAsByteArray();
- byte[] linkSubTlvBody = tlvBodyAsBytes();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
-
- return linkSubType;
- }
-
- /**
- * Returns unreserved bandwidth as byte array.
- *
- * @return unreserved bandwidth as byte array
- */
- public byte[] tlvBodyAsBytes() {
- List<Byte> linkSubTypeBody = new ArrayList<>();
- if (this.unReservedBandwidth.size() < 8) {
- int size = IsisUtil.EIGHT_BYTES - this.unReservedBandwidth.size();
- for (int i = 0; i < size; i++) {
- linkSubTypeBody.addAll(Bytes.asList(IsisUtil.convertToFourBytes(IsisUtil.INITIAL_BANDWIDTH)));
- }
- }
- for (Float unreservedBandwidth : this.unReservedBandwidth) {
- int unresBandwidth = Float.floatToIntBits(unreservedBandwidth);
- linkSubTypeBody.addAll(Bytes.asList(IsisUtil.convertToFourBytes(unresBandwidth)));
- }
-
- return Bytes.toArray(linkSubTypeBody);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("unReservedBandwidth", unReservedBandwidth)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/package-info.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/package-info.java
deleted file mode 100644
index bfb1ed6..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ISIS protocol.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/package-info.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/package-info.java
deleted file mode 100644
index 89ed736..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ISIS protocol IO.
- */
-package org.onosproject.isis.io;
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/ChecksumCalculator.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/ChecksumCalculator.java
deleted file mode 100644
index 0671eed..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/ChecksumCalculator.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.util;
-
-
-import java.util.Arrays;
-
-/**
- * Calculates checksum for ISIS LSP packets.
- */
-public class ChecksumCalculator {
-
- /**
- * Verifies the checksum is valid in given LSP packet bytes.
- *
- * @param lspPacket lsp as byte array
- * @param lspChecksumPos1 position of checksum bit in packet
- * @param lspChecksumPos2 position of checksum bit in packet
- * @return true if valid else false
- */
- public boolean validateLspCheckSum(byte[] lspPacket, int lspChecksumPos1, int lspChecksumPos2) {
-
- byte[] checksum = calculateLspChecksum(lspPacket, lspChecksumPos1, lspChecksumPos2);
- if (lspPacket[lspChecksumPos1] == checksum[0] && lspPacket[lspChecksumPos2] == checksum[1]) {
- return true;
- }
- return false;
- }
-
-
- /**
- * Calculates the LSP checksum.
- *
- * @param lspBytes as byte array
- * @param lspChecksumPos1 position of checksum bit in packet
- * @param lspChecksumPos2 position of checksum bit in packet
- * @return checksum bytes
- */
- public byte[] calculateLspChecksum(byte[] lspBytes, int lspChecksumPos1, int lspChecksumPos2) {
-
- byte[] tempLsaByte = Arrays.copyOf(lspBytes, lspBytes.length);
-
- int[] checksumOut = {0, 0};
- tempLsaByte[lspChecksumPos1] = 0;
- tempLsaByte[lspChecksumPos2] = 0;
- byte[] byteCheckSum = {0, 0};
- for (int i = 12; i < tempLsaByte.length; i++) {
- checksumOut[0] = checksumOut[0] + ((int) tempLsaByte[i] & 0xFF);
- checksumOut[1] = checksumOut[1] + checksumOut[0];
- }
- checksumOut[0] = checksumOut[0] % 255;
- checksumOut[1] = checksumOut[1] % 255;
- int byte1 = (int) ((tempLsaByte.length - lspChecksumPos1 - 1) * checksumOut[0] - checksumOut[1]) % 255;
- if (byte1 <= 0) {
- byte1 += 255;
- }
- int byte2 = 510 - checksumOut[0] - byte1;
- if (byte2 > 255) {
- byte2 -= 255;
- }
-
- byteCheckSum[0] = (byte) byte1;
- byteCheckSum[1] = (byte) byte2;
-
- return byteCheckSum;
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisConstants.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisConstants.java
deleted file mode 100644
index 9e48ee8..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisConstants.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.isis.io.util;
-
-import org.onlab.packet.Ip4Address;
-
-/**
- * Representation of ISIS Constants.
- */
-public final class IsisConstants {
- public static final char PDU_LENGTH = 1497;
- public static final char CONFIG_LENGTH = 1498;
- public static final int MINIMUM_FRAME_LEN = 1521;
- public static final int METADATA_LEN = 7;
- public static final String SHOST = "127.0.0.1";
- public static final Ip4Address DEFAULTIP = Ip4Address.valueOf("0.0.0.0");
- public static final int SPORT = 3000;
- public static final byte L2 = 1;
- public static final int IRPDISCRIMINATOR = 131;
- public static final int ISISVERSION = 1;
- public static final int RESERVED = 0;
- public static final int PRIORITY = 0;
- public static final int MAXAREAADDRESS = 0;
- public static final int SYSTEMIDLENGTH = 0;
- public static final int PROTOCOLSUPPORTED = 204;
- public static final int LOCALCIRCUITIDFORP2P = 130;
- public static final int P2PHELLOHEADERLENGTH = 20;
- public static final int HELLOHEADERLENGTH = 27;
- public static final int CSNPDUHEADERLENGTH = 33;
- public static final int PSNPDUHEADERLENGTH = 17;
- public static final int PDULENGTHPOSITION = 17;
- public static final int COMMONHEADERLENGTH = 8;
- public static final int LSPMAXAGE = 1200;
- public static final int LSPREFRESH = 900;
- public static final int MAXSEQUENCENUMBER = Integer.MAX_VALUE;
- public static final int STARTLSSEQUENCENUM = 1;
- public static final int LENGTHPOSITION = 8;
- public static final int RESERVEDPOSITION = 6;
- public static final int CHECKSUMPOSITION = 24;
- public static final String REFRESHLSP = "refreshLsp";
- public static final String MAXAGELSP = "maxAgeLsp";
- public static final String DEFAULTLANID = "0000.0000.0000.00";
- public static final String PROCESSESID = "processId";
- public static final String INTERFACE = "interface";
- public static final String INTERFACEINDEX = "interfaceIndex";
- public static final String INTERMEDIATESYSTEMNAME = "intermediateSystemName";
- public static final String SYSTEMID = "systemId";
- public static final String RESERVEDPACKETCIRCUITTYPE = "reservedPacketCircuitType";
- public static final String CIRCUITID = "circuitId";
- public static final String NETWORKTYPE = "networkType";
- public static final String AREAADDRESS = "areaAddress";
- public static final String HOLDINGTIME = "holdingTime";
- public static final String HELLOINTERVAL = "helloInterval";
- public static final int PORT = 7000;
- public static final String LSPADDED = "LSP_ADDED";
- public static final String LSPREMOVED = "LSP_REMOVED";
-
- /**
- * Non parameterized constructor.
- */
- private IsisConstants() {
- }
-}
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java
deleted file mode 100644
index 511f000..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java
+++ /dev/null
@@ -1,762 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.util;
-
-import com.google.common.primitives.Bytes;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.MacAddress;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisInterfaceState;
-import org.onosproject.isis.controller.IsisNeighbor;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.controller.IsisRouterType;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
-import org.onosproject.isis.io.isispacket.pdu.P2PHelloPdu;
-import org.onosproject.isis.io.isispacket.tlv.AdjacencyStateTlv;
-import org.onosproject.isis.io.isispacket.tlv.AreaAddressTlv;
-import org.onosproject.isis.io.isispacket.tlv.IpInterfaceAddressTlv;
-import org.onosproject.isis.io.isispacket.tlv.IsisNeighborTlv;
-import org.onosproject.isis.io.isispacket.tlv.PaddingTlv;
-import org.onosproject.isis.io.isispacket.tlv.ProtocolSupportedTlv;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.isispacket.tlv.TlvType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.xml.bind.DatatypeConverter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-/**
- * Representation of ISIS utils.
- */
-public final class IsisUtil {
- public static final int ETHER_HEADER_LEN = 17;
- public static final int ID_SIX_BYTES = 6;
- public static final int ID_PLUS_ONE_BYTE = 7;
- public static final int ID_PLUS_TWO_BYTE = 8;
- public static final int THREE_BYTES = 3;
- public static final int TWO_BYTES = 2;
- public static final int SIX_BYTES = 6;
- public static final int EIGHT_BYTES = 8;
- public static final int FOUR_BYTES = 4;
- public static final int PADDING_FIXED_LENGTH = 255;
- public static final int TLVHEADERLENGTH = 2;
- public static final int INITIAL_BANDWIDTH = 12500000;
- private static final Logger log = LoggerFactory.getLogger(IsisUtil.class);
-
- /**
- * Creates an instance.
- */
- private IsisUtil() {
-
- }
-
- /**
- * Checks given IPs are in same network or not.
- *
- * @param ip1 IP address
- * @param ip2 IP address
- * @param mask network mask
- * @return true if both are in same network else false
- */
- public static boolean sameNetwork(Ip4Address ip1, Ip4Address ip2, byte[] mask) {
- try {
- byte[] a1 = ip1.toOctets();
- byte[] a2 = ip2.toOctets();
- for (int i = 0; i < a1.length; i++) {
- if ((a1[i] & mask[i]) != (a2[i] & mask[i])) {
- return false;
- }
- }
- } catch (Exception e) {
- log.debug("Exception::IsisUtil::sameNetwork:: {}", e.getMessage());
- }
- return true;
- }
-
- /**
- * Parse byte array to string system ID.
- *
- * @param bytes system ID
- * @return systemId system ID
- */
- public static String systemId(byte[] bytes) {
- String systemId = "";
- for (Byte byt : bytes) {
- String hexa = Integer.toHexString(Byte.toUnsignedInt(byt));
- if (hexa.length() % 2 != 0) {
- hexa = "0" + hexa;
- }
- systemId = systemId + hexa;
- if (systemId.length() == 4 || systemId.length() == 9) {
- systemId = systemId + ".";
- }
- }
- return systemId;
- }
-
- /**
- * Parse byte array to LAN ID.
- *
- * @param bytes LAN ID
- * @return systemIdPlus system ID
- */
- public static String systemIdPlus(byte[] bytes) {
- int count = 1;
- String systemId = "";
- for (Byte byt : bytes) {
- String hexa = Integer.toHexString(Byte.toUnsignedInt(byt));
- if (hexa.length() % 2 != 0) {
- hexa = "0" + hexa;
- }
- if (count == 7 && bytes.length == 8) {
- systemId = systemId + hexa + "-";
- } else {
- systemId = systemId + hexa;
- }
- if (systemId.length() == 4 || systemId.length() == 9
- || systemId.length() == 14) {
- systemId = systemId + ".";
- }
- count++;
- }
- return systemId;
- }
-
- /**
- * Parse byte array to area address.
- *
- * @param bytes area address
- * @return areaAddress area address
- */
- public static String areaAddress(byte[] bytes) {
- String areaAddres = "";
- for (Byte byt : bytes) {
- String hexa = Integer.toHexString(Byte.toUnsignedInt(byt));
- if (hexa.length() % 2 != 0) {
- hexa = "0" + hexa;
- }
- areaAddres = areaAddres + hexa;
- }
- return areaAddres;
- }
-
- /**
- * Parse area address to bytes.
- *
- * @param address area address
- * @return areaAddress area address
- */
- public static List<Byte> areaAddressToBytes(String address) {
- List<Byte> idList = new ArrayList<>();
- for (int i = 0; i < address.length(); i = i + 2) {
- Character c1 = address.charAt(i);
- Character c2 = address.charAt(i + 1);
- String str = c1.toString() + c2.toString();
- idList.add((byte) Integer.parseInt(str, 16));
- }
- return idList;
- }
-
- /**
- * Returns PDU headaer length.
- *
- * @param pduType PDU type
- * @return headerLength header length
- */
- public static int getPduHeaderLength(int pduType) {
- int headerLength = 0;
- switch (IsisPduType.get(pduType)) {
- case L1HELLOPDU:
- case L2HELLOPDU:
- case L1LSPDU:
- case L2LSPDU:
- headerLength = IsisConstants.HELLOHEADERLENGTH;
- break;
- case P2PHELLOPDU:
- headerLength = IsisConstants.P2PHELLOHEADERLENGTH;
- break;
- case L1PSNP:
- case L2PSNP:
- headerLength = IsisConstants.PSNPDUHEADERLENGTH;
- break;
- case L1CSNP:
- case L2CSNP:
- headerLength = IsisConstants.CSNPDUHEADERLENGTH;
- break;
- default:
- break;
- }
- return headerLength;
- }
-
- /**
- * Adds the PDU length in packet.
- *
- * @param isisPacket ISIS packet
- * @param lengthBytePos1 length byte position
- * @param lengthBytePos2 length byte position
- * @param reservedBytePos reserved byte position
- * @return byte array with PDU length
- */
- public static byte[] addLengthAndMarkItInReserved(byte[] isisPacket, int lengthBytePos1,
- int lengthBytePos2, int reservedBytePos) {
- //Set the length of the packet
- //Get the total length of the packet
- int length = isisPacket.length;
- //Convert the lenth to two bytes as the length field is 2 bytes
- byte[] lenthInTwoBytes = IsisUtil.convertToTwoBytes(length);
- //isis header 3rd and 4th position represents length
- isisPacket[lengthBytePos1] = lenthInTwoBytes[0]; //assign 1st byte in lengthBytePos1
- isisPacket[lengthBytePos2] = lenthInTwoBytes[1]; //assign 2st byte in lengthBytePos2
- isisPacket[reservedBytePos] = (byte) lengthBytePos1;
- return isisPacket;
- }
-
- /**
- * Adds the checksum in packet.
- *
- * @param isisPacket ISIS packet
- * @param checksumBytePos1 checksum byte position
- * @param checksumBytePos2 checksum byte position
- * @return byte array with PDU length
- */
- public static byte[] addChecksum(byte[] isisPacket, int checksumBytePos1, int checksumBytePos2) {
- //Set the checksum for the packet
- //Convert the length to two bytes as the length field is 2 bytes
- byte[] checksumInTwoBytes = new ChecksumCalculator().calculateLspChecksum(
- isisPacket, checksumBytePos1, checksumBytePos2);
- //isis header 3rd and 4th position represents length
- isisPacket[checksumBytePos1] = checksumInTwoBytes[0];
- isisPacket[checksumBytePos2] = checksumInTwoBytes[1];
- return isisPacket;
- }
-
- /**
- * Adds frame a packet of 1498 of size.
- *
- * @param isisPacket ISIS packet
- * @param interfaceIndex interface index
- * @return byte array with 1498 is the length
- */
- public static byte[] framePacket(byte[] isisPacket, int interfaceIndex) {
- //Set the length of the packet
- //Get the total length of the packet
- int length = isisPacket.length;
- //PDU_LENGTH + 1 byte for interface index
- if (length < IsisConstants.PDU_LENGTH + 1) {
- byte[] bytes = new byte[IsisConstants.PDU_LENGTH + 1];
- System.arraycopy(isisPacket, 0, bytes, 0, length);
- bytes[IsisConstants.PDU_LENGTH] = (byte) interfaceIndex;
- return bytes;
- }
- return isisPacket;
- }
-
- /**
- * Parse source and LAN ID.
- *
- * @param id source and LAN ID
- * @return source and LAN ID
- */
- public static List<Byte> sourceAndLanIdToBytes(String id) {
- List<Byte> idList = new ArrayList<>();
- StringTokenizer tokenizer = new StringTokenizer(id, "." + "-");
- while (tokenizer.hasMoreElements()) {
- int i = 0;
- String str = tokenizer.nextToken();
- idList.add((byte) Integer.parseInt(str.substring(0, i + 2), 16));
- if (str.length() > 2) {
- idList.add((byte) Integer.parseInt(str.substring(i + 2, str.length()), 16));
- }
- }
- return idList;
- }
-
- /**
- * Parse padding for PDU based on current length.
- *
- * @param currentLength current length
- * @return byteArray padding array
- */
- public static byte[] getPaddingTlvs(int currentLength) {
- List<Byte> bytes = new ArrayList<>();
- while (IsisConstants.PDU_LENGTH > currentLength) {
- int length = IsisConstants.PDU_LENGTH - currentLength;
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.PADDING.value());
- if (length >= PADDING_FIXED_LENGTH) {
- tlvHeader.setTlvLength(PADDING_FIXED_LENGTH);
- } else {
- tlvHeader.setTlvLength(IsisConstants.PDU_LENGTH - (currentLength + TLVHEADERLENGTH));
- }
- PaddingTlv tlv = new PaddingTlv(tlvHeader);
- bytes.addAll(Bytes.asList(tlv.asBytes()));
- currentLength = currentLength + tlv.tlvLength() + TLVHEADERLENGTH;
- }
- byte[] byteArray = new byte[bytes.size()];
- int i = 0;
- for (byte byt : bytes) {
- byteArray[i++] = byt;
- }
- return byteArray;
- }
-
- /**
- * Converts an integer to two bytes.
- *
- * @param numberToConvert number to convert
- * @return numInBytes given number as bytes
- */
- public static byte[] convertToTwoBytes(int numberToConvert) {
-
- byte[] numInBytes = new byte[2];
- String s1 = Integer.toHexString(numberToConvert);
- if (s1.length() % 2 != 0) {
- s1 = "0" + s1;
- }
- byte[] hexas = DatatypeConverter.parseHexBinary(s1);
- if (hexas.length == 1) {
- numInBytes[0] = 0;
- numInBytes[1] = hexas[0];
- } else {
- numInBytes[0] = hexas[0];
- numInBytes[1] = hexas[1];
- }
- return numInBytes;
- }
-
- /**
- * Converts a number to four bytes.
- *
- * @param numberToConvert number to convert
- * @return numInBytes given number as bytes
- */
- public static byte[] convertToFourBytes(int numberToConvert) {
- byte[] numInBytes = new byte[4];
- String s1 = Integer.toHexString(numberToConvert);
- if (s1.length() % 2 != 0) {
- s1 = "0" + s1;
- }
- byte[] hexas = DatatypeConverter.parseHexBinary(s1);
- if (hexas.length == 1) {
- numInBytes[0] = 0;
- numInBytes[1] = 0;
- numInBytes[2] = 0;
- numInBytes[3] = hexas[0];
- } else if (hexas.length == 2) {
- numInBytes[0] = 0;
- numInBytes[1] = 0;
- numInBytes[2] = hexas[0];
- numInBytes[3] = hexas[1];
- } else if (hexas.length == 3) {
- numInBytes[0] = 0;
- numInBytes[1] = hexas[0];
- numInBytes[2] = hexas[1];
- numInBytes[3] = hexas[2];
- } else {
- numInBytes[0] = hexas[0];
- numInBytes[1] = hexas[1];
- numInBytes[2] = hexas[2];
- numInBytes[3] = hexas[3];
- }
- return numInBytes;
- }
-
- /**
- * Returns the P2P hello PDU.
- *
- * @param isisInterface ISIS interface instance
- * @param paddingEnabled padding enabled or not
- * @return hello PDU
- */
- public static byte[] getP2pHelloPdu(IsisInterface isisInterface, boolean paddingEnabled) {
- IsisHeader isisHeader = new IsisHeader();
- isisHeader.setIrpDiscriminator((byte) IsisConstants.IRPDISCRIMINATOR);
- isisHeader.setPduHeaderLength((byte) IsisConstants.P2PHELLOHEADERLENGTH);
- isisHeader.setVersion((byte) IsisConstants.ISISVERSION);
- isisHeader.setIdLength((byte) IsisConstants.SYSTEMIDLENGTH);
- isisHeader.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
- isisHeader.setVersion2((byte) IsisConstants.ISISVERSION);
- isisHeader.setReserved((byte) IsisConstants.PDULENGTHPOSITION);
- isisHeader.setMaximumAreaAddresses((byte) IsisConstants.MAXAREAADDRESS);
- P2PHelloPdu p2pHelloPdu = new P2PHelloPdu(isisHeader);
- p2pHelloPdu.setCircuitType((byte) isisInterface.reservedPacketCircuitType());
- p2pHelloPdu.setSourceId(isisInterface.systemId());
- p2pHelloPdu.setHoldingTime(isisInterface.holdingTime());
- p2pHelloPdu.setPduLength(IsisConstants.PDU_LENGTH);
- p2pHelloPdu.setLocalCircuitId((byte) IsisConstants.LOCALCIRCUITIDFORP2P);
-
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
- tlvHeader.setTlvLength(0);
- AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
- areaAddressTlv.addAddress(isisInterface.areaAddress());
- p2pHelloPdu.addTlv(areaAddressTlv);
-
- tlvHeader.setTlvType(TlvType.PROTOCOLSUPPORTED.value());
- tlvHeader.setTlvLength(0);
- ProtocolSupportedTlv protocolSupportedTlv = new ProtocolSupportedTlv(tlvHeader);
- protocolSupportedTlv.addProtocolSupported((byte) IsisConstants.PROTOCOLSUPPORTED);
- p2pHelloPdu.addTlv(protocolSupportedTlv);
-
- tlvHeader.setTlvType(TlvType.ADJACENCYSTATE.value());
- tlvHeader.setTlvLength(0);
- AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader);
- adjacencyStateTlv.setAdjacencyType((byte) IsisInterfaceState.DOWN.value());
- adjacencyStateTlv.setLocalCircuitId(Integer.parseInt(isisInterface.circuitId()));
- Set<MacAddress> neighbors = isisInterface.neighbors();
- if (!neighbors.isEmpty()) {
- IsisNeighbor neighbor = isisInterface.lookup(neighbors.iterator().next());
- adjacencyStateTlv.setAdjacencyType((byte) neighbor.interfaceState().value());
- adjacencyStateTlv.setNeighborSystemId(neighbor.neighborSystemId());
- adjacencyStateTlv.setNeighborLocalCircuitId(neighbor.localExtendedCircuitId());
- }
- p2pHelloPdu.addTlv(adjacencyStateTlv);
-
- tlvHeader.setTlvType(TlvType.IPINTERFACEADDRESS.value());
- tlvHeader.setTlvLength(0);
- IpInterfaceAddressTlv ipInterfaceAddressTlv = new IpInterfaceAddressTlv(tlvHeader);
- ipInterfaceAddressTlv.addInterfaceAddres(isisInterface.interfaceIpAddress());
- p2pHelloPdu.addTlv(ipInterfaceAddressTlv);
-
- byte[] beforePadding = p2pHelloPdu.asBytes();
- byte[] helloMessage;
- if (paddingEnabled) {
- byte[] paddingTlvs = getPaddingTlvs(beforePadding.length);
- helloMessage = Bytes.concat(beforePadding, paddingTlvs);
- } else {
- helloMessage = beforePadding;
- }
- return helloMessage;
- }
-
- /**
- * Returns the L1 hello PDU.
- *
- * @param isisInterface ISIS interface instance
- * @param paddingEnabled padding enabled or not
- * @return helloMessage hello PDU
- */
- public static byte[] getL1HelloPdu(IsisInterface isisInterface, boolean paddingEnabled) {
- return getL1OrL2HelloPdu(isisInterface, IsisPduType.L1HELLOPDU, paddingEnabled);
- }
-
- /**
- * Returns the L2 hello PDU.
- *
- * @param isisInterface ISIS interface instance
- * @param paddingEnabled padding enabled or not
- * @return helloMessage hello PDU
- */
- public static byte[] getL2HelloPdu(IsisInterface isisInterface, boolean paddingEnabled) {
- return getL1OrL2HelloPdu(isisInterface, IsisPduType.L2HELLOPDU, paddingEnabled);
- }
-
- /**
- * Returns the hello PDU.
- *
- * @param isisInterface ISIS interface instance
- * @param paddingEnabled padding enabled or not
- * @return helloMessage hello PDU
- */
- private static byte[] getL1OrL2HelloPdu(IsisInterface isisInterface, IsisPduType isisPduType,
- boolean paddingEnabled) {
- String lanId = "";
- IsisHeader isisHeader = new IsisHeader();
- isisHeader.setIrpDiscriminator((byte) IsisConstants.IRPDISCRIMINATOR);
- isisHeader.setPduHeaderLength((byte) IsisConstants.HELLOHEADERLENGTH);
- isisHeader.setVersion((byte) IsisConstants.ISISVERSION);
- isisHeader.setIdLength((byte) IsisConstants.SYSTEMIDLENGTH);
- if (isisPduType == IsisPduType.L1HELLOPDU) {
- isisHeader.setIsisPduType(IsisPduType.L1HELLOPDU.value());
- lanId = isisInterface.l1LanId();
- } else if (isisPduType == IsisPduType.L2HELLOPDU) {
- isisHeader.setIsisPduType(IsisPduType.L2HELLOPDU.value());
- lanId = isisInterface.l2LanId();
- }
- isisHeader.setVersion2((byte) IsisConstants.ISISVERSION);
- isisHeader.setReserved((byte) IsisConstants.PDULENGTHPOSITION);
- isisHeader.setMaximumAreaAddresses((byte) IsisConstants.MAXAREAADDRESS);
- L1L2HelloPdu l1L2HelloPdu = new L1L2HelloPdu(isisHeader);
- l1L2HelloPdu.setCircuitType((byte) isisInterface.reservedPacketCircuitType());
- l1L2HelloPdu.setSourceId(isisInterface.systemId());
- l1L2HelloPdu.setHoldingTime(isisInterface.holdingTime());
- l1L2HelloPdu.setPduLength(IsisConstants.PDU_LENGTH);
- l1L2HelloPdu.setPriority((byte) isisInterface.priority());
- l1L2HelloPdu.setLanId(lanId);
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
- tlvHeader.setTlvLength(0);
- AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
- areaAddressTlv.addAddress(isisInterface.areaAddress());
- l1L2HelloPdu.addTlv(areaAddressTlv);
- Set<MacAddress> neighbors = isisInterface.neighbors();
- if (!neighbors.isEmpty()) {
- List<MacAddress> neighborMacs = new ArrayList<>();
- for (MacAddress neighbor : neighbors) {
- IsisNeighbor isisNeighbor = isisInterface.lookup(neighbor);
- if (isisPduType == IsisPduType.L1HELLOPDU) {
- if (isisNeighbor.routerType() == IsisRouterType.L1 ||
- isisNeighbor.routerType() == IsisRouterType.L1L2) {
- neighborMacs.add(neighbor);
- }
- } else if (isisPduType == IsisPduType.L2HELLOPDU) {
- if (isisNeighbor.routerType() == IsisRouterType.L2 ||
- isisNeighbor.routerType() == IsisRouterType.L1L2) {
- neighborMacs.add(neighbor);
- }
- }
- }
-
- tlvHeader.setTlvType(TlvType.ISNEIGHBORS.value());
- tlvHeader.setTlvLength(0);
-
- IsisNeighborTlv isisNeighborTlv = new IsisNeighborTlv(tlvHeader);
- for (MacAddress neighbor : neighborMacs) {
- isisNeighborTlv.addNeighbor(neighbor);
- }
- l1L2HelloPdu.addTlv(isisNeighborTlv);
- }
-
- tlvHeader.setTlvType(TlvType.PROTOCOLSUPPORTED.value());
- tlvHeader.setTlvLength(0);
- ProtocolSupportedTlv protocolSupportedTlv = new ProtocolSupportedTlv(tlvHeader);
- protocolSupportedTlv.addProtocolSupported((byte) IsisConstants.PROTOCOLSUPPORTED);
- l1L2HelloPdu.addTlv(protocolSupportedTlv);
-
- tlvHeader.setTlvType(TlvType.IPINTERFACEADDRESS.value());
- tlvHeader.setTlvLength(0);
- IpInterfaceAddressTlv ipInterfaceAddressTlv = new IpInterfaceAddressTlv(tlvHeader);
- ipInterfaceAddressTlv.addInterfaceAddres(isisInterface.interfaceIpAddress());
- l1L2HelloPdu.addTlv(ipInterfaceAddressTlv);
-
- byte[] beforePadding = l1L2HelloPdu.asBytes();
- byte[] helloMessage;
- if (paddingEnabled) {
- byte[] paddingTlvs = getPaddingTlvs(beforePadding.length);
- helloMessage = Bytes.concat(beforePadding, paddingTlvs);
- } else {
- helloMessage = beforePadding;
- }
- return helloMessage;
- }
-
- /**
- * Converts a byte to integer variable.
- *
- * @param bytesToConvert bytes to convert
- * @return integer representation of bytes
- */
- public static int byteToInteger(byte[] bytesToConvert) {
- final StringBuilder builder = new StringBuilder();
- for (byte eachByte : bytesToConvert) {
- builder.append(String.format("%02x", eachByte));
- }
- int number = Integer.parseInt(builder.toString(), 16);
- return number;
- }
-
- /**
- * Converts a byte to long variable.
- *
- * @param bytesToConvert bytes to convert
- * @return long representation of bytes
- */
- public static long byteToLong(byte[] bytesToConvert) {
- final StringBuilder builder = new StringBuilder();
- for (byte eachByte : bytesToConvert) {
- builder.append(String.format("%02x", eachByte));
- }
- long number = Long.parseLong(builder.toString(), 16);
- return number;
- }
-
- /**
- * Converts a number to four bytes.
- *
- * @param numberToConvert number to convert
- * @return numInBytes given number as bytes
- */
- public static byte[] convertToFourBytes(long numberToConvert) {
- byte[] numInBytes = new byte[4];
- String s1 = Long.toHexString(numberToConvert);
- if (s1.length() % 2 != 0) {
- s1 = "0" + s1;
- }
- if (s1.length() == 16) {
- s1 = s1.substring(8, s1.length());
- }
- byte[] hexas = DatatypeConverter.parseHexBinary(s1);
- if (hexas.length == 1) {
- numInBytes[0] = 0;
- numInBytes[1] = 0;
- numInBytes[2] = 0;
- numInBytes[3] = hexas[0];
- } else if (hexas.length == 2) {
- numInBytes[0] = 0;
- numInBytes[1] = 0;
- numInBytes[2] = hexas[0];
- numInBytes[3] = hexas[1];
- } else if (hexas.length == 3) {
- numInBytes[0] = 0;
- numInBytes[1] = hexas[0];
- numInBytes[2] = hexas[1];
- numInBytes[3] = hexas[2];
- } else {
- numInBytes[0] = hexas[0];
- numInBytes[1] = hexas[1];
- numInBytes[2] = hexas[2];
- numInBytes[3] = hexas[3];
- }
- return numInBytes;
- }
-
- /**
- * Converts a number to eight bit binary.
- *
- * @param binaryString string to binary
- * @return numInBytes given number as bytes
- */
- public static String toEightBitBinary(String binaryString) {
- String eightBit = binaryString;
- if (eightBit.length() % 8 != 0) {
- int numOfZero = 8 - eightBit.length();
- while (numOfZero > 0) {
- eightBit = "0" + eightBit;
- numOfZero--;
- }
- }
- return eightBit;
- }
-
- /**
- * Converts a number to four bit binary.
- *
- * @param binaryString string to binary
- * @return numInBytes given number as bytes
- */
- public static String toFourBitBinary(String binaryString) {
- String fourBit = binaryString;
- if (fourBit.length() % 4 != 0) {
- int numOfZero = 4 - fourBit.length();
- while (numOfZero > 0) {
- fourBit = "0" + fourBit;
- numOfZero--;
- }
- }
- return fourBit;
- }
-
- /**
- * Converts a number to three bytes.
- *
- * @param numberToConvert number to convert
- * @return given number as bytes
- */
- public static byte[] convertToThreeBytes(int numberToConvert) {
- byte[] numInBytes = new byte[3];
- String s1 = Integer.toHexString(numberToConvert);
- if (s1.length() % 2 != 0) {
- s1 = "0" + s1;
- }
- byte[] hexas = DatatypeConverter.parseHexBinary(s1);
- if (hexas.length == 1) {
- numInBytes[0] = 0;
- numInBytes[1] = 0;
- numInBytes[2] = hexas[0];
- } else if (hexas.length == 2) {
- numInBytes[0] = 0;
- numInBytes[1] = hexas[0];
- numInBytes[2] = hexas[1];
- } else {
- numInBytes[0] = hexas[0];
- numInBytes[1] = hexas[1];
- numInBytes[2] = hexas[2];
- }
- return numInBytes;
- }
-
- /**
- * Converts the bytes of prefix to string type value.
- *
- * @param bytes array of prefix
- * @return string value of prefix
- */
- public static String prefixConversion(byte[] bytes) {
- String prefix = "";
- for (int i = 0; i < bytes.length; i++) {
- if (i < (bytes.length - 1)) {
- prefix = prefix + bytes[i] + ".";
- } else {
- prefix = prefix + bytes[i];
- }
- }
- return prefix;
- }
-
- /**
- * Converts the prefix to bytes.
- *
- * @param prefix prefix
- * @return prefix to bytes
- */
- public static byte[] prefixToBytes(String prefix) {
- List<Byte> byteList = new ArrayList<>();
- StringTokenizer tokenizer = new StringTokenizer(prefix, ".");
- while (tokenizer.hasMoreTokens()) {
- byteList.add((byte) Integer.parseInt(tokenizer.nextToken()));
- }
- return Bytes.toArray(byteList);
- }
-
- /**
- * Return the DIS value from the systemId.
- *
- * @param systemId system Id.
- * @return return true if DIS else false
- */
- public static boolean checkIsDis(String systemId) {
- StringTokenizer stringTokenizer = new StringTokenizer(systemId, "." + "-");
- int count = 0;
- while (stringTokenizer.hasMoreTokens()) {
- String str = stringTokenizer.nextToken();
- if (count == 3) {
- int x = Integer.parseInt(str);
- if (x > 0) {
- return true;
- }
- }
- count++;
- }
- return false;
- }
-
- /**
- * Return the systemId.
- *
- * @param systemId system Id.
- * @return return system ID
- */
- public static String removeTailingZeros(String systemId) {
- StringTokenizer stringTokenizer = new StringTokenizer(systemId, "-");
- return stringTokenizer.nextToken();
- }
-}
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/LspGenerator.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/LspGenerator.java
deleted file mode 100644
index 194bf08..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/LspGenerator.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.util;
-
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.MacAddress;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisNeighbor;
-import org.onosproject.isis.controller.IsisNetworkType;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.pdu.AttachedToOtherAreas;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-import org.onosproject.isis.io.isispacket.tlv.AreaAddressTlv;
-import org.onosproject.isis.io.isispacket.tlv.HostNameTlv;
-import org.onosproject.isis.io.isispacket.tlv.IpExtendedReachabilityTlv;
-import org.onosproject.isis.io.isispacket.tlv.IpInterfaceAddressTlv;
-import org.onosproject.isis.io.isispacket.tlv.IpInternalReachabilityTlv;
-import org.onosproject.isis.io.isispacket.tlv.IsReachabilityTlv;
-import org.onosproject.isis.io.isispacket.tlv.MetricOfInternalReachability;
-import org.onosproject.isis.io.isispacket.tlv.MetricsOfReachability;
-import org.onosproject.isis.io.isispacket.tlv.ProtocolSupportedTlv;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-import org.onosproject.isis.io.isispacket.tlv.TlvType;
-
-import java.util.List;
-
-/**
- * Representation of link state PDU generator.
- */
-public class LspGenerator {
-
- public LsPdu getLsp(IsisInterface isisInterface, String lspId, IsisPduType isisPduType,
- List<Ip4Address> allConfiguredInterfaceIps) {
- IsisHeader header = getHeader(isisPduType);
- LsPdu lsp = new LsPdu(header);
-
- lsp.setPduLength(0);
- lsp.setRemainingLifeTime(IsisConstants.LSPMAXAGE);
- lsp.setLspId(lspId);
- lsp.setSequenceNumber(isisInterface.isisLsdb().lsSequenceNumber(isisPduType));
- lsp.setCheckSum(0);
- if (isisPduType == IsisPduType.L1LSPDU) {
- lsp.setTypeBlock((byte) 1);
- lsp.setIntermediateSystemType((byte) 1);
- } else if (isisPduType == IsisPduType.L2LSPDU) {
- lsp.setTypeBlock((byte) 3);
- lsp.setIntermediateSystemType((byte) 3);
- }
- lsp.setAttachedToOtherAreas(AttachedToOtherAreas.NONE);
- lsp.setPartitionRepair(false);
- lsp.setLspDbol(false);
-
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
- tlvHeader.setTlvLength(0);
- AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
- areaAddressTlv.addAddress(isisInterface.areaAddress());
- lsp.addTlv(areaAddressTlv);
-
- tlvHeader.setTlvType(TlvType.PROTOCOLSUPPORTED.value());
- tlvHeader.setTlvLength(0);
- ProtocolSupportedTlv protocolSupportedTlv = new ProtocolSupportedTlv(tlvHeader);
- protocolSupportedTlv.addProtocolSupported((byte) IsisConstants.PROTOCOLSUPPORTED);
- lsp.addTlv(protocolSupportedTlv);
-
- tlvHeader.setTlvType(TlvType.IPINTERFACEADDRESS.value());
- tlvHeader.setTlvLength(0);
- IpInterfaceAddressTlv ipInterfaceAddressTlv = new IpInterfaceAddressTlv(tlvHeader);
- for (Ip4Address ipaddress : allConfiguredInterfaceIps) {
- ipInterfaceAddressTlv.addInterfaceAddres(ipaddress);
- }
- lsp.addTlv(ipInterfaceAddressTlv);
-
- tlvHeader.setTlvType(TlvType.HOSTNAME.value());
- tlvHeader.setTlvLength(0);
- HostNameTlv hostNameTlv = new HostNameTlv(tlvHeader);
- hostNameTlv.setHostName(isisInterface.intermediateSystemName());
- lsp.addTlv(hostNameTlv);
-
- tlvHeader.setTlvType(TlvType.ISREACHABILITY.value());
- tlvHeader.setTlvLength(0);
- IsReachabilityTlv isReachabilityTlv = new IsReachabilityTlv(tlvHeader);
- isReachabilityTlv.setReserved(0);
- MetricsOfReachability metricsOfReachability = new MetricsOfReachability();
- metricsOfReachability.setDefaultMetric((byte) 10);
- metricsOfReachability.setDefaultIsInternal(true);
- metricsOfReachability.setDelayMetric((byte) 10);
- metricsOfReachability.setDelayIsInternal(true);
- metricsOfReachability.setDelayMetricSupported(true);
- metricsOfReachability.setExpenseMetric((byte) 10);
- metricsOfReachability.setExpenseIsInternal(true);
- metricsOfReachability.setExpenseMetricSupported(true);
- metricsOfReachability.setErrorMetric((byte) 10);
- metricsOfReachability.setErrorIsInternal(true);
- metricsOfReachability.setErrorMetricSupported(true);
- if (isisInterface.networkType() == IsisNetworkType.BROADCAST) {
- if (isisPduType == IsisPduType.L1LSPDU) {
- metricsOfReachability.setNeighborId(isisInterface.l1LanId());
- } else if (isisPduType == IsisPduType.L2LSPDU) {
- metricsOfReachability.setNeighborId(isisInterface.l2LanId());
- }
- } else if (isisInterface.networkType() == IsisNetworkType.P2P) {
- MacAddress neighborMac = isisInterface.neighbors().iterator().next();
- IsisNeighbor neighbor = isisInterface.lookup(neighborMac);
- metricsOfReachability.setNeighborId(neighbor.neighborSystemId() + ".00");
- }
-
- isReachabilityTlv.addMeticsOfReachability(metricsOfReachability);
- lsp.addTlv(isReachabilityTlv);
-
- tlvHeader.setTlvType(TlvType.IPINTERNALREACHABILITY.value());
- tlvHeader.setTlvLength(0);
- IpInternalReachabilityTlv ipInterReacTlv = new IpInternalReachabilityTlv(tlvHeader);
- MetricOfInternalReachability metricOfIntRea = new MetricOfInternalReachability();
- metricOfIntRea.setDefaultMetric((byte) 10);
- metricOfIntRea.setDefaultIsInternal(true);
- metricOfIntRea.setDefaultDistributionDown(true);
- metricOfIntRea.setDelayMetric((byte) 0);
- metricOfIntRea.setDelayMetricSupported(false);
- metricOfIntRea.setDelayIsInternal(true);
- metricOfIntRea.setExpenseMetric((byte) 0);
- metricOfIntRea.setExpenseMetricSupported(false);
- metricOfIntRea.setExpenseIsInternal(true);
- metricOfIntRea.setErrorMetric((byte) 0);
- metricOfIntRea.setErrorMetricSupported(false);
- metricOfIntRea.setExpenseIsInternal(true);
- Ip4Address ip4Address = isisInterface.interfaceIpAddress();
- byte[] ipAddress = ip4Address.toOctets();
- // ipAddress[ipAddress.length - 1] = 0;
- byte[] networkmass = isisInterface.networkMask();
- // metric calculation part
- byte[] result = new byte[ipAddress.length];
- result[0] = (byte) (ipAddress[0] & networkmass[0]);
- result[1] = (byte) (ipAddress[1] & networkmass[1]);
- result[2] = (byte) (ipAddress[2] & networkmass[2]);
- result[3] = (byte) (ipAddress[3] & networkmass[3]);
- metricOfIntRea.setIpAddress(Ip4Address.valueOf(result));
- metricOfIntRea.setSubnetAddress(Ip4Address.valueOf(isisInterface.networkMask()));
- ipInterReacTlv.addInternalReachabilityMetric(metricOfIntRea);
- lsp.addTlv(ipInterReacTlv);
-
- tlvHeader.setTlvType(TlvType.IPEXTENDEDREACHABILITY.value());
- tlvHeader.setTlvLength(0);
- IpExtendedReachabilityTlv extendedTlv = new IpExtendedReachabilityTlv(tlvHeader);
- extendedTlv.setDown(false);
- extendedTlv.setMetric(10);
- extendedTlv.setPrefix("192.168.7");
- extendedTlv.setPrefixLength(24);
- extendedTlv.setSubTlvLength((byte) 0);
- extendedTlv.setSubTlvPresence(false);
- lsp.addTlv(extendedTlv);
-
- return lsp;
- }
-
- public IsisHeader getHeader(IsisPduType pduType) {
- IsisHeader isisHeader = new IsisHeader();
- isisHeader.setIrpDiscriminator((byte) IsisConstants.IRPDISCRIMINATOR);
- isisHeader.setPduHeaderLength((byte) IsisUtil.getPduHeaderLength(pduType.value()));
- isisHeader.setVersion((byte) IsisConstants.ISISVERSION);
- isisHeader.setIdLength((byte) IsisConstants.SYSTEMIDLENGTH);
- isisHeader.setIsisPduType(pduType.value());
- isisHeader.setVersion2((byte) IsisConstants.ISISVERSION);
- isisHeader.setReserved((byte) IsisConstants.RESERVED);
- isisHeader.setMaximumAreaAddresses((byte) IsisConstants.MAXAREAADDRESS);
- return isisHeader;
- }
-}
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/package-info.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/package-info.java
deleted file mode 100644
index 8a896fb..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ISIS protocol util.
- */
-package org.onosproject.isis.io.util;
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/package-info.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/package-info.java
deleted file mode 100644
index 2de3c81..0000000
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ISIS protocol.
- */
-package org.onosproject.isis;
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/IsisHeaderTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/IsisHeaderTest.java
deleted file mode 100644
index d9fbb4a..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/IsisHeaderTest.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.MacAddress;
-import org.onosproject.isis.controller.IsisPduType;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for IsisHeader.
- */
-public class IsisHeaderTest {
-
- private IsisHeader isisHeader;
- private MacAddress macAddress = MacAddress.valueOf("a4:23:05:00:00:00");
- private int result;
- private MacAddress result1;
- private byte result2;
- private IsisPduType result3;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- isisHeader = new IsisHeader();
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- isisHeader = null;
- }
-
- /**
- * Tests interfaceIndex() getter method.
- */
- @Test
- public void testInterfaceIndex() throws Exception {
- isisHeader.setInterfaceIndex(1);
- result = isisHeader.interfaceIndex();
- assertThat(result, is(1));
- }
-
- /**
- * Tests interfaceIndex() setter method.
- */
- @Test
- public void testSetInterfaceIndex() throws Exception {
- isisHeader.setInterfaceIndex(1);
- result = isisHeader.interfaceIndex();
- assertThat(result, is(1));
- }
-
- /**
- * Tests interfaceMac() getter method.
- */
- @Test
- public void testInterfaceMac() throws Exception {
- isisHeader.setInterfaceMac(macAddress);
- result1 = isisHeader.interfaceMac();
- assertThat(result1, is(macAddress));
- }
-
- /**
- * Tests sourceMac() getter method.
- */
- @Test
- public void testSourceMac() throws Exception {
- isisHeader.setSourceMac(macAddress);
- result1 = isisHeader.sourceMac();
- assertThat(result1, is(macAddress));
- }
-
- /**
- * Tests sourceMac() setter method.
- */
- @Test
- public void testSetSourceMac() throws Exception {
- isisHeader.setSourceMac(macAddress);
- result1 = isisHeader.sourceMac();
- assertThat(result1, is(macAddress));
- }
-
- /**
- * Tests interfaceMac() setter method.
- */
- @Test
- public void testSetInterfaceMac() throws Exception {
- isisHeader.setSourceMac(macAddress);
- result1 = isisHeader.sourceMac();
- assertThat(result1, is(macAddress));
- }
-
- /**
- * Tests version2() getter method.
- */
- @Test
- public void testVersion2() throws Exception {
- isisHeader.setVersion2((byte) 1);
- result2 = isisHeader.version2();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests version2() setter method.
- */
- @Test
- public void testSetVersion2() throws Exception {
- isisHeader.setVersion2((byte) 1);
- result2 = isisHeader.version2();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests maximumAreaAddresses() getter method.
- */
- @Test
- public void testMaximumAreaAddresses() throws Exception {
- isisHeader.setMaximumAreaAddresses((byte) 1);
- result2 = isisHeader.maximumAreaAddresses();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests maximumAreaAddresses() setter method.
- */
- @Test
- public void testSetMaximumAreaAddresses() throws Exception {
- isisHeader.setMaximumAreaAddresses((byte) 1);
- result2 = isisHeader.maximumAreaAddresses();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests reserved() getter method.
- */
- @Test
- public void testReserved() throws Exception {
- isisHeader.setReserved((byte) 1);
- result2 = isisHeader.reserved();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests reserved() setter method.
- */
- @Test
- public void testSetReserved() throws Exception {
- isisHeader.setReserved((byte) 1);
- result2 = isisHeader.reserved();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests version() getter method.
- */
- @Test
- public void testVersion() throws Exception {
- isisHeader.setVersion((byte) 1);
- result2 = isisHeader.version();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests version() setter method.
- */
- @Test
- public void testSetVersion() throws Exception {
- isisHeader.setVersion((byte) 1);
- result2 = isisHeader.version();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests idLength() getter method.
- */
- @Test
- public void testIdLength() throws Exception {
- isisHeader.setIdLength((byte) 1);
- result2 = isisHeader.idLength();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests idLength() setter method.
- */
- @Test
- public void testSetIdLength() throws Exception {
- isisHeader.setIdLength((byte) 1);
- result2 = isisHeader.idLength();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests pduType() getter method.
- */
- @Test
- public void testPduType() throws Exception {
- isisHeader.setIsisPduType(1);
- result = isisHeader.pduType();
- assertThat(result, is(1));
- }
-
- /**
- * Tests pduType() setter method.
- */
- @Test
- public void testSetIsisPduType() throws Exception {
- isisHeader.setIsisPduType(1);
- result = isisHeader.pduType();
- assertThat(result, is(1));
- }
-
- /**
- * Tests pduHeaderLength() getter method.
- */
- @Test
- public void testPduHeaderLength() throws Exception {
- isisHeader.setPduHeaderLength((byte) 1);
- result2 = isisHeader.pduHeaderLength();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests pduHeaderLength() setter method.
- */
- @Test
- public void testSetPduHeaderLength() throws Exception {
- isisHeader.setPduHeaderLength((byte) 1);
- result2 = isisHeader.pduHeaderLength();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests irpDiscriminator() getter method.
- */
- @Test
- public void testIrpDiscriminator() throws Exception {
- isisHeader.setIrpDiscriminator((byte) 1);
- result2 = isisHeader.irpDiscriminator();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests irpDiscriminator() setter method.
- */
- @Test
- public void testSetIrpDiscriminator() throws Exception {
- isisHeader.setIrpDiscriminator((byte) 1);
- result2 = isisHeader.irpDiscriminator();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests irpDiscriminator() setter method.
- */
- @Test
- public void testIsisPduType() throws Exception {
- isisHeader.setIsisPduType(IsisPduType.L1HELLOPDU.value());
- result3 = isisHeader.isisPduType();
- assertThat(result3, is(IsisPduType.L1HELLOPDU));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- isisHeader.readFrom(channelBuffer);
- assertThat(isisHeader, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- isisHeader.asBytes();
- assertThat(isisHeader, is(notNullValue()));
- }
-
- /**
- * Tests populateHeader() method.
- */
- @Test
- public void testPopulateHeader() throws Exception {
- isisHeader.populateHeader(new IsisHeader());
- assertThat(isisHeader, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/IsisMessageReaderTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/IsisMessageReaderTest.java
deleted file mode 100644
index 300fa1b..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/IsisMessageReaderTest.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket;
-
-import com.google.common.primitives.Bytes;
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.controller.IsisMessage;
-import org.onosproject.isis.io.isispacket.pdu.Csnp;
-import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-import org.onosproject.isis.io.isispacket.pdu.P2PHelloPdu;
-import org.onosproject.isis.io.isispacket.pdu.Psnp;
-import org.onosproject.isis.io.util.IsisUtil;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for IsisMessageReader.
- */
-public class IsisMessageReaderTest {
-
- private final byte[] helloP2P = {
- -125, 20, 1, 0, 17, 1, 0, 0,
- 2, 51, 51, 51, 51, 51, 51, 0, 100, 5, -39, -126, 1, 4, 3,
- 73, 0, 0, -127, 1, -52, -124, 4, -64, -88, 56, 102, 8, -1,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 8, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, -1, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, -1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 8, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 8, -81, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
- private final byte[] helloL1L2 = {
- -125, 27, 1, 0, 15, 1, 0, 0, 1, 34, 34, 34, 34, 34, 34, 0,
- 30, 5, -39, 64, 34, 34, 34, 34, 34, 34, 1, -127, 1, -52, 1,
- 4, 3, 73, 0, 10, -124, 4, 10, 0, 10, 2, -45, 3, 0, 0, 0,
- 8, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, -1, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8,
- -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 8, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 8, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, -93, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
- private final byte[] l1Lsp = {
- -125, 27, 1, 0, 18, 1, 0, 0, 0, 86, 4, -81, 34, 34, 34,
- 34, 34, 34, 0, 0, 0, 0, 0, 9, 99, 11, 1, 1, 4, 3, 73,
- 0, 10, -127, 1, -52, -119, 2, 82, 50, -124, 4, -64, -88, 10, 1, -128,
- 24, 10, -128, -128, -128, 10, 0, 10, 0, -1, -1, -1, -4, 10, -128, -128,
- -128, -64, -88, 10, 0, -1, -1, -1, 0, 2, 12, 0, 10, -128, -128, -128,
- 51, 51, 51, 51, 51, 51, 2
- };
- private final byte[] csnp = {
- -125, 33, 1, 6, 25, 1, 0, 3, 0, 67, 18, 52, 18, 52, 0,
- 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1,
- -1, -1, 9, 32, 4, -81, 18, 52, 18, 52, 0, 18, 0, 0, 0,
- 0, 0, 41, -92, -30, 4, -81, 41, 41, 41, 41, 41, 41, 0,
- 0, 0, 0, 0, 1, 91, 126
- };
- private final byte[] psnp = {
- -125, 17, 1, 0, 27, 1, 0, 0, 0, 35, 41, 41,
- 41, 41, 41, 41, 0, 9, 16, 4, -81, 18, 52, 18,
- 52, 0, 18, 0, 0, 0, 0, 0, 42, -94, -29
-
- };
- private IsisMessageReader reader;
- private ChannelBuffer channelBuffer;
- private IsisMessage message;
-
- @Before
- public void setUp() throws Exception {
- reader = new IsisMessageReader();
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- reader = null;
- channelBuffer = null;
- message = null;
- }
-
- /**
- * Tests readFromBuffer() method.
- */
- @Test
- public void testReadFromBuffer() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(helloP2P);
- message = reader.readFromBuffer(channelBuffer);
- assertThat(message, is(instanceOf(P2PHelloPdu.class)));
-
- channelBuffer = ChannelBuffers.copiedBuffer(helloL1L2);
- message = reader.readFromBuffer(channelBuffer);
- assertThat(message, is(instanceOf(L1L2HelloPdu.class)));
-
- byte[] tlv1 = Bytes.concat(l1Lsp, (IsisUtil.getPaddingTlvs(l1Lsp.length)));
- channelBuffer = ChannelBuffers.copiedBuffer(tlv1);
- message = reader.readFromBuffer(channelBuffer);
- assertThat(message, is(instanceOf(LsPdu.class)));
-
- tlv1 = Bytes.concat(csnp, (IsisUtil.getPaddingTlvs(csnp.length)));
- channelBuffer = ChannelBuffers.copiedBuffer(tlv1);
- message = reader.readFromBuffer(channelBuffer);
- assertThat(message, is(instanceOf(Csnp.class)));
-
- tlv1 = Bytes.concat(psnp, (IsisUtil.getPaddingTlvs(psnp.length)));
- channelBuffer = ChannelBuffers.copiedBuffer(tlv1);
- message = reader.readFromBuffer(channelBuffer);
- assertThat(message, is(instanceOf(Psnp.class)));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/CsnpTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/CsnpTest.java
deleted file mode 100644
index e96f13d..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/CsnpTest.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.pdu;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.tlv.AdjacencyStateTlv;
-import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for Csnp.
- */
-public class CsnpTest {
-
- private final String srcId = "1111.1111.1111";
- private final byte[] csnpBytes = {
- 0, 67, 18, 52, 18, 52, 0, 0, 67, 18, 52, 18, 52, 0,
- 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1,
- -1, -1, 9, 32, 4, -81, 18, 52, 18, 52, 0, 18, 0, 0, 0,
- 0, 0, 41, -92, -30, 4, -81, 41, 41, 41, 41, 41, 41, 0,
- 0, 0, 0, 0, 1, 91, 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0
- };
- private Csnp csnp;
- private IsisHeader isisHeader;
- private IsisTlv isisTlv;
- private TlvHeader tlvHeader;
- private List<IsisTlv> resultList;
- private String resultStr;
- private int resultInt;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- isisHeader = new IsisHeader();
- isisHeader.setIsisPduType(IsisPduType.L1CSNP.value());
- csnp = new Csnp(isisHeader);
- tlvHeader = new TlvHeader();
- isisTlv = new AdjacencyStateTlv(tlvHeader);
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- isisHeader = null;
- csnp = null;
- tlvHeader = null;
- isisTlv = null;
- }
-
- /**
- * Tests getAllTlv() method.
- */
- @Test
- public void testGetAllTlv() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(csnpBytes);
- csnp.readFrom(channelBuffer);
- resultList = csnp.getAllTlv();
- assertThat(resultList.size(), is(0));
- }
-
- /**
- * Tests sourceId() getter method.
- */
- @Test
- public void testSourceId() throws Exception {
- csnp.setSourceId(srcId);
- resultStr = csnp.sourceId();
- assertThat(resultStr, is(srcId));
- }
-
- /**
- * Tests sourceId() setter method.
- */
- @Test
- public void testSetSourceId() throws Exception {
- csnp.setSourceId(srcId);
- resultStr = csnp.sourceId();
- assertThat(resultStr, is(srcId));
- }
-
-
- /**
- * Tests startLspId() getter method.
- */
- @Test
- public void testStartLspId() throws Exception {
- csnp.setStartLspId(srcId);
- resultStr = csnp.startLspId();
- assertThat(resultStr, is(srcId));
- }
-
- /**
- * Tests startLspId() setter method.
- */
- @Test
- public void testSetStartLspId() throws Exception {
- csnp.setStartLspId(srcId);
- resultStr = csnp.startLspId();
- assertThat(resultStr, is(srcId));
- }
-
- /**
- * Tests endLspId() getter method.
- */
- @Test
- public void testEndLspId() throws Exception {
- csnp.setEndLspId(srcId);
- resultStr = csnp.endLspId();
- assertThat(resultStr, is(srcId));
- }
-
- /**
- * Tests endLspId() setter method.
- */
- @Test
- public void testSetEndLspId() throws Exception {
- csnp.setEndLspId(srcId);
- resultStr = csnp.endLspId();
- assertThat(resultStr, is(srcId));
- }
-
- /**
- * Tests pduLength() getter method.
- */
- @Test
- public void testPduLength() throws Exception {
- csnp.setPduLength(10);
- resultInt = csnp.pduLength();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests pduLength() setter method.
- */
- @Test
- public void testSetPduLength() throws Exception {
- csnp.setPduLength(10);
- resultInt = csnp.pduLength();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(csnpBytes);
- csnp.readFrom(channelBuffer);
- assertThat(csnp, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(csnpBytes);
- csnp.readFrom(channelBuffer);
- result = csnp.asBytes();
- assertThat(csnp, is(notNullValue()));
- }
-
- /**
- * Tests isisPduHeader() method.
- */
- @Test
- public void testIsisPduHeader() throws Exception {
- result = csnp.isisPduHeader();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests completeSequenceNumberPduBody() method.
- */
- @Test
- public void testCompleteSequenceNumberPduBody() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(csnpBytes);
- csnp.readFrom(channelBuffer);
- result = csnp.completeSequenceNumberPduBody();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat((csnp.toString()), is(notNullValue()));
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEquals() throws Exception {
- assertThat(csnp.equals(new Csnp(new IsisHeader())), is(true));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- int hashCode = csnp.hashCode();
- assertThat(hashCode, is(notNullValue()));
- }
-}
-
-
-
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/HelloPduTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/HelloPduTest.java
deleted file mode 100644
index 2952a92..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/HelloPduTest.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.pdu;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.MacAddress;
-import org.onosproject.isis.controller.IsisInterfaceState;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.tlv.AdjacencyStateTlv;
-import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for HelloPdu.
- */
-public class HelloPduTest {
-
- private final byte[] macAddr = new byte[]{
- (byte) 0xa4, (byte) 0x22, (byte) 0xc2, 0x00, 0x00, 0x00
- };
- private final String srcId = "1111.1111.1111";
- private final byte[] helloL1L2 = {
- 1, 34, 34, 34, 34, 34, 34, 0,
- 30, 5, -39, 64, 34, 34, 34, 34, 34, 34, 1, -127, 1, -52, 1,
- 4, 3, 73, 0, 10, -124, 4, 10, 0, 10, 2, -45, 3, 0, 0, 0,
- 8, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, -1, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8,
- -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 8, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 8, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, -93, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
-
- private HelloPdu helloPdu;
- private IsisHeader isisHeader;
- private IsisTlv isisTlv;
- private TlvHeader tlvHeader;
- private MacAddress macAddress;
- private List<IsisTlv> resultList;
- private List<String> resultListStr;
- private List<Ip4Address> resultListIPv4;
- private List<MacAddress> resultListMac;
- private IsisInterfaceState resultAdjState;
- private String resultStr;
- private int resultInt;
- private byte resultByte;
- private ChannelBuffer channelBuffer;
- private HelloPdu pdu;
-
- @Before
- public void setUp() throws Exception {
- isisHeader = new IsisHeader();
- helloPdu = new L1L2HelloPdu(isisHeader);
- tlvHeader = new TlvHeader();
- isisTlv = new AdjacencyStateTlv(tlvHeader);
- macAddress = new MacAddress(macAddr);
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- pdu = helloPdu;
- }
-
- @After
- public void tearDown() throws Exception {
- isisHeader = null;
- helloPdu = null;
- isisTlv = null;
- tlvHeader = null;
- macAddress = null;
- }
-
- /**
- * Tests addTlv() getter method.
- */
- @Test
- public void testAddTlv() throws Exception {
- helloPdu.addTlv(isisTlv);
- resultList = helloPdu.tlvs();
- assertThat(resultList.size(), is(1));
- }
-
- /**
- * Tests tlvs() method.
- */
- @Test
- public void testTlvs() throws Exception {
- helloPdu.addTlv(isisTlv);
- resultList = helloPdu.tlvs();
- assertThat(resultList.size(), is(1));
- }
-
- /**
- * Tests areaAddress() method.
- */
- @Test
- public void testAreaAddress() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(helloL1L2);
- helloPdu.readFrom(channelBuffer);
- resultListStr = helloPdu.areaAddress();
- assertThat(resultListStr.size(), is(1));
- }
-
- /**
- * Tests interfaceIpAddresse() method.
- */
- @Test
- public void testInterfaceIpAddresses() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(helloL1L2);
- helloPdu.readFrom(channelBuffer);
- resultListIPv4 = helloPdu.interfaceIpAddresses();
- assertThat(resultListIPv4.size(), is(1));
- }
-
- /**
- * Tests neighborList() method.
- */
- @Test
- public void testNeighborList() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(helloL1L2);
- helloPdu.readFrom(channelBuffer);
- resultListMac = helloPdu.neighborList();
- assertThat(resultListMac, is(nullValue()));
- }
-
- /**
- * Tests adjacencyState() method.
- */
- @Test
- public void testAdjacencyState() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(helloL1L2);
- helloPdu.readFrom(channelBuffer);
- resultAdjState = helloPdu.adjacencyState();
- assertThat(resultAdjState, is(nullValue()));
- }
-
- /**
- * Tests sourceId() getter method.
- */
- @Test
- public void testSourceId() throws Exception {
- helloPdu.setSourceId(srcId);
- resultStr = helloPdu.sourceId();
- assertThat(resultStr, is(srcId));
- }
-
- /**
- * Tests sourceId() setter method.
- */
- @Test
- public void testSetSourceId() throws Exception {
- helloPdu.setSourceId(srcId);
- resultStr = helloPdu.sourceId();
- assertThat(resultStr, is(srcId));
- }
-
- /**
- * Tests pduLength() getter method.
- */
- @Test
- public void testPduLength() throws Exception {
- helloPdu.setPduLength(10);
- resultInt = helloPdu.pduLength();
- assertThat(resultInt, is(10));
-
- }
-
- /**
- * Tests pduLength() setter method.
- */
- @Test
- public void testSetPduLength() throws Exception {
- helloPdu.setPduLength(10);
- resultInt = helloPdu.pduLength();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests holdingTime() getter method.
- */
- @Test
- public void testHoldingTime() throws Exception {
- helloPdu.setHoldingTime(10);
- resultInt = helloPdu.holdingTime();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests holdingTime() setter method.
- */
- @Test
- public void testSetHoldingTime() throws Exception {
- helloPdu.setHoldingTime(10);
- resultInt = helloPdu.holdingTime();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests circuitType() getter method.
- */
- @Test
- public void testCircuitType() throws Exception {
- helloPdu.setCircuitType((byte) 1);
- resultByte = helloPdu.circuitType();
- assertThat(resultByte, is((byte) 1));
- }
-
- /**
- * Tests circuitType() setter method.
- */
- @Test
- public void testSetCircuitType() throws Exception {
- helloPdu.setCircuitType((byte) 1);
- resultByte = helloPdu.circuitType();
- assertThat(resultByte, is((byte) 1));
- }
-
- /**
- * Tests toString() getter method.
- */
- @Test
- public void testToString() throws Exception {
- pdu = helloPdu;
- assertThat(pdu.toString(), is(notNullValue()));
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEquals() throws Exception {
- pdu = helloPdu;
- assertThat(pdu.equals(new L1L2HelloPdu(new IsisHeader())), is(true));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- pdu = helloPdu;
- resultInt = pdu.hashCode();
- assertThat(resultInt, is(notNullValue()));
- }
-}
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/L1L2HelloPduTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/L1L2HelloPduTest.java
deleted file mode 100644
index db87ba1..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/L1L2HelloPduTest.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.pdu;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for L1L2HelloPdu.
- */
-public class L1L2HelloPduTest {
- private final String lanId = "1111.1111.1111";
- private final byte[] helloL1L2 = {
- 1, 34, 34, 34, 34, 34, 34, 0,
- 30, 5, -39, 64, 34, 34, 34, 34, 34, 34, 1, -127, 1, -52, 1,
- 4, 3, 73, 0, 10, -124, 4, 10, 0, 10, 2, -45, 3, 0, 0, 0,
- 8, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, -1, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8,
- -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 8, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 8, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, -93, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
- private L1L2HelloPdu l1L2HelloPdu;
- private IsisHeader isisHeader;
- private String resultStr;
- private byte resultByte;
- private int resultInt;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- isisHeader = new IsisHeader();
- isisHeader.setIsisPduType(15);
- l1L2HelloPdu = new L1L2HelloPdu(isisHeader);
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- isisHeader = null;
- l1L2HelloPdu = null;
- }
-
- /**
- * Tests setLanId() getter method.
- */
- @Test
- public void testLanId() throws Exception {
- l1L2HelloPdu.setLanId(lanId);
- resultStr = l1L2HelloPdu.lanId();
- assertThat(resultStr, is(lanId));
- }
-
- /**
- * Tests setLanId() setter method.
- */
- @Test
- public void testSetLanId() throws Exception {
- l1L2HelloPdu.setLanId(lanId);
- resultStr = l1L2HelloPdu.lanId();
- assertThat(resultStr, is(lanId));
- }
-
- /**
- * Tests priority() getter method.
- */
- @Test
- public void testPriority() throws Exception {
- l1L2HelloPdu.setPriority((byte) 1);
- resultByte = l1L2HelloPdu.priority();
- assertThat(resultByte, is((byte) 1));
- }
-
- /**
- * Tests priority() setter method.
- */
- @Test
- public void testSetPriority() throws Exception {
- l1L2HelloPdu.setPriority((byte) 1);
- resultByte = l1L2HelloPdu.priority();
- assertThat(resultByte, is((byte) 1));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(helloL1L2);
- l1L2HelloPdu.readFrom(channelBuffer);
- assertThat(l1L2HelloPdu, is(notNullValue()));
- }
-
- /**
- * Tests asByte() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(helloL1L2);
- l1L2HelloPdu.readFrom(channelBuffer);
- result = l1L2HelloPdu.asBytes();
- assertThat(l1L2HelloPdu, is(notNullValue()));
- }
-
- /**
- * Tests l1l2IsisPduHeader() method.
- */
- @Test
- public void testL1l2IsisPduHeader() throws Exception {
- result = l1L2HelloPdu.l1l2IsisPduHeader();
- assertThat(l1L2HelloPdu, is(notNullValue()));
- }
-
- /**
- * Tests l1l2HelloPduBody() method.
- */
- @Test
- public void testL1l2HelloPduBody() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(helloL1L2);
- l1L2HelloPdu.readFrom(channelBuffer);
- result = l1L2HelloPdu.l1l2HelloPduBody();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(l1L2HelloPdu.toString(), is(notNullValue()));
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEquals() throws Exception {
- assertThat(l1L2HelloPdu.equals(new L1L2HelloPdu(new IsisHeader())), is(true));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- resultInt = l1L2HelloPdu.hashCode();
- assertThat(resultInt, is(notNullValue()));
- }
-}
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/LsPduTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/LsPduTest.java
deleted file mode 100644
index 5a19f2c..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/LsPduTest.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.isis.io.isispacket.pdu;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.tlv.HostNameTlv;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for LsPdu.
- */
-public class LsPduTest {
- private final String lspId = "1111.1111.1111";
- private final byte[] l1Lsp = {
- 0, 86, 4, -81, 34, 34, 34, 34, 34, 34, 0, 0, 0, 0, 0, 9, 99, 11, 1, 1, 4, 3, 73,
- 0, 10, -127, 1, -52, -119, 2, 82, 50, -124, 4, -64, -88, 10, 1, -128, 24, 10,
- -128, -128, -128, 10, 0, 10, 0, -1, -1, -1, -4, 10, -128, -128, -128, -64, -88,
- 10, 0, -1, -1, -1, 0, 2, 12, 0, 10, -128, -128, -128, 51, 51, 51, 51, 51, 51, 2
- };
- private LsPdu lsPdu;
- private IsisHeader isisHeader;
- private TlvHeader tlvHeader;
- private int resultInt;
- private boolean resultBool;
- private byte resultByte;
- private AttachedToOtherAreas resultObj;
- private String resultStr;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- isisHeader = new IsisHeader();
- tlvHeader = new TlvHeader();
- isisHeader.setIsisPduType(IsisPduType.L1LSPDU.value());
- lsPdu = new LsPdu(isisHeader);
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- isisHeader = null;
- lsPdu = null;
- tlvHeader = null;
- channelBuffer = null;
- }
-
- /**
- * Tests addTlv() method.
- */
- @Test
- public void testAddTlv() throws Exception {
- lsPdu.addTlv(new HostNameTlv(tlvHeader));
- assertThat(lsPdu, is(notNullValue()));
- }
-
- /**
- * Tests remainingLifeTime() getter method.
- */
- @Test
- public void testRemainingLifeTime() throws Exception {
- lsPdu.setRemainingLifeTime(10);
- resultInt = lsPdu.remainingLifeTime();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests remainingLifeTime() setter method.
- */
- @Test
- public void testSetRemainingLifeTime() throws Exception {
- lsPdu.setRemainingLifeTime(10);
- resultInt = lsPdu.remainingLifeTime();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests lspDbol() getter method.
- */
- @Test
- public void testLspDbol() throws Exception {
- lsPdu.setLspDbol(true);
- resultBool = lsPdu.lspDbol();
- assertThat(resultBool, is(true));
- }
-
- /**
- * Tests lspDbol() setter method.
- */
- @Test
- public void testSetLspDbol() throws Exception {
- lsPdu.setLspDbol(true);
- resultBool = lsPdu.lspDbol();
- assertThat(resultBool, is(true));
- }
-
- /**
- * Tests typeBlock() getter method.
- */
- @Test
- public void testTypeBlock() throws Exception {
- lsPdu.setTypeBlock((byte) 1);
- resultByte = lsPdu.typeBlock();
- assertThat(resultByte, is((byte) 1));
- }
-
- /**
- * Tests typeBlock() setter method.
- */
- @Test
- public void testSetTypeBlock() throws Exception {
- lsPdu.setTypeBlock((byte) 1);
- resultByte = lsPdu.typeBlock();
- assertThat(resultByte, is((byte) 1));
- }
-
- /**
- * Tests sequenceNumber() getter method.
- */
- @Test
- public void testSequenceNumber() throws Exception {
- lsPdu.setSequenceNumber(1);
- resultInt = lsPdu.sequenceNumber();
- assertThat(resultInt, is(1));
- }
-
- /**
- * Tests sequenceNumber() setter method.
- */
- @Test
- public void testSetSequenceNumber() throws Exception {
- lsPdu.setSequenceNumber(1);
- resultInt = lsPdu.sequenceNumber();
- assertThat(resultInt, is(1));
- }
-
- /**
- * Tests checkSum() getter method.
- */
- @Test
- public void testCheckSum() throws Exception {
- lsPdu.setCheckSum(1);
- resultInt = lsPdu.checkSum();
- assertThat(resultInt, is(1));
- }
-
- /**
- * Tests checkSum() setter method.
- */
- @Test
- public void testSetCheckSum() throws Exception {
- lsPdu.setCheckSum(1);
- resultInt = lsPdu.checkSum();
- assertThat(resultInt, is(1));
- }
-
- /**
- * Tests partitionRepair() getter method.
- */
- @Test
- public void testPartitionRepair() throws Exception {
- lsPdu.setPartitionRepair(true);
- resultBool = lsPdu.partitionRepair();
- assertThat(resultBool, is(true));
- }
-
- /**
- * Tests partitionRepair() setter method.
- */
- @Test
- public void testSetPartitionRepair() throws Exception {
- lsPdu.setPartitionRepair(true);
- resultBool = lsPdu.partitionRepair();
- assertThat(resultBool, is(true));
- }
-
- /**
- * Tests attachedToOtherAreas() getter method.
- */
- @Test
- public void testAttachedToOtherAreas() throws Exception {
- lsPdu.setAttachedToOtherAreas(AttachedToOtherAreas.DEFAULTMETRIC);
- resultObj = lsPdu.attachedToOtherAreas();
- assertThat(resultObj, is(AttachedToOtherAreas.DEFAULTMETRIC));
- }
-
- /**
- * Tests attachedToOtherAreas() setter method.
- */
- @Test
- public void testSetAttachedToOtherAreas() throws Exception {
- lsPdu.setAttachedToOtherAreas(AttachedToOtherAreas.DEFAULTMETRIC);
- resultObj = lsPdu.attachedToOtherAreas();
- assertThat(resultObj, is(AttachedToOtherAreas.DEFAULTMETRIC));
- }
-
- /**
- * Tests intermediateSystemType() getter method.
- */
- @Test
- public void testIntermediateSystemType() throws Exception {
- lsPdu.setIntermediateSystemType((byte) 1);
- resultByte = lsPdu.intermediateSystemType();
- assertThat(resultByte, is((byte) 1));
- }
-
- /**
- * Tests intermediateSystemType() setter method.
- */
- @Test
- public void testSetIntermediateSystemType() throws Exception {
- lsPdu.setIntermediateSystemType((byte) 1);
- resultByte = lsPdu.intermediateSystemType();
- assertThat(resultByte, is((byte) 1));
- }
-
- /**
- * Tests lspId() getter method.
- */
- @Test
- public void testLspId() throws Exception {
- lsPdu.setLspId(lspId);
- resultStr = lsPdu.lspId();
- assertThat(resultStr, is(lspId));
- }
-
- /**
- * Tests lspId() setter method.
- */
- @Test
- public void testSetLspId() throws Exception {
- lsPdu.setLspId(lspId);
- resultStr = lsPdu.lspId();
- assertThat(resultStr, is(lspId));
- }
-
- /**
- * Tests pduLength() getter method.
- */
- @Test
- public void testPduLength() throws Exception {
- lsPdu.setPduLength(10);
- resultInt = lsPdu.pduLength();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests pduLength() setter method.
- */
- @Test
- public void testSetPduLength() throws Exception {
- lsPdu.setPduLength(10);
- resultInt = lsPdu.pduLength();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(l1Lsp);
- lsPdu.readFrom(channelBuffer);
- assertThat(lsPdu, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(l1Lsp);
- lsPdu.readFrom(channelBuffer);
- result = lsPdu.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests l1l2IsisPduHeader() method.
- */
- @Test
- public void testL1l2IsisPduHeader() throws Exception {
- result = lsPdu.l1l2IsisPduHeader();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests l1l2LsPduBody() method.
- */
- @Test
- public void testL1l2LsPduBody() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(l1Lsp);
- lsPdu.readFrom(channelBuffer);
- result = lsPdu.l1l2LsPduBody();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(lsPdu.toString(), is(notNullValue()));
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEquals() throws Exception {
- assertThat(lsPdu.equals(new LsPdu(new IsisHeader())), is(true));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- resultInt = lsPdu.hashCode();
- assertThat(resultInt, is(notNullValue()));
- }
-}
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/P2PHelloPduTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/P2PHelloPduTest.java
deleted file mode 100644
index 17dfd54..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/P2PHelloPduTest.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.isis.io.isispacket.pdu;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for P2PHelloPdu.
- */
-public class P2PHelloPduTest {
- private final byte[] p2p = {
- 2, 51, 51, 51, 51, 51, 51, 0, 100, 5, -39, -126, 1, 4, 3,
- 73, 0, 0, -127, 1, -52, -124, 4, -64, -88, 56, 102, 8, -1,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 8, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, -1, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, -1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 8, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 8, -81, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
- private P2PHelloPdu p2PHelloPdu;
- private IsisHeader isisHeader;
- private byte resultByte;
- private ChannelBuffer channelBuffer;
- private byte[] result;
- private int resultInt;
-
- @Before
- public void setUp() throws Exception {
- isisHeader = new IsisHeader();
- isisHeader.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
- p2PHelloPdu = new P2PHelloPdu(isisHeader);
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
-
-
- }
-
- @After
- public void tearDown() throws Exception {
- isisHeader = null;
- p2PHelloPdu = null;
- channelBuffer = null;
- }
-
- /**
- * Tests localCircuitId() getter method.
- */
- @Test
- public void testLocalCircuitId() throws Exception {
- p2PHelloPdu.setLocalCircuitId((byte) 1);
- resultByte = p2PHelloPdu.localCircuitId();
- assertThat(resultByte, is((byte) 1));
- }
-
- /**
- * Tests localCircuitId() setter method.
- */
- @Test
- public void testSetLocalCircuitId() throws Exception {
- p2PHelloPdu.setLocalCircuitId((byte) 1);
- resultByte = p2PHelloPdu.localCircuitId();
- assertThat(resultByte, is((byte) 1));
- }
-
- /**
- * Tests setVariableLengths() method.
- */
- @Test
- public void testSetVariableLengths() throws Exception {
-
-
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(p2p);
- p2PHelloPdu.readFrom(channelBuffer);
- assertThat(p2PHelloPdu, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(p2p);
- p2PHelloPdu.readFrom(channelBuffer);
- result = p2PHelloPdu.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests p2PHeader() method.
- */
- @Test
- public void testP2PHeader() throws Exception {
- result = p2PHelloPdu.p2PHeader();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests p2P2HelloPduBody() method.
- */
- @Test
- public void testP2P2HelloPduBody() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(p2p);
- p2PHelloPdu.readFrom(channelBuffer);
- result = p2PHelloPdu.p2P2HelloPduBody();
- assertThat(result, is(notNullValue()));
-
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(p2PHelloPdu.toString(), is(notNullValue()));
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEquals() throws Exception {
- assertThat(p2PHelloPdu.equals(new P2PHelloPdu(new IsisHeader())), is(true));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- resultInt = p2PHelloPdu.hashCode();
- assertThat(resultInt, is(notNullValue()));
- }
-}
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/PsnpTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/PsnpTest.java
deleted file mode 100644
index 7d71fd8..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/pdu/PsnpTest.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.pdu;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-import org.onosproject.isis.io.isispacket.tlv.AdjacencyStateTlv;
-import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for Psnp.
- */
-public class PsnpTest {
- private final String srcId = "1111.1111.1111";
- private final byte[] psnpPkt = {
- 0, 35, 41, 41, 41, 41, 41, 41, 0, 9, 16, 4, -81, 18, 52, 18,
- 52, 0, 18, 0, 0, 0, 0, 0, 42, -94, -29
- };
- private Psnp psnp;
- private IsisHeader isisHeader;
- private ChannelBuffer channelBuffer;
- private IsisTlv isisTlv;
- private TlvHeader tlvHeader;
- private List<IsisTlv> resultList;
- private String resultStr;
- private int resultInt;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- isisHeader = new IsisHeader();
- isisHeader.setIsisPduType(IsisPduType.L1PSNP.value());
- psnp = new Psnp(isisHeader);
- tlvHeader = new TlvHeader();
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- isisTlv = new AdjacencyStateTlv(tlvHeader);
-
- }
-
- @After
- public void tearDown() throws Exception {
- isisHeader = null;
- psnp = null;
- channelBuffer = null;
- tlvHeader = null;
- isisTlv = null;
- tlvHeader = null;
- }
-
- /**
- * Tests addTlv() method.
- */
- @Test
- public void testAddTlv() throws Exception {
- psnp.addTlv(isisTlv);
- resultList = psnp.getAllTlv();
- assertThat(resultList.size(), is(1));
-
- }
-
- /**
- * Tests getAllTlv() method.
- */
- @Test
- public void testGetAllTlv() throws Exception {
- psnp.addTlv(isisTlv);
- resultList = psnp.getAllTlv();
- assertThat(resultList.size(), is(1));
-
- }
-
- /**
- * Tests sourceId() getter method.
- */
- @Test
- public void testSourceId() throws Exception {
- psnp.setSourceId(srcId);
- resultStr = psnp.sourceId();
- assertThat(resultStr, is(srcId));
- }
-
- /**
- * Tests sourceId() setter method.
- */
- @Test
- public void testSetSourceId() throws Exception {
- psnp.setSourceId(srcId);
- resultStr = psnp.sourceId();
- assertThat(resultStr, is(srcId));
- }
-
- /**
- * Tests pduLength() getter method.
- */
- @Test
- public void testPduLength() throws Exception {
- psnp.setPduLength(10);
- resultInt = psnp.pduLength();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests pduLength() setter method.
- */
- @Test
- public void testSetPduLength() throws Exception {
- psnp.setPduLength(10);
- resultInt = psnp.pduLength();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(psnpPkt);
- psnp.readFrom(channelBuffer);
- assertThat(psnp, is(notNullValue()));
- }
-
- /**
- * Tests lasBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(psnpPkt);
- psnp.readFrom(channelBuffer);
- result = psnp.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests isisPduHeader() method.
- */
- @Test
- public void testIsisPduHeader() throws Exception {
- result = psnp.isisPduHeader();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests partialSequenceNumberPduBody() method.
- */
- @Test
- public void testPartialSequenceNumberPduBody() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(psnpPkt);
- psnp.readFrom(channelBuffer);
- result = psnp.partialSequenceNumberPduBody();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat((psnp.toString()), is(notNullValue()));
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEquals() throws Exception {
- assertThat(psnp.equals(new Psnp(new IsisHeader())), is(true));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- int hashCode = psnp.hashCode();
- assertThat(hashCode, is(notNullValue()));
- }
-}
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/AdjacencyStateTlvTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/AdjacencyStateTlvTest.java
deleted file mode 100644
index 5152975..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/AdjacencyStateTlvTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for AdjacencyStateTlv.
- */
-public class AdjacencyStateTlvTest {
-
- private final String neighborSystemId = "2929.2929.2929";
- private final byte[] tlv = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- private AdjacencyStateTlv adjacencyStateTlv;
- private TlvHeader tlvHeader;
- private int result;
- private byte result2;
- private String result1;
- private ChannelBuffer channelBuffer;
- private byte[] result3;
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader);
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- tlvHeader = null;
- adjacencyStateTlv = null;
- channelBuffer = null;
- }
-
- /**
- * Tests localCircuitId() getter method.
- */
- @Test
- public void testLocalCircuitId() throws Exception {
- adjacencyStateTlv.setLocalCircuitId(1);
- result = adjacencyStateTlv.localCircuitId();
- assertThat(result, is(1));
- }
-
- /**
- * Tests localCircuitId() setter method.
- */
- @Test
- public void testSetLocalCircuitId() throws Exception {
- adjacencyStateTlv.setLocalCircuitId(1);
- result = adjacencyStateTlv.localCircuitId();
- assertThat(result, is(1));
- }
-
- /**
- * Tests neighborSystemId() getter method.
- */
- @Test
- public void testNeighborSystemId() throws Exception {
- adjacencyStateTlv.setNeighborSystemId(neighborSystemId);
- result1 = adjacencyStateTlv.neighborSystemId();
- assertThat(result1, is(neighborSystemId));
- }
-
- /**
- * Tests neighborSystemId() setter method.
- */
- @Test
- public void testSetNeighborSystemId() throws Exception {
- adjacencyStateTlv.setNeighborSystemId(neighborSystemId);
- result1 = adjacencyStateTlv.neighborSystemId();
- assertThat(result1, is(neighborSystemId));
- }
-
- /**
- * Tests neighborLocalCircuitId() getter method.
- */
- @Test
- public void testNeighborLocalCircuitId() throws Exception {
- adjacencyStateTlv.setNeighborLocalCircuitId(1);
- result = adjacencyStateTlv.neighborLocalCircuitId();
- assertThat(result, is(1));
- }
-
- /**
- * Tests neighborLocalCircuitId() setter method.
- */
- @Test
- public void testSetNeighborLocalCircuitId() throws Exception {
- adjacencyStateTlv.setNeighborLocalCircuitId(1);
- result = adjacencyStateTlv.neighborLocalCircuitId();
- assertThat(result, is(1));
- }
-
- /**
- * Tests adjacencyType() getter method.
- */
- @Test
- public void testAdjacencyType() throws Exception {
- adjacencyStateTlv.setAdjacencyType((byte) 1);
- result2 = adjacencyStateTlv.adjacencyType();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests adjacencyType() setter method.
- */
- @Test
- public void testSetAdjacencyType() throws Exception {
- adjacencyStateTlv.setAdjacencyType((byte) 1);
- result2 = adjacencyStateTlv.adjacencyType();
- assertThat(result2, is((byte) 1));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- adjacencyStateTlv.readFrom(channelBuffer);
- assertThat(adjacencyStateTlv.adjacencyType(), is((byte) 0));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- adjacencyStateTlv.readFrom(channelBuffer);
- result3 = adjacencyStateTlv.asBytes();
- assertThat(result3, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(adjacencyStateTlv.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/AreaAddressTlvTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/AreaAddressTlvTest.java
deleted file mode 100644
index c33f5e4..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/AreaAddressTlvTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for AreaAddressTlv.
- */
-public class AreaAddressTlvTest {
-
- private final String areaAddress = "490001";
- private final byte[] tlv = {1, 49};
- private AreaAddressTlv areaAddressTlv;
- private TlvHeader tlvHeader;
- private List<String> result;
- private ChannelBuffer channelBuffer;
- private byte[] result1;
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- areaAddressTlv = new AreaAddressTlv(tlvHeader);
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- tlvHeader = null;
- areaAddressTlv = null;
- }
-
- /**
- * Tests addAddress() method.
- */
- @Test
- public void testAddAddress() throws Exception {
- areaAddressTlv.addAddress(areaAddress);
- result = areaAddressTlv.areaAddress();
- assertThat(result.size(), is(1));
- }
-
- /**
- * Tests areaAddress() setter method.
- */
- @Test
- public void testSetAreaAddress() throws Exception {
- areaAddressTlv.addAddress(areaAddress);
- result = areaAddressTlv.areaAddress();
- assertThat(result.size(), is(1));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- areaAddressTlv.readFrom(channelBuffer);
- assertThat(areaAddressTlv.areaAddress().size(), is(1));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- areaAddressTlv.readFrom(channelBuffer);
- result1 = areaAddressTlv.asBytes();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(areaAddressTlv.toString(), is(notNullValue()));
- }
-}
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/HostNameTlvTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/HostNameTlvTest.java
deleted file mode 100644
index 7a9d8cd..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/HostNameTlvTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for HostNameTlv.
- */
-public class HostNameTlvTest {
- private final String hostName = "TEST";
- private final byte[] tlv = hostName.getBytes();
- private HostNameTlv hostNameTlv;
- private TlvHeader tlvHeader;
- private String result;
- private ChannelBuffer channelBuffer;
- private byte[] result1;
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvLength(tlv.length);
- hostNameTlv = new HostNameTlv(tlvHeader);
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- tlvHeader = null;
- hostNameTlv = null;
- }
-
- /**
- * Tests hostName() getter method.
- */
- @Test
- public void testHostName() throws Exception {
- hostNameTlv.setHostName(hostName);
- result = hostNameTlv.hostName();
- assertThat(result, is(hostName));
- }
-
- /**
- * Tests hostName() setter method.
- */
- @Test
- public void testSetHostName() throws Exception {
- hostNameTlv.setHostName(hostName);
- result = hostNameTlv.hostName();
- assertThat(result, is(hostName));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- hostNameTlv.readFrom(channelBuffer);
- assertThat(hostNameTlv.hostName(), is(hostName));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- hostNameTlv.readFrom(channelBuffer);
- result1 = hostNameTlv.asBytes();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(hostNameTlv.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IpExtendedReachabilityTlvTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IpExtendedReachabilityTlvTest.java
deleted file mode 100644
index da1664b..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IpExtendedReachabilityTlvTest.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.AdministrativeGroup;
-import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for IP ExtendedReachabilityTlv.
- */
-public class IpExtendedReachabilityTlvTest {
- private final String prefix = "00";
- private final byte[] tlv = {0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0};
- private final byte[] tlv1 = {0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0};
- private final byte[] tlv2 = {0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0};
- private final byte[] tlv3 = {0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0};
- private TlvHeader tlvHeader;
- private IpExtendedReachabilityTlv ipExtendedReachabilityTlv;
- private String result;
- private boolean result1;
- private int result2;
- private TrafficEngineeringSubTlv trafficEngineeringSubTlv;
- private byte result4;
- private ChannelBuffer channelBuffer;
- private byte[] result3;
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- ipExtendedReachabilityTlv = new IpExtendedReachabilityTlv(tlvHeader);
- trafficEngineeringSubTlv = new AdministrativeGroup(tlvHeader);
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- tlvHeader = null;
- ipExtendedReachabilityTlv = null;
-
- }
-
- /**
- * Tests prefix() getter method.
- */
- @Test
- public void testPrefix() throws Exception {
- ipExtendedReachabilityTlv.setPrefix(prefix);
- result = ipExtendedReachabilityTlv.prefix();
- assertThat(result, is("00"));
- }
-
- /**
- * Tests prefix() setter method.
- */
- @Test
- public void testSetPrefix() throws Exception {
- ipExtendedReachabilityTlv.setPrefix(prefix);
- result = ipExtendedReachabilityTlv.prefix();
- assertThat(result, is("00"));
- }
-
- /**
- * Tests isDown() getter method.
- */
-
- @Test
- public void testIsDown() throws Exception {
- ipExtendedReachabilityTlv.setDown(true);
- result1 = ipExtendedReachabilityTlv.isDown();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isDown() setter method.
- */
- @Test
- public void testSetDown() throws Exception {
- ipExtendedReachabilityTlv.setDown(true);
- result1 = ipExtendedReachabilityTlv.isDown();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isSubTlvPresence() getter method.
- */
- @Test
- public void testIsSubTlvPresence() throws Exception {
- ipExtendedReachabilityTlv.setSubTlvPresence(true);
- result1 = ipExtendedReachabilityTlv.isSubTlvPresence();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isSubTlvPresence() setter method.
- */
- @Test
- public void testSetSubTlvPresence() throws Exception {
- ipExtendedReachabilityTlv.setSubTlvPresence(true);
- result1 = ipExtendedReachabilityTlv.isSubTlvPresence();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests prefixLength() getter method.
- */
- @Test
- public void testPrefixLength() throws Exception {
- ipExtendedReachabilityTlv.setPrefixLength(10);
- result2 = ipExtendedReachabilityTlv.prefixLength();
- assertThat(result2, is(10));
-
- }
-
- /**
- * Tests prefixLength() setter method.
- */
- @Test
- public void testSetPrefixLength() throws Exception {
- ipExtendedReachabilityTlv.setPrefixLength(10);
- result2 = ipExtendedReachabilityTlv.prefixLength();
- assertThat(result2, is(10));
- }
-
- /**
- * Tests addNeighbor() method.
- */
- @Test
- public void testAddSubTlv() throws Exception {
- ipExtendedReachabilityTlv.addSubTlv(trafficEngineeringSubTlv);
- assertThat(ipExtendedReachabilityTlv, is(notNullValue()));
-
- }
-
- /**
- * Tests subTlvLength() getter method.
- */
- @Test
- public void testSubTlvLength() throws Exception {
- ipExtendedReachabilityTlv.setSubTlvLength((byte) 10);
- result4 = ipExtendedReachabilityTlv.subTlvLength();
- assertThat(result4, is((byte) 10));
- }
-
- /**
- * Tests subTlvLength() setter method.
- */
- @Test
- public void testSetSubTlvLength() throws Exception {
- ipExtendedReachabilityTlv.setSubTlvLength((byte) 10);
- result4 = ipExtendedReachabilityTlv.subTlvLength();
- assertThat(result4, is((byte) 10));
- }
-
- /**
- * Tests metric() getter method.
- */
- @Test
- public void testMetric() throws Exception {
- ipExtendedReachabilityTlv.setMetric(10);
- result2 = ipExtendedReachabilityTlv.metric();
- assertThat(result2, is(10));
- }
-
- /**
- * Tests metric() setter method.
- */
- @Test
- public void testSetMetric() throws Exception {
- ipExtendedReachabilityTlv.setMetric(10);
- result2 = ipExtendedReachabilityTlv.metric();
- assertThat(result2, is(10));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- ipExtendedReachabilityTlv.readFrom(channelBuffer);
- assertThat(ipExtendedReachabilityTlv.metric(), is(0));
- channelBuffer = ChannelBuffers.copiedBuffer(tlv1);
- ipExtendedReachabilityTlv.readFrom(channelBuffer);
- assertThat(ipExtendedReachabilityTlv.metric(), is(0));
- channelBuffer = ChannelBuffers.copiedBuffer(tlv2);
- ipExtendedReachabilityTlv.readFrom(channelBuffer);
- assertThat(ipExtendedReachabilityTlv.metric(), is(0));
- channelBuffer = ChannelBuffers.copiedBuffer(tlv3);
- ipExtendedReachabilityTlv.readFrom(channelBuffer);
- assertThat(ipExtendedReachabilityTlv.metric(), is(0));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- ipExtendedReachabilityTlv.readFrom(channelBuffer);
- ipExtendedReachabilityTlv.setPrefix(prefix);
- result3 = ipExtendedReachabilityTlv.asBytes();
- assertThat(result3, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(ipExtendedReachabilityTlv.toString(), is(notNullValue()));
- }
-
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IpInterfaceAddressTlvTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IpInterfaceAddressTlvTest.java
deleted file mode 100644
index 1dd0fe8..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IpInterfaceAddressTlvTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for IP InterfaceAddressTlv.
- */
-public class IpInterfaceAddressTlvTest {
- private final Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10");
- private final byte[] tlv = {0, 0, 0, 0};
- private TlvHeader tlvHeader;
- private IpInterfaceAddressTlv ipInterfaceAddressTlv;
- private List<Ip4Address> resultList;
- private byte[] result;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- ipInterfaceAddressTlv = new IpInterfaceAddressTlv(tlvHeader);
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- tlvHeader = null;
- ipInterfaceAddressTlv = null;
- }
-
- /**
- * Tests addInterfaceAddress() method.
- */
- @Test
- public void testAddInterfaceAddres() throws Exception {
- ipInterfaceAddressTlv.addInterfaceAddres(ip4Address);
- resultList = ipInterfaceAddressTlv.interfaceAddress();
- assertThat(resultList.size(), is(1));
-
- }
-
- /**
- * Tests interfaceAddress() getter method.
- */
- @Test
- public void testInterfaceAddress() throws Exception {
- ipInterfaceAddressTlv.addInterfaceAddres(ip4Address);
- resultList = ipInterfaceAddressTlv.interfaceAddress();
- assertThat(resultList.size(), is(1));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- ipInterfaceAddressTlv.readFrom(channelBuffer);
- assertThat(ipInterfaceAddressTlv.interfaceAddress().size(), is(1));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- ipInterfaceAddressTlv.readFrom(channelBuffer);
- result = ipInterfaceAddressTlv.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(ipInterfaceAddressTlv.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IpInternalReachabilityTlvTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IpInternalReachabilityTlvTest.java
deleted file mode 100644
index 30130c6..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IpInternalReachabilityTlvTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for IP InternalReachabilityTlv.
- */
-public class IpInternalReachabilityTlvTest {
- private final byte[] tlv = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- private TlvHeader tlvHeader;
- private IpInternalReachabilityTlv ipInternalReachabilityTlv;
- private MetricOfInternalReachability metricOfInternalReachability;
- private byte[] result;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- ipInternalReachabilityTlv = new IpInternalReachabilityTlv(tlvHeader);
- metricOfInternalReachability = new MetricOfInternalReachability();
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- tlvHeader = null;
- ipInternalReachabilityTlv = null;
- }
-
- /**
- * Tests addInternalReachabilityMetric() method.
- */
- @Test
- public void testAddInternalReachabilityMetric() throws Exception {
- ipInternalReachabilityTlv.addInternalReachabilityMetric(metricOfInternalReachability);
- assertThat(ipInternalReachabilityTlv, is(notNullValue()));
-
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- ipInternalReachabilityTlv.readFrom(channelBuffer);
- assertThat(ipInternalReachabilityTlv, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- ipInternalReachabilityTlv.readFrom(channelBuffer);
- result = ipInternalReachabilityTlv.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(ipInternalReachabilityTlv.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IsReachabilityTlvTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IsReachabilityTlvTest.java
deleted file mode 100644
index d271926..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IsReachabilityTlvTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for IS ReachabilityTlv.
- */
-public class IsReachabilityTlvTest {
- private final byte[] tlv = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- private TlvHeader tlvHeader;
- private IsReachabilityTlv isReachabilityTlv;
- private MetricsOfReachability metricsOfReachability;
- private int resultInt;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- isReachabilityTlv = new IsReachabilityTlv(tlvHeader);
- metricsOfReachability = new MetricsOfReachability();
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- tlvHeader = null;
- isReachabilityTlv = null;
- }
-
- /**
- * Tests reserved() getter method.
- */
- @Test
- public void testReserved() throws Exception {
- isReachabilityTlv.setReserved(10);
- resultInt = isReachabilityTlv.reserved();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests reserved() setter method.
- */
- @Test
- public void testSetReserved() throws Exception {
- isReachabilityTlv.setReserved(10);
- resultInt = isReachabilityTlv.reserved();
- assertThat(resultInt, is(10));
- }
-
- /**
- * Tests addMeticsOfReachability() getter method.
- */
- @Test
- public void testAddMeticsOfReachability() throws Exception {
- isReachabilityTlv.addMeticsOfReachability(metricsOfReachability);
- assertThat(isReachabilityTlv, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- isReachabilityTlv.readFrom(channelBuffer);
- assertThat(isReachabilityTlv, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- isReachabilityTlv.readFrom(channelBuffer);
- result = isReachabilityTlv.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(isReachabilityTlv.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IsisNeighborTlvTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IsisNeighborTlvTest.java
deleted file mode 100644
index a430c1c..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IsisNeighborTlvTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.MacAddress;
-
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for ISIS NeighborTLV.
- */
-public class IsisNeighborTlvTest {
- private final MacAddress macAddress = MacAddress.valueOf("a4:23:05:00:00:00");
- private final byte[] tlv = {0, 0, 0, 0, 0, 0};
- private TlvHeader tlvHeader;
- private IsisNeighborTlv isisNeighborTlv;
- private List<MacAddress> resultList;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- isisNeighborTlv = new IsisNeighborTlv(tlvHeader);
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- tlvHeader = null;
- isisNeighborTlv = null;
- }
-
- /**
- * Tests addNeighbor() getter method.
- */
- @Test
- public void testAddNeighbor() throws Exception {
- isisNeighborTlv.addNeighbor(macAddress);
- resultList = isisNeighborTlv.neighbor();
- assertThat(resultList.size(), is(1));
-
- }
-
- /**
- * Tests neighbor() setter method.
- */
- @Test
- public void testNeighbor() throws Exception {
- isisNeighborTlv.addNeighbor(macAddress);
- resultList = isisNeighborTlv.neighbor();
- assertThat(resultList.size(), is(1));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- isisNeighborTlv.readFrom(channelBuffer);
- assertThat(isisNeighborTlv.neighbor().size(), is(1));
- }
-
- /**
- * Tests asBytes() getter method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- isisNeighborTlv.readFrom(channelBuffer);
- result = isisNeighborTlv.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(isisNeighborTlv.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/LspEntriesTlvTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/LspEntriesTlvTest.java
deleted file mode 100644
index 2daece4..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/LspEntriesTlvTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for LspEntriesTlv.
- */
-public class LspEntriesTlvTest {
-
- private final byte[] entry = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- private LspEntriesTlv lspEntriesTlv;
- private TlvHeader tlvHeader;
- private List<LspEntry> lspEntries = new ArrayList();
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- lspEntriesTlv = new LspEntriesTlv(tlvHeader);
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- tlvHeader = null;
- lspEntriesTlv = null;
- lspEntries.clear();
- }
-
- /**
- * Tests lspEntry() getter method.
- */
- @Test
- public void testLspEntry() throws Exception {
- lspEntriesTlv.addLspEntry(new LspEntry());
- assertThat(lspEntriesTlv.lspEntry().size(), is(1));
- }
-
- /**
- * Tests lspEntry() add method.
- */
- @Test
- public void testAddLspEntry() throws Exception {
- lspEntriesTlv.addLspEntry(new LspEntry());
- assertThat(lspEntriesTlv.lspEntry().size(), is(1));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(entry);
- lspEntriesTlv.readFrom(channelBuffer);
- lspEntries = lspEntriesTlv.lspEntry();
- assertThat(lspEntriesTlv.lspEntry().size(), is(1));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(entry);
- lspEntriesTlv.readFrom(channelBuffer);
- lspEntriesTlv.asBytes();
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(lspEntriesTlv.toString(), is(notNullValue()));
- }
-
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/LspEntryTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/LspEntryTest.java
deleted file mode 100644
index ba24d82..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/LspEntryTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for LspEntry.
- */
-public class LspEntryTest {
-
- private final String lspId = "10.10.10.10";
- private final byte[] entry = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- private LspEntry lspEntry;
- private int result;
- private String result2;
- private ChannelBuffer channelBuffer;
- private byte[] result3;
-
- @Before
- public void setUp() throws Exception {
- lspEntry = new LspEntry();
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- lspEntry = null;
- channelBuffer = null;
- }
-
- /**
- * Tests lspSequenceNumber() getter method.
- */
- @Test
- public void testLspSequenceNumber() throws Exception {
- lspEntry.setLspSequenceNumber(0);
- result = lspEntry.lspSequenceNumber();
- assertThat(result, is(0));
- }
-
- /**
- * Tests lspSequenceNumber() setter method.
- */
- @Test
- public void testSetLspSequenceNumber() throws Exception {
- lspEntry.setLspSequenceNumber(0);
- result = lspEntry.lspSequenceNumber();
- assertThat(result, is(0));
- }
-
- /**
- * Tests lspChecksum() getter method.
- */
- @Test
- public void testLspChecksum() throws Exception {
- lspEntry.setLspChecksum(0);
- result = lspEntry.lspChecksum();
- assertThat(result, is(0));
- }
-
- /**
- * Tests lspChecksum() setter method.
- */
- @Test
- public void testSetLspChecksum() throws Exception {
- lspEntry.setLspChecksum(0);
- result = lspEntry.lspChecksum();
- assertThat(result, is(0));
- }
-
- /**
- * Tests remainingTime() getter method.
- */
- @Test
- public void testRemainingTime() throws Exception {
- lspEntry.setRemainingTime(0);
- result = lspEntry.remainingTime();
- assertThat(result, is(0));
- }
-
- /**
- * Tests remainingTime() setter method.
- */
- @Test
- public void testSetRemainingTime() throws Exception {
- lspEntry.setRemainingTime(0);
- result = lspEntry.remainingTime();
- assertThat(result, is(0));
- }
-
- /**
- * Tests lspId() getter method.
- */
- @Test
- public void testLspId() throws Exception {
- lspEntry.setLspId(lspId);
- result2 = lspEntry.lspId();
- assertThat(result2, is("10.10.10.10"));
- }
-
- /**
- * Tests lspId() getter method.
- */
- @Test
- public void testSetLspId() throws Exception {
- lspEntry.setLspId(lspId);
- result2 = lspEntry.lspId();
- assertThat(result2, is("10.10.10.10"));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(entry);
- lspEntry.readFrom(channelBuffer);
- assertThat(lspEntry, is(notNullValue()));
- }
-
- /**
- * Tests lspEntryAsBytes() method.
- */
- @Test
- public void testLspEntryAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(entry);
- lspEntry.readFrom(channelBuffer);
- result3 = lspEntry.lspEntryAsBytes();
- assertThat(lspEntry, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(lspEntry.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/MetricOfInternalReachabilityTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/MetricOfInternalReachabilityTest.java
deleted file mode 100644
index 3ece0e0..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/MetricOfInternalReachabilityTest.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for MetricOfInternalReachability.
- */
-public class MetricOfInternalReachabilityTest {
-
- private final Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10");
- private final byte[] internalReachability = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- private MetricOfInternalReachability reachability;
- private Ip4Address result;
- private boolean result1;
- private byte result2;
- private ChannelBuffer channelBuffer;
- private byte[] result3;
-
- @Before
- public void setUp() throws Exception {
- reachability = new MetricOfInternalReachability();
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- reachability = null;
- result = null;
- result1 = false;
- }
-
- /**
- * Tests getIpAddress() getter method.
- */
- @Test
- public void testGetIpAddress() throws Exception {
- reachability.setIpAddress(ip4Address);
- result = reachability.getIpAddress();
- assertThat(result, is(ip4Address));
- }
-
- /**
- * Tests setIpAddress() setter method.
- */
- @Test
- public void testSetIpAddress() throws Exception {
- reachability.setIpAddress(ip4Address);
- result = reachability.getIpAddress();
- assertThat(result, is(ip4Address));
- }
-
- /**
- * Tests getSubnetAddress() getter method.
- */
- @Test
- public void testGetSubnetAddres() throws Exception {
- reachability.setSubnetAddress(ip4Address);
- result = reachability.getSubnetAddress();
- assertThat(result, is(ip4Address));
- }
-
- /**
- * Tests setSubnetAddress() setter method.
- */
- @Test
- public void testSetSubnetAddres() throws Exception {
- reachability.setSubnetAddress(ip4Address);
- result = reachability.getSubnetAddress();
- assertThat(result, is(ip4Address));
- }
-
- /**
- * Tests isErrorIsInternal() getter method.
- */
- @Test
- public void testIsErrorIsInternal() throws Exception {
- reachability.setErrorIsInternal(true);
- result1 = reachability.isErrorIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isErrorIsInternal() setter method.
- */
- @Test
- public void testSetErrorIsInternal() throws Exception {
- reachability.setErrorIsInternal(true);
- result1 = reachability.isErrorIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isExpenseIsInternal() getter method.
- */
- @Test
- public void testIsExpenseIsInternal() throws Exception {
- reachability.setExpenseIsInternal(true);
- result1 = reachability.isExpenseIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isExpenseIsInternal() setter method.
- */
- @Test
- public void testSetExpenseIsInternal() throws Exception {
- reachability.setExpenseIsInternal(true);
- result1 = reachability.isExpenseIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isDelayIsInternal() getter method.
- */
- @Test
- public void testIsDelayIsInternal() throws Exception {
- reachability.setDelayIsInternal(true);
- result1 = reachability.isDelayIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isDelayIsInternal() setter method.
- */
- @Test
- public void testSetDelayIsInternal() throws Exception {
- reachability.setDelayIsInternal(true);
- result1 = reachability.isDelayIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isDefaultDistributionDown() getter method.
- */
- @Test
- public void testIsDefaultDistributionDown() throws Exception {
- reachability.setDefaultDistributionDown(true);
- result1 = reachability.isDefaultDistributionDown();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isDefaultDistributionDown() setter method.
- */
- @Test
- public void testSetDefaultDistributionDown() throws Exception {
- reachability.setDefaultDistributionDown(true);
- result1 = reachability.isDefaultDistributionDown();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isDefaultIsInternal() getter method.
- */
- @Test
- public void testIsDefaultIsInternal() throws Exception {
- reachability.setDefaultIsInternal(true);
- result1 = reachability.isDefaultIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isDefaultIsInternal() setter method.
- */
- @Test
- public void testSetDefaultIsInternal() throws Exception {
- reachability.setDefaultIsInternal(true);
- result1 = reachability.isDefaultIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isErrorMetricSupported() getter method.
- */
- @Test
- public void testIsErrorMetricSupported() throws Exception {
- reachability.setErrorMetricSupported(true);
- result1 = reachability.isErrorMetricSupported();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isErrorMetricSupported() setter method.
- */
- @Test
- public void testSetErrorMetricSupported() throws Exception {
- reachability.setErrorMetricSupported(true);
- result1 = reachability.isErrorMetricSupported();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isExpenseMetricSupported() setter method.
- */
- @Test
- public void testIsExpenseMetricSupported() throws Exception {
- reachability.setExpenseMetricSupported(true);
- result1 = reachability.isExpenseMetricSupported();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isExpenseMetricSupported() setter method.
- */
- @Test
- public void testSetExpenseMetricSupported() throws Exception {
- reachability.setExpenseMetricSupported(true);
- result1 = reachability.isExpenseMetricSupported();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isDelayMetricSupported() getter method.
- */
- @Test
- public void testIsDelayMetricSupported() throws Exception {
- reachability.setDelayMetricSupported(true);
- result1 = reachability.isDelayMetricSupported();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isDelayMetricSupported() setter method.
- */
- @Test
- public void testSetDelayMetricSupported() throws Exception {
- reachability.setDelayMetricSupported(true);
- result1 = reachability.isDelayMetricSupported();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests errorMetric() getter method.
- */
- @Test
- public void testErrorMetric() throws Exception {
- reachability.setErrorMetric((byte) 0);
- result2 = reachability.errorMetric();
- assertThat(result2, is((byte) 0));
- }
-
- /**
- * Tests errorMetric() setter method.
- */
- @Test
- public void testSetErrorMetric() throws Exception {
- reachability.setErrorMetric((byte) 0);
- result2 = reachability.errorMetric();
- assertThat(result2, is((byte) 0));
- }
-
- /**
- * Tests delayMetric() getter method.
- */
- @Test
- public void testDelayMetric() throws Exception {
- reachability.setDelayMetric((byte) 0);
- result2 = reachability.delayMetric();
- assertThat(result2, is((byte) 0));
- }
-
- /**
- * Tests delayMetric() setter method.
- */
- @Test
- public void testSetDelayMetric() throws Exception {
- reachability.setDelayMetric((byte) 0);
- result2 = reachability.delayMetric();
- assertThat(result2, is((byte) 0));
- }
-
- /**
- * Tests defaultMetric() getter method.
- */
- @Test
- public void testDefaultMetric() throws Exception {
- reachability.setDefaultMetric((byte) 0);
- result2 = reachability.defaultMetric();
- assertThat(result2, is((byte) 0));
- }
-
- /**
- * Tests defaultMetric() setter method.
- */
- @Test
- public void testSetDefaultMetric() throws Exception {
- reachability.setDefaultMetric((byte) 0);
- result2 = reachability.defaultMetric();
- assertThat(result2, is((byte) 0));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(internalReachability);
- reachability.readFrom(channelBuffer);
- assertThat(reachability, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(internalReachability);
- reachability.readFrom(channelBuffer);
- result3 = reachability.asBytes();
- assertThat(result3, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(reachability.toString(), is(notNullValue()));
- }
-}
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/MetricsOfReachabilityTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/MetricsOfReachabilityTest.java
deleted file mode 100644
index 080c3c5..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/MetricsOfReachabilityTest.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for MetricsOfReachability.
- */
-public class MetricsOfReachabilityTest {
- private final Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10");
- private final byte[] metricReachability = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- private MetricsOfReachability reachability;
- private String neighborId = "2929.2929.2929";
- private Ip4Address result;
- private boolean result1;
- private byte result2;
- private ChannelBuffer channelBuffer;
- private byte[] result3;
- private String result4;
-
- @Before
- public void setUp() throws Exception {
- reachability = new MetricsOfReachability();
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- result1 = false;
- }
-
- @After
- public void tearDown() throws Exception {
- reachability = null;
- result1 = false;
- result3 = null;
- channelBuffer = null;
- }
-
- /**
- * Tests isDelayIsInternal() getter method.
- */
- @Test
- public void testIsDelayIsInternal() throws Exception {
- reachability.setDelayIsInternal(true);
- result1 = reachability.isDelayIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isDelayIsInternal() setter method.
- */
- @Test
- public void testSetDelayIsInternal() throws Exception {
- reachability.setDelayIsInternal(true);
- result1 = reachability.isDelayIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isExpenseIsInternal() getter method.
- */
- @Test
- public void testIsExpenseIsInternal() throws Exception {
- reachability.setExpenseIsInternal(true);
- result1 = reachability.isExpenseIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isExpenseIsInternal() setter method.
- */
- @Test
- public void testSetExpenseIsInternal() throws Exception {
- reachability.setExpenseIsInternal(true);
- result1 = reachability.isExpenseIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isErrorIsInternal() getter method.
- */
- @Test
- public void testIsErrorIsInternal() throws Exception {
- reachability.setErrorIsInternal(true);
- result1 = reachability.isErrorIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isErrorIsInternal() setter method.
- */
- @Test
- public void testSetErrorIsInternal() throws Exception {
- reachability.setErrorIsInternal(true);
- result1 = reachability.isErrorIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isDefaultIsInternal() getter method.
- */
- @Test
- public void testIsDefaultIsInternal() throws Exception {
- reachability.setDefaultIsInternal(true);
- result1 = reachability.isDefaultIsInternal();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isDefaultIsInternal() setter method.
- */
- @Test
- public void testSetDefaultIsInternal() throws Exception {
- reachability.setDefaultIsInternal(true);
- result1 = reachability.isDefaultIsInternal();
- assertThat(result1, is(true));
- }
-
- @Test
- public void testIsDelayMetricSupported() throws Exception {
- reachability.setDelayMetricSupported(true);
- result1 = reachability.isDelayMetricSupported();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isDelayMetricSupported() setter method.
- */
- @Test
- public void testSetDelayMetricSupported() throws Exception {
- reachability.setDelayMetricSupported(true);
- result1 = reachability.isDelayMetricSupported();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isExpenseMetricSupported() getter method.
- */
- @Test
- public void testIsExpenseMetricSupported() throws Exception {
- reachability.setExpenseMetricSupported(true);
- result1 = reachability.isExpenseMetricSupported();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isExpenseMetricSupported() setter method.
- */
- @Test
- public void testSetExpenseMetricSupported() throws Exception {
- reachability.setExpenseMetricSupported(true);
- result1 = reachability.isExpenseMetricSupported();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isErrorMetricSupported() getter method.
- */
- @Test
- public void testIsErrorMetricSupported() throws Exception {
- reachability.setErrorMetricSupported(true);
- result1 = reachability.isErrorMetricSupported();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests isErrorMetricSupported() setter method.
- */
- @Test
- public void testSetErrorMetricSupported() throws Exception {
- reachability.setErrorMetricSupported(true);
- result1 = reachability.isErrorMetricSupported();
- assertThat(result1, is(true));
- }
-
- /**
- * Tests neighborId() getter method.
- */
- @Test
- public void testNeighborId() throws Exception {
- reachability.setNeighborId(neighborId);
- result4 = reachability.neighborId();
- assertThat(result4, is(neighborId));
- }
-
- /**
- * Tests neighborId() setter method.
- */
- @Test
- public void testSetNeighborId() throws Exception {
- reachability.setNeighborId(neighborId);
- result4 = reachability.neighborId();
- assertThat(result4, is(neighborId));
- }
-
- /**
- * Tests defaultMetric() getter method.
- */
- @Test
- public void testDefaultMetric() throws Exception {
- reachability.setDefaultMetric((byte) 0);
- result2 = reachability.defaultMetric();
- assertThat(result2, is((byte) 0));
- }
-
- /**
- * Tests defaultMetric() setter method.
- */
- @Test
- public void testSetDefaultMetric() throws Exception {
- reachability.setDefaultMetric((byte) 0);
- result2 = reachability.defaultMetric();
- assertThat(result2, is((byte) 0));
- }
-
- /**
- * Tests delayMetric() getter method.
- */
- @Test
- public void testDelayMetric() throws Exception {
- reachability.setDelayMetric((byte) 0);
- result2 = reachability.delayMetric();
- assertThat(result2, is((byte) 0));
- }
-
- /**
- * Tests delayMetric() setter method.
- */
- @Test
- public void testSetDelayMetric() throws Exception {
- reachability.setDelayMetric((byte) 0);
- result2 = reachability.delayMetric();
- assertThat(result2, is((byte) 0));
- }
-
- /**
- * Tests expenseMetric() getter method.
- */
- @Test
- public void testExpenseMetric() throws Exception {
- reachability.setExpenseMetric((byte) 0);
- result2 = reachability.expenseMetric();
- assertThat(result2, is((byte) 0));
- }
-
- /**
- * Tests expenseMetric() setter method.
- */
- @Test
- public void testSetExpenseMetric() throws Exception {
- reachability.setExpenseMetric((byte) 0);
- result2 = reachability.expenseMetric();
- assertThat(result2, is((byte) 0));
- }
-
- /**
- * Tests errorMetric() getter method.
- */
- @Test
- public void testErrorMetric() throws Exception {
- reachability.setErrorMetric((byte) 0);
- result2 = reachability.errorMetric();
- assertThat(result2, is((byte) 0));
- }
-
- /**
- * Tests errorMetric() setter method.
- */
- @Test
- public void testSetErrorMetric() throws Exception {
- reachability.setErrorMetric((byte) 0);
- result2 = reachability.errorMetric();
- assertThat(result2, is((byte) 0));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(metricReachability);
- reachability.readFrom(channelBuffer);
- assertThat(reachability, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(metricReachability);
- reachability.readFrom(channelBuffer);
- result3 = reachability.asBytes();
- assertThat(result3, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(reachability.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/NeighborForExtendedIsTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/NeighborForExtendedIsTest.java
deleted file mode 100644
index 72c93c0..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/NeighborForExtendedIsTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for NeighborForExtendedIs.
- *
- * Here we have passed a byte array containing data for 2 neighbors along with
- * their Sub TLVs. The test case checks whether the code is able to parse the Sub TLVs
- * for each neighbor or not. Along with this it also checks for neighbor id and metric
- * assigned to each neighbor.
- */
-public class NeighborForExtendedIsTest {
- private final byte[] tlv = {
- (byte) 0x10, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x10, (byte) 0x02, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x0a, (byte) 0x3f, (byte) 0x06, (byte) 0x04, (byte) 0x14, (byte) 0x14, (byte) 0x14,
- (byte) 0xbe, (byte) 0x08, (byte) 0x04, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0xd1, (byte) 0x09,
- (byte) 0x04, (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x0a, (byte) 0x04, (byte) 0x49,
- (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x0b, (byte) 0x20, (byte) 0x49, (byte) 0x98, (byte) 0x96,
- (byte) 0x80, (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x49, (byte) 0x98, (byte) 0x96,
- (byte) 0x80, (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x49, (byte) 0x98, (byte) 0x96,
- (byte) 0x80, (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x49, (byte) 0x98, (byte) 0x96,
- (byte) 0x80, (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x12, (byte) 0x03, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x10, (byte) 0x01,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, (byte) 0x3f, (byte) 0x06, (byte) 0x04, (byte) 0x1e,
- (byte) 0x1e, (byte) 0x1e, (byte) 0xce, (byte) 0x08, (byte) 0x04, (byte) 0x1e, (byte) 0x1e, (byte) 0x1e,
- (byte) 0xa9, (byte) 0x09, (byte) 0x04, (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x0a,
- (byte) 0x04, (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x0b, (byte) 0x20, (byte) 0x49,
- (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x49,
- (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x49,
- (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x49,
- (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80, (byte) 0x12,
- (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00
- };
-
- //tlv2 bytes are for testing the else part of readFrom() method
- private final byte[] tlv2 = {
- (byte) 0x10, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x10, (byte) 0x02, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x0a, (byte) 0x06, (byte) 0x2D, (byte) 0x04, (byte) 0x14, (byte) 0x14, (byte) 0x14,
- (byte) 0xbe, (byte) 0x2D, (byte) 0xd1, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0xd1, (byte) 0x09
- };
- private final String neighborId1 = "1000.1000.1002.00";
- private final String neighborId2 = "1000.1000.1001.00";
- private final int metric = 10;
- private final int subTlvLength = 6;
- private NeighborForExtendedIs neighborForExtendedIs;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- neighborForExtendedIs = new NeighborForExtendedIs();
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- neighborForExtendedIs = null;
- channelBuffer = null;
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- neighborForExtendedIs.readFrom(channelBuffer);
- assertThat(neighborForExtendedIs.teSubTlv().size(), is(subTlvLength));
- assertThat(neighborForExtendedIs.neighborId(), is(neighborId1));
- assertThat(neighborForExtendedIs.metric(), is(metric));
-
- neighborForExtendedIs = new NeighborForExtendedIs();
- neighborForExtendedIs.readFrom(channelBuffer);
- assertThat(neighborForExtendedIs.teSubTlv().size(), is(subTlvLength));
- assertThat(neighborForExtendedIs.neighborId(), is(neighborId2));
- assertThat(neighborForExtendedIs.metric(), is(metric));
- }
-
- /**
- * Tests else condition of readFrom() method.
- */
- @Test
- public void testElsePartOfReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv2);
- neighborForExtendedIs = new NeighborForExtendedIs();
- neighborForExtendedIs.readFrom(channelBuffer);
- assertThat(neighborForExtendedIs.neighborId(), is(neighborId1));
- assertThat(neighborForExtendedIs.metric(), is(metric));
- }
-}
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/PaddingTlvTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/PaddingTlvTest.java
deleted file mode 100644
index 04e87c8..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/PaddingTlvTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for PaddingTlv.
- */
-public class PaddingTlvTest {
-
- private final byte[] tlv = {0, 0, 0, 0, 0, 0, 0};
- private PaddingTlv paddingTlv;
- private TlvHeader tlvHeader;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- paddingTlv = new PaddingTlv(tlvHeader);
- }
-
- @After
- public void tearDown() throws Exception {
- paddingTlv = null;
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- paddingTlv.readFrom(channelBuffer);
- assertThat(paddingTlv, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- paddingTlv.readFrom(channelBuffer);
- result = paddingTlv.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests toString() getter method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(paddingTlv.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/ProtocolSupportedTlvTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/ProtocolSupportedTlvTest.java
deleted file mode 100644
index 962cf0c..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/ProtocolSupportedTlvTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for ProtocolSupportedTlv.
- */
-public class ProtocolSupportedTlvTest {
- private final byte[] tlv = {0};
- private ProtocolSupportedTlv protocolSupportedTlv;
- private TlvHeader tlvHeader;
- private List<Byte> supported;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- protocolSupportedTlv = new ProtocolSupportedTlv(tlvHeader);
- }
-
- @After
- public void tearDown() throws Exception {
- tlvHeader = null;
- protocolSupportedTlv = null;
- channelBuffer = null;
- }
-
- /**
- * Tests addProtocolSupported() method.
- */
- @Test
- public void testAddProtocolSupported() throws Exception {
- protocolSupportedTlv.addProtocolSupported((byte) 1);
- supported = protocolSupportedTlv.protocolSupported();
- assertThat(supported.size(), is(1));
- }
-
- /**
- * Tests addProtocolSupported() getter method.
- */
- @Test
- public void testProtocolSupported() throws Exception {
- protocolSupportedTlv.addProtocolSupported((byte) 1);
- supported = protocolSupportedTlv.protocolSupported();
- assertThat(supported.size(), is(1));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- protocolSupportedTlv.readFrom(channelBuffer);
- supported = protocolSupportedTlv.protocolSupported();
- assertThat(supported.size(), is(1));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- protocolSupportedTlv.readFrom(channelBuffer);
- result = protocolSupportedTlv.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests toString() method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(protocolSupportedTlv.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/TlvFinderTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/TlvFinderTest.java
deleted file mode 100644
index bd9a443..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/TlvFinderTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-
-/**
- * Unit test class for TlvFinder.
- */
-public class TlvFinderTest {
-
- private final byte[] tlv = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- private final byte[] tlv1 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- private TlvFinder tlvFinder;
- private TlvHeader tlvHeader;
- private ChannelBuffer channelBuffer;
- private IsisTlv isisTlv;
-
- @Before
- public void setUp() throws Exception {
- tlvFinder = new TlvFinder();
- tlvHeader = new TlvHeader();
- }
-
- @After
- public void tearDown() throws Exception {
- tlvFinder = null;
- isisTlv = null;
- }
-
- /**
- * Tests IsisTlv() getter method.
- */
- @Test
- public void testIsisTlv() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
-
- tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
- isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer);
- assertThat(isisTlv, instanceOf(AreaAddressTlv.class));
-
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- tlvHeader.setTlvType(TlvType.HOSTNAME.value());
- isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer);
- assertThat(isisTlv, instanceOf(HostNameTlv.class));
-
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- tlvHeader.setTlvType(TlvType.IDRPINFORMATION.value());
- isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer);
- assertThat(isisTlv, instanceOf(IdrpInformationTlv.class));
-
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- tlvHeader.setTlvType(TlvType.IPEXTENDEDREACHABILITY.value());
- isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer);
- assertThat(isisTlv, instanceOf(IpExtendedReachabilityTlv.class));
-
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- tlvHeader.setTlvType(TlvType.IPINTERFACEADDRESS.value());
- isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer);
- assertThat(isisTlv, instanceOf(IpInterfaceAddressTlv.class));
-
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- tlvHeader.setTlvType(TlvType.IPINTERNALREACHABILITY.value());
- isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer);
- assertThat(isisTlv, instanceOf(IpInternalReachabilityTlv.class));
-
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- tlvHeader.setTlvType(TlvType.PROTOCOLSUPPORTED.value());
- isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer);
- assertThat(isisTlv, instanceOf(ProtocolSupportedTlv.class));
-
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- tlvHeader.setTlvType(TlvType.ISREACHABILITY.value());
- isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer);
- assertThat(isisTlv, instanceOf(IsReachabilityTlv.class));
-
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- tlvHeader.setTlvType(TlvType.ISNEIGHBORS.value());
- isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer);
- assertThat(isisTlv, instanceOf(IsisNeighborTlv.class));
-
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- tlvHeader.setTlvType(TlvType.LSPENTRY.value());
- isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer);
- assertThat(isisTlv, instanceOf(LspEntriesTlv.class));
-
- channelBuffer = ChannelBuffers.copiedBuffer(tlv);
- tlvHeader.setTlvType(TlvType.PADDING.value());
- isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer);
- assertThat(isisTlv, instanceOf(PaddingTlv.class));
-
- channelBuffer = ChannelBuffers.copiedBuffer(tlv1);
- tlvHeader.setTlvType(TlvType.ADJACENCYSTATE.value());
- isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer);
- assertThat(isisTlv, instanceOf(AdjacencyStateTlv.class));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/TlvHeaderTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/TlvHeaderTest.java
deleted file mode 100644
index 0e7fba2..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/TlvHeaderTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for TlvHeader.
- */
-public class TlvHeaderTest {
-
- private TlvHeader tlvHeader;
- private int result;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- tlvHeader = null;
- channelBuffer = null;
- }
-
- /**
- * Tests tlvLength() getter method.
- */
- @Test
- public void testTlvLength() throws Exception {
- tlvHeader.setTlvLength(1);
- result = tlvHeader.tlvLength();
- assertThat(result, is(1));
- }
-
- /**
- * Tests tlvLength() setter method.
- */
- @Test
- public void testSetTlvLength() throws Exception {
- tlvHeader.setTlvLength(1);
- result = tlvHeader.tlvLength();
- assertThat(result, is(1));
- }
-
- /**
- * Tests tlvType() getter method.
- */
- @Test
- public void testTlvType() throws Exception {
- tlvHeader.setTlvType(1);
- result = tlvHeader.tlvType();
- assertThat(result, is(1));
- }
-
- /**
- * Tests tlvType() setter method.
- */
- @Test
- public void testSetTlvType() throws Exception {
- tlvHeader.setTlvType(1);
- result = tlvHeader.tlvType();
- assertThat(result, is(1));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- tlvHeader.readFrom(channelBuffer);
- assertThat(tlvHeader, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() getter method.
- */
- @Test
- public void testAsBytes() throws Exception {
- assertThat(tlvHeader.asBytes(), is(nullValue()));
- }
-
- /**
- * Tests tlvHeaderAsByteArray() method.
- */
- @Test
- public void testTlvHeaderAsByteArray() throws Exception {
- tlvHeader.setTlvLength(1);
- tlvHeader.setTlvType(1);
- assertThat(tlvHeader.tlvHeaderAsByteArray(), is(notNullValue()));
- assertThat(tlvHeader.tlvType(), is(1));
- assertThat(tlvHeader.tlvLength(), is(1));
- }
-
- /**
- * Tests toString() getter method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(tlvHeader.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/TlvsToBytesTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/TlvsToBytesTest.java
deleted file mode 100644
index 7905eb5..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/TlvsToBytesTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv;
-
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.MacAddress;
-import org.onosproject.isis.controller.IsisInterfaceState;
-import org.onosproject.isis.io.util.IsisConstants;
-
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for TlvsToBytes.
- */
-public class TlvsToBytesTest {
- private final String areaAddress = "49";
- private final Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10");
- private final String systemName = "ROUTER";
- private final String neighborId = "2929.2929.2929";
- private List<Byte> tlv;
- private MacAddress macAddress = MacAddress.valueOf("a4:23:05:00:00:00");
- private String prefix = "192.168.7";
-
- /**
- * Tests TlvToBytes() method.
- */
- @Test
- public void testTlvToBytes() throws Exception {
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(TlvType.AREAADDRESS.value());
- tlvHeader.setTlvLength(0);
- AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader);
- areaAddressTlv.addAddress(areaAddress);
- tlv = TlvsToBytes.tlvToBytes(areaAddressTlv);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader.setTlvType(TlvType.PROTOCOLSUPPORTED.value());
- tlvHeader.setTlvLength(0);
- ProtocolSupportedTlv protocolSupportedTlv = new ProtocolSupportedTlv(tlvHeader);
- protocolSupportedTlv.addProtocolSupported((byte) IsisConstants.PROTOCOLSUPPORTED);
- tlv = TlvsToBytes.tlvToBytes(protocolSupportedTlv);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader.setTlvType(TlvType.IPINTERFACEADDRESS.value());
- tlvHeader.setTlvLength(0);
- IpInterfaceAddressTlv ipInterfaceAddressTlv = new IpInterfaceAddressTlv(tlvHeader);
- ipInterfaceAddressTlv.addInterfaceAddres(ip4Address);
- tlv = TlvsToBytes.tlvToBytes(ipInterfaceAddressTlv);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader.setTlvType(TlvType.HOSTNAME.value());
- tlvHeader.setTlvLength(0);
- HostNameTlv hostNameTlv = new HostNameTlv(tlvHeader);
- hostNameTlv.setHostName(systemName);
- tlv = TlvsToBytes.tlvToBytes(hostNameTlv);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader.setTlvType(TlvType.ISREACHABILITY.value());
- tlvHeader.setTlvLength(0);
- IsReachabilityTlv isReachabilityTlv = new IsReachabilityTlv(tlvHeader);
- isReachabilityTlv.setReserved(0);
- MetricsOfReachability metricsOfReachability = new MetricsOfReachability();
- metricsOfReachability.setDefaultMetric((byte) 10);
- metricsOfReachability.setDefaultIsInternal(true);
- metricsOfReachability.setDelayMetric((byte) 10);
- metricsOfReachability.setDelayIsInternal(true);
- metricsOfReachability.setDelayMetricSupported(true);
- metricsOfReachability.setExpenseMetric((byte) 10);
- metricsOfReachability.setExpenseIsInternal(true);
- metricsOfReachability.setExpenseMetricSupported(true);
- metricsOfReachability.setErrorMetric((byte) 10);
- metricsOfReachability.setErrorIsInternal(true);
- metricsOfReachability.setErrorMetricSupported(true);
- metricsOfReachability.setNeighborId(neighborId);
- isReachabilityTlv.addMeticsOfReachability(metricsOfReachability);
- tlv = TlvsToBytes.tlvToBytes(isReachabilityTlv);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader.setTlvType(TlvType.IPINTERNALREACHABILITY.value());
- tlvHeader.setTlvLength(0);
- IpInternalReachabilityTlv ipInterReacTlv = new IpInternalReachabilityTlv(tlvHeader);
- MetricOfInternalReachability metricOfIntRea = new MetricOfInternalReachability();
- metricOfIntRea.setDefaultMetric((byte) 10);
- metricOfIntRea.setDefaultIsInternal(true);
- metricOfIntRea.setDefaultDistributionDown(true);
- metricOfIntRea.setDelayMetric((byte) 0);
- metricOfIntRea.setDelayMetricSupported(false);
- metricOfIntRea.setDelayIsInternal(true);
- metricOfIntRea.setExpenseMetric((byte) 0);
- metricOfIntRea.setExpenseMetricSupported(false);
- metricOfIntRea.setExpenseIsInternal(true);
- metricOfIntRea.setErrorMetric((byte) 0);
- metricOfIntRea.setErrorMetricSupported(false);
- metricOfIntRea.setExpenseIsInternal(true);
- metricOfIntRea.setIpAddress(ip4Address);
- metricOfIntRea.setSubnetAddress(ip4Address);
- ipInterReacTlv.addInternalReachabilityMetric(metricOfIntRea);
- tlv = TlvsToBytes.tlvToBytes(ipInterReacTlv);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader.setTlvType(TlvType.PADDING.value());
- tlvHeader.setTlvLength(255);
- PaddingTlv paddingTlv = new PaddingTlv(tlvHeader);
- tlv = TlvsToBytes.tlvToBytes(paddingTlv);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader.setTlvType(TlvType.IPEXTENDEDREACHABILITY.value());
- tlvHeader.setTlvLength(0);
- IpExtendedReachabilityTlv extendedTlv = new IpExtendedReachabilityTlv(tlvHeader);
- extendedTlv.setDown(false);
- extendedTlv.setMetric(10);
- extendedTlv.setPrefix(prefix);
- extendedTlv.setPrefixLength(24);
- extendedTlv.setSubTlvLength((byte) 0);
- extendedTlv.setSubTlvPresence(false);
- tlv = TlvsToBytes.tlvToBytes(extendedTlv);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader.setTlvType(TlvType.ADJACENCYSTATE.value());
- tlvHeader.setTlvLength(0);
- AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader);
- adjacencyStateTlv.setAdjacencyType((byte) IsisInterfaceState.DOWN.value());
- tlv = TlvsToBytes.tlvToBytes(adjacencyStateTlv);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader.setTlvType(TlvType.ISNEIGHBORS.value());
- tlvHeader.setTlvLength(0);
- IsisNeighborTlv isisNeighborTlv = new IsisNeighborTlv(tlvHeader);
- isisNeighborTlv.addNeighbor(macAddress);
- tlv = TlvsToBytes.tlvToBytes(isisNeighborTlv);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader.setTlvType(TlvType.EXTENDEDISREACHABILITY.value());
- tlvHeader.setTlvLength(0);
- IsExtendedReachability reachability = new IsExtendedReachability(tlvHeader);
- NeighborForExtendedIs forExtendedIs = new NeighborForExtendedIs();
- forExtendedIs.setMetric(10);
- forExtendedIs.setNeighborId(neighborId);
- reachability.addNeighbor(forExtendedIs);
- tlv = TlvsToBytes.tlvToBytes(reachability);
- assertThat(tlv, is(notNullValue()));
- }
-}
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/AdministrativeGroupTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/AdministrativeGroupTest.java
deleted file mode 100644
index f982419..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/AdministrativeGroupTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for AdministrativeGroup.
- */
-public class AdministrativeGroupTest {
-
- private final byte[] packet = {0, 0, 0, 1};
- private AdministrativeGroup administrativeGroup;
- private ChannelBuffer channelBuffer;
- private TlvHeader tlvHeader;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- administrativeGroup = new AdministrativeGroup(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- administrativeGroup = null;
- channelBuffer = null;
- tlvHeader = null;
- }
-
- /**
- * Tests administrativeGroup() getter method.
- */
- @Test
- public void testGetAdministrativeGroup() throws Exception {
- administrativeGroup.setAdministrativeGroup(1);
- assertThat(administrativeGroup.administrativeGroup(), is(1));
- }
-
- /**
- * Tests administrativeGroup() setter method.
- */
- @Test
- public void testSetAdministrativeGroup() throws Exception {
- administrativeGroup.setAdministrativeGroup(1);
- assertThat(administrativeGroup.administrativeGroup(), is(1));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(9);
- tlvHeader.setTlvLength(4);
- administrativeGroup = new AdministrativeGroup(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- administrativeGroup.readFrom(channelBuffer);
- assertThat(administrativeGroup.administrativeGroup(), is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = administrativeGroup.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getLinkSubTypeTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
- result = administrativeGroup.tlvBodyAsBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(administrativeGroup.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddressTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddressTest.java
deleted file mode 100644
index caafa95..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddressTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for InterfaceIpAddress.
- */
-public class InterfaceIpAddressTest {
- private final byte[] packet = {1, 1, 1, 1};
- private final byte[] packet1 = {};
- private NeighborIpAddress interfaceIpAddress;
- private TlvHeader tlvHeader;
- private Ip4Address ip4Address = Ip4Address.valueOf("1.1.1.1");
- private byte[] result;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- interfaceIpAddress = new NeighborIpAddress(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- interfaceIpAddress = null;
- tlvHeader = null;
- result = null;
- channelBuffer = null;
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(interfaceIpAddress.toString(), is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() {
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(3);
- tlvHeader.setTlvLength(4);
- interfaceIpAddress = new NeighborIpAddress(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- interfaceIpAddress.readFrom(channelBuffer);
- assertThat(interfaceIpAddress, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom1() throws Exception {
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(3);
- tlvHeader.setTlvLength(4);
- interfaceIpAddress = new NeighborIpAddress(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- interfaceIpAddress.readFrom(channelBuffer);
- assertThat(interfaceIpAddress, is(notNullValue()));
- }
-
-
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumBandwidthTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumBandwidthTest.java
deleted file mode 100644
index 4f2dbda..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumBandwidthTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for MaximumBandwidth.
- */
-public class MaximumBandwidthTest {
-
- private final byte[] packet = {0, 0, 0, 0};
- private MaximumBandwidth maximumBandwidth;
- private TlvHeader header;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- maximumBandwidth = new MaximumBandwidth(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- maximumBandwidth = null;
- header = null;
- channelBuffer = null;
- result = null;
- }
-
- /**
- * Tests maximumBandwidth() setter method.
- */
- @Test
- public void testSetMaximumBandwidth() throws Exception {
- maximumBandwidth.setMaximumBandwidth(123456.00f);
- assertThat(maximumBandwidth, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- header = new TlvHeader();
- header.setTlvType(6);
- header.setTlvLength(4);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- maximumBandwidth = new MaximumBandwidth(header);
- maximumBandwidth.readFrom(channelBuffer);
- assertThat(maximumBandwidth, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = maximumBandwidth.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(maximumBandwidth.toString(), is(notNullValue()));
- }
-}
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumReservableBandwidthTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumReservableBandwidthTest.java
deleted file mode 100644
index 524a772..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/MaximumReservableBandwidthTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for MaximumReservableBandwidth.
- */
-public class MaximumReservableBandwidthTest {
-
- private final byte[] packet = {0, 0, 0, 0};
- private MaximumReservableBandwidth maximumReservableBandwidth;
- private TlvHeader header;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- maximumReservableBandwidth = new MaximumReservableBandwidth(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- maximumReservableBandwidth = null;
- header = null;
- channelBuffer = null;
- result = null;
- }
-
- /**
- * Tests maximumBandwidth() setter method.
- */
- @Test
- public void testSetMaximumBandwidth() throws Exception {
- maximumReservableBandwidth.setMaximumBandwidth(123456.78f);
- assertThat(maximumReservableBandwidth, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- header = new TlvHeader();
- header.setTlvType(6);
- header.setTlvLength(4);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- maximumReservableBandwidth = new MaximumReservableBandwidth(header);
- maximumReservableBandwidth.readFrom(channelBuffer);
- assertThat(maximumReservableBandwidth, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = maximumReservableBandwidth.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getLinkSubTypeTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
- result = maximumReservableBandwidth.tlvBodyAsBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(maximumReservableBandwidth.toString(), is(notNullValue()));
- }
-}
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvFinderTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvFinderTest.java
deleted file mode 100644
index 4b672d1..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvFinderTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for SubTlvFinder.
- */
-public class SubTlvFinderTest {
- private final byte[] packet1 = {0, 0, 0, 1};
- private TlvHeader tlvHeader;
- private ChannelBuffer channelBuffer;
- private TrafficEngineeringSubTlv tlv;
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- tlvHeader = null;
- channelBuffer = null;
- }
-
- @Test
- public void testFindSubTlv() throws Exception {
-
- tlvHeader.setTlvLength(4);
- tlvHeader.setTlvType(SubTlvType.ADMINISTRATIVEGROUP.value());
- AdministrativeGroup administrativeGroup = new AdministrativeGroup(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvLength(4);
- tlvHeader.setTlvType(SubTlvType.TRAFFICENGINEERINGMETRIC.value());
- TrafficEngineeringMetric trafficEngineeringMetric = new TrafficEngineeringMetric(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvLength(4);
- tlvHeader.setTlvType(SubTlvType.MAXIMUMBANDWIDTH.value());
- MaximumBandwidth maximumBandwidth = new MaximumBandwidth(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvLength(4);
- tlvHeader.setTlvType(SubTlvType.MAXIMUMRESERVABLEBANDWIDTH.value());
- MaximumReservableBandwidth maximumReservableBandwidth = new MaximumReservableBandwidth(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvLength(4);
- tlvHeader.setTlvType(SubTlvType.UNRESERVEDBANDWIDTH.value());
- UnreservedBandwidth unreservedBandwidth = new UnreservedBandwidth(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvLength(4);
- tlvHeader.setTlvType(SubTlvType.INTERFACEADDRESS.value());
- InterfaceIpAddress ipInterfaceAddressTlv = new InterfaceIpAddress(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer);
- assertThat(tlv, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytesTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytesTest.java
deleted file mode 100644
index ae975bf..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytesTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for SubTlvToBytes.
- */
-public class SubTlvToBytesTest {
- private TlvHeader tlvHeader;
- private ChannelBuffer channelBuffer;
- private List<Byte> tlv;
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- channelBuffer = EasyMock.createMock(ChannelBuffer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- tlvHeader = null;
- channelBuffer = null;
- }
-
- @Test
- public void testTlvToBytes() throws Exception {
- tlvHeader.setTlvLength(4);
- tlvHeader.setTlvType(9);
- AdministrativeGroup administrativeGroup = new AdministrativeGroup(tlvHeader);
- tlv = SubTlvToBytes.tlvToBytes(administrativeGroup);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvLength(4);
- tlvHeader.setTlvType(5);
- TrafficEngineeringMetric trafficEngineeringMetric = new TrafficEngineeringMetric(tlvHeader);
- tlv = SubTlvToBytes.tlvToBytes(trafficEngineeringMetric);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvLength(4);
- tlvHeader.setTlvType(6);
- MaximumBandwidth maximumBandwidth = new MaximumBandwidth(tlvHeader);
- tlv = SubTlvToBytes.tlvToBytes(maximumBandwidth);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvLength(4);
- tlvHeader.setTlvType(7);
- MaximumReservableBandwidth maximumReservableBandwidth = new MaximumReservableBandwidth(tlvHeader);
- tlv = SubTlvToBytes.tlvToBytes(maximumReservableBandwidth);
- assertThat(tlv, is(notNullValue()));
-
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvLength(4);
- tlvHeader.setTlvType(8);
- UnreservedBandwidth unreservedBandwidth = new UnreservedBandwidth(tlvHeader);
- tlv = SubTlvToBytes.tlvToBytes(unreservedBandwidth);
- assertThat(tlv, is(notNullValue()));
- }
-}
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/TrafficEngineeringMetricTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/TrafficEngineeringMetricTest.java
deleted file mode 100644
index 358e5d4..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/TrafficEngineeringMetricTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-
-/**
- * Unit test class for TrafficEngineeringMetric.
- */
-public class TrafficEngineeringMetricTest {
-
- private final byte[] packet = {0, 0, 1, 1};
- private TrafficEngineeringMetric trafficEngineeringMetric;
- private TlvHeader header;
- private byte[] result;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- trafficEngineeringMetric = new TrafficEngineeringMetric(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- trafficEngineeringMetric = null;
- header = null;
- result = null;
- channelBuffer = null;
- }
-
- /**
- * Tests trafficEngineeringMetric() setter method.
- */
- @Test
- public void testSetTrafficEngineeringMetric() throws Exception {
- trafficEngineeringMetric.setTrafficEngineeringMetric(123456789L);
- assertThat(trafficEngineeringMetric, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- header = new TlvHeader();
- header.setTlvLength(4);
- header.setTlvType(5);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- trafficEngineeringMetric = new TrafficEngineeringMetric(header);
- trafficEngineeringMetric.readFrom(channelBuffer);
- assertThat(trafficEngineeringMetric, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = trafficEngineeringMetric.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getLinkSubTypeTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
- result = trafficEngineeringMetric.tlvBodyAsBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(trafficEngineeringMetric.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/UnreservedBandwidthTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/UnreservedBandwidthTest.java
deleted file mode 100644
index 268e09f..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/UnreservedBandwidthTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.isispacket.tlv.subtlv;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for UnreservedBandwidth.
- */
-public class UnreservedBandwidthTest {
-
- private final byte[] packet = {0, 0, 0, 1};
- private UnreservedBandwidth unreservedBandwidth;
- private TlvHeader header;
- private byte[] result;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- unreservedBandwidth = new UnreservedBandwidth(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- unreservedBandwidth = null;
- header = null;
- result = null;
- channelBuffer = null;
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(unreservedBandwidth.toString(), is(notNullValue()));
- }
-
- /**
- * Tests addUnReservedBandwidth() method.
- */
- @Test
- public void testAddUnReservedBandwidth() throws Exception {
- unreservedBandwidth.addUnReservedBandwidth(123456.78f);
- assertThat(unreservedBandwidth, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- header = new TlvHeader();
- header.setTlvLength(4);
- header.setTlvType(8);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- unreservedBandwidth = new UnreservedBandwidth(header);
- unreservedBandwidth.readFrom(channelBuffer);
- unreservedBandwidth.readFrom(channelBuffer);
- assertThat(unreservedBandwidth, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = unreservedBandwidth.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getLinkSubTypeTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
- result = unreservedBandwidth.asBytes();
- assertThat(result, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/util/ChecksumCalculatorTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/util/ChecksumCalculatorTest.java
deleted file mode 100644
index cdc4eaf..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/util/ChecksumCalculatorTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.util;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for ChecksumCalculator.
- */
-public class ChecksumCalculatorTest {
-
- private final byte[] l1Lsp = {
- -125, 27, 1, 0, 18, 1, 0, 0, 0, 86, 4, -81, 34, 34, 34,
- 34, 34, 34, 0, 0, 0, 0, 0, 9, 99, 11, 1, 1, 4, 3, 73,
- 0, 10, -127, 1, -52, -119, 2, 82, 50, -124, 4, -64, -88, 10, 1, -128,
- 24, 10, -128, -128, -128, 10, 0, 10, 0, -1, -1, -1, -4, 10, -128, -128,
- -128, -64, -88, 10, 0, -1, -1, -1, 0, 2, 12, 0, 10, -128, -128, -128,
- 51, 51, 51, 51, 51, 51, 2
- };
- private ChecksumCalculator calculator;
- private byte[] result;
- private boolean result1;
-
- @Before
- public void setUp() throws Exception {
- calculator = new ChecksumCalculator();
- }
-
- @After
- public void tearDown() throws Exception {
- calculator = null;
- }
-
- /**
- * Tests validateLspCheckSum() method.
- */
- @Test
- public void testValidateLspCheckSum() throws Exception {
- result1 = calculator.validateLspCheckSum(l1Lsp, IsisConstants.CHECKSUMPOSITION,
- IsisConstants.CHECKSUMPOSITION + 1);
-
- assertThat(result1, is(true));
- }
-
- /**
- * Tests calculateLspChecksum() method.
- */
- @Test
- public void testCalculateLspChecksum() throws Exception {
- result = calculator.calculateLspChecksum(l1Lsp, IsisConstants.CHECKSUMPOSITION,
- IsisConstants.CHECKSUMPOSITION + 1);
- assertThat(result[0],
- is(l1Lsp[IsisConstants.CHECKSUMPOSITION]));
- assertThat(result[1],
- is(l1Lsp[IsisConstants.CHECKSUMPOSITION + 1]));
- }
-}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/util/IsisUtilTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/util/IsisUtilTest.java
deleted file mode 100644
index de96972..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/util/IsisUtilTest.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.util;
-
-import com.google.common.primitives.Bytes;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.isis.controller.IsisPduType;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for IsisUtil.
- */
-public class IsisUtilTest {
-
- private final String systemId = "2929.2929.2929";
- private final String lanId = "2929.2929.2929.01";
- private final String areaAddress = "490001";
- private final byte[] l1Lsp = {
- -125, 27, 1, 0, 18, 1, 0, 0, 0, 86, 4, -81, 34, 34, 34,
- 34, 34, 34, 0, 0, 0, 0, 0, 9, 99, 11, 1, 1, 4, 3, 73,
- 0, 10, -127, 1, -52, -119, 2, 82, 50, -124, 4, -64, -88, 10, 1, -128,
- 24, 10, -128, -128, -128, 10, 0, 10, 0, -1, -1, -1, -4, 10, -128, -128,
- -128, -64, -88, 10, 0, -1, -1, -1, 0, 2, 12, 0, 10, -128, -128, -128,
- 51, 51, 51, 51, 51, 51, 2
- };
- private final byte[] intger = {0, 0, 0, 1};
- private Ip4Address ip4Address1 = Ip4Address.valueOf("10.10.10.10");
- private Ip4Address ip4Address2 = Ip4Address.valueOf("10.10.10.11");
- private Ip4Address mask = Ip4Address.valueOf("255.255.255.0");
- private boolean result;
- private String result1;
- private byte[] result2;
- private int result3;
- private long result4;
- private byte[] prefixBytes = {0, 0, 0, 1};
- private String prefix = "192.16.17";
-
- @Before
- public void setUp() throws Exception {
-
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
- /**
- * Tests sameNetwork() method.
- */
- @Test
- public void testSameNetwork() throws Exception {
- result = IsisUtil.sameNetwork(ip4Address1, ip4Address2, mask.toOctets());
- assertThat(result, is(true));
- }
-
- /**
- * Tests systemId() method.
- */
- @Test
- public void testSystemId() throws Exception {
- result1 = IsisUtil.systemId(Bytes.toArray(
- IsisUtil.sourceAndLanIdToBytes(systemId)));
- assertThat(result1, is(systemId));
- }
-
- /**
- * Tests systemIdPlus() method.
- */
- @Test
- public void testSystemIdPlus() throws Exception {
- result1 = IsisUtil.systemIdPlus(Bytes.toArray(
- IsisUtil.sourceAndLanIdToBytes(lanId)));
- assertThat(result1, is(lanId));
- }
-
- /**
- * Tests areaAddress() method.
- */
- @Test
- public void testAreaAddres() throws Exception {
- result1 = IsisUtil.areaAddress(Bytes.toArray(
- IsisUtil.areaAddressToBytes(areaAddress)));
- assertThat(result1, is(areaAddress));
- }
-
- /**
- * Tests areaAddressToBytes() method.
- */
- @Test
- public void testAreaAddressToBytes() throws Exception {
- result2 = Bytes.toArray(IsisUtil.areaAddressToBytes(areaAddress));
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests getPduHeaderLength() method.
- */
- @Test
- public void testGetPduHeaderLength() throws Exception {
- result3 = IsisUtil.getPduHeaderLength(IsisPduType.L1CSNP.value());
- assertThat(result3, is(33));
- result3 = IsisUtil.getPduHeaderLength(IsisPduType.L1PSNP.value());
- assertThat(result3, is(17));
- result3 = IsisUtil.getPduHeaderLength(IsisPduType.L1HELLOPDU.value());
- assertThat(result3, is(27));
- result3 = IsisUtil.getPduHeaderLength(IsisPduType.P2PHELLOPDU.value());
- assertThat(result3, is(20));
- }
-
- /**
- * Tests addLengthAndMarkItInReserved() method.
- */
- @Test
- public void testAddLengthAndMarkItInReserved() throws Exception {
- result2 = IsisUtil.addLengthAndMarkItInReserved(l1Lsp,
- IsisConstants.LENGTHPOSITION, IsisConstants.LENGTHPOSITION + 1,
- IsisConstants.RESERVEDPOSITION);
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests addChecksum() method.
- */
- @Test
- public void testAddChecksum() throws Exception {
- result2 = IsisUtil.addChecksum(l1Lsp,
- IsisConstants.CHECKSUMPOSITION, IsisConstants.CHECKSUMPOSITION + 1);
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests framePacket() method.
- */
- @Test
- public void testFramePacket() throws Exception {
- result2 = IsisUtil.framePacket(l1Lsp, 2);
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests sourceAndLanIdToBytes() method.
- */
- @Test
- public void testSourceAndLanIdToBytes() throws Exception {
- result2 = Bytes.toArray(IsisUtil.sourceAndLanIdToBytes(lanId));
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests getPaddingTlvs() method.
- */
- @Test
- public void testGetPaddingTlvs() throws Exception {
- result2 = IsisUtil.getPaddingTlvs(250);
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests convertToTwoBytes() method.
- */
- @Test
- public void testConvertToTwoBytes() throws Exception {
- result2 = IsisUtil.convertToTwoBytes(250);
- assertThat(result2.length, is(2));
- }
-
- /**
- * Tests convertToFourBytes() method.
- */
- @Test
- public void testConvertToFourBytes() throws Exception {
- result2 = IsisUtil.convertToFourBytes(250);
- assertThat(result2.length, is(4));
- }
-
- /**
- * Tests byteToInteger() method.
- */
- @Test
- public void testByteToInteger() throws Exception {
- result3 = IsisUtil.byteToInteger(intger);
- assertThat(result3, is(1));
- }
-
- /**
- * Tests byteToInteger() method.
- */
- @Test
- public void testByteToLong() throws Exception {
- result4 = IsisUtil.byteToLong(intger);
- assertThat(result4, is(1L));
- }
-
- /**
- * Tests convertToFourBytes() method.
- */
- @Test
- public void testConvertToFourBytes1() throws Exception {
- result2 = IsisUtil.convertToFourBytes(250L);
- assertThat(result2.length, is(4));
- }
-
- /**
- * Tests toFourBitBinary() method.
- */
- @Test
- public void testToEightBitBinary() throws Exception {
- result1 = IsisUtil.toEightBitBinary("01");
- assertThat(result1.length(), is(8));
- }
-
- /**
- * Tests toFourBitBinary() method.
- */
- @Test
- public void testToFourBitBinary() throws Exception {
- result1 = IsisUtil.toFourBitBinary("01");
- assertThat(result1.length(), is(4));
- }
-
- /**
- * Tests convertToThreeBytes() method.
- */
- @Test
- public void testConvertToThreeBytes() throws Exception {
- result2 = IsisUtil.convertToThreeBytes(30);
- assertThat(result2.length, is(3));
- }
-
- /**
- * Tests prefixConversion() method.
- */
- @Test
- public void testPrefixConversion() throws Exception {
- result1 = IsisUtil.prefixConversion(prefixBytes);
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests prefixToBytes() method.
- */
- @Test
- public void testPrefixToBytes() throws Exception {
- result2 = IsisUtil.prefixToBytes(prefix);
- assertThat(result2, is(notNullValue()));
- }
-}
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/util/LspGeneratorTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/util/LspGeneratorTest.java
deleted file mode 100644
index d2d7dae..0000000
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/util/LspGeneratorTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.io.util;
-
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisLsdb;
-import org.onosproject.isis.controller.IsisPduType;
-import org.onosproject.isis.io.isispacket.IsisHeader;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for LspGenerator.
- */
-public class LspGeneratorTest {
- private LspGenerator generator;
- private IsisHeader isisHeader;
- private IsisInterface isisInterface;
- private IsisLsdb isisLsdb;
-
- @Before
- public void setUp() throws Exception {
- generator = new LspGenerator();
- isisLsdb = EasyMock.createMock(IsisLsdb.class);
- isisInterface = EasyMock.createMock(IsisInterface.class);
- }
-
- @After
- public void tearDown() throws Exception {
- generator = null;
- }
-
- /**
- * Tests getHeader() method.
- */
- @Test
- public void testGetHeader() throws Exception {
- isisHeader = generator.getHeader(IsisPduType.L1CSNP);
- assertThat(isisHeader, is(instanceOf(IsisHeader.class)));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/BUILD b/protocols/ospf/api/BUILD
deleted file mode 100644
index 9e01912..0000000
--- a/protocols/ospf/api/BUILD
+++ /dev/null
@@ -1,7 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
- "@io_netty_netty//jar",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/DeviceInformation.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/DeviceInformation.java
deleted file mode 100644
index b63926f..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/DeviceInformation.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import org.onlab.packet.Ip4Address;
-
-import java.util.List;
-
-/**
- * Representation of an OSPF device information.
- */
-public interface DeviceInformation {
-
- /**
- * Gets router id.
- *
- * @return router id
- */
- Ip4Address routerId();
-
- /**
- * Sets router id.
- *
- * @param routId router id
- */
- void setRouterId(Ip4Address routId);
-
- /**
- * Gets device id.
- *
- * @return device id
- */
- Ip4Address deviceId();
-
- /**
- * Sets device id.
- *
- * @param deviceId device id
- */
- void setDeviceId(Ip4Address deviceId);
-
- /**
- * Gets list of interface ids.
- *
- * @return list of interface ids
- */
- List<Ip4Address> interfaceId();
-
- /**
- * Adds interface id to list.
- *
- * @param interfaceId interface id
- */
- void addInterfaceId(Ip4Address interfaceId);
-
- /**
- * Gets area id.
- *
- * @return area id
- */
- Ip4Address areaId();
-
- /**
- * Sets area id.
- *
- * @param areaId area id
- */
- void setAreaId(Ip4Address areaId);
-
- /**
- * Gets device information is already created or not.
- *
- * @return true if device information is already created else false
- */
- boolean isAlreadyCreated();
-
- /**
- * Sets device information is already created or not.
- *
- * @param alreadyCreated true if device information is already created else false
- */
- void setAlreadyCreated(boolean alreadyCreated);
-
- /**
- * Gets device is dr or not.
- *
- * @return true if device is dr else false
- */
- boolean isDr();
-
- /**
- * Sets device is dr or not.
- *
- * @param dr true if device is dr else false
- */
- void setDr(boolean dr);
-
- /**
- * Gets neighbor id.
- *
- * @return neighbor id
- */
- Ip4Address neighborId();
-
- /**
- * Sets neighbor id.
- *
- * @param neighborId neighbor id
- */
- void setNeighborId(Ip4Address neighborId);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LinkInformation.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LinkInformation.java
deleted file mode 100644
index 4bd9c67..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LinkInformation.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import org.onlab.packet.Ip4Address;
-
-/**
- * Representation of an OSPF link information.
- */
-public interface LinkInformation {
-
- /**
- * Gets link id.
- *
- * @return link id
- */
- String linkId();
-
- /**
- * Sets link id.
- *
- * @param linkId link id
- */
- void setLinkId(String linkId);
-
- /**
- * Gets link information is already created or not.
- *
- * @return true if link information is already created else false
- */
- boolean isAlreadyCreated();
-
- /**
- * Sets link information is already created or not.
- *
- * @param alreadyCreated true if link information is already created else false
- */
- void setAlreadyCreated(boolean alreadyCreated);
-
- /**
- * Gets is link source id is same as router id or not.
- *
- * @return true if link source id is not same as router id else false
- */
- boolean isLinkSrcIdNotRouterId();
-
- /**
- * Sets is link source id is same as router id or not.
- *
- * @param linkSrcIdNotRouterId true if link source id is not same as router id else false
- */
- void setLinkSrcIdNotRouterId(boolean linkSrcIdNotRouterId);
-
- /**
- * Gets link destination id.
- *
- * @return link destination id
- */
- Ip4Address linkDestinationId();
-
- /**
- * Sets link destination id.
- *
- * @param linkDestinationId link destination id
- */
- void setLinkDestinationId(Ip4Address linkDestinationId);
-
- /**
- * Gets link source id.
- *
- * @return link source id
- */
- Ip4Address linkSourceId();
-
- /**
- * Sets link source id.
- *
- * @param linkSourceId link source id
- */
- void setLinkSourceId(Ip4Address linkSourceId);
-
- /**
- * Gets interface ip address.
- *
- * @return interface ip address
- */
- Ip4Address interfaceIp();
-
- /**
- * Sets interface ip address.
- *
- * @param interfaceIp interface ip address
- */
- void setInterfaceIp(Ip4Address interfaceIp);
-
- /**
- * Gets link source ip address.
- *
- * @return link source ip address
- */
- Ip4Address linkSourceIpAddress();
-
- /**
- * Sets link source ip address.
- *
- * @param linkSourceIpAddress link source ip address
- */
- void setLinkSourceIpAddress(Ip4Address linkSourceIpAddress);
-
- /**
- * Gets link destination ip address.
- *
- * @return link destination ip address
- */
- Ip4Address linkDestinationIpAddress();
-
- /**
- * Sets link destination ip address.
- *
- * @param linkDestinationIpAddress link destination ip address
- */
- void setLinkDestinationIpAddress(Ip4Address linkDestinationIpAddress);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsaBin.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsaBin.java
deleted file mode 100644
index 5f9fdc7..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsaBin.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import java.util.Map;
-
-/**
- * Representation of a bin where an LSA is stored for aging.
- * A bin is identified by a bin number and can have one or more LSAs
- * stored in a particular bin location.
- */
-public interface LsaBin {
-
- /**
- * Adds the given LSA to this bin with the given key.
- *
- * @param lsaKey key of the stored LSA
- * @param lsaWrapper wrapper instance to store
- */
- public void addOspfLsa(String lsaKey, LsaWrapper lsaWrapper);
-
- /**
- * Retrieves the LSA from the bin for verification of max age and ls refresh.
- *
- * @param lsaKey key to search the LSA
- * @return LSA Wrapper instance
- */
- public LsaWrapper ospfLsa(String lsaKey);
-
- /**
- * Removes the given LSA from the bin. when ever it reaches max age or ls refresh time.
- *
- * @param lsaKey key to search LSA
- * @param lsaWrapper wrapper instance of the particular LSA
- */
- public void removeOspfLsa(String lsaKey, LsaWrapper lsaWrapper);
-
- /**
- * Gets the list of LSAs in this bin as key value pair.
- * with key being the LSA key formed from the LSA header.
- *
- * @return list of LSAs in this bin as key value pair
- */
- public Map<String, LsaWrapper> listOfLsa();
-
- /**
- * Gets the bin number assigned during the initialization process of the bins .
- *
- * @return the bin number
- */
- public int binNumber();
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsaWrapper.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsaWrapper.java
deleted file mode 100644
index caf99f3..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsaWrapper.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-/**
- * Representation of a wrapper object to store LSA and associated metadata.
- * Metadata consists about the origination of LSA, age of LSA when received etc.
- */
-public interface LsaWrapper {
- /**
- * Gets the type of LSA, it can be a router,network,summary,external.
- *
- * @return lsa type
- */
- public OspfLsaType lsaType();
-
- /**
- * Sets the LSA type during the initialization of wrapper.
- *
- * @param lsaType lsa type
- */
- public void setLsaType(OspfLsaType lsaType);
-
- /**
- * Determines the origination of LSA , this is called during ls refresh interval.
- *
- * @return true if self originated else false
- */
- public boolean isSelfOriginated();
-
- /**
- * Sets is self originated or not.
- *
- * @param isSelfOriginated true if self originated else false
- */
- public void setIsSelfOriginated(boolean isSelfOriginated);
-
-
- /**
- * Age of LSA when received during the adjacency formation.
- *
- * @return Age of LSA when received
- */
- public int lsaAgeReceived();
-
- /**
- * Sets the Age of LSA when received during the adjacency formation.
- *
- * @param lsaAgeReceived Age of LSA when received
- */
- public void setLsaAgeReceived(int lsaAgeReceived);
-
- /**
- * Gets the LSA present in the wrapper instance.
- *
- * @return LSA instance
- */
- public OspfLsa ospfLsa();
-
- /**
- * Sets the LSA instance to the wrapper.
- *
- * @param ospfLsa LSA instance
- */
- public void setOspfLsa(OspfLsa ospfLsa);
-
- /**
- * Gets the current LSA Age, using this we calculate current age.
- * It is done against the age counter which is incremented every second.
- *
- * @return lsa age
- */
- public int currentAge();
-
- /**
- * Gets the age counter when received.
- *
- * @return the age counter when received
- */
- public int ageCounterWhenReceived();
-
- /**
- * Sets the age counter when received.
- *
- * @param ageCounterWhenReceived the age counter when received
- */
- public void setAgeCounterWhenReceived(int ageCounterWhenReceived);
-
- /**
- * Gets the LSA process command, like max age, ls refresh, based on the command set.
- * The queue consumer will pick the LSA and start performing the actions, like flooding
- * out of the domain or generating a new LSA and flooding.
- *
- * @return lsa process command
- */
- public String lsaProcessing();
-
- /**
- * Sets the LSA process command, like max age , ls refresh , based on the command set.
- * The queue consumer will pick the LSA and start performing the actions, like flooding
- * out of the domain or generating a new LSA and flooding.
- *
- * @param lsaProcessing lsa process command
- */
- public void setLsaProcessing(String lsaProcessing);
-
- /**
- * Gets bin number into which the LSA wrapper is put for aging process.
- *
- * @return bin number
- */
- public int binNumber();
-
- /**
- * Sets bin number into which the LSA wrapper is put for aging process.
- *
- * @param binNumber bin number
- */
- public void setBinNumber(int binNumber);
-
- /**
- * Gets the interface on which the LSA was received.
- *
- * @return the interface instance
- */
- public OspfInterface ospfInterface();
-
- /**
- * Sets the interface on which the LSA was received, this is used later to flood the information.
- *
- * @param ospfInterface interface instance
- */
- public void setOspfInterface(OspfInterface ospfInterface);
-
- /**
- * Sets the LSDB age.
- * Using LSDB age we are calculating age of a particular LSA.
- *
- * @param lsdbAge lsdbAge instance
- */
- public void setLsdbAge(LsdbAge lsdbAge);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsdbAge.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsdbAge.java
deleted file mode 100644
index 120bcd5..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsdbAge.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-/**
- * Representation of LSDB aging process.
- * The age of each LSA in the database must be incremented by 1 each second.
- * We put all the LSAs of a given age into a single bin. The age of an LSA is the
- * difference between its age bin and the bin representing LS age 0.
- */
-public interface LsdbAge {
-
- /**
- * Adds LSA to bin for aging.
- *
- * @param binKey key to store the LSA in bin
- * @param lsaBin LSA bin instance
- */
- public void addLsaBin(Integer binKey, LsaBin lsaBin);
-
- /**
- * Gets LSA from bin, this method is used while processing ls refresh and max age on LSA.
- *
- * @param binKey key to retrieve the LSA from bin
- * @return lsaBin bin instance
- */
- public LsaBin getLsaBin(Integer binKey);
-
- /**
- * Adds the lsa to maxAge bin if LSAs age is max age.
- *
- * @param key key to store the LSA in bin.
- * @param wrapper wrapper instance which contains LSA
- */
- public void addLsaToMaxAgeBin(String key, LsaWrapper wrapper);
-
- /**
- * Gets the bin number out of LSAs age, in which the LSA can be placed.
- * so that age can be calculated.
- *
- * @param x Can be either age or ageCounter
- * @return bin number.
- */
- public int age2Bin(int x);
-
- /**
- * Gets the max age bin, a special bin is created which holds only max age LSAs.
- *
- * @return lsa bin instance
- */
- public LsaBin getMaxAgeBin();
-
- /**
- * Gets the age counter.
- *
- * @return age counter
- */
- public int getAgeCounter();
-
-
- /**
- * Refresh the LSAs which are in the refresh bin.
- */
- public void refreshLsa();
-
- /**
- * If the LSAs have completed the MaxAge stop aging and flood it.
- */
- public void maxAgeLsa();
-
- /**
- * Invoked every 1 second as part of the aging process, and increments age counter.
- * It also verifies if any LSA has reached ls refresh time or max age.
- */
- public void ageLsaAndFlood();
-
- /**
- * Starts the aging timer thread which gets invokes every second.
- */
- public void startDbAging();
-
- /**
- * Removes LSA from Bin, when ever it reaches a max age or ls refresh time.
- *
- * @param lsaWrapper wrapper instance
- */
- public void removeLsaFromBin(LsaWrapper lsaWrapper);
-
- /**
- * Gets the age counter roll over.
- *
- * @return the age counter roll over
- */
- public int getAgeCounterRollOver();
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfAgent.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfAgent.java
deleted file mode 100644
index e2b878df..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfAgent.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-/**
- * Representation of an OSPF agent.
- * It is responsible for keeping track of the current set of routers
- * connected to the system.
- */
-public interface OspfAgent {
-
- /**
- * Adds a router that has just connected to the system.
- *
- * @param ospfRouter the router id to add
- * @return true if added, false otherwise
- */
- boolean addConnectedRouter(OspfRouter ospfRouter);
-
- /**
- * Removes the router which got disconnected from the system.
- *
- * @param ospfRouter the router id to remove
- */
- void removeConnectedRouter(OspfRouter ospfRouter);
-
- /**
- * Notifies that got a packet of link from network and need to add the link.
- *
- * @param ospfRouter router instance
- * @param ospfLinkTed link TED instance
- */
- void addLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed);
-
- /**
- * Notifies that got a packet of link from network and need do delete the link.
- *
- * @param ospfRouter router instance
- * @param ospfLinkTed link TED instance
- */
- void deleteLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java
deleted file mode 100644
index a66160d..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import org.onlab.packet.Ip4Address;
-
-import java.util.List;
-
-/**
- * Representation of an OSPF area. OSPF areas are collections of network segments.
- * The configuration of OSPF area consists of assigning an area id to each network segment.
- * Each area has its own link state database.
- */
-public interface OspfArea {
-
- /**
- * Gets the router id associated with the area.
- *
- * @return router id
- */
- Ip4Address routerId();
-
- /**
- * Sets the router id for this area.
- *
- * @param routerId router's ip address
- */
- void setRouterId(Ip4Address routerId);
-
- /**
- * Gets the area id.
- *
- * @return area id
- */
- Ip4Address areaId();
-
- /**
- * Sets the area id.
- *
- * @param areaId area id as an IPv4 address
- */
- void setAreaId(Ip4Address areaId);
-
- /**
- * Gets the LSDB instance for this area.
- *
- * @return LSDB instance for this area
- */
- OspfLsdb database();
-
- /**
- * Checks whether an instance of the given LSA exists in the database.
- *
- * @param lookupLsa LSA instance to lookup
- * @return LSA wrapper instance which contains the LSA
- */
- LsaWrapper lsaLookup(OspfLsa lookupLsa);
-
- /**
- * Initializes link state database, this acts as a place holder for storing the received LSA.
- */
- void initializeDb();
-
- /**
- * Sets the options value.
- *
- * @param options integer value
- */
- void setOptions(int options);
-
- /**
- * Gets external routing capability.
- * This indicates Whether AS-external-LSAs will be flooded into/throughout the area.
- *
- * @return true if external routing capable, else false
- */
- boolean isExternalRoutingCapability();
-
- /**
- * Sets external routing capability.
- * This indicates Whether AS-external-LSAs will be flooded into/throughout the area.
- *
- * @param externalRoutingCapability true if external routing capable, else false
- */
- void setExternalRoutingCapability(boolean externalRoutingCapability);
-
- /**
- * Gets if the router is opaque enabled or not.
- * This indicates whether the router accepts opaque LSA.
- *
- * @return true if opaque enabled else false
- */
- boolean isOpaqueEnabled();
-
- /**
- * Gets the list of interfaces attached to this area.
- *
- * @return list of interfaces
- */
- List<OspfInterface> ospfInterfaceList();
-
- /**
- * Sets the list of interfaces attached to this area.
- *
- * @param interfacesLst list of interface instances
- */
- void setOspfInterfaceList(List<OspfInterface> interfacesLst);
-
- /**
- * Gets the options value, which indicates the supported optional capabilities.
- *
- * @return options value
- */
- int options();
-
- /**
- * Gets the opaque enabled options value, which indicates support of opaque capabilities.
- *
- * @return opaque enabled options value
- */
- int opaqueEnabledOptions();
-
- /**
- * Sets opaque enabled to true or false, which indicates whether the router accepts opaque LSA.
- *
- * @param isOpaqueEnable true if opaque enabled else false
- */
- void setIsOpaqueEnabled(boolean isOpaqueEnable);
-
- /**
- * Refreshes areas, by sending a router LSA and network LSA (in case of DR).
- * with a new sequence number.
- *
- * @param ospfInterface interface instance
- */
- void refreshArea(OspfInterface ospfInterface);
-
- /**
- * Verifies no neighbor is in exchange process.
- *
- * @return boolean indicating that there is no Neighbor in Database Exchange
- */
- boolean noNeighborInLsaExchangeProcess();
-
- /**
- * Checks whether an instance of the given LSA exists in the database belonging to this area.
- * If so return true else false.
- *
- * @param lsa1 LSA instance to compare
- * @param lsa2 LSA instance to compare
- * @return "same" if both instances are same, "latest" if lsa1 is latest, or "old" if lsa1 is old
- */
- String isNewerOrSameLsa(OspfLsa lsa1, OspfLsa lsa2);
-
- /**
- * Whenever we receive an LSA with max age - we put it in the max age bin.
- * This is later used to flush LSAs out of the routing domain.
- *
- * @param key key to add it to LSDB
- * @param wrapper LSA wrapper instance
- */
- void addLsaToMaxAgeBin(String key, LsaWrapper wrapper);
-
- /**
- * Whenever an LSA is being flushed out or reaches max age, it must be stopped from aging.
- * This achieved by removing it from bin.
- *
- * @param lsaWrapper the LSA wrapper instance to delete
- */
- void removeLsaFromBin(LsaWrapper lsaWrapper);
-
- /**
- * Adds the received LSA to LSDB, this method creates an LSA wrapper for the LSA.
- * Also adds it to the LSDB of the area. This method is specifically called for
- * the self originated LSAs.
- *
- * @param ospfLsa LSA instance
- * @param isSelfOriginated true if the LSA is self originated else false
- * @param ospfInterface interface instance
- */
- void addLsa(OspfLsa ospfLsa, boolean isSelfOriginated, OspfInterface ospfInterface);
-
- /**
- * Adds the received LSA to LSDB,this method creates an LSA wrapper for the LSA.
- * Adds it to the LSDB of the area.
- *
- * @param ospfLsa LSA instance
- * @param ospfInterface interface instance
- */
- void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface);
-
- /**
- * Sets router sequence number for router LSA.
- *
- * @param newSequenceNumber sequence number
- */
- void setDbRouterSequenceNumber(long newSequenceNumber);
-
- /**
- * Gets LSA header of all types of LSAs present in the link state database.
- *
- * @param excludeMaxAgeLsa need to include(true) or exclude(false) max age LSA
- * @param isOpaqueCapable need to include(true) or exclude(false) type 10 Opaque LSA
- * @return list of LSA header in the LSDB
- */
- List getLsaHeaders(boolean excludeMaxAgeLsa, boolean isOpaqueCapable);
-
- /**
- * Gets the LSA wrapper from link state database based on the parameters passed.
- *
- * @param lsType type of LSA to form the key
- * @param linkStateID link state id to form the key
- * @param advertisingRouter advertising router to form the key
- * @return LSA wrapper instance which contains the LSA
- */
- LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter);
-
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfAreaAddressRange.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfAreaAddressRange.java
deleted file mode 100644
index 2897d5a..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfAreaAddressRange.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import org.onlab.packet.Ip4Address;
-
-/**
- * Represents the collection of IP addresses contained in the address range.
- */
-public interface OspfAreaAddressRange {
-
- /**
- * Gets the IP address.
- *
- * @return IP address
- */
- public Ip4Address ipAddress();
-
- /**
- * Sets the IP address.
- *
- * @param ipAddress IPv4 address
- */
- public void setIpAddress(Ip4Address ipAddress);
-
- /**
- * Gets the network mask.
- *
- * @return network mask
- */
- public String mask();
-
- /**
- * Sets the network mask.
- *
- * @param mask network mask
- */
- public void setMask(String mask);
-
- /**
- * Gets the advertise value, which indicates routing information is condensed at area boundaries.
- *
- * @return advertise true if advertise flag is set else false
- */
- public boolean isAdvertise();
-
- /**
- * Sets the advertise value, which indicates routing information is condensed at area boundaries.
- *
- * @param advertise true if advertise flag to set else false
- */
- public void setAdvertise(boolean advertise);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfController.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfController.java
deleted file mode 100644
index 3435f95..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfController.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Abstraction of an OSPF controller.
- * Serves as a one stop shop for obtaining OSPF devices and (un)register listeners on OSPF events.
- */
-public interface OspfController {
-
- /**
- * Registers a listener for router meta events.
- *
- * @param listener the listener to notify
- */
- void addRouterListener(OspfRouterListener listener);
-
- /**
- * Unregisters a router listener.
- *
- * @param listener the listener to unregister
- */
- void removeRouterListener(OspfRouterListener listener);
-
- /**
- * Registers a listener for OSPF message events.
- *
- * @param listener the listener to notify
- */
- void addLinkListener(OspfLinkListener listener);
-
- /**
- * Unregisters a link listener.
- *
- * @param listener the listener to unregister
- */
- void removeLinkListener(OspfLinkListener listener);
-
- /**
- * Updates configuration of processes.
- *
- * @param processesNode process info to update
- */
- void updateConfig(JsonNode processesNode);
-
- /**
- * Deletes configuration parameters.
- *
- * @param processes list of process instance
- * @param attribute attribute to delete
- */
- void deleteConfig(List<OspfProcess> processes, String attribute);
-
- /**
- * Gets the list of listeners registered for router events.
- *
- * @return list of listeners
- */
- Set<OspfRouterListener> listener();
-
- /**
- * Gets the list of listeners registered for link events.
- *
- * @return list of listeners
- */
- public Set<OspfLinkListener> linkListener();
-
- /**
- * Gets the configured process.
- *
- * @return list of process instances
- */
- public List<OspfProcess> getAllConfiguredProcesses();
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfDeviceTed.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfDeviceTed.java
deleted file mode 100644
index 58c8876..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfDeviceTed.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip6Address;
-
-import java.util.List;
-
-/**
- * Represents Device Traffic Engineering parameters.
- */
-public interface OspfDeviceTed {
-
- /**
- * Obtain list of IPv4 router ids.
- *
- * @return IPv4 router ids
- */
- public List<Ip4Address> ipv4RouterIds();
-
- /**
- * Sets list of IPv4 router ids.
- *
- * @param routerIds list of IPv4 router ids
- */
- public void setIpv4RouterIds(List<Ip4Address> routerIds);
-
- /**
- * Obtain list of IPv6 router id.
- *
- * @return IPv4 router ids
- */
- public List<Ip6Address> ipv6RouterIds();
-
- /**
- * Sets list of IPv4 router ids.
- *
- * @param routerIds list of IPv4 router ids
- */
- public void setIpv6RouterIds(List<Ip6Address> routerIds);
-
- /**
- * Obtain the list of topology ids.
- *
- * @return list of topology ids
- */
- public List<Short> topologyIds();
-
- /**
- * Sets the list of topology ids.
- *
- * @param topologyIds the list of topology ids
- */
- public void setTopologyIds(List<Short> topologyIds);
-
- /**
- * Obtains position of device in the network.
- *
- * @return position of device in the network
- */
- public Boolean asbr();
-
- /**
- * Sets position of device in the network.
- *
- * @param asbr position of device in the network
- */
- public void setAsbr(Boolean asbr);
-
- /**
- * Obtains position of device in the network.
- *
- * @return position of device in the network
- */
- public Boolean abr();
-
- /**
- * Sets position of device in the network.
- *
- * @param abr position of device in the network
- */
- public void setAbr(Boolean abr);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java
deleted file mode 100644
index 1c05ad5..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.onlab.packet.Ip4Address;
-
-import java.util.Map;
-
-/**
- * Represents an OSPF Interface.
- */
-public interface OspfInterface {
-
- /**
- * Returns interface index.
- *
- * @return interface index
- */
- public int interfaceIndex();
-
- /**
- * Sets interface index.
- *
- * @param interfaceIndex interface index
- */
- public void setInterfaceIndex(int interfaceIndex);
-
- /**
- * Returns OSPF area instance.
- *
- * @return OSPF area instance
- */
- public OspfArea ospfArea();
-
- /**
- * Sets OSPF area instance.
- *
- * @param ospfArea OSPF area instance
- */
- public void setOspfArea(OspfArea ospfArea);
-
- /**
- * Gets network mask of the interface.
- *
- * @return network mask
- */
- Ip4Address ipNetworkMask();
-
- /**
- * Sets the value of BDR.
- * The BDR is calculated during adjacency formation.
- *
- * @param bdr backup designated router's IP address
- */
- void setBdr(Ip4Address bdr);
-
- /**
- * Sets the value of DR.
- * The DR is calculated during adjacency formation.
- *
- * @param dr designated router's IP address
- */
- void setDr(Ip4Address dr);
-
- /**
- * Sets the hello interval time.
- * It is the interval at which a hello packet is sent out via this interface.
- *
- * @param helloIntervalTime an integer interval time
- */
- void setHelloIntervalTime(int helloIntervalTime);
-
- /**
- * Sets router dead interval time.
- * This is the interval after which this interface will trigger a process to kill neighbor.
- *
- * @param routerDeadIntervalTime an integer interval time
- */
- void setRouterDeadIntervalTime(int routerDeadIntervalTime);
-
- /**
- * Sets interface type.
- * This indicates whether the interface is on point to point mode or broadcast mode.
- *
- * @param interfaceType an integer represents interface type
- */
- void setInterfaceType(int interfaceType);
-
- /**
- * Sets IP Address of this interface.
- *
- * @param ipAddress IP address
- */
- void setIpAddress(Ip4Address ipAddress);
-
- /**
- * Sets IP network mask.
- *
- * @param ipNetworkMask network mask
- */
- void setIpNetworkMask(Ip4Address ipNetworkMask);
-
- /**
- * Sets retransmit interval which indicates the number of seconds between LSA retransmissions.
- *
- * @param reTransmitInterval an integer represents interval
- */
- void setReTransmitInterval(int reTransmitInterval);
-
- /**
- * Sets MTU.
- *
- * @param mtu an integer represents max transfer unit
- */
- void setMtu(int mtu);
-
- /**
- * Sets router priority.
- *
- * @param routerPriority value
- */
- void setRouterPriority(int routerPriority);
-
- /**
- * Gets the IP address.
- *
- * @return an string represents IP address
- */
- Ip4Address ipAddress();
-
- /**
- * Gets the interface type.
- *
- * @return an integer represents interface type
- */
- int interfaceType();
-
- /**
- * Gets the MTU.
- *
- * @return an integer representing max transfer unit
- */
- int mtu();
-
- /**
- * Gets the list of neighbors associated with the interface.
- *
- * @return listOfNeighbors as key value pair
- */
- Map<String, OspfNbr> listOfNeighbors();
-
- /**
- * Gets the IP address of the BDR.
- *
- * @return bdr BDR's IP address
- */
- Ip4Address bdr();
-
- /**
- * Gets the ip address of the DR..
- *
- * @return dr DR's IP address
- */
- Ip4Address dr();
-
- /**
- * Gets hello interval time in seconds, this defines how often we send the hello packet.
- *
- * @return hello interval time in seconds
- */
- int helloIntervalTime();
-
- /**
- * Gets retransmit interval.
- *
- * @return reTransmitInterval an integer represents interval
- */
- int reTransmitInterval();
-
- /**
- * Gets router dead interval time.
- * This defines how long we should wait for hello packets before we declare the neighbor is dead.
- *
- * @return routerDeadIntervalTime an integer interval time
- */
- int routerDeadIntervalTime();
-
- /**
- * Gets router priority.
- *
- * @return routerPriority value
- */
- int routerPriority();
-
- /**
- * Adds the given neighboring router to the neighbor map.
- *
- * @param ospfNbr neighbor instance
- */
- void addNeighbouringRouter(OspfNbr ospfNbr);
-
- /**
- * Gets the neighbor instance from listOfNeighbors map for the given neighbor ID.
- *
- * @param neighborId neighbors id
- * @return ospfNbr neighbor instance
- */
- OspfNbr neighbouringRouter(String neighborId);
-
- /**
- * Checks the given neighbor is in the neighbor list.
- *
- * @param neighborId neighbors id
- * @return true if neighbor in list else false
- */
- boolean isNeighborInList(String neighborId);
-
- /**
- * Removes LSA headers from the map in which LSA headers are stored.
- *
- * @param lsaKey key used to store lsa in map
- */
- void removeLsaFromNeighborMap(String lsaKey);
-
- /**
- * When an OSPF message received it is handed over to this method.
- * Based on the type of the OSPF message received it will be handed over
- * to corresponding message handler methods.
- *
- * @param ospfMessage received OSPF message
- * @param ctx channel handler context instance.
- */
- void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx);
-
- /**
- * Represents an interface is up and connected.
- */
- void interfaceUp();
-
- /**
- * Starts the timer which waits for configured seconds and sends Delayed Ack Packet.
- */
- void startDelayedAckTimer();
-
- /**
- * Stops the delayed acknowledge timer.
- */
- void stopDelayedAckTimer();
-
- /**
- * Starts the hello timer which sends hello packet every configured seconds.
- */
- void startHelloTimer();
-
- /**
- * Stops the hello timer.
- */
- void stopHelloTimer();
-
- /**
- * Gets called when an interface is down.
- * All interface variables are reset, and interface timers disabled.
- * Also all neighbor connections associated with the interface are destroyed.
- */
- void interfaceDown();
-
- /**
- * Removes all the neighbors.
- */
- void removeNeighbors();
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLink.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLink.java
deleted file mode 100644
index b5b5176..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLink.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import org.onlab.packet.IpAddress;
-
-import java.util.List;
-
-/**
- * Abstraction of an OSPF Link.
- */
-public interface OspfLink {
-
- /**
- * Gets IP address of the Router.
- *
- * @return IP address of router
- */
- IpAddress remoteRouterId();
-
- /**
- * Gets the area id for this device.
- *
- * @return the area id
- */
- int areaIdOfInterface();
-
- /**
- * Gets IP address of the interface.
- *
- * @return IP address of the interface
- */
- IpAddress interfaceIp();
-
- /**
- * Gets list of the link TED.
- *
- * @return list of the link TED
- */
- List<OspfLinkTed> linkTedLists();
-
- /**
- * Sets IP address of the router.
- *
- * @param routerIp router's IP address
- */
- void setRouterIp(IpAddress routerIp);
-
- /**
- * Sets the area id for this device.
- *
- * @param areaIdOfInterface area id
- */
- void setAreaIdOfInterface(int areaIdOfInterface);
-
- /**
- * Sets IP address of the interface.
- *
- * @param interfaceIp IP address of the interface.
- */
- void setInterfaceIp(IpAddress interfaceIp);
-
- /**
- * Sets list of the link TED.
- *
- * @param linkTedLists list of the link TED
- */
- void setLinkTedLists(List<OspfLinkTed> linkTedLists);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLinkListener.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLinkListener.java
deleted file mode 100644
index 7bbaf7d..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLinkListener.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-/**
- * Abstraction of an OSPF link listener.
- */
-public interface OspfLinkListener {
-
- /**
- * Notifies that we got a link from network.
- *
- * @param ospfRouter router instance
- * @param ospfLinkTed link TED information of router
- */
- void addLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed);
-
- /**
- * Notifies that a link got removed from network.
- *
- * @param ospfRouter router instance
- * @param ospfLinkTed link TED information of router
- */
- void deleteLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLinkTed.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLinkTed.java
deleted file mode 100644
index f0e5614..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLinkTed.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip6Address;
-import org.onlab.util.Bandwidth;
-
-import java.util.List;
-
-/**
- * Represents OSPF Link Traffic Engineering parameters.
- */
-public interface OspfLinkTed {
-
- /**
- * Provides maximum bandwidth can be used on the link.
- *
- * @return maximum bandwidth
- */
- public Bandwidth maximumLink();
-
- /**
- * Sets maximum band width.
- *
- * @param bandwidth maximum bandwidth
- */
- public void setMaximumLink(Bandwidth bandwidth);
-
- /**
- * Amount of bandwidth reservable on the link.
- *
- * @return unreserved bandwidth
- */
- public List<Bandwidth> maxUnResBandwidth();
-
- /**
- * Sets max bandwidth that is not reserved on the link.
- *
- * @param bandwidth max bandwidth that is not reserved on the link
- */
- public void setMaxUnResBandwidth(Bandwidth bandwidth);
-
- /**
- * Provides max bandwidth that can be reserved on the link.
- *
- * @return max bandwidth reserved
- */
- public Bandwidth maxReserved();
-
- /**
- * Sets max bandwidth that can be reserved on the link.
- *
- * @param bandwidth max bandwidth that can be reserved on the link
- */
- public void setMaxReserved(Bandwidth bandwidth);
-
- /**
- * Provides Traffic Engineering metric for the link.
- *
- * @return Traffic Engineering metric
- */
- public Integer teMetric();
-
- /**
- * Sets Traffic Engineering metric for the link.
- *
- * @param teMetric Traffic Engineering metric for the link
- */
- public void setTeMetric(Integer teMetric);
-
- /**
- * Provides IPv4 router-Id of local node.
- *
- * @return IPv4 router-Id of local node
- */
- public List<Ip4Address> ipv4LocRouterId();
-
- /**
- * Sets IPv4 router-Id of local node.
- *
- * @param routerIds IPv4 router-Id of local node
- */
- public void setIpv4LocRouterId(List<Ip4Address> routerIds);
-
- /**
- * Provides IPv6 router-Id of local node.
- *
- * @return IPv6 router-Id of local node
- */
- public List<Ip6Address> ipv6LocRouterId();
-
- /**
- * Sets IPv6 router-Id of local node.
- *
- * @param routerIds IPv6 router-Id of local node
- */
- public void setIpv6LocRouterId(List<Ip6Address> routerIds);
-
- /**
- * Provides IPv4 router-Id of remote node.
- *
- * @return IPv4 router-Id of remote node
- */
- public List<Ip4Address> ipv4RemRouterId();
-
- /**
- * Sets IPv4 router-Id of remote node.
- *
- * @param routerIds IPv4 router-Id of remote node
- */
- public void setIpv4RemRouterId(List<Ip4Address> routerIds);
-
- /**
- * Provides IPv6 router-Id of remote node.
- *
- * @return IPv6 router-Id of remote node
- */
- public List<Ip6Address> ipv6RemRouterId();
-
- /**
- * Sets IPv6 router-Id of remote node.
- *
- * @param routerIds IPv6 router-Id of remote node
- */
- public void setIpv6RemRouterId(List<Ip6Address> routerIds);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLsa.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLsa.java
deleted file mode 100644
index c9d37fc..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLsa.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-/**
- * Represents an OSPF LSA.
- */
-public interface OspfLsa {
-
- /**
- * Gets the type of OSPF LSA.
- *
- * @return OSPF LSA type instance
- */
- OspfLsaType getOspfLsaType();
-
- /**
- * Gets the age of LSA.
- *
- * @return age of LSA
- */
- int age();
-
- /**
- * Gets the LSA header instance.
- *
- * @return this instance
- */
- public OspfLsa lsaHeader();
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLsaType.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLsaType.java
deleted file mode 100644
index db05055..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLsaType.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-/**
- * Represents OSPF LSA types.
- */
-public enum OspfLsaType {
-
- ROUTER(1),
- NETWORK(2),
- SUMMARY(3),
- ASBR_SUMMARY(4),
- EXTERNAL_LSA(5),
- LINK_LOCAL_OPAQUE_LSA(9),
- AREA_LOCAL_OPAQUE_LSA(10),
- AS_OPAQUE_LSA(11),
- UNDEFINED(20);
-
- private int value;
-
- /**
- * Creates an instance of OSPF LSA type.
- *
- * @param value represents LSA type
- */
- OspfLsaType(int value) {
- this.value = value;
- }
-
- /**
- * Gets the value representing LSA type.
- *
- * @return value represents LSA type
- */
- public int value() {
- return value;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLsdb.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLsdb.java
deleted file mode 100644
index 3d3c170..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLsdb.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import java.util.List;
-
-/**
- * Represents an OSPF link state database.
- */
-public interface OspfLsdb {
-
- /**
- * Initializes the link state database.
- */
- public void initializeDb();
-
- /**
- * Gets all LSA headers.
- *
- * @param excludeMaxAgeLsa exclude the max age LSAs
- * @param isOpaqueCapable is opaque capable or not
- * @return List of LSA headers
- */
- public List getAllLsaHeaders(boolean excludeMaxAgeLsa, boolean isOpaqueCapable);
-
- /**
- * Finds the LSA from appropriate LSA maps.
- *
- * @param lsType type of LSA
- * @param lsaKey key
- * @return LSA wrapper object
- */
- public LsaWrapper findLsa(int lsType, String lsaKey);
-
- /**
- * Adds the LSA to maxAge bin.
- *
- * @param key key
- * @param lsaWrapper LSA wrapper instance
- */
- public void addLsaToMaxAgeBin(String key, Object lsaWrapper);
-
- /**
- * Removes LSA from bin.
- *
- * @param lsaWrapper LSA wrapper instance
- */
- public void removeLsaFromBin(Object lsaWrapper);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfMessage.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfMessage.java
deleted file mode 100644
index 460457f..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfMessage.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.exceptions.OspfParseException;
-
-/**
- * Representation of an OSPF message.
- */
-public interface OspfMessage {
-
- /**
- * Returns the interface index on which the message received.
- *
- * @return interface index on which the message received
- */
- int interfaceIndex();
-
- /**
- * Sets the interface index on which the message received.
- *
- * @param interfaceIndex interface index on which the message received
- */
- void setInterfaceIndex(int interfaceIndex);
-
- /**
- * Returns the type of OSPF message.
- *
- * @return OSPF message type
- */
- public OspfPacketType ospfMessageType();
-
- /**
- * Reads from ChannelBuffer and initializes the type of LSA.
- *
- * @param channelBuffer channel buffer instance
- * @throws OspfParseException might throws exception while parsing buffer
- */
- void readFrom(ChannelBuffer channelBuffer) throws OspfParseException;
-
- /**
- * Returns OSPFMessage as byte array.
- *
- * @return OSPF message as bytes
- */
- byte[] asBytes();
-
- /**
- * Sets the source IP address.
- *
- * @param sourceIp IP address
- */
- public void setSourceIp(Ip4Address sourceIp);
-
- /**
- * Gets the destination IP address.
- *
- * @return destination IP address
- */
- public Ip4Address destinationIp();
-
- /**
- * Sets destination IP.
- *
- * @param destinationIp destination IP address
- */
- public void setDestinationIp(Ip4Address destinationIp);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java
deleted file mode 100644
index 9a62fad..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import org.jboss.netty.channel.Channel;
-import org.onlab.packet.Ip4Address;
-
-import java.util.Map;
-
-/**
- * Represents an OSPF neighbor.
- */
-public interface OspfNbr {
-
- /**
- * Gets neighbor's id.
- *
- * @return neighbor's id
- */
- public Ip4Address neighborId();
-
- /**
- * Gets router priority.
- *
- * @return router priority
- */
- public int routerPriority();
-
- /**
- * Gets the IP address of this neighbor.
- *
- * @return the IP address of this neighbor
- */
- public Ip4Address neighborIpAddr();
-
- /**
- * Gets the neighbor's DR address.
- *
- * @return neighbor's DR address
- */
- public Ip4Address neighborDr();
-
- /**
- * Gets the neighbor's BDR address.
- *
- * @return neighbor's BDR address
- */
- Ip4Address neighborBdr();
-
- /**
- * Determines whether an adjacency should be established/maintained with the neighbor.
- *
- * @param ch netty channel instance
- */
- void adjOk(Channel ch);
-
- /**
- * Gets the pending re transmit list as a map.
- *
- * @return pending re transmit list as a map
- */
- Map<String, OspfLsa> getPendingReTxList();
-
- /**
- * Sets the neighbor's id.
- *
- * @param neighborId neighbor's id
- */
- void setNeighborId(Ip4Address neighborId);
-
- /**
- * Sets the neighbor's BDR address.
- *
- * @param neighborBdr neighbor's BDR address
- */
- void setNeighborBdr(Ip4Address neighborBdr);
-
- /**
- * Sets the neighbor's DR address.
- *
- * @param neighborDr neighbor's DR address
- */
- void setNeighborDr(Ip4Address neighborDr);
-
- /**
- * Sets router priority.
- *
- * @param routerPriority router priority
- */
- void setRouterPriority(int routerPriority);
-
- /**
- * Sets the neighbor is opaque enabled or not.
- *
- * @param isOpaqueCapable true if the neighbor is opaque enabled else false
- */
- void setIsOpaqueCapable(boolean isOpaqueCapable);
-
- /**
- * Sets neighbor is master or not.
- *
- * @param isMaster neighbor is master or not
- */
- void setIsMaster(int isMaster);
-
- /**
- * Gets the DD sequence number.
- *
- * @return DD sequence number
- */
- long ddSeqNum();
-
- /**
- * Sets the DD sequence number.
- *
- * @param ddSeqNum DD sequence number
- */
- void setDdSeqNum(long ddSeqNum);
-
- /**
- * Gets neighbor is master or not.
- *
- * @return true if neighbor is master else false
- */
- int isMaster();
-
- /**
- * Gets the options value.
- *
- * @return options value
- */
- int options();
-
- /**
- * Sets the options value.
- *
- * @param options options value
- */
- void setOptions(int options);
-
- /**
- * An invalid request for LSA has been received.
- * This indicates an error in the Database Exchange process. Actions to be performed
- * are the same as in seqNumMismatch. In addition, stop the possibly activated
- * retransmission timer.
- *
- * @param ch netty channel instance
- */
- void badLSReq(Channel ch);
-
- /**
- * Gets the LS request list.
- *
- * @return LS request list
- */
- Map getLsReqList();
-
- /**
- * Gets the reTxList instance.
- *
- * @return reTxList instance
- */
- Map getReTxList();
-
- /**
- * Gets if the neighbor is opaque enabled or not.
- *
- * @return true if the neighbor is opaque enabled else false.
- */
- public boolean isOpaqueCapable();
-
- /**
- * Gets the neighbor's state.
- *
- * @return neighbor's state
- */
- OspfNeighborState getState();
-
- /**
- * Starts the inactivity timer.
- */
- void startInactivityTimeCheck();
-
- /**
- * Stops the inactivity timer.
- */
- void stopInactivityTimeCheck();
-
- /**
- * Sets router dead interval.
- *
- * @param routerDeadInterval router dead interval
- */
- void setRouterDeadInterval(int routerDeadInterval);
-
- /**
- * Stops the flooding timer.
- */
- void stopFloodingTimer();
-
- /**
- * Stops the Dd Retransmission executor task.
- */
- void stopRxMtDdTimer();
-
- /**
- * Stops Ls request retransmission executor task.
- */
- void stopRxMtLsrTimer();
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNeighborState.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNeighborState.java
deleted file mode 100644
index 8019f49..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNeighborState.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-/**
- * Enum representing OSPF neighbor state.
- */
-public enum OspfNeighborState {
-
- DOWN(1),
- ATTEMPT(2),
- INIT(3),
- TWOWAY(4),
- EXSTART(5),
- EXCHANGE(6),
- LOADING(7),
- FULL(8);
-
- private int value;
-
- /**
- * Creates an OSPF neighbor state.
- *
- * @param value represents neighbors state
- */
- OspfNeighborState(int value) {
- this.value = value;
- }
-
- /**
- * Gets value of neighbor state.
- *
- * @return value represents neighbors state
- */
- public int getValue() {
- return value;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfPacketType.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfPacketType.java
deleted file mode 100644
index 810b700..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfPacketType.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-/**
- * Representation of different OSPF packet types.
- */
-public enum OspfPacketType {
-
- /**
- * OSPF hello packet.
- */
- HELLO(1),
- /**
- * OSPF device description packet.
- */
- DD(2),
- /**
- * OSPF link state request packet.
- */
- LSREQUEST(3),
- /**
- * OSPF link state update packet.
- */
- LSUPDATE(4),
- /**
- * OSPF link state acknowledge packet.
- */
- LSAACK(5);
-
- private int value;
-
- /**
- * Creates instance of OSPF packet types.
- *
- * @param value OSPF packet types
- */
- OspfPacketType(int value) {
- this.value = value;
- }
-
- /**
- * Gets the value.
- *
- * @return value
- */
- public int value() {
- return value;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfProcess.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfProcess.java
deleted file mode 100644
index 767184c..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfProcess.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import java.util.List;
-
-/**
- * Represents an OSPF Process.
- */
-public interface OspfProcess {
-
- /**
- * Gets the list of areas belonging to this process.
- *
- * @return list of areas belonging to this process
- */
- public List<OspfArea> areas();
-
- /**
- * Sets the list of areas belonging to this process.
- *
- * @param areas list of areas belonging to this process
- */
- public void setAreas(List<OspfArea> areas);
-
- /**
- * Gets the process id.
- *
- * @return process id
- */
- public String processId();
-
- /**
- * Sets the process id.
- *
- * @param processId the process id
- */
- public void setProcessId(String processId);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfRouter.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfRouter.java
deleted file mode 100644
index 38b3013..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfRouter.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import org.onlab.packet.Ip4Address;
-
-/**
- * Abstraction of an OSPF Router.
- */
-public interface OspfRouter {
-
- /**
- * Gets IP address of the router.
- *
- * @return IP address of the router
- */
- Ip4Address routerIp();
-
- /**
- * Gets the area id for this device.
- *
- * @return the area id for this device
- */
- Ip4Address areaIdOfInterface();
-
- /**
- * Gets IP address of the interface.
- *
- * @return IP address of the interface
- */
- Ip4Address interfaceId();
-
- /**
- * Gets list of device TED.
- *
- * @return list of device TED.
- */
- OspfDeviceTed deviceTed();
-
- /**
- * Sets IP address of the Router.
- *
- * @param routerIp IP address of the router
- */
- void setRouterIp(Ip4Address routerIp);
-
- /**
- * Sets area id in which this device belongs to.
- *
- * @param areaIdOfInterface area id in which this device belongs to
- */
- void setAreaIdOfInterface(Ip4Address areaIdOfInterface);
-
- /**
- * Sets IP address of the interface.
- *
- * @param interfaceId IP address of the interface
- */
- void setInterfaceId(Ip4Address interfaceId);
-
- /**
- * Sets the device TED information.
- *
- * @param deviceTed device TED instance
- */
- void setDeviceTed(OspfDeviceTed deviceTed);
-
- /**
- * Gets if router is opaque enabled.
- *
- * @return true if router is opaque enabled else false.
- */
- boolean isOpaque();
-
- /**
- * Sets true if device is opaque enable if not sets false.
- *
- * @param opaque true if device is opaque enable if not sets false
- */
- void setOpaque(boolean opaque);
-
- /**
- * Gets IP address of the advertising router.
- *
- * @return IP address of the advertising router
- */
- Ip4Address neighborRouterId();
-
- /**
- * Sets IP address of the advertising router.
- *
- * @param advertisingRouterId IP address of the advertising router
- */
- void setNeighborRouterId(Ip4Address advertisingRouterId);
-
-
- /**
- * Gets if the router id DR or not.
- *
- * @return true if the router is DR else false
- */
- boolean isDr();
-
- /**
- * Sets if the router id DR or not.
- *
- * @param dr true if the router is DR else false
- */
- void setDr(boolean dr);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfRouterId.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfRouterId.java
deleted file mode 100644
index 22c91f4..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfRouterId.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ospf.controller;
-
-import org.onlab.packet.IpAddress;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-/**
- * Represents an OSPF router id.
- */
-public class OspfRouterId {
-
- private static final String SCHEME = "l3";
- private static final long UNKNOWN = 0;
- private final IpAddress ipAddress;
-
- /**
- * Creates an instance of OSPF router id.
- *
- * @param ipAddress IP address of the router
- */
- public OspfRouterId(IpAddress ipAddress) {
- this.ipAddress = ipAddress;
- }
-
- /**
- * Creates an instance from ip address.
- *
- * @param ipAddress IP address
- * @return OSPF router id instance
- */
- public static OspfRouterId ospfRouterId(IpAddress ipAddress) {
- return new OspfRouterId(ipAddress);
- }
-
- /**
- * Creates OSPF router id instance from the URI.
- *
- * @param uri device URI
- * @return OSPF router id instance
- */
- public static OspfRouterId ospfRouterId(URI uri) {
- checkArgument(uri.getScheme().equals(SCHEME), "Unsupported URI scheme");
- return new OspfRouterId(IpAddress.valueOf(uri.getSchemeSpecificPart()));
- }
-
- /**
- * Returns device URI from the given router id.
- *
- * @param ospfRouterId router id instance
- * @return device URI
- */
- public static URI uri(OspfRouterId ospfRouterId) {
- return uri(ospfRouterId.ipAddress());
- }
-
- /**
- * Returns device URI from the given IP address.
- *
- * @param ipAddress device IP address
- * @return device URI
- */
- public static URI uri(IpAddress ipAddress) {
- try {
- return new URI(SCHEME, ipAddress.toString(), null);
- } catch (URISyntaxException e) {
- return null;
- }
- }
-
- /**
- * Returns the IP address.
- *
- * @return IP address
- */
- public IpAddress ipAddress() {
- return ipAddress;
- }
-
- @Override
- public String toString() {
- return ipAddress.toString();
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof OspfRouterId)) {
- return false;
- }
-
- OspfRouterId otherOspfRouterId = (OspfRouterId) other;
- return Objects.equals(ipAddress, otherOspfRouterId.ipAddress);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(ipAddress);
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfRouterListener.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfRouterListener.java
deleted file mode 100644
index 62f2e63..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfRouterListener.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-/**
- * Abstraction of an OSPF Router Listener.
- * Allows for providers interested in switch events to be notified.
- */
-public interface OspfRouterListener {
-
- /**
- * Notifies that a router is added.
- *
- * @param ospfRouter OSPF router instance
- */
- void routerAdded(OspfRouter ospfRouter);
-
- /**
- * Notifies that a router is removed.
- *
- * @param ospfRouter OSPF router instance
- */
- void routerRemoved(OspfRouter ospfRouter);
-
- /**
- * Notifies that the router has changed in some way.
- *
- * @param ospfRouter OSPF router instance
- */
- void routerChanged(OspfRouter ospfRouter);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/TopologyForDeviceAndLink.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/TopologyForDeviceAndLink.java
deleted file mode 100644
index 9d6dd64..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/TopologyForDeviceAndLink.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import org.onlab.packet.Ip4Address;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Represents IP topology for OSPF device and link details.
- */
-public interface TopologyForDeviceAndLink {
-
- /**
- * Gets the device information.
- *
- * @return device information
- */
- Map<String, DeviceInformation> deviceInformationMap();
-
- /**
- * Sets the device information.
- *
- * @param key key used to store in map
- * @param deviceInformationMap device information instance
- */
- void setDeviceInformationMap(String key, DeviceInformation deviceInformationMap);
-
- /**
- * Gets the link information.
- *
- * @return link information
- */
- Map<String, LinkInformation> linkInformationMap();
-
- /**
- * Sets link information.
- *
- * @param key key used to store in map
- * @param linkInformationMap link information instance
- */
- void setLinkInformationMap(String key, LinkInformation linkInformationMap);
-
- /**
- * Removes link information.
- *
- * @param key key used to remove from map
- */
- void removeLinkInformationMap(String key);
-
- /**
- * Adds device information.
- *
- * @param ospfLsa LSA instance
- * @param ospfInterface interface instance
- * @param ospfArea area instance
- */
- void addLocalDevice(OspfLsa ospfLsa, OspfInterface ospfInterface, OspfArea ospfArea);
-
- /**
- * Removes device information.
- *
- * @param key key used to remove from map
- */
- void removeDeviceInformationMap(String key);
-
- /**
- * Removes links from link information map.
- *
- * @param routerId router's IP address
- */
- void removeLinks(Ip4Address routerId);
-
- /**
- * Gets OSPF link TED details.
- *
- * @param key key used to retrieve from map
- * @return links TED information
- */
- OspfLinkTed getOspfLinkTedHashMap(String key);
-
- /**
- * Gets all the router information to be deleted.
- *
- * @param ospfLsa LSA instance
- * @param ospfArea area instance
- * @return list of router information which needs to delete from device list
- */
- List<String> getDeleteRouterInformation(OspfLsa ospfLsa, OspfArea ospfArea);
-
- /**
- * Updates the device and link information.
- *
- * @param ospfLsa LSA instance
- * @param ospfArea area instance
- */
- void updateLinkInformation(OspfLsa ospfLsa, OspfArea ospfArea);
-
- /**
- * Gets device information as map.
- *
- * @return deviceInformationMap to delete from core
- */
- Map<String, DeviceInformation> deviceInformationMapToDelete();
-
- /**
- * Sets device information as map.
- *
- * @param key key to store in device info map
- * @param deviceInformationMapToDelete device information instance
- */
- void setDeviceInformationMapToDelete(String key, DeviceInformation deviceInformationMapToDelete);
-
- /**
- * Removes device information from deviceInformationMapToDelete.
- *
- * @param key key to remove device information
- */
- void removeDeviceInformationMapFromDeleteMap(String key);
-
- /**
- * Gets device information as map for Point-To-Point.
- *
- * @return deviceInformationMap
- */
- Map<String, DeviceInformation> deviceInformationMapForPointToPoint();
-
- /**
- * Sets device information as map for Point-To-Point.
- *
- * @param key key to store in device info
- * @param deviceInformationMap device information instance
- */
- void setDeviceInformationMapForPointToPoint(String key, DeviceInformation deviceInformationMap);
-
- /**
- * Gets link information as map for Point-To-Point.
- *
- * @return linkInformationMap
- */
- Map<String, LinkInformation> linkInformationMapForPointToPoint();
-
- /**
- * Sets link information as map for Point-To-Point.
- *
- * @param key key to store link info
- * @param linkInformationMap link information instance
- */
- void setLinkInformationMapForPointToPoint(String key, LinkInformation linkInformationMap);
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/package-info.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/package-info.java
deleted file mode 100644
index 9233eee..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ospf api interfaces.
- */
-package org.onosproject.ospf.controller;
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/exceptions/OspfParseException.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/exceptions/OspfParseException.java
deleted file mode 100644
index c228381..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/exceptions/OspfParseException.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.exceptions;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Representation of a custom exception for OSPF.
- */
-public class OspfParseException extends Exception {
-
- private static final long serialVersionUID = 1L;
- private byte errorCode;
- private byte errorSubCode;
-
- /**
- * Creates a new OSPF exception.
- */
- public OspfParseException() {
- super();
- }
-
- /**
- * Creates a new OSPF exception based on the given arguments.
- *
- * @param message the detail of exception in string
- * @param cause underlying cause of the error
- */
- public OspfParseException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Creates a new OSPF exception for the given message.
- *
- * @param message the detail of exception in string
- */
- public OspfParseException(final String message) {
- super(message);
- }
-
- /**
- * Creates a new OSPF exception from throwable instance.
- *
- * @param cause underlying cause of the error
- */
- public OspfParseException(final Throwable cause) {
- super(cause);
- }
-
- /**
- * Creates a new OSPF exception from error code and error sub code.
- *
- * @param errorCode error code of OSPF message
- * @param errorSubCode error sub code of OSPF message
- */
- public OspfParseException(final byte errorCode, final byte errorSubCode) {
- super();
- this.errorCode = errorCode;
- this.errorSubCode = errorSubCode;
- }
-
- /**
- * Returns error code for this exception.
- *
- * @return error code for this exception
- */
- public byte errorCode() {
- return this.errorCode;
- }
-
- /**
- * Returns error sub code for this exception.
- *
- * @return error sub code for this exception
- */
- public byte errorSubCode() {
- return this.errorSubCode;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("errorCode", errorCode)
- .add("errorSubCode", errorSubCode)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/exceptions/package-info.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/exceptions/package-info.java
deleted file mode 100644
index db2cc81..0000000
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/exceptions/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the OSPF exception types.
- */
-package org.onosproject.ospf.exceptions;
\ No newline at end of file
diff --git a/protocols/ospf/api/src/test/java/org/onosproject/ospf/controller/OspfRouterIdTest.java b/protocols/ospf/api/src/test/java/org/onosproject/ospf/controller/OspfRouterIdTest.java
deleted file mode 100644
index 6944a6f..0000000
--- a/protocols/ospf/api/src/test/java/org/onosproject/ospf/controller/OspfRouterIdTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-
-import java.net.URI;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for OspfRouterId.
- */
-public class OspfRouterIdTest {
-
- private OspfRouterId ospfRouterId;
-
- @Before
- public void setUp() throws Exception {
- ospfRouterId = new OspfRouterId(IpAddress.valueOf("2.2.2.2"));
- }
-
- @After
- public void tearDown() throws Exception {
- ospfRouterId = null;
- }
-
- /**
- * Tests constructor.
- */
- @Test
- public void testOspfRouterId() throws Exception {
- assertThat(OspfRouterId.ospfRouterId(IpAddress.valueOf("2.2.2.2")), instanceOf(OspfRouterId.class));
-
- }
-
- /**
- * Tests ipAddress() getter method.
- */
- @Test
- public void testIpAddress() throws Exception {
- assertThat(ospfRouterId.ipAddress(), instanceOf(IpAddress.class));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(ospfRouterId.toString(), is(notNullValue()));
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEquals() throws Exception {
- assertThat(ospfRouterId.equals(new OspfRouterId(IpAddress.valueOf("3.3.3.3"))), is(false));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- assertThat(ospfRouterId.hashCode(), is(notNullValue()));
- }
-
- /**
- * Tests constructor.
- */
- @Test
- public void testOspfRouterId1() throws Exception {
- assertThat(OspfRouterId.ospfRouterId(OspfRouterId.uri(ospfRouterId)), instanceOf(OspfRouterId.class));
- }
-
- /**
- * Tests uri() method.
- */
- @Test
- public void testUri() throws Exception {
- assertThat(OspfRouterId.uri(IpAddress.valueOf("2.2.2.2")), instanceOf(URI.class));
- }
-
- /**
- * Tests uri() method..
- */
- @Test
- public void testUri1() throws Exception {
- assertThat(OspfRouterId.uri(ospfRouterId), instanceOf(URI.class));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/BUILD b/protocols/ospf/ctl/BUILD
deleted file mode 100644
index de94b39..0000000
--- a/protocols/ospf/ctl/BUILD
+++ /dev/null
@@ -1,10 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
- "@io_netty_netty//jar",
- "//protocols/ospf/api:onos-protocols-ospf-api",
- "//protocols/ospf/protocol:onos-protocols-ospf-protocol",
-]
-
-osgi_jar_with_tests(
- exclude_tests = ["org.onosproject.ospf.controller.impl.OspfPipelineFactoryTest"],
- deps = COMPILE_DEPS,
-)
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/Configuration.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/Configuration.java
deleted file mode 100644
index 65ea80c..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/Configuration.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.area;
-
-import com.google.common.base.MoreObjects;
-import org.onosproject.ospf.controller.OspfProcess;
-
-import java.util.List;
-
-/**
- * Representation of an OSPF configuration data.
- */
-public class Configuration {
- private List<OspfProcess> processes;
- private String method;
-
- /**
- * Gets the configured processes.
- *
- * @return list of configured processes.
- */
- public List<OspfProcess> getProcesses() {
- return processes;
- }
-
- /**
- * Sets the configured processes.
- *
- * @param processes configured processes
- */
- public void setProcesses(List<OspfProcess> processes) {
- this.processes = processes;
- }
-
- /**
- * Gets whether to update, add or delete configuration.
- *
- * @return update, add or delete configuration
- */
- public String getMethod() {
- return method;
- }
-
- /**
- * Sets whether to update, add or delete configuration.
- *
- * @param method configuration method.
- */
- public void setMethod(String method) {
- this.method = method;
- }
-
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("method", method)
- .add("processes", processes)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaAddressRangeImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaAddressRangeImpl.java
deleted file mode 100644
index 3848b24..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaAddressRangeImpl.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.area;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfAreaAddressRange;
-
-/**
- * Representation of an area address ranges.
- * Address ranges are used in order to aggregate routing information at area boundaries.
- * Each address range is specified by an [address,mask] pair and a status indication of
- * either advertise or do not advertise
- */
-public class OspfAreaAddressRangeImpl implements OspfAreaAddressRange {
-
- private Ip4Address ipAddress;
- private String mask;
- private boolean advertise;
-
- /**
- * Gets the IP address.
- *
- * @return IP address
- */
- public Ip4Address ipAddress() {
- return ipAddress;
- }
-
- /**
- * Sets the IP address.
- *
- * @param ipAddress IP address
- */
- public void setIpAddress(Ip4Address ipAddress) {
- this.ipAddress = ipAddress;
- }
-
- /**
- * Gets the network mask.
- *
- * @return network mask
- */
- public String mask() {
- return mask;
- }
-
- /**
- * Sets the network mask.
- *
- * @param mask network mask value
- */
- public void setMask(String mask) {
- this.mask = mask;
- }
-
- /**
- * Gets the advertise value.
- *
- * @return advertise value
- */
- public boolean isAdvertise() {
- return advertise;
- }
-
- /**
- * Sets the advertise value.
- *
- * @param advertise advertise value
- */
- public void setAdvertise(boolean advertise) {
- this.advertise = advertise;
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof OspfAreaAddressRangeImpl)) {
- return false;
- }
- OspfAreaAddressRangeImpl otherAreaAddressRange = (OspfAreaAddressRangeImpl) other;
- return Objects.equal(ipAddress, otherAreaAddressRange.ipAddress) &&
- Objects.equal(mask, otherAreaAddressRange.mask) &&
- Objects.equal(advertise, otherAreaAddressRange.advertise);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(ipAddress, mask, advertise);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("ipAddress", ipAddress)
- .add("mask", mask)
- .add("advertise", advertise)
- .toString();
- }
-}
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java
deleted file mode 100644
index 7a74637..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java
+++ /dev/null
@@ -1,729 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.area;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.LsaWrapper;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfLsa;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.controller.OspfLsdb;
-import org.onosproject.ospf.controller.OspfNbr;
-import org.onosproject.ospf.controller.OspfNeighborState;
-import org.onosproject.ospf.controller.impl.OspfNbrImpl;
-import org.onosproject.ospf.controller.lsdb.OspfLsdbImpl;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.subtypes.OspfLsaLink;
-import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.util.ChecksumCalculator;
-import org.onosproject.ospf.protocol.util.OspfInterfaceState;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Representation an OSPF area and related information.
- */
-public class OspfAreaImpl implements OspfArea {
- private static final Logger log = LoggerFactory.getLogger(OspfAreaImpl.class);
- /**
- * Whether AS-external-LSAs will be flooded into/throughout the area.
- */
- private boolean externalRoutingCapability;
-
- /**
- * Represents a list of all router's interfaces associated with this area.
- */
- private List<OspfInterface> ospfInterfaceList;
- /**
- * The LS Database for this area. It includes router-LSAs, network-LSAs and.
- * summary-LSAs. AS-external-LSAs are hold in the OSPF class itself.
- */
- private OspfLsdbImpl database;
- /**
- * A 32-bit number identifying the area.
- */
- private Ip4Address areaId;
- /**
- * Router ID.
- */
- private Ip4Address routerId;
- /**
- * Represents Options like external, opaque capabilities.
- */
- private int options;
- /**
- * Represents Opaque Enable or not.
- */
- private boolean isOpaqueEnable;
-
- /**
- * Creates an instance of area implementation.
- */
- public OspfAreaImpl() {
- database = new OspfLsdbImpl(this);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- OspfAreaImpl that = (OspfAreaImpl) o;
- return Objects.equal(areaId, that.areaId) &&
- Objects.equal(routerId, that.routerId) &&
- Objects.equal(externalRoutingCapability, that.externalRoutingCapability) &&
- Objects.equal(ospfInterfaceList.size(), that.ospfInterfaceList.size()) &&
- Objects.equal(database, that.database);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(areaId, routerId, externalRoutingCapability,
- ospfInterfaceList, database);
- }
-
- /**
- * Gets the router id.
- *
- * @return router id
- */
- public Ip4Address routerId() {
- return routerId;
- }
-
- /**
- * Sets the router id.
- *
- * @param routerId router id
- */
- @JsonProperty("routerId")
- public void setRouterId(Ip4Address routerId) {
- this.routerId = routerId;
- }
-
- /**
- * Sets opaque enabled to true or false.
- *
- * @param isOpaqueEnable true if opaque enabled else false
- */
- @JsonProperty("isOpaqueEnable")
- public void setIsOpaqueEnabled(boolean isOpaqueEnable) {
- this.isOpaqueEnable = isOpaqueEnable;
- }
-
- /**
- * Gets is opaque enabled or not.
- *
- * @return true if opaque enabled else false
- */
- public boolean isOpaqueEnabled() {
- return this.isOpaqueEnable;
- }
-
- /**
- * Initializes link state database.
- */
- public void initializeDb() {
-
- database.initializeDb();
- }
-
- /**
- * Refreshes the OSPF area information .
- * Gets called as soon as the interface is down or neighbor full Router LSA is updated.
- *
- * @param ospfInterface OSPF interface instance
- */
- @Override
- public void refreshArea(OspfInterface ospfInterface) {
- OspfInterfaceImpl ospfInterfaceImpl = (OspfInterfaceImpl) ospfInterface;
- log.debug("Inside refreshArea...!!!");
- //If interface state is DR build network LSA.
- if (ospfInterfaceImpl.state() == OspfInterfaceState.DR) {
- if (ospfInterface.listOfNeighbors().size() > 0) {
- //Get the NetworkLsa
- NetworkLsa networkLsa = null;
- try {
- networkLsa = buildNetworkLsa(ospfInterface.ipAddress(), ospfInterface.ipNetworkMask());
- } catch (Exception e) {
- log.debug("Error while building NetworkLsa {}", e.getMessage());
- }
- //Add the NetworkLsa to lsdb
- database.addLsa(networkLsa, true, ospfInterface);
- addToOtherNeighborLsaTxList(networkLsa);
- } else {
- log.debug("No Neighbors hence not creating NetworkLSA...!!!");
- }
- }
- //Get the router LSA
- RouterLsa routerLsa = null;
- try {
- routerLsa = buildRouterLsa(ospfInterface);
- } catch (Exception e) {
- log.debug("Error while building RouterLsa {}", e.getMessage());
- }
- //Add the RouterLSA to lsdb
- database.addLsa(routerLsa, true, ospfInterface);
- addToOtherNeighborLsaTxList(routerLsa);
- }
-
- /**
- * Builds a network LSA.
- *
- * @param interfaceIp interface IP address
- * @param mask interface network mask
- * @return NetworkLsa instance
- * @throws OspfParseException might throws exception
- */
- public NetworkLsa buildNetworkLsa(Ip4Address interfaceIp, Ip4Address mask) throws OspfParseException {
- // generate the Router-LSA for this Area.
- NetworkLsa networkLsa = new NetworkLsa();
- networkLsa.setAdvertisingRouter(routerId);
- networkLsa.setLinkStateId(interfaceIp.toString());
- networkLsa.setLsType(OspfLsaType.NETWORK.value());
- networkLsa.setAge(1);
- networkLsa.setOptions(2);
- networkLsa.setNetworkMask(mask);
- //Adding our own router.
- networkLsa.addAttachedRouter(routerId());
- Iterator iter = ospfInterfaceList.iterator();
- OspfInterfaceImpl ospfInterface = null;
- while (iter.hasNext()) {
- ospfInterface = (OspfInterfaceImpl) iter.next();
- if (ospfInterface.ipAddress().equals(interfaceIp)) {
- break;
- }
- }
- if (ospfInterface != null) {
- List<OspfNbr> neighborsInFullState = getNeighborsInFullState(ospfInterface);
- if (neighborsInFullState != null) {
- for (OspfNbr ospfnbr : neighborsInFullState) {
- networkLsa.addAttachedRouter(ospfnbr.neighborId());
- log.debug("Adding attached neighbor:: {}", ospfnbr.neighborId());
- }
- }
- }
- networkLsa.setLsSequenceNo(database.getLsSequenceNumber(OspfLsaType.NETWORK));
- //Find the byte length and add it in lsa object
- ChecksumCalculator checksum = new ChecksumCalculator();
- byte[] lsaBytes = networkLsa.asBytes();
- networkLsa.setLsPacketLen(lsaBytes.length);
- //Convert lsa object to byte again to reflect the packet length which we added.
- lsaBytes = networkLsa.asBytes();
- //find the checksum
- byte[] twoByteChecksum = checksum.calculateLsaChecksum(lsaBytes,
- OspfUtil.LSAPACKET_CHECKSUM_POS1,
- OspfUtil.LSAPACKET_CHECKSUM_POS2);
- int checkSumVal = OspfUtil.byteToInteger(twoByteChecksum);
- networkLsa.setLsCheckSum(checkSumVal);
- return networkLsa;
- }
-
- /**
- * Builds Router LSA.
- *
- * @param ospfInterface Interface instance
- * @return routerLsa Router LSA instance
- * @throws OspfParseException might throws exception
- */
- public RouterLsa buildRouterLsa(OspfInterface ospfInterface) throws OspfParseException {
- // generate the Router-LSA for this Area.
- RouterLsa routerLsa = new RouterLsa();
- routerLsa.setAdvertisingRouter(routerId);
- routerLsa.setLinkStateId(routerId.toString());
- routerLsa.setLsType(OspfLsaType.ROUTER.value());
- routerLsa.setAge(1);
- routerLsa.setOptions(options);
- routerLsa.setAreaBorderRouter(false);
- routerLsa.setAsBoundaryRouter(false);
- routerLsa.setVirtualEndPoint(false);
- buildLinkForRouterLsa(routerLsa, ospfInterface);
- routerLsa.setLsSequenceNo(database.getLsSequenceNumber(OspfLsaType.ROUTER));
- //Find the byte length and add it in lsa object
- ChecksumCalculator checksum = new ChecksumCalculator();
- byte[] lsaBytes = routerLsa.asBytes();
- routerLsa.setLsPacketLen(lsaBytes.length);
- //Convert lsa object to byte again to reflect the packet length which we added.
- lsaBytes = routerLsa.asBytes();
- //find the checksum
- byte[] twoByteChecksum = checksum.calculateLsaChecksum(lsaBytes,
- OspfUtil.LSAPACKET_CHECKSUM_POS1,
- OspfUtil.LSAPACKET_CHECKSUM_POS2);
- int checkSumVal = OspfUtil.byteToInteger(twoByteChecksum);
- routerLsa.setLsCheckSum(checkSumVal);
- return routerLsa;
- }
-
- /**
- * Builds LSA link for router LSA.
- *
- * @param routerLsa router LSA instance
- * @param ospfInterface interface instance
- */
- private void buildLinkForRouterLsa(RouterLsa routerLsa, OspfInterface ospfInterface) {
- OspfInterfaceImpl nextInterface;
- Iterator interfaces = ospfInterfaceList.iterator();
- while (interfaces.hasNext()) {
- nextInterface = (OspfInterfaceImpl) interfaces.next();
- if (nextInterface.state() == OspfInterfaceState.DOWN) {
- continue;
- } else if (nextInterface.state() == OspfInterfaceState.LOOPBACK) {
- OspfLsaLink link = new OspfLsaLink();
- link.setLinkData("-1");
- link.setLinkId(nextInterface.ipAddress().toString());
- link.setLinkType(3);
- link.setMetric(0);
- link.setTos(0);
- routerLsa.addRouterLink(link);
- routerLsa.incrementLinkNo();
- } else if (nextInterface.state() == OspfInterfaceState.POINT2POINT) {
- // adding all neighbour routers
- List<OspfNbr> neighborsInFullState = getNeighborsInFullState(nextInterface);
- if (neighborsInFullState != null) {
- log.debug("Adding OspfLsaLink ::neighborsInFullState {}, InterfaceIP: {}",
- neighborsInFullState.size(), nextInterface.ipAddress());
- for (OspfNbr ospfnbr : neighborsInFullState) {
- OspfLsaLink link = new OspfLsaLink();
- link.setLinkData(nextInterface.ipAddress().toString());
- link.setLinkId(ospfnbr.neighborId().toString());
- link.setLinkType(1);
- link.setMetric(0);
- link.setTos(0);
- routerLsa.addRouterLink(link);
- routerLsa.incrementLinkNo();
- log.debug("Added OspfLsaLink :: {}, neighborIP: {}, routerLinks: {}",
- ospfnbr.neighborId(), ospfnbr.neighborIpAddr(), routerLsa.noLink());
- }
- }
- // adding the self address
- OspfLsaLink link = new OspfLsaLink();
- link.setLinkData(nextInterface.ipNetworkMask().toString());
- link.setLinkId(nextInterface.ipAddress().toString());
- link.setLinkType(3);
- link.setMetric(0);
- link.setTos(0);
- routerLsa.addRouterLink(link);
- routerLsa.incrementLinkNo();
- } else {
- buildLinkForRouterLsaBroadcast(routerLsa, nextInterface);
- }
- }
- }
-
- /**
- * Builds LSA link for router LSA.
- *
- * @param routerLsa router LSA instance
- * @param ospfInterface interface instance
- */
- private void buildLinkForRouterLsaBroadcast(RouterLsa routerLsa, OspfInterface ospfInterface) {
- OspfInterfaceImpl ospfInterfaceImpl = (OspfInterfaceImpl) ospfInterface;
- if (ospfInterfaceImpl.state() == OspfInterfaceState.WAITING) {
- OspfLsaLink link = new OspfLsaLink();
- link.setLinkData(ospfInterface.ipNetworkMask().toString());
- //Link id should be set to ip network number
- link.setLinkId(ospfInterface.ipAddress().toString());
- link.setLinkType(3);
- link.setMetric(0);
- link.setTos(0);
- routerLsa.addRouterLink(link);
- routerLsa.incrementLinkNo();
- } else if (ospfInterfaceImpl.state() == OspfInterfaceState.DR) {
- OspfLsaLink link = new OspfLsaLink();
- link.setLinkData(ospfInterface.ipAddress().toString());
- link.setLinkId(ospfInterface.ipAddress().toString());
- link.setLinkType(2);
- link.setMetric(0);
- link.setTos(0);
- routerLsa.addRouterLink(link);
- routerLsa.incrementLinkNo();
- } else if (ospfInterfaceImpl.state() == OspfInterfaceState.BDR ||
- ospfInterfaceImpl.state() == OspfInterfaceState.DROTHER) {
- OspfLsaLink link = new OspfLsaLink();
- link.setLinkData(ospfInterface.ipAddress().toString());
- link.setLinkId(ospfInterface.dr().toString());
- link.setLinkType(2);
- link.setMetric(0);
- link.setTos(0);
- routerLsa.addRouterLink(link);
- routerLsa.incrementLinkNo();
- }
- }
-
- /**
- * Gets the area id.
- *
- * @return area id
- */
- public Ip4Address areaId() {
- return areaId;
- }
-
- /**
- * Sets the area id.
- *
- * @param areaId area id
- */
- @JsonProperty("areaId")
- public void setAreaId(Ip4Address areaId) {
- this.areaId = areaId;
- }
-
- /**
- * Gets external routing capability.
- *
- * @return true if external routing capable, else false
- */
- public boolean isExternalRoutingCapability() {
- return externalRoutingCapability;
- }
-
- /**
- * Sets external routing capability.
- *
- * @param externalRoutingCapability true if external routing capable, else false
- */
- @JsonProperty("externalRoutingCapability")
- public void setExternalRoutingCapability(boolean externalRoutingCapability) {
- this.externalRoutingCapability = externalRoutingCapability;
- }
-
- /**
- * Gets the list of interfaces in this area.
- *
- * @return list of interfaces
- */
- public List<OspfInterface> ospfInterfaceList() {
- return ospfInterfaceList;
- }
-
- /**
- * Sets the list of interfaces attached to the area.
- *
- * @param ospfInterfaceList list of OspfInterface instances
- */
- @JsonProperty("interface")
- public void setOspfInterfaceList(List<OspfInterface> ospfInterfaceList) {
- this.ospfInterfaceList = ospfInterfaceList;
- }
-
- /**
- * Checks all neighbors belonging to this area whether they are in state EXCHANGE or LOADING.
- * Return false if there is at least one, else return true. This Method is used by
- * "processReceivedLsa()" in the neighbor class.
- *
- * @return boolean indicating that there is no Neighbor in Database Exchange
- */
- public boolean noNeighborInLsaExchangeProcess() {
- OspfInterfaceImpl nextInterface;
- OspfNeighborState nextNeighborState;
- Iterator interfaces = ospfInterfaceList.iterator();
- while (interfaces.hasNext()) {
- nextInterface = (OspfInterfaceImpl) interfaces.next();
- Iterator neighbors = nextInterface.listOfNeighbors().values().iterator();
- while (neighbors.hasNext()) {
- nextNeighborState = ((OspfNbrImpl) neighbors.next()).getState();
- if (nextNeighborState == OspfNeighborState.EXCHANGE ||
- nextNeighborState == OspfNeighborState.LOADING) {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Gets header of all types of LSAs.
- *
- * @param excludeMaxAgeLsa need to include(true) or exclude(false) maxage lsa's
- * @param isOpaquecapable need to include(true) or exclude(false) Type 10 Opaque lsa's
- * @return list of lsa header in the lsdb
- */
- public List getLsaHeaders(boolean excludeMaxAgeLsa, boolean isOpaquecapable) {
- return database.getAllLsaHeaders(excludeMaxAgeLsa, isOpaquecapable);
- }
-
- /**
- * Gets the LSA from LSDB based on the input.
- *
- * @param lsType type of lsa to form the key
- * @param linkStateID link state id to form the key
- * @param advertisingRouter advertising router to form the key
- * @return lsa wrapper instance which contains the Lsa
- */
- public LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter) {
- String lsaKey = lsType + "-" + linkStateID + "-" + advertisingRouter;
- if (lsType == OspfParameters.LINK_LOCAL_OPAQUE_LSA || lsType == OspfParameters.AREA_LOCAL_OPAQUE_LSA ||
- lsType == OspfParameters.AS_OPAQUE_LSA) {
- try {
- byte[] linkStateAsBytes = InetAddress.getByName(linkStateID).getAddress();
-
- int opaqueType = linkStateAsBytes[0];
- int opaqueId = OspfUtil.byteToInteger(Arrays.copyOfRange(linkStateAsBytes, 1,
- linkStateAsBytes.length));
- lsaKey = lsType + "-" + opaqueType + opaqueId + "-" + advertisingRouter;
- } catch (UnknownHostException uhe) {
- log.warn("Can't resolve host in Lsa wrapper", uhe);
- return null;
- }
- }
- return database.findLsa(lsType, lsaKey);
- }
-
-
- /**
- * Checks whether an instance of the given LSA exists in the database belonging to this area.
- * If so return true else false.
- *
- * @param lookupLsa ospf LSA instance to lookup
- * @return LSA wrapper instance which contains the Lsa
- */
- public LsaWrapper lsaLookup(OspfLsa lookupLsa) {
- return database.lsaLookup((LsaHeader) lookupLsa);
- }
-
- /**
- * Checks whether an instance of the given LSA exists in the database belonging to this area.
- * If so return true else false.
- *
- * @param lsa1 OSPF LSA instance to compare
- * @param lsa2 OSPF LSA instance to compare
- * @return "same" if both instances are same, "latest" if lsa1 is latest, or "old" if lsa1 is old
- */
- public String isNewerOrSameLsa(OspfLsa lsa1, OspfLsa lsa2) {
- return database.isNewerOrSameLsa((LsaHeader) lsa1, (LsaHeader) lsa2);
- }
-
- /**
- * Methods gets called from ChannelHandler to add the received LSA to LSDB.
- *
- * @param ospfLsa OSPF LSA instance
- * @param ospfInterface OSPF interface instance
- */
- public void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface) {
- //second param is false as lsa from network
- database.addLsa((LsaHeader) ospfLsa, false, ospfInterface);
- }
-
- /**
- * Methods gets called from ChannelHandler to add the received LSA to LSDB.
- *
- * @param ospfLsa OSPF LSA instance
- * @param isSelfOriginated true if the LSA is self originated. Else false
- * @param ospfInterface OSPF interface instance
- */
- public void addLsa(OspfLsa ospfLsa, boolean isSelfOriginated, OspfInterface ospfInterface) {
- database.addLsa((LsaHeader) ospfLsa, isSelfOriginated, ospfInterface);
- }
-
- /**
- * Adds the LSA to maxAge bin.
- *
- * @param key key to add it to LSDB
- * @param wrapper LSA wrapper instance
- */
- public void addLsaToMaxAgeBin(String key, LsaWrapper wrapper) {
- database.addLsaToMaxAgeBin(key, wrapper);
- }
-
- /**
- * Sets router sequence number for router LSA.
- *
- * @param newSequenceNumber sequence number
- */
- public void setDbRouterSequenceNumber(long newSequenceNumber) {
- database.setRouterLsaSeqNo(newSequenceNumber);
- }
-
- /**
- * Methods gets called from ChannelHandler to delete the LSA.
- *
- * @param ospfLsa the LSA instance to delete
- */
- public void deleteLsa(LsaHeader ospfLsa) {
- database.deleteLsa(ospfLsa);
- }
-
- /**
- * Removes LSA from bin.
- *
- * @param lsaWrapper the LSA wrapper instance to delete
- */
- public void removeLsaFromBin(LsaWrapper lsaWrapper) {
- database.removeLsaFromBin(lsaWrapper);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("areaID", areaId)
- .add("ospfInterfaceList", ospfInterfaceList)
- .add("externalRoutingCapability", externalRoutingCapability)
- .toString();
- }
-
- /**
- * Checks all Neighbors belonging to this Area whether they are in state lesser than the EXCHANGE.
- * Creates list of such neighbors
- * Returns list of neighbors who satisfy the conditions
- *
- * @param ospfInterface OSPF interface instance
- * @return List of interfaces having state lesser than exchange
- */
- public List<OspfNbr> getNeighborsInFullState(OspfInterface ospfInterface) {
-
- List<OspfNbr> listEligibleNeighbors = null;
- OspfNbrImpl ospfNeighbor = null;
- OspfNeighborState nextNeighborState;
- Iterator nbrInterface = ospfInterface.listOfNeighbors().values().iterator();
- while (nbrInterface.hasNext()) {
- ospfNeighbor = (OspfNbrImpl) nbrInterface.next();
- nextNeighborState = ospfNeighbor.getState();
- if (nextNeighborState.getValue() == OspfNeighborState.FULL.getValue()) {
- if (listEligibleNeighbors == null) {
- listEligibleNeighbors = new ArrayList<OspfNbr>();
- listEligibleNeighbors.add(ospfNeighbor);
- } else {
- listEligibleNeighbors.add(ospfNeighbor);
- }
- }
- }
- return listEligibleNeighbors;
- }
-
- /**
- * Gets the LSDB LSA key from LSA header.
- *
- * @param lsaHeader LSA header instance
- * @return key LSA key
- */
- public String getLsaKey(LsaHeader lsaHeader) {
- return database.getLsaKey(lsaHeader);
- }
-
- /**
- * Adds the received LSA in other neighbors tx list.
- *
- * @param recLsa LSA Header instance
- */
- public void addToOtherNeighborLsaTxList(LsaHeader recLsa) {
- //Add the received LSA in other neighbors retransmission list.
- log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList");
- List<OspfInterface> ospfInterfaces = ospfInterfaceList();
- for (OspfInterface ospfInterfaceFromArea : ospfInterfaces) {
- Map neighbors = ospfInterfaceFromArea.listOfNeighbors();
- for (Object neighborIP : neighbors.keySet()) {
- OspfNbrImpl nbr = (OspfNbrImpl) neighbors.get(neighborIP);
- if (nbr.getState().getValue() < OspfNeighborState.EXCHANGE.getValue()) {
- continue;
- }
- String key = database.getLsaKey(recLsa);
- if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING) {
- if (nbr.getLsReqList().containsKey(key)) {
- LsaWrapper lsWrapper = lsaLookup(recLsa);
- if (lsWrapper != null) {
- LsaHeader ownLsa = (LsaHeader) lsWrapper.ospfLsa();
- String status = isNewerOrSameLsa(recLsa, ownLsa);
- if (status.equals("old")) {
- continue;
- } else if (status.equals("same")) {
- log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList: " +
- "Removing lsa from reTxtList {}", key);
- nbr.getLsReqList().remove(key);
- continue;
- } else {
- log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList: " +
- "Removing lsa from reTxtList {}", key);
- nbr.getLsReqList().remove(key);
- }
- }
- }
- }
- if (recLsa.advertisingRouter().toString().equals((String) neighborIP)) {
- continue;
- }
- if ((recLsa.lsType() == OspfParameters.LINK_LOCAL_OPAQUE_LSA ||
- recLsa.lsType() == OspfParameters.AREA_LOCAL_OPAQUE_LSA)) {
- if (nbr.isOpaqueCapable()) {
- log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList: Adding lsa to reTxtList {}",
- recLsa);
- nbr.getReTxList().put(key, recLsa);
- }
- } else {
- log.debug("OspfAreaImpl: addToOtherNeighborLsaTxList: Adding lsa to reTxtList {}",
- recLsa);
- nbr.getReTxList().put(key, recLsa);
- }
- }
- }
- }
-
- /**
- * Gets the options value.
- *
- * @return options value
- */
- public int options() {
- return options;
- }
-
- /**
- * Sets the options value.
- *
- * @param options options value
- */
- public void setOptions(int options) {
- this.options = options;
- }
-
- /**
- * Gets the opaque enabled options value.
- *
- * @return opaque enabled options value
- */
- public int opaqueEnabledOptions() {
- return Integer.parseInt(OspfParameters.OPAQUE_ENABLED_OPTION_VALUE, 2);
- }
-
- /**
- * Gets the lsdb instance for this area.
- *
- * @return lsdb instance
- */
- public OspfLsdb database() {
- return database;
- }
-}
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfInterfaceImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfInterfaceImpl.java
deleted file mode 100644
index be503c2..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfInterfaceImpl.java
+++ /dev/null
@@ -1,1801 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ospf.controller.area;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelFuture;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.LsaWrapper;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfLinkTed;
-import org.onosproject.ospf.controller.OspfLsa;
-import org.onosproject.ospf.controller.OspfMessage;
-import org.onosproject.ospf.controller.OspfNbr;
-import org.onosproject.ospf.controller.OspfNeighborState;
-import org.onosproject.ospf.controller.OspfPacketType;
-import org.onosproject.ospf.controller.OspfRouter;
-import org.onosproject.ospf.controller.TopologyForDeviceAndLink;
-import org.onosproject.ospf.controller.impl.Controller;
-import org.onosproject.ospf.controller.impl.OspfNbrImpl;
-import org.onosproject.ospf.controller.impl.TopologyForDeviceAndLinkImpl;
-import org.onosproject.ospf.controller.lsdb.LsaWrapperImpl;
-import org.onosproject.ospf.controller.lsdb.OspfLsdbImpl;
-import org.onosproject.ospf.controller.util.OspfEligibleRouter;
-import org.onosproject.ospf.controller.util.OspfInterfaceType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.ospfpacket.OspfMessageWriter;
-import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
-import org.onosproject.ospf.protocol.util.ChecksumCalculator;
-import org.onosproject.ospf.protocol.util.OspfInterfaceState;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Representation of an OSPF interface.
- */
-public class OspfInterfaceImpl implements OspfInterface {
- private static final Logger log = LoggerFactory.getLogger(OspfInterfaceImpl.class);
- private int interfaceIndex;
- private Ip4Address ipAddress;
- private Ip4Address ipNetworkMask;
- private Channel channel = null;
- private int helloIntervalTime;
- private int routerDeadIntervalTime;
- private int routerPriority;
- private int interfaceType;
- private int mtu;
- private int reTransmitInterval;
- private Ip4Address dr;
- private Ip4Address bdr;
- private OspfInterfaceState state;
- private List<LsaHeader> linkStateHeaders = new ArrayList<>();
- private Map<String, OspfNbr> listOfNeighbors = new ConcurrentHashMap<>();
- private Map<String, LsaHeader> listOfNeighborMap = new ConcurrentHashMap<>();
- private long delay = 0;
- private InternalHelloTimer helloTimerTask;
- private InternalWaitTimer waitTimerTask;
- private InternalDelayedAckTimer delayedAckTimerTask;
- private ScheduledExecutorService exServiceHello;
- private ScheduledExecutorService exServiceWait;
- private ScheduledExecutorService exServiceDelayedAck;
- private boolean isDelayedAckTimerScheduled = false;
- private int delayedAckTimerInterval = 2500;
- private int interfaceTypeOldValue = 0;
- private TopologyForDeviceAndLink topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
- private OspfArea ospfArea;
- private Controller controller;
-
-
- /**
- * Gets the interface state.
- *
- * @return interfaceState state of the interface
- */
- public OspfInterfaceState state() {
- return state;
- }
-
- /**
- * Sets the interface state.
- *
- * @param ospfInterfaceState interface state enum instance
- */
- public void setState(OspfInterfaceState ospfInterfaceState) {
- this.state = ospfInterfaceState;
- }
-
- /**
- * Sets the netty channel.
- *
- * @param channel channel
- */
- public void setChannel(Channel channel) {
- this.channel = channel;
- }
-
- /**
- * Returns OSPF area instance.
- *
- * @return OSPF area instance
- */
- @Override
- public OspfArea ospfArea() {
- return ospfArea;
- }
-
- /**
- * Sets OSPF controller instance.
- *
- * @param controller OSPF controller instance
- */
- public void setController(Controller controller) {
- this.controller = controller;
- }
-
- /**
- * Sets OSPF area instance.
- *
- * @param ospfArea OSPF area instance
- */
- @Override
- public void setOspfArea(OspfArea ospfArea) {
- this.ospfArea = ospfArea;
- }
-
- /**
- * Gets interface state.
- *
- * @return interface state
- */
- public String interfaceState() {
- return state.interfaceState();
- }
-
- /**
- * Gets link state headers.
- *
- * @return get the list of lsa headers
- */
- public List<LsaHeader> linkStateHeaders() {
- Set<String> key = listOfNeighborMap.keySet();
- for (String keys : key) {
- LsaHeader lsaHeader = listOfNeighborMap.get(keys);
- linkStateHeaders.add(lsaHeader);
- }
- return linkStateHeaders;
- }
-
- /**
- * Gets IP network mask.
- *
- * @return network mask
- */
- @Override
- public Ip4Address ipNetworkMask() {
- return ipNetworkMask;
- }
-
- /**
- * Sets IP network mask.
- *
- * @param ipNetworkMask network mask
- */
- @Override
- public void setIpNetworkMask(Ip4Address ipNetworkMask) {
- this.ipNetworkMask = ipNetworkMask;
- }
-
- /**
- * Adds neighboring router to list.
- *
- * @param ospfNbr ospfNbr instance
- */
- @Override
- public void addNeighbouringRouter(OspfNbr ospfNbr) {
- listOfNeighbors.put(ospfNbr.neighborId().toString(), ospfNbr);
- }
-
- /**
- * Gets the neighbour details from listOfNeighbors map.
- *
- * @param neighborId neighbors id
- * @return ospfNbr neighbor instance
- */
- @Override
- public OspfNbr neighbouringRouter(String neighborId) {
- return listOfNeighbors.get(neighborId);
- }
-
- /**
- * Removes all the neighbors.
- */
- @Override
- public void removeNeighbors() {
- Set<String> neighbors = listOfNeighbors.keySet();
- for (String neighborId : neighbors) {
- removeNeighbor(listOfNeighbors.get(neighborId));
- log.debug("Neighbor removed - {}", neighborId);
- }
- listOfNeighbors.clear();
- }
-
- /**
- * Removes neighbor from the interface neighbor map.
- *
- * @param ospfNeighbor OSPF neighbor instance
- */
- public void removeNeighbor(OspfNbr ospfNeighbor) {
- log.debug("Neighbor removed - {}", ospfNeighbor.neighborId());
- ospfNeighbor.stopInactivityTimeCheck();
- ospfNeighbor.stopFloodingTimer();
- ospfNeighbor.stopRxMtDdTimer();
- ospfNeighbor.stopRxMtLsrTimer();
-
- listOfNeighbors.remove(ospfNeighbor.neighborId().toString());
- }
-
-
- /**
- * Adds LSA header to map.
- *
- * @param lsaHeader LSA header instance
- */
- public void addLsaHeaderForDelayAck(LsaHeader lsaHeader) {
- String key = lsaHeader.lsType() + "-" + lsaHeader.linkStateId() + "-" +
- lsaHeader.advertisingRouter();
- if (lsaHeader.lsType() == OspfParameters.LINK_LOCAL_OPAQUE_LSA ||
- lsaHeader.lsType() == OspfParameters.AREA_LOCAL_OPAQUE_LSA ||
- lsaHeader.lsType() == OspfParameters.AS_OPAQUE_LSA) {
- OpaqueLsaHeader header = (OpaqueLsaHeader) lsaHeader;
- key = lsaHeader.lsType() + "-" + header.opaqueType() + header.opaqueId()
- + "-" + lsaHeader.advertisingRouter();
- }
-
- log.debug("Adding LSA key {} for delayed Ack", key);
- listOfNeighborMap.put(key, lsaHeader);
- }
-
- /**
- * Removes LSA header from map.
- *
- * @param lsaKey key used to store LSA in map
- */
- @Override
- public void removeLsaFromNeighborMap(String lsaKey) {
- listOfNeighborMap.remove(lsaKey);
- }
-
- /**
- * Checks neighbor is in the list or not.
- *
- * @param neighborId neighbors id
- * @return true if neighbor in list else false
- */
- @Override
- public boolean isNeighborInList(String neighborId) {
- return listOfNeighbors.containsKey(neighborId);
- }
-
- /**
- * Gets the list of neighbors.
- *
- * @return listOfNeighbors as key value pair
- */
- @Override
- public Map<String, OspfNbr> listOfNeighbors() {
- return listOfNeighbors;
- }
-
- /**
- * Sets the list of neighbors.
- *
- * @param listOfNeighbors as key value pair
- */
- public void setListOfNeighbors(HashMap<String, OspfNbr> listOfNeighbors) {
- this.listOfNeighbors = listOfNeighbors;
- }
-
- /**
- * Returns interface index.
- *
- * @return interface index
- */
- @Override
- public int interfaceIndex() {
- return interfaceIndex;
- }
-
- /**
- * Set interface index.
- *
- * @param interfaceIndex interface index
- */
- @Override
- public void setInterfaceIndex(int interfaceIndex) {
- this.interfaceIndex = interfaceIndex;
- }
-
- /**
- * Gets the IP address.
- *
- * @return IP address
- */
- @Override
- public Ip4Address ipAddress() {
- return ipAddress;
- }
-
- /**
- * Sets the interface IP address.
- *
- * @param ipAddress interface IP address
- */
- @Override
- public void setIpAddress(Ip4Address ipAddress) {
- this.ipAddress = ipAddress;
- }
-
- /**
- * Gets router priority.
- *
- * @return routerPriority value
- */
- @Override
- public int routerPriority() {
- return routerPriority;
- }
-
- /**
- * Sets router priority.
- *
- * @param routerPriority value
- */
- @Override
- public void setRouterPriority(int routerPriority) {
- this.routerPriority = routerPriority;
- }
-
- /**
- * Gets hello interval time.
- *
- * @return hello interval time
- */
- @Override
- public int helloIntervalTime() {
- return helloIntervalTime;
- }
-
- /**
- * Sets hello interval time.
- *
- * @param helloIntervalTime an integer interval time
- */
- @Override
- public void setHelloIntervalTime(int helloIntervalTime) {
- this.helloIntervalTime = helloIntervalTime;
- }
-
- /**
- * Gets router dead interval time.
- *
- * @return router dead interval time
- */
- @Override
- public int routerDeadIntervalTime() {
- return routerDeadIntervalTime;
- }
-
- /**
- * Sets router dead interval time.
- *
- * @param routerDeadIntervalTime router dead interval time
- */
- @Override
- public void setRouterDeadIntervalTime(int routerDeadIntervalTime) {
- this.routerDeadIntervalTime = routerDeadIntervalTime;
- }
-
- /**
- * Gets interface type.
- *
- * @return interfaceType an integer represents interface type
- */
- @Override
- public int interfaceType() {
- return interfaceType;
- }
-
- /**
- * Sets interface type.
- *
- * @param interfaceType interface type
- */
- @Override
- public void setInterfaceType(int interfaceType) {
- this.interfaceType = interfaceType;
- }
-
- /**
- * Gets max transfer unit.
- *
- * @return mtu an integer represents max transfer unit
- */
- @Override
- public int mtu() {
- return mtu;
- }
-
- /**
- * Sets max transfer unit.
- *
- * @param mtu max transfer unit
- */
- @Override
- public void setMtu(int mtu) {
- this.mtu = mtu;
- }
-
- /**
- * Gets retransmit interval.
- *
- * @return retransmit interval
- */
- @Override
- public int reTransmitInterval() {
- return reTransmitInterval;
- }
-
- /**
- * Sets retransmit interval.
- *
- * @param reTransmitInterval retransmit interval
- */
- @Override
- public void setReTransmitInterval(int reTransmitInterval) {
- this.reTransmitInterval = reTransmitInterval;
- }
-
- /**
- * Gets designated routers IP address.
- *
- * @return dr designated routers IP address
- */
- @Override
- public Ip4Address dr() {
- return dr;
- }
-
- /**
- * Sets designated routers IP address.
- *
- * @param dr designated routers IP address
- */
- @Override
- public void setDr(Ip4Address dr) {
- this.dr = dr;
- }
-
- /**
- * Gets backup designated routers IP address.
- *
- * @return bdr backup designated routers IP address
- */
- @Override
- public Ip4Address bdr() {
- return bdr;
- }
-
- /**
- * Sets backup designated routers IP address.
- *
- * @param bdr backup designated routers IP address
- */
- @Override
- public void setBdr(Ip4Address bdr) {
- this.bdr = bdr;
- }
-
- /**
- * Represents an interface is up and connected.
- */
- @Override
- public void interfaceUp() {
- log.debug("OSPFInterfaceChannelHandler::interfaceUp...!!!");
- if (interfaceType() == OspfInterfaceType.POINT_TO_POINT.value()) {
- setState(OspfInterfaceState.POINT2POINT);
- interfaceTypeOldValue = interfaceType();
- log.debug("OSPFInterfaceChannelHandler::InterfaceType {} state {} ",
- interfaceType(), state());
- } else if (interfaceType() == OspfInterfaceType.BROADCAST.value()) {
- //if router priority is 0, move the state to DROther
- interfaceTypeOldValue = interfaceType();
- if (routerPriority() == 0) {
- setState(OspfInterfaceState.DROTHER);
- } else {
- log.debug("OSPFInterfaceChannelHandler::InterfaceType {} state {} RouterPriority {}",
- interfaceType(),
- state(), routerPriority());
- setState(OspfInterfaceState.WAITING);
- //start wait timer - like inactivity timer with router deadInterval
- startWaitTimer();
- }
- }
- // Start hello timer with interval from config - convert seconds to milliseconds
- startHelloTimer();
- ospfArea.refreshArea(this);
- }
-
-
- /**
- * Gets called when a BDR was detected before the wait timer expired.
- *
- * @param ch channel instance
- */
- public void backupSeen(Channel ch) {
- log.debug("OSPFInterfaceChannelHandler::backupSeen ");
- if (state() == OspfInterfaceState.WAITING) {
- electRouter(ch);
- }
- }
-
- /**
- * Gets called when no hello message received for particular period.
- *
- * @param ch channel instance
- */
- public void waitTimer(Channel ch) {
- log.debug("OSPFInterfaceChannelHandler::waitTimer ");
- //According to RFC-2328 section 9.4
- if (state() == OspfInterfaceState.WAITING) {
- electRouter(ch);
- }
- }
-
- /**
- * Initiates DR election process.
- *
- * @param ch netty channel instance
- */
- public void callDrElection(Channel ch) {
- log.debug("OSPFInterfaceChannelHandler::callDrElection ");
- //call when timer expired
- //no hello message received for particular interval
- //section 9.4
- electRouter(ch);
- interfaceTypeOldValue = interfaceType();
- }
-
- /**
- * Neighbor change event is triggered when the router priority gets changed.
- */
- public void neighborChange() {
- log.debug("OSPFInterfaceChannelHandler::neighborChange ");
- if (state() == OspfInterfaceState.DR || state() == OspfInterfaceState.BDR ||
- state() == OspfInterfaceState.DROTHER) {
- electRouter(channel);
- }
- }
-
- /**
- * Gets called when an interface is down.
- * All interface variables are reset, and interface timers disabled.
- * Also all neighbor connections associated with the interface are destroyed.
- */
- @Override
- public void interfaceDown() {
- log.debug("OSPFInterfaceChannelHandler::interfaceDown ");
- stopHelloTimer();
- listOfNeighbors().clear();
- setState(OspfInterfaceState.DOWN);
- }
-
- /**
- * When an OSPF message received it is handed over to this method.
- * Based on the type of the OSPF message received it will be handed over
- * to corresponding message handler methods.
- *
- * @param ospfMessage received OSPF message
- * @param ctx channel handler context instance.
- */
- @Override
- public void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) {
- log.debug("OspfChannelHandler::processOspfMessage...!!!");
-
- if (!validateMessage(ospfMessage)) {
- return;
- }
-
- try {
- switch (ospfMessage.ospfMessageType().value()) {
- case OspfParameters.HELLO:
- processHelloMessage(ospfMessage, ctx);
- break;
- case OspfParameters.DD:
- processDdMessage(ospfMessage, ctx);
- break;
- case OspfParameters.LSREQUEST:
- processLsRequestMessage(ospfMessage, ctx);
- break;
- case OspfParameters.LSUPDATE:
- processLsUpdateMessage(ospfMessage, ctx);
- break;
- case OspfParameters.LSACK:
- processLsAckMessage(ospfMessage, ctx);
- break;
- default:
- log.debug("Unknown packet to process...!!!");
- break;
- }
- } catch (OspfParseException ope) {
- log.debug("Error parsing packet", ope);
- }
- }
-
- /**
- * Validates the OSPF message received.
- *
- * @param ospfMessage OSPF message.
- * @return true if it is a valid else false.
- */
- private boolean validateMessage(OspfMessage ospfMessage) {
- boolean isValid = true;
- OspfPacketHeader header = (OspfPacketHeader) ospfMessage;
-
- //added the check to eliminate self origin packets also two interfaces on same router.
- if (!header.sourceIp().equals(ipAddress()) && !header.routerId().equals(
- ospfArea.routerId())) {
- //Verify the checksum
- ChecksumCalculator checksum = new ChecksumCalculator();
- if (!checksum.isValidOspfCheckSum(ospfMessage, OspfUtil.OSPFPACKET_CHECKSUM_POS1,
- OspfUtil.OSPFPACKET_CHECKSUM_POS2)) {
- log.debug("Checksum mismatch. Received packet type {} ", ospfMessage.ospfMessageType());
- return false;
- }
- if (((OspfPacketHeader) ospfMessage).ospfVersion() != OspfUtil.OSPF_VERSION_2) {
- log.debug("Received osfpMessage Version should match with Interface Version ");
- return false;
- }
- if (!((OspfPacketHeader) ospfMessage).areaId().equals(ospfArea.areaId())) {
- log.debug("Received ospf packets are from different area than our Area ID. " +
- "Received Area ID {}, Our AreaId {} ",
- ((OspfPacketHeader) ospfMessage).areaId(), ospfArea.areaId());
- return false;
- }
-
- //According to RFC-2328 (8.2)
- /*
- * ABR should receive packets from backbone 0.0.0.0 as we are not acting as ABR
- * we are rejecting the packet.
- */
- if (((OspfPacketHeader) ospfMessage).areaId().equals(Ip4Address.valueOf("0.0.0.0"))) {
- log.debug("ABR should receive packets from backbone 0.0.0.0 as we are not acting as " +
- "ABR we are rejecting the ospf packet");
- return false;
- }
- if (interfaceType() == OspfInterfaceType.BROADCAST.value() &&
- !OspfUtil.sameNetwork(((OspfPacketHeader) ospfMessage).sourceIp(),
- ipAddress(), ipNetworkMask())) {
- log.debug("Received packets from different subnets. Discarding...!!!");
- return false;
- }
- } else {
- isValid = false;
- }
-
- return isValid;
- }
-
- /**
- * Processes Hello message.
- *
- * @param ospfMessage OSPF message instance.
- * @param ctx context instance.
- */
- void processHelloMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) {
- Channel channel = ctx.getChannel();
- log.debug("OspfChannelHandler::processHelloMessage...!!!");
- HelloPacket helloPacket = (HelloPacket) ospfMessage;
-
- // processing of hello packet as per RFC 2328 section 10.5
- log.debug("OspfChannelHandler::processHelloMessage::Interface Type {} OSPFInterfaceState {} ",
- interfaceType(), state());
-
- if (interfaceType() != OspfInterfaceType.POINT_TO_POINT.value()) {
- if (!helloPacket.networkMask().equals(ipNetworkMask())) {
- log.debug("OspfChannelHandler::processHelloMessage::Hello Packet Received does not " +
- "match the same network mask as the configure Interface");
- return;
- }
- }
- if (helloPacket.helloInterval() != helloIntervalTime()) {
- log.debug("OspfChannelHandler::processHelloMessage::Hello Packet Received have the same " +
- "hello interval as configured Interface");
- return;
- }
- if (helloPacket.routerDeadInterval() != routerDeadIntervalTime()) {
- log.debug("OspfChannelHandler::processHelloMessage::Hello Packet Received have the same " +
- "Router Dead interval as configured Interface");
- return;
- }
-
- if (interfaceType == OspfInterfaceType.POINT_TO_POINT.value() &&
- !helloPacket.dr().equals(OspfUtil.DEFAULTIP)) {
- log.debug("OspfChannelHandler::processHelloMessage:: Neighbor in broadcast network");
- return;
- }
-
- if (interfaceType == OspfInterfaceType.POINT_TO_POINT.value()) {
- // to verify if the neighbor which sent the hello is present in the OSPF Interface neighboring list .
- OspfNbr nbr;
- if (!isNeighborInList(helloPacket.routerId().toString())) {
- nbr = new OspfNbrImpl(ospfArea, this, helloPacket.sourceIp(),
- helloPacket.routerId(), helloPacket.options(), topologyForDeviceAndLink);
- addNeighbouringRouter(nbr);
- } else {
- nbr = neighbouringRouter(helloPacket.routerId().toString());
- nbr.setRouterPriority(helloPacket.routerPriority());
- }
- if (!helloPacket.containsNeighbour(ospfArea.routerId())) {
- ((OspfNbrImpl) nbr).oneWayReceived(helloPacket, channel);
- } else {
- ((OspfNbrImpl) nbr).twoWayReceived(helloPacket, ctx.getChannel());
- }
- } else if (interfaceType == OspfInterfaceType.BROADCAST.value()) {
-
- if (state() == OspfInterfaceState.WAITING) {
- if ((!helloPacket.dr().equals(Ip4Address.valueOf("0.0.0.0"))) &&
- (!helloPacket.bdr().equals(Ip4Address.valueOf("0.0.0.0")))) {
- stopWaitTimer();
- setDr(helloPacket.dr());
- setBdr(helloPacket.bdr());
- if (helloPacket.dr().equals(ipAddress())) {
- setState(OspfInterfaceState.DR);
- //refresh router Lsa
- ospfArea.refreshArea(this);
- } else if (helloPacket.bdr().equals(ipAddress())) {
- setState(OspfInterfaceState.BDR);
- //refresh router Lsa
- ospfArea.refreshArea(this);
- } else {
- setState(OspfInterfaceState.DROTHER);
- ospfArea.refreshArea(this);
- }
-
- } else if (!helloPacket.dr().equals(Ip4Address.valueOf("0.0.0.0")) ||
- !helloPacket.bdr().equals(Ip4Address.valueOf("0.0.0.0"))) {
- setDr(helloPacket.dr());
- setBdr(helloPacket.bdr());
- }
- Ip4Address sourceIp = helloPacket.sourceIp();
- OspfNbr nbr;
- if (!isNeighborInList(helloPacket.routerId().toString())) {
- nbr = new OspfNbrImpl(ospfArea, this, sourceIp, helloPacket.routerId(),
- helloPacket.options(), topologyForDeviceAndLink);
- nbr.setNeighborId(helloPacket.routerId());
- nbr.setNeighborBdr(helloPacket.bdr());
- nbr.setNeighborDr(helloPacket.dr());
- nbr.setRouterPriority(helloPacket.routerPriority());
- addNeighbouringRouter(nbr);
- } else {
- nbr = neighbouringRouter(helloPacket.routerId().toString());
- nbr.setRouterPriority(helloPacket.routerPriority());
- }
- if (!helloPacket.containsNeighbour(ospfArea.routerId())) {
- ((OspfNbrImpl) nbr).oneWayReceived(helloPacket, channel);
- } else {
- ((OspfNbrImpl) nbr).twoWayReceived(helloPacket, ctx.getChannel());
- }
-
- if (helloPacket.dr().equals(sourceIp)) {
- if (helloPacket.bdr().equals(Ip4Address.valueOf("0.0.0.0"))) {
- // call backup seen
- stopWaitTimer();
- backupSeen(ctx.getChannel());
- }
- }
-
- if (helloPacket.bdr().equals(sourceIp)) {
- // call backup seen
- stopWaitTimer();
- backupSeen(ctx.getChannel());
- }
- } else {
-
- if ((!helloPacket.dr().equals(Ip4Address.valueOf("0.0.0.0")) ||
- !helloPacket.bdr().equals(Ip4Address.valueOf("0.0.0.0")))
- && routerPriority() == 0) {
- setDr(helloPacket.dr());
- setBdr(helloPacket.bdr());
- }
- //To verify if the neighbor which sent the hello is present in the OSPF Interface neighboring list .
- Ip4Address sourceIp = helloPacket.sourceIp();
- OspfNbr nbr;
- if (!isNeighborInList(helloPacket.routerId().toString())) {
- nbr = new OspfNbrImpl(ospfArea, this, sourceIp, helloPacket.routerId(),
- helloPacket.options(), topologyForDeviceAndLink);
- nbr.setNeighborId(helloPacket.routerId());
- nbr.setNeighborBdr(helloPacket.bdr());
- nbr.setNeighborDr(helloPacket.dr());
- nbr.setRouterPriority(helloPacket.routerPriority());
- addNeighbouringRouter(nbr);
- ((OspfNbrImpl) nbr).oneWayReceived(helloPacket, channel);
- } else {
- log.debug("OspfChannelHandler::NeighborInList::helloPacket.bdr(): {}, " +
- "helloPacket.dr(): {}", helloPacket.bdr(), helloPacket.dr());
- nbr = neighbouringRouter(helloPacket.routerId().toString());
- nbr.setRouterPriority(helloPacket.routerPriority());
- if (!helloPacket.containsNeighbour(ospfArea.routerId())) {
- ((OspfNbrImpl) nbr).oneWayReceived(helloPacket, channel);
- } else {
- ((OspfNbrImpl) nbr).twoWayReceived(helloPacket, ctx.getChannel());
- }
- if (nbr.routerPriority() != helloPacket.routerPriority()) {
- nbr.setNeighborBdr(helloPacket.bdr());
- nbr.setNeighborDr(helloPacket.dr());
- neighborChange();
- }
-
-
- if (nbr.neighborIpAddr().equals(helloPacket.dr()) &&
- !(nbr.neighborIpAddr().equals(nbr.neighborDr()))) {
- nbr.setNeighborBdr(helloPacket.bdr());
- nbr.setNeighborDr(helloPacket.dr());
- neighborChange();
- }
-
- if (!(nbr.neighborIpAddr().equals(helloPacket.dr())) &&
- (nbr.neighborIpAddr().equals(nbr.neighborDr()))) {
- nbr.setNeighborBdr(helloPacket.bdr());
- nbr.setNeighborDr(helloPacket.dr());
- neighborChange();
- }
-
- if (nbr.neighborIpAddr().equals(helloPacket.bdr()) &&
- !(nbr.neighborIpAddr().equals(nbr.neighborBdr()))) {
- nbr.setNeighborBdr(helloPacket.bdr());
- nbr.setNeighborDr(helloPacket.dr());
- neighborChange();
- }
-
- if (!(nbr.neighborIpAddr().equals(helloPacket.bdr())) &&
- (nbr.neighborIpAddr().equals(nbr.neighborBdr()))) {
- nbr.setNeighborBdr(helloPacket.bdr());
- nbr.setNeighborDr(helloPacket.dr());
- neighborChange();
- }
-
- nbr.setNeighborBdr(helloPacket.bdr());
- nbr.setNeighborDr(helloPacket.dr());
- }
- }
- }
- }
-
- /**
- * process the DD message which received.
- *
- * @param ospfMessage OSPF message instance.
- * @param ctx channel handler context instance
- */
- void processDdMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) {
- log.debug("OspfChannelHandler::processDdMessage...!!!");
- Channel channel = ctx.getChannel();
- DdPacket ddPacket = (DdPacket) ospfMessage;
- log.debug("Got DD packet from {}", ddPacket.sourceIp());
- //check it is present in listOfNeighbors
- Ip4Address neighbourId = ddPacket.routerId();
- OspfNbr nbr = neighbouringRouter(neighbourId.toString());
-
- if (nbr != null) {
- log.debug("OspfChannelHandler::processDdMessage:: OSPFNeighborState {}", nbr.getState());
- // set options for the NBR
- nbr.setIsOpaqueCapable(ddPacket.isOpaqueCapable());
- if (ddPacket.imtu() > mtu()) {
- log.debug("the MTU size is greater than the interface MTU");
- return;
- }
- if (nbr.getState() == OspfNeighborState.DOWN) {
- return;
- }
- if (nbr.getState() == OspfNeighborState.ATTEMPT) {
- return;
- }
- if (nbr.getState() == OspfNeighborState.TWOWAY) {
- nbr.adjOk(channel);
- return;
- }
- //if init is the state call twoWayReceived
- if (nbr.getState() == OspfNeighborState.INIT) {
- ((OspfNbrImpl) nbr).twoWayReceived(ddPacket, ctx.getChannel());
- } else if (nbr.getState() == OspfNeighborState.EXSTART) {
- //get I,M,MS Bits
- int initialize = ddPacket.isInitialize();
- int more = ddPacket.isMore();
- int masterOrSlave = ddPacket.isMaster();
- int options = ddPacket.options();
- nbr.setOptions(options);
-
- if (initialize == OspfUtil.INITIALIZE_SET && more == OspfUtil.MORE_SET &&
- masterOrSlave == OspfUtil.IS_MASTER) {
- if (ddPacket.getLsaHeaderList().isEmpty()) {
- if (OspfUtil.ipAddressToLong(ddPacket.routerId().toString()) >
- OspfUtil.ipAddressToLong(ospfArea.routerId().toString())) {
- nbr.setIsMaster(OspfUtil.IS_MASTER);
- ((OspfNbrImpl) nbr).setLastDdPacket(ddPacket);
- nbr.setDdSeqNum(ddPacket.sequenceNo());
- nbr.setOptions(ddPacket.options());
- ((OspfNbrImpl) nbr).negotiationDone(ddPacket, true, ddPacket.getLsaHeaderList(),
- ctx.getChannel());
- }
- }
- }
- if (initialize == OspfUtil.INITIALIZE_NOTSET && masterOrSlave == OspfUtil.NOT_MASTER) {
- if (nbr.ddSeqNum() == ddPacket.sequenceNo()) {
- if (OspfUtil.ipAddressToLong(ddPacket.routerId().toString()) <
- OspfUtil.ipAddressToLong(ospfArea.routerId().toString())) {
- ((OspfNbrImpl) nbr).setLastDdPacket(ddPacket);
- nbr.setOptions(ddPacket.options());
- nbr.setDdSeqNum(nbr.ddSeqNum() + 1);
- ((OspfNbrImpl) nbr).negotiationDone(ddPacket, false, ddPacket.getLsaHeaderList(),
- ctx.getChannel());
- }
- }
- }
-
- } else if (nbr.getState() == OspfNeighborState.EXCHANGE) {
- //get I,M,MS Bits
- log.debug("Neighbor state:: EXCHANGE");
- boolean isDuplicateDDPacket = compareDdPackets(ddPacket, ((OspfNbrImpl) nbr).lastDdPacket());
- int initialize = ddPacket.isInitialize();
- int more = ddPacket.isMore();
- int masterOrSlave = ddPacket.isMaster();
- int options = ddPacket.options();
-
- if (!isDuplicateDDPacket) {
- //if dd packet is not duplicate then continue
- if (nbr.isMaster() != masterOrSlave) {
- DdPacket newResPacket =
- (DdPacket) ((OspfNbrImpl) nbr).seqNumMismatch("Master/Slave Inconsistency");
- newResPacket.setDestinationIp(ddPacket.sourceIp());
- log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
- byte[] messageToWrite = getMessage(newResPacket);
- ctx.getChannel().write(messageToWrite);
- } else if (initialize == 1) {
- DdPacket newResPacket =
- (DdPacket) ((OspfNbrImpl) nbr).seqNumMismatch("Initialize bit inconsistency");
- newResPacket.setDestinationIp(ddPacket.sourceIp());
- log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
- byte[] messageToWrite = getMessage(newResPacket);
- ctx.getChannel().write(messageToWrite);
- } else {
-
- if (masterOrSlave == OspfUtil.NOT_MASTER) {
- if (ddPacket.sequenceNo() == nbr.ddSeqNum()) {
- //Process the DD Packet
- ((OspfNbrImpl) nbr).processDdPacket(false, ddPacket, ctx.getChannel());
- log.debug("Received DD Packet");
- } else {
- DdPacket newResPacket =
- (DdPacket) ((OspfNbrImpl) nbr).seqNumMismatch("Sequence Number Mismatch");
- newResPacket.setDestinationIp(ddPacket.sourceIp());
- log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
- byte[] messageToWrite = getMessage(newResPacket);
- ctx.getChannel().write(messageToWrite);
- }
- } else {
- //we are the slave
- if (ddPacket.sequenceNo() == (nbr.ddSeqNum() + 1)) {
- ((OspfNbrImpl) nbr).setLastDdPacket(ddPacket);
- ((OspfNbrImpl) nbr).processDdPacket(true, ddPacket, ctx.getChannel());
- log.debug("Process DD Packet");
- } else {
- DdPacket newResPacket =
- (DdPacket) ((OspfNbrImpl) nbr).seqNumMismatch("options inconsistency");
- newResPacket.setDestinationIp(ddPacket.sourceIp());
- log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
- byte[] messageToWrite = getMessage(newResPacket);
- ctx.getChannel().write(messageToWrite);
- }
- }
- }
- } else {
- if (masterOrSlave == OspfUtil.NOT_MASTER) {
- return;
- } else {
- DdPacket newResPacket = ((OspfNbrImpl) nbr).lastSentDdPacket();
- log.debug("Sending back DDPacket to {}", ddPacket.sourceIp());
- byte[] messageToWrite = getMessage(newResPacket);
- ctx.getChannel().write(messageToWrite);
- }
- }
- } else if (nbr.getState() == OspfNeighborState.LOADING || nbr.getState() == OspfNeighborState.FULL) {
- //In case if we are slave then we have to send the last received DD Packet
- int options = ddPacket.options();
- if (nbr.options() != options) {
- OspfMessage newResPacket = ((OspfNbrImpl) nbr).seqNumMismatch("Initialize bit inconsistency");
- newResPacket.setDestinationIp(ddPacket.sourceIp());
- byte[] messageToWrite = getMessage(newResPacket);
- ctx.getChannel().write(messageToWrite);
- } else if (ddPacket.isInitialize() == OspfUtil.INITIALIZE_SET) {
- OspfMessage newResPacket = ((OspfNbrImpl) nbr).seqNumMismatch("Initialize bit inconsistency");
- newResPacket.setDestinationIp(ddPacket.sourceIp());
- byte[] messageToWrite = getMessage(newResPacket);
- ctx.getChannel().write(messageToWrite);
- }
- boolean isDuplicate = compareDdPackets(ddPacket, ((OspfNbrImpl) nbr).lastDdPacket());
- //we are master
- if (nbr.isMaster() != OspfUtil.IS_MASTER) {
- // check if the packet is duplicate, duplicates should be discarded by the master
- if (isDuplicate) {
- log.debug("received a duplicate DD packet");
- }
- } else {
- //The slave must respond to duplicates by repeating the last Database Description packet
- //that it had sent.
- if (isDuplicate) {
- ddPacket.setDestinationIp(ddPacket.sourceIp());
- byte[] messageToWrite = getMessage(((OspfNbrImpl) nbr).lastSentDdPacket());
- ctx.getChannel().write(messageToWrite);
- log.debug("Sending back the duplicate packet ");
- }
- }
- }
- }
- }
-
- /**
- * Process the Ls Request message.
- *
- * @param ospfMessage OSPF message instance.
- * @param ctx channel handler context instance.
- */
- void processLsRequestMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) {
- log.debug("OspfChannelHandler::processLsRequestMessage...!!!");
- Channel channel = ctx.getChannel();
- LsRequest lsrPacket = (LsRequest) ospfMessage;
- OspfNbr nbr = neighbouringRouter(lsrPacket.routerId().toString());
-
- if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING ||
- nbr.getState() == OspfNeighborState.FULL) {
-
- LsRequest reqMsg = (LsRequest) ospfMessage;
- if (reqMsg.getLinkStateRequests().isEmpty()) {
- log.debug("Received Link State Request Vector is Empty ");
- return;
- } else {
- //Send the LsUpdate back
- ListIterator<LsRequestPacket> listItr = reqMsg.getLinkStateRequests().listIterator();
- while (listItr.hasNext()) {
- LsUpdate lsupdate = new LsUpdate();
- lsupdate.setOspfVer(OspfUtil.OSPF_VERSION);
- lsupdate.setOspftype(OspfPacketType.LSUPDATE.value());
- lsupdate.setRouterId(ospfArea.routerId());
- lsupdate.setAreaId(ospfArea.areaId());
- lsupdate.setAuthType(OspfUtil.NOT_ASSIGNED);
- lsupdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
- lsupdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
- lsupdate.setChecksum(OspfUtil.NOT_ASSIGNED);
-
- //limit to mtu
- int currentLength = OspfUtil.OSPF_HEADER_LENGTH + OspfUtil.FOUR_BYTES;
- int maxSize = mtu() -
- OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
- int noLsa = 0;
- while (listItr.hasNext()) {
- LsRequestPacket lsRequest = listItr.next();
- // to verify length of the LSA
- LsaWrapper wrapper = ospfArea.getLsa(lsRequest.lsType(), lsRequest.linkStateId(),
- lsRequest.ownRouterId());
- if (wrapper != null) {
- OspfLsa ospflsa = wrapper.ospfLsa();
- if ((currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen()) >= maxSize) {
- listItr.previous();
- break;
- }
- if (ospflsa != null) {
- lsupdate.addLsa(ospflsa);
- noLsa++;
-
- currentLength = currentLength + ((LsaWrapperImpl) wrapper).lsaHeader().lsPacketLen();
- } else {
- nbr.badLSReq(channel);
- }
- }
- }
- lsupdate.setNumberOfLsa(noLsa);
- //set the destination
- if (state() == OspfInterfaceState.DR ||
- state() == OspfInterfaceState.BDR ||
- state() == OspfInterfaceState.POINT2POINT) {
- lsupdate.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
- } else if (state() == OspfInterfaceState.DROTHER) {
- lsupdate.setDestinationIp(OspfUtil.ALL_DROUTERS);
- }
- byte[] messageToWrite = getMessage(lsupdate);
- ctx.getChannel().write(messageToWrite);
- }
- }
- }
- }
-
- /**
- * Process the ls update message.
- *
- * @param ospfMessage OSPF message instance.
- * @param ctx channel handler context instance.
- * @throws OspfParseException on parsing error
- */
- void processLsUpdateMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws OspfParseException {
- log.debug("OspfChannelHandler::processLsUpdateMessage");
- LsUpdate lsUpdate = (LsUpdate) ospfMessage;
- String neighbourId = lsUpdate.routerId().toString();
- //LSUpdate packet has been associated with a particular neighbor.
- //Neighbor should not be in lesser state than Exchange.
- if (isNeighborInList(neighbourId)) {
- OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(neighbourId);
- if (nbr.getState() == OspfNeighborState.EXCHANGE ||
- nbr.getState() == OspfNeighborState.LOADING) {
- nbr.processLsUpdate(lsUpdate, ctx.getChannel());
- } else if (nbr.getState() == OspfNeighborState.FULL) {
- if (lsUpdate.noLsa() != 0) {
- List<OspfLsa> list = lsUpdate.getLsaList();
- Iterator itr = list.iterator();
- while (itr.hasNext()) {
- LsaHeader lsa = (LsaHeader) itr.next();
- nbr.processReceivedLsa(lsa, true, ctx.getChannel(), lsUpdate.sourceIp());
- }
- } else {
- return;
- }
- }
- }
- }
-
- /**
- * Process the ls acknowledge message.
- *
- * @param ospfMessage OSPF message instance.
- * @param ctx channel handler context instance.
- */
- void processLsAckMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) {
- log.debug("OspfChannelHandler::processLsAckMessage");
- LsAcknowledge lsAckPacket = (LsAcknowledge) ospfMessage;
- //check it is present in listOfNeighbors
- OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(lsAckPacket.routerId().toString());
- if (nbr != null) {
- if (nbr.getState().getValue() < OspfNeighborState.EXCHANGE.getValue()) {
- // discard the packet.
- return;
- } else {
- // process ls acknowledgements
- Iterator itr = lsAckPacket.getLinkStateHeaders().iterator();
- while (itr.hasNext()) {
- LsaHeader lsRequest = (LsaHeader) itr.next();
-
- OspfLsa ospfLsa =
- nbr.getPendingReTxList().get(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest));
- if (ospfLsa != null) {
- String isSame = ((OspfLsdbImpl) ospfArea.database()).isNewerOrSameLsa(
- lsRequest, (LsaHeader) ospfLsa);
- if (isSame.equals("same")) {
- nbr.getPendingReTxList().remove(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest));
- }
- }
- }
- }
- }
- }
-
- /**
- * Compares two Dd Packets to check whether its duplicate or not.
- *
- * @param receivedDPacket received DD packet from network.
- * @param lastDdPacket Last DdPacket which we sent.
- * @return true if it is a duplicate packet else false.
- */
- public boolean compareDdPackets(DdPacket receivedDPacket, DdPacket lastDdPacket) {
- if (receivedDPacket.isInitialize() == lastDdPacket.isInitialize()) {
- if (receivedDPacket.isMaster() == lastDdPacket.isMaster()) {
- if (receivedDPacket.isMore() == lastDdPacket.isMore()) {
- if (receivedDPacket.options() == lastDdPacket.options()) {
- if (receivedDPacket.sequenceNo() == lastDdPacket.sequenceNo()) {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
-
- /**
- * Starts the hello timer which sends hello packet every configured seconds.
- */
- @Override
- public void startHelloTimer() {
- log.debug("OSPFInterfaceChannelHandler::startHelloTimer");
- exServiceHello = Executors.newSingleThreadScheduledExecutor();
- helloTimerTask = new InternalHelloTimer();
- final ScheduledFuture<?> helloHandle =
- exServiceHello.scheduleAtFixedRate(helloTimerTask, delay, helloIntervalTime, TimeUnit.SECONDS);
- }
-
- /**
- * Stops the hello timer.
- */
- @Override
- public void stopHelloTimer() {
- log.debug("OSPFInterfaceChannelHandler::stopHelloTimer ");
- exServiceHello.shutdown();
- }
-
- /**
- * Starts the wait timer.
- */
- public void startWaitTimer() {
- log.debug("OSPFNbr::startWaitTimer");
- exServiceWait = Executors.newSingleThreadScheduledExecutor();
- waitTimerTask = new InternalWaitTimer();
- final ScheduledFuture<?> waitTimerHandle =
- exServiceWait.schedule(waitTimerTask, routerDeadIntervalTime(), TimeUnit.SECONDS);
- }
-
- /**
- * Stops the wait timer.
- */
- public void stopWaitTimer() {
- log.debug("OSPFNbr::stopWaitTimer ");
- exServiceWait.shutdown();
- }
-
- /**
- * Starts the timer which waits for configured seconds and sends Delayed Ack Packet.
- */
- @Override
- public void startDelayedAckTimer() {
- if (!isDelayedAckTimerScheduled) {
- log.debug("Started DelayedAckTimer...!!!");
- exServiceDelayedAck = Executors.newSingleThreadScheduledExecutor();
- delayedAckTimerTask = new InternalDelayedAckTimer();
- final ScheduledFuture<?> delayAckHandle =
- exServiceDelayedAck.scheduleAtFixedRate(delayedAckTimerTask, delayedAckTimerInterval,
- delayedAckTimerInterval, TimeUnit.MILLISECONDS);
- isDelayedAckTimerScheduled = true;
- }
- }
-
- /**
- * Stops the delayed acknowledge timer.
- */
- @Override
- public void stopDelayedAckTimer() {
- if (isDelayedAckTimerScheduled) {
- log.debug("Stopped DelayedAckTimer...!!!");
- isDelayedAckTimerScheduled = false;
- exServiceDelayedAck.shutdown();
- }
- }
-
- /**
- * Performs DR election.
- *
- * @param ch Netty Channel instance.
- */
- public void electRouter(Channel ch) {
-
- Ip4Address currentDr = dr();
- Ip4Address currentBdr = bdr();
- OspfInterfaceState oldState = state();
- OspfInterfaceState newState;
-
- log.debug("OSPFInterfaceChannelHandler::electRouter -> currentDr: {}, currentBdr: {}",
- currentDr, currentBdr);
- List<OspfEligibleRouter> eligibleRouters = calculateListOfEligibleRouters(new OspfEligibleRouter());
-
- log.debug("OSPFInterfaceChannelHandler::electRouter -> eligibleRouters: {}", eligibleRouters);
- OspfEligibleRouter electedBdr = electBdr(eligibleRouters);
- OspfEligibleRouter electedDr = electDr(eligibleRouters, electedBdr);
-
- setBdr(electedBdr.getIpAddress());
- setDr(electedDr.getIpAddress());
-
- if (electedBdr.getIpAddress().equals(ipAddress()) &&
- !electedBdr.getIpAddress().equals(currentBdr)) {
- setState(OspfInterfaceState.BDR);
- }
-
- if (electedDr.getIpAddress().equals(ipAddress()) &&
- !electedDr.getIpAddress().equals(currentDr)) {
- setState(OspfInterfaceState.DR);
- }
-
- if (state() != oldState &&
- !(state() == OspfInterfaceState.DROTHER &&
- oldState.value() < OspfInterfaceState.DROTHER.value())) {
- log.debug("Recalculating as the State is changed ");
- log.debug("OSPFInterfaceChannelHandler::electRouter -> currentDr: {}, currentBdr: {}",
- currentDr, currentBdr);
- eligibleRouters = calculateListOfEligibleRouters(new OspfEligibleRouter());
-
- log.debug("OSPFInterfaceChannelHandler::electRouter -> eligibleRouters: {}", eligibleRouters);
- electedBdr = electBdr(eligibleRouters);
- electedDr = electDr(eligibleRouters, electedBdr);
-
- setBdr(electedBdr.getIpAddress());
- setDr(electedDr.getIpAddress());
- }
-
- if (electedBdr.getIpAddress().equals(ipAddress()) &&
- !electedBdr.getIpAddress().equals(currentBdr)) {
- setState(OspfInterfaceState.BDR);
- ospfArea.refreshArea(this);
- }
-
- if (electedDr.getIpAddress().equals(ipAddress()) &&
- !electedDr.getIpAddress().equals(currentDr)) {
- setState(OspfInterfaceState.DR);
- //Refresh Router Lsa & Network Lsa
- ospfArea.refreshArea(this);
- }
-
- if (currentDr != electedDr.getIpAddress() || currentBdr != electedBdr.getIpAddress()) {
- Set<String> negibhorIdList;
- negibhorIdList = listOfNeighbors().keySet();
- for (String routerid : negibhorIdList) {
- OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(routerid);
- if (nbr.getState().getValue() >= OspfNeighborState.TWOWAY.getValue()) {
- nbr.adjOk(ch);
- }
- }
- }
-
- log.debug("OSPFInterfaceChannelHandler::electRouter -> ElectedDR: {}, ElectedBDR: {}",
- electedDr.getIpAddress(), electedBdr.getIpAddress());
- }
-
-
- /**
- * BDR Election process. Find the list of eligible router to participate in the process.
- *
- * @param electedDr router elected as DR.
- * @return list of eligible routers
- */
- public List<OspfEligibleRouter> calculateListOfEligibleRouters(OspfEligibleRouter electedDr) {
- log.debug("OSPFNbr::calculateListOfEligibleRouters ");
- Set<String> neighborIdList;
- List<OspfEligibleRouter> eligibleRouters = new ArrayList<>();
-
- neighborIdList = listOfNeighbors().keySet();
- for (String routerId : neighborIdList) {
- OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(routerId);
- if (nbr.getState().getValue() >= OspfNeighborState.TWOWAY.getValue() &&
- nbr.routerPriority() > 0) {
- OspfEligibleRouter router = new OspfEligibleRouter();
- router.setIpAddress(nbr.neighborIpAddr());
- router.setRouterId(nbr.neighborId());
- router.setRouterPriority(nbr.routerPriority());
- if (nbr.neighborDr().equals(nbr.neighborIpAddr()) ||
- electedDr.getIpAddress().equals(nbr.neighborIpAddr())) {
- router.setIsDr(true);
- } else if (nbr.neighborBdr().equals(nbr.neighborIpAddr())) {
- router.setIsBdr(true);
- }
- eligibleRouters.add(router);
- }
- }
- // interface does not have states like two and all
- if (routerPriority() > 0) {
- OspfEligibleRouter router = new OspfEligibleRouter();
- router.setIpAddress(ipAddress());
- router.setRouterId(ospfArea.routerId());
- router.setRouterPriority(routerPriority());
- if (dr().equals(ipAddress()) ||
- electedDr.getIpAddress().equals(ipAddress())) {
- router.setIsDr(true);
- } else if (bdr().equals(ipAddress()) &&
- !dr().equals(ipAddress())) {
- router.setIsBdr(true);
- }
-
- eligibleRouters.add(router);
- }
-
- return eligibleRouters;
- }
-
- /**
- * Based on router priority assigns BDR.
- *
- * @param eligibleRouters list of routers to participate in bdr election.
- * @return OSPF Eligible router instance.
- */
- public OspfEligibleRouter electBdr(List<OspfEligibleRouter> eligibleRouters) {
- log.debug("OSPFInterfaceChannelHandler::electBdr -> eligibleRouters: {}", eligibleRouters);
- List<OspfEligibleRouter> declaredAsBdr = new ArrayList<>();
- List<OspfEligibleRouter> notDrAndBdr = new ArrayList<>();
- for (OspfEligibleRouter router : eligibleRouters) {
- if (router.isBdr()) {
- declaredAsBdr.add(router);
- }
- if (!router.isBdr() && !router.isDr()) {
- notDrAndBdr.add(router);
- }
- }
-
- OspfEligibleRouter electedBdr = new OspfEligibleRouter();
- if (!declaredAsBdr.isEmpty()) {
- if (declaredAsBdr.size() == 1) {
- electedBdr = declaredAsBdr.get(0);
- } else if (declaredAsBdr.size() > 1) {
- electedBdr = selectRouterBasedOnPriority(declaredAsBdr);
- }
- } else {
- if (notDrAndBdr.size() == 1) {
- electedBdr = notDrAndBdr.get(0);
- } else if (notDrAndBdr.size() > 1) {
- electedBdr = selectRouterBasedOnPriority(notDrAndBdr);
- }
- }
-
- electedBdr.setIsBdr(true);
- electedBdr.setIsDr(false);
-
- return electedBdr;
- }
-
- /**
- * DR Election process.
- *
- * @param eligibleRouters list of eligible routers.
- * @param electedBdr Elected Bdr, OSPF eligible router instance.
- * @return OSPF eligible router instance.
- */
- public OspfEligibleRouter electDr(List<OspfEligibleRouter> eligibleRouters,
- OspfEligibleRouter electedBdr) {
-
- List<OspfEligibleRouter> declaredAsDr = new ArrayList<>();
- for (OspfEligibleRouter router : eligibleRouters) {
- if (router.isDr()) {
- declaredAsDr.add(router);
- }
- }
-
- OspfEligibleRouter electedDr = new OspfEligibleRouter();
- if (!declaredAsDr.isEmpty()) {
- if (declaredAsDr.size() == 1) {
- electedDr = declaredAsDr.get(0);
- } else if (eligibleRouters.size() > 1) {
- electedDr = selectRouterBasedOnPriority(declaredAsDr);
- }
- } else {
- electedDr = electedBdr;
- electedDr.setIsDr(true);
- electedDr.setIsBdr(false);
- }
-
- return electedDr;
- }
-
- /**
- * DR election process.
- *
- * @param routersList list of eligible routers.
- * @return OSPF eligible router instance.
- */
- public OspfEligibleRouter selectRouterBasedOnPriority(List<OspfEligibleRouter> routersList) {
-
- OspfEligibleRouter initialRouter = routersList.get(0);
-
- for (int i = 1; i < routersList.size(); i++) {
- OspfEligibleRouter router = routersList.get(i);
- if (router.getRouterPriority() > initialRouter.getRouterPriority()) {
- initialRouter = router;
- } else if (router.getRouterPriority() == initialRouter.getRouterPriority()) {
- try {
- if (OspfUtil.ipAddressToLong(router.getIpAddress().toString()) >
- OspfUtil.ipAddressToLong(initialRouter.getIpAddress().toString())) {
- initialRouter = router;
- }
- } catch (Exception e) {
- log.debug("OSPFInterfaceChannelHandler::selectRouterBasedOnPriority ->" +
- " eligibleRouters: {}", initialRouter);
- }
- }
- }
-
- return initialRouter;
- }
-
- /**
- * Adds device information.
- *
- * @param ospfRouter OSPF router instance
- */
- public void addDeviceInformation(OspfRouter ospfRouter) {
- controller.addDeviceDetails(ospfRouter);
- }
-
- /**
- * removes device information.
- *
- * @param ospfRouter OSPF neighbor instance
- */
- public void removeDeviceInformation(OspfRouter ospfRouter) {
- controller.removeDeviceDetails(ospfRouter);
- }
-
- /**
- * Adds link information.
- *
- * @param ospfRouter OSPF router instance
- * @param ospfLinkTed list link ted instances
- */
- public void addLinkInformation(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
- controller.addLinkDetails(ospfRouter, ospfLinkTed);
- }
-
- /**
- * Removes link information.
- *
- * @param ospfRouter OSPF router instance
- * @param ospfLinkTed OSPF link TED instance
- */
- public void removeLinkInformation(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
- controller.removeLinkDetails(ospfRouter, ospfLinkTed);
- }
-
- /**
- * Gets message as bytes.
- *
- * @param ospfMessage OSPF message
- * @return OSPF message
- */
- private byte[] getMessage(OspfMessage ospfMessage) {
- OspfMessageWriter messageWriter = new OspfMessageWriter();
- if (state().equals(OspfInterfaceState.POINT2POINT)) {
- ospfMessage.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
- }
- return (messageWriter.getMessage(ospfMessage, interfaceIndex, state.value()));
- }
-
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- OspfInterfaceImpl that = (OspfInterfaceImpl) o;
- return Objects.equal(helloIntervalTime, that.helloIntervalTime) &&
- Objects.equal(routerDeadIntervalTime, that.routerDeadIntervalTime) &&
- Objects.equal(routerPriority, that.routerPriority) &&
- Objects.equal(interfaceType, that.interfaceType) &&
- Objects.equal(mtu, that.mtu) &&
- Objects.equal(reTransmitInterval, that.reTransmitInterval) &&
- Objects.equal(ipAddress, that.ipAddress) &&
- Objects.equal(ipNetworkMask, that.ipNetworkMask) &&
- Objects.equal(listOfNeighbors, that.listOfNeighbors) &&
- Objects.equal(dr, that.dr) &&
- Objects.equal(bdr, that.bdr);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(ipAddress, ipNetworkMask, helloIntervalTime,
- routerDeadIntervalTime, routerPriority, listOfNeighbors,
- interfaceType, mtu, reTransmitInterval, dr, bdr);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("ipAddress", ipAddress)
- .add("routerPriority", routerPriority)
- .add("helloIntervalTime", helloIntervalTime)
- .add("routerDeadIntervalTime", routerDeadIntervalTime)
- .add("interfaceType", interfaceType)
- .add("mtu", mtu)
- .add("reTransmitInterval", reTransmitInterval)
- .add("dr", dr)
- .add("bdr", bdr)
- .toString();
- }
-
- /**
- * Represents a Hello task which sent a hello message every configured time interval.
- */
- private class InternalHelloTimer implements Runnable {
-
- /**
- * Creates an instance of Hello Timer.
- */
- InternalHelloTimer() {
- }
-
- @Override
- public void run() {
- if (channel != null && channel.isOpen() && channel.isConnected()) {
- if (interfaceType() == OspfInterfaceType.BROADCAST.value()) {
- if (interfaceTypeOldValue != interfaceType()) {
- try {
- callDrElection(channel);
- } catch (Exception e) {
- log.debug("Error while calling interfaceUp {}", e.getMessage());
- }
- }
- } else {
- if (interfaceTypeOldValue != interfaceType()) {
- interfaceTypeOldValue = interfaceType();
- }
- }
- HelloPacket hellopacket = new HelloPacket();
- //Headers
- hellopacket.setOspfVer(OspfUtil.OSPF_VERSION);
- hellopacket.setOspftype(OspfPacketType.HELLO.value());
- hellopacket.setOspfPacLength(0); //will be modified while encoding
- hellopacket.setRouterId(ospfArea.routerId());
- hellopacket.setAreaId(ospfArea.areaId());
- hellopacket.setChecksum(0); //will be modified while encoding
- hellopacket.setAuthType(OspfUtil.NOT_ASSIGNED);
- hellopacket.setAuthentication(OspfUtil.NOT_ASSIGNED);
- //Body
- hellopacket.setNetworkMask(ipNetworkMask());
- hellopacket.setOptions(ospfArea.options());
- hellopacket.setHelloInterval(helloIntervalTime());
- hellopacket.setRouterPriority(routerPriority());
- hellopacket.setRouterDeadInterval(routerDeadIntervalTime());
- hellopacket.setDr(dr());
- hellopacket.setBdr(bdr());
-
- Map<String, OspfNbr> listOfNeighbors = listOfNeighbors();
- Set<String> keys = listOfNeighbors.keySet();
- Iterator itr = keys.iterator();
- while (itr.hasNext()) {
- String nbrKey = (String) itr.next();
- OspfNbrImpl nbr = (OspfNbrImpl) listOfNeighbors.get(nbrKey);
- if (nbr.getState() != OspfNeighborState.DOWN) {
- hellopacket.addNeighbor(Ip4Address.valueOf(nbrKey));
- }
- }
- // build a hello Packet
- if (channel == null || !channel.isOpen() || !channel.isConnected()) {
- log.debug("Hello Packet not sent !!.. Channel Issue...");
- return;
- }
-
- hellopacket.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
- byte[] messageToWrite = getMessage(hellopacket);
- ChannelFuture future = channel.write(messageToWrite);
- if (future.isSuccess()) {
- log.debug("Hello Packet successfully sent !!");
- } else {
- future.awaitUninterruptibly();
- }
-
- }
- }
- }
-
- /**
- * Represents a Wait Timer task which waits the interface state to become WAITING.
- * It initiates DR election process.
- */
- private class InternalWaitTimer implements Runnable {
- Channel ch;
-
- /**
- * Creates an instance of Wait Timer.
- */
- InternalWaitTimer() {
- this.ch = channel;
- }
-
- @Override
- public void run() {
- log.debug("Wait timer expires...");
- if (ch != null && ch.isConnected()) {
- try {
- waitTimer(ch);
- } catch (Exception e) {
- log.debug("Exception at wait timer ...!!!");
- }
- }
- }
- }
-
- /**
- * Represents a task which sent a LS Acknowledge from the link state headers list.
- */
- private class InternalDelayedAckTimer implements Runnable {
- Channel ch;
-
- /**
- * Creates an instance of Delayed acknowledge timer.
- */
- InternalDelayedAckTimer() {
- this.ch = channel;
- }
-
- @Override
- public void run() {
- if (!linkStateHeaders().isEmpty()) {
- isDelayedAckTimerScheduled = true;
- if (ch != null && ch.isConnected()) {
-
- List<LsaHeader> listOfLsaHeadersAcknowledged = new ArrayList<>();
- List<LsaHeader> listOfLsaHeaders = linkStateHeaders();
- log.debug("Delayed Ack, Number of Lsa's to Ack {}", listOfLsaHeaders.size());
- Iterator itr = listOfLsaHeaders.iterator();
- while (itr.hasNext()) {
- LsAcknowledge ackContent = new LsAcknowledge();
- //Setting OSPF Header
- ackContent.setOspfVer(OspfUtil.OSPF_VERSION);
- ackContent.setOspftype(OspfPacketType.LSAACK.value());
- ackContent.setRouterId(ospfArea.routerId());
- ackContent.setAreaId(ospfArea.areaId());
- ackContent.setAuthType(OspfUtil.NOT_ASSIGNED);
- ackContent.setAuthentication(OspfUtil.NOT_ASSIGNED);
- ackContent.setOspfPacLength(OspfUtil.NOT_ASSIGNED);
- ackContent.setChecksum(OspfUtil.NOT_ASSIGNED);
- //limit to mtu
- int currentLength = OspfUtil.OSPF_HEADER_LENGTH;
- int maxSize = mtu() -
- OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
- while (itr.hasNext()) {
- if ((currentLength + OspfUtil.LSA_HEADER_LENGTH) >= maxSize) {
- break;
- }
- LsaHeader lsaHeader = (LsaHeader) itr.next();
- ackContent.addLinkStateHeader(lsaHeader);
- currentLength = currentLength + OspfUtil.LSA_HEADER_LENGTH;
- listOfLsaHeadersAcknowledged.add(lsaHeader);
- log.debug("Delayed Ack, Added Lsa's to Ack {}", lsaHeader);
- }
-
- log.debug("Delayed Ack, Number of Lsa's in LsAck packet {}",
- ackContent.getLinkStateHeaders().size());
-
- //set the destination
- if (state() == OspfInterfaceState.DR || state() == OspfInterfaceState.BDR
- || state() == OspfInterfaceState.POINT2POINT) {
- ackContent.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
- } else if (state() == OspfInterfaceState.DROTHER) {
- ackContent.setDestinationIp(OspfUtil.ALL_DROUTERS);
- }
- byte[] messageToWrite = getMessage(ackContent);
- ch.write(messageToWrite);
-
- for (LsaHeader lsa : listOfLsaHeadersAcknowledged) {
- linkStateHeaders().remove(lsa);
- removeLsaFromNeighborMap(((OspfAreaImpl) ospfArea).getLsaKey(lsa));
- }
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfProcessImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfProcessImpl.java
deleted file mode 100644
index 26666ad..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfProcessImpl.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.area;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.MoreObjects;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfProcess;
-
-import java.util.List;
-
-/**
- * Representation of the configuration data for OSPF Process, which will be configured using rest URI.
- */
-public class OspfProcessImpl implements OspfProcess {
-
- private String processId;
- private List<OspfArea> areas;
-
- /**
- * Gets the list of areas belonging to this process.
- *
- * @return list of areas belonging to this process
- */
- public List<OspfArea> areas() {
- return areas;
- }
-
- /**
- * Sets the list of areas belonging to this process.
- *
- * @param areas list of areas belonging to this process
- */
- @JsonProperty("areas")
- public void setAreas(List<OspfArea> areas) {
- this.areas = areas;
- }
-
- /**
- * Gets the process id.
- *
- * @return process id
- */
- public String processId() {
- return processId;
- }
-
- /**
- * Sets the process id.
- *
- * @param processId the process id
- */
- @JsonProperty("processId")
- public void setProcessId(String processId) {
- this.processId = processId;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("areas", areas)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/package-info.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/package-info.java
deleted file mode 100644
index c8e3c92..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the OSPF controller.
- */
-package org.onosproject.ospf.controller.area;
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/Controller.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/Controller.java
deleted file mode 100644
index 8e8e5f3..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/Controller.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.jboss.netty.bootstrap.ClientBootstrap;
-import org.jboss.netty.channel.AdaptiveReceiveBufferSizePredictor;
-import org.jboss.netty.channel.ChannelFuture;
-import org.jboss.netty.channel.ChannelFutureListener;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory;
-import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.TpPort;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.ospf.controller.OspfAgent;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfLinkTed;
-import org.onosproject.ospf.controller.OspfProcess;
-import org.onosproject.ospf.controller.OspfRouter;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.NetworkInterface;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import static org.onlab.util.Tools.groupedThreads;
-
-/**
- * Representation of an OSPF controller.
- */
-public class Controller {
- protected static final int BUFFER_SIZE = 4 * 1024 * 1024;
- private static final Logger log = LoggerFactory.getLogger(Controller.class);
- private static final int RETRY_INTERVAL = 4;
- private final int peerWorkerThreads = 16;
- protected long systemStartTime;
- byte[] configPacket = null;
- private List<OspfProcess> processes = null;
- private OspfInterfaceChannelHandler ospfChannelHandler;
- private NioClientSocketChannelFactory peerExecFactory;
- private ClientBootstrap peerBootstrap = null;
- private TpPort ospfPort = TpPort.tpPort(OspfUtil.SPORT);
- private ScheduledExecutorService connectExecutor = null;
- private int connectRetryCounter = 0;
- private int connectRetryTime;
- private DriverService driverService;
- private OspfAgent agent;
-
- /**
- * Deactivates OSPF controller.
- */
- public void ospfDeactivate() {
- peerExecFactory.shutdown();
- }
-
- /**
- * Updates the processes configuration.
- *
- * @param ospfProcesses list of OSPF process instances
- */
- public void updateConfig(List<OspfProcess> ospfProcesses) {
- log.debug("Controller::UpdateConfig called");
- configPacket = new byte[OspfUtil.CONFIG_LENGTH];
- byte numberOfInterface = 0; // number of interfaces to configure
- configPacket[0] = (byte) 0xFF; // its a conf packet - identifier
- for (OspfProcess ospfProcess : ospfProcesses) {
- log.debug("OspfProcessDetails : " + ospfProcess);
- for (OspfArea ospfArea : ospfProcess.areas()) {
- for (OspfInterface ospfInterface : ospfArea.ospfInterfaceList()) {
- log.debug("OspfInterfaceDetails : " + ospfInterface);
- numberOfInterface++;
- configPacket[2 * numberOfInterface] = (byte) ospfInterface.interfaceIndex();
- configPacket[(2 * numberOfInterface) + 1] = (byte) 4;
- }
- }
- }
- configPacket[1] = numberOfInterface;
- //First time configuration
- if (processes == null) {
- if (ospfProcesses.size() > 0) {
- processes = ospfProcesses;
- connectPeer();
- }
- } else {
- ospfChannelHandler.updateInterfaceMap(ospfProcesses);
- //Send the config packet
- ospfChannelHandler.sentConfigPacket(configPacket);
- }
- }
-
- /**
- * Initializes the netty client channel connection.
- */
- private void initConnection() {
- if (peerBootstrap != null) {
- return;
- }
- peerBootstrap = createPeerBootStrap();
-
- peerBootstrap.setOption("reuseAddress", true);
- peerBootstrap.setOption("tcpNoDelay", true);
- peerBootstrap.setOption("keepAlive", true);
- peerBootstrap.setOption("receiveBufferSize", Controller.BUFFER_SIZE);
- peerBootstrap.setOption("receiveBufferSizePredictorFactory",
- new FixedReceiveBufferSizePredictorFactory(
- Controller.BUFFER_SIZE));
- peerBootstrap.setOption("receiveBufferSizePredictor",
- new AdaptiveReceiveBufferSizePredictor(64, 4096, 65536));
- peerBootstrap.setOption("child.keepAlive", true);
- peerBootstrap.setOption("child.tcpNoDelay", true);
- peerBootstrap.setOption("child.sendBufferSize", Controller.BUFFER_SIZE);
- peerBootstrap.setOption("child.receiveBufferSize", Controller.BUFFER_SIZE);
- peerBootstrap.setOption("child.receiveBufferSizePredictorFactory",
- new FixedReceiveBufferSizePredictorFactory(
- Controller.BUFFER_SIZE));
- peerBootstrap.setOption("child.reuseAddress", true);
-
- ospfChannelHandler = new OspfInterfaceChannelHandler(this, processes);
- ChannelPipelineFactory pfact = new OspfPipelineFactory(ospfChannelHandler);
- peerBootstrap.setPipelineFactory(pfact);
- }
-
- /**
- * Creates peer boot strap.
- *
- * @return client bootstrap instance
- */
- private ClientBootstrap createPeerBootStrap() {
-
- if (peerWorkerThreads == 0) {
- peerExecFactory = new NioClientSocketChannelFactory(
- Executors.newCachedThreadPool(groupedThreads("onos/ospf", "boss-%d")),
- Executors.newCachedThreadPool(groupedThreads("onos/ospf", "worker-%d")));
- return new ClientBootstrap(peerExecFactory);
- } else {
- peerExecFactory = new NioClientSocketChannelFactory(
- Executors.newCachedThreadPool(groupedThreads("onos/ospf", "boss-%d")),
- Executors.newCachedThreadPool(groupedThreads("onos/ospf", "worker-%d")),
- peerWorkerThreads);
- return new ClientBootstrap(peerExecFactory);
- }
- }
-
- /**
- * Gets all configured processes.
- *
- * @return all configured processes
- */
- public List<OspfProcess> getAllConfiguredProcesses() {
- return processes;
- }
-
- /**
- * Adds device details.
- *
- * @param ospfRouter OSPF router instance
- */
- public void addDeviceDetails(OspfRouter ospfRouter) {
- agent.addConnectedRouter(ospfRouter);
- }
-
- /**
- * Removes device details.
- *
- * @param ospfRouter OSPF router instance
- */
- public void removeDeviceDetails(OspfRouter ospfRouter) {
- agent.removeConnectedRouter(ospfRouter);
- }
-
- /**
- * Adds link details.
- *
- * @param ospfRouter OSPF router instance
- * @param ospfLinkTed OSPF link ted instance
- */
- public void addLinkDetails(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
- agent.addLink(ospfRouter, ospfLinkTed);
- }
-
- /**
- * Removes link details.
- *
- * @param ospfRouter OSPF router instance
- * @param ospfLinkTed OSPF link ted instance
- */
- public void removeLinkDetails(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
- agent.deleteLink(ospfRouter, ospfLinkTed);
- }
-
- /**
- * Initializes internal data structures.
- */
- public void init() {
- this.systemStartTime = System.currentTimeMillis();
- }
-
- /**
- * Starts the controller.
- *
- * @param ag OSPF agent instance
- * @param driverService driver service instance
- */
- public void start(OspfAgent ag, DriverService driverService) {
- log.info("Starting OSPF controller...!!!");
- this.agent = ag;
- this.driverService = driverService;
- this.init();
- }
-
- /**
- * Stops the Controller.
- */
- public void stop() {
- log.info("Stopping OSPF controller...!!!");
- ospfDeactivate();
- processes.clear();
- }
-
- /**
- * Returns interface IP by index.
- *
- * @param interfaceIndex interface index
- * @return interface IP by index
- */
- private Ip4Address getInterfaceIp(int interfaceIndex) {
- Ip4Address ipAddress = null;
- try {
- NetworkInterface networkInterface = NetworkInterface.getByIndex(interfaceIndex);
- Enumeration ipAddresses = networkInterface.getInetAddresses();
- while (ipAddresses.hasMoreElements()) {
- InetAddress address = (InetAddress) ipAddresses.nextElement();
- if (!address.isLinkLocalAddress()) {
- ipAddress = Ip4Address.valueOf(address.getAddress());
- break;
- }
- }
- } catch (Exception e) {
- log.debug("Error while getting Interface IP by index");
- return OspfUtil.DEFAULTIP;
- }
-
- return ipAddress;
- }
-
- /**
- * Returns interface mask by index.
- *
- * @param interfaceIndex interface index
- * @return interface IP by index
- */
- private String getInterfaceMask(int interfaceIndex) {
- String subnetMask = null;
- try {
- Ip4Address ipAddress = getInterfaceIp(interfaceIndex);
- NetworkInterface networkInterface = NetworkInterface.getByInetAddress(
- InetAddress.getByName(ipAddress.toString()));
- Enumeration ipAddresses = networkInterface.getInetAddresses();
- int index = 0;
- while (ipAddresses.hasMoreElements()) {
- InetAddress address = (InetAddress) ipAddresses.nextElement();
- if (!address.isLinkLocalAddress()) {
- break;
- }
- index++;
- }
- int prfLen = networkInterface.getInterfaceAddresses().get(index).getNetworkPrefixLength();
- int shft = 0xffffffff << (32 - prfLen);
- int oct1 = ((byte) ((shft & 0xff000000) >> 24)) & 0xff;
- int oct2 = ((byte) ((shft & 0x00ff0000) >> 16)) & 0xff;
- int oct3 = ((byte) ((shft & 0x0000ff00) >> 8)) & 0xff;
- int oct4 = ((byte) (shft & 0x000000ff)) & 0xff;
- subnetMask = oct1 + "." + oct2 + "." + oct3 + "." + oct4;
- } catch (Exception e) {
- log.debug("Error while getting Interface network mask by index");
- return subnetMask;
- }
-
- return subnetMask;
- }
-
- /**
- * Disconnects the executor.
- */
- public void disconnectExecutor() {
- if (connectExecutor != null) {
- connectExecutor.shutdown();
- connectExecutor = null;
- }
- }
-
- /**
- * Connects to peer.
- */
- public void connectPeer() {
- scheduleConnectionRetry(this.connectRetryTime);
- }
-
- /**
- * Retry connection with exponential back-off mechanism.
- *
- * @param retryDelay retry delay
- */
- private void scheduleConnectionRetry(long retryDelay) {
- if (this.connectExecutor == null) {
- this.connectExecutor = Executors.newSingleThreadScheduledExecutor();
- }
- this.connectExecutor.schedule(new ConnectionRetry(), retryDelay, TimeUnit.MINUTES);
- }
-
- /**
- * Implements OSPF connection and manages connection to peer with back-off mechanism in case of failure.
- */
- class ConnectionRetry implements Runnable {
- @Override
- public void run() {
- log.debug("Connect to peer {}", OspfUtil.SHOST);
- initConnection();
- ospfChannelHandler.sentConfigPacket(configPacket);
- InetSocketAddress connectToSocket = new InetSocketAddress(OspfUtil.SHOST, ospfPort.toInt());
- try {
- peerBootstrap.connect(connectToSocket).addListener(new ChannelFutureListener() {
- @Override
- public void operationComplete(ChannelFuture future) {
- if (!future.isSuccess()) {
- connectRetryCounter++;
- log.error("Connection failed, ConnectRetryCounter {} remote host {}", connectRetryCounter,
- OspfUtil.SHOST);
- /*
- * Reconnect to peer on failure is exponential till 4 mins, later on retry after every 4
- * mins.
- */
- if (connectRetryTime < RETRY_INTERVAL) {
- connectRetryTime = (connectRetryTime != 0) ? connectRetryTime * 2 : 1;
- }
- scheduleConnectionRetry(connectRetryTime);
- } else {
- //Send the config packet
- ospfChannelHandler.sentConfigPacket(configPacket);
- connectRetryCounter++;
- log.info("Connected to remote host {}, Connect Counter {}", OspfUtil.SHOST,
- connectRetryCounter);
- disconnectExecutor();
-
- return;
- }
- }
- });
- } catch (Exception e) {
- log.info("Connect peer exception : " + e.toString());
- disconnectExecutor();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/DeviceInformationImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/DeviceInformationImpl.java
deleted file mode 100644
index b827c28..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/DeviceInformationImpl.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.DeviceInformation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of an OSPF device information.
- */
-public class DeviceInformationImpl implements DeviceInformation {
-
- Ip4Address deviceId;
- Ip4Address routerId;
- List<Ip4Address> interfaceId = new ArrayList<>();
- Ip4Address areaId;
- boolean alreadyCreated;
- boolean isDr;
-
- Ip4Address neighborId;
-
- /**
- * Gets router id.
- *
- * @return router id
- */
- public Ip4Address routerId() {
- return routerId;
- }
-
- /**
- * Sets router id.
- *
- * @param routerId router id
- */
- public void setRouterId(Ip4Address routerId) {
- this.routerId = routerId;
- }
-
- /**
- * Gets device id.
- *
- * @return device id
- */
- public Ip4Address deviceId() {
- return deviceId;
- }
-
- /**
- * Sets device id.
- *
- * @param deviceId device id
- */
- public void setDeviceId(Ip4Address deviceId) {
- this.deviceId = deviceId;
- }
-
- /**
- * Gets interface id list.
- *
- * @return interface id list
- */
- public List<Ip4Address> interfaceId() {
- return this.interfaceId;
- }
-
- /**
- * Adds interface id to list.
- *
- * @param interfaceId interface id
- */
- public void addInterfaceId(Ip4Address interfaceId) {
- this.interfaceId.add(interfaceId);
- }
-
- /**
- * Gets area id.
- *
- * @return area id
- */
- public Ip4Address areaId() {
- return areaId;
- }
-
- /**
- * Sets area id.
- *
- * @param areaId area id
- */
- public void setAreaId(Ip4Address areaId) {
- this.areaId = areaId;
- }
-
- /**
- * Gets is already created or not.
- *
- * @return true if already created else false
- */
- public boolean isAlreadyCreated() {
- return alreadyCreated;
- }
-
- /**
- * Sets is already created or not.
- *
- * @param alreadyCreated true or false
- */
- public void setAlreadyCreated(boolean alreadyCreated) {
- this.alreadyCreated = alreadyCreated;
- }
-
- /**
- * Gets is DR or not.
- *
- * @return true if DR else false
- */
- public boolean isDr() {
- return isDr;
- }
-
- /**
- * Stes DR or not.
- *
- * @param dr true or false
- */
- public void setDr(boolean dr) {
- this.isDr = dr;
- }
-
- /**
- * Gets neighbor id.
- *
- * @return neighbor id
- */
- public Ip4Address neighborId() {
- return neighborId;
- }
-
- /**
- * Sets neighbor id.
- *
- * @param neighborId neighbor id
- */
- public void setNeighborId(Ip4Address neighborId) {
- this.neighborId = neighborId;
- }
-}
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/LinkInformationImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/LinkInformationImpl.java
deleted file mode 100644
index aa29d61..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/LinkInformationImpl.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.LinkInformation;
-
-/**
- * Representation of an OSPF link information..
- */
-public class LinkInformationImpl implements LinkInformation {
-
- String linkId;
- Ip4Address linkSourceId;
- Ip4Address linkDestinationId;
- Ip4Address interfaceIp;
- boolean linkSrcIdNotRouterId;
- boolean alreadyCreated;
- Ip4Address linkSourceIpAddress;
- Ip4Address linkDestinationIpAddress;
-
- /**
- * Gets link id.
- *
- * @return link id
- */
- public String linkId() {
- return linkId;
- }
-
- /**
- * Sets link id.
- *
- * @param linkId link id
- */
- public void setLinkId(String linkId) {
- this.linkId = linkId;
- }
-
- /**
- * Gets is already created or not.
- *
- * @return true if already created else false
- */
- public boolean isAlreadyCreated() {
- return alreadyCreated;
- }
-
- /**
- * Sets is already created or not.
- *
- * @param alreadyCreated true or false
- */
- public void setAlreadyCreated(boolean alreadyCreated) {
- this.alreadyCreated = alreadyCreated;
- }
-
- /**
- * Gets is link source id is not router id.
- *
- * @return true if link source id is router id else false
- */
- public boolean isLinkSrcIdNotRouterId() {
- return linkSrcIdNotRouterId;
- }
-
- /**
- * Sets is link source id is not router id.
- *
- * @param linkSrcIdNotRouterId true or false
- */
- public void setLinkSrcIdNotRouterId(boolean linkSrcIdNotRouterId) {
- this.linkSrcIdNotRouterId = linkSrcIdNotRouterId;
- }
-
- /**
- * Gets link destination id.
- *
- * @return link destination id
- */
- public Ip4Address linkDestinationId() {
- return linkDestinationId;
- }
-
- /**
- * Sets link destination id.
- *
- * @param linkDestinationId link destination id
- */
- public void setLinkDestinationId(Ip4Address linkDestinationId) {
- this.linkDestinationId = linkDestinationId;
- }
-
- /**
- * Gets link source id.
- *
- * @return link source id
- */
- public Ip4Address linkSourceId() {
- return linkSourceId;
- }
-
- /**
- * Sets link source id.
- *
- * @param linkSourceId link source id
- */
- public void setLinkSourceId(Ip4Address linkSourceId) {
- this.linkSourceId = linkSourceId;
- }
-
- /**
- * Gets interface IP address.
- *
- * @return interface IP address
- */
- public Ip4Address interfaceIp() {
- return interfaceIp;
- }
-
- /**
- * Sets interface IP address.
- *
- * @param interfaceIp interface IP address
- */
- public void setInterfaceIp(Ip4Address interfaceIp) {
- this.interfaceIp = interfaceIp;
- }
-
- /**
- * Gets link source IP address.
- *
- * @return link source IP address
- */
- public Ip4Address linkSourceIpAddress() {
- return linkSourceIpAddress;
- }
-
- /**
- * Sets link source IP address.
- *
- * @param linkSourceIpAddress link source IP address
- */
- public void setLinkSourceIpAddress(Ip4Address linkSourceIpAddress) {
- this.linkSourceIpAddress = linkSourceIpAddress;
- }
-
- /**
- * Gets link destination IP address.
- *
- * @return link destination IP address
- */
- public Ip4Address linkDestinationIpAddress() {
- return linkDestinationIpAddress;
- }
-
- /**
- * Sets link destination IP address.
- *
- * @param linkDestinationIpAddress link destination IP address
- */
- public void setLinkDestinationIpAddress(Ip4Address linkDestinationIpAddress) {
- this.linkDestinationIpAddress = linkDestinationIpAddress;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfConfigUtil.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfConfigUtil.java
deleted file mode 100644
index 2173496..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfConfigUtil.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfProcess;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.controller.area.OspfProcessImpl;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * Representation of OSPF network configuration parsing util.
- */
-public final class OspfConfigUtil {
- public static final String PROCESSID = "processId";
- public static final String AREAS = "areas";
- public static final String INTERFACEINDEX = "interfaceIndex";
- public static final String AREAID = "areaId";
- public static final String ROUTERID = "routerId";
- public static final String INTERFACE = "interface";
- public static final String HELLOINTERVAL = "helloIntervalTime";
- public static final String ROUTERDEADINTERVAL = "routerDeadIntervalTime";
- public static final String INTERFACETYPE = "interfaceType";
- public static final String EXTERNALROUTINGCAPABILITY = "externalRoutingCapability";
- private static final Logger log = LoggerFactory.getLogger(OspfConfigUtil.class);
- private static final String ISOPAQUE = "isOpaqueEnable";
-
- /**
- * Creates an instance of this.
- */
- private OspfConfigUtil() {
-
- }
-
- /**
- * Returns list of OSPF process from the json nodes.
- *
- * @param jsonNodes represents one or more OSPF process configuration
- * @return list of OSPF processes.
- */
- public static List<OspfProcess> processes(JsonNode jsonNodes) {
- List<OspfProcess> ospfProcesses = new ArrayList<>();
- if (jsonNodes == null) {
- return ospfProcesses;
- }
- //From each Process nodes, get area and related interface details.
- jsonNodes.forEach(jsonNode -> {
- List<OspfArea> areas = new ArrayList<>();
- //Get configured areas for the process.
- for (JsonNode areaNode : jsonNode.path(AREAS)) {
- List<OspfInterface> interfaceList = new ArrayList<>();
- for (JsonNode interfaceNode : areaNode.path(INTERFACE)) {
- OspfInterface ospfInterface = interfaceDetails(interfaceNode);
- if (ospfInterface != null) {
- interfaceList.add(ospfInterface);
- }
- }
- //Get the area details
- OspfArea area = areaDetails(areaNode);
- if (area != null) {
- area.setOspfInterfaceList(interfaceList);
- areas.add(area);
- }
- }
- OspfProcess process = new OspfProcessImpl();
- process.setProcessId(jsonNode.path(PROCESSID).asText());
- process.setAreas(areas);
- ospfProcesses.add(process);
- });
-
- return ospfProcesses;
- }
-
- /**
- * Returns interface IP by index.
- *
- * @param interfaceIndex interface index
- * @return interface IP by index
- */
- private static Ip4Address getInterfaceIp(int interfaceIndex) {
- Ip4Address ipAddress = null;
- try {
- NetworkInterface networkInterface = NetworkInterface.getByIndex(interfaceIndex);
- Enumeration ipAddresses = networkInterface.getInetAddresses();
- while (ipAddresses.hasMoreElements()) {
- InetAddress address = (InetAddress) ipAddresses.nextElement();
- if (!address.isLinkLocalAddress()) {
- ipAddress = Ip4Address.valueOf(address.getAddress());
- break;
- }
- }
- } catch (Exception e) {
- log.debug("Error while getting Interface IP by index");
- return OspfUtil.DEFAULTIP;
- }
- return ipAddress;
- }
-
- /**
- * Returns interface MAC by index.
- *
- * @param interfaceIndex interface index
- * @return interface IP by index
- */
- private static String getInterfaceMask(int interfaceIndex) {
- String subnetMask = null;
- try {
- Ip4Address ipAddress = getInterfaceIp(interfaceIndex);
- NetworkInterface networkInterface = NetworkInterface.getByInetAddress(
- InetAddress.getByName(ipAddress.toString()));
- Enumeration ipAddresses = networkInterface.getInetAddresses();
- int index = 0;
- while (ipAddresses.hasMoreElements()) {
- InetAddress address = (InetAddress) ipAddresses.nextElement();
- if (!address.isLinkLocalAddress()) {
- break;
- }
- index++;
- }
- int prfLen = networkInterface.getInterfaceAddresses().get(index).getNetworkPrefixLength();
- int shft = 0xffffffff << (32 - prfLen);
- int oct1 = ((byte) ((shft & 0xff000000) >> 24)) & 0xff;
- int oct2 = ((byte) ((shft & 0x00ff0000) >> 16)) & 0xff;
- int oct3 = ((byte) ((shft & 0x0000ff00) >> 8)) & 0xff;
- int oct4 = ((byte) (shft & 0x000000ff)) & 0xff;
- subnetMask = oct1 + "." + oct2 + "." + oct3 + "." + oct4;
- } catch (Exception e) {
- log.debug("Error while getting Interface network mask by index");
- return subnetMask;
- }
- return subnetMask;
- }
-
- /**
- * Checks if valid digit or not.
- *
- * @param strInput input value
- * @return true if valid else false
- */
- private static boolean isValidDigit(String strInput) {
- boolean isValid = true;
- if (isPrimitive(strInput)) {
- int input = Integer.parseInt(strInput);
- if (input < 1 || input > 255) {
- log.debug("Wrong config input value: {}", strInput);
- isValid = false;
- } else {
- isValid = true;
- }
-
- } else {
- isValid = false;
- }
-
- return isValid;
- }
-
- /**
- * Checks if primitive or not.
- *
- * @param value input value
- * @return true if number else false
- */
- private static boolean isPrimitive(String value) {
- boolean status = true;
- value = value.trim();
- if (value.length() < 1) {
- return false;
- }
- for (int i = 0; i < value.length(); i++) {
- char c = value.charAt(i);
- if (!Character.isDigit(c)) {
- status = false;
- break;
- }
- }
-
- return status;
- }
-
- /**
- * Checks if boolean or not.
- *
- * @param value input value
- * @return true if boolean else false
- */
- private static boolean isBoolean(String value) {
- boolean status = false;
- value = value.trim();
- if (value.equals("true") || value.equals("false")) {
- return true;
- }
-
- return status;
- }
-
- /**
- * Checks if given id is valid or not.
- *
- * @param value input value
- * @return true if valid else false
- */
- private static boolean isValidIpAddress(String value) {
- boolean status = true;
- try {
- Ip4Address ipAddress = Ip4Address.valueOf(value);
- } catch (Exception e) {
- log.debug("Invalid IP address string: {}", value);
- return false;
- }
-
- return status;
- }
-
- /**
- * Returns OSPF area instance from configuration.
- *
- * @param areaNode area configuration
- * @return OSPF area instance
- */
- private static OspfArea areaDetails(JsonNode areaNode) {
- OspfArea area = new OspfAreaImpl();
- String areaId = areaNode.path(AREAID).asText();
- if (isValidIpAddress(areaId)) {
- area.setAreaId(Ip4Address.valueOf(areaId));
- } else {
- log.debug("Wrong areaId: {}", areaId);
- return null;
- }
- String routerId = areaNode.path(ROUTERID).asText();
- if (isValidIpAddress(routerId)) {
- area.setRouterId(Ip4Address.valueOf(routerId));
- } else {
- log.debug("Wrong routerId: {}", routerId);
- return null;
- }
- String routingCapability = areaNode.path(EXTERNALROUTINGCAPABILITY).asText();
- if (isBoolean(routingCapability)) {
- area.setExternalRoutingCapability(Boolean.valueOf(routingCapability));
- } else {
- log.debug("Wrong routingCapability: {}", routingCapability);
- return null;
- }
- String isOpaqueEnabled = areaNode.path(ISOPAQUE).asText();
- if (isBoolean(isOpaqueEnabled)) {
- area.setIsOpaqueEnabled(Boolean.valueOf(isOpaqueEnabled));
- } else {
- log.debug("Wrong isOpaqueEnabled: {}", isOpaqueEnabled);
- return null;
- }
- area.setOptions(OspfUtil.HELLO_PACKET_OPTIONS);
-
- return area;
- }
-
- /**
- * Returns OSPF interface instance from configuration.
- *
- * @param interfaceNode interface configuration
- * @return OSPF interface instance
- */
- private static OspfInterface interfaceDetails(JsonNode interfaceNode) {
- OspfInterface ospfInterface = new OspfInterfaceImpl();
- String index = interfaceNode.path(INTERFACEINDEX).asText();
- if (isValidDigit(index)) {
- ospfInterface.setInterfaceIndex(Integer.parseInt(index));
- } else {
- log.debug("Wrong interface index: {}", index);
- return null;
- }
- Ip4Address interfaceIp = getInterfaceIp(ospfInterface.interfaceIndex());
- if (interfaceIp.equals(OspfUtil.DEFAULTIP)) {
- return null;
- }
- ospfInterface.setIpAddress(interfaceIp);
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf(getInterfaceMask(
- ospfInterface.interfaceIndex())));
- ospfInterface.setBdr(OspfUtil.DEFAULTIP);
- ospfInterface.setDr(OspfUtil.DEFAULTIP);
- String helloInterval = interfaceNode.path(HELLOINTERVAL).asText();
- if (isValidDigit(helloInterval)) {
- ospfInterface.setHelloIntervalTime(Integer.parseInt(helloInterval));
- } else {
- log.debug("Wrong hello interval: {}", helloInterval);
- return null;
- }
- String routerDeadInterval = interfaceNode.path(ROUTERDEADINTERVAL).asText();
- if (isValidDigit(routerDeadInterval)) {
- ospfInterface.setRouterDeadIntervalTime(Integer.parseInt(routerDeadInterval));
- } else {
- log.debug("Wrong routerDeadInterval: {}", routerDeadInterval);
- return null;
- }
- String interfaceType = interfaceNode.path(INTERFACETYPE).asText();
- if (isValidDigit(interfaceType)) {
- ospfInterface.setInterfaceType(Integer.parseInt(interfaceType));
- } else {
- log.debug("Wrong interfaceType: {}", interfaceType);
- return null;
- }
- ospfInterface.setReTransmitInterval(OspfUtil.RETRANSMITINTERVAL);
- ospfInterface.setMtu(OspfUtil.MTU);
- ospfInterface.setRouterPriority(OspfUtil.ROUTER_PRIORITY);
-
- return ospfInterface;
- }
-}
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfControllerImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfControllerImpl.java
deleted file mode 100644
index dc63617..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfControllerImpl.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ospf.controller.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.google.common.collect.Sets;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.ospf.controller.OspfAgent;
-import org.onosproject.ospf.controller.OspfController;
-import org.onosproject.ospf.controller.OspfLinkListener;
-import org.onosproject.ospf.controller.OspfLinkTed;
-import org.onosproject.ospf.controller.OspfProcess;
-import org.onosproject.ospf.controller.OspfRouter;
-import org.onosproject.ospf.controller.OspfRouterListener;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Representation of an OSPF controller implementation.
- * Serves as a one stop shop for obtaining OSPF devices and (un)register listeners on OSPF events
- */
-@Component(immediate = true, service = OspfController.class)
-public class OspfControllerImpl implements OspfController {
-
- private static final Logger log = LoggerFactory.getLogger(OspfControllerImpl.class);
- private final Controller ctrl = new Controller();
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DriverService driverService;
- protected Set<OspfRouterListener> ospfRouterListener = new HashSet<>();
- protected Set<OspfLinkListener> ospfLinkListener = Sets.newHashSet();
- protected OspfAgent agent = new InternalDeviceConfig();
-
- @Activate
- public void activate() {
- log.info("OSPFControllerImpl activate...!!!");
- ctrl.start(agent, driverService);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- ctrl.stop();
- log.info("Stopped");
- }
-
-
- @Override
- public void addRouterListener(OspfRouterListener listener) {
- if (!ospfRouterListener.contains(listener)) {
- this.ospfRouterListener.add(listener);
- }
- }
-
- @Override
- public void removeRouterListener(OspfRouterListener listener) {
- this.ospfRouterListener.remove(listener);
- }
-
- @Override
- public void addLinkListener(OspfLinkListener listener) {
- ospfLinkListener.add(listener);
-
- }
-
- @Override
- public void removeLinkListener(OspfLinkListener listener) {
- ospfLinkListener.remove(listener);
-
- }
-
- @Override
- public Set<OspfRouterListener> listener() {
- return ospfRouterListener;
- }
-
- @Override
- public Set<OspfLinkListener> linkListener() {
- return ospfLinkListener;
- }
-
-
- @Override
- public List<OspfProcess> getAllConfiguredProcesses() {
- List<OspfProcess> processes = ctrl.getAllConfiguredProcesses();
- return processes;
- }
-
- @Override
- public void updateConfig(JsonNode processesNode) {
- try {
- List<OspfProcess> ospfProcesses = OspfConfigUtil.processes(processesNode);
- //if there is interface details then update configuration
- if (!ospfProcesses.isEmpty() &&
- ospfProcesses.get(0).areas() != null && !ospfProcesses.get(0).areas().isEmpty() &&
- ospfProcesses.get(0).areas().get(0) != null &&
- !ospfProcesses.get(0).areas().get(0).ospfInterfaceList().isEmpty()) {
- ctrl.updateConfig(ospfProcesses);
- }
- } catch (Exception e) {
- log.debug("Error::updateConfig::{}", e.getMessage());
- }
- }
-
- @Override
- public void deleteConfig(List<OspfProcess> processes, String attribute) {
- }
-
- /**
- * Notifier for internal OSPF device and link changes.
- */
- private class InternalDeviceConfig implements OspfAgent {
-
- @Override
- public boolean addConnectedRouter(OspfRouter ospfRouter) {
- for (OspfRouterListener l : listener()) {
- l.routerAdded(ospfRouter);
- }
- return true;
- }
-
- @Override
- public void removeConnectedRouter(OspfRouter ospfRouter) {
- for (OspfRouterListener l : listener()) {
- l.routerRemoved(ospfRouter);
- }
- }
-
- @Override
- public void addLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
- for (OspfLinkListener l : linkListener()) {
- l.addLink(ospfRouter, ospfLinkTed);
- }
-
- }
-
- @Override
- public void deleteLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
- for (OspfLinkListener l : linkListener()) {
- l.deleteLink(ospfRouter, ospfLinkTed);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfDeviceTedImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfDeviceTedImpl.java
deleted file mode 100644
index 298074d..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfDeviceTedImpl.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip6Address;
-import org.onosproject.ospf.controller.OspfDeviceTed;
-
-import java.util.List;
-
-/**
- * Representation of an OSPF device Traffic Engineering details.
- */
-public class OspfDeviceTedImpl implements OspfDeviceTed {
-
- List<Ip4Address> ipv4RouterIds;
- List<Ip6Address> ipv6RouterIds;
- List<Short> topologyIds;
- Boolean asbr;
- Boolean abr;
-
- /**
- * Gets list of IPv4 router id.
- *
- * @return list of IPv4 router id
- */
- public List<Ip4Address> ipv4RouterIds() {
- return ipv4RouterIds;
- }
-
- @Override
- public void setIpv4RouterIds(List<Ip4Address> ipv4RouterIds) {
- this.ipv4RouterIds = ipv4RouterIds;
- }
-
- /**
- * Gets if router is area border router or not.
- *
- * @return true if it is area border router else false
- */
- public Boolean abr() {
- return abr;
- }
-
- @Override
- public void setAbr(Boolean abr) {
- this.abr = abr;
- }
-
- /**
- * Gets if router is autonomous system border router or not.
- *
- * @return true or false
- */
- public Boolean asbr() {
- return asbr;
- }
-
- @Override
- public void setAsbr(Boolean asbr) {
- this.asbr = asbr;
- }
-
- /**
- * Gets list of topology id's.
- *
- * @return list of topology id's
- */
- public List<Short> topologyIds() {
- return topologyIds;
- }
-
- @Override
- public void setTopologyIds(List<Short> topologyIds) {
- this.topologyIds = topologyIds;
- }
-
- /**
- * Gets list of ipv6 router id's.
- *
- * @return list of ipv6 router id's
- */
- public List<Ip6Address> ipv6RouterIds() {
- return ipv6RouterIds;
- }
-
- @Override
- public void setIpv6RouterIds(List<Ip6Address> ipv6RouterIds) {
- this.ipv6RouterIds = ipv6RouterIds;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java
deleted file mode 100644
index 5ac63b1..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelStateEvent;
-import org.jboss.netty.channel.ExceptionEvent;
-import org.jboss.netty.channel.MessageEvent;
-import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler;
-import org.jboss.netty.handler.timeout.ReadTimeoutException;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfMessage;
-import org.onosproject.ospf.controller.OspfNbr;
-import org.onosproject.ospf.controller.OspfProcess;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.controller.util.OspfInterfaceType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.util.OspfInterfaceState;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.nio.channels.ClosedChannelException;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.RejectedExecutionException;
-
-/**
- * Channel handler deals with the OSPF channel connection.
- * Also it dispatches messages to the appropriate handlers for processing.
- */
-public class OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler {
-
- private static final Logger log = LoggerFactory.getLogger(OspfInterfaceChannelHandler.class);
- private static Map<Integer, Object> isisDb = null;
- private Channel channel = null;
- private Controller controller;
- private List<OspfProcess> processes = null;
- private byte[] configPacket = null;
- private Map<Integer, OspfInterface> ospfInterfaceMap = new ConcurrentHashMap<>();
-
- /**
- * Creates an instance of OSPF channel handler.
- *
- * @param controller controller instance
- * @param processes list of configured processes
- */
- public OspfInterfaceChannelHandler(Controller controller, List<OspfProcess> processes) {
- this.controller = controller;
- this.processes = processes;
- }
-
- /**
- * Initializes the interface map with interface details.
- */
- public void initializeInterfaceMap() {
- for (OspfProcess process : processes) {
- for (OspfArea area : process.areas()) {
- for (OspfInterface ospfInterface : area.ospfInterfaceList()) {
- OspfInterface anInterface = ospfInterfaceMap.get(ospfInterface.interfaceIndex());
- if (anInterface == null) {
- ospfInterface.setOspfArea(area);
- ((OspfInterfaceImpl) ospfInterface).setController(controller);
- ((OspfInterfaceImpl) ospfInterface).setState(OspfInterfaceState.DOWN);
- ospfInterface.setDr(Ip4Address.valueOf("0.0.0.0"));
- ospfInterface.setBdr(Ip4Address.valueOf("0.0.0.0"));
- ospfInterfaceMap.put(ospfInterface.interfaceIndex(), ospfInterface);
- }
- ((OspfInterfaceImpl) ospfInterface).setChannel(channel);
- ospfInterface.interfaceUp();
- ospfInterface.startDelayedAckTimer();
- }
- //Initialize the LSDB and aging process
- area.initializeDb();
- }
- }
- }
-
- /**
- * Updates the interface map with interface details.
- *
- * @param ospfProcesses updated process instances
- */
- public void updateInterfaceMap(List<OspfProcess> ospfProcesses) {
- for (OspfProcess ospfUpdatedProcess : ospfProcesses) {
- for (OspfArea updatedArea : ospfUpdatedProcess.areas()) {
- for (OspfInterface ospfUpdatedInterface : updatedArea.ospfInterfaceList()) {
- OspfInterface ospfInterface = ospfInterfaceMap.get(ospfUpdatedInterface.interfaceIndex());
- if (ospfInterface == null) {
- ospfUpdatedInterface.setOspfArea(updatedArea);
- ((OspfInterfaceImpl) ospfUpdatedInterface).setController(controller);
- ((OspfInterfaceImpl) ospfUpdatedInterface).setState(OspfInterfaceState.DOWN);
- ospfUpdatedInterface.setDr(Ip4Address.valueOf("0.0.0.0"));
- ospfUpdatedInterface.setBdr(Ip4Address.valueOf("0.0.0.0"));
- ospfInterfaceMap.put(ospfUpdatedInterface.interfaceIndex(), ospfUpdatedInterface);
- ((OspfInterfaceImpl) ospfUpdatedInterface).setChannel(channel);
- ospfUpdatedInterface.interfaceUp();
- ospfUpdatedInterface.startDelayedAckTimer();
- } else {
- ospfInterface.setOspfArea(updatedArea);
-
- if (ospfInterface.routerDeadIntervalTime() != ospfUpdatedInterface.routerDeadIntervalTime()) {
- ospfInterface.setRouterDeadIntervalTime(ospfUpdatedInterface.routerDeadIntervalTime());
- Map<String, OspfNbr> neighbors = ospfInterface.listOfNeighbors();
- for (String key : neighbors.keySet()) {
- OspfNbr ospfNbr = ospfInterface.neighbouringRouter(key);
- ospfNbr.setRouterDeadInterval(ospfInterface.routerDeadIntervalTime());
- ospfNbr.stopInactivityTimeCheck();
- ospfNbr.startInactivityTimeCheck();
- }
- }
- if (ospfInterface.interfaceType() != ospfUpdatedInterface.interfaceType()) {
- ospfInterface.setInterfaceType(ospfUpdatedInterface.interfaceType());
- if (ospfInterface.interfaceType() == OspfInterfaceType.POINT_TO_POINT.value()) {
- ospfInterface.setDr(Ip4Address.valueOf("0.0.0.0"));
- ospfInterface.setBdr(Ip4Address.valueOf("0.0.0.0"));
- }
- ospfInterface.removeNeighbors();
- }
- if (ospfInterface.helloIntervalTime() != ospfUpdatedInterface.helloIntervalTime()) {
- ospfInterface.setHelloIntervalTime(ospfUpdatedInterface.helloIntervalTime());
- ospfInterface.stopHelloTimer();
- ospfInterface.startHelloTimer();
- }
- ospfInterfaceMap.put(ospfInterface.interfaceIndex(), ospfInterface);
- }
- }
- }
- }
- }
-
- /**
- * Initialize channel, start hello sender and initialize LSDB.
- */
- private void initialize() {
- log.debug("OspfChannelHandler initialize..!!!");
- if (configPacket != null) {
- log.debug("OspfChannelHandler initialize -> sentConfig packet of length ::"
- + configPacket.length);
- sentConfigPacket(configPacket);
- }
- initializeInterfaceMap();
- }
-
- @Override
- public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent evt) {
- log.info("OSPF channelConnected from {}", evt.getChannel().getRemoteAddress());
- this.channel = evt.getChannel();
- initialize();
- }
-
- @Override
- public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent evt) {
- log.debug("OspfChannelHandler::channelDisconnected...!!!");
-
- for (Integer interfaceIndex : ospfInterfaceMap.keySet()) {
- OspfInterface anInterface = ospfInterfaceMap.get(interfaceIndex);
- if (anInterface != null) {
- anInterface.interfaceDown();
- anInterface.stopDelayedAckTimer();
- }
- }
-
- if (controller != null) {
- controller.connectPeer();
- }
- }
-
- @Override
- public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
- log.debug("[exceptionCaught]: " + e.toString());
- if (e.getCause() instanceof ReadTimeoutException) {
- log.debug("Disconnecting device {} due to read timeout", e.getChannel().getRemoteAddress());
- return;
- } else if (e.getCause() instanceof ClosedChannelException) {
- log.debug("Channel for OSPF {} already closed", e.getChannel().getRemoteAddress());
- } else if (e.getCause() instanceof IOException) {
- log.debug("Disconnecting OSPF {} due to IO Error: {}", e.getChannel().getRemoteAddress(),
- e.getCause().getMessage());
- } else if (e.getCause() instanceof OspfParseException) {
- OspfParseException errMsg = (OspfParseException) e.getCause();
- byte errorCode = errMsg.errorCode();
- byte errorSubCode = errMsg.errorSubCode();
- log.debug("Error while parsing message from OSPF {}, ErrorCode {}",
- e.getChannel().getRemoteAddress(), errorCode);
- } else if (e.getCause() instanceof RejectedExecutionException) {
- log.debug("Could not process message: queue full");
- } else {
- log.debug("Error while processing message from OSPF {}, {}",
- e.getChannel().getRemoteAddress(), e.getCause().getMessage());
- }
- }
-
- @Override
- public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
- log.debug("OspfChannelHandler::messageReceived...!!!");
- Object message = e.getMessage();
- if (message instanceof List) {
- List<OspfMessage> ospfMessageList = (List<OspfMessage>) message;
- log.debug("OspfChannelHandler::List of IsisMessages Size {}", ospfMessageList.size());
-
- for (OspfMessage ospfMessage : ospfMessageList) {
- processOspfMessage(ospfMessage, ctx);
- }
- }
- if (message instanceof OspfMessage) {
- OspfMessage ospfMessage = (OspfMessage) message;
- log.debug("OspfChannelHandler::OspfMessages received...!!");
- processOspfMessage(ospfMessage, ctx);
- }
- }
-
- /**
- * When an OSPF message received it is handed over to this method.
- * Based on the type of the OSPF message received it will be handed over
- * to corresponding message handler methods.
- *
- * @param ospfMessage received OSPF message
- * @param ctx channel handler context instance.
- */
- private void processOspfMessage(OspfMessage
- ospfMessage, ChannelHandlerContext ctx) {
- log.debug("OspfChannelHandler::processOspfMessage...!!!");
- int interfaceIndex = ospfMessage.interfaceIndex();
- OspfInterface ospfInterface = ospfInterfaceMap.get(interfaceIndex);
- if (ospfInterface != null) {
- ospfInterface.processOspfMessage(ospfMessage, ctx);
- }
- }
-
- /**
- * Sends the interface configuration packet to server.
- *
- * @param configPacket interface configuration
- */
- public void sentConfigPacket(byte[] configPacket) {
- if (channel != null) {
- channel.write(configPacket);
- log.debug("OspfChannelHandler sentConfigPacket packet sent..!!!");
- } else {
- log.debug("OspfChannelHandler sentConfigPacket channel not connected - re try..!!!");
- this.configPacket = configPacket;
- }
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfLinkTedImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfLinkTedImpl.java
deleted file mode 100644
index cb55499..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfLinkTedImpl.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip6Address;
-import org.onlab.util.Bandwidth;
-import org.onosproject.ospf.controller.OspfLinkTed;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Implements OSPF Link Traffic engineering details.
- */
-public class OspfLinkTedImpl implements OspfLinkTed {
-
-
- Bandwidth maximumLink;
- List<Bandwidth> maxUnResBandwidth = new ArrayList<>();
- Bandwidth maxReserved;
- Integer teMetric;
- List<Ip4Address> ipv4LocRouterId = new ArrayList<>();
- List<Ip6Address> ipv6LocRouterId = new ArrayList<>();
- List<Ip4Address> ipv4RemRouterId = new ArrayList<>();
- List<Ip6Address> ipv6RemRouterId = new ArrayList<>();
-
-
- /**
- * Gets maximum link.
- *
- * @return maximum link
- */
- public Bandwidth maximumLink() {
- return maximumLink;
- }
-
- /**
- * Sets maximum link.
- *
- * @param maximumLink maximum link
- */
- public void setMaximumLink(Bandwidth maximumLink) {
- this.maximumLink = maximumLink;
- }
-
- /**
- * Gets list of IPv6 remote router id.
- *
- * @return list of IPv6 remote router id
- */
- public List<Ip6Address> ipv6RemRouterId() {
- return ipv6RemRouterId;
- }
-
-
- /**
- * Sets list of IPv6 remote router id.
- *
- * @param ipv6RemRouterId IPv6 remote router id
- */
- public void setIpv6RemRouterId(List<Ip6Address> ipv6RemRouterId) {
- this.ipv6RemRouterId = ipv6RemRouterId;
- }
-
- /**
- * Gets list of IPv4 remote router id.
- *
- * @return list of IPv4 remote router id
- */
- public List<Ip4Address> ipv4RemRouterId() {
- return ipv4RemRouterId;
- }
-
- /**
- * Sets IPv4 remote router id.
- *
- * @param ipv4RemRouterId IPv4 remote router id
- */
- public void setIpv4RemRouterId(List<Ip4Address> ipv4RemRouterId) {
- this.ipv4RemRouterId = ipv4RemRouterId;
- }
-
- /**
- * Gets list of IPv6 local router id.
- *
- * @return list of IPv6 local router id
- */
- public List<Ip6Address> ipv6LocRouterId() {
- return ipv6LocRouterId;
- }
-
- /**
- * Sets list of IPv6 local router id.
- *
- * @param ipv6LocRouterId IPv6 local router id
- */
- public void setIpv6LocRouterId(List<Ip6Address> ipv6LocRouterId) {
- this.ipv6LocRouterId = ipv6LocRouterId;
- }
-
- /**
- * Gets list of IPv4 local router id.
- *
- * @return list of IPv4 local router id
- */
- public List<Ip4Address> ipv4LocRouterId() {
- return ipv4LocRouterId;
- }
-
- /**
- * Sets list of IPv4 local router id.
- *
- * @param ipv4LocRouterId IPv4 local router id
- */
- public void setIpv4LocRouterId(List<Ip4Address> ipv4LocRouterId) {
- this.ipv4LocRouterId = ipv4LocRouterId;
- }
-
- /**
- * Gets traffic engineering metric.
- *
- * @return traffic engineering metric
- */
- public Integer teMetric() {
- return teMetric;
- }
-
- /**
- * Sets traffic engineering metric.
- *
- * @param teMetric Traffic engineering metric
- */
- public void setTeMetric(Integer teMetric) {
- this.teMetric = teMetric;
- }
-
- /**
- * Gets maximum bandwidth reserved.
- *
- * @return maximum bandwidth reserved
- */
- public Bandwidth maxReserved() {
- return maxReserved;
- }
-
- /**
- * Sets maximum bandwidth reserved.
- *
- * @param maxReserved maximum bandwidth reserved
- */
- public void setMaxReserved(Bandwidth maxReserved) {
- this.maxReserved = maxReserved;
- }
-
- /**
- * Gets list of maximum unreserved bandwidth.
- *
- * @return list of maximum unreserved bandwidth
- */
- public List<Bandwidth> maxUnResBandwidth() {
- return maxUnResBandwidth;
- }
-
- /**
- * Sets ist of maximum unreserved bandwidth.
- *
- * @param bandwidth maximum unreserved bandwidth
- */
- public void setMaxUnResBandwidth(Bandwidth bandwidth) {
- this.maxUnResBandwidth.add(bandwidth);
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java
deleted file mode 100644
index 0446e09..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageDecoder.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfMessage;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.ospfpacket.OspfMessageReader;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Decodes an OSPF message from a Channel, for use in a netty pipeline.
- */
-public class OspfMessageDecoder extends FrameDecoder {
-
- private static final Logger log = LoggerFactory.getLogger(OspfMessageDecoder.class);
-
- @Override
- protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer)
- throws OspfParseException {
- log.debug("OspfMessageDecoder::Message received <:> length {}", buffer.readableBytes());
- if (!channel.isConnected()) {
- log.info("Channel is not connected.");
- return null;
- }
- OspfMessageReader messageReader = new OspfMessageReader();
- List<OspfMessage> ospfMessageList = new LinkedList<>();
- while (buffer.readableBytes() >= OspfUtil.MINIMUM_FRAME_LEN) {
- ChannelBuffer ospfDataBuffer = buffer.readBytes(OspfUtil.MINIMUM_FRAME_LEN);
- int readableBytes = ospfDataBuffer.readableBytes();
- OspfMessage message = messageReader.readFromBuffer(ospfDataBuffer);
- if (message != null) {
- if (ospfDataBuffer.readableBytes() >= OspfUtil.METADATA_LEN) {
- ospfDataBuffer.readerIndex(readableBytes - OspfUtil.METADATA_LEN);
- log.debug("IsisMessageDecoder::Reading metadata <:> length {}", ospfDataBuffer.readableBytes());
-
-
- int interfaceIndex = ospfDataBuffer.readByte();
- byte[] sourceIpBytes = new byte[OspfUtil.FOUR_BYTES];
- ospfDataBuffer.readBytes(sourceIpBytes, 0, OspfUtil.FOUR_BYTES);
- Ip4Address sourceIP = Ip4Address.valueOf(sourceIpBytes);
-
- message.setSourceIp(sourceIP);
- message.setInterfaceIndex(interfaceIndex);
- }
- ospfMessageList.add(message);
- }
- }
- return (!ospfMessageList.isEmpty()) ? ospfMessageList : null;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageEncoder.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageEncoder.java
deleted file mode 100644
index c457725..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfMessageEncoder.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ospf.controller.impl;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Encodes an OSPF message for output into a ChannelBuffer, for use in a netty pipeline.
- */
-public class OspfMessageEncoder extends OneToOneEncoder {
-
- private static final Logger log = LoggerFactory.getLogger(OspfMessageEncoder.class);
-
- @Override
- protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) {
-
- byte[] byteMsg = (byte[]) msg;
- log.debug("Encoding ospfMessage of length {}", byteMsg.length);
- ChannelBuffer channelBuffer = ChannelBuffers.buffer(byteMsg.length);
- channelBuffer.writeBytes(byteMsg);
-
- return channelBuffer;
- }
-}
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java
deleted file mode 100644
index 0f7a91c..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java
+++ /dev/null
@@ -1,1953 +0,0 @@
-/*
-* Copyright 2016-present Open Networking Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.onosproject.ospf.controller.impl;
-
-import org.jboss.netty.channel.Channel;
-import org.onlab.packet.Ip4Address;
-import org.onlab.util.Bandwidth;
-import org.onosproject.ospf.controller.DeviceInformation;
-import org.onosproject.ospf.controller.LinkInformation;
-import org.onosproject.ospf.controller.LsaWrapper;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfDeviceTed;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfLinkTed;
-import org.onosproject.ospf.controller.OspfLsa;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.controller.OspfLsdb;
-import org.onosproject.ospf.controller.OspfMessage;
-import org.onosproject.ospf.controller.OspfNbr;
-import org.onosproject.ospf.controller.OspfNeighborState;
-import org.onosproject.ospf.controller.OspfPacketType;
-import org.onosproject.ospf.controller.OspfRouter;
-import org.onosproject.ospf.controller.TopologyForDeviceAndLink;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.controller.lsdb.LsaWrapperImpl;
-import org.onosproject.ospf.controller.util.OspfInterfaceType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
-import org.onosproject.ospf.protocol.lsa.types.TopLevelTlv;
-import org.onosproject.ospf.protocol.ospfpacket.OspfMessageWriter;
-import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
-import org.onosproject.ospf.protocol.util.ChecksumCalculator;
-import org.onosproject.ospf.protocol.util.OspfInterfaceState;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Represents an OSPF neighbor.
- * The first thing an OSPF router must do is find its neighbors and form adjacency.
- * Each neighbor that the router finds will be represented by this class.
- */
-public class OspfNbrImpl implements OspfNbr {
- private static final Logger log = LoggerFactory.getLogger(OspfNbrImpl.class);
- private OspfNeighborState state;
- private InternalRxmtDdPacket rxmtDdPacketTask;
- private InternalInactivityTimeCheck inActivityTimeCheckTask;
- private InternalFloodingTask floodingTask;
- private InternalRxmtLsrPacket rxmtLsrPacketTask;
- private ScheduledExecutorService exServiceRxmtLsr;
- private ScheduledExecutorService exServiceFlooding;
- private ScheduledExecutorService exServiceRxmtDDPacket;
- private ScheduledExecutorService exServiceInActivity;
-
- private boolean floodingTimerScheduled = false;
- private boolean rxmtLsrTimerScheduled = false;
- private boolean rxmtDdPacketTimerScheduled = false;
- private boolean inActivityTimerScheduled = false;
-
- /**
- * When the two neighbors are exchanging databases, they form a master/slave relationship.
- * The master sends the first Database Description Packet
- */
- private int isMaster;
-
- /**
- * The DD Sequence Number of the DD packet that is currently being sent to the neighbor.
- */
- private long ddSeqNum;
-
- /**
- * Another data structure for keeping information of the last received DD packet.
- */
- private DdPacket lastDdPacket;
-
- /**
- * Another data structure for keeping information of the last Sent DD packet.
- */
- private DdPacket lastSentDdPacket;
-
- /**
- * Another data structure for keeping information of the last Sent LSrequest packet.
- */
- private LsRequest lastSentLsrPacket;
-
- /**
- * The router ID of the Neighbor Router.
- */
- private Ip4Address neighborId;
-
- /**
- * The IP address of the neighboring router's interface to the attached network.
- */
- private Ip4Address neighborIpAddr;
-
- /**
- * The neighbor's IDEA of the designated router.
- */
- private Ip4Address neighborDr;
-
- /**
- * The neighbor's IDEA of the backup designated router.
- */
- private Ip4Address neighborBdr;
-
- private int routerPriority;
- private int routerDeadInterval;
-
- /**
- * The list of LSAs that have to be flooded.
- */
- private Map<String, OspfLsa> reTxList = new LinkedHashMap<>();
-
- /**
- * The list of LSAs that have been flooded but not yet acknowledged on this adjacency.
- */
- private Map<String, OspfLsa> pendingReTxList = new LinkedHashMap<>();
-
- /**
- * List of LSAs which are failed to received ACK.
- */
- private Map failedTxList = new HashMap<>();
-
- /**
- * The complete list of LSAs that make up the area link-state database, at the moment the.
- * neighbor goes into Database Exchange state (EXCHANGE).
- */
- private List<LsaHeader> ddSummaryList = new CopyOnWriteArrayList<>();
-
- /**
- * LSA Request List from Neighbor.
- */
- private Hashtable lsReqList = new Hashtable();
-
- /**
- * The optional OSPF capabilities supported by the neighbor.
- */
- private int options;
- private boolean isOpaqueCapable;
-
- /**
- * A link to the OSPF-Interface this Neighbor belongs to.
- */
- private OspfInterface ospfInterface;
-
- /**
- * A link to the OSPF-Area this Neighbor Data Structure belongs to.
- */
- private OspfArea ospfArea;
- private List<TopLevelTlv> topLevelTlvs = new ArrayList<>();
- private List<DeviceInformation> deviceInformationList = new ArrayList<>();
-
- private TopologyForDeviceAndLink topologyForDeviceAndLink;
-
- /**
- * Creates an instance of Neighbor.
- *
- * @param paramOspfArea OSPF Area instance
- * @param paramOspfInterface OSPF interface instance
- * @param ipAddr IP address
- * @param routerId router id
- * @param options options
- * @param topologyForDeviceAndLinkCommon topology for device and link instance
- */
- public OspfNbrImpl(OspfArea paramOspfArea, OspfInterface paramOspfInterface,
- Ip4Address ipAddr, Ip4Address routerId, int options,
- TopologyForDeviceAndLink topologyForDeviceAndLinkCommon) {
- this.ospfArea = paramOspfArea;
- this.ospfInterface = paramOspfInterface;
- state = OspfNeighborState.DOWN;
- isMaster = OspfUtil.NOT_MASTER;
- ddSeqNum = OspfUtil.createRandomNumber();
- neighborIpAddr = ipAddr;
- neighborId = routerId;
- this.options = options;
- lastDdPacket = new DdPacket();
- routerDeadInterval = paramOspfInterface.routerDeadIntervalTime();
- this.topologyForDeviceAndLink = topologyForDeviceAndLinkCommon;
- }
-
- /**
- * Gets the IP address of this neighbor.
- *
- * @return the IP address of this neighbor
- */
- @Override
- public Ip4Address neighborIpAddr() {
- return neighborIpAddr;
- }
-
- /**
- * Gets the neighbor is opaque enabled or not.
- *
- * @return true if the neighbor is opaque enabled else false.
- */
- @Override
- public boolean isOpaqueCapable() {
- return isOpaqueCapable;
- }
-
- /**
- * Sets the neighbor is opaque enabled or not.
- *
- * @param isOpaqueCapable true if the neighbor is opaque enabledelse false
- */
- @Override
- public void setIsOpaqueCapable(boolean isOpaqueCapable) {
- this.isOpaqueCapable = isOpaqueCapable;
- }
-
- /**
- * Sets router dead interval.
- *
- * @param routerDeadInterval router dead interval
- */
- @Override
- public void setRouterDeadInterval(int routerDeadInterval) {
- this.routerDeadInterval = routerDeadInterval;
- }
-
- /**
- * Have seen a Neighbor, but the Neighbor doesn't know about me.
- *
- * @param ospfHello Hello Packet instance
- * @param channel netty channel instance
- */
- public void oneWayReceived(OspfMessage ospfHello, Channel channel) {
- log.debug("OSPFNbr::oneWayReceived...!!!");
- stopInactivityTimeCheck();
- startInactivityTimeCheck();
-
- if (state == OspfNeighborState.ATTEMPT) {
- state = OspfNeighborState.INIT;
- } else if (state == OspfNeighborState.DOWN) {
- state = OspfNeighborState.INIT;
- }
-
- if (state.getValue() >= OspfNeighborState.TWOWAY.getValue()) {
- state = OspfNeighborState.INIT;
- failedTxList.clear();
- ddSummaryList.clear();
- lsReqList.clear();
- }
- }
-
- /**
- * Called when a DD OSPFMessage is received while state was INIT.
- *
- * @param ospfMessage ospf message instance
- * @param channel netty channel instance
- */
- public void twoWayReceived(OspfMessage ospfMessage, Channel channel) {
- log.debug("OSPFNbr::twoWayReceived...!!!");
- stopInactivityTimeCheck();
- startInactivityTimeCheck();
- startFloodingTimer(channel);
-
- OspfPacketHeader packet = (OspfPacketHeader) ospfMessage;
- if (state.getValue() <= OspfNeighborState.TWOWAY.getValue()) {
- if (formAdjacencyOrNot()) {
- state = OspfNeighborState.EXSTART;
-
- ddSeqNum++;
- DdPacket ddPacket = new DdPacket();
- // seting OSPF Header
- ddPacket.setOspfVer(OspfUtil.OSPF_VERSION);
- ddPacket.setOspftype(OspfPacketType.DD.value());
- ddPacket.setRouterId(ospfArea.routerId());
- ddPacket.setAreaId(ospfArea.areaId());
- ddPacket.setAuthType(OspfUtil.NOT_ASSIGNED);
- ddPacket.setAuthentication(OspfUtil.NOT_ASSIGNED);
- ddPacket.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
- ddPacket.setChecksum(OspfUtil.NOT_ASSIGNED);
- boolean isOpaqueEnabled = ospfArea.isOpaqueEnabled();
- if (isOpaqueEnabled) {
- ddPacket.setOptions(ospfArea.opaqueEnabledOptions());
- } else {
- ddPacket.setOptions(ospfArea.options());
- }
- ddPacket.setIsInitialize(OspfUtil.INITIALIZE_SET);
- ddPacket.setIsMore(OspfUtil.MORE_SET);
- ddPacket.setIsMaster(OspfUtil.IS_MASTER);
- ddPacket.setImtu(ospfInterface.mtu());
- ddPacket.setSequenceNo(ddSeqNum);
-
- setLastSentDdPacket(ddPacket);
- rxmtDdPacketTask = new InternalRxmtDdPacket(channel);
- startRxMtDdTimer(channel);
- //setting destination ip
- ddPacket.setDestinationIp(packet.sourceIp());
- byte[] messageToWrite = getMessage(ddPacket);
- channel.write(messageToWrite);
- } else {
- state = OspfNeighborState.TWOWAY;
- }
- }
- }
-
- /**
- * Checks whether to form adjacency or not.
- *
- * @return true indicates form adjacency, else false
- */
- private boolean formAdjacencyOrNot() {
- boolean formAdjacency = false;
-
- if (ospfInterface.interfaceType() == OspfInterfaceType.POINT_TO_POINT.value()) {
- formAdjacency = true;
- } else if (ospfInterface.interfaceType() == OspfInterfaceType.BROADCAST.value()) {
- if (ospfInterface.ipAddress().equals(this.neighborDr) ||
- ospfInterface.ipAddress().equals(this.neighborBdr)) {
- formAdjacency = true;
- } else if (neighborBdr.equals(neighborIpAddr) ||
- neighborDr.equals(neighborIpAddr)) {
- formAdjacency = true;
- }
- }
-
- log.debug("FormAdjacencyOrNot - neighborDR: {}, neighborBDR: {}, neighborIPAddr: {}, formAdjacencyOrNot {}",
- neighborDr, neighborBdr, neighborIpAddr, formAdjacency);
-
- return formAdjacency;
- }
-
- /**
- * At this point Master/Slave relationship is definitely established.
- * DD sequence numbers have been exchanged.
- * This is the begin of sending/receiving of DD OSPFMessages.
- *
- * @param ospfMessage OSPF message instance
- * @param neighborIsMaster neighbor is master or slave
- * @param payload contains the LSAs to add in Dd Packet
- * @param ch netty channel instance
- */
- public void negotiationDone(OspfMessage ospfMessage,
- boolean neighborIsMaster, List payload, Channel ch) {
- stopRxMtDdTimer();
- OspfPacketHeader packet = (OspfPacketHeader) ospfMessage;
- DdPacket ddPacketForCheck = (DdPacket) packet;
- if (ddPacketForCheck.isOpaqueCapable()) {
- OspfLsdb database = ospfArea.database();
- List opaqueLsas = database.getAllLsaHeaders(true, true);
- Iterator iterator = opaqueLsas.iterator();
- while (iterator.hasNext()) {
- OspfLsa ospfLsa = (OspfLsa) iterator.next();
- if (ospfLsa.getOspfLsaType() == OspfLsaType.AREA_LOCAL_OPAQUE_LSA) {
- OpaqueLsa10 opaqueLsa10 = (OpaqueLsa10) ospfLsa;
- topLevelTlvs = opaqueLsa10.topLevelValues();
- }
- }
- }
- if (state == OspfNeighborState.EXSTART) {
- state = OspfNeighborState.EXCHANGE;
- boolean excludeMaxAgeLsa = true;
- //list of contents of area wise LSA
- ddSummaryList = ospfArea.getLsaHeaders(excludeMaxAgeLsa, isOpaqueCapable);
-
- if (neighborIsMaster) {
- processLsas(payload);
- // ...construct new DD Packet...
- DdPacket ddPacket = new DdPacket();
- // setting OSPF Header
- ddPacket.setOspfVer(OspfUtil.OSPF_VERSION);
- ddPacket.setOspftype(OspfPacketType.DD.value());
- ddPacket.setRouterId(ospfArea.routerId());
- ddPacket.setAreaId(ospfArea.areaId());
- ddPacket.setAuthType(OspfUtil.NOT_ASSIGNED);
- ddPacket.setAuthentication(OspfUtil.NOT_ASSIGNED);
- ddPacket.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
- ddPacket.setChecksum(OspfUtil.NOT_ASSIGNED);
- boolean isOpaqueEnabled = ospfArea.isOpaqueEnabled();
- if (isOpaqueEnabled && isOpaqueCapable) {
- ddPacket.setOptions(ospfArea.opaqueEnabledOptions());
- } else {
- ddPacket.setOptions(ospfArea.options());
- }
- ddPacket.setIsInitialize(OspfUtil.INITIALIZE_NOTSET);
- ddPacket.setIsMore(OspfUtil.MORE_NOTSET);
- ddPacket.setIsMaster(OspfUtil.NOT_MASTER);
- ddPacket.setImtu(ospfInterface.mtu());
- ddPacket.setSequenceNo(ddSeqNum);
- //setting the destination
- ddPacket.setDestinationIp(packet.sourceIp());
- setLastSentDdPacket(ddPacket);
- getIsMoreBit();
-
- byte[] messageToWrite = getMessage(lastSentDdPacket);
- ch.write(messageToWrite);
- } else {
- // process LSA Vector's List, Add it to LSRequestList.
- processLsas(payload);
- DdPacket ddPacket = new DdPacket();
- // setting OSPF Header
- ddPacket.setOspfVer(OspfUtil.OSPF_VERSION);
- ddPacket.setOspftype(OspfPacketType.DD.value());
- ddPacket.setRouterId(ospfArea.routerId());
- ddPacket.setAreaId(ospfArea.areaId());
- ddPacket.setAuthType(OspfUtil.NOT_ASSIGNED);
- ddPacket.setAuthentication(OspfUtil.NOT_ASSIGNED);
- ddPacket.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
- ddPacket.setChecksum(OspfUtil.NOT_ASSIGNED);
- boolean isOpaqueEnabled = ospfArea.isOpaqueEnabled();
- if (isOpaqueEnabled && isOpaqueCapable) {
- ddPacket.setOptions(ospfArea.opaqueEnabledOptions());
- } else {
- ddPacket.setOptions(ospfArea.options());
- }
- ddPacket.setIsInitialize(OspfUtil.INITIALIZE_NOTSET);
- ddPacket.setIsMore(OspfUtil.MORE_NOTSET);
- ddPacket.setIsMaster(OspfUtil.IS_MASTER);
- ddPacket.setImtu(ospfInterface.mtu());
- ddPacket.setSequenceNo(ddSeqNum);
- setLastSentDdPacket(ddPacket);
- getIsMoreBit();
- ddPacket.setDestinationIp(packet.sourceIp());
- byte[] messageToWrite = getMessage(lastSentDdPacket);
- ch.write(messageToWrite);
- startRxMtDdTimer(ch);
- }
- }
- }
-
- /**
- * Process the LSA Headers received in the last received Database Description OSPFMessage.
- *
- * @param ddPayload LSA headers to process
- */
- public void processLsas(List ddPayload) {
- log.debug("OSPFNbr::processLsas...!!!");
- OspfLsa nextLsa;
- Iterator lsas = ddPayload.iterator();
- while (lsas.hasNext()) {
- nextLsa = (OspfLsa) lsas.next();
- // check LSA Type.
- if (((nextLsa.getOspfLsaType().value() > OspfLsaType.EXTERNAL_LSA.value()) &&
- (nextLsa.getOspfLsaType().value() < OspfLsaType.LINK_LOCAL_OPAQUE_LSA.value())) ||
- (nextLsa.getOspfLsaType().value() > OspfLsaType.AS_OPAQUE_LSA.value())) {
- // unknown lsType found!
- seqNumMismatch("LS Type found was unknown.");
- return;
- }
-
- if ((nextLsa.getOspfLsaType() == OspfLsaType.EXTERNAL_LSA) &&
- !ospfArea.isExternalRoutingCapability()) {
- // LSA is external and the Area has no external lsa capability
- seqNumMismatch("External LSA found although area is stub.");
- return;
- }
-
- LsaWrapper lsaHasInstance = ospfArea.lsaLookup(nextLsa);
- if (lsaHasInstance == null) {
- lsReqList.put(((OspfAreaImpl) ospfArea).getLsaKey((LsaHeader) nextLsa), nextLsa);
- } else {
- String isNew = ((OspfAreaImpl) ospfArea).isNewerOrSameLsa(nextLsa,
- lsaHasInstance.ospfLsa());
- if (isNew.equals("latest")) {
- lsReqList.put(((OspfAreaImpl) ospfArea).getLsaKey((LsaHeader) nextLsa), nextLsa);
- }
- }
- }
- }
-
- /**
- * Handles sequence number mis match event.
- *
- * @param reason a string represents the mismatch reason
- * @return OSPF message instance
- */
- public OspfMessage seqNumMismatch(String reason) {
- log.debug("OSPFNbr::seqNumMismatch...{} ", reason);
- stopRxMtDdTimer();
-
- if (state.getValue() >= OspfNeighborState.EXCHANGE.getValue()) {
- /* if (state == OspfNeighborState.FULL) {
- ospfArea.refreshArea(ospfInterface);
- }*/
-
- state = OspfNeighborState.EXSTART;
- lsReqList.clear();
- ddSummaryList.clear();
- //increment the dd sequence number
- ddSeqNum++;
-
- DdPacket ddPacket = new DdPacket();
- // seting OSPF Header
- ddPacket.setOspfVer(OspfUtil.OSPF_VERSION);
- ddPacket.setOspftype(OspfPacketType.DD.value());
- ddPacket.setRouterId(ospfArea.routerId());
- ddPacket.setAreaId(ospfArea.areaId());
- ddPacket.setAuthType(OspfUtil.NOT_ASSIGNED);
- ddPacket.setAuthentication(OspfUtil.NOT_ASSIGNED);
- ddPacket.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
- ddPacket.setChecksum(OspfUtil.NOT_ASSIGNED);
- boolean isOpaqueEnabled = ospfArea.isOpaqueEnabled();
- if (isOpaqueEnabled) {
- ddPacket.setOptions(ospfArea.opaqueEnabledOptions());
- } else {
- ddPacket.setOptions(ospfArea.options());
- }
- ddPacket.setIsInitialize(OspfUtil.INITIALIZE_SET);
- ddPacket.setIsMore(OspfUtil.MORE_SET);
- ddPacket.setIsMaster(OspfUtil.IS_MASTER);
- ddPacket.setImtu(ospfInterface.mtu());
- ddPacket.setSequenceNo(ddSeqNum);
-
- setLastSentDdPacket(ddPacket);
- //setting destination ip
- ddPacket.setDestinationIp(neighborIpAddr());
- setLastSentDdPacket(ddPacket);
-
- return ddPacket;
- }
-
- return null;
- }
-
- /**
- * Called if a LS Request has been received for an LSA which is not contained in the database.
- * This indicates an error in the Database Exchange process.
- * Actions to be performed are the same as in seqNumMismatch.
- * In addition, stop the possibly activated re transmission timer.
- *
- * @param ch netty channel instance
- */
- @Override
- public void badLSReq(Channel ch) {
- log.debug("OSPFNbr::badLSReq...!!!");
-
- if (state.getValue() >= OspfNeighborState.EXCHANGE.getValue()) {
- if (state == OspfNeighborState.FULL) {
- ospfArea.refreshArea(ospfInterface);
- }
-
- stopRxMtDdTimer();
- state = OspfNeighborState.EXSTART;
-
- lsReqList.clear();
- ddSummaryList.clear();
- reTxList.clear();
- //increment the dd sequence number
- isMaster = OspfUtil.IS_MASTER;
- ddSeqNum++;
- DdPacket ddPacket = new DdPacket();
- // seting OSPF Header
- ddPacket.setOspfVer(OspfUtil.OSPF_VERSION);
- ddPacket.setOspftype(OspfPacketType.DD.value());
- ddPacket.setRouterId(ospfArea.routerId());
- ddPacket.setAreaId(ospfArea.areaId());
- ddPacket.setAuthType(OspfUtil.NOT_ASSIGNED);
- ddPacket.setAuthentication(OspfUtil.NOT_ASSIGNED);
- ddPacket.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
- ddPacket.setChecksum(OspfUtil.NOT_ASSIGNED);
-
- // setting DD Body
- boolean isOpaqueEnabled = ospfArea.isOpaqueEnabled();
- if (isOpaqueEnabled && this.isOpaqueCapable) {
- ddPacket.setOptions(ospfArea.opaqueEnabledOptions());
- } else {
- ddPacket.setOptions(ospfArea.options());
- }
- ddPacket.setIsInitialize(OspfUtil.INITIALIZE_SET);
- ddPacket.setIsMore(OspfUtil.MORE_SET);
- ddPacket.setIsMaster(OspfUtil.IS_MASTER);
- ddPacket.setImtu(ospfInterface.mtu());
- ddPacket.setSequenceNo(ddSeqNum);
-
- rxmtDdPacketTask = new InternalRxmtDdPacket(ch);
- startRxMtDdTimer(ch);
-
- //setting destination ip
- ddPacket.setDestinationIp(neighborIpAddr());
- setLastSentDdPacket(ddPacket);
- byte[] messageToWrite = getMessage(ddPacket);
- ch.write(messageToWrite);
- }
- }
-
- /**
- * Called if state is EXCHANGE. This method is executed every time a DD Packets arrives.
- * When the last Packet arrives, it transfers the state into LOADING or FULL
- *
- * @param neighborIsMaster true if neighbor is master else false
- * @param dataDescPkt DdPacket instance
- * @param ch netty channel instance
- */
- public void processDdPacket(boolean neighborIsMaster, DdPacket dataDescPkt,
- Channel ch) {
- log.debug("OSPFNbr::neighborIsMaster.{}", neighborIsMaster);
-
- if (!neighborIsMaster) {
- stopRxMtDdTimer();
- ddSeqNum++;
- processLsas(dataDescPkt.getLsaHeaderList());
- if ((ddSummaryList.isEmpty()) &&
- (dataDescPkt.isMore() == OspfUtil.MORE_NOTSET)) {
- log.debug(
- "OSPFNbr::ddSummaryList is empty and dataDescPkt.isMore is zero..!!!");
- // generate the neighbor event ExchangeDone.
- exchangeDone(dataDescPkt, ch);
- } else {
- log.debug("OSPFNbr::ddSummaryList is present...!!!");
- // send a new Database Description Packet to the slave.
- DdPacket ddPacket = new DdPacket();
- // seting OSPF Header
- ddPacket.setOspfVer(OspfUtil.OSPF_VERSION);
- ddPacket.setOspftype(OspfPacketType.DD.value());
- ddPacket.setRouterId(ospfArea.routerId());
- ddPacket.setAreaId(ospfArea.areaId());
- ddPacket.setAuthType(OspfUtil.NOT_ASSIGNED);
- ddPacket.setAuthentication(OspfUtil.NOT_ASSIGNED);
- ddPacket.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
- ddPacket.setChecksum(OspfUtil.NOT_ASSIGNED);
- // setting DD Body
- boolean isOpaqueEnabled = ospfArea.isOpaqueEnabled();
- if (isOpaqueEnabled && isOpaqueCapable) {
- ddPacket.setOptions(ospfArea.opaqueEnabledOptions());
- } else {
- ddPacket.setOptions(ospfArea.options());
- }
- ddPacket.setIsInitialize(OspfUtil.INITIALIZE_NOTSET);
- ddPacket.setIsMore(OspfUtil.MORE_NOTSET);
- ddPacket.setIsMaster(OspfUtil.IS_MASTER);
- ddPacket.setImtu(ospfInterface.mtu());
- ddPacket.setSequenceNo(ddSeqNum);
-
- setLastSentDdPacket(ddPacket);
- getIsMoreBit();
- //Set the destination IP Address
- ddPacket.setDestinationIp(dataDescPkt.sourceIp());
- byte[] messageToWrite = getMessage(lastSentDdPacket());
- ch.write(messageToWrite);
-
- startRxMtDdTimer(ch);
- }
- } else {
- log.debug("OSPFNbr::neighborIsMaster is master...!!!");
- ddSeqNum = dataDescPkt.sequenceNo();
- processLsas(dataDescPkt.getLsaHeaderList());
-
- DdPacket ddPacket = new DdPacket();
- // seting OSPF Header
- ddPacket.setOspfVer(OspfUtil.OSPF_VERSION);
- ddPacket.setOspftype(OspfPacketType.DD.value());
- ddPacket.setRouterId(ospfArea.routerId());
- ddPacket.setAreaId(ospfArea.areaId());
- ddPacket.setAuthType(OspfUtil.NOT_ASSIGNED);
- ddPacket.setAuthentication(OspfUtil.NOT_ASSIGNED);
- ddPacket.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
- ddPacket.setChecksum(OspfUtil.NOT_ASSIGNED);
- // setting DD Body
- boolean isOpaqueEnabled = ospfArea.isOpaqueEnabled();
- if (isOpaqueEnabled && this.isOpaqueCapable) {
- ddPacket.setOptions(ospfArea.opaqueEnabledOptions());
- } else {
- ddPacket.setOptions(ospfArea.options());
- }
- ddPacket.setIsInitialize(OspfUtil.INITIALIZE_NOTSET);
- ddPacket.setIsMore(OspfUtil.MORE_NOTSET);
- ddPacket.setIsMaster(OspfUtil.NOT_MASTER);
- ddPacket.setImtu(ospfInterface.mtu());
- ddPacket.setSequenceNo(ddSeqNum);
- setLastSentDdPacket(ddPacket);
- getIsMoreBit();
-
- if ((ddPacket.isMore() == OspfUtil.MORE_NOTSET) &&
- (dataDescPkt.isMore() == OspfUtil.MORE_NOTSET)) {
- // generate the neighbor event ExchangeDone.
- exchangeDone(dataDescPkt, ch);
- }
-
- ddPacket.setDestinationIp(dataDescPkt.sourceIp());
- byte[] messageToWrite = getMessage(ddPacket);
- ch.write(messageToWrite);
- }
- }
-
- /**
- * Sets the more bit in stored, last sent DdPacket.
- */
- private void getIsMoreBit() {
- DdPacket ddPacket = lastSentDdPacket();
- int count = ddSummaryList.size();
-
- if (!ddSummaryList.isEmpty()) {
- Iterator itr = ddSummaryList.iterator();
- int currentLength = OspfUtil.DD_HEADER_LENGTH;
- int maxSize = ospfInterface.mtu() - OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
- while (itr.hasNext()) {
- if ((currentLength + OspfUtil.LSA_HEADER_LENGTH) > maxSize) {
- break;
- }
-
- LsaHeader lsaHeader = (LsaHeader) itr.next();
- ddPacket.addLsaHeader(lsaHeader);
- currentLength = currentLength + OspfUtil.LSA_HEADER_LENGTH;
- ddSummaryList.remove(lsaHeader);
- count--;
- }
-
- if (count > 0) {
- ddPacket.setIsMore(OspfUtil.MORE_SET);
- } else {
- ddPacket.setIsMore(OspfUtil.MORE_NOTSET);
- }
- }
-
- setLastSentDdPacket(ddPacket);
- }
-
- /**
- * At this point, the router has sent and received an entire sequence of DD packets.
- * Now it must be determined whether the new state is FULL, or LS Request packets
- * have to be send.
- *
- * @param message OSPF message instance
- * @param ch netty channel handler
- */
- public void exchangeDone(OspfMessage message, Channel ch) {
- log.debug("OSPFNbr::exchangeDone...!!!");
- stopRxMtDdTimer();
-
- OspfPacketHeader header = (OspfPacketHeader) message;
-
- if (state == OspfNeighborState.EXCHANGE) {
- if (lsReqList.isEmpty()) {
- state = OspfNeighborState.FULL;
- //handler.addDeviceInformation(this);
- //handler.addLinkInformation(this, topLevelTlvs);
- } else {
- state = OspfNeighborState.LOADING;
- LsRequest lsRequest = buildLsRequest();
- //Setting the destination address
- lsRequest.setDestinationIp(header.sourceIp());
- byte[] messageToWrite = getMessage(lsRequest);
- ch.write(messageToWrite);
-
- setLastSentLsrPacket(lsRequest);
- startRxMtLsrTimer(ch);
- }
- }
- }
-
- /**
- * Builds LS Request.
- *
- * @return ls request instance
- */
- private LsRequest buildLsRequest() {
- //send link state request packet to neighbor
- //for recent lsa's which are not received in exchange state
- LsRequest lsRequest = new LsRequest();
- lsRequest.setOspfVer(OspfUtil.OSPF_VERSION);
- lsRequest.setOspftype(OspfPacketType.LSREQUEST.value());
- lsRequest.setRouterId(ospfArea.routerId());
- lsRequest.setAreaId(ospfArea.areaId());
- lsRequest.setAuthType(OspfUtil.NOT_ASSIGNED);
- lsRequest.setAuthentication(OspfUtil.NOT_ASSIGNED);
- lsRequest.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
- lsRequest.setChecksum(OspfUtil.NOT_ASSIGNED);
-
- Set lsaKeys = lsReqList.keySet();
- Iterator itr = lsaKeys.iterator();
-
- int currentLength = OspfUtil.OSPF_HEADER_LENGTH;
- int maxSize = ospfInterface.mtu() -
- OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
-
- while (itr.hasNext()) {
- if ((currentLength + OspfUtil.LSREQUEST_LENGTH) >= maxSize) {
- break;
- }
- LsRequestPacket lsRequestPacket = new LsRequestPacket();
-
- String key = ((String) itr.next());
- String[] lsaKey = key.split("-");
- OspfLsa lsa = (OspfLsa) lsReqList.get(key);
-
- lsRequestPacket.setLsType(Integer.valueOf(lsaKey[0]));
- lsRequestPacket.setOwnRouterId(lsaKey[2]);
-
- if (((lsa.getOspfLsaType().value() == OspfLsaType.AREA_LOCAL_OPAQUE_LSA.value()) ||
- (lsa.getOspfLsaType().value() == OspfLsaType.LINK_LOCAL_OPAQUE_LSA.value())) ||
- (lsa.getOspfLsaType().value() == OspfLsaType.AS_OPAQUE_LSA.value())) {
- OpaqueLsaHeader header = (OpaqueLsaHeader) lsa;
- byte[] opaqueIdBytes = OspfUtil.convertToTwoBytes(header.opaqueId());
- lsRequestPacket.setLinkStateId(header.opaqueType() + "." + "0" + "." + opaqueIdBytes[0]
- + "." + opaqueIdBytes[1]);
- } else {
- lsRequestPacket.setLinkStateId(lsaKey[1]);
- }
-
- lsRequest.addLinkStateRequests(lsRequestPacket);
- currentLength = currentLength + OspfUtil.LSREQUEST_LENGTH;
- }
-
- return lsRequest;
- }
-
- /**
- * Determines whether an adjacency should be established/maintained with the neighbor or not.
- *
- * @param ch netty channel instance
- */
- @Override
- public void adjOk(Channel ch) {
- log.debug("OSPFNbr::adjOk...!!!");
- if (ospfInterface.interfaceType() != OspfInterfaceType.POINT_TO_POINT.value()) {
- if (state == OspfNeighborState.TWOWAY) {
- if (formAdjacencyOrNot()) {
- state = OspfNeighborState.EXSTART;
- //check for sequence number in lsdb
- ddSeqNum++;
-
- DdPacket ddPacket = new DdPacket();
- // seting OSPF Header
- ddPacket.setOspfVer(OspfUtil.OSPF_VERSION);
- ddPacket.setOspftype(OspfPacketType.DD.value());
- ddPacket.setRouterId(ospfArea.routerId());
- ddPacket.setAreaId(ospfArea.areaId());
- ddPacket.setAuthType(OspfUtil.NOT_ASSIGNED);
- ddPacket.setAuthentication(OspfUtil.NOT_ASSIGNED);
- ddPacket.setOspfPacLength(OspfUtil.NOT_ASSIGNED);
- ddPacket.setChecksum(OspfUtil.NOT_ASSIGNED);
-
- // setting DD Body
- boolean isOpaqueEnabled = ospfArea.isOpaqueEnabled();
- if (isOpaqueEnabled && this.isOpaqueCapable) {
- ddPacket.setOptions(ospfArea.opaqueEnabledOptions());
- } else {
- ddPacket.setOptions(ospfArea.options());
- }
- ddPacket.setIsInitialize(OspfUtil.INITIALIZE_SET);
- ddPacket.setIsMore(OspfUtil.MORE_SET);
- ddPacket.setIsMaster(OspfUtil.IS_MASTER);
- ddPacket.setImtu(ospfInterface.mtu());
- ddPacket.setSequenceNo(ddSeqNum);
- rxmtDdPacketTask = new InternalRxmtDdPacket(ch);
- startRxMtDdTimer(ch);
- //setting destination ip
- ddPacket.setDestinationIp(neighborIpAddr());
- setLastSentDdPacket(ddPacket);
- byte[] messageToWrite = getMessage(ddPacket);
- ch.write(messageToWrite);
- }
- } else if (state.getValue() >= OspfNeighborState.EXSTART.getValue()) {
- if (!formAdjacencyOrNot()) {
- state = OspfNeighborState.TWOWAY;
- lsReqList.clear();
- ddSummaryList.clear();
- reTxList.clear();
- }
- }
- }
- }
-
- /**
- * LS Update Packet has been received while state was EXCHANGE or LOADING.
- * Examine the received LSAs, check whether they were requested or not and process
- * them accordingly. Therefore use method "processReceivedLsa" for further treatment.
- *
- * @param lsUpdPkt LS Update Packet received while Neighbor state was EXCHANGE or
- * LOADING
- * @param ch netty channel instance
- * @throws OspfParseException on parsing error
- */
- public void processLsUpdate(LsUpdate lsUpdPkt, Channel ch) throws OspfParseException {
- stopRxMtLsrTimer();
- log.debug("OSPFNbr::processLsUpdate...!!!");
-
- List lsaList = lsUpdPkt.getLsaList();
- if (!lsaList.isEmpty()) {
- Iterator itr = lsaList.iterator();
-
- while (itr.hasNext()) {
- LsaHeader lsaHeader = (LsaHeader) itr.next();
- String key = ((OspfAreaImpl) ospfArea).getLsaKey(lsaHeader);
-
- if (lsReqList.containsKey(key)) {
- boolean removeIt;
- removeIt = processReceivedLsa(lsaHeader, false, ch,
- lsUpdPkt.sourceIp());
- if (removeIt) {
- lsReqList.remove(key);
- }
- } else {
- // LSA was received via Flooding
- processReceivedLsa(lsaHeader, true, ch,
- lsUpdPkt.sourceIp());
- }
- }
-
- if (lsReqList.isEmpty() && (state == OspfNeighborState.LOADING)) {
- // loading complete
- loadingDone();
- } else {
- stopRxMtLsrTimer();
- LsRequest lsRequest = buildLsRequest();
- lsRequest.setDestinationIp(lsUpdPkt.sourceIp());
- setLastSentLsrPacket(lsRequest);
-
- startRxMtLsrTimer(ch);
- }
- }
- }
-
- /***
- * Method gets called when no more ls request list and moving to FULL State.
- */
- public void loadingDone() {
- stopRxMtLsrTimer();
- stopRxMtDdTimer();
- log.debug("OSPFNbr::loadingDone...!!!");
- state = OspfNeighborState.FULL;
- ospfArea.refreshArea(ospfInterface);
- }
-
- /**
- * Adds device and link.
- *
- * @param topologyForDeviceAndLink topology for device and link instance
- */
- private void callDeviceAndLinkAdding(TopologyForDeviceAndLink topologyForDeviceAndLink) {
- Map<String, DeviceInformation> deviceInformationMap = topologyForDeviceAndLink.deviceInformationMap();
- Map<String, DeviceInformation> deviceInformationMapForPointToPoint =
- topologyForDeviceAndLink.deviceInformationMapForPointToPoint();
- Map<String, DeviceInformation> deviceInformationMapToDelete =
- topologyForDeviceAndLink.deviceInformationMapToDelete();
- Map<String, LinkInformation> linkInformationMap = topologyForDeviceAndLink.linkInformationMap();
- Map<String, LinkInformation> linkInformationMapForPointToPoint =
- topologyForDeviceAndLink.linkInformationMapForPointToPoint();
- OspfRouter ospfRouter = new OspfRouterImpl();
-
- if (deviceInformationMap.size() != 0) {
- for (String key : deviceInformationMap.keySet()) {
- DeviceInformation value = deviceInformationMap.get(key);
- ospfRouter.setRouterIp(value.routerId());
- ospfRouter.setAreaIdOfInterface(ospfArea.areaId());
- ospfRouter.setNeighborRouterId(value.deviceId());
- OspfDeviceTed ospfDeviceTed = new OspfDeviceTedImpl();
- List<Ip4Address> ip4Addresses = value.interfaceId();
- ospfDeviceTed.setIpv4RouterIds(ip4Addresses);
- ospfRouter.setDeviceTed(ospfDeviceTed);
- ospfRouter.setOpaque(ospfArea.isOpaqueEnabled());
- if (value.isDr()) {
- ospfRouter.setDr(value.isDr());
- } else {
- ospfRouter.setDr(false);
- }
- int size = value.interfaceId().size();
- for (int i = 0; i < size; i++) {
- ospfRouter.setInterfaceId(value.interfaceId().get(i));
- }
- ((OspfInterfaceImpl) ospfInterface).addDeviceInformation(ospfRouter);
- }
- }
- if (deviceInformationMapForPointToPoint.size() != 0) {
- for (String key : deviceInformationMapForPointToPoint.keySet()) {
- DeviceInformation value = deviceInformationMapForPointToPoint.get(key);
- ospfRouter.setRouterIp(value.routerId());
- ospfRouter.setAreaIdOfInterface(ospfArea.areaId());
- ospfRouter.setNeighborRouterId(value.deviceId());
- OspfDeviceTed ospfDeviceTed = new OspfDeviceTedImpl();
- List<Ip4Address> ip4Addresses = value.interfaceId();
- ospfDeviceTed.setIpv4RouterIds(ip4Addresses);
- ospfRouter.setDeviceTed(ospfDeviceTed);
- ospfRouter.setOpaque(value.isDr());
- int size = value.interfaceId().size();
- for (int i = 0; i < size; i++) {
- ospfRouter.setInterfaceId(value.interfaceId().get(i));
- }
- ((OspfInterfaceImpl) ospfInterface).addDeviceInformation(ospfRouter);
- }
- }
- for (Map.Entry<String, LinkInformation> entry : linkInformationMap.entrySet()) {
- String key = entry.getKey();
- LinkInformation value = entry.getValue();
- OspfRouter ospfRouterForLink = new OspfRouterImpl();
- ospfRouterForLink.setInterfaceId(value.interfaceIp());
- ospfRouterForLink.setAreaIdOfInterface(ospfArea.areaId());
- ospfRouterForLink.setOpaque(ospfArea.isOpaqueEnabled());
- OspfLinkTed ospfLinkTed = topologyForDeviceAndLink.getOspfLinkTedHashMap(
- value.linkDestinationId().toString());
- if (ospfLinkTed == null) {
- ospfLinkTed = new OspfLinkTedImpl();
- ospfLinkTed.setMaximumLink(Bandwidth.bps(0));
- ospfLinkTed.setMaxReserved(Bandwidth.bps(0));
- ospfLinkTed.setTeMetric(0);
- }
-
- if (!value.isLinkSrcIdNotRouterId()) {
- ospfRouterForLink.setRouterIp(value.linkSourceId());
- ospfRouterForLink.setNeighborRouterId(value.linkDestinationId());
- try {
- ((OspfInterfaceImpl) ospfInterface).addLinkInformation(ospfRouterForLink, ospfLinkTed);
- } catch (Exception e) {
- log.debug("Exception addLinkInformation: " + e.getMessage());
- }
- }
- }
- }
-
- // RFC 2328 Section 13 - partly as flooding procedure
-
- /**
- * Processes the received Lsa.
- *
- * @param recLsa received Lsa
- * @param receivedViaFlooding received via flooding or not
- * @param ch channel instance
- * @param sourceIp source of this Lsa
- * @throws OspfParseException on parsing error
- * @return true to remove it from lsReqList else false
- */
- public boolean processReceivedLsa(LsaHeader recLsa,
- boolean receivedViaFlooding, Channel ch, Ip4Address sourceIp)
- throws OspfParseException {
- log.debug("OSPFNbr::processReceivedLsa(recLsa, receivedViaFlooding, ch)...!!!");
-
- //Validate the lsa checksum RFC 2328 13 (1)
- ChecksumCalculator checkSum = new ChecksumCalculator();
- if (!checkSum.isValidLsaCheckSum(recLsa,
- recLsa.getOspfLsaType().value(),
- OspfUtil.LSAPACKET_CHECKSUM_POS1,
- OspfUtil.LSAPACKET_CHECKSUM_POS2)) {
- log.debug("Checksum mismatch. Received LSA packet type {} ",
- recLsa.lsType());
-
- return true;
- }
-
- //If LSA type is unknown discard the lsa RFC 2328 13(2)
- if (((recLsa.getOspfLsaType().value() > OspfLsaType.EXTERNAL_LSA.value()) &&
- (recLsa.getOspfLsaType().value() < OspfLsaType.LINK_LOCAL_OPAQUE_LSA.value())) ||
- (recLsa.getOspfLsaType().value() > OspfLsaType.AS_OPAQUE_LSA.value())) {
- return true;
- }
-
- //If LSA type is external & the area is configured as stub area discard the lsa RFC 2328 13(3)
- if ((recLsa.getOspfLsaType() == OspfLsaType.EXTERNAL_LSA) &&
- (!ospfArea.isExternalRoutingCapability())) {
- return true;
- }
-
- //if lsa age is equal to maxage && instance is not in lsdb && none of neighbors are in exchange
- // or loading state
- // Acknowledge the receipt by sending LSAck to the sender. 2328 13(4)
- if ((recLsa.age() == OspfParameters.MAXAGE) &&
- (ospfArea.lsaLookup(recLsa) == null) &&
- ospfArea.noNeighborInLsaExchangeProcess()) {
- // RFC 2328 Section 13. (4)
- // Because the LSA was not yet requested, it is treated as a flooded LSA and thus
- // acknowledged.
- directAcknowledge(recLsa, ch, sourceIp);
- return true;
- }
-
- String key = ((OspfAreaImpl) ospfArea).getLsaKey(recLsa);
- LsaWrapper lsWrapper = ospfArea.lsaLookup(recLsa);
- String status = isNullorLatest(lsWrapper, recLsa);
- //Section 13 (5)
- if (status.equals("isNullorLatest")) {
-
- if (recLsa.lsType() == OspfLsaType.ROUTER.value() && recLsa.advertisingRouter().equals(
- ospfArea.routerId())) {
- if (recLsa.lsSequenceNo() > ((LsaWrapperImpl) lsWrapper).lsaHeader().lsSequenceNo()) {
- ospfArea.setDbRouterSequenceNumber(recLsa.lsSequenceNo() + 1);
- processSelfOriginatedLsa();
- }
-
- if (recLsa.age() == OspfParameters.MAXAGE) {
- ((LsaWrapperImpl) lsWrapper).lsaHeader().setAge(OspfParameters.MAXAGE);
- //remove from db & bin, add the lsa to MaxAge bin.
- ospfArea.addLsaToMaxAgeBin(((OspfAreaImpl) ospfArea).getLsaKey(((LsaWrapperImpl)
- lsWrapper).lsaHeader()), lsWrapper);
- ospfArea.removeLsaFromBin(lsWrapper);
- }
-
- return true;
- } else if (recLsa.lsType() == OspfLsaType.NETWORK.value() && isLinkStateMatchesOwnRouterId(
- recLsa.linkStateId())) {
- // if we are not DR or if origination router ID not equal to our router ID //either
- // DR state changed or our router ID was changed
- //set LSAge = MaxAge
- //flood the LSA
- if (((OspfInterfaceImpl) ospfInterface).state() != OspfInterfaceState.DR ||
- !recLsa.advertisingRouter().equals(
- ospfArea.routerId())) {
- if (lsWrapper != null) {
- ((LsaWrapperImpl) lsWrapper).lsaHeader().setAge(OspfParameters.MAXAGE);
- //remove from bin, add the lsa to MaxAge bin.
- ospfArea.addLsaToMaxAgeBin(((OspfAreaImpl) ospfArea).getLsaKey(((LsaWrapperImpl)
- lsWrapper).lsaHeader()), lsWrapper);
- ospfArea.removeLsaFromBin(lsWrapper);
- } else {
- recLsa.setAge(OspfParameters.MAXAGE);
- ((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(recLsa);
- }
- }
-
- return true;
- } else {
- if (recLsa.age() == OspfParameters.MAXAGE) {
- ((OspfInterfaceImpl) ospfInterface).addLsaHeaderForDelayAck(recLsa);
- //remove from db & bin, add the lsa to MaxAge bin.
- if (lsWrapper != null) {
- lsWrapper.setLsaAgeReceived(OspfParameters.MAXAGE);
- ospfArea.addLsaToMaxAgeBin(((OspfAreaImpl) ospfArea).getLsaKey(((LsaWrapperImpl)
- lsWrapper).lsaHeader()), lsWrapper);
- ospfArea.removeLsaFromBin(lsWrapper);
- } else {
- ((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(recLsa);
- }
-
- return true;
- } else {
- ospfArea.addLsa(recLsa, ospfInterface);
- log.debug("Inside addLsaMethod");
- topologyForDeviceAndLink.addLocalDevice(recLsa, ospfInterface, ospfArea);
- callDeviceAndLinkAdding(topologyForDeviceAndLink);
- log.debug("Adding to lsdb interface State {}", ((OspfInterfaceImpl) ospfInterface).state().value());
- // should not send any acknowledge if flooded out on receiving interface
- if (((OspfInterfaceImpl) ospfInterface).state().value() == OspfInterfaceState.BDR.value()) {
- if (neighborDr.equals(sourceIp)) {
- log.debug("Adding for delayed ack {}", recLsa);
- ((OspfInterfaceImpl) ospfInterface).addLsaHeaderForDelayAck(recLsa);
- }
- } else {
- log.debug("Adding for delayed ack {}", recLsa);
- ((OspfInterfaceImpl) ospfInterface).addLsaHeaderForDelayAck(recLsa);
- }
-
- if (((OspfInterfaceImpl) ospfInterface).state().value() == OspfInterfaceState.DR.value() ||
- ((OspfInterfaceImpl) ospfInterface).state().value() ==
- OspfInterfaceState.POINT2POINT.value()) {
- ((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(recLsa);
- }
- }
-
- }
- }
- // RFC 2328 Section 13 (6)
- if (lsReqList.containsValue(key)) {
- badLSReq(ch);
- }
- if (status.equals("same")) { //13 (7)
- if (pendingReTxList.containsKey(key)) {
- pendingReTxList.remove(key);
- if (((OspfInterfaceImpl) ospfInterface).state().value() == OspfInterfaceState.BDR.value()) {
- if (neighborDr.equals(recLsa.advertisingRouter())) {
- ((OspfInterfaceImpl) ospfInterface).addLsaHeaderForDelayAck(recLsa);
- }
- }
- } else {
- directAcknowledge(recLsa, ch, sourceIp);
- return true;
- }
- } else if (status.equals("old")) { // section 13 - point 8
- if ((recLsa.lsSequenceNo() == OspfParameters.MAXSEQUENCENUMBER) &&
- (recLsa.age() == OspfParameters.MAXAGE)) {
- // section 13 - point 8
- // simple discard the received LSA -
- return true;
- } else {
- // respond back with the same LSA
- //Using flood LSA to sent the LSUpdate back to advertising router
- int diff = Math.abs(lsWrapper.lsaAgeReceived() - recLsa.age());
- if (diff > OspfParameters.MINLSARRIVAL) {
- sendLsa(((LsaWrapperImpl) lsWrapper).lsaHeader(), sourceIp, ch);
- }
- }
- }
-
- constructDeviceInformationFromDb();
- callDeviceAndLinkAdding(topologyForDeviceAndLink);
-
- return true;
- }
-
- /**
- * Constructs device and link information from link state database.
- */
- private void constructDeviceInformationFromDb() {
- OspfLsdb database = ospfArea.database();
- List lsas = database.getAllLsaHeaders(true, true);
- Iterator iterator = lsas.iterator();
- while (iterator.hasNext()) {
- OspfLsa ospfLsa = (OspfLsa) iterator.next();
- if (ospfLsa.getOspfLsaType().value() == OspfLsaType.ROUTER.value()) {
- topologyForDeviceAndLink.addLocalDevice(ospfLsa, ospfInterface, ospfArea);
- } else if (ospfLsa.getOspfLsaType().value() == OspfLsaType.NETWORK.value()) {
- topologyForDeviceAndLink.addLocalDevice(ospfLsa, ospfInterface, ospfArea);
- }
- }
- }
-
- /**
- * Checks Link State ID is equal to one of the router's own IP interface addresses.
- *
- * @param linkStateId link state id
- * @return true if link state matches or false
- */
- private boolean isLinkStateMatchesOwnRouterId(String linkStateId) {
- boolean isLinkStateMatches = false;
- List<OspfInterface> interfaceLst = ospfArea.ospfInterfaceList();
- for (OspfInterface ospfInterface : interfaceLst) {
- if (ospfInterface.ipAddress().toString().equals(linkStateId)) {
- isLinkStateMatches = true;
- break;
- }
- }
-
- return isLinkStateMatches;
- }
-
- /**
- * RFC 2328 Section 13 (5).
- *
- * @param lsWrapper ls wrapper instance
- * @param recLsa received LSA instance
- * @return returns a string status
- */
- public String isNullorLatest(LsaWrapper lsWrapper, LsaHeader recLsa) {
-
-
- if (lsWrapper != null) {
- LsaHeader ownLsa = (LsaHeader) lsWrapper.ospfLsa();
- String status = ospfArea.isNewerOrSameLsa(recLsa, ownLsa);
-
- if (status.equals("latest")) {
- return "isNullorLatest";
- } else {
- return status;
- }
- } else {
- return "isNullorLatest";
- }
- }
-
- /**
- * RFC 2328 section 13.4
- * Processing self-originated LSAs.
- */
- public void processSelfOriginatedLsa() {
- ospfArea.refreshArea(ospfInterface);
- }
-
- /**
- * Sends the LSA to destination address.
- *
- * @param lsa LSA instance to sent
- * @param destination destination IP address
- * @param ch netty channel instance
- */
- public void sendLsa(LsaHeader lsa, Ip4Address destination, Channel ch) {
- if (lsa == null) {
- return;
- }
-
- LsUpdate responseLsUpdate = new LsUpdate();
- // seting OSPF Header
- responseLsUpdate.setOspfVer(OspfUtil.OSPF_VERSION);
- responseLsUpdate.setOspftype(OspfPacketType.LSUPDATE.value());
- responseLsUpdate.setRouterId(ospfArea.routerId());
- responseLsUpdate.setAreaId(ospfArea.areaId());
- responseLsUpdate.setAuthType(OspfUtil.NOT_ASSIGNED);
- responseLsUpdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
- responseLsUpdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
- responseLsUpdate.setChecksum(OspfUtil.NOT_ASSIGNED);
- responseLsUpdate.setNumberOfLsa(1);
- responseLsUpdate.addLsa(lsa);
-
- //setting the destination.
- responseLsUpdate.setDestinationIp(destination);
- byte[] messageToWrite = getMessage(responseLsUpdate);
- ch.write(messageToWrite);
- }
-
- /**
- * Sends a direct Acknowledgment for a particular LSA to the Neighbor.
- *
- * @param ackLsa LSA instance
- * @param ch netty channel instance
- * @param sourceIp source IP address
- */
- public void directAcknowledge(LsaHeader ackLsa, Channel ch, Ip4Address sourceIp) {
- log.debug("OSPFNbr::directAcknowledge...!!!");
-
- LsAcknowledge ackContent = new LsAcknowledge();
- // seting OSPF Header
- ackContent.setOspfVer(OspfUtil.OSPF_VERSION);
- ackContent.setOspftype(OspfPacketType.LSAACK.value());
- ackContent.setRouterId(ospfArea.routerId());
- ackContent.setAreaId(ospfArea.areaId());
- ackContent.setAuthType(OspfUtil.NOT_ASSIGNED);
- ackContent.setAuthentication(OspfUtil.NOT_ASSIGNED);
- ackContent.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
- ackContent.setChecksum(OspfUtil.NOT_ASSIGNED);
- ackContent.addLinkStateHeader(ackLsa);
- //setting the destination IP
- ackContent.setDestinationIp(sourceIp);
- byte[] messageToWrite = getMessage(ackContent);
- ch.write(messageToWrite);
- }
-
- /**
- * Called when neighbor is down.
- */
- public void neighborDown() {
- log.debug("Neighbor Down {} and NeighborId {}", neighborIpAddr,
- neighborId);
- stopInactivityTimeCheck();
- stopRxMtDdTimer();
- stopRxMtLsrTimer();
-
- if (floodingTimerScheduled) {
- stopFloodingTimer();
- floodingTimerScheduled = false;
- }
-
- state = OspfNeighborState.DOWN;
- ospfArea.refreshArea(ospfInterface);
- lsReqList.clear();
- ddSummaryList.clear();
- if (neighborIpAddr.equals(neighborBdr) ||
- neighborIpAddr.equals(neighborDr)) {
- ((OspfInterfaceImpl) ospfInterface).neighborChange();
- }
- log.debug("Neighbor Went Down : "
- + this.neighborIpAddr + " , " + this.neighborId);
- removeDeviceDetails(this.neighborId);
- OspfRouter ospfRouter = new OspfRouterImpl();
- ospfRouter.setRouterIp(this.neighborId());
- ospfRouter.setInterfaceId(ospfInterface.ipAddress());
- ospfRouter.setAreaIdOfInterface(ospfArea.areaId());
- ospfRouter.setDeviceTed(new OspfDeviceTedImpl());
- ((OspfInterfaceImpl) ospfInterface).removeDeviceInformation(ospfRouter);
- removeDeviceDetails(this.neighborIpAddr);
- OspfRouter ospfRouter1 = new OspfRouterImpl();
- ospfRouter1.setRouterIp(this.neighborIpAddr);
- ospfRouter1.setInterfaceId(ospfInterface.ipAddress());
- ospfRouter1.setAreaIdOfInterface(ospfArea.areaId());
- ospfRouter1.setDeviceTed(new OspfDeviceTedImpl());
- ((OspfInterfaceImpl) ospfInterface).removeDeviceInformation(ospfRouter1);
- }
-
- /**
- * Removes device details.
- *
- * @param routerId router id
- */
- private void removeDeviceDetails(Ip4Address routerId) {
- String key = "device:" + routerId;
- topologyForDeviceAndLink.removeDeviceInformationMap(key);
- }
-
- /**
- * Starts the inactivity timer.
- */
- @Override
- public void startInactivityTimeCheck() {
- if (!inActivityTimerScheduled) {
- log.debug("OSPFNbr::startInactivityTimeCheck");
- inActivityTimeCheckTask = new InternalInactivityTimeCheck();
- exServiceInActivity = Executors.newSingleThreadScheduledExecutor();
- exServiceInActivity.scheduleAtFixedRate(inActivityTimeCheckTask, routerDeadInterval,
- routerDeadInterval, TimeUnit.SECONDS);
- inActivityTimerScheduled = true;
- }
- }
-
- /**
- * Stops the inactivity timer.
- */
- @Override
- public void stopInactivityTimeCheck() {
- if (inActivityTimerScheduled) {
- log.debug("OSPFNbr::stopInactivityTimeCheck ");
- exServiceInActivity.shutdown();
- inActivityTimerScheduled = false;
- }
- }
-
- /**
- * Starts the flooding timer.
- *
- * @param channel channel instance
- */
- public void startFloodingTimer(Channel channel) {
-
- if (!floodingTimerScheduled) {
- log.debug("OSPFNbr::startFloodingTimer");
- floodingTask = new InternalFloodingTask(channel);
- exServiceFlooding = Executors.newSingleThreadScheduledExecutor();
- //Run every 5 seconds.
- exServiceFlooding.scheduleAtFixedRate(floodingTask, OspfParameters.START_NOW,
- OspfParameters.MINLSINTERVAL, TimeUnit.SECONDS);
- floodingTimerScheduled = true;
- }
- }
-
- /**
- * Stops the flooding timer.
- */
- @Override
- public void stopFloodingTimer() {
- if (floodingTimerScheduled) {
- log.debug("OSPFNbr::stopFloodingTimer ");
- exServiceFlooding.shutdown();
- floodingTimerScheduled = false;
- }
- }
-
- /**
- * Starts the Dd Retransmission executor task.
- *
- * @param ch netty channel instance
- */
- private void startRxMtDdTimer(Channel ch) {
- if (!rxmtDdPacketTimerScheduled) {
- long retransmitInterval = ospfInterface.reTransmitInterval();
- rxmtDdPacketTask = new InternalRxmtDdPacket(ch);
- exServiceRxmtDDPacket = Executors.newSingleThreadScheduledExecutor();
- exServiceRxmtDDPacket.scheduleAtFixedRate(rxmtDdPacketTask, retransmitInterval,
- retransmitInterval, TimeUnit.SECONDS);
- rxmtDdPacketTimerScheduled = true;
- }
- }
-
- /**
- * Stops the Dd Retransmission executor task.
- */
- @Override
- public void stopRxMtDdTimer() {
- if (rxmtDdPacketTimerScheduled) {
- exServiceRxmtDDPacket.shutdown();
- rxmtDdPacketTimerScheduled = false;
- }
- }
-
- /**
- * Starts Ls request retransmission executor task.
- *
- * @param ch Netty channel instance
- */
- private void startRxMtLsrTimer(Channel ch) {
- if (!rxmtLsrTimerScheduled) {
- log.debug("OSPFNbr::startRxMtLsrTimer...!!!");
- long retransmitIntrvl = ospfInterface.reTransmitInterval();
- rxmtLsrPacketTask = new InternalRxmtLsrPacket(ch);
- exServiceRxmtLsr = Executors.newSingleThreadScheduledExecutor();
- exServiceRxmtLsr.scheduleAtFixedRate(rxmtLsrPacketTask, retransmitIntrvl,
- retransmitIntrvl, TimeUnit.SECONDS);
- rxmtLsrTimerScheduled = true;
- }
- }
-
- /**
- * Stops Ls request retransmission executor task.
- */
- @Override
- public void stopRxMtLsrTimer() {
- if (rxmtLsrTimerScheduled) {
- exServiceRxmtLsr.shutdown();
- rxmtLsrTimerScheduled = false;
- }
- }
-
- /**
- * Gets the last sent DdPacket.
- *
- * @return DdPacket instance
- */
- public DdPacket lastDdPacket() {
- return lastDdPacket;
- }
-
- /**
- * Sets the last sent DdPacket.
- *
- * @param lastDdPacket DdPacket instance
- */
- public void setLastDdPacket(DdPacket lastDdPacket) {
- this.lastDdPacket = lastDdPacket;
- }
-
- /**
- * Gets neighbor id.
- *
- * @return neighbor id
- */
- @Override
- public Ip4Address neighborId() {
- return neighborId;
- }
-
- /**
- * Sets the neighbor id.
- *
- * @param neighborId neighbor id
- */
- @Override
- public void setNeighborId(Ip4Address neighborId) {
- this.neighborId = neighborId;
- }
-
- /**
- * Gets the neighbor DR address.
- *
- * @return neighbor DR address
- */
- @Override
- public Ip4Address neighborDr() {
- return neighborDr;
- }
-
- /**
- * Sets the neighbor DR address.
- *
- * @param neighborDr neighbor DR address
- */
- @Override
- public void setNeighborDr(Ip4Address neighborDr) {
- this.neighborDr = neighborDr;
- }
-
- /**
- * Gets the neighbor BDR address.
- *
- * @return neighbor BDR address
- */
- @Override
- public Ip4Address neighborBdr() {
- return neighborBdr;
- }
-
- /**
- * Sets the neighbor BDR address.
- *
- * @param neighborBdr neighbor BDR address
- */
- @Override
- public void setNeighborBdr(Ip4Address neighborBdr) {
- this.neighborBdr = neighborBdr;
- }
-
- /**
- * Gets router priority.
- *
- * @return router priority
- */
- @Override
- public int routerPriority() {
- return routerPriority;
- }
-
- /**
- * Sets router priority.
- *
- * @param routerPriority router priority
- */
- @Override
- public void setRouterPriority(int routerPriority) {
- this.routerPriority = routerPriority;
- }
-
- /**
- * Gets the options value.
- *
- * @return options value
- */
- @Override
- public int options() {
- return options;
- }
-
- /**
- * Sets the options value.
- *
- * @param options options value
- */
- @Override
- public void setOptions(int options) {
- this.options = options;
- }
-
- /**
- * Gets the DD sequence number.
- *
- * @return DD sequence number
- */
- @Override
- public long ddSeqNum() {
- return ddSeqNum;
- }
-
- /**
- * Sets the DD sequence number.
- *
- * @param ddSeqNum DD sequence number
- */
- @Override
- public void setDdSeqNum(long ddSeqNum) {
- this.ddSeqNum = ddSeqNum;
- }
-
- /**
- * Gets neighbor is master or not.
- *
- * @return true if neighbor is master else false
- */
- @Override
- public int isMaster() {
- return isMaster;
- }
-
- /**
- * Gets the last sent DD Packet.
- *
- * @return last sent DD Packet
- */
- public DdPacket lastSentDdPacket() {
- return lastSentDdPacket;
- }
-
- /**
- * Sets the last sent DD Packet.
- *
- * @param lastSentDdPacket last sent DD Packet
- */
- public void setLastSentDdPacket(DdPacket lastSentDdPacket) {
- this.lastSentDdPacket = lastSentDdPacket;
- }
-
- /**
- * Gets the last sent Ls Request Packet.
- *
- * @return last sent Ls Request Packet
- */
- public LsRequest getLastSentLsrPacket() {
- return lastSentLsrPacket;
- }
-
- /**
- * Sets the last sent Ls Request Packet.
- *
- * @param lastSentLsrPacket last sent Ls Request Packet
- */
- public void setLastSentLsrPacket(LsRequest lastSentLsrPacket) {
- this.lastSentLsrPacket = lastSentLsrPacket;
- }
-
- /**
- * Gets the neighbors state.
- *
- * @return neighbors state
- */
- @Override
- public OspfNeighborState getState() {
- return state;
- }
-
- /**
- * Sets the neighbors state.
- *
- * @param state neighbors state
- */
- public void setState(OspfNeighborState state) {
- this.state = state;
- }
-
- /**
- * Sets neighbor is master or not.
- *
- * @param isMaster neighbor is master or not
- */
- @Override
- public void setIsMaster(int isMaster) {
- this.isMaster = isMaster;
- }
-
- /**
- * Gets the ls request list.
- *
- * @return ls request list
- */
- @Override
- public Hashtable getLsReqList() {
- return lsReqList;
- }
-
- /**
- * Gets the reTxList instance.
- *
- * @return reTxList instance
- */
- @Override
- public Map getReTxList() {
- return reTxList;
- }
-
- /**
- * Gets the pending re transmit list.
- *
- * @return pendingReTxList instance
- */
- @Override
- public Map<String, OspfLsa> getPendingReTxList() {
- return pendingReTxList;
- }
-
- /**
- * Gets message as bytes.
- *
- * @param ospfMessage OSPF message
- * @return OSPF message
- */
- private byte[] getMessage(OspfMessage ospfMessage) {
- OspfMessageWriter messageWriter = new OspfMessageWriter();
- if (((OspfInterfaceImpl) ospfInterface).state().equals(OspfInterfaceState.POINT2POINT)) {
- ospfMessage.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
- }
- return (messageWriter.getMessage(ospfMessage, ospfInterface.interfaceIndex(),
- ((OspfInterfaceImpl) ospfInterface).state().value()));
- }
-
-
- /**
- * Represents a Task which will do an inactivity time check.
- */
- private class InternalInactivityTimeCheck implements Runnable {
- /**
- * Constructor.
- */
- InternalInactivityTimeCheck() {
- }
-
- @Override
- public void run() {
- try {
- log.debug("Neighbor Not Heard till the past router dead interval .");
- neighborDown();
- } catch (Exception e) {
- log.debug("Exception at inactivity time check...!!!");
- }
- }
- }
-
- /**
- * Task which re transmits DdPacket every configured time interval.
- */
- private class InternalRxmtDdPacket implements Runnable {
- Channel ch;
-
- /**
- * Creates an instance or Re transmit DD packet timer.
- *
- * @param ch netty channel instance
- */
- InternalRxmtDdPacket(Channel ch) {
- this.ch = ch;
- }
-
- @Override
- public void run() {
- if ((ch != null) && ch.isConnected()) {
- DdPacket ddPacket = lastSentDdPacket();
- byte[] messageToWrite = getMessage(ddPacket);
- ch.write(messageToWrite);
- log.debug("Re-Transmit DD Packet .");
- } else {
- log.debug(
- "Re-Transmit DD Packet failed. Channel not connected..");
- }
- }
- }
-
- /**
- * Task which re transmits Ls request Packet every configured time interval.
- */
- private class InternalRxmtLsrPacket implements Runnable {
- Channel ch;
-
- /**
- * Creates an instance or Re transmit LS Request packet timer.
- *
- * @param ch netty channel instance
- */
- InternalRxmtLsrPacket(Channel ch) {
- this.ch = ch;
- }
-
- @Override
- public void run() {
- if ((ch != null) && ch.isConnected()) {
- LsRequest lsrPacket = getLastSentLsrPacket();
- byte[] messageToWrite = getMessage(lsrPacket);
- ch.write(messageToWrite);
- log.debug("Re-Transmit LSRequest Packet .");
- } else {
- log.debug(
- "Re-Transmit LSRequest failed. Channel not connected..");
- }
- }
- }
-
- /**
- * Task which transmits Ls update Packet based on the re transmit list.
- * every configured time interval.
- */
- private class InternalFloodingTask implements Runnable {
- Channel channel;
-
- /**
- * Creates an instance or Flooding task.
- *
- * @param ch netty channel instance
- */
- InternalFloodingTask(Channel ch) {
- this.channel = ch;
- }
-
- @Override
- public void run() {
- if ((channel != null) && channel.isConnected()) {
-
- if ((pendingReTxList != null) && (pendingReTxList.size() > 0)) {
- List<LsUpdate> lsUpdateList = buildLsUpdate(pendingReTxList);
-
- for (LsUpdate lsupdate : lsUpdateList) {
- //Pending for acknowledge directly sent it to neighbor
- lsupdate.setDestinationIp(neighborIpAddr);
- byte[] messageToWrite = getMessage(lsupdate);
- channel.write(messageToWrite);
- }
- }
-
- if ((reTxList != null) && (reTxList.size() > 0)) {
- List<LsUpdate> lsUpdateList = buildLsUpdate(reTxList);
-
- for (LsUpdate lsupdate : lsUpdateList) {
- //set the destination
- if ((((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DR) ||
- (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.POINT2POINT)) {
- lsupdate.setDestinationIp(OspfUtil.ALL_SPF_ROUTERS);
- } else if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DROTHER ||
- (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.BDR)) {
- lsupdate.setDestinationIp(neighborDr);
- }
- byte[] messageToWrite = getMessage(lsupdate);
- channel.write(messageToWrite);
- }
- }
- }
- }
-
- /**
- * Builds the LsUpdate for flooding.
- *
- * @param txList list contains LSAs
- * @return list of LsUpdate instances
- */
- private List buildLsUpdate(Map<String, OspfLsa> txList) {
- List<LsUpdate> lsUpdateList = new ArrayList<>();
- ListIterator itr = new ArrayList(txList.keySet()).listIterator();
- while (itr.hasNext()) {
- LsUpdate lsupdate = new LsUpdate();
- // seting OSPF Header
- lsupdate.setOspfVer(OspfUtil.OSPF_VERSION);
- lsupdate.setOspftype(OspfPacketType.LSUPDATE.value());
- lsupdate.setRouterId(ospfArea.routerId());
- lsupdate.setAreaId(ospfArea.areaId());
- lsupdate.setAuthType(OspfUtil.NOT_ASSIGNED);
- lsupdate.setAuthentication(OspfUtil.NOT_ASSIGNED);
- lsupdate.setOspfPacLength(OspfUtil.NOT_ASSIGNED); // to calculate packet length
- lsupdate.setChecksum(OspfUtil.NOT_ASSIGNED);
-
- //limit to mtu
- int currentLength = OspfUtil.OSPF_HEADER_LENGTH + OspfUtil.FOUR_BYTES;
- int maxSize = ospfInterface.mtu() -
- OspfUtil.LSA_HEADER_LENGTH; // subtract a normal IP header.
-
- int noLsa = 0;
- while (itr.hasNext()) {
-
- String key = (String) itr.next();
- OspfLsa lsa = txList.get(key);
- if (lsa != null) {
- if ((lsa.age() + OspfParameters.INFTRA_NS_DELAY) >= OspfParameters.MAXAGE) {
- ((LsaHeader) lsa.lsaHeader()).setAge(OspfParameters.MAXAGE);
- } else {
- ((LsaHeader) lsa.lsaHeader()).setAge(lsa.age() + OspfParameters.INFTRA_NS_DELAY);
- }
-
- if ((currentLength + ((LsaHeader) lsa.lsaHeader()).lsPacketLen()) >= maxSize) {
- itr.previous();
- break;
- }
- log.debug("FloodingTimer::LSA Type::{}, Header: {}, LSA: {}", lsa.getOspfLsaType(),
- lsa.lsaHeader(), lsa);
- lsupdate.addLsa(lsa);
- noLsa++;
- currentLength = currentLength + ((LsaHeader) lsa.lsaHeader()).lsPacketLen();
- }
- log.debug("FloodingTimer::Removing key {}", key);
- if (txList.equals(reTxList)) {
- reTxList.remove(key);
- pendingReTxList.put(key, lsa);
- }
- }
- //set number of lsa's
- lsupdate.setNumberOfLsa(noLsa);
- lsUpdateList.add(lsupdate);
- }
- return lsUpdateList;
- }
- }
-}
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfPipelineFactory.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfPipelineFactory.java
deleted file mode 100644
index f98f54c..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfPipelineFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.Channels;
-
-/**
- * Creates a ChannelPipeline for a client-side OSPF channel.
- */
-public class OspfPipelineFactory implements ChannelPipelineFactory {
- private OspfInterfaceChannelHandler ospfChannelHandler;
-
- /**
- * Creates an instance of OSPF channel pipeline factory.
- *
- * @param ospfChannelHandler OSPF channel handler instance
- */
- public OspfPipelineFactory(OspfInterfaceChannelHandler ospfChannelHandler) {
- this.ospfChannelHandler = ospfChannelHandler;
- }
-
- @Override
- public ChannelPipeline getPipeline() {
- ChannelPipeline pipeline = Channels.pipeline();
- pipeline.addLast("encoder", new OspfMessageDecoder());
- pipeline.addLast("decoder", new OspfMessageEncoder());
- pipeline.addLast("handler", ospfChannelHandler);
-
- return pipeline;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfRouterImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfRouterImpl.java
deleted file mode 100644
index 5cfb028..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfRouterImpl.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ospf.controller.impl;
-
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfDeviceTed;
-import org.onosproject.ospf.controller.OspfRouter;
-
-/**
- * Representation of an OSPF Router.
- */
-public class OspfRouterImpl implements OspfRouter {
-
- private Ip4Address routerIp;
- private Ip4Address areaIdOfInterface;
- private Ip4Address neighborRouterId;
- private Ip4Address interfaceId;
- private OspfDeviceTed deviceTed;
- private boolean isOpaque;
- private boolean isDr;
-
- /**
- * Gets IP address of the Router.
- *
- * @return IP address router
- */
- public Ip4Address routerIp() {
- return routerIp;
- }
-
- /**
- * Sets IP address of the Router.
- *
- * @param routerIp IP address of the router
- */
- public void setRouterIp(Ip4Address routerIp) {
- this.routerIp = routerIp;
- }
-
- /**
- * Gets the area id of this device.
- *
- * @return the area id od this device
- */
- public Ip4Address areaIdOfInterface() {
- return areaIdOfInterface;
- }
-
- /**
- * Sets the area id for this device.
- *
- * @param areaIdOfInterface area identifier for the device
- */
- public void setAreaIdOfInterface(Ip4Address areaIdOfInterface) {
- this.areaIdOfInterface = areaIdOfInterface;
- }
-
- /**
- * Gets IP address of the interface.
- *
- * @return IP address of the interface
- */
- public Ip4Address interfaceId() {
- return interfaceId;
- }
-
- /**
- * Gets IP address of the interface.
- *
- * @param interfaceId IP address of the interface
- */
- public void setInterfaceId(Ip4Address interfaceId) {
- this.interfaceId = interfaceId;
- }
-
- /**
- * Gets List of the device ted.
- *
- * @return List of the device ted.
- */
- public OspfDeviceTed deviceTed() {
- return deviceTed;
- }
-
- /**
- * Sets List of the device TED.
- *
- * @param deviceTed of the device TED.
- */
- public void setDeviceTed(OspfDeviceTed deviceTed) {
- this.deviceTed = deviceTed;
- }
-
- /**
- * Gets boolean value.
- *
- * @return boolean value.
- */
- public boolean isOpaque() {
- return isOpaque;
- }
-
- /**
- * Sets boolean value.
- *
- * @param opaque true if opaque else false
- */
- public void setOpaque(boolean opaque) {
- isOpaque = opaque;
- }
-
- /**
- * Gets neighbor's Router id.
- *
- * @return neighbor's Router id
- */
- public Ip4Address neighborRouterId() {
- return neighborRouterId;
- }
-
- /**
- * Sets neighbor's Router id.
- *
- * @param advertisingRouterId neighbor's Router id
- */
- public void setNeighborRouterId(Ip4Address advertisingRouterId) {
- this.neighborRouterId = advertisingRouterId;
- }
-
- /**
- * Gets if DR or not.
- *
- * @return true if DR else false
- */
- public boolean isDr() {
- return isDr;
- }
-
- /**
- * Sets dr or not.
- *
- * @param dr true if DR else false
- */
- public void setDr(boolean dr) {
- isDr = dr;
- }
-}
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/TopologyForDeviceAndLinkImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/TopologyForDeviceAndLinkImpl.java
deleted file mode 100644
index 710e6a8..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/TopologyForDeviceAndLinkImpl.java
+++ /dev/null
@@ -1,669 +0,0 @@
-/*
-* Copyright 2016-present Open Networking Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.onosproject.ospf.controller.impl;
-
-import org.onlab.packet.Ip4Address;
-import org.onlab.util.Bandwidth;
-import org.onosproject.ospf.controller.DeviceInformation;
-import org.onosproject.ospf.controller.LinkInformation;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfLinkTed;
-import org.onosproject.ospf.controller.OspfLsa;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.controller.TopologyForDeviceAndLink;
-import org.onosproject.ospf.protocol.lsa.linksubtype.LinkSubType;
-import org.onosproject.ospf.protocol.lsa.linksubtype.LocalInterfaceIpAddress;
-import org.onosproject.ospf.protocol.lsa.linksubtype.MaximumBandwidth;
-import org.onosproject.ospf.protocol.lsa.linksubtype.MaximumReservableBandwidth;
-import org.onosproject.ospf.protocol.lsa.linksubtype.RemoteInterfaceIpAddress;
-import org.onosproject.ospf.protocol.lsa.linksubtype.TrafficEngineeringMetric;
-import org.onosproject.ospf.protocol.lsa.linksubtype.UnreservedBandwidth;
-import org.onosproject.ospf.protocol.lsa.subtypes.OspfLsaLink;
-import org.onosproject.ospf.protocol.lsa.tlvtypes.LinkTlv;
-import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.lsa.types.TopLevelTlv;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * Represents device and link topology information.
- */
-public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink {
-
- private static final Logger log = LoggerFactory.getLogger(TopologyForDeviceAndLinkImpl.class);
- Set<Ip4Address> routerSet = new TreeSet<Ip4Address>();
- Ip4Address firstValue = Ip4Address.valueOf("0.0.0.0");
- private Map<String, DeviceInformation> deviceInformationMap = new LinkedHashMap();
- private Map<Ip4Address, List<Ip4Address>> networkLsaMap = new LinkedHashMap();
- private Map<String, DeviceInformation> deviceInformationMapForPointToPoint = new LinkedHashMap();
- private Map<String, DeviceInformation> deviceInformationMapToDelete = new LinkedHashMap();
- private HashMap<String, Set<OspfLsaLink>> deviceAndLinkInformation = new HashMap();
- private HashMap<String, OspfLinkTed> ospfLinkTedHashMap = new LinkedHashMap();
- private Ip4Address drRouter = Ip4Address.valueOf("0.0.0.0");
- private Ip4Address drRouterOld = Ip4Address.valueOf("0.0.0.0");
- private Ip4Address adRouterId = Ip4Address.valueOf("0.0.0.0");
- private Map<String, LinkInformation> linkInformationMap = new LinkedHashMap();
- private Map<String, LinkInformation> linkInformationMapForPointToPoint = new LinkedHashMap();
- private List<String> toRemove = new ArrayList<>();
-
- /**
- * Gets device information.
- *
- * @return device information
- */
- public Map<String, DeviceInformation> deviceInformationMap() {
- return deviceInformationMap;
- }
-
- /**
- * Sets device information.
- *
- * @param key key used to add in map
- * @param deviceInformationMap device information instance
- */
- public void setDeviceInformationMap(String key, DeviceInformation deviceInformationMap) {
- if (deviceInformationMap != null) {
- this.deviceInformationMap.put(key, deviceInformationMap);
- }
-
- }
-
- /**
- * Gets deviceInformation as map for Point-To-Point.
- *
- * @return deviceInformationMap
- */
- public Map<String, DeviceInformation> deviceInformationMapForPointToPoint() {
- return deviceInformationMapForPointToPoint;
- }
-
- /**
- * Sets deviceInformation as map for Point-To-Point..
- *
- * @param key key to store device information
- * @param deviceInformationMap device information instance
- */
- public void setDeviceInformationMapForPointToPoint(String key, DeviceInformation deviceInformationMap) {
- if (deviceInformationMap != null) {
- this.deviceInformationMapForPointToPoint.put(key, deviceInformationMap);
- }
-
- }
-
- /**
- * Gets deviceInformation as map.
- *
- * @return deviceInformationMap to delete from core
- */
- public Map<String, DeviceInformation> deviceInformationMapToDelete() {
- return deviceInformationMapToDelete;
- }
-
- /**
- * Sets device information for removal.
- *
- * @param key ket used to add in map
- * @param deviceInformationMapToDelete map from device information to remove
- */
- public void setDeviceInformationMapToDelete(String key, DeviceInformation deviceInformationMapToDelete) {
- if (deviceInformationMapToDelete != null) {
- this.deviceInformationMapToDelete.put(key, deviceInformationMapToDelete);
- }
- }
-
- /**
- * Removes Device Information.
- *
- * @param key ket used to remove from map
- */
- public void removeDeviceInformationMapFromDeleteMap(String key) {
- removeDeviceInformationMap(key);
- if (this.deviceInformationMapToDelete.containsKey(key)) {
- this.deviceInformationMapToDelete.remove(key);
- }
- }
-
- /**
- * Gets Device Information.
- *
- * @param key key to store in map
- * @return Device Information
- */
- public DeviceInformation deviceInformation(String key) {
- DeviceInformation deviceInformation = this.deviceInformationMap.get(key);
- return deviceInformation;
- }
-
- /**
- * Removes Device Information from map.
- *
- * @param key key used to remove from map
- */
- public void removeDeviceInformationMap(String key) {
- if (this.deviceInformationMap.containsKey(key)) {
- this.deviceInformationMap.remove(key);
- }
- }
-
- /**
- * Gets link information as map.
- *
- * @return link information as map
- */
- public Map<String, LinkInformation> linkInformationMap() {
- return linkInformationMap;
- }
-
- private LinkInformation getLinkInformation(String key) {
- LinkInformation linkInformation = this.linkInformationMap.get(key);
- return linkInformation;
- }
-
- /**
- * Sets link information in map.
- *
- * @param key key used to add in map
- * @param linkInformationMap link information instance
- */
- public void setLinkInformationMap(String key, LinkInformation linkInformationMap) {
- if (!this.linkInformationMap.containsKey(key)) {
- this.linkInformationMap.put(key, linkInformationMap);
- }
- }
-
- /**
- * Gets linkInformation as map for PointToPoint.
- *
- * @return linkInformationMap
- */
- public Map<String, LinkInformation> linkInformationMapForPointToPoint() {
- return linkInformationMap;
- }
-
- /**
- * Sets linkInformation as map for PointToPoint.
- *
- * @param key key to store link information
- * @param linkInformationMap link information instance
- */
- public void setLinkInformationMapForPointToPoint(String key, LinkInformation linkInformationMap) {
- if (!this.linkInformationMap.containsKey(key)) {
- this.linkInformationMap.put(key, linkInformationMap);
- }
- }
-
- /**
- * Removes Link Information from linkInformationMap.
- *
- * @param key key to remove link information
- */
- public void removeLinkInformationMap(String key) {
- if (this.linkInformationMap.containsKey(key)) {
- this.linkInformationMap.remove(key);
- }
- }
-
-
- /**
- * Gets OSPF Link TED details from the map.
- *
- * @param key key used to retrieve from map
- * @return OSPF link ted instance
- */
- public OspfLinkTed getOspfLinkTedHashMap(String key) {
- OspfLinkTed ospfLinkTed = ospfLinkTedHashMap.get(key);
- return ospfLinkTed;
- }
-
- /**
- * Adds device information to map.
- *
- * @param ospfLsa OSPF LSA instance
- * @param ospfInterface OSPF interface instance
- * @param ospfArea OSPF area instance
- */
- public void addLocalDevice(OspfLsa ospfLsa, OspfInterface ospfInterface, OspfArea ospfArea) {
- if (ospfLsa.getOspfLsaType().equals(OspfLsaType.ROUTER)) {
- createDeviceAndLinkFromRouterLsa(ospfLsa, ospfArea);
- } else if (ospfLsa.getOspfLsaType().equals(OspfLsaType.NETWORK)) {
- createDeviceAndLinkFromNetworkLsa(ospfLsa, ospfArea);
- } else if (ospfLsa.getOspfLsaType().equals(OspfLsaType.AREA_LOCAL_OPAQUE_LSA)) {
- createDeviceAndLinkFromOpaqueLsa(ospfLsa, ospfArea);
- }
- }
-
- /**
- * Creates device object from parameters.
- *
- * @param alreadyCreated device already created or not
- * @param deviceId device id
- * @param neighborId neighbor's id
- * @param routerId router's id
- * @param interfaceId interface id
- * @param areaId area id
- * @param isDr true if router is DR else false
- */
- private DeviceInformation createDeviceInformation(boolean alreadyCreated, Ip4Address deviceId,
- Ip4Address neighborId, Ip4Address routerId,
- Ip4Address interfaceId, Ip4Address areaId,
- boolean isDr) {
- DeviceInformation deviceInformation = new DeviceInformationImpl();
- deviceInformation.setAlreadyCreated(alreadyCreated);
- deviceInformation.setDeviceId(deviceId);
- deviceInformation.setNeighborId(neighborId);
- deviceInformation.setRouterId(routerId);
- deviceInformation.addInterfaceId(interfaceId);
- deviceInformation.setAreaId(areaId);
- deviceInformation.setDr(isDr);
- return deviceInformation;
- }
-
- /**
- * Creates Device and Link instance from the RouterLsa parameters.
- *
- * @param ospfLsa OSPF LSA instance
- * @param ospfArea OSPF area
- */
- private void createDeviceAndLinkFromRouterLsa(OspfLsa ospfLsa, OspfArea ospfArea) {
- RouterLsa routerLsa = (RouterLsa) ospfLsa;
- List<OspfLsaLink> ospfLsaLinkList = routerLsa.routerLink();
- Iterator iterator = ospfLsaLinkList.iterator();
- Ip4Address advertisingRouterId = routerLsa.advertisingRouter();
- while (iterator.hasNext()) {
- OspfLsaLink ospfLsaLink = (OspfLsaLink) iterator.next();
- Ip4Address linkId = Ip4Address.valueOf(ospfLsaLink.linkId());
- Ip4Address linkData = Ip4Address.valueOf(ospfLsaLink.linkData());
- if (ospfLsaLink.linkType() == 1) {
- if ((advertisingRouterId.equals(ospfArea.routerId())) || (linkId.equals(ospfArea.routerId()))) {
- if (!advertisingRouterId.equals(ospfArea.routerId())) {
- DeviceInformation deviceInformationPointToPoint =
- createDeviceInformation(false, linkId, linkId, advertisingRouterId, linkData,
- ospfArea.areaId(), false);
- String key = "device:" + advertisingRouterId;
- setDeviceInformationMapForPointToPoint(key, deviceInformationPointToPoint);
- }
- } else {
- DeviceInformation deviceInformationPointToPoint =
- createDeviceInformation(false, linkId, linkId, advertisingRouterId,
- linkData, ospfArea.areaId(), false);
- String key = "device:" + advertisingRouterId;
- setDeviceInformationMapForPointToPoint(key, deviceInformationPointToPoint);
- String linkIdKey = "linkId:" + advertisingRouterId + "-" + linkId;
- addLocalLinkForPointToPoint(linkIdKey, linkData, advertisingRouterId, linkId, true, false);
- }
- }
- }
- }
-
- /**
- * Creates device and link instance from the network LSA parameters.
- *
- * @param ospfLsa OSPF LSA instance
- * @param ospfArea OSPF area instance
- */
- private void createDeviceAndLinkFromNetworkLsa(OspfLsa ospfLsa, OspfArea ospfArea) {
- NetworkLsa networkLsa = (NetworkLsa) ospfLsa;
- Ip4Address linkStateId = Ip4Address.valueOf(networkLsa.linkStateId());
- Set<Ip4Address> drList = networkLsaMap.keySet();
- try {
- Ip4Address drToReplace = null;
- for (Ip4Address drIp : drList) {
- if (!drIp.equals(linkStateId)) {
- if (OspfUtil.sameNetwork(drIp, linkStateId, networkLsa.networkMask())) {
- drToReplace = drIp;
- String key = "device:" + drToReplace;
- DeviceInformation deleteDr = deviceInformation(key);
- if (deleteDr != null) {
- deleteDr.setAlreadyCreated(true);
- setDeviceInformationMapToDelete(key, deleteDr);
- }
-
- networkLsaMap.remove(drToReplace);
- break;
- }
- }
- }
- networkLsaMap.put(linkStateId, networkLsa.attachedRouters());
-
- } catch (Exception e) {
- log.debug("Error::TopologyForDeviceAndLinkImpl:: {}", e.getMessage());
- }
- constructDeviceForBroadCastTopology(ospfArea);
- disp();
-
- }
-
- private void constructDeviceForBroadCastTopology(OspfArea ospfArea) {
-
- for (Map.Entry<Ip4Address, List<Ip4Address>> entry : networkLsaMap.entrySet()) {
- Ip4Address key = entry.getKey();
- DeviceInformation deviceInformationForDr = createDeviceInformation(false, key, key, key,
- key, ospfArea.areaId(), true);
- String dr = "device:" + key;
- setDeviceInformationMap(dr, deviceInformationForDr);
- List<Ip4Address> value = entry.getValue();
- for (Ip4Address connectedRouter : value) {
- if (!connectedRouter.equals(ospfArea.routerId())) {
- DeviceInformation deviceInformationAttachedRouters =
- createDeviceInformation(false, connectedRouter, key, connectedRouter,
- key, ospfArea.areaId(), false);
- String attachedRouters = "device:" + connectedRouter;
- setDeviceInformationMap(attachedRouters, deviceInformationAttachedRouters);
- String linkIdKey = "linkId:" + key + "-" + connectedRouter;
- addLocalLink(linkIdKey, key, key, connectedRouter, true, false);
- }
- }
- }
-
- }
-
- private void disp() {
- for (String key : deviceInformationMap.keySet()) {
- DeviceInformation deviceInformation = deviceInformationMap.get(key);
- log.debug("************************************************************************");
- log.debug("DeviceInfoList RouterId is : {} and neighbour is {} and linkdata {}",
- deviceInformation.routerId(), deviceInformation.neighborId(), deviceInformation.interfaceId());
- }
-
- for (Map.Entry<String, LinkInformation> entry : linkInformationMap.entrySet()) {
- String linkDetail = entry.getKey();
- log.debug("Link From and to is " + linkDetail);
- }
- log.debug("Devices Needs to delete from Core are : " + deviceInformationMapToDelete.size());
- for (String key : deviceInformationMapToDelete.keySet()) {
- DeviceInformation value = deviceInformationMapToDelete.get(key);
- if (value.isAlreadyCreated()) {
- log.debug("Device is deleted from list " + value.routerId());
- }
- }
- }
-
- private void getLinksToDelete(Set<Ip4Address> list, Ip4Address value, OspfArea ospfArea) {
-
- Iterator iterator = list.iterator();
-
- while (iterator.hasNext()) {
- Ip4Address secondValue = (Ip4Address) iterator.next();
- if (!value.toString().equals("0.0.0.0")) {
- if ((!value.equals(secondValue))) {
- if ((!secondValue.equals(ospfArea.routerId()))) {
- String key = "link:" + value.toString() + "-" + secondValue.toString();
- String key1 = "link:" + secondValue.toString() + "-" + value.toString();
- LinkInformation linkDetails = getLinkInformation(key);
- LinkInformation linkDetailsOther = getLinkInformation(key1);
- linkInformationMapForPointToPoint.put(key, linkDetails);
- linkInformationMapForPointToPoint.put(key1, linkDetailsOther);
- }
- }
- }
-
- }
-
- }
-
- /**
- * Creates Device and Link instance from the OpaqueLsa parameters.
- *
- * @param ospfLsa OSPF LSA instance
- * @param ospfArea OSPF area instance
- */
- private void createDeviceAndLinkFromOpaqueLsa(OspfLsa ospfLsa, OspfArea ospfArea) {
- OspfLinkTed ospfLinkTed = new OspfLinkTedImpl();
- OpaqueLsa10 opaqueLsa10 = (OpaqueLsa10) ospfLsa;
- List<TopLevelTlv> topLevelTlvList = opaqueLsa10.topLevelValues();
- for (TopLevelTlv topLevelTlv : topLevelTlvList) {
- if (topLevelTlv instanceof LinkTlv) {
- LinkTlv linkTlv = (LinkTlv) topLevelTlv;
- List<LinkSubType> subTypes = linkTlv.subTlvList();
- for (LinkSubType type : subTypes) {
- if (type instanceof UnreservedBandwidth) {
- UnreservedBandwidth unreservedBandwidth = (UnreservedBandwidth) type;
- List<Float> bandwidthFloatValues = unreservedBandwidth.getUnReservedBandwidthValue();
- List<Bandwidth> bandwidthList = new ArrayList<>();
- for (Float value : bandwidthFloatValues) {
- Bandwidth bandwidth = Bandwidth.bps((double) value);
- ospfLinkTed.setMaxUnResBandwidth(bandwidth);
- bandwidthList.add(bandwidth);
- }
- }
- if (type instanceof MaximumBandwidth) {
- MaximumBandwidth maximumBandwidth = (MaximumBandwidth) type;
- float maxBandValue = maximumBandwidth.getMaximumBandwidthValue();
- Bandwidth bandwidth = Bandwidth.bps((double) maxBandValue);
- ospfLinkTed.setMaximumLink(bandwidth);
- }
- if (type instanceof MaximumReservableBandwidth) {
- MaximumReservableBandwidth maximumReservableBandwidth = (MaximumReservableBandwidth) type;
- float maxResBandValue = maximumReservableBandwidth.getMaximumBandwidthValue();
- Bandwidth bandwidth = Bandwidth.bps((double) maxResBandValue);
- ospfLinkTed.setMaxReserved(bandwidth);
- }
- if (type instanceof TrafficEngineeringMetric) {
- TrafficEngineeringMetric trafficEngineeringMetric = (TrafficEngineeringMetric) type;
- long teMetric = trafficEngineeringMetric.getTrafficEngineeringMetricValue();
- ospfLinkTed.setTeMetric((Integer) (int) teMetric);
- }
- if (type instanceof LocalInterfaceIpAddress) {
- LocalInterfaceIpAddress localInterfaceIpAddress = (LocalInterfaceIpAddress) type;
- List<String> stringValue = localInterfaceIpAddress.getLocalInterfaceIPAddress();
- List<Ip4Address> localIp4Address = new ArrayList<>();
- for (String value : stringValue) {
- Ip4Address ip4Address = Ip4Address.valueOf(value);
- localIp4Address.add(ip4Address);
- }
- ospfLinkTed.setIpv4LocRouterId(localIp4Address);
- }
- if (type instanceof RemoteInterfaceIpAddress) {
- RemoteInterfaceIpAddress remoteInterfaceIpAddress = (RemoteInterfaceIpAddress) type;
- List<String> stringValue = remoteInterfaceIpAddress.getRemoteInterfaceAddress();
- List<Ip4Address> remoteIp4Address = new ArrayList<>();
- for (String value : stringValue) {
- Ip4Address ip4Address = Ip4Address.valueOf(value);
- remoteIp4Address.add(ip4Address);
- }
- ospfLinkTed.setIpv4RemRouterId(remoteIp4Address);
- }
- }
- }
-
- }
- ospfLinkTedHashMap.put(adRouterId.toString(), ospfLinkTed);
- }
-
-
- /**
- * Adds link information to LinkInformationMap.
- *
- * @param advertisingRouter advertising router
- * @param linkData link data address
- * @param linkSrc link source address
- * @param linkDest link destination address
- * @param opaqueEnabled opaque enabled or not
- * @param linkSrcIdNotRouterId link source id or not
- */
- public void addLocalLink(String advertisingRouter, Ip4Address linkData, Ip4Address linkSrc, Ip4Address linkDest,
- boolean opaqueEnabled, boolean linkSrcIdNotRouterId) {
- String linkKey = "link:";
- LinkInformation linkInformation = new LinkInformationImpl();
- linkInformation.setLinkId(advertisingRouter);
- linkInformation.setLinkSourceId(linkSrc);
- linkInformation.setLinkDestinationId(linkDest);
- linkInformation.setAlreadyCreated(false);
- linkInformation.setLinkSrcIdNotRouterId(linkSrcIdNotRouterId);
- linkInformation.setInterfaceIp(linkData);
- if (linkDest != null) {
- linkInformation.setLinkSrcIdNotRouterId(false);
- }
- linkKey = linkKey + "-" + linkSrc + "-" + linkDest;
- setLinkInformationMap(linkKey, linkInformation);
- }
-
- /**
- * Adds link information to LinkInformationMap for PointToPoint.
- *
- * @param advertisingRouter advertising router
- * @param linkData link data
- * @param linkSrc link source
- * @param linkDest link destination
- * @param opaqueEnabled whether opaque is enabled or not
- * @param linkSrcIdNotRouterId whether link is source id or router id
- */
- public void addLocalLinkForPointToPoint(String advertisingRouter, Ip4Address linkData, Ip4Address linkSrc,
- Ip4Address linkDest, boolean opaqueEnabled, boolean linkSrcIdNotRouterId) {
- String linkKey = "link:";
- LinkInformation linkInformation = new LinkInformationImpl();
- linkInformation.setLinkId(advertisingRouter);
- linkInformation.setLinkSourceId(linkSrc);
- linkInformation.setLinkDestinationId(linkDest);
- linkInformation.setAlreadyCreated(false);
- linkInformation.setLinkSrcIdNotRouterId(linkSrcIdNotRouterId);
- linkInformation.setInterfaceIp(linkData);
- if (linkDest != null) {
- linkInformation.setLinkSrcIdNotRouterId(false);
- }
- linkKey = linkKey + "-" + linkSrc + "-" + linkDest;
- setLinkInformationMapForPointToPoint(linkKey, linkInformation);
- }
-
- /**
- * Removes links from LinkInformationMap.
- *
- * @param routerId router id
- */
- public void removeLinks(Ip4Address routerId) {
- Map<String, LinkInformation> linkInformationMapLocal = linkInformationMap;
- if (linkInformationMapLocal != null) {
- for (Map.Entry<String, LinkInformation> entry : linkInformationMap.entrySet()) {
- String key = entry.getKey();
- boolean check = key.contains(routerId.toString());
- LinkInformation linkInformation = linkInformationMap.get(key);
- boolean check1 = (linkInformation.linkDestinationId() == routerId) ? true : false;
- if (check || check1) {
- toRemove.add(key);
- }
- }
- removeLinkFromMap();
- }
- }
-
- /**
- * Removes Device from DeviceInformationMap.
- *
- * @param routerId router id
- */
- public void removeDevice(Ip4Address routerId) {
- String key = "device:" + routerId;
- this.deviceInformationMap.remove(key);
- }
-
- /**
- * Removes link information from Map.
- */
- private void removeLinkFromMap() {
- Iterator iterator = toRemove.iterator();
- while (iterator.hasNext()) {
- String key = (String) iterator.next();
- removeLinkInformationMap(key);
- }
- }
-
- /**
- * Updates the deviceAndLinkInformation list for received OSPF LSA.
- *
- * @param ospfLsa OSPF LSA instance
- * @param ospfArea OSPF area instance
- */
- public void updateLinkInformation(OspfLsa ospfLsa, OspfArea ospfArea) {
- if (ospfLsa.getOspfLsaType().equals(OspfLsaType.ROUTER)) {
- RouterLsa routerLsa = (RouterLsa) ospfLsa;
- routerLsa.lsType();
- List<OspfLsaLink> ospfLsaLinkList = routerLsa.routerLink();
- for (OspfLsaLink link : ospfLsaLinkList) {
- if (link.linkType() == 1 || link.linkType() == 2) {
- if ((routerLsa.advertisingRouter().equals(ospfArea.routerId())) ||
- (link.linkId().equals(ospfArea.routerId().toString()))) {
- log.debug("OspfInterface information will not display in web ");
- } else {
- String key = routerLsa.advertisingRouter() + "-" + link.linkData();
- Set<OspfLsaLink> linkInformations = new HashSet<>();
- if (deviceAndLinkInformation.containsKey(key)) {
- linkInformations = deviceAndLinkInformation.get(key);
- linkInformations.add(link);
- deviceAndLinkInformation.put(key, linkInformations);
- } else {
- linkInformations.add(link);
- deviceAndLinkInformation.put(key, linkInformations);
- }
- }
- }
- }
- }
- }
-
- /**
- * Gets all the router information which needs to delete from deviceList.
- *
- * @param ospfLsa OSPF LSA instance
- * @param ospfArea OSPF area instance
- * @return list of deleted router information
- */
- public List<String> getDeleteRouterInformation(OspfLsa ospfLsa, OspfArea ospfArea) {
- List<String> removedLinkList = new ArrayList<>();
- if (ospfLsa.getOspfLsaType().equals(OspfLsaType.ROUTER)) {
-
- RouterLsa routerLsa = (RouterLsa) ospfLsa;
- List<OspfLsaLink> ospfLsaLinkList = routerLsa.routerLink();
- for (OspfLsaLink link : ospfLsaLinkList) {
- if (link.linkType() == 1 || link.linkType() == 2) {
- if ((routerLsa.advertisingRouter().equals(ospfArea.routerId())) ||
- (link.linkId().equals(ospfArea.routerId().toString()))) {
- log.debug("OspfInterface information will not display in web ");
- } else {
- String key = routerLsa.advertisingRouter() + "-" + link.linkData();
- Set<OspfLsaLink> linkInformations = deviceAndLinkInformation.get(key);
- if (linkInformations.contains(link)) {
- linkInformations.remove(link);
- deviceAndLinkInformation.put(key, linkInformations);
- }
- }
- }
- Set<String> keys = deviceAndLinkInformation.keySet();
- for (String key : keys) {
- Set<OspfLsaLink> linkInformations = deviceAndLinkInformation.get(key);
- for (OspfLsaLink link1 : linkInformations) {
- String removedLink = link1.linkId();
- removedLinkList.add(removedLink);
- }
- }
- }
- }
- return removedLinkList;
- }
-}
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/package-info.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/package-info.java
deleted file mode 100644
index 9275af0..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the OSPF controller.
- */
-package org.onosproject.ospf.controller.impl;
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaBinImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaBinImpl.java
deleted file mode 100644
index 9ba49a4..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaBinImpl.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.lsdb;
-
-import com.google.common.base.MoreObjects;
-import org.onosproject.ospf.controller.LsaBin;
-import org.onosproject.ospf.controller.LsaWrapper;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Represents a bin, where an LSA is stored for Aging.
- * A bin is identified by a bin number and can have one or more LSAs
- * store in a particular bin location.
- */
-public class LsaBinImpl implements LsaBin {
-
- private int binNumber;
- private Map<String, LsaWrapper> listOfLsa = new ConcurrentHashMap<>();
-
- /**
- * Creates an instance of LSA bin.
- *
- * @param binNumber unique number of this bin
- */
- public LsaBinImpl(int binNumber) {
- this.binNumber = binNumber;
- }
-
- /**
- * Adds the LSA to this bin with the given key.
- *
- * @param lsaKey key of the LSA
- * @param lsaWrapper wrapper instance to store
- */
- public void addOspfLsa(String lsaKey, LsaWrapper lsaWrapper) {
- if (!listOfLsa.containsKey(lsaKey)) {
- listOfLsa.put(lsaKey, lsaWrapper);
- lsaWrapper.setBinNumber(this.binNumber);
- }
- }
-
- /**
- * Gets the LSA from the bin.
- *
- * @param lsaKey key to search the LSA
- * @return LSA Wrapper instance
- */
- public LsaWrapper ospfLsa(String lsaKey) {
-
- return listOfLsa.get(lsaKey);
- }
-
- /**
- * Removes LSA from the bin.
- *
- * @param lsaKey key to search LSA
- * @param lsaWrapper wrapper object to remove
- */
- public void removeOspfLsa(String lsaKey, LsaWrapper lsaWrapper) {
- if (listOfLsa.containsKey(lsaKey)) {
- listOfLsa.remove(lsaKey);
- }
- }
-
- /**
- * Gets the list of LSAs in this bin as key value pair.
- *
- * @return list of LSAs in this bin as key value pair
- */
- public Map<String, LsaWrapper> listOfLsa() {
- return listOfLsa;
- }
-
- /**
- * Gets the bin number.
- *
- * @return the bin number
- */
- public int binNumber() {
- return binNumber;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("binNumber", binNumber)
- .add("listOfLsa", listOfLsa)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaQueueConsumer.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaQueueConsumer.java
deleted file mode 100644
index 94d232c..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaQueueConsumer.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.lsdb;
-
-import org.jboss.netty.channel.Channel;
-import org.onosproject.ospf.controller.LsaWrapper;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.util.ChecksumCalculator;
-import org.onosproject.ospf.protocol.util.OspfInterfaceState;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.BlockingQueue;
-
-/**
- * Consumes LSA from the Queue and processes it.
- * Its a producer consumer implementation using Blocking queue.
- */
-public class LsaQueueConsumer implements Runnable {
- private static final Logger log = LoggerFactory.getLogger(LsaQueueConsumer.class);
- private BlockingQueue queue = null;
- private Channel channel;
- private OspfArea ospfArea;
-
- /**
- * Creates an instance of LSA queue consumer.
- *
- * @param queue queue instance
- * @param channel netty channel instance
- * @param ospfArea OSPF area instance
- */
- public LsaQueueConsumer(BlockingQueue queue, Channel channel, OspfArea ospfArea) {
- this.queue = queue;
- this.channel = channel;
- this.ospfArea = ospfArea;
- }
-
- /**
- * Threads run method.
- */
- public void run() {
- log.debug("LSAQueueConsumer:run...!!!");
- try {
- while (true) {
- if (!queue.isEmpty()) {
- LsaWrapper wrapper = (LsaWrapper) queue.take();
- String lsaProcessing = wrapper.lsaProcessing();
- switch (lsaProcessing) {
- case OspfParameters.VERIFYCHECKSUM:
- log.debug("LSAQueueConsumer: Message - " + OspfParameters.VERIFYCHECKSUM + " consumed.");
- processVerifyChecksum(wrapper);
- break;
- case OspfParameters.REFRESHLSA:
- log.debug("LSAQueueConsumer: Message - " + OspfParameters.REFRESHLSA + " consumed.");
- processRefreshLsa(wrapper);
- break;
- case OspfParameters.MAXAGELSA:
- log.debug("LSAQueueConsumer: Message - " + OspfParameters.MAXAGELSA + " consumed.");
- processMaxAgeLsa(wrapper);
- break;
- default:
- log.debug("Unknown command to process the LSA in queue ...!!!");
- break;
- }
- }
- }
-
- } catch (Exception e) {
- log.debug("Error::LSAQueueConsumer::{}", e.getMessage());
- }
- }
-
- /**
- * Processes verify checksum - checkAges.
- *
- * @param wrapper LSA wrapper instance
- */
- private void processVerifyChecksum(LsaWrapper wrapper) throws OspfParseException {
- ChecksumCalculator checkSum = new ChecksumCalculator();
- if (!checkSum.isValidLsaCheckSum(wrapper.ospfLsa(), ((LsaWrapperImpl) wrapper).lsaHeader().lsType(),
- OspfUtil.LSAPACKET_CHECKSUM_POS1,
- OspfUtil.LSAPACKET_CHECKSUM_POS2)) {
- log.debug("LSAQueueConsumer::Checksum mismatch. Received LSA packet type {} ",
- ((LsaWrapperImpl) wrapper).lsaHeader().lsType());
-
- //Checksum Invalid
- //RFC 2328 Restart the Router.
- //Currently we are not restarting. We are not handling this case.
- }
- }
-
- /**
- * Process refresh LSA.
- *
- * @param wrapper LSA wrapper instance
- */
- private void processRefreshLsa(LsaWrapper wrapper) throws OspfParseException {
- if (wrapper.isSelfOriginated()) { //self originated
- //set the destination
- OspfInterface ospfInterface = wrapper.ospfInterface();
- if (ospfInterface != null) {
- LsaHeader header = ((LsaWrapperImpl) wrapper).lsaHeader();
- header.setAge(wrapper.currentAge());
- if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DR) {
- if (header.lsType() == OspfLsaType.ROUTER.value()) {
- RouterLsa routerLsa = ((OspfAreaImpl) ospfArea).buildRouterLsa(ospfInterface);
- ((OspfAreaImpl) ospfArea).addLsa(routerLsa, true, ospfInterface);
- ((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(routerLsa);
- } else if (header.lsType() == OspfLsaType.NETWORK.value()) {
- if (ospfInterface.listOfNeighbors().size() > 0) {
- NetworkLsa networkLsa = ((OspfAreaImpl) ospfArea).buildNetworkLsa(
- ospfInterface.ipAddress(), ospfInterface.ipNetworkMask());
- ospfArea.addLsa(networkLsa, true, ospfInterface);
- ((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(networkLsa);
- }
- }
- }
-
- if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.BDR ||
- ((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.POINT2POINT ||
- ((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DROTHER) {
- ospfArea.refreshArea(ospfInterface);
- }
- log.debug("LSAQueueConsumer: processRefreshLsa - Flooded SelfOriginated LSA {}",
- ((LsaWrapperImpl) wrapper).lsaHeader());
- }
- }
- }
-
- /**
- * Process max age LSA.
- *
- * @param wrapper LSA wrapper instance
- */
- private void processMaxAgeLsa(LsaWrapper wrapper) {
- //set the destination
- OspfInterface ospfInterface = wrapper.ospfInterface();
- if (ospfInterface != null) {
- LsaHeader header = (LsaHeader) wrapper.ospfLsa().lsaHeader();
- header.setAge(OspfParameters.MAXAGE);
- ((LsaWrapperImpl) wrapper).lsaHeader().setAge(OspfParameters.MAXAGE);
- if (((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.DR ||
- ((OspfInterfaceImpl) ospfInterface).state() == OspfInterfaceState.POINT2POINT) {
- //remove from db
- ((OspfAreaImpl) ospfArea).addToOtherNeighborLsaTxList(((LsaWrapperImpl) wrapper).lsaHeader());
- ((OspfAreaImpl) ospfArea).deleteLsa(((LsaWrapperImpl) wrapper).lsaHeader());
- } else {
- ((OspfAreaImpl) ospfArea).deleteLsa(((LsaWrapperImpl) wrapper).lsaHeader());
- }
- log.debug("LSAQueueConsumer: processMaxAgeLsa - Flooded SelfOriginated-Max Age LSA {}",
- ((LsaWrapperImpl) wrapper).lsaHeader());
- }
- }
-
- /**
- * Sets the channel.
- *
- * @param channel channel instance
- */
- public void setChannel(Channel channel) {
- this.channel = channel;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImpl.java
deleted file mode 100644
index 9d747ad..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImpl.java
+++ /dev/null
@@ -1,463 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.lsdb;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import org.onosproject.ospf.controller.LsaWrapper;
-import org.onosproject.ospf.controller.LsdbAge;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfLsa;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Wrapper object to store LSA and associated metadata information.
- */
-public class LsaWrapperImpl implements LsaWrapper {
- private static final Logger log = LoggerFactory.getLogger(LsaWrapperImpl.class);
- private LsaHeader lsaHeader;
- private int lsaAgeReceived;
- private int ageCounterWhenReceived;
- private boolean isSelfOriginated;
- private OspfLsaType lsaType;
- private OspfLsa ospfLsa;
- private int noReTransmissionLists;
- private boolean inAnAgeBin;
- private boolean changedSinceLastFlood;
- private boolean isSequenceRollOver;
- private boolean sentReplyForOlderLsa;
- private boolean checkAge; // Queued for check sum verification
- private boolean isAging;
- private String lsaProcessing; //for LSAQueueConsumer processing
- private int binNumber = -1;
- private OspfInterface ospfInterface;
- private LsdbAge lsdbAge;
- private int ageCounterRollOverWhenAdded;
-
- public int getAgeCounterRollOverWhenAdded() {
- return ageCounterRollOverWhenAdded;
- }
-
- public void setAgeCounterRollOverWhenAdded(int ageCounterRollOverWhenAdded) {
- this.ageCounterRollOverWhenAdded = ageCounterRollOverWhenAdded;
- }
-
- /**
- * Gets the LSA type.
- *
- * @return LSA type
- */
- public OspfLsaType lsaType() {
- return lsaType;
- }
-
- /**
- * Sets the LSA type.
- *
- * @param lsaType LSA type
- */
- public void setLsaType(OspfLsaType lsaType) {
- this.lsaType = lsaType;
- }
-
- /**
- * Gets if self originated or not.
- *
- * @return true if self originated else false
- */
- public boolean isSelfOriginated() {
- return isSelfOriginated;
- }
-
- /**
- * Sets if self originated or not.
- *
- * @param isSelfOriginated true if self originated else false
- */
- public void setIsSelfOriginated(boolean isSelfOriginated) {
- this.isSelfOriginated = isSelfOriginated;
- }
-
- /**
- * Adds the LSA in the wrapper.
- *
- * @param lsaType LSA type
- * @param ospfLsa LSA instance
- */
- public void addLsa(OspfLsaType lsaType, OspfLsa ospfLsa) {
- this.lsaType = lsaType;
- this.lsaHeader = (LsaHeader) ospfLsa.lsaHeader();
- this.ospfLsa = ospfLsa;
- }
-
- /**
- * Age of LSA when received.
- *
- * @return Age of LSA when received
- */
- public int lsaAgeReceived() {
- return lsaAgeReceived;
- }
-
- /**
- * Sets the Age of LSA when received.
- *
- * @param lsaAgeReceived Age of LSA when received
- */
- public void setLsaAgeReceived(int lsaAgeReceived) {
- this.lsaAgeReceived = lsaAgeReceived;
- }
-
- /**
- * Gets the LSA header.
- *
- * @return LSA header instance
- */
- public LsaHeader lsaHeader() {
- lsaHeader.setAge(currentAge());
- return lsaHeader;
- }
-
- /**
- * Sets LSA header.
- *
- * @param lsaHeader LSA header
- */
- public void setLsaHeader(LsaHeader lsaHeader) {
- this.lsaHeader = lsaHeader;
- }
-
- /**
- * Gets the LSA.
- *
- * @return LSA instance
- */
- public OspfLsa ospfLsa() {
- LsaHeader lsaHeader = (LsaHeader) ospfLsa;
- lsaHeader.setAge(currentAge());
-
- return lsaHeader;
- }
-
- /**
- * Sets the LSA.
- *
- * @param ospfLsa LSA instance
- */
- public void setOspfLsa(OspfLsa ospfLsa) {
- this.ospfLsa = ospfLsa;
- }
-
- /**
- * Gets number of LSAs in retransmission list.
- *
- * @return number of LSAs in retransmission list
- */
- public int noReTransmissionLists() {
- return noReTransmissionLists;
- }
-
- /**
- * Sets number of LSAs in retransmission list.
- *
- * @param noReTransmissionLists number of LSAs in retransmission list
- */
- public void setNoReTransmissionLists(int noReTransmissionLists) {
- this.noReTransmissionLists = noReTransmissionLists;
- }
-
- /**
- * whether LSA in age bin or not.
- *
- * @return true if LSA in age bin else false
- */
- public boolean isInAnAgeBin() {
- return inAnAgeBin;
- }
-
- /**
- * Sets whether LSA in age bin or not.
- *
- * @param inAnAgeBin whether LSA in age bin or not
- */
- public void setInAnAgeBin(boolean inAnAgeBin) {
- this.inAnAgeBin = inAnAgeBin;
- }
-
- /**
- * Gets if LSA is changed since last flood.
- *
- * @return true if LSA is changed since last flood else false
- */
- public boolean isChangedSinceLastFlood() {
- return changedSinceLastFlood;
- }
-
- /**
- * Sets if LSA is changed since last flood.
- *
- * @param changedSinceLastFlood true if LSA is changed since last flood else false
- */
- public void setChangedSinceLastFlood(boolean changedSinceLastFlood) {
- this.changedSinceLastFlood = changedSinceLastFlood;
- }
-
- /**
- * Gets if sequence number rolled over.
- *
- * @return true if sequence rolled over else false.
- */
- public boolean isSequenceRollOver() {
- return isSequenceRollOver;
- }
-
- /**
- * Sets if sequence number rolled over.
- *
- * @param isSequenceRollOver true if sequence rolled over else false
- */
- public void setIsSequenceRollOver(boolean isSequenceRollOver) {
- this.isSequenceRollOver = isSequenceRollOver;
- }
-
- /**
- * Gets is sent reply for older LSA.
- *
- * @return true if sent reply for old LSA else false
- */
- public boolean isSentReplyForOlderLsa() {
- return sentReplyForOlderLsa;
- }
-
- /**
- * Sets is sent reply for older lsa.
- *
- * @param sentReplyForOlderLsa true if sent reply for older lsa else false
- */
- public void setSentReplyForOlderLsa(boolean sentReplyForOlderLsa) {
- this.sentReplyForOlderLsa = sentReplyForOlderLsa;
- }
-
- /**
- * Gets check age flag.
- *
- * @return true check age flag is set else false
- */
- public boolean isCheckAge() {
- return checkAge;
- }
-
- /**
- * Sets check age flag.
- *
- * @param checkAge check age flag.
- */
- public void setCheckAge(boolean checkAge) {
- this.checkAge = checkAge;
- }
-
- /**
- * Gets value of aging flag.
- *
- * @return is aging flag
- */
- public boolean isAging() {
- return isAging;
- }
-
- /**
- * Sets aging flag.
- *
- * @param isAging is aging flag
- */
- public void setIsAging(boolean isAging) {
- this.isAging = isAging;
- }
-
- /**
- * Gets the LSDB age.
- *
- * @return LSDB age
- */
- public LsdbAge getLsdbAge() {
- return lsdbAge;
- }
-
- /**
- * Sets the LSDB age.
- *
- * @param lsdbAge LSDB age
- */
- public void setLsdbAge(LsdbAge lsdbAge) {
- this.lsdbAge = lsdbAge;
- }
-
- /**
- * Gets the current LSA Age.
- *
- * @return LSA age
- */
- public int currentAge() {
-
- int currentAge = 0;
- //ls age received
- if (lsdbAge.getAgeCounter() >= ageCounterWhenReceived) {
- currentAge = lsaAgeReceived + (lsdbAge.getAgeCounter() - ageCounterWhenReceived);
- } else {
- currentAge = lsaAgeReceived + ((OspfParameters.MAXAGE + lsdbAge.getAgeCounter())
- - ageCounterWhenReceived);
- }
-
- if (currentAge >= OspfParameters.MAXAGE) {
- return OspfParameters.MAXAGE;
- } else if ((currentAge == lsaAgeReceived) && ageCounterRollOverWhenAdded != lsdbAge.getAgeCounterRollOver()) {
- return OspfParameters.MAXAGE;
- }
-
- return currentAge;
- }
-
- /**
- * Gets the age counter when received.
- *
- * @return the age counter when received
- */
- public int ageCounterWhenReceived() {
- return ageCounterWhenReceived;
- }
-
- /**
- * Sets the age counter when received.
- *
- * @param ageCounterWhenReceived the age counter when received
- */
- public void setAgeCounterWhenReceived(int ageCounterWhenReceived) {
- this.ageCounterWhenReceived = ageCounterWhenReceived;
- }
-
- /**
- * Gets the LSA process command.
- *
- * @return LSA process command
- */
- public String lsaProcessing() {
- return lsaProcessing;
- }
-
- /**
- * Sets the LSA process command.
- *
- * @param lsaProcessing LSA process command
- */
- public void setLsaProcessing(String lsaProcessing) {
- this.lsaProcessing = lsaProcessing;
- }
-
- /**
- * Gets bin number.
- *
- * @return bin number
- */
- public int binNumber() {
- return binNumber;
- }
-
- /**
- * Sets bin number.
- *
- * @param binNumber bin number
- */
- public void setBinNumber(int binNumber) {
- this.binNumber = binNumber;
- }
-
-
- /**
- * Get the OSPF interface.
- *
- * @return the OSPF interface.
- */
- public OspfInterface ospfInterface() {
- return ospfInterface;
- }
-
- /**
- * Sets the OSPF interface.
- *
- * @param ospfInterface OSPF interface instance
- */
- @Override
- public void setOspfInterface(OspfInterface ospfInterface) {
- this.ospfInterface = ospfInterface;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("lsaAgeReceived", lsaAgeReceived)
- .add("ageCounterWhenReceived", ageCounterWhenReceived)
- .add("isSelfOriginated", isSelfOriginated)
- .add("lsaHeader", lsaHeader)
- .add("lsaType", lsaType)
- .add("ospflsa", ospfLsa)
- .add("noReTransmissionLists", noReTransmissionLists)
- .add("inAnAgeBin", inAnAgeBin)
- .add("changedSinceLasFlood", changedSinceLastFlood)
- .add("isSequenceRollOver", isSequenceRollOver)
- .add("sentReplyForOlderLSA", sentReplyForOlderLsa)
- .add("checkAge", checkAge)
- .add("isAging", isAging)
- .add("lsaProcessing", lsaProcessing)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- LsaWrapperImpl that = (LsaWrapperImpl) o;
- return Objects.equal(lsaAgeReceived, that.lsaAgeReceived) &&
- Objects.equal(ageCounterWhenReceived, that.ageCounterWhenReceived) &&
- Objects.equal(isSelfOriginated, that.isSelfOriginated) &&
- Objects.equal(lsaHeader, that.lsaHeader) &&
- Objects.equal(ospfLsa, that.ospfLsa) &&
- Objects.equal(noReTransmissionLists, that.noReTransmissionLists) &&
- Objects.equal(inAnAgeBin, that.inAnAgeBin) &&
- Objects.equal(changedSinceLastFlood, that.changedSinceLastFlood) &&
- Objects.equal(isSequenceRollOver, that.isSequenceRollOver) &&
- Objects.equal(sentReplyForOlderLsa, that.sentReplyForOlderLsa) &&
- Objects.equal(checkAge, that.checkAge) &&
- Objects.equal(isAging, that.isAging) &&
- Objects.equal(lsaProcessing, that.lsaProcessing);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(lsaAgeReceived, lsaAgeReceived, ageCounterWhenReceived, isSelfOriginated,
- lsaHeader, lsaType, ospfLsa, noReTransmissionLists, inAnAgeBin,
- changedSinceLastFlood, isSequenceRollOver, sentReplyForOlderLsa,
- checkAge, isAging, lsaProcessing);
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsdbAgeImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsdbAgeImpl.java
deleted file mode 100644
index ea10996..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsdbAgeImpl.java
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.lsdb;
-
-import com.google.common.base.Objects;
-import org.jboss.netty.channel.Channel;
-import org.onosproject.ospf.controller.LsaBin;
-import org.onosproject.ospf.controller.LsaWrapper;
-import org.onosproject.ospf.controller.LsdbAge;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Map;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Representation of LSDB Aging process.
- */
-public class LsdbAgeImpl implements LsdbAge {
-
- private static final Logger log =
- LoggerFactory.getLogger(LsdbAgeImpl.class);
- protected static int ageCounter = 0;
- private InternalAgeTimer dbAgeTimer;
- private ScheduledExecutorService exServiceage;
- // creating age bins of MAXAGE
- private Map<Integer, LsaBin> ageBins = new ConcurrentHashMap<>(OspfParameters.MAXAGE);
- private LsaBin maxAgeBin = new LsaBinImpl(OspfParameters.MAXAGE);
- private int ageCounterRollOver = 0;
- private Channel channel = null;
- private LsaQueueConsumer queueConsumer = null;
- private BlockingQueue<LsaWrapper> lsaQueue = new ArrayBlockingQueue(1024);
- private OspfArea ospfArea = null;
-
-
- /**
- * Creates an instance of LSDB age.
- *
- * @param ospfArea OSPF area instance
- */
- public LsdbAgeImpl(OspfArea ospfArea) {
- // create LSBin's in the HashMap.
- for (int i = 0; i < OspfParameters.MAXAGE; i++) {
- LsaBin lsaBin = new LsaBinImpl(i);
- ageBins.put(i, lsaBin);
- }
- this.ospfArea = ospfArea;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- LsdbAgeImpl that = (LsdbAgeImpl) o;
- return Objects.equal(ageBins, that.ageBins) &&
- Objects.equal(ageCounter, that.ageCounter) &&
- Objects.equal(ageCounterRollOver, that.ageCounterRollOver) &&
- Objects.equal(lsaQueue, that.lsaQueue);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(ageBins, ageCounter, ageCounterRollOver, lsaQueue);
- }
-
- /**
- * Adds LSA to bin.
- *
- * @param binKey key to store in bin
- * @param lsaBin LSA bin instance
- */
- @Override
- public void addLsaBin(Integer binKey, LsaBin lsaBin) {
- if (!ageBins.containsKey(binKey)) {
- ageBins.put(binKey, lsaBin);
- }
- }
-
- /**
- * Gets LSA from Bin.
- *
- * @param binKey key
- * @return bin instance
- */
- @Override
- public LsaBin getLsaBin(Integer binKey) {
-
- return ageBins.get(binKey);
- }
-
- /**
- * Adds the LSA to maxAge bin.
- *
- * @param key key
- * @param wrapper wrapper instance
- */
- @Override
- public void addLsaToMaxAgeBin(String key, LsaWrapper wrapper) {
- maxAgeBin.addOspfLsa(key, wrapper);
- }
-
- /**
- * Removes LSA from Bin.
- *
- * @param lsaWrapper wrapper instance
- */
- @Override
- public void removeLsaFromBin(LsaWrapper lsaWrapper) {
- if (ageBins.containsKey(lsaWrapper.binNumber())) {
- LsaBin lsaBin = ageBins.get(lsaWrapper.binNumber());
- lsaBin.removeOspfLsa(((OspfAreaImpl) ospfArea).getLsaKey(((LsaWrapperImpl)
- lsaWrapper).lsaHeader()), lsaWrapper);
- }
- }
-
- /**
- * Starts the aging timer and queue consumer.
- */
- @Override
- public void startDbAging() {
- startDbAgeTimer();
- queueConsumer = new LsaQueueConsumer(lsaQueue, channel, ospfArea);
- new Thread(queueConsumer).start();
- }
-
-
- /**
- * Gets called every 1 second as part of the timer.
- */
- @Override
- public void ageLsaAndFlood() {
- //every 5 mins checksum validation
- checkAges();
- //every 30 mins - flood LSA
- refreshLsa();
- //every 60 mins - flood LSA
- maxAgeLsa();
-
- if (ageCounter == OspfParameters.MAXAGE) {
- ageCounter = 0;
- ageCounterRollOver++;
- } else {
- //increment age bin
- ageCounter++;
- }
- }
-
- /**
- * If the LSA have completed the MaxAge - they are moved called stop aging and flooded.
- */
- @Override
- public void maxAgeLsa() {
- if (ageCounter == 0) {
- return;
- }
- //Get from Age Bins
- LsaBin lsaBin = ageBins.get(ageCounter - 1);
- if (lsaBin == null) {
- return;
- }
- Map lsaBinMap = lsaBin.listOfLsa();
- for (Object key : lsaBinMap.keySet()) {
- LsaWrapper lsa = (LsaWrapper) lsaBinMap.get(key);
- if (lsa.currentAge() == OspfParameters.MAXAGE) {
- lsa.setLsaProcessing(OspfParameters.MAXAGELSA);
- log.debug("Lsa picked for maxage flooding. Age Counter: {}, AgeCounterRollover: {}, " +
- "AgeCounterRollover WhenAddedToDb: {}, LSA Type: {}, LSA Key: {}",
- ageCounter, ageCounterRollOver, lsa.currentAge(), lsa.lsaType(), key);
- //add it to lsaQueue for processing
- try {
- lsaQueue.put(lsa);
- //remove from bin
- lsaBin.removeOspfLsa((String) key, lsa);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- log.debug("Error::LSDBAge::maxAgeLsa::{}", e.getMessage());
- }
- }
- }
-
- //Get from maxAgeBin
- Map lsaMaxAgeBinMap = maxAgeBin.listOfLsa();
- for (Object key : lsaMaxAgeBinMap.keySet()) {
- LsaWrapper lsa = (LsaWrapper) lsaMaxAgeBinMap.get(key);
- lsa.setLsaProcessing(OspfParameters.MAXAGELSA);
- log.debug("Lsa picked for maxage flooding. Age Counter: {}, LSA Type: {}, LSA Key: {}",
- ageCounter, lsa.lsaType(), key);
- //add it to lsaQueue for processing
- try {
- lsaQueue.put(lsa);
- //remove from bin
- maxAgeBin.removeOspfLsa((String) key, lsa);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- log.debug("Error::LSDBAge::maxAgeLsa::{}", e.getMessage());
- }
- }
- }
-
-
- /*
- * If the LSA is in age bin of 1800 - it's pushed into refresh list.
- */
- @Override
- public void refreshLsa() {
- int binNumber;
- if (ageCounter < OspfParameters.LSREFRESHTIME) {
- binNumber = ageCounter + OspfParameters.LSREFRESHTIME;
- } else {
- binNumber = ageCounter - OspfParameters.LSREFRESHTIME;
- }
- LsaBin lsaBin = ageBins.get(binNumber);
- if (lsaBin == null) {
- return;
- }
- Map lsaBinMap = lsaBin.listOfLsa();
- for (Object key : lsaBinMap.keySet()) {
- LsaWrapper lsa = (LsaWrapper) lsaBinMap.get(key);
- try {
- if (lsa.isSelfOriginated()) {
- log.debug("Lsa picked for refreshLsa. binNumber: {}, LSA Type: {}, LSA Key: {}",
- binNumber, lsa.lsaType(), key);
- lsa.setLsaProcessing(OspfParameters.REFRESHLSA);
- lsaQueue.put(lsa);
- //remove from bin
- lsaBin.removeOspfLsa((String) key, lsa);
- }
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- log.debug("Error::LSDBAge::refreshLsa::{}", e.getMessage());
- }
- }
- }
-
- /**
- * Verify the checksum for the LSAs who are in bins of 300 and it's multiples.
- */
- public void checkAges() {
- //evry 5 min age counter + multiples of 300
- for (int age = OspfParameters.CHECKAGE; age < OspfParameters.MAXAGE;
- age += OspfParameters.CHECKAGE) {
- LsaBin lsaBin = ageBins.get(age2Bin(age));
- if (lsaBin == null) {
- continue;
- }
- Map lsaBinMap = lsaBin.listOfLsa();
- for (Object key : lsaBinMap.keySet()) {
- LsaWrapper lsa = (LsaWrapper) lsaBinMap.get(key);
- lsa.setLsaProcessing(OspfParameters.VERIFYCHECKSUM);
- try {
- lsaQueue.put(lsa);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- log.debug("Error::LSDBAge::checkAges::{}", e.getMessage());
- }
- }
- }
- }
-
-
- /**
- * Starts DB age timer method start the aging task.
- */
- private void startDbAgeTimer() {
- log.debug("OSPFNbr::startWaitTimer");
- dbAgeTimer = new InternalAgeTimer();
- //from 1 sec
- exServiceage = Executors.newSingleThreadScheduledExecutor();
- exServiceage.scheduleAtFixedRate(dbAgeTimer, OspfParameters.AGECOUNTER,
- OspfParameters.AGECOUNTER, TimeUnit.SECONDS);
- }
-
- /**
- * Stops the aging task.
- */
- private void stopDbAgeTimer() {
- log.debug("OSPFNbr::stopWaitTimer ");
- exServiceage.shutdown();
- }
-
-
- /**
- * Gets the netty channel.
- *
- * @return netty channel
- */
- public Channel getChannel() {
- return channel;
- }
-
- /**
- * Sets the netty channel.
- *
- * @param channel netty channel
- */
- public void setChannel(Channel channel) {
-
- this.channel = channel;
- if (queueConsumer != null) {
- queueConsumer.setChannel(channel);
- }
- }
-
- /**
- * Gets the age counter.
- *
- * @return ageCounter
- */
- @Override
- public int getAgeCounter() {
- return ageCounter;
- }
-
- /**
- * Gets the age counter roll over value.
- *
- * @return the age counter roll over value
- */
- @Override
- public int getAgeCounterRollOver() {
- return ageCounterRollOver;
- }
-
- /**
- * Gets the max age bin.
- *
- * @return lsa bin instance
- */
- @Override
- public LsaBin getMaxAgeBin() {
- return maxAgeBin;
- }
-
- /**
- * Gets the bin number.
- *
- * @param x Can be either age or ageCounter
- * @return bin number.
- */
- @Override
- public int age2Bin(int x) {
- if (x <= ageCounter) {
- return (ageCounter - x);
- } else {
- return ((OspfParameters.MAXAGE - 1) + (ageCounter - x));
- }
- }
-
- /**
- * Runnable task which runs every second and calls aging process.
- */
- private class InternalAgeTimer implements Runnable {
-
- /**
- * Constructor.
- */
- InternalAgeTimer() {
- log.debug("Starts::LsdbAge::AgeTimer...!!! ");
- }
-
- @Override
- public void run() {
- ageLsaAndFlood();
- }
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/OspfLsdbImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/OspfLsdbImpl.java
deleted file mode 100644
index a494afa..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/OspfLsdbImpl.java
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.lsdb;
-
-import com.google.common.base.Objects;
-import org.onosproject.ospf.controller.LsaBin;
-import org.onosproject.ospf.controller.LsaWrapper;
-import org.onosproject.ospf.controller.LsdbAge;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.controller.OspfLsdb;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * Represents the Link State Database.
- */
-public class OspfLsdbImpl implements OspfLsdb {
- private static final Logger log = LoggerFactory.getLogger(OspfLsdbImpl.class);
- private Map routerLsas = new HashMap();
- private Map networkLsas = new HashMap();
- private Map summaryLsas = new HashMap();
- private Map asbrSummaryLSAs = new HashMap();
- private Map opaque9Lsas = new HashMap();
- private Map opaque10Lsas = new HashMap();
- private Map opaque11Lsas = new HashMap();
- private Map externalLsas = new HashMap();
- private long routerLsaSeqNo = OspfParameters.STARTLSSEQUENCENUM;
- private long networkLsaSeqNo = OspfParameters.STARTLSSEQUENCENUM;
- private LsdbAge lsdbAge = null;
- private OspfArea ospfArea = null;
-
-
- /**
- * Creates an instance of OSPF LSDB.
- *
- * @param ospfArea area instance
- */
- public OspfLsdbImpl(OspfArea ospfArea) {
- this.ospfArea = ospfArea;
- lsdbAge = new LsdbAgeImpl(ospfArea);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- OspfLsdbImpl that = (OspfLsdbImpl) o;
- return Objects.equal(routerLsas.size(), that.routerLsas.size()) &&
- Objects.equal(networkLsas.size(), that.networkLsas.size()) &&
- Objects.equal(summaryLsas.size(), that.summaryLsas.size()) &&
- Objects.equal(asbrSummaryLSAs.size(), that.asbrSummaryLSAs.size()) &&
- Objects.equal(lsdbAge, that.lsdbAge) &&
- Objects.equal(routerLsaSeqNo, that.routerLsaSeqNo) &&
- Objects.equal(networkLsaSeqNo, that.networkLsaSeqNo);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(routerLsas, networkLsas, summaryLsas, asbrSummaryLSAs, lsdbAge,
- routerLsaSeqNo, networkLsaSeqNo);
- }
-
- /**
- * Initializes the link state database.
- */
- public void initializeDb() {
- lsdbAge.startDbAging();
- }
-
- /**
- * Returns all LSA Headers (Router and Summary) in a Vector.
- *
- * @param excludeMaxAgeLsa exclude the max age LSAs
- * @param isOpaqueCapable is opaque capable or not
- * @return List of LSA headers
- */
- public List getAllLsaHeaders(boolean excludeMaxAgeLsa, boolean isOpaqueCapable) {
- List summList = new CopyOnWriteArrayList();
- addLsaToHeaderList(summList, excludeMaxAgeLsa, routerLsas);
- addLsaToHeaderList(summList, excludeMaxAgeLsa, networkLsas);
- addLsaToHeaderList(summList, excludeMaxAgeLsa, summaryLsas);
- addLsaToHeaderList(summList, excludeMaxAgeLsa, asbrSummaryLSAs);
- addLsaToHeaderList(summList, excludeMaxAgeLsa, externalLsas);
- if (isOpaqueCapable) {
- addLsaToHeaderList(summList, excludeMaxAgeLsa, opaque9Lsas);
- addLsaToHeaderList(summList, excludeMaxAgeLsa, opaque10Lsas);
- addLsaToHeaderList(summList, excludeMaxAgeLsa, opaque11Lsas);
- }
-
- return summList;
- }
-
- /**
- * Adds the LSAs to summary list.
- *
- * @param summList summary list
- * @param excludeMaxAgeLsa exclude max age LSA
- * @param lsaMap map of LSA
- */
- private void addLsaToHeaderList(List summList, boolean excludeMaxAgeLsa, Map lsaMap) {
- Iterator slotVals = lsaMap.values().iterator();
- while (slotVals.hasNext()) {
- LsaWrapper wrapper = (LsaWrapper) slotVals.next();
- if (excludeMaxAgeLsa) {
- //if current age of lsa is max age or lsa present in Max Age bin
- if (wrapper.currentAge() != OspfParameters.MAXAGE &&
- lsdbAge.getMaxAgeBin().ospfLsa(((OspfAreaImpl)
- ospfArea).getLsaKey(((LsaWrapperImpl) wrapper).lsaHeader())) == null) {
- addToList(wrapper, summList);
- }
- } else {
- addToList(wrapper, summList);
- }
- }
- }
-
- /**
- * Adds the LSWrapper to summary list.
- *
- * @param wrapper LSA wrapper instance
- * @param summList LSA summary list
- */
- private void addToList(LsaWrapper wrapper, List summList) {
- LsaHeader header = (LsaHeader) wrapper.ospfLsa();
- //set the current age
- header.setAge(wrapper.currentAge());
- summList.add(header);
- }
-
- /**
- * Gets the LSDB LSA key from Lsa Header.
- *
- * @param lsaHeader LSA header instance
- * @return key
- */
- public String getLsaKey(LsaHeader lsaHeader) {
- String lsaKey = "";
- switch (lsaHeader.lsType()) {
- case OspfParameters.LINK_LOCAL_OPAQUE_LSA:
- case OspfParameters.AREA_LOCAL_OPAQUE_LSA:
- case OspfParameters.AS_OPAQUE_LSA:
- OpaqueLsaHeader header = (OpaqueLsaHeader) lsaHeader;
- lsaKey = lsaHeader.lsType() + "-" + header.opaqueType() + header.opaqueId() + "-" +
- lsaHeader.advertisingRouter();
- break;
- case OspfParameters.ROUTER:
- case OspfParameters.NETWORK:
- case OspfParameters.ASBR_SUMMARY:
- case OspfParameters.SUMMARY:
- case OspfParameters.EXTERNAL_LSA:
- lsaKey = lsaHeader.lsType() + "-" + lsaHeader.linkStateId() + "-" +
- lsaHeader.advertisingRouter();
- break;
- default:
- log.debug("Unknown LSA type..!!!");
- break;
- }
-
- return lsaKey;
- }
-
- /**
- * Gets wrapper instance in LSDB.
- *
- * @param lsaHeader LSA header instance.
- * @return LSA Wrapper instance.
- */
- public LsaWrapper lsaLookup(LsaHeader lsaHeader) {
-
- return findLsa(lsaHeader.lsType(), getLsaKey(lsaHeader));
- }
-
- /**
- * Finds the LSA from appropriate maps.
- *
- * @param lsType type of LSA
- * @param lsaKey key
- * @return LSA wrapper object
- */
- public LsaWrapper findLsa(int lsType, String lsaKey) {
- LsaWrapper lsaWrapper = null;
-
- switch (lsType) {
- case OspfParameters.LINK_LOCAL_OPAQUE_LSA:
- lsaWrapper = (LsaWrapper) opaque9Lsas.get(lsaKey);
- break;
- case OspfParameters.AREA_LOCAL_OPAQUE_LSA:
- lsaWrapper = (LsaWrapper) opaque10Lsas.get(lsaKey);
- break;
- case OspfParameters.AS_OPAQUE_LSA:
- lsaWrapper = (LsaWrapper) opaque11Lsas.get(lsaKey);
- break;
- case OspfParameters.ROUTER:
- lsaWrapper = (LsaWrapper) routerLsas.get(lsaKey);
- break;
- case OspfParameters.NETWORK:
- lsaWrapper = (LsaWrapper) networkLsas.get(lsaKey);
- break;
- case OspfParameters.ASBR_SUMMARY:
- lsaWrapper = (LsaWrapper) asbrSummaryLSAs.get(lsaKey);
- break;
- case OspfParameters.SUMMARY:
- lsaWrapper = (LsaWrapper) summaryLsas.get(lsaKey);
- break;
- case OspfParameters.EXTERNAL_LSA:
- lsaWrapper = (LsaWrapper) externalLsas.get(lsaKey);
- break;
- default:
- log.debug("Unknown LSA type..!!!");
- break;
- }
-
- //set the current age
- if (lsaWrapper != null) {
- //set the current age
- ((LsaWrapperImpl) lsaWrapper).lsaHeader().setAge(lsaWrapper.currentAge());
- ((LsaHeader) lsaWrapper.ospfLsa()).setAge(lsaWrapper.currentAge());
- }
-
- return lsaWrapper;
- }
-
-
- /**
- * Installs a new self-originated LSA if possible.
- * Return true if installing was successful else false.
- *
- * @param newLsa LSA header instance
- * @param isSelfOriginated is self originated or not
- * @param ospfInterface OSPF interface instance
- * @return true if successfully added
- */
- public boolean addLsa(LsaHeader newLsa, boolean isSelfOriginated, OspfInterface ospfInterface) {
-
- LsaWrapperImpl lsaWrapper = new LsaWrapperImpl();
- lsaWrapper.setLsaType(newLsa.getOspfLsaType());
- lsaWrapper.setOspfLsa(newLsa);
- lsaWrapper.setLsaHeader(newLsa);
- lsaWrapper.setLsaAgeReceived(newLsa.age());
- lsaWrapper.setAgeCounterWhenReceived(lsdbAge.getAgeCounter());
- lsaWrapper.setAgeCounterRollOverWhenAdded(lsdbAge.getAgeCounterRollOver());
- lsaWrapper.setIsSelfOriginated(isSelfOriginated);
- lsaWrapper.setIsSelfOriginated(isSelfOriginated);
- lsaWrapper.setOspfInterface(ospfInterface);
- lsaWrapper.setLsdbAge(lsdbAge);
- addLsa(lsaWrapper);
-
- log.debug("Added LSA In LSDB: {}", newLsa);
-
- return true;
- }
-
- /**
- * Installs a new self-originated LSA if possible.
- * Return true if installing was successful else false.
- * Adding LSA In cases
- * 1) New Self Originated LSA based on change in topology
- * 2) New Self Originated LSA because of LSRefresh
- * 2) New LSA received via Link State Update Packet
- *
- * @param newLsa LSA wrapper instance
- * @return true if added successfully
- */
- private boolean addLsa(LsaWrapper newLsa) {
- // adding an LSA - verify if it's old or new
- // verify min failed
- // to verify if it's a new LSA or updating the old LSA .
- // fetch the LSA Type
- // verify if the LSA age is ! Max Age
- // a) it is received during the flooding process (Section 13)
- // b) it is originated by the router itself (Section 12.4)
- // start aging .
- String key = getLsaKey(((LsaWrapperImpl) newLsa).lsaHeader());
- //Remove the lsa from bin if exist. we will be adding it in new bin based on the current age.
- removeLsaFromBin(lsaLookup(((LsaWrapperImpl) newLsa).lsaHeader()));
-
- switch (((LsaWrapperImpl) newLsa).lsaHeader().lsType()) {
-
- case OspfParameters.LINK_LOCAL_OPAQUE_LSA:
- opaque9Lsas.put(key, newLsa);
- break;
- case OspfParameters.AREA_LOCAL_OPAQUE_LSA:
- opaque10Lsas.put(key, newLsa);
- break;
- case OspfParameters.AS_OPAQUE_LSA:
- opaque11Lsas.put(key, newLsa);
- break;
- case OspfParameters.ROUTER:
- routerLsas.put(key, newLsa);
- break;
- case OspfParameters.NETWORK:
- networkLsas.put(key, newLsa);
- break;
- case OspfParameters.ASBR_SUMMARY:
- asbrSummaryLSAs.put(key, newLsa);
- break;
- case OspfParameters.SUMMARY:
- summaryLsas.put(key, newLsa);
- break;
- case OspfParameters.EXTERNAL_LSA:
- externalLsas.put(key, newLsa);
- break;
- default:
- log.debug("Unknown LSA type to add..!!!");
- break;
- }
- //add it to bin
- Integer binNumber = lsdbAge.age2Bin(((LsaWrapperImpl) newLsa).lsaHeader().age());
- LsaBin lsaBin = lsdbAge.getLsaBin(binNumber);
- if (lsaBin != null) {
- //remove from existing
- newLsa.setBinNumber(binNumber);
- lsaBin.addOspfLsa(key, newLsa);
- lsdbAge.addLsaBin(binNumber, lsaBin);
- log.debug("Added Type {} LSA to LSDB and LSABin[{}], Age of LSA {}", newLsa.lsaType(),
- binNumber, ((LsaWrapperImpl) newLsa).lsaHeader().age());
- }
-
- return false;
- }
-
- /**
- * Adds the LSA to maxAge bin.
- *
- * @param key key
- * @param wrapper LSA wrapper instance
- */
- public void addLsaToMaxAgeBin(String key, Object wrapper) {
- lsdbAge.addLsaToMaxAgeBin(key, (LsaWrapper) wrapper);
- }
-
- /**
- * Removes LSA from Bin.
- *
- * @param lsaWrapper LSA wrapper instance
- */
- public void removeLsaFromBin(Object lsaWrapper) {
- if (lsaWrapper != null) {
- lsdbAge.removeLsaFromBin((LsaWrapper) lsaWrapper);
- }
- }
-
- /**
- * RFC 2328 - Section 13.1. Determining which LSA is newer.
- *
- * @param lsa1 LSA instance
- * @param lsa2 LSA instance
- * @return string status
- */
- public String isNewerOrSameLsa(LsaHeader lsa1, LsaHeader lsa2) {
- if (lsa1.lsSequenceNo() > lsa2.lsSequenceNo()) {
- return "latest";
- } else if (lsa1.lsSequenceNo() < lsa2.lsSequenceNo()) {
- return "old";
- } else if (lsa1.lsSequenceNo() == lsa2.lsSequenceNo()) {
- if (lsa1.lsCheckSum() > lsa2.lsCheckSum()) {
- return "latest";
- } else if (lsa1.lsCheckSum() < lsa2.lsCheckSum()) {
- return "old";
- } else if (lsa1.lsCheckSum() == lsa2.lsCheckSum()) {
- if (lsa1.age() == lsa2.age()) {
- return "same";
- } else if (lsa1.age() == OspfParameters.MAXAGE) {
- return "latest";
- } else if (lsa2.age() == OspfParameters.MAXAGE) {
- return "old";
- } else if (OspfParameters.MAXAGEDIFF == (lsa1.age() - lsa2.age())) {
- if (lsa1.age() < lsa2.age()) {
- return "latest";
- } else {
- return "old";
- }
- } else {
- return "same";
- }
- }
- }
-
- return "";
- }
-
- /**
- * Gets the sequence number.
- *
- * @param lsaType type of LSA
- * @return sequence number
- */
- public long getLsSequenceNumber(OspfLsaType lsaType) {
- switch (lsaType) {
- case ROUTER:
- return routerLsaSeqNo++;
- case NETWORK:
- return networkLsaSeqNo++;
- default:
- return OspfParameters.STARTLSSEQUENCENUM;
- }
- }
-
- /**
- * Deletes the given LSA.
- *
- * @param lsaHeader LSA header instance
- */
- public void deleteLsa(LsaHeader lsaHeader) {
-
- String lsaKey = getLsaKey(lsaHeader);
- switch (lsaHeader.lsType()) {
- case OspfParameters.LINK_LOCAL_OPAQUE_LSA:
- opaque9Lsas.remove(lsaKey);
- break;
- case OspfParameters.AREA_LOCAL_OPAQUE_LSA:
- opaque10Lsas.remove(lsaKey);
- break;
- case OspfParameters.AS_OPAQUE_LSA:
- opaque11Lsas.remove(lsaKey);
- break;
- case OspfParameters.ROUTER:
- routerLsas.remove(lsaKey);
- break;
- case OspfParameters.NETWORK:
- networkLsas.remove(lsaKey);
- break;
- case OspfParameters.ASBR_SUMMARY:
- asbrSummaryLSAs.remove(lsaKey);
- break;
- case OspfParameters.SUMMARY:
- summaryLsas.remove(lsaKey);
- break;
- case OspfParameters.EXTERNAL_LSA:
- externalLsas.remove(lsaKey);
- break;
- default:
- log.debug("Unknown LSA type to delete..!!!");
- break;
- }
- }
-
- /**
- * Sets sequence number.
- *
- * @param routerLsaSeqNo sequence number
- */
- public void setRouterLsaSeqNo(long routerLsaSeqNo) {
- this.routerLsaSeqNo = routerLsaSeqNo;
- }
-
- /**
- * Sets sequence number.
- *
- * @param networkLsaSeqNo sequence number
- */
- public void setNetworkLsaSeqNo(long networkLsaSeqNo) {
- this.networkLsaSeqNo = networkLsaSeqNo;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/package-info.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/package-info.java
deleted file mode 100644
index 6c8f422..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the OSPF Link state database and Ageing.
- */
-package org.onosproject.ospf.controller.lsdb;
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfEligibleRouter.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfEligibleRouter.java
deleted file mode 100644
index 3e8acda..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfEligibleRouter.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.util;
-
-import org.onlab.packet.Ip4Address;
-
-/**
- * Represents a router who is eligible for DR election.
- */
-public class OspfEligibleRouter {
-
- private Ip4Address ipAddress;
- private Ip4Address routerId;
- private int routerPriority;
- private boolean isDr;
- private boolean isBdr;
-
- /**
- * Creates an instance.
- * Initialize IP address of eligible router.
- */
- public OspfEligibleRouter() {
- ipAddress = Ip4Address.valueOf("0.0.0.0");
- }
-
- /**
- * Gets the value of IP address.
- *
- * @return IP address
- */
- public Ip4Address getIpAddress() {
- return ipAddress;
- }
-
- /**
- * Sets the value of IP address.
- *
- * @param ipAddress IP address
- */
- public void setIpAddress(Ip4Address ipAddress) {
- this.ipAddress = ipAddress;
- }
-
- /**
- * Gets the value of router id.
- *
- * @return router id.
- */
- public Ip4Address getRouterId() {
- return routerId;
- }
-
- /**
- * Sets the value of router id.
- *
- * @param routerId router id
- */
- public void setRouterId(Ip4Address routerId) {
- this.routerId = routerId;
- }
-
- /**
- * Gets the value of router priority.
- *
- * @return router priority.
- */
- public int getRouterPriority() {
- return routerPriority;
- }
-
- /**
- * Sets the value of router priority.
- *
- * @param routerPriority router priority
- */
- public void setRouterPriority(int routerPriority) {
- this.routerPriority = routerPriority;
- }
-
- /**
- * Gets whether the router is DR.
- *
- * @return boolean true if router is DR else return false.
- */
- public boolean isDr() {
- return isDr;
- }
-
- /**
- * Sets the router is DR or not.
- *
- * @param isDr router is DR or not
- */
- public void setIsDr(boolean isDr) {
- this.isDr = isDr;
- }
-
- /**
- * Gets whether the router is BDR or not.
- *
- * @return boolean true if router is Bdr else return false.
- */
- public boolean isBdr() {
- return isBdr;
- }
-
- /**
- * Sets the router is BDR or not.
- *
- * @param isBdr the router is BDR or not
- */
- public void setIsBdr(boolean isBdr) {
- this.isBdr = isBdr;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfInterfaceType.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfInterfaceType.java
deleted file mode 100644
index c173884..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfInterfaceType.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.util;
-
-/**
- * Enum represents OSPF interface types.
- */
-public enum OspfInterfaceType {
-
- POINT_TO_POINT(1),
- BROADCAST(2),
- VIRTUAL(3);
-
- private int value;
-
- /**
- * Creates an instance.
- *
- * @param value value represents interface type
- */
- OspfInterfaceType(int value) {
- this.value = value;
- }
-
- /**
- * Gets value represents interface type.
- *
- * @return value represents interface type
- */
- public int value() {
- return value;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfLinkType.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfLinkType.java
deleted file mode 100644
index ad38cea..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfLinkType.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.util;
-
-/**
- * Enum represents OSPF link type.
- */
-public enum OspfLinkType {
-
- /**
- * Indicates a point-to-point connection to another router.
- */
- POINT_TO_POINT,
-
- /**
- * Indicates a connection to a transit network.
- */
- TO_TRANSIT_NET,
-
- /**
- * Indicates a connection to a stub network.
- */
- TO_STUB_NET,
-
- /**
- * Indicates a Virtual link to another area border router.
- */
- VIRTUAL_LINK
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/package-info.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/package-info.java
deleted file mode 100644
index e1fad0d..0000000
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the OSPF utilities.
- */
-package org.onosproject.ospf.controller.util;
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/ConfigurationTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/ConfigurationTest.java
deleted file mode 100644
index 9583e17..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/ConfigurationTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.area;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.controller.OspfProcess;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for Configuration.
- */
-public class ConfigurationTest {
- private Configuration configuration;
- private List<OspfProcess> ospfProcesses;
- private List result;
- private OspfProcessImpl ospfProcessImpl;
-
- @Before
- public void setUp() throws Exception {
- configuration = new Configuration();
- }
-
- @After
- public void tearDown() throws Exception {
- configuration = null;
- ospfProcessImpl = new OspfProcessImpl();
- result = null;
- ospfProcesses = null;
- }
-
- /**
- * Tests getProcesses() getter method.
- */
- @Test
- public void testGetOspfProcess() throws Exception {
- ospfProcesses = new ArrayList();
- ospfProcesses.add(ospfProcessImpl);
- ospfProcesses.add(ospfProcessImpl);
- configuration.setProcesses(ospfProcesses);
- result = configuration.getProcesses();
- assertThat(result.size(), is(2));
- }
-
- /**
- * Tests setProcesses() setter method.
- */
- @Test
- public void testSetOspfProcess() throws Exception {
- ospfProcesses = new ArrayList();
- ospfProcesses.add(ospfProcessImpl);
- ospfProcesses.add(ospfProcessImpl);
- configuration.setProcesses(ospfProcesses);
- result = configuration.getProcesses();
- assertThat(result.size(), is(2));
- }
-
- /**
- * Tests getMethod() getter method.
- */
- @Test
- public void testGetMethod() throws Exception {
- configuration.setMethod("method");
- assertThat(configuration.getMethod(), is("method"));
- }
-
- /**
- * Tests setMethod() setter method.
- */
- @Test
- public void testSetMethod() throws Exception {
- configuration.setMethod("method");
- assertThat(configuration.getMethod(), is("method"));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(configuration.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaAddressRangeImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaAddressRangeImplTest.java
deleted file mode 100644
index d294db1..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaAddressRangeImplTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.area;
-
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfAreaAddressRange;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for OspfAreaAddressRangeImpl.
- */
-public class OspfAreaAddressRangeImplTest {
-
- private OspfAreaAddressRange ospfAreaAddressRange;
- private int result;
- private String result1;
-
- @Before
- public void setUp() throws Exception {
- ospfAreaAddressRange = new OspfAreaAddressRangeImpl();
- }
-
- @After
- public void tearDown() throws Exception {
- ospfAreaAddressRange = null;
- }
-
- /**
- * Tests ipAddress() getter method.
- */
- @Test
- public void testGetIpAddress() throws Exception {
- ospfAreaAddressRange.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfAreaAddressRange.ipAddress(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests ipAddress() setter method.
- */
- @Test
- public void testSetIpAddress() throws Exception {
- ospfAreaAddressRange.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfAreaAddressRange.ipAddress(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests mask() getter method.
- */
- @Test
- public void testGetMask() throws Exception {
- ospfAreaAddressRange.setMask("1.1.1.1");
- assertThat(ospfAreaAddressRange.mask(), is("1.1.1.1"));
- }
-
- /**
- * Tests mask() setter method.
- */
- @Test
- public void testSetMask() throws Exception {
- ospfAreaAddressRange.setMask("1.1.1.1");
- assertThat(ospfAreaAddressRange.mask(), is("1.1.1.1"));
- }
-
- /**
- * Tests isAdvertise() getter method.
- */
- @Test
- public void testIsAdvertise() throws Exception {
- ospfAreaAddressRange.setAdvertise(true);
- assertThat(ospfAreaAddressRange.isAdvertise(), is(true));
- }
-
- /**
- * Tests isAdvertise() setter method.
- */
- @Test
- public void testSetAdvertise() throws Exception {
- ospfAreaAddressRange.setAdvertise(true);
- assertThat(ospfAreaAddressRange.isAdvertise(), is(true));
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEquals() throws Exception {
- assertThat(ospfAreaAddressRange.equals(new OspfAreaAddressRangeImpl()), is(true));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- result = ospfAreaAddressRange.hashCode();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- result1 = ospfAreaAddressRange.toString();
- assertThat(result1, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaImplTest.java
deleted file mode 100644
index 79689c0..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaImplTest.java
+++ /dev/null
@@ -1,468 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.area;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfNeighborState;
-import org.onosproject.ospf.controller.TopologyForDeviceAndLink;
-import org.onosproject.ospf.controller.impl.OspfNbrImpl;
-import org.onosproject.ospf.controller.impl.TopologyForDeviceAndLinkImpl;
-import org.onosproject.ospf.controller.lsdb.LsaWrapperImpl;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.util.OspfInterfaceState;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
-
-/**
- * Unit test class for OspfAreaImpl.
- */
-public class OspfAreaImplTest {
-
- private OspfAreaImpl ospfArea;
- private int result;
- private List<OspfInterface> ospfInterfaces = new ArrayList<>();
- private OspfInterfaceImpl ospfInterface1;
- private OspfInterfaceImpl ospfInterface2;
- private OspfInterfaceImpl ospfInterface3;
- private OspfNbrImpl ospfNbr;
- private OspfNbrImpl ospfNbr1;
- private NetworkLsa networkLsa;
- private LsaHeader lsaHeader;
- private Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10");
- private Ip4Address ip4Address1 = Ip4Address.valueOf("11.11.11.11");
- private Ip4Address networkAddress = Ip4Address.valueOf("255.255.255.255");
- private TopologyForDeviceAndLink topologyForDeviceAndLink;
- private RouterLsa routerLsa;
- private OpaqueLsaHeader opaqueLsaHeader;
- private OpaqueLsa10 opaqueLsa10;
-
- @Before
- public void setUp() throws Exception {
- lsaHeader = new LsaHeader();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setAdvertisingRouter(ip4Address);
- lsaHeader.setAdvertisingRouter(ip4Address);
- routerLsa = new RouterLsa(lsaHeader);
- routerLsa.setAdvertisingRouter(ip4Address);
- opaqueLsa10 = new OpaqueLsa10(opaqueLsaHeader);
- ospfArea = new OspfAreaImpl();
- ospfInterface1 = new OspfInterfaceImpl();
- topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface1, ip4Address, ip4Address1,
- 2, topologyForDeviceAndLink);
- ospfNbr.setState(OspfNeighborState.EXCHANGE);
- ospfNbr1 = new OspfNbrImpl(ospfArea, ospfInterface1, ip4Address, ip4Address1,
- 2, topologyForDeviceAndLink);
- ospfNbr1.setState(OspfNeighborState.FULL);
- ospfNbr1.setNeighborId(ip4Address);
- ospfNbr.setNeighborId(ip4Address);
- ospfNbr.setIsOpaqueCapable(true);
- ospfInterface1.addNeighbouringRouter(ospfNbr);
- ospfInterface1.addNeighbouringRouter(ospfNbr1);
- ospfInterface2 = new OspfInterfaceImpl();
- ospfInterface2.setIpAddress(ip4Address);
- ospfInterface2.setIpNetworkMask(networkAddress);
- ospfInterface2.setState(OspfInterfaceState.LOOPBACK);
- ospfInterface2.addNeighbouringRouter(ospfNbr);
- ospfInterface2.addNeighbouringRouter(ospfNbr1);
- ospfInterfaces.add(ospfInterface2);
- }
-
- @After
- public void tearDown() throws Exception {
- ospfArea = null;
- ospfInterfaces = null;
- lsaHeader = null;
- networkLsa = null;
- ospfInterface1 = null;
- ospfInterface2 = null;
- ospfInterface3 = null;
-
- }
-
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- result = ospfArea.hashCode();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests routerId() getter method.
- */
- @Test
- public void testGetRouterId() throws Exception {
- ospfArea.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfArea.routerId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests routerId() setter method.
- */
- @Test
- public void testSetRouterId() throws Exception {
- ospfArea.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfArea.routerId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests isOpaqueEnabled() getter method.
- */
- @Test
- public void testSetisOpaqueEnabled() throws Exception {
- ospfArea.setIsOpaqueEnabled(true);
- assertThat(ospfArea.isOpaqueEnabled(), is(true));
- }
-
- /**
- * Tests isOpaqueEnabled() setter method.
- */
- @Test
- public void testIsOpaqueEnabled() throws Exception {
- ospfArea.setIsOpaqueEnabled(true);
- assertThat(ospfArea.isOpaqueEnabled(), is(true));
- }
-
- /**
- * Tests initializeDb() method.
- */
- @Test
- public void testInitializeDb() throws Exception {
- ospfArea.initializeDb();
- assertThat(ospfArea, is(notNullValue()));
- }
-
-
- /**
- * Tests buildNetworkLsa() method.
- */
- @Test
- public void testBuildNetworkLsa() throws Exception {
- ospfInterfaces = new ArrayList();
- ospfInterface1 = new OspfInterfaceImpl();
- ospfInterface1.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- ospfInterfaces.add(ospfInterface1);
- ospfInterface2 = new OspfInterfaceImpl();
- ospfInterface2.setIpAddress(Ip4Address.valueOf("2.2.2.2"));
- ospfInterfaces.add(ospfInterface2);
- ospfInterface3 = new OspfInterfaceImpl();
- ospfInterface3.setIpAddress(Ip4Address.valueOf("3.3.3.3"));
- ospfInterfaces.add(ospfInterface3);
- ospfArea.setOspfInterfaceList(ospfInterfaces);
- ospfArea.setRouterId(Ip4Address.valueOf("111.111.111.111"));
- networkLsa = ospfArea.buildNetworkLsa(Ip4Address.valueOf("1.1.1.1"),
- Ip4Address.valueOf("255.255.255.255"));
- assertThat(ospfInterfaces.size(), is(3));
- assertThat(networkLsa, is(notNullValue()));
- assertThat(ospfArea, is(notNullValue()));
- }
-
-
- /**
- * Tests areaId() getter method.
- */
- @Test
- public void testGetAreaId() throws Exception {
- ospfArea.setAreaId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfArea.areaId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests areaId() setter method.
- */
- @Test
- public void testSetAreaId() throws Exception {
- ospfArea.setAreaId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfArea.areaId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
-
- /**
- * Tests isExternalRoutingCapability() getter method.
- */
- @Test
- public void testIsExternalRoutingCapability() throws Exception {
- ospfArea.setExternalRoutingCapability(true);
- assertThat(ospfArea.isExternalRoutingCapability(), is(true));
- }
-
- /**
- * Tests isExternalRoutingCapability() setter method.
- */
- @Test
- public void testSetExternalRoutingCapability() throws Exception {
- ospfArea.setExternalRoutingCapability(true);
- assertThat(ospfArea.isExternalRoutingCapability(), is(true));
- }
-
-
- /**
- * Tests ospfInterfaceList() getter method.
- */
- @Test
- public void testGetInterfacesLst() throws Exception {
- ospfInterfaces = new ArrayList();
- ospfInterface1 = new OspfInterfaceImpl();
- ospfInterface1.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- ospfInterfaces.add(ospfInterface1);
- ospfInterface2 = new OspfInterfaceImpl();
- ospfInterface2.setIpAddress(Ip4Address.valueOf("2.2.2.2"));
- ospfInterfaces.add(ospfInterface2);
- ospfInterface3 = new OspfInterfaceImpl();
- ospfInterface3.setIpAddress(Ip4Address.valueOf("3.3.3.3"));
- ospfInterfaces.add(ospfInterface3);
- ospfArea.setOspfInterfaceList(ospfInterfaces);
- assertThat(ospfInterfaces.size(), is(3));
- assertThat(ospfArea.ospfInterfaceList(), is(notNullValue()));
- }
-
- /**
- * Tests setInterfacesLst() setter method.
- */
- @Test
- public void testSetInterfacesLst() throws Exception {
- ospfInterfaces = new ArrayList();
- ospfInterface1 = new OspfInterfaceImpl();
- ospfInterface1.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- ospfInterfaces.add(ospfInterface1);
- ospfInterface2 = new OspfInterfaceImpl();
- ospfInterface2.setIpAddress(Ip4Address.valueOf("2.2.2.2"));
- ospfInterfaces.add(ospfInterface2);
- ospfInterface3 = new OspfInterfaceImpl();
- ospfInterface3.setIpAddress(Ip4Address.valueOf("3.3.3.3"));
- ospfInterfaces.add(ospfInterface3);
- ospfArea.setOspfInterfaceList(ospfInterfaces);
- assertThat(ospfInterfaces.size(), is(3));
- assertThat(ospfArea.ospfInterfaceList(), is(notNullValue()));
- }
-
-
- /**
- * Tests getLsaHeaders() method.
- */
- @Test
- public void testGetLsaHeaders() throws Exception {
- assertThat(ospfArea.getLsaHeaders(true, true).size(), is(0));
- }
-
- /**
- * Tests getLsa() method.
- */
- @Test
- public void testGetLsa() throws Exception {
- assertThat(ospfArea.getLsa(1, "1.1.1.1", "1.1.1.1"), is(nullValue()));
- assertThat(ospfArea.getLsa(10, "1.1.1.1", "1.1.1.1"), is(nullValue()));
- }
-
- /**
- * Tests lsaLookup() method.
- */
- @Test
- public void testLsaLookup() throws Exception {
- assertThat(ospfArea.lsaLookup(new RouterLsa()), is(nullValue()));
- }
-
- /**
- * Tests isNewerOrSameLsa() method.
- */
- @Test
- public void testIsNewerOrSameLsa() throws Exception {
- assertThat(ospfArea.isNewerOrSameLsa(new RouterLsa(), new RouterLsa()), is("same"));
- }
-
- /**
- * Tests addLsa() method.
- */
- @Test
- public void testAddLsa() throws Exception {
- ospfArea.addLsa(new RouterLsa(), new OspfInterfaceImpl());
- assertThat(ospfArea, is(notNullValue()));
- }
-
- /**
- * Tests addLsa() method.
- */
- @Test
- public void testAddLsa1() throws Exception {
- ospfArea.addLsa(new RouterLsa(), false, new OspfInterfaceImpl());
- assertThat(ospfArea, is(notNullValue()));
- }
-
- /**
- * Tests addLsaToMaxAgeBin() method.
- */
- @Test
- public void testAddLsaToMaxAgeBin() throws Exception {
- ospfArea.addLsaToMaxAgeBin("111", new LsaWrapperImpl());
- assertThat(ospfArea, is(notNullValue()));
- }
-
- /**
- * Tests setDbRouterSequenceNumber() method.
- */
- @Test
- public void testSetDbRouterSequenceNumber() throws Exception {
- ospfArea.setDbRouterSequenceNumber(123456);
- assertThat(ospfArea, is(notNullValue()));
- }
-
- /**
- * Tests deleteLsa() method.
- */
- @Test
- public void testDeleteLsa() throws Exception {
- ospfArea.deleteLsa(new LsaHeader());
- assertThat(ospfArea, is(notNullValue()));
- }
-
- /**
- * Tests removeLsaFromBin() method.
- */
- @Test
- public void testRemoveLsaFromBin() throws Exception {
- ospfArea.removeLsaFromBin(new LsaWrapperImpl());
- assertThat(ospfArea, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(ospfArea.toString(), is(notNullValue()));
- }
-
-
- /**
- * Tests getLsaKey() method.
- */
- @Test
- public void testGetLsaKey() throws Exception {
- lsaHeader = new LsaHeader();
- lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfArea.getLsaKey(lsaHeader), is(notNullValue()));
- }
-
-
- /**
- * Tests options() getter method.
- */
- @Test
- public void testGetOptions() throws Exception {
- ospfArea.setOptions(2);
- assertThat(ospfArea.options(), is(2));
- }
-
- /**
- * Tests options() setter method.
- */
- @Test
- public void testSetOptions() throws Exception {
- ospfArea.setOptions(2);
- assertThat(ospfArea.options(), is(2));
- }
-
- /**
- * Tests isOpaqueEnabled() method.
- */
- @Test
- public void testGetOpaqueEnabledOptions() throws Exception {
- ospfArea.setIsOpaqueEnabled(true);
- assertThat(ospfArea.isOpaqueEnabled(), is(true));
- }
-
- /**
- * Tests database() method.
- */
- @Test
- public void testGetDatabase() throws Exception {
- assertThat(ospfArea.database(), is(notNullValue()));
- }
-
- /**
- * Tests opaqueEnabledOptions() method.
- */
- @Test
- public void testOpaqueEnabledOptionsa() throws Exception {
- assertThat(ospfArea.opaqueEnabledOptions(), is(66));
- }
-
- /**
- * Tests noNeighborInLsaExchangeProcess() method.
- */
- @Test
- public void testNoNeighborInLsaExchangeProcess() throws Exception {
- ospfArea.setOspfInterfaceList(ospfInterfaces);
- ospfArea.noNeighborInLsaExchangeProcess();
- assertThat(ospfArea, is(notNullValue()));
- }
-
- /**
- * Tests getNeighborsInFullState() method.
- */
- @Test
- public void testGetNeighborsInFullState() throws Exception {
- ospfArea.getNeighborsInFullState(ospfInterface1);
- assertThat(ospfArea, is(notNullValue()));
- }
-
- /**
- * Tests addToOtherNeighborLsaTxList() method.
- */
- @Test
- public void testAddToOtherNeighborLsaTxList() throws Exception {
- ospfArea.setOspfInterfaceList(ospfInterfaces);
- ospfArea.addToOtherNeighborLsaTxList(routerLsa);
- assertThat(ospfArea, is(notNullValue()));
-
- opaqueLsa10.setLsType(OspfParameters.LINK_LOCAL_OPAQUE_LSA);
- ospfArea.addToOtherNeighborLsaTxList(opaqueLsa10);
- assertThat(ospfArea, is(notNullValue()));
- }
-
- /**
- * Tests buildRouterLsa() method.
- */
- @Test
- public void testBuildRouterLsa() throws Exception {
- ospfArea.setRouterId(ip4Address);
- ospfArea.setOspfInterfaceList(ospfInterfaces);
- ospfInterface1.setState(OspfInterfaceState.POINT2POINT);
- ospfInterface1.setIpAddress(ip4Address);
- ospfInterface1.setIpNetworkMask(networkAddress);
- ospfInterfaces.add(ospfInterface1);
- ospfArea.buildRouterLsa(ospfInterface1);
- ospfArea.setOspfInterfaceList(ospfInterfaces);
- assertThat(ospfArea, is(notNullValue()));
-
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfInterfaceImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfInterfaceImplTest.java
deleted file mode 100644
index 13aacf0..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfInterfaceImplTest.java
+++ /dev/null
@@ -1,1472 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.area;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.buffer.HeapChannelBufferFactory;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelConfig;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelStateEvent;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfAreaAddressRange;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.controller.OspfMessage;
-import org.onosproject.ospf.controller.OspfNbr;
-import org.onosproject.ospf.controller.OspfNeighborState;
-import org.onosproject.ospf.controller.OspfProcess;
-import org.onosproject.ospf.controller.TopologyForDeviceAndLink;
-import org.onosproject.ospf.controller.impl.Controller;
-import org.onosproject.ospf.controller.impl.OspfInterfaceChannelHandler;
-import org.onosproject.ospf.controller.impl.OspfLinkTedImpl;
-import org.onosproject.ospf.controller.impl.OspfNbrImpl;
-import org.onosproject.ospf.controller.impl.OspfRouterImpl;
-import org.onosproject.ospf.controller.impl.TopologyForDeviceAndLinkImpl;
-import org.onosproject.ospf.controller.util.OspfEligibleRouter;
-import org.onosproject.ospf.controller.util.OspfInterfaceType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.lsa.tlvtypes.RouterTlv;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
-import org.onosproject.ospf.protocol.util.ChecksumCalculator;
-import org.onosproject.ospf.protocol.util.OspfInterfaceState;
-
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for OspfInterfaceImpl.
- */
-public class OspfInterfaceImplTest {
- private List<OspfAreaAddressRange> addressRanges = new ArrayList();
- private List<OspfInterface> ospfInterfaces = new ArrayList();
- private OspfInterfaceImpl ospfInterface;
- private OspfNbrImpl ospfNbr;
- private OpaqueLsaHeader opaqueLsaHeader;
- private int result;
- private OspfAreaImpl ospfArea;
- private HashMap<String, OspfNbr> ospfNbrHashMap;
- private TopologyForDeviceAndLink topologyForDeviceAndLink;
- private Channel channel;
- private ChannelHandlerContext channelHandlerContext;
- private ChannelStateEvent channelStateEvent;
- private HelloPacket helloPacket;
- private DdPacket ddPacket;
- private ChecksumCalculator checksumCalculator;
- private byte[] byteArray;
- private byte[] checkArray;
- private OspfInterfaceChannelHandler ospfInterfaceChannelHandler;
- private LsRequest lsRequest;
- private ChannelBuffer buf;
- private LsUpdate lsUpdate;
- private LsAcknowledge lsAck;
- private Controller controller;
- private List<OspfProcess> ospfProcesses = new ArrayList();
- private OspfProcess ospfProcess;
- private OspfEligibleRouter ospfEligibleRouter;
-
- @Before
- public void setUp() throws Exception {
- ospfProcess = new OspfProcessImpl();
- ospfProcesses.add(ospfProcess);
- ospfInterface = new OspfInterfaceImpl();
- topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
- channel = EasyMock.createMock(Channel.class);
- ospfArea = createOspfArea();
- ospfInterface = createOspfInterface();
- ospfNbrHashMap = new HashMap();
- topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setNeighborId(Ip4Address.valueOf("10.10.10.10"));
- ospfNbr.setRouterPriority(0);
- ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
- ospfInterface.addNeighbouringRouter(ospfNbr);
- controller = new Controller();
- ospfInterfaceChannelHandler = new OspfInterfaceChannelHandler(controller, ospfProcesses);
-
- }
-
- @After
- public void tearDown() throws Exception {
- ospfInterface = null;
- ospfNbr = null;
- opaqueLsaHeader = null;
- ospfNbrHashMap = null;
- }
-
- /**
- * Tests state() getter method.
- */
- @Test
- public void testGetState() throws Exception {
- ospfInterface.setState(OspfInterfaceState.DROTHER);
- assertThat(ospfInterface.state(), is(OspfInterfaceState.DROTHER));
- }
-
- /**
- * Tests state() setter method.
- */
- @Test
- public void testSetState() throws Exception {
- ospfInterface.setState(OspfInterfaceState.DROTHER);
- assertThat(ospfInterface.state(), is(OspfInterfaceState.DROTHER));
- }
-
- /**
- * Tests linkStateHeaders() method.
- */
- @Test
- public void testGetLinkStateHeaders() throws Exception {
-
- assertThat(ospfInterface.linkStateHeaders().size(), is(0));
- }
-
- /**
- * Tests ipNetworkMask() getter method.
- */
- @Test
- public void testGetIpNetworkMask() throws Exception {
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfInterface.ipNetworkMask(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests ipNetworkMask() setter method.
- */
- @Test
- public void testSetIpNetworkMask() throws Exception {
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfInterface.ipNetworkMask(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests addNeighbouringRouter() method.
- */
- @Test
- public void testAddNeighbouringRouter() throws Exception {
- ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
- Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
- ospfInterface.addNeighbouringRouter(ospfNbr);
- assertThat(ospfInterface, is(notNullValue()));
-
- }
-
- /**
- * Tests neighbouringRouter() method.
- */
- @Test
- public void testGetNeighbouringRouter() throws Exception {
- ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
- Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
- ospfInterface.addNeighbouringRouter(ospfNbr);
- assertThat(ospfInterface.neighbouringRouter("111.111.111.111"), is(notNullValue()));
- }
-
- /**
- * Tests addLsaHeaderForDelayAck() method.
- */
- @Test
- public void testAddLsaHeaderForDelayAck() throws Exception {
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(10);
- ospfInterface.addLsaHeaderForDelayAck(opaqueLsaHeader);
- assertThat(ospfInterface, is(notNullValue()));
- }
-
- /**
- * Tests removeLsaFromNeighborMap() method.
- */
- @Test
- public void testRemoveLsaFromNeighborMap() throws Exception {
- ospfInterface.removeLsaFromNeighborMap("lsa10");
- assertThat(ospfInterface, is(notNullValue()));
- }
-
- /**
- * Tests isNeighborInList() method.
- */
- @Test
- public void testIsNeighborinList() throws Exception {
- ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
- Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
- ospfInterface.addNeighbouringRouter(ospfNbr);
- assertThat(ospfInterface.isNeighborInList("111.111.111.111"), is(notNullValue()));
- }
-
- /**
- * Tests listOfNeighbors() getter method.
- */
- @Test
- public void testGetListOfNeighbors() throws Exception {
- ospfNbrHashMap = new HashMap();
- ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
- Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
- ospfNbrHashMap.put("111.111.111.111", ospfNbr);
- ospfInterface.setListOfNeighbors(ospfNbrHashMap);
- assertThat(ospfInterface.listOfNeighbors().size(), is(1));
- }
-
- /**
- * Tests listOfNeighbors() setter method.
- */
- @Test
- public void testSetListOfNeighbors() throws Exception {
- ospfNbrHashMap = new HashMap();
- ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
- Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
- ospfNbrHashMap.put("111.111.111.111", ospfNbr);
- ospfInterface.setListOfNeighbors(ospfNbrHashMap);
- assertThat(ospfInterface.listOfNeighbors().size(), is(1));
- }
-
- /**
- * Tests ipAddress() getter method.
- */
- @Test
- public void testGetIpAddress() throws Exception {
- ospfInterface.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfInterface.ipAddress(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests ipAddress() getter method.
- */
- @Test
- public void testSetIpAddress() throws Exception {
- ospfInterface.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfInterface.ipAddress(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests routerPriority() getter method.
- */
- @Test
- public void testGetRouterPriority() throws Exception {
- ospfInterface.setRouterPriority(1);
- Assert.assertEquals(1, ospfInterface.routerPriority());
- }
-
- /**
- * Tests routerPriority() setter method.
- */
- @Test
- public void testSetRouterPriority() throws Exception {
- ospfInterface.setRouterPriority(1);
- assertThat(ospfInterface.routerPriority(), is(1));
- }
-
- /**
- * Tests helloIntervalTime() getter method.
- */
- @Test
- public void testGetHelloIntervalTime() throws Exception {
- ospfInterface.setHelloIntervalTime(10);
- assertThat(ospfInterface.helloIntervalTime(), is(10));
- }
-
- /**
- * Tests helloIntervalTime() setter method.
- */
- @Test
- public void testSetHelloIntervalTime() throws Exception {
- ospfInterface.setHelloIntervalTime(10);
- assertThat(ospfInterface.helloIntervalTime(), is(10));
- }
-
- /**
- * Tests routerDeadIntervalTime() getter method.
- */
- @Test
- public void testGetRouterDeadIntervalTime() throws Exception {
- ospfInterface.setRouterDeadIntervalTime(10);
- assertThat(ospfInterface.routerDeadIntervalTime(), is(10));
- }
-
- /**
- * Tests routerDeadIntervalTime() setter method.
- */
- @Test
- public void testSetRouterDeadIntervalTime() throws Exception {
- ospfInterface.setRouterDeadIntervalTime(10);
- assertThat(ospfInterface.routerDeadIntervalTime(), is(10));
- }
-
- /**
- * Tests interfaceType() getter method.
- */
- @Test
- public void testGetInterfaceType() throws Exception {
- ospfInterface.setInterfaceType(1);
- assertThat(ospfInterface.interfaceType(), is(1));
- }
-
- /**
- * Tests interfaceType() setter method.
- */
- @Test
- public void testSetInterfaceType() throws Exception {
- ospfInterface.setInterfaceType(1);
- assertThat(ospfInterface.interfaceType(), is(1));
- }
-
- /**
- * Tests mtu() getter method.
- */
- @Test
- public void testGetMtu() throws Exception {
- ospfInterface.setMtu(100);
- assertThat(ospfInterface.mtu(), is(100));
- }
-
- /**
- * Tests mtu() setter method.
- */
- @Test
- public void testSetMtu() throws Exception {
- ospfInterface.setMtu(100);
- assertThat(ospfInterface.mtu(), is(100));
- }
-
- /**
- * Tests reTransmitInterval() getter method.
- */
- @Test
- public void testGetReTransmitInterval() throws Exception {
- ospfInterface.setReTransmitInterval(100);
- assertThat(ospfInterface.reTransmitInterval(), is(100));
- }
-
- /**
- * Tests reTransmitInterval() setter method.
- */
- @Test
- public void testSetReTransmitInterval() throws Exception {
- ospfInterface.setReTransmitInterval(100);
- assertThat(ospfInterface.reTransmitInterval(), is(100));
- }
-
- /**
- * Tests dr() getter method.
- */
- @Test
- public void testGetDr() throws Exception {
- ospfInterface.setDr(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfInterface.dr(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests dr() setter method.
- */
- @Test
- public void testSetDr() throws Exception {
- ospfInterface.setDr(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfInterface.dr(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests bdr() getter method.
- */
- @Test
- public void testGetBdr() throws Exception {
- ospfInterface.setBdr(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfInterface.bdr(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests bdr() setter method.
- */
- @Test
- public void testSetBdr() throws Exception {
- ospfInterface.setBdr(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfInterface.bdr(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEquals() throws Exception {
- assertThat(ospfInterface.equals(new OspfInterfaceImpl()), is(false));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- result = ospfInterface.hashCode();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(ospfInterface.toString(), is(notNullValue()));
- }
-
- /**
- * Tests to interfaceUp() method.
- */
- @Test(expected = Exception.class)
- public void testInterfaceUp() throws Exception {
- ospfInterface.setInterfaceType(OspfInterfaceType.POINT_TO_POINT.value());
- ospfInterface.interfaceUp();
- assertThat(ospfInterface, is(notNullValue()));
- }
-
- /**
- * Tests to interfaceUp() method.
- */
- @Test(expected = Exception.class)
- public void testInterfaceUp1() throws Exception {
-
- ospfInterface.setInterfaceType(OspfInterfaceType.BROADCAST.value());
- ospfInterface.interfaceUp();
- assertThat(ospfInterface, is(notNullValue()));
- }
-
- /**
- * Tests to interfaceUp() method.
- */
- @Test(expected = Exception.class)
- public void testInterfaceUp2() throws Exception {
-
- ospfInterface.setRouterPriority(1);
- ospfInterface.setInterfaceType(OspfInterfaceType.BROADCAST.value());
- ospfInterface.interfaceUp();
- assertThat(ospfInterface, is(notNullValue()));
- }
-
- /**
- * Tests to backupSeen() method.
- */
- @Test
- public void testBackupSeen() throws Exception {
- ospfInterface.setOspfArea(ospfArea);
- ospfInterface.setState(OspfInterfaceState.WAITING);
- ospfInterface.backupSeen(channel);
- assertThat(ospfInterface, is(notNullValue()));
- }
-
- /**
- * Tests to waitTimer() method.
- */
- @Test
- public void testWaitTimer() throws Exception {
- ospfInterface.setOspfArea(ospfArea);
- ospfInterface.setState(OspfInterfaceState.WAITING);
- ospfInterface.waitTimer(channel);
- assertThat(ospfInterface, is(notNullValue()));
- }
-
- /**
- * Tests to callDrElection() method.
- */
- @Test
- public void testCallDrElection() throws Exception {
- ospfInterface.setOspfArea(ospfArea);
- ospfInterface.setState(OspfInterfaceState.WAITING);
- ospfInterface.callDrElection(channel);
- assertThat(ospfInterface, is(notNullValue()));
- }
-
- /**
- * Tests to neighborChange() method.
- */
- @Test
- public void testNeighborChange() throws Exception {
- ospfInterface.setOspfArea(ospfArea);
- ospfInterface.setState(OspfInterfaceState.DR);
- ospfInterface.neighborChange();
- assertThat(ospfInterface, is(notNullValue()));
- }
-
- /**
- * Tests to interfaceDown() method.
- */
- @Test(expected = Exception.class)
- public void testInterfaceDown() throws Exception {
- ospfInterface.interfaceDown();
- assertThat(ospfInterface, is(notNullValue()));
- }
-
- /**
- * Tests processOspfMessage() method.
- */
- @Test
- public void testProcessOspfMessage() throws Exception {
- ospfInterface.setOspfArea(ospfArea);
- ospfInterface.setInterfaceType(OspfInterfaceType.POINT_TO_POINT.value());
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("0.0.0.0"));
- ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
- ospfInterface.setInterfaceType(2);
- ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- OspfMessage message;
- helloPacket = new HelloPacket();
- helloPacket.setSourceIp(Ip4Address.valueOf("1.1.0.1"));
- helloPacket.setRouterId(Ip4Address.valueOf("10.10.10.10"));
- helloPacket.setOspfVer(2);
- helloPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- helloPacket.setOptions(2);
- helloPacket.setNetworkMask(Ip4Address.valueOf("3.3.3.3"));
- helloPacket.setOspftype(1);
- helloPacket.setAuthType(0);
- helloPacket.setHelloInterval(60);
- helloPacket.setRouterDeadInterval(60);
- helloPacket.setAuthentication(0);
- helloPacket.setNetworkMask(Ip4Address.valueOf("1.1.1.1"));
- checksumCalculator = new ChecksumCalculator();
- byteArray = helloPacket.asBytes();
- helloPacket.setOspfPacLength(byteArray.length);
- checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
- checkArray[0] = -51;
- checkArray[1] = 52;
- buf = ChannelBuffers.copiedBuffer(checkArray);
- helloPacket.setChecksum(buf.readUnsignedShort());
- message = helloPacket;
- ospfInterface.processOspfMessage(message, channelHandlerContext);
- ddPacket = new DdPacket();
- ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- ddPacket.setRouterId(Ip4Address.valueOf("10.10.10.10"));
- ddPacket.setOspfVer(2);
- ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- ddPacket.setOptions(2);
- ddPacket.setOspftype(2);
- ddPacket.setAuthType(0);
- ddPacket.setAuthentication(0);
- checksumCalculator = new ChecksumCalculator();
- byteArray = ddPacket.asBytes();
- ddPacket.setOspfPacLength(byteArray.length);
- checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
- checkArray[0] = -49;
- checkArray[1] = -79;
- buf = ChannelBuffers.copiedBuffer(checkArray);
- ddPacket.setChecksum(buf.readUnsignedShort());
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- message = ddPacket;
- ospfInterface.processOspfMessage(message, channelHandlerContext);
- lsRequest = new LsRequest();
- lsRequest.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- lsRequest.setRouterId(Ip4Address.valueOf("10.10.10.10"));
- lsRequest.setOspfVer(2);
- lsRequest.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- lsRequest.setOspftype(3);
- lsRequest.setAuthType(0);
- lsRequest.setAuthentication(0);
- checksumCalculator = new ChecksumCalculator();
- byteArray = lsRequest.asBytes();
- lsRequest.setOspfPacLength(byteArray.length);
- checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
- checkArray[0] = -47;
- checkArray[1] = -72;
- buf = ChannelBuffers.copiedBuffer(checkArray);
- lsRequest.setChecksum(buf.readUnsignedShort());
- message = lsRequest;
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ospfInterface.processOspfMessage(message, channelHandlerContext);
- lsUpdate = new LsUpdate();
- lsUpdate.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- lsUpdate.setRouterId(Ip4Address.valueOf("10.10.10.10"));
- lsUpdate.setOspfVer(2);
- lsUpdate.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- lsUpdate.setOspftype(4);
- lsUpdate.setAuthType(0);
- lsUpdate.setAuthentication(0);
- checksumCalculator = new ChecksumCalculator();
- byteArray = lsUpdate.asBytes();
- lsUpdate.setOspfPacLength(byteArray.length);
- checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
- checkArray[0] = -47;
- checkArray[1] = -77;
- buf = ChannelBuffers.copiedBuffer(checkArray);
- lsUpdate.setChecksum(buf.readUnsignedShort());
- message = lsUpdate;
- ospfInterface.processOspfMessage(message, channelHandlerContext);
- lsAck = new LsAcknowledge();
- lsAck.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- lsAck.setRouterId(Ip4Address.valueOf("10.10.10.10"));
- lsAck.setOspfVer(2);
- lsAck.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- lsAck.setOspftype(5);
- lsAck.setAuthType(0);
- lsAck.setAuthentication(0);
- checksumCalculator = new ChecksumCalculator();
- byteArray = lsAck.asBytes();
- lsAck.setOspfPacLength(byteArray.length);
- checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
- checkArray[0] = -47;
- checkArray[1] = -74;
- buf = ChannelBuffers.copiedBuffer(checkArray);
- lsAck.setChecksum(buf.readUnsignedShort());
- message = lsAck;
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ospfInterface.processOspfMessage(message, channelHandlerContext);
- assertThat(ospfInterface, is(notNullValue()));
- }
-
- /**
- * Tests processHelloMessage() method.
- */
- @Test
- public void testProcessHelloMessage() throws Exception {
- ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
- ospfInterface.setInterfaceType(1);
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("244.244.244.244"));
- ospfInterface.setHelloIntervalTime(10);
- ospfInterface.setRouterDeadIntervalTime(10);
- ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- OspfMessage message;
- helloPacket = new HelloPacket();
- helloPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- helloPacket.setOspfVer(2);
- helloPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- helloPacket.setNetworkMask(Ip4Address.valueOf("244.244.244.244"));
- helloPacket.setHelloInterval(10);
- helloPacket.setRouterDeadInterval(10);
- helloPacket.setDr(Ip4Address.valueOf("10.10.10.10"));
- helloPacket.setBdr(Ip4Address.valueOf("11.11.11.11"));
- helloPacket.setRouterId(Ip4Address.valueOf("111.111.111.111"));
- message = helloPacket;
- ospfInterface.processHelloMessage(message, channelHandlerContext);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests processHelloMessage() method.
- */
- @Test
- public void testProcessHelloMessage1() throws Exception {
- ospfInterface.setOspfArea(ospfArea);
- ospfInterface.setInterfaceType(2);
- ospfInterface.setRouterPriority(1);
- ospfInterface.interfaceUp();
- ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
- ospfInterface.setState(OspfInterfaceState.WAITING);
- ospfInterface.setInterfaceType(2);
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("244.244.244.244"));
- ospfInterface.setHelloIntervalTime(10);
- ospfInterface.setRouterDeadIntervalTime(10);
- ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- OspfMessage message;
- helloPacket = new HelloPacket();
- helloPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- helloPacket.setOspfVer(2);
- helloPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- helloPacket.setNetworkMask(Ip4Address.valueOf("244.244.244.244"));
- helloPacket.setHelloInterval(10);
- helloPacket.setRouterDeadInterval(10);
- helloPacket.setDr(Ip4Address.valueOf("10.10.10.10"));
- helloPacket.setBdr(Ip4Address.valueOf("11.11.11.11"));
- helloPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
- message = helloPacket;
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ospfInterface.processHelloMessage(message, channelHandlerContext);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
- ospfNbrHashMap = new HashMap();
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
- ospfNbr.setRouterPriority(0);
- ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
- ospfInterface.addNeighbouringRouter(ospfNbr);
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ospfInterface.processHelloMessage(message, channelHandlerContext);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests processDdMessage() method.
- */
- @Test
- public void testProcessDdMessage() throws Exception {
- ospfInterface.setOspfArea(ospfArea);
- ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
- ospfInterface.setInterfaceType(2);
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- ospfInterface.setHelloIntervalTime(10);
- ospfInterface.setRouterDeadIntervalTime(10);
- ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- OspfMessage message;
- ddPacket = new DdPacket();
- ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- ddPacket.setOspfVer(2);
- ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
- ddPacket.setIsOpaqueCapable(true);
- ddPacket.setIsMore(1);
- ddPacket.setIsInitialize(1);
- ddPacket.setIsMaster(1);
- ddPacket.setSequenceNo(123);
- message = ddPacket;
- ospfNbrHashMap = new HashMap();
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setLastDdPacket(createDdPacket());
- ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
- ospfNbr.setState(OspfNeighborState.EXSTART);
- ospfNbr.setRouterPriority(0);
- ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
- ospfNbr.setDdSeqNum(123);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ospfInterface.processDdMessage(message, channelHandlerContext);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests processDdMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessDdMessage3() throws Exception {
- ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
- ospfInterface.setInterfaceType(2);
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- ospfInterface.setHelloIntervalTime(10);
- ospfInterface.setRouterDeadIntervalTime(10);
- ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- OspfMessage message;
- ddPacket = new DdPacket();
- ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- ddPacket.setOspfVer(2);
- ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
- ddPacket.setIsOpaqueCapable(true);
- ddPacket.setIsMore(1);
- ddPacket.setIsInitialize(1);
- ddPacket.setIsMaster(1);
- ddPacket.setSequenceNo(123);
- message = ddPacket;
- ospfNbrHashMap = new HashMap();
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setLastDdPacket(createDdPacket());
- ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
- ospfNbr.setState(OspfNeighborState.EXSTART);
- ospfNbr.setRouterPriority(0);
- ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
- ospfNbr.setDdSeqNum(123);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- ddPacket.setIsMore(1);
- ddPacket.setIsInitialize(0);
- ddPacket.setIsMaster(0);
- ddPacket.setSequenceNo(123);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ospfInterface.processDdMessage(message, channelHandlerContext);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests processDdMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessDdMessage1() throws Exception {
- ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
- ospfInterface.setInterfaceType(2);
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- ospfInterface.setHelloIntervalTime(10);
- ospfInterface.setRouterDeadIntervalTime(10);
- ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- OspfMessage message;
- ddPacket = new DdPacket();
- ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- ddPacket.setOspfVer(2);
- ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
- ddPacket.setIsOpaqueCapable(true);
- ddPacket.setIsMore(1);
- ddPacket.setIsInitialize(1);
- ddPacket.setIsMaster(1);
- ddPacket.setSequenceNo(123);
- message = ddPacket;
- ospfNbrHashMap = new HashMap();
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setLastDdPacket(createDdPacket());
- ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
- ospfNbr.setState(OspfNeighborState.EXCHANGE);
- ospfNbr.setRouterPriority(0);
- ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
- ospfNbr.setDdSeqNum(123);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- ddPacket.setIsMore(1);
- ddPacket.setIsInitialize(0);
- ddPacket.setIsMaster(0);
- ddPacket.setSequenceNo(123);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ospfInterface.processDdMessage(message, channelHandlerContext);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-
- }
-
- /**
- * Tests processDdMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessDdMessage2() throws Exception {
- ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
- ospfInterface.setInterfaceType(2);
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- ospfInterface.setHelloIntervalTime(10);
- ospfInterface.setRouterDeadIntervalTime(10);
- ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- OspfMessage message;
- ddPacket = new DdPacket();
- ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- ddPacket.setOspfVer(2);
- ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
- ddPacket.setIsOpaqueCapable(true);
- ddPacket.setIsMore(1);
- ddPacket.setIsInitialize(1);
- ddPacket.setIsMaster(1);
- ddPacket.setSequenceNo(123);
- message = ddPacket;
- ospfNbrHashMap = new HashMap();
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setLastDdPacket(createDdPacket());
- ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
- ospfNbr.setState(OspfNeighborState.LOADING);
- ospfNbr.setRouterPriority(0);
- ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
- ospfNbr.setDdSeqNum(123);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- ospfInterface.setState(OspfInterfaceState.POINT2POINT);
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ospfInterface.processDdMessage(message, channelHandlerContext);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-
- }
-
- /**
- * Tests processDdMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessDdMessage4() throws Exception {
- ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
- ospfInterface.setInterfaceType(2);
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- ospfInterface.setHelloIntervalTime(10);
- ospfInterface.setRouterDeadIntervalTime(10);
- ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- OspfMessage message;
- ddPacket = new DdPacket();
- ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- ddPacket.setOspfVer(2);
- ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
- ddPacket.setIsOpaqueCapable(true);
- ddPacket.setIsMore(1);
- ddPacket.setIsInitialize(1);
- ddPacket.setIsMaster(1);
- ddPacket.setSequenceNo(123);
- message = ddPacket;
- ospfNbrHashMap = new HashMap();
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setLastDdPacket(createDdPacket());
- ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
- ospfNbr.setState(OspfNeighborState.EXCHANGE);
- ospfNbr.setRouterPriority(0);
- ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
- ospfNbr.setDdSeqNum(123);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- ospfInterface.setState(OspfInterfaceState.POINT2POINT);
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ddPacket.setIsMore(1);
- ddPacket.setIsInitialize(0);
- ddPacket.setIsMaster(1);
- ddPacket.setSequenceNo(123);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- ospfNbr.setState(OspfNeighborState.EXCHANGE);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ospfInterface.processDdMessage(message, channelHandlerContext);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-
- }
-
- /**
- * Tests processDdMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessDdMessage5() throws Exception {
- ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
- ospfInterface.setInterfaceType(2);
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- ospfInterface.setHelloIntervalTime(10);
- ospfInterface.setRouterDeadIntervalTime(10);
- ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- OspfMessage message;
- ddPacket = new DdPacket();
- ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- ddPacket.setOspfVer(2);
- ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
- ddPacket.setIsOpaqueCapable(true);
- ddPacket.setIsMore(1);
- ddPacket.setIsInitialize(1);
- ddPacket.setIsMaster(1);
- ddPacket.setSequenceNo(123);
- message = ddPacket;
- ospfNbrHashMap = new HashMap();
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setLastDdPacket(createDdPacket());
- ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
- ospfNbr.setState(OspfNeighborState.EXCHANGE);
- ospfNbr.setRouterPriority(0);
- ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
- ospfNbr.setDdSeqNum(123);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- ospfInterface.setState(OspfInterfaceState.POINT2POINT);
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ddPacket.setIsMore(1);
- ddPacket.setIsInitialize(1);
- ddPacket.setIsMaster(0);
- ddPacket.setSequenceNo(123);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- ospfNbr.setState(OspfNeighborState.EXCHANGE);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ospfInterface.processDdMessage(message, channelHandlerContext);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-
- }
-
- /**
- * Tests processDdMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessDdMessage6() throws Exception {
- ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
- ospfInterface.setInterfaceType(2);
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- ospfInterface.setHelloIntervalTime(10);
- ospfInterface.setRouterDeadIntervalTime(10);
- ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- OspfMessage message;
- ddPacket = new DdPacket();
- ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- ddPacket.setOspfVer(2);
- ddPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- ddPacket.setRouterId(Ip4Address.valueOf("2.2.2.2"));
- ddPacket.setIsOpaqueCapable(true);
- ddPacket.setIsMore(1);
- ddPacket.setIsInitialize(1);
- ddPacket.setIsMaster(1);
- ddPacket.setSequenceNo(123);
- message = ddPacket;
- ospfNbrHashMap = new HashMap();
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setLastDdPacket(createDdPacket());
- ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
- ospfNbr.setState(OspfNeighborState.FULL);
- ospfNbr.setRouterPriority(0);
- ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
- ospfNbr.setDdSeqNum(123);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- ospfInterface.setState(OspfInterfaceState.POINT2POINT);
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ddPacket.setIsMore(1);
- ddPacket.setIsInitialize(1);
- ddPacket.setIsMaster(0);
- ddPacket.setSequenceNo(123);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- ospfNbr.setState(OspfNeighborState.FULL);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ospfInterface.processDdMessage(message, channelHandlerContext);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-
- }
-
- /**
- * Tests processLsRequestMessage() method.
- */
- @Test(expected = Exception.class)
- public void testProcessLSRequestMessage() throws Exception {
- ospfArea.setRouterId(Ip4Address.valueOf("11.11.11.11"));
- ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- ospfInterface.setOspfArea(ospfArea);
- ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
- ospfInterface.setInterfaceType(2);
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- ospfInterface.setHelloIntervalTime(10);
- ospfInterface.setRouterDeadIntervalTime(10);
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- OspfMessage message;
- lsRequest = new LsRequest();
- lsRequest.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- lsRequest.setOspfVer(2);
- lsRequest.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- lsRequest.setRouterId(Ip4Address.valueOf("10.226.165.100"));
- List<LsRequestPacket> lsRequests = new ArrayList();
- LsRequestPacket lsRequestPacket = new LsRequestPacket();
- lsRequestPacket.setLsType(OspfLsaType.AREA_LOCAL_OPAQUE_LSA.value());
- lsRequestPacket.setLinkStateId("2.2.2.2");
- lsRequestPacket.setOwnRouterId("10.226.165.100");
- lsRequests.add(lsRequestPacket);
- lsRequests.add(lsRequestPacket);
- lsRequest.addLinkStateRequests(lsRequestPacket);
- message = lsRequest;
- ospfNbrHashMap = new HashMap();
- ospfNbr.setState(OspfNeighborState.EXCHANGE);
- ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("10.226.165.100"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setLastDdPacket(createDdPacket());
- ospfNbr.setNeighborId(Ip4Address.valueOf("10.226.165.100"));
- ospfNbr.setState(OspfNeighborState.FULL);
- ospfNbr.setRouterPriority(0);
- ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
- ospfNbr.setDdSeqNum(123);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- OpaqueLsaHeader lsaHeader = new OpaqueLsaHeader();
- lsaHeader.setLsType(OspfLsaType.AREA_LOCAL_OPAQUE_LSA.value());
- lsaHeader.setLinkStateId("2.2.2.2");
- lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("10.226.165.100"));
- OpaqueLsa10 opaqueLsa10 = new OpaqueLsa10(lsaHeader);
- ospfArea.addLsa(opaqueLsa10, false, ospfInterface);
- ospfInterface.setOspfArea(ospfArea);
- ospfInterface.processLsRequestMessage(message, channelHandlerContext);
- assertThat(ospfInterface, is(notNullValue()));
- }
-
- /**
- * Tests processLsUpdateMessage() method.
- */
- @Test
- public void testProcessLSUpdateMessage() throws Exception {
- ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
- ospfInterface.setInterfaceType(2);
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- ospfInterface.setHelloIntervalTime(10);
- ospfInterface.setRouterDeadIntervalTime(10);
- ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- OspfMessage message;
- lsUpdate = new LsUpdate();
- lsUpdate.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- lsUpdate.setOspfVer(2);
- lsUpdate.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- lsUpdate.setRouterId(Ip4Address.valueOf("10.226.165.100"));
- RouterLsa routerLsa = new RouterLsa();
- lsUpdate.addLsa(routerLsa);
- lsUpdate.setNumberOfLsa(1);
- message = lsUpdate;
- ospfNbrHashMap = new HashMap();
- ospfNbr.setState(OspfNeighborState.FULL);
- ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("10.226.165.100"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setLastDdPacket(createDdPacket());
- ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
- ospfNbr.setState(OspfNeighborState.FULL);
- ospfNbr.setRouterPriority(0);
- ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
- ospfNbr.setDdSeqNum(123);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ospfInterface.processLsUpdateMessage(message, channelHandlerContext);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-
- }
-
- @Test(expected = Exception.class)
- public void testProcessLSAckMessage() throws Exception {
- ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
- ospfInterface.setInterfaceType(2);
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- ospfInterface.setHelloIntervalTime(10);
- ospfInterface.setRouterDeadIntervalTime(10);
- ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- OspfMessage message;
- lsAck = new LsAcknowledge();
- lsAck.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- lsAck.setOspfVer(2);
- lsAck.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- LsaHeader lsaHeader = new LsaHeader();
- lsAck.addLinkStateHeader(lsaHeader);
- message = lsAck;
- ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("10.226.165.100"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setLastDdPacket(createDdPacket());
- ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
- ospfNbr.setState(OspfNeighborState.FULL);
- ospfNbr.setRouterPriority(0);
- ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
- ospfNbr.setDdSeqNum(123);
- channelHandlerContext = null;
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ospfInterface.processLsAckMessage(message, channelHandlerContext);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
-
- }
-
- /**
- * Tests electRouter() method.
- */
- @Test
- public void testElectRouter() throws Exception {
- ospfInterface.setOspfArea(ospfArea);
- ospfInterface.setDr(Ip4Address.valueOf("3.3.3.3"));
- ospfInterface.setBdr(Ip4Address.valueOf("3.3.3.3"));
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- ChannelConfig channelConfig = EasyMock.createMock(ChannelConfig.class);
- EasyMock.expect(channelConfig.getBufferFactory()).andReturn(new HeapChannelBufferFactory());
- Channel channel = EasyMock.createMock(Channel.class);
- ospfInterface.electRouter(channel);
- assertThat(ospfInterface.dr(), is(notNullValue()));
- }
-
- /**
- * Tests electBdr() method.
- */
- @Test
- public void testElectBdr() throws Exception {
- ospfEligibleRouter = new OspfEligibleRouter();
- ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsDr(true);
- ospfEligibleRouter.setRouterPriority(10);
- ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsBdr(false);
- OspfEligibleRouter ospfEligibleRouter1 = new OspfEligibleRouter();
- ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsDr(true);
- ospfEligibleRouter.setRouterPriority(10);
- ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsBdr(false);
- OspfEligibleRouter ospfEligibleRouter2 = new OspfEligibleRouter();
- ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsDr(true);
- ospfEligibleRouter.setRouterPriority(10);
- ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsBdr(false);
- List<OspfEligibleRouter> ospfEligibleRouters = new ArrayList<>();
-
- ospfEligibleRouters.add(ospfEligibleRouter);
- ospfEligibleRouters.add(ospfEligibleRouter1);
- ospfEligibleRouters.add(ospfEligibleRouter2);
- OspfEligibleRouter eligibleRouter = ospfInterface.electBdr(ospfEligibleRouters);
- assertThat(ospfEligibleRouters.size(), is(3));
- assertThat(eligibleRouter, is(notNullValue()));
- }
-
- /**
- * Tests electDr() method.
- */
- @Test
- public void testElectDR() throws Exception {
- ospfEligibleRouter = new OspfEligibleRouter();
- ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsDr(true);
- ospfEligibleRouter.setRouterPriority(10);
- ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsBdr(false);
- OspfEligibleRouter ospfEligibleRouter1 = new OspfEligibleRouter();
- ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsDr(true);
- ospfEligibleRouter.setRouterPriority(10);
- ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsBdr(false);
- OspfEligibleRouter ospfEligibleRouter2 = new OspfEligibleRouter();
- ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsDr(true);
- ospfEligibleRouter.setRouterPriority(10);
- ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsBdr(false);
- List<OspfEligibleRouter> ospfEligibleRouters = new ArrayList<>();
- ospfEligibleRouters.add(ospfEligibleRouter);
- ospfEligibleRouters.add(ospfEligibleRouter1);
- ospfEligibleRouters.add(ospfEligibleRouter2);
- OspfEligibleRouter eligibleRouter = ospfInterface.electDr(ospfEligibleRouters,
- ospfEligibleRouter);
- assertThat(ospfEligibleRouters.size(), is(3));
- assertThat(eligibleRouter, is(notNullValue()));
- }
-
- /**
- * Tests selectRouterBasedOnPriority() method.
- */
- @Test
- public void testSelectRouterBasedOnPriority() throws Exception {
- ospfEligibleRouter = new OspfEligibleRouter();
- ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsDr(true);
- ospfEligibleRouter.setRouterPriority(10);
- ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsBdr(false);
- OspfEligibleRouter ospfEligibleRouter1 = new OspfEligibleRouter();
- ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsDr(true);
- ospfEligibleRouter.setRouterPriority(11);
- ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsBdr(false);
- OspfEligibleRouter ospfEligibleRouter2 = new OspfEligibleRouter();
- ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsDr(true);
- ospfEligibleRouter.setRouterPriority(12);
- ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- ospfEligibleRouter.setIsBdr(false);
- List<OspfEligibleRouter> ospfEligibleRouters = new ArrayList<>();
- ospfEligibleRouters.add(ospfEligibleRouter);
- ospfEligibleRouters.add(ospfEligibleRouter1);
- ospfEligibleRouters.add(ospfEligibleRouter2);
- OspfEligibleRouter eligibleRouter = ospfInterface.selectRouterBasedOnPriority(
- ospfEligibleRouters);
- assertThat(eligibleRouter, is(notNullValue()));
- }
-
- /**
- * Tests addDeviceInformation() method.
- */
- @Test(expected = Exception.class)
- public void testAddDeviceInformation() throws Exception {
- ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("10.226.165.100"), 2,
- topologyForDeviceAndLink);
-
- ospfInterface.addDeviceInformation(new OspfRouterImpl());
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests removeDeviceInformation() method.
- */
- @Test(expected = Exception.class)
- public void testRemoveDeviceInformation() throws Exception {
- ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("10.226.165.100"), 2,
- topologyForDeviceAndLink);
-
- ospfInterface.removeDeviceInformation(new OspfRouterImpl());
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests addLinkInformation() method.
- */
- @Test(expected = Exception.class)
- public void testaddLinkInformation() throws Exception {
- ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("10.226.165.100"), 2,
- topologyForDeviceAndLink);
-
- List topTlv = new ArrayList();
- topTlv.add(new RouterTlv(new TlvHeader()));
- ospfInterface.addLinkInformation(new OspfRouterImpl(), new OspfLinkTedImpl());
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests removeLinkInformation() method.
- */
- @Test(expected = Exception.class)
- public void testRemoveLinkInformation() throws Exception {
- ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("10.226.165.100"), 2,
- topologyForDeviceAndLink);
-
- ospfInterface.removeLinkInformation(new OspfRouterImpl(), new OspfLinkTedImpl());
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
- }
-
- /**
- * Utility for test method.
- */
- private DdPacket createDdPacket() throws OspfParseException {
- byte[] ddPacket = {2, 2, 0, 32, -64, -88, -86, 8, 0, 0, 0, 1, -96, 82,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, -36, 2, 7, 65, 119, -87, 126};
- DdPacket ddPacket1 = new DdPacket();
- ChannelBuffer buf = ChannelBuffers.buffer(ddPacket.length);
- buf.writeBytes(ddPacket);
- ddPacket1.readFrom(buf);
- return ddPacket1;
- }
-
- /**
- * Utility for test method.
- */
- private OspfInterfaceImpl createOspfInterface() throws UnknownHostException {
- ospfInterface = new OspfInterfaceImpl();
- OspfAreaImpl ospfArea = new OspfAreaImpl();
- OspfInterfaceChannelHandler ospfInterfaceChannelHandler = EasyMock.createMock(
- OspfInterfaceChannelHandler.class);
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.226.165.164"),
- Ip4Address.valueOf("1.1.1.1"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setState(OspfNeighborState.EXSTART);
- ospfNbr.setNeighborId(Ip4Address.valueOf("10.226.165.100"));
- this.ospfInterface = new OspfInterfaceImpl();
- this.ospfInterface.setIpAddress(Ip4Address.valueOf("10.226.165.164"));
- this.ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- this.ospfInterface.setBdr(Ip4Address.valueOf("111.111.111.111"));
- this.ospfInterface.setDr(Ip4Address.valueOf("111.111.111.111"));
- this.ospfInterface.setHelloIntervalTime(20);
- this.ospfInterface.setInterfaceType(2);
- this.ospfInterface.setReTransmitInterval(2000);
- this.ospfInterface.setMtu(6500);
- this.ospfInterface.setRouterDeadIntervalTime(1000);
- this.ospfInterface.setRouterPriority(1);
- this.ospfInterface.setInterfaceType(1);
- this.ospfInterface.addNeighbouringRouter(ospfNbr);
- return this.ospfInterface;
- }
-
- /**
- * Utility for test method.
- */
- private OspfInterfaceImpl createOspfInterface1() throws UnknownHostException {
- ospfInterface = new OspfInterfaceImpl();
- OspfAreaImpl ospfArea = new OspfAreaImpl();
- OspfInterfaceChannelHandler ospfInterfaceChannelHandler = EasyMock.createMock(
- OspfInterfaceChannelHandler.class);
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.226.165.164"),
- Ip4Address.valueOf("1.1.1.1"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setState(OspfNeighborState.FULL);
- ospfNbr.setNeighborId(Ip4Address.valueOf("10.226.165.100"));
- ospfInterface = new OspfInterfaceImpl();
- ospfInterface.setIpAddress(Ip4Address.valueOf("10.226.165.164"));
- ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- ospfInterface.setBdr(Ip4Address.valueOf("111.111.111.111"));
- ospfInterface.setDr(Ip4Address.valueOf("111.111.111.111"));
- ospfInterface.setHelloIntervalTime(20);
- ospfInterface.setInterfaceType(2);
- ospfInterface.setReTransmitInterval(2000);
- ospfInterface.setMtu(6500);
- ospfInterface.setRouterDeadIntervalTime(1000);
- ospfInterface.setRouterPriority(1);
- ospfInterface.setInterfaceType(1);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- return ospfInterface;
- }
-
- /**
- * Utility for test method.
- */
- private OspfAreaImpl createOspfArea() throws UnknownHostException {
- OspfAreaAddressRangeImpl ospfAreaAddressRange;
- ospfAreaAddressRange = createOspfAreaAddressRange();
- addressRanges.add(ospfAreaAddressRange);
- OspfAreaImpl ospfArea = new OspfAreaImpl();
- ospfArea.setAreaId(Ip4Address.valueOf("10.226.165.164"));
- ospfArea.setExternalRoutingCapability(true);
- OspfInterfaceImpl ospfInterface = createOspfInterface();
- ospfInterfaces.add(ospfInterface);
- ospfArea.setOspfInterfaceList(ospfInterfaces);
- RouterLsa routerLsa = new RouterLsa();
- routerLsa.setLsType(1);
- routerLsa.setLinkStateId("2.2.2.2");
- routerLsa.setAdvertisingRouter(Ip4Address.valueOf("2.2.2.2"));
- try {
- ospfArea.addLsa(routerLsa, false, ospfInterface);
- } catch (Exception e) {
- System.out.println("ospfAreaImpl createOspfArea");
- }
- ospfArea.setRouterId(Ip4Address.valueOf("111.111.111.111"));
-
- return ospfArea;
- }
-
- /**
- * Utility for test method.
- */
- private OspfAreaAddressRangeImpl createOspfAreaAddressRange() {
- OspfAreaAddressRangeImpl ospfAreaAddressRange = new OspfAreaAddressRangeImpl();
- ospfAreaAddressRange.setIpAddress(Ip4Address.valueOf("10.226.165.164"));
- ospfAreaAddressRange.setAdvertise(true);
- ospfAreaAddressRange.setMask("mask");
- return ospfAreaAddressRange;
- }
-
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfProcessImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfProcessImplTest.java
deleted file mode 100644
index f20048c..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfProcessImplTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.area;
-
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.controller.OspfArea;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for OspfProcessImpl.
- */
-public class OspfProcessImplTest {
-
- private OspfProcessImpl ospfProcess;
- private List<OspfArea> list;
- private List result;
-
- @Before
- public void setUp() throws Exception {
- ospfProcess = new OspfProcessImpl();
- }
-
- @After
- public void tearDown() throws Exception {
- ospfProcess = null;
- list = null;
- }
-
- /**
- * Tests areas() getter method.
- */
- @Test
- public void testGetAreas() throws Exception {
- list = new ArrayList();
- list.add(new OspfAreaImpl());
- list.add(new OspfAreaImpl());
- ospfProcess.setAreas(list);
- result = ospfProcess.areas();
- assertThat(result.size(), is(2));
- }
-
- /**
- * Tests areas() setter method.
- */
- @Test
- public void testSetAreas() throws Exception {
- list = new ArrayList();
- list.add(new OspfAreaImpl());
- list.add(new OspfAreaImpl());
- ospfProcess.setAreas(list);
- result = ospfProcess.areas();
- assertThat(result.size(), is(2));
- }
-
- /**
- * Tests processId() getter method.
- */
- @Test
- public void testGetProcessId() throws Exception {
- ospfProcess.setProcessId("1.1.1.1");
- assertThat(ospfProcess.processId(), is("1.1.1.1"));
- }
-
- /**
- * Tests processId() setter method.
- */
- @Test
- public void testSetProcessId() throws Exception {
- ospfProcess.setProcessId("1.1.1.1");
- assertThat(ospfProcess.processId(), is("1.1.1.1"));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(ospfProcess.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/ControllerTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/ControllerTest.java
deleted file mode 100644
index c0b5db8..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/ControllerTest.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.ospf.controller.OspfAgent;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfProcess;
-import org.onosproject.ospf.controller.OspfRouter;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.controller.area.OspfProcessImpl;
-
-import java.nio.channels.Channel;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for Controller.
- */
-public class ControllerTest {
- private Controller controller;
- private Map<String, Long> maps;
- private OspfAgent ospfAgent;
- private DriverService driverService;
- private List<Channel> connectedChannels;
- private List<OspfProcess> process;
- private OspfProcess ospfProcess;
- private OspfArea ospfArea;
- private OspfInterface ospfInterface;
- private List<OspfInterface> ospfInterfaces;
- private List<OspfArea> ospfAreas;
- private List<OspfProcess> ospfProcesses;
- private OspfProcess ospfProcess1;
- private OspfArea ospfArea1;
- private OspfRouter ospfRouter;
-
- @Before
- public void setUp() throws Exception {
- controller = new Controller();
- maps = new HashMap<String, Long>();
- ospfProcess = new OspfProcessImpl();
- ospfArea = new OspfAreaImpl();
- ospfInterface = new OspfInterfaceImpl();
- ospfInterfaces = new ArrayList();
- ospfInterface.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- ospfInterfaces.add(ospfInterface);
- ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2"));
- ospfArea.setOspfInterfaceList(ospfInterfaces);
- ospfProcess.setProcessId("10.10.10.10");
- ospfAreas = new ArrayList();
- ospfAreas.add(ospfArea);
- ospfProcess.setAreas(ospfAreas);
- ospfProcesses = new ArrayList();
- ospfProcesses.add(ospfProcess);
- ospfProcess1 = new OspfProcessImpl();
- ospfProcess1.setProcessId("11.11.11.11");
- ospfArea1 = new OspfAreaImpl();
- ospfArea1.setAreaId(Ip4Address.valueOf("2.2.2.2"));
- ospfArea1.setOspfInterfaceList(ospfInterfaces);
- ospfAreas.add(ospfArea1);
- ospfProcess1.setAreas(ospfAreas);
- ospfProcesses.add(ospfProcess1);
- connectedChannels = new ArrayList<>();
- }
-
- @After
- public void tearDown() throws Exception {
- controller = null;
- maps.clear();
- connectedChannels.clear();
- controller = null;
- maps = null;
- ospfAgent = null;
- driverService = null;
- connectedChannels = null;
- process = null;
- ospfProcess = null;
- ospfArea = null;
- ospfInterface = null;
- ospfInterfaces = null;
- ospfAreas = null;
- ospfProcesses = null;
- ospfProcess1 = null;
- ospfArea1 = null;
- }
-
- /**
- * Tests getAllConfiguredProcesses() method.
- */
- @Test
- public void testGetAllConfiguredProcesses() throws Exception {
- process = controller.getAllConfiguredProcesses();
- assertThat(process, is(nullValue()));
- }
-
- /**
- * Tests addDeviceDetails() method.
- */
- @Test(expected = Exception.class)
- public void testAddDeviceDetails() throws Exception {
- controller.addDeviceDetails(new OspfRouterImpl());
- assertThat(controller, is(notNullValue()));
- }
-
- /**
- * Tests removeDeviceDetails() method.
- */
- @Test(expected = Exception.class)
- public void testRemoveDeviceDetails() throws Exception {
- controller.removeDeviceDetails(new OspfRouterImpl());
- assertThat(controller, is(notNullValue()));
- }
-
- /**
- * Tests init() method.
- */
- @Test
- public void testInit() throws Exception {
- controller.init();
- assertThat(controller.systemStartTime, is(notNullValue()));
- }
-
- /**
- * Tests start() method.
- */
- @Test
- public void testStart() throws Exception {
- ospfAgent = EasyMock.createMock(OspfAgent.class);
- controller.start(ospfAgent, driverService);
- controller.updateConfig(ospfProcesses);
- assertThat(controller, is(notNullValue()));
- }
-
- /**
- * Tests stop() method.
- */
- @Test(expected = Exception.class)
- public void testStop() throws Exception {
- controller.start(ospfAgent, driverService);
- controller.stop();
- assertThat(controller, is(notNullValue()));
- }
-
-
- /**
- * Tests updateConfig() method.
- */
- @Test
- public void testUpdateConfig1() throws Exception {
- ospfProcess = new OspfProcessImpl();
- ospfArea = new OspfAreaImpl();
- ospfInterface = new OspfInterfaceImpl();
- ospfInterfaces = new ArrayList();
- ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.5"));
- ospfInterfaces.add(ospfInterface);
- ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2"));
- ospfArea.setOspfInterfaceList(ospfInterfaces);
- ospfProcess.setProcessId("10.10.10.10");
- ospfAreas = new ArrayList();
- ospfAreas.add(ospfArea);
- ospfProcess.setAreas(ospfAreas);
- ospfProcesses = new ArrayList();
- ospfProcesses.add(ospfProcess);
- controller.updateConfig(ospfProcesses);
- assertThat(controller, is(notNullValue()));
- }
-
- /**
- * Tests addLinkDetails() method.
- */
- @Test
- public void testAddLinkDetails() throws Exception {
- ospfAgent = EasyMock.createMock(OspfAgent.class);
- controller.start(ospfAgent, driverService);
- ospfRouter = new OspfRouterImpl();
- controller.addLinkDetails(ospfRouter, new OspfLinkTedImpl());
- assertThat(controller, is(notNullValue()));
- }
-
- /**
- * Tests removeLinkDetails() method.
- */
- @Test
- public void testRemoveLinkDetails() throws Exception {
- ospfAgent = EasyMock.createMock(OspfAgent.class);
- controller.start(ospfAgent, driverService);
- ospfRouter = new OspfRouterImpl();
- controller.addLinkDetails(ospfRouter, new OspfLinkTedImpl());
- controller.removeLinkDetails(ospfRouter, new OspfLinkTedImpl());
- assertThat(controller, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/DeviceInformationImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/DeviceInformationImplTest.java
deleted file mode 100644
index a96d523..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/DeviceInformationImplTest.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for DeviceInformationImpl.
- */
-public class DeviceInformationImplTest {
-
- private DeviceInformationImpl deviceInformation;
-
- @Before
- public void setUp() throws Exception {
- deviceInformation = new DeviceInformationImpl();
- }
-
- @After
- public void tearDown() throws Exception {
- deviceInformation = null;
- }
-
- /**
- * Tests routerId() getter method.
- */
- @Test
- public void testRouterId() throws Exception {
- deviceInformation.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(deviceInformation.routerId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests routerId() setter method.
- */
- @Test
- public void testSetRouterId() throws Exception {
- deviceInformation.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(deviceInformation.routerId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests deviceId() getter method.
- */
- @Test
- public void testDeviceId() throws Exception {
- deviceInformation.setDeviceId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(deviceInformation.deviceId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests deviceId() getter method.
- */
- @Test
- public void testSetDeviceId() throws Exception {
- deviceInformation.setDeviceId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(deviceInformation.deviceId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests interfaceId() method.
- */
- @Test
- public void testInterfaceId() throws Exception {
- deviceInformation.addInterfaceId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(deviceInformation.interfaceId().size(), is(1));
- }
-
- /**
- * Tests addInterfaceId() method.
- */
- @Test
- public void testAddInterfaceId() throws Exception {
- deviceInformation.addInterfaceId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(deviceInformation.interfaceId().size(), is(1));
- }
-
- /**
- * Tests areaId() getter method.
- */
- @Test
- public void testAreaId() throws Exception {
- deviceInformation.setAreaId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(deviceInformation.areaId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests areaId() setter method.
- */
- @Test
- public void testSetAreaId() throws Exception {
- deviceInformation.setAreaId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(deviceInformation.areaId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests isAlreadyCreated() getter method.
- */
- @Test
- public void testIsAlreadyCreated() throws Exception {
- deviceInformation.setAlreadyCreated(true);
- assertThat(deviceInformation.isAlreadyCreated(), is(true));
- }
-
- /**
- * Tests isAlreadyCreated() setter method.
- */
- @Test
- public void testSetAlreadyCreated() throws Exception {
- deviceInformation.setAlreadyCreated(true);
- assertThat(deviceInformation.isAlreadyCreated(), is(true));
- }
-
- /**
- * Tests isDr() getter method.
- */
- @Test
- public void testIsDr() throws Exception {
- deviceInformation.setDr(true);
- assertThat(deviceInformation.isDr(), is(true));
- }
-
- /**
- * Tests isDr() setter method.
- */
- @Test
- public void testSetDr() throws Exception {
- deviceInformation.setDr(true);
- assertThat(deviceInformation.isDr(), is(true));
- }
-
- /**
- * Tests neighborId() getter method.
- */
- @Test
- public void testNeighborId() throws Exception {
- deviceInformation.setNeighborId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(deviceInformation.neighborId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests neighborId() setter method.
- */
- @Test
- public void testSetNeighborId() throws Exception {
- deviceInformation.setNeighborId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(deviceInformation.neighborId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/LinkInformationImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/LinkInformationImplTest.java
deleted file mode 100644
index e666c4e..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/LinkInformationImplTest.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for LinkInformationImpl.
- */
-public class LinkInformationImplTest {
-
- private LinkInformationImpl linkInformation;
-
- @Before
- public void setUp() throws Exception {
- linkInformation = new LinkInformationImpl();
- }
-
- @After
- public void tearDown() throws Exception {
- linkInformation = null;
- }
-
- /**
- * Tests linkId() getter method.
- */
- @Test
- public void testLinkId() throws Exception {
- linkInformation.setLinkId("1.1.1.1");
- assertThat(linkInformation.linkId(), is("1.1.1.1"));
- }
-
- /**
- * Tests linkId() setter method.
- */
- @Test
- public void testSetLinkId() throws Exception {
- linkInformation.setLinkId("1.1.1.1");
- assertThat(linkInformation.linkId(), is("1.1.1.1"));
- }
-
- /**
- * Tests isAlreadyCreated() getter method.
- */
- @Test
- public void testIsAlreadyCreated() throws Exception {
- linkInformation.setAlreadyCreated(true);
- assertThat(linkInformation.isAlreadyCreated(), is(true));
- }
-
- /**
- * Tests isAlreadyCreated() setter method.
- */
- @Test
- public void testSetAlreadyCreated() throws Exception {
- linkInformation.setAlreadyCreated(true);
- assertThat(linkInformation.isAlreadyCreated(), is(true));
- }
-
- /**
- * Tests isLinkSrcIdNotRouterId() getter method.
- */
- @Test
- public void testIsLinkSrcIdNotRouterId() throws Exception {
- linkInformation.setLinkSrcIdNotRouterId(true);
- assertThat(linkInformation.isLinkSrcIdNotRouterId(), is(true));
- }
-
- /**
- * Tests isLinkSrcIdNotRouterId() setter method.
- */
- @Test
- public void testSetLinkSrcIdNotRouterId() throws Exception {
- linkInformation.setLinkSrcIdNotRouterId(true);
- assertThat(linkInformation.isLinkSrcIdNotRouterId(), is(true));
- }
-
- /**
- * Tests linkDestinationId() getter method.
- */
- @Test
- public void testLinkDestinationId() throws Exception {
- linkInformation.setLinkDestinationId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(linkInformation.linkDestinationId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests linkDestinationId() setter method.
- */
- @Test
- public void testSetLinkDestinationId() throws Exception {
- linkInformation.setLinkDestinationId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(linkInformation.linkDestinationId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests linkSourceId() getter method.
- */
- @Test
- public void testLinkSourceId() throws Exception {
- linkInformation.setLinkSourceId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(linkInformation.linkSourceId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests linkSourceId() setter method.
- */
- @Test
- public void testSetLinkSourceId() throws Exception {
- linkInformation.setLinkSourceId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(linkInformation.linkSourceId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests interfaceIp() getter method.
- */
- @Test
- public void testInterfaceIp() throws Exception {
- linkInformation.setInterfaceIp(Ip4Address.valueOf("1.1.1.1"));
- assertThat(linkInformation.interfaceIp(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests interfaceIp() setter method.
- */
- @Test
- public void testSetInterfaceIp() throws Exception {
- linkInformation.setInterfaceIp(Ip4Address.valueOf("1.1.1.1"));
- assertThat(linkInformation.interfaceIp(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests linkSourceIpAddress() getter method.
- */
- @Test
- public void testLinkSourceIpAddress() throws Exception {
- linkInformation.setLinkSourceIpAddress(Ip4Address.valueOf("1.1.1.1"));
- assertThat(linkInformation.linkSourceIpAddress(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests linkSourceIpAddress() setter method.
- */
- @Test
- public void testSetLinkSourceIpAddress() throws Exception {
- linkInformation.setLinkSourceIpAddress(Ip4Address.valueOf("1.1.1.1"));
- assertThat(linkInformation.linkSourceIpAddress(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests linkDestinationId() getter method.
- */
- @Test
- public void testLinkDestinationIpAddress() throws Exception {
- linkInformation.setLinkDestinationIpAddress(Ip4Address.valueOf("1.1.1.1"));
- assertThat(linkInformation.linkDestinationIpAddress(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests linkDestinationId() setter method.
- */
- @Test
- public void testSetLinkDestinationIpAddress() throws Exception {
- linkInformation.setLinkDestinationIpAddress(Ip4Address.valueOf("1.1.1.1"));
- assertThat(linkInformation.linkDestinationIpAddress(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfConfigUtilTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfConfigUtilTest.java
deleted file mode 100644
index 4ac6dd9..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfConfigUtilTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onosproject.ospf.controller.OspfProcess;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for OspfJsonParsingUtilTest.
- */
-public class OspfConfigUtilTest {
- private ObjectMapper mapper;
- private JsonNode jsonNode;
- private List<OspfProcess> ospfProcessList = new ArrayList<>();
- private String jsonString = "{\n" +
- "\t\"processes\": {\n" +
- "\t\t\"areas\": [{\n" +
- "\t\t\t\"interface\": [{\n" +
- "\t\t\t\t\"interfaceIndex\": \"2\",\n" +
- "\n" +
- "\t\t\t\t\"helloIntervalTime\": \"10\",\n" +
- "\n" +
- "\t\t\t\t\"routerDeadIntervalTime\": \"40\",\n" +
- "\n" +
- "\t\t\t\t\"interfaceType\": \"2\",\n" +
- "\n" +
- "\t\t\t\t\"reTransmitInterval\": \"5\"\n" +
- "\t\t\t}],\n" +
- "\t\t\t\"areaId\": \"5.5.5.5\",\n" +
- "\n" +
- "\t\t\t\"routerId\": \"7.7.7.7\",\n" +
- "\n" +
- "\t\t\t\"isOpaqueEnable\": \"false\",\n" +
- "\n" +
- "\t\t\t\"externalRoutingCapability\": \"true\"\n" +
- "\t\t}]\n" +
- "\t}\n" +
- "}";
-
- @Before
- public void setUp() throws Exception {
- mapper = new ObjectMapper();
- jsonNode = mapper.readTree(jsonString);
- mapper = new ObjectMapper();
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
- @Test
- @Ignore
- // Disabling because it seems to have an external dependency that can cause
- // it to fail in some environments.
- public void testProcesses() throws Exception {
- jsonNode.path("areas");
- ospfProcessList = OspfConfigUtil.processes(jsonNode);
- assertThat(ospfProcessList, is(notNullValue()));
- }
-}
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfControllerImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfControllerImplTest.java
deleted file mode 100644
index b38ddfb..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfControllerImplTest.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfLinkListener;
-import org.onosproject.ospf.controller.OspfProcess;
-import org.onosproject.ospf.controller.OspfRouter;
-import org.onosproject.ospf.controller.OspfRouterListener;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.controller.area.OspfProcessImpl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for OspfRouterId.
- */
-public class OspfControllerImplTest {
-
- private OspfControllerImpl ospfController;
- private OspfRouterListener ospfRouterListener;
- private OspfLinkListener ospfLinkListener;
- private List<OspfProcess> ospfProcesses;
- private OspfProcess process1;
- private List<OspfArea> areas;
- private OspfAreaImpl ospfArea;
- private List<OspfInterface> ospfInterfaces;
- private OspfInterfaceImpl ospfInterface;
- private OspfProcess ospfProcess;
- private OspfArea ospfArea1;
- private OspfRouter ospfRouter;
-
- @Before
- public void setUp() throws Exception {
- ospfController = new OspfControllerImpl();
- }
-
- @After
- public void tearDown() throws Exception {
- ospfController = null;
- ospfRouterListener = null;
- ospfLinkListener = null;
- ospfProcesses = null;
- areas = null;
- ospfArea = null;
- ospfInterfaces = null;
- ospfInterface = null;
- ospfProcess = null;
- ospfProcess = null;
- ospfArea1 = null;
- ospfRouter = null;
- }
-
- /**
- * Tests activate() method.
- */
- @Test
- public void testActivate() throws Exception {
- ospfController.activate();
- assertThat(ospfController, is(notNullValue()));
- }
-
- @Test(expected = Exception.class)
- public void testDeactivate() throws Exception {
- ospfController.activate();
- ospfController.deactivate();
- assertThat(ospfController, is(notNullValue()));
- }
-
- /**
- * Tests addRouterListener() method.
- */
- @Test
- public void testAddRouterListener() throws Exception {
- ospfRouterListener = EasyMock.createMock(OspfRouterListener.class);
- ospfController.addRouterListener(ospfRouterListener);
- assertThat(ospfController, is(notNullValue()));
- }
-
- /**
- * Tests removeRouterListener() method.
- */
- @Test
- public void testRemoveRouterListener() throws Exception {
- ospfRouterListener = EasyMock.createMock(OspfRouterListener.class);
- ospfController.addRouterListener(ospfRouterListener);
- ospfController.removeRouterListener(ospfRouterListener);
- assertThat(ospfController, is(notNullValue()));
- }
-
- /**
- * Tests addLinkListener() method.
- */
- @Test
- public void testAddLinkListener() throws Exception {
- ospfLinkListener = EasyMock.createMock(OspfLinkListener.class);
- ospfController.addLinkListener(ospfLinkListener);
- assertThat(ospfController, is(notNullValue()));
- }
-
- /**
- * Tests removeLinkListener() method.
- */
- @Test
- public void testRemoveLinkListener() throws Exception {
- ospfLinkListener = EasyMock.createMock(OspfLinkListener.class);
- ospfController.addLinkListener(ospfLinkListener);
- ospfController.removeLinkListener(ospfLinkListener);
- assertThat(ospfController, is(notNullValue()));
- }
-
- /**
- * Tests deleteConfig() method.
- */
- @Test
- public void testDeleteConfig() throws Exception {
- ospfProcess = new OspfProcessImpl();
- ospfArea = new OspfAreaImpl();
- ospfInterface = new OspfInterfaceImpl();
- ospfInterfaces = new ArrayList();
- ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.5"));
- ospfInterfaces.add(ospfInterface);
- ospfArea.setAreaId(Ip4Address.valueOf("2.2.2.2"));
- ospfArea.setOspfInterfaceList(ospfInterfaces);
- ospfProcess.setProcessId("10.10.10.10");
- areas = new ArrayList();
- areas.add(ospfArea);
- ospfProcess.setAreas(areas);
- ospfProcesses = new ArrayList();
- ospfProcesses.add(ospfProcess);
- process1 = new OspfProcessImpl();
- process1.setProcessId("11.11.11.11");
- ospfArea1 = new OspfAreaImpl();
- ospfArea1.setAreaId(Ip4Address.valueOf("2.2.2.2"));
- ospfArea1.setOspfInterfaceList(ospfInterfaces);
- areas.add(ospfArea1);
- process1.setAreas(areas);
- ospfProcesses.add(process1);
- ospfController.deleteConfig(ospfProcesses, "INTERFACE");
- assertThat(ospfController, is(notNullValue()));
- }
-
- /**
- * Tests addLink() method.
- */
- @Test
- public void testAddLink() throws Exception {
- ospfRouter = new OspfRouterImpl();
-
- ospfController.agent.addLink(ospfRouter, new OspfLinkTedImpl());
- assertThat(ospfController, is(notNullValue()));
- }
-
- /**
- * Tests deleteLink() method.
- */
- @Test
- public void testDeleteLink() throws Exception {
- ospfRouter = new OspfRouterImpl();
-
- ospfController.agent.addLink(ospfRouter, new OspfLinkTedImpl());
- ospfController.agent.deleteLink(ospfRouter, new OspfLinkTedImpl());
- assertThat(ospfController, is(notNullValue()));
- }
-
- /**
- * Tests listener() method.
- */
- @Test
- public void testListener() throws Exception {
- assertThat(ospfController.listener().size(), is(0));
- }
-
- /**
- * Tests linkListener() method.
- */
- @Test
- public void testLinkListener() throws Exception {
- assertThat(ospfController.linkListener().size(), is(0));
- }
-
- /**
- * Tests addConnectedRouter() method.
- */
- @Test
- public void testaddConnectedRouter() throws Exception {
- ospfRouter = new OspfRouterImpl();
-
- ospfController.agent.addConnectedRouter(ospfRouter);
- assertThat(ospfController, is(notNullValue()));
- }
-
- /**
- * Tests removeConnectedRouter() method.
- */
- @Test
- public void testRemoveConnectedRouter() throws Exception {
- ospfRouter = new OspfRouterImpl();
-
- ospfController.agent.addConnectedRouter(ospfRouter);
- ospfController.agent.removeConnectedRouter(ospfRouter);
- assertThat(ospfController, is(notNullValue()));
- }
-
- /**
- * Tests getAllConfiguredProcesses() method.
- */
- @Test(expected = Exception.class)
- public void testGetAllConfiguredProcesses() throws Exception {
- assertThat(ospfController.getAllConfiguredProcesses().size(), is(0));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfDeviceTedImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfDeviceTedImplTest.java
deleted file mode 100644
index 1fe33d4..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfDeviceTedImplTest.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip6Address;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for OspfDeviceTedImpl.
- */
-public class OspfDeviceTedImplTest {
- private OspfDeviceTedImpl ospfDeviceTed;
-
- @Before
- public void setUp() throws Exception {
- ospfDeviceTed = new OspfDeviceTedImpl();
- }
-
- @After
- public void tearDown() throws Exception {
- ospfDeviceTed = null;
- }
-
- /**
- * Tests ipv4RouterIds() getter method.
- */
- @Test
- public void testIpv4RouterIds() throws Exception {
- List list = new ArrayList();
- list.add(Ip4Address.valueOf("1.1.1.1"));
- ospfDeviceTed.setIpv4RouterIds(list);
- assertThat(ospfDeviceTed.ipv4RouterIds().size(), is(1));
- }
-
- /**
- * Tests ipv4RouterIds() setter method.
- */
- @Test
- public void testSetIpv4RouterIds() throws Exception {
- List list = new ArrayList();
- list.add(Ip4Address.valueOf("1.1.1.1"));
- ospfDeviceTed.setIpv4RouterIds(list);
- assertThat(ospfDeviceTed.ipv4RouterIds().size(), is(1));
- }
-
- /**
- * Tests abr() getter method.
- */
- @Test
- public void testAbr() throws Exception {
- ospfDeviceTed.setAbr(true);
- assertThat(ospfDeviceTed.abr(), is(true));
- }
-
- /**
- * Tests abr() setter method.
- */
- @Test
- public void testSetAbr() throws Exception {
- ospfDeviceTed.setAbr(true);
- assertThat(ospfDeviceTed.abr(), is(true));
- }
-
- /**
- * Tests asbr() getter method.
- */
- @Test
- public void testAsbr() throws Exception {
- ospfDeviceTed.setAsbr(true);
- assertThat(ospfDeviceTed.asbr(), is(true));
- }
-
- /**
- * Tests asbr() setter method.
- */
- @Test
- public void testSetAsbr() throws Exception {
- ospfDeviceTed.setAsbr(true);
- assertThat(ospfDeviceTed.asbr(), is(true));
- }
-
- /**
- * Tests topologyIds() getter method.
- */
- @Test
- public void testTopologyIds() throws Exception {
- List list = new ArrayList();
- list.add(Ip4Address.valueOf("1.1.1.1"));
- ospfDeviceTed.setTopologyIds(list);
- assertThat(ospfDeviceTed.topologyIds().size(), is(1));
- }
-
- /**
- * Tests topologyIds() setter method.
- */
- @Test
- public void testSetTopologyIds() throws Exception {
- List list = new ArrayList();
- list.add(Ip4Address.valueOf("1.1.1.1"));
- ospfDeviceTed.setTopologyIds(list);
- assertThat(ospfDeviceTed.topologyIds().size(), is(1));
- }
-
- /**
- * Tests ipv6RouterIds() getter method.
- */
- @Test
- public void testIpv6RouterIds() throws Exception {
- List list = new ArrayList();
- list.add(Ip6Address.valueOf(1));
- ospfDeviceTed.setIpv6RouterIds(list);
- assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1));
- }
-
- /**
- * Tests ipv6RouterIds() setter method.
- */
- @Test
- public void testSetIpv6RouterIds() throws Exception {
- List list = new ArrayList();
- list.add(Ip6Address.valueOf(1));
- ospfDeviceTed.setIpv6RouterIds(list);
- assertThat(ospfDeviceTed.ipv6RouterIds().size(), is(1));
- }
-}
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandlerTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandlerTest.java
deleted file mode 100644
index 49a7435..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandlerTest.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelFuture;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelStateEvent;
-import org.jboss.netty.channel.ExceptionEvent;
-import org.jboss.netty.channel.MessageEvent;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfAreaAddressRange;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.controller.OspfNeighborState;
-import org.onosproject.ospf.controller.OspfProcess;
-import org.onosproject.ospf.controller.TopologyForDeviceAndLink;
-import org.onosproject.ospf.controller.area.OspfAreaAddressRangeImpl;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.controller.area.OspfProcessImpl;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
-import org.onosproject.ospf.protocol.util.ChecksumCalculator;
-
-import java.net.SocketAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-
-/**
- * Unit test class for OspfInterfaceChannelHandler.
- */
-public class OspfInterfaceChannelHandlerTest {
- private final String string1 = "2.2.2.2";
- private List<OspfAreaAddressRange> addressRanges = new ArrayList();
- private List<OspfInterface> ospfInterfaces = new ArrayList<>();
- private Controller controller;
- private OspfAreaImpl ospfArea;
- private OspfInterfaceImpl ospfInterface;
- private OspfInterfaceChannelHandler ospfInterfaceChannelHandler;
- private OspfNbrImpl ospfNbr;
- private ChannelHandlerContext channelHandlerContext;
- private ChannelStateEvent channelStateEvent;
- private TopologyForDeviceAndLink topologyForDeviceAndLink;
- private List<OspfProcess> ospfProcesses = new ArrayList<>();
- private OspfProcess ospfProcess;
- private Ip4Address ip4Address1 = Ip4Address.valueOf("10.10.10.10");
- private Ip4Address ip4Address2 = Ip4Address.valueOf("2.2.2.2");
- private Ip4Address ip4Address3 = Ip4Address.valueOf("13.13.13.13");
- private Ip4Address ip4Address4 = Ip4Address.valueOf("111.111.111.111");
- private Ip4Address ip4Address5 = Ip4Address.valueOf("10.226.165.164");
- private Ip4Address ip4Address6 = Ip4Address.valueOf("1.1.1.1");
- private Ip4Address ip4Address7 = Ip4Address.valueOf("10.226.165.100");
- private Ip4Address subnetAddress = Ip4Address.valueOf("255.255.255.255");
- private byte[] byteArray;
- private byte[] checkArray;
- private HelloPacket helloPacket;
- private ChecksumCalculator checksumCalculator;
- private ChannelBuffer buf;
- private List<OspfArea> ospfAreas = new ArrayList<>();
-
- @Before
- public void setUp() throws Exception {
- ospfProcess = new OspfProcessImpl();
- ospfArea = createOspfArea();
- ospfAreas.add(ospfArea);
- ospfProcess.setAreas(ospfAreas);
- ospfProcesses.add(ospfProcess);
- controller = new Controller();
- topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, ip4Address1,
- ip4Address2, 2, topologyForDeviceAndLink);
- ospfNbr.setNeighborId(ip4Address1);
- ospfNbr.setRouterPriority(0);
- ospfNbr.setNeighborDr(ip4Address3);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- ospfInterfaceChannelHandler = new OspfInterfaceChannelHandler(controller, ospfProcesses);
- }
-
- @After
- public void tearDown() throws Exception {
- ospfInterfaceChannelHandler = null;
- ospfInterfaceChannelHandler = null;
- ospfInterface = null;
- channelHandlerContext = null;
- channelStateEvent = null;
- }
-
- /**
- * Tests channelConnected() method.
- */
- @Test(expected = Exception.class)
- public void testChannelConnected() throws Exception {
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- channelStateEvent = EasyMock.createMock(ChannelStateEvent.class);
- ospfInterfaceChannelHandler.channelConnected(channelHandlerContext, channelStateEvent);
- }
-
- /**
- * Tests exceptionCaught() method.
- */
- @Test(expected = Exception.class)
- public void testExceptionCaught() throws Exception {
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- ExceptionEvent exception = EasyMock.createMock(ExceptionEvent.class);
- ospfInterfaceChannelHandler.exceptionCaught(channelHandlerContext, exception);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests channelDisconnected() method.
- */
- @Test
- public void testChannelDisconnected() throws Exception {
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- channelStateEvent = EasyMock.createMock(ChannelStateEvent.class);
- ospfInterfaceChannelHandler.channelDisconnected(channelHandlerContext, channelStateEvent);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests initializeInterfaceMap() method.
- */
- @Test
- public void testInitializeInterfaceMap() throws Exception {
- ospfInterfaceChannelHandler.initializeInterfaceMap();
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
- }
-
- /**
- * Tests updateInterfaceMap() method.
- */
- @Test
- public void testUpdateInterfaceMap() throws Exception {
- ospfInterfaceChannelHandler.updateInterfaceMap(ospfProcesses);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
- }
-
- /**
- * Utility for test method.
- */
- private OspfAreaImpl createOspfArea() throws Exception {
- OspfAreaAddressRangeImpl ospfAreaAddressRange;
- ospfAreaAddressRange = createOspfAreaAddressRange();
- addressRanges.add(ospfAreaAddressRange);
- OspfAreaImpl ospfArea = new OspfAreaImpl();
- ospfArea.setAreaId(ip4Address5);
- ospfArea.setExternalRoutingCapability(true);
- OspfInterfaceImpl ospfInterface = createOspfInterface();
- ospfInterfaces.add(ospfInterface);
- ospfArea.setOspfInterfaceList(ospfInterfaces);
- RouterLsa routerLsa = new RouterLsa();
- routerLsa.setLsType(1);
- routerLsa.setLinkStateId(string1);
- routerLsa.setAdvertisingRouter(ip4Address2);
- ospfArea.addLsa(routerLsa, false, ospfInterface);
- ospfArea.setRouterId(ip4Address4);
-
- return ospfArea;
- }
-
- /**
- * Utility for test method.
- */
- private OspfAreaAddressRangeImpl createOspfAreaAddressRange() {
- OspfAreaAddressRangeImpl ospfAreaAddressRange = new OspfAreaAddressRangeImpl();
- ospfAreaAddressRange.setIpAddress(ip4Address5);
- ospfAreaAddressRange.setAdvertise(true);
- ospfAreaAddressRange.setMask("mask");
- return ospfAreaAddressRange;
- }
-
- /**
- * Tests messageReceived() method.
- */
- @Test
- public void testMessageReceived() throws Exception {
- ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
- ospfInterface.setInterfaceType(2);
- ospfArea.setAreaId(Ip4Address.valueOf("13.13.13.13"));
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- MessageEvent messageEvent = new MessageEvent() {
- @Override
- public Object getMessage() {
- helloPacket = new HelloPacket();
- helloPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- helloPacket.setRouterId(Ip4Address.valueOf("10.10.10.10"));
- helloPacket.setOspfVer(2);
- helloPacket.setAreaId(Ip4Address.valueOf("12.12.12.12"));
- helloPacket.setOptions(2);
- helloPacket.setAreaId(Ip4Address.valueOf("5.5.5.5"));
- helloPacket.setNetworkMask(Ip4Address.valueOf("3.3.3.3"));
- helloPacket.setOspftype(1);
- helloPacket.setAuthType(0);
- helloPacket.setAuthentication(0);
- checksumCalculator = new ChecksumCalculator();
- byteArray = helloPacket.asBytes();
- helloPacket.setOspfPacLength(byteArray.length);
- checkArray = checksumCalculator.calculateOspfCheckSum(byteArray, 12, 13);
- buf = ChannelBuffers.copiedBuffer(checkArray);
- helloPacket.setChecksum(buf.readUnsignedShort());
- List<HelloPacket> messPackets = new ArrayList<>();
- messPackets.add(helloPacket);
- return messPackets;
- }
-
- @Override
- public SocketAddress getRemoteAddress() {
- return null;
- }
-
- @Override
- public Channel getChannel() {
- return null;
- }
-
- @Override
- public ChannelFuture getFuture() {
- return null;
- }
- };
- ospfInterfaceChannelHandler.messageReceived(channelHandlerContext, messageEvent);
- assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
- }
-
- /**
- * Utility for test method.
- */
- private OspfInterfaceImpl createOspfInterface1() throws UnknownHostException {
- ospfInterface = new OspfInterfaceImpl();
- OspfAreaImpl ospfArea = new OspfAreaImpl();
- OspfInterfaceChannelHandler ospfInterfaceChannelHandler = EasyMock.createMock(
- OspfInterfaceChannelHandler.class);
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, ip4Address5,
- ip4Address6, 2, topologyForDeviceAndLink);
- ospfNbr.setState(OspfNeighborState.FULL);
- ospfNbr.setNeighborId(ip4Address7);
- ospfInterface = new OspfInterfaceImpl();
- ospfInterface.setIpAddress(ip4Address5);
- ospfInterface.setIpNetworkMask(subnetAddress);
- ospfInterface.setBdr(ip4Address4);
- ospfInterface.setDr(ip4Address4);
- ospfInterface.setHelloIntervalTime(20);
- ospfInterface.setInterfaceType(2);
- ospfInterface.setReTransmitInterval(2000);
- ospfInterface.setMtu(6500);
- ospfInterface.setRouterDeadIntervalTime(1000);
- ospfInterface.setRouterPriority(1);
- ospfInterface.setInterfaceType(1);
- ospfInterface.addNeighbouringRouter(ospfNbr);
- return ospfInterface;
- }
-
- /**
- * Utility for test method.
- */
- private OspfInterfaceImpl createOspfInterface() throws Exception {
- ospfInterface = new OspfInterfaceImpl();
- LsaHeader lsaHeader = new LsaHeader();
- lsaHeader.setLsType(OspfLsaType.ROUTER.value());
- RouterLsa routerLsa = new RouterLsa();
- OspfAreaImpl ospfArea = new OspfAreaImpl();
- ospfArea.addLsa(routerLsa, true, ospfInterface);
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, ip4Address5,
- ip4Address6, 2, topologyForDeviceAndLink);
- ospfNbr.setState(OspfNeighborState.EXSTART);
- ospfNbr.setNeighborId(ip4Address7);
- this.ospfInterface = new OspfInterfaceImpl();
- this.ospfInterface.setIpAddress(ip4Address5);
- this.ospfInterface.setIpNetworkMask(subnetAddress);
- this.ospfInterface.setBdr(ip4Address4);
- this.ospfInterface.setDr(ip4Address4);
- this.ospfInterface.setHelloIntervalTime(20);
- this.ospfInterface.setInterfaceType(2);
- this.ospfInterface.setReTransmitInterval(2000);
- this.ospfInterface.setMtu(6500);
- this.ospfInterface.setRouterDeadIntervalTime(1000);
- this.ospfInterface.setRouterPriority(1);
- this.ospfInterface.setInterfaceType(1);
- this.ospfInterface.setInterfaceIndex(1);
- this.ospfInterface.addNeighbouringRouter(ospfNbr);
- this.ospfInterface.setOspfArea(ospfArea);
- return this.ospfInterface;
- }
-
- /**
- * Utility for test method.
- */
- private DdPacket createDdPacket() throws OspfParseException {
- byte[] ddPacket = {2, 2, 0, 32, -64, -88, -86, 8, 0, 0, 0, 1, -96, 82,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, -36, 2, 7, 65, 119, -87, 126};
- DdPacket ddPacket1 = new DdPacket();
- ChannelBuffer buf = ChannelBuffers.buffer(ddPacket.length);
- buf.writeBytes(ddPacket);
- ddPacket1.readFrom(buf);
- return ddPacket1;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfLinkTedImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfLinkTedImplTest.java
deleted file mode 100644
index 87fc853..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfLinkTedImplTest.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onlab.util.Bandwidth;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for OspfDeviceTedImpl.
- */
-public class OspfLinkTedImplTest {
- private OspfLinkTedImpl ospfLinkTed;
-
- @Before
- public void setUp() throws Exception {
- ospfLinkTed = new OspfLinkTedImpl();
- }
-
- @After
- public void tearDown() throws Exception {
- ospfLinkTed = null;
- }
-
- /**
- * Tests maximumLink() getter method.
- */
- @Test
- public void testMaximumLink() throws Exception {
-
- ospfLinkTed.setMaximumLink(Bandwidth.bps(1234));
- assertThat(ospfLinkTed.maximumLink(), is(Bandwidth.bps(1234)));
- }
-
- /**
- * Tests maximumLink() setter method.
- */
- @Test
- public void testSetMaximumLink() throws Exception {
- ospfLinkTed.setMaximumLink(Bandwidth.bps(1234));
- assertThat(ospfLinkTed.maximumLink(), is(Bandwidth.bps(1234)));
- }
-
- /**
- * Tests ipv6RemRouterId() getter method.
- */
- @Test
- public void testIpv6RemRouterId() throws Exception {
- List list = new ArrayList();
- ospfLinkTed.setIpv6RemRouterId(list);
- assertThat(ospfLinkTed.ipv6RemRouterId().size(), is(0));
- }
-
- /**
- * Tests ipv6RemRouterId() setter method.
- */
- @Test
- public void testSetIpv6RemRouterId() throws Exception {
- List list = new ArrayList();
- ospfLinkTed.setIpv6RemRouterId(list);
- assertThat(ospfLinkTed.ipv6RemRouterId().size(), is(0));
- }
-
- /**
- * Tests ipv4RemRouterId() getter method.
- */
- @Test
- public void testIpv4RemRouterId() throws Exception {
- List list = new ArrayList();
- list.add(Ip4Address.valueOf(1));
- ospfLinkTed.setIpv4RemRouterId(list);
- assertThat(ospfLinkTed.ipv4RemRouterId().size(), is(1));
- }
-
- /**
- * Tests ipv4RemRouterId() setter method.
- */
- @Test
- public void testSetIpv4RemRouterId() throws Exception {
- List list = new ArrayList();
- list.add(Ip4Address.valueOf(1));
- ospfLinkTed.setIpv4RemRouterId(list);
- assertThat(ospfLinkTed.ipv4RemRouterId().size(), is(1));
- }
-
- /**
- * Tests ipv6LocRouterId() getter method.
- */
- @Test
- public void testIpv6LocRouterId() throws Exception {
- List list = new ArrayList();
- ospfLinkTed.setIpv4LocRouterId(list);
- assertThat(ospfLinkTed.ipv6LocRouterId().size(), is(0));
- }
-
- /**
- * Tests ipv6LocRouterId() setter method.
- */
- @Test
- public void testSetIpv6LocRouterId() throws Exception {
- List list = new ArrayList();
- ospfLinkTed.setIpv4LocRouterId(list);
- assertThat(ospfLinkTed.ipv6LocRouterId().size(), is(0));
- }
-
- /**
- * Tests ipv4LocRouterId() getter method.
- */
- @Test
- public void testIpv4LocRouterId() throws Exception {
- List list = new ArrayList();
- list.add(Ip4Address.valueOf(1));
- ospfLinkTed.setIpv4LocRouterId(list);
- assertThat(ospfLinkTed.ipv4LocRouterId().size(), is(1));
- }
-
- /**
- * Tests ipv4LocRouterId() setter method.
- */
- @Test
- public void testSetIpv4LocRouterId() throws Exception {
- List list = new ArrayList();
- list.add(Ip4Address.valueOf(1));
- ospfLinkTed.setIpv4LocRouterId(list);
- assertThat(ospfLinkTed.ipv4LocRouterId().size(), is(1));
- }
-
- /**
- * Tests teMetric() getter method.
- */
- @Test
- public void testTeMetric() throws Exception {
- ospfLinkTed.setTeMetric(1234);
- assertThat(ospfLinkTed.teMetric(), is(1234));
- }
-
- /**
- * Tests teMetric() setter method.
- */
- @Test
- public void testSetTeMetric() throws Exception {
- ospfLinkTed.setTeMetric(1234);
- assertThat(ospfLinkTed.teMetric(), is(1234));
- }
-
- /**
- * Tests maxReserved() getter method.
- */
- @Test
- public void testMaxReserved() throws Exception {
- ospfLinkTed.setMaxReserved(Bandwidth.bps(1234));
- assertThat(ospfLinkTed.maxReserved(), is(Bandwidth.bps(1234)));
- }
-
- /**
- * Tests maxReserved() setter method.
- */
- @Test
- public void testSetMaxReserved() throws Exception {
- ospfLinkTed.setMaxReserved(Bandwidth.bps(1234));
- assertThat(ospfLinkTed.maxReserved(), is(Bandwidth.bps(1234)));
- }
-
- /**
- * Tests maxUnResBandwidth() getter method.
- */
- @Test
- public void testMaxUnResBandwidth() throws Exception {
- ospfLinkTed.setMaxUnResBandwidth(Bandwidth.bps(1234));
- assertThat(ospfLinkTed.maxUnResBandwidth(), is(notNullValue()));
- }
-
- /**
- * Tests maxUnResBandwidth() setter method.
- */
- @Test
- public void testSetMaxUnResBandwidth() throws Exception {
- ospfLinkTed.setMaxUnResBandwidth(Bandwidth.bps(1234.0));
- assertThat(ospfLinkTed.maxUnResBandwidth(), is(notNullValue()));
- }
-}
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageDecoderTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageDecoderTest.java
deleted file mode 100644
index a7dd372..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageDecoderTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for OspfMessageDecoder.
- */
-public class OspfMessageDecoderTest {
-
- private final byte[] hellopacket = {0, 0, 0, 0, 0, 2, 1, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, 39, 59,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 10, 2, 1, 0, 0, 0,
- 40, -64, -88, -86, 8, 0, 0, 0, 0};
- private final byte[] ddpacket = {0, 0, 0, 0, 2, 2, 0, 32, -64, -88, -86, 8, 0, 0, 0, 1, -96, 82,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, -36, 2, 7, 65, 119, -87, 126};
- private final byte[] ddpacket44 = {0, 0, 0, 0, 2, 2, 0, 10, -64, -88};
- private final byte[] lsAckpacket = {0, 0, 0, 0, 2, 5, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, -30, -12,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 16, 2, 1, -64, -88, -86, 2, -64,
- -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48};
- private final byte[] lsUpdatePacket = {0, 0, 0, 0, 2, 4, 0, 76, -64, -88, -86, 3, 0, 0, 0, 1, 7, 111,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 14, 16, 2, 1, -64, -88,
- -86, 2, -64, -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48, 2, 0, 0, 2,
- -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10, -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10};
- private final byte[] lsRequestPacket = {0, 0, 0, 0, 2, 3, 0, 36, -64, -88, -86, 3, 0, 0, 0, 1, -67, -57,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -64, -88, -86, 8, -64, -88, -86, 8};
- private OspfMessageDecoder ospfMessageDecoder;
- private ChannelHandlerContext ctx;
- private Channel channel;
- private SocketAddress socketAddress;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- ospfMessageDecoder = new OspfMessageDecoder();
- }
-
- @After
- public void tearDown() throws Exception {
- ospfMessageDecoder = null;
- channel = null;
- socketAddress = null;
- channelBuffer = null;
- }
-
- /**
- * Tests decode() method.
- */
- @Test
- public void testDecode() throws Exception {
- channel = EasyMock.createMock(Channel.class);
- socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 7000);
- channelBuffer = ChannelBuffers.copiedBuffer(hellopacket);
- ospfMessageDecoder.decode(ctx, channel, channelBuffer);
- assertThat(ospfMessageDecoder, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageEncoderTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageEncoderTest.java
deleted file mode 100644
index c356877..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageEncoderTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-
-import org.easymock.EasyMock;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Created by sdn on 13/1/16.
- */
-public class OspfMessageEncoderTest {
-
- private final byte[] object = {2, 1, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, 39,
- 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 10, 2, 1, 0, 0,
- 0, 40, -64, -88, -86, 8, 0, 0, 0, 0};
- private OspfMessageEncoder ospfMessageEncoder;
- private ChannelHandlerContext channelHandlerContext;
- private Channel channel;
-
- @Before
- public void setUp() throws Exception {
- ospfMessageEncoder = new OspfMessageEncoder();
- channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class);
- channel = EasyMock.createMock(Channel.class);
- }
-
- @After
- public void tearDown() throws Exception {
- ospfMessageEncoder = null;
- }
-
- /**
- * Tests encode() method.
- */
- @Test
- public void testEncode() throws Exception {
- assertThat(ospfMessageEncoder.encode(channelHandlerContext, channel, object), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfNbrImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfNbrImplTest.java
deleted file mode 100644
index 25e2ac6..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfNbrImplTest.java
+++ /dev/null
@@ -1,768 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-
-import org.easymock.EasyMock;
-import org.jboss.netty.channel.Channel;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfAreaAddressRange;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfLsa;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.controller.OspfMessage;
-import org.onosproject.ospf.controller.OspfNeighborState;
-import org.onosproject.ospf.controller.TopologyForDeviceAndLink;
-import org.onosproject.ospf.controller.area.OspfAreaAddressRangeImpl;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.controller.lsdb.LsaWrapperImpl;
-import org.onosproject.ospf.controller.lsdb.LsdbAgeImpl;
-import org.onosproject.ospf.controller.util.OspfInterfaceType;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
-import org.onosproject.ospf.protocol.util.ChecksumCalculator;
-import org.onosproject.ospf.protocol.util.OspfInterfaceState;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-
-import java.net.SocketAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for OspfNbrImpl.
- */
-public class OspfNbrImplTest {
- private List<OspfAreaAddressRange> addressRanges = new ArrayList();
- private OspfNbrImpl ospfNbr;
- private OspfNbrImpl ospfNbr1;
- private OspfInterfaceImpl ospfInterface;
- private OspfAreaImpl ospfArea;
- private OspfInterfaceImpl ospfInterface1;
- private OspfInterfaceImpl ospfInterface2;
- private List<OspfInterface> ospfInterfaces = new ArrayList();
- private List<OspfLsa> ospfLsaList;
- private Channel channel;
- private Channel channel1;
- private Channel channel2;
- private OspfMessage ospfMessage;
- private TopologyForDeviceAndLink topologyForDeviceAndLink;
- private LsaHeader lsaHeader;
-
- @Before
- public void setUp() throws Exception {
- lsaHeader = new LsaHeader();
- lsaHeader.setLsType(OspfLsaType.ROUTER.value());
- RouterLsa routerLsa = new RouterLsa(lsaHeader);
- routerLsa.setLsType(OspfLsaType.ROUTER.value());
- ospfInterface = new OspfInterfaceImpl();
- ospfInterface.setInterfaceType(2);
- ospfInterface.setInterfaceIndex(1);
- ospfInterface.setRouterDeadIntervalTime(30);
- ospfInterface.setReTransmitInterval(30);
- ospfInterface.setDr(Ip4Address.valueOf("1.1.1.1"));
- ospfInterface.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- ospfInterface.setState(OspfInterfaceState.POINT2POINT);
- ospfArea = createOspfArea();
- ospfArea.addLsa(routerLsa, true, ospfInterface);
- ospfInterface.setOspfArea(ospfArea);
- ospfInterface1 = new OspfInterfaceImpl();
- ospfInterface1.setInterfaceType(2);
- ospfInterface1.setInterfaceIndex(1);
- ospfInterface1.setRouterDeadIntervalTime(30);
- ospfInterface1.setReTransmitInterval(30);
- ospfInterface1.setDr(Ip4Address.valueOf("7.7.7.7"));
- ospfInterface1.setIpAddress(Ip4Address.valueOf("7.7.7.7"));
- ospfInterface1.setState(OspfInterfaceState.DOWN);
- ospfInterface1.setOspfArea(ospfArea);
- ospfInterface2 = new OspfInterfaceImpl();
- ospfInterface2.setInterfaceType(2);
- ospfInterface2.setInterfaceIndex(1);
- ospfInterface2.setRouterDeadIntervalTime(30);
- ospfInterface2.setReTransmitInterval(30);
- ospfInterface2.setDr(Ip4Address.valueOf("6.6.6.6"));
- ospfInterface2.setIpAddress(Ip4Address.valueOf("6.6.6.6"));
- ospfInterface2.setOspfArea(ospfArea);
- ospfInterface1.setState(OspfInterfaceState.DR);
- ospfInterfaces = new ArrayList();
- ospfInterfaces.add(ospfInterface);
- ospfInterfaces.add(ospfInterface1);
- ospfInterfaces.add(ospfInterface2);
- ospfArea.setOspfInterfaceList(ospfInterfaces);
- ospfInterface.setState(OspfInterfaceState.POINT2POINT);
- ospfArea.setRouterId(Ip4Address.valueOf("111.111.111.111"));
- topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("1.1.1.1"),
- Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- }
-
- @After
- public void tearDown() throws Exception {
- ospfNbr = null;
- ospfArea = null;
- ospfInterface = null;
- ospfLsaList = null;
- channel = null;
- channel1 = null;
- channel2 = null;
- ospfMessage = null;
-
- }
-
- /**
- * Tests neighborIpAddr() method.
- */
- @Test
- public void testNeighborIpAddr() throws Exception {
- assertThat(ospfNbr.neighborIpAddr(), is(notNullValue()));
- }
-
- /**
- * Tests isOpaqueCapable() getter method.
- */
- @Test
- public void testIsOpaqueCapable() throws Exception {
- assertThat(ospfNbr.isOpaqueCapable(), is(false));
- }
-
- /**
- * Tests isOpaqueCapable() setter method.
- */
- @Test
- public void testSetIsOpaqueCapable() throws Exception {
- ospfNbr.setIsOpaqueCapable(true);
- assertThat(ospfNbr.isOpaqueCapable(), is(true));
- }
-
- /**
- * Tests oneWayReceived() method.
- */
- @Test
- public void testOneWayReceived() throws Exception {
- ospfMessage = new HelloPacket();
- ospfNbr.setState(OspfNeighborState.ATTEMPT);
- channel = EasyMock.createMock(Channel.class);
- ospfNbr.oneWayReceived(ospfMessage, channel);
- channel1 = EasyMock.createMock(Channel.class);
- ospfNbr.setState(OspfNeighborState.DOWN);
- ospfNbr.oneWayReceived(ospfMessage, channel1);
- channel2 = EasyMock.createMock(Channel.class);
- ospfNbr.setState(OspfNeighborState.TWOWAY);
- ospfNbr.oneWayReceived(ospfMessage, channel2);
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests twoWayReceived() method.
- */
- @Test(expected = Exception.class)
- public void testTwoWayReceived() throws Exception {
- ospfNbr.setNeighborDr(Ip4Address.valueOf("1.1.1.1"));
- ospfMessage = new HelloPacket();
- ospfNbr.setState(OspfNeighborState.ATTEMPT);
- ospfNbr.setNeighborDr(Ip4Address.valueOf("2.2.2.2"));
- ospfInterface.setIpAddress(Ip4Address.valueOf("2.2.2.2"));
- channel = EasyMock.createMock(Channel.class);
- SocketAddress socketAddress = EasyMock.createMock(SocketAddress.class);
- channel.bind(socketAddress);
- ospfNbr.twoWayReceived(ospfMessage, channel);
- ospfInterface.setIpAddress(Ip4Address.valueOf("3.3.3.3"));
- channel1 = EasyMock.createMock(Channel.class);
- ospfNbr.twoWayReceived(ospfMessage, channel1);
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests negotiationDone() method.
- */
- @Test
- public void testNegotiationDone() throws Exception {
-
- ospfLsaList = new ArrayList();
- RouterLsa routerLsa = new RouterLsa();
- routerLsa.setLsType(OspfLsaType.ROUTER.value());
- ospfLsaList.add(routerLsa);
- DdPacket ddPacket = new DdPacket();
- ddPacket.setIsOpaqueCapable(true);
- ospfMessage = ddPacket;
- ospfNbr.setState(OspfNeighborState.EXSTART);
- ospfNbr.setIsOpaqueCapable(true);
- channel = null;
- channel = EasyMock.createMock(Channel.class);
- ospfNbr.negotiationDone(ospfMessage, true, ospfLsaList, channel);
- channel1 = EasyMock.createMock(Channel.class);
- ospfNbr.negotiationDone(ospfMessage, false, ospfLsaList, channel1);
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests processLsas() method.
- */
- @Test
- public void testProcessLsas() throws Exception {
- ospfLsaList = new ArrayList();
- RouterLsa routerLsa = new RouterLsa();
- routerLsa.setLsType(1);
- ospfLsaList.add(routerLsa);
- NetworkLsa networkLsa = new NetworkLsa();
- routerLsa.setLsType(2);
- ospfLsaList.add(networkLsa);
- routerLsa.setLsType(3);
- ospfLsaList.add(routerLsa);
- ospfNbr.processLsas(ospfLsaList);
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests seqNumMismatch() method.
- */
- @Test
- public void testSeqNumMismatch() throws Exception {
- ospfNbr.setState(OspfNeighborState.FULL);
- assertThat(ospfNbr.seqNumMismatch("samelsa"), is(notNullValue()));
- }
-
- /**
- * Tests badLSReq() method.
- */
- @Test
- public void testBadLSReq() throws Exception {
- channel = EasyMock.createMock(Channel.class);
- ospfNbr.setState(OspfNeighborState.EXCHANGE);
- ospfNbr.badLSReq(channel);
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests processDdPacket() method.
- */
- @Test
- public void testProcessDdPacket() throws Exception {
- ospfArea.addLsa(new RouterLsa(), false, ospfInterface);
- ospfArea.addLsa(new RouterLsa(), ospfInterface);
- ospfArea.addLsaToMaxAgeBin("lsa", new LsaWrapperImpl());
- channel = EasyMock.createMock(Channel.class);
- DdPacket ddPacket = new DdPacket();
- ddPacket.addLsaHeader(new LsaHeader());
- ospfNbr.processDdPacket(true, ddPacket, channel);
- channel1 = EasyMock.createMock(Channel.class);
- ddPacket.setIsMore(1);
- ospfNbr.processDdPacket(false, ddPacket, channel1);
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests exchangeDone() method.
- */
- @Test
- public void testExchangeDone() throws Exception {
- ospfMessage = new HelloPacket();
- channel = EasyMock.createMock(Channel.class);
- ospfNbr.setState(OspfNeighborState.EXCHANGE);
- ospfNbr.exchangeDone(ospfMessage, channel);
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests exchangeDone() method.
- */
- @Test
- public void testExchangeDone1() throws Exception {
- ospfMessage = new HelloPacket();
- channel = EasyMock.createMock(Channel.class);
- ospfNbr.setState(OspfNeighborState.EXCHANGE);
- ospfLsaList = new ArrayList();
- RouterLsa routerLsa = new RouterLsa();
- routerLsa.setLsType(1);
- ospfLsaList.add(routerLsa);
- NetworkLsa networkLsa = new NetworkLsa();
- routerLsa.setLsType(2);
- ospfLsaList.add(networkLsa);
- routerLsa.setLsType(3);
- ospfLsaList.add(routerLsa);
- ospfNbr.processLsas(ospfLsaList);
- ospfNbr.setState(OspfNeighborState.EXCHANGE);
- ospfNbr.exchangeDone(ospfMessage, channel);
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests adjOk() method.
- */
- @Test
- public void testAdjOk() throws Exception {
- channel = EasyMock.createMock(Channel.class);
- ospfInterface.setInterfaceType(OspfInterfaceType.BROADCAST.value());
- ospfInterface.setIpAddress(Ip4Address.valueOf("2.2.2.2"));
- ospfNbr1 = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("1.1.1.1"),
- Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- ospfNbr1.setState(OspfNeighborState.TWOWAY);
- ospfNbr1.setNeighborDr(Ip4Address.valueOf("2.2.2.2"));
- ospfNbr1.adjOk(channel);
- assertThat(ospfNbr1, is(notNullValue()));
-
- ospfInterface.setInterfaceType(OspfInterfaceType.POINT_TO_POINT.value());
- ospfNbr1 = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("1.1.1.1"),
- Ip4Address.valueOf("2.2.2.2"), 2,
- topologyForDeviceAndLink);
- channel = null;
- channel = EasyMock.createMock(Channel.class);
- ospfNbr1.adjOk(channel);
- assertThat(ospfNbr1, is(notNullValue()));
- }
-
- /**
- * Tests processLsUpdate() method.
- */
- @Test
- public void testProcessLsUpdate() throws Exception {
- LsUpdate ospfMessage = new LsUpdate();
- ospfMessage.setSourceIp(Ip4Address.valueOf("10.10.10.10"));
- ospfMessage.addLsa(new RouterLsa());
- ospfMessage.addLsa(new NetworkLsa());
- channel = EasyMock.createMock(Channel.class);
- ospfNbr.setState(OspfNeighborState.EXCHANGE);
- ospfNbr.processLsUpdate(ospfMessage, channel);
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests loadingDone() method.
- */
- @Test
- public void testLoadingDone() throws Exception {
- LsaHeader lsaHeader = new LsaHeader();
- lsaHeader.setLsType(OspfLsaType.ROUTER.value());
- RouterLsa routerLsa = new RouterLsa(lsaHeader);
- ospfArea.addLsa(routerLsa, false, ospfInterface);
- ospfArea.addLsa(routerLsa, ospfInterface);
- ospfArea.addLsaToMaxAgeBin("lsa", new LsaWrapperImpl());
- ospfNbr.loadingDone();
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests processReceivedLsa() method.
- */
- @Test
- public void testProcessReceivedLsa() throws Exception {
- LsaWrapperImpl lsaWrapper = new LsaWrapperImpl();
- LsdbAgeImpl lsdbAge = new LsdbAgeImpl(new OspfAreaImpl());
- lsdbAge.ageLsaAndFlood();
- lsaWrapper.setLsdbAge(lsdbAge);
- lsaWrapper.setLsaHeader(new NetworkLsa());
- RouterLsa routerlsa = new RouterLsa();
- routerlsa.setLsType(1);
- routerlsa.setOptions(2);
- routerlsa.setAdvertisingRouter(Ip4Address.valueOf("1.1.1.1"));
- routerlsa.setAge(100);
- routerlsa.setLinkStateId("2.2.2.2");
- routerlsa.setLsSequenceNo(1010101);
- lsaWrapper.setLsaHeader(new RouterLsa());
- ospfArea.addLsa(routerlsa, false, ospfInterface);
-
- lsaWrapper.addLsa(OspfLsaType.ROUTER, routerlsa);
- ospfArea.addLsa(routerlsa, ospfInterface);
- ospfArea.addLsaToMaxAgeBin("lsa", new LsaWrapperImpl());
- byte[] res = routerlsa.asBytes();
- routerlsa.setLsPacketLen(res.length);
- res = new ChecksumCalculator().calculateLsaChecksum(routerlsa.asBytes(), 16, 17);
- routerlsa.setLsCheckSum(OspfUtil.byteToInteger(res));
- channel = EasyMock.createMock(Channel.class);
- lsdbAge.ageLsaAndFlood();
- assertThat(ospfNbr.processReceivedLsa(lsaWrapper.lsaHeader(), true, channel,
- Ip4Address.valueOf("10.10.10.10")), is(true));
- channel1 = EasyMock.createMock(Channel.class);
- assertThat(ospfNbr.processReceivedLsa(routerlsa, true, channel1,
- Ip4Address.valueOf("10.10.10.10")), is(true));
-
- }
-
- /**
- * Tests isNullorLatest() method.
- */
- @Test
- public void testIsNullorLatest() throws Exception {
-
- LsaWrapperImpl lsaWrapper = new LsaWrapperImpl();
- LsdbAgeImpl lsdbAge = new LsdbAgeImpl(new OspfAreaImpl());
- lsdbAge.ageLsaAndFlood();
- lsaWrapper.setLsdbAge(lsdbAge);
- lsaWrapper.setLsaHeader(new LsaHeader());
- lsaWrapper.addLsa(OspfLsaType.ROUTER, new RouterLsa());
- assertThat(ospfNbr.isNullorLatest(lsaWrapper, new LsaHeader()), is(notNullValue()));
- }
-
- /**
- * Tests processSelfOriginatedLsa() method.
- */
- @Test
- public void testProcessSelfOriginatedLsa() throws Exception {
- ospfNbr.processSelfOriginatedLsa();
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests sendLsa() method.
- */
- @Test
- public void testSendLsa() throws Exception {
- channel = EasyMock.createMock(Channel.class);
- ospfNbr.sendLsa(lsaHeader, Ip4Address.valueOf("1.1.1.1"), channel);
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests directAcknowledge() method.
- */
- @Test
- public void testDirectAcknowledge() throws Exception {
- channel = EasyMock.createMock(Channel.class);
- ospfNbr.directAcknowledge(new LsaHeader(), channel, Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests neighborDown() method.
- */
- @Test(expected = Exception.class)
- public void testNeighborDown() throws Exception {
- ospfNbr.neighborDown();
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests startFloodingTimer() method.
- */
- @Test
- public void testStartFloodingTimer() throws Exception {
- channel = EasyMock.createMock(Channel.class);
- ospfNbr.startFloodingTimer(channel);
- assertThat(ospfNbr, is(notNullValue()));
- }
-
- /**
- * Tests lastDdPacket() getter method.
- */
- @Test
- public void testGetLastDdPacket() throws Exception {
- ospfNbr.setLastDdPacket(new DdPacket());
- assertThat(ospfNbr.lastDdPacket(), is(notNullValue()));
- }
-
- /**
- * Tests lastDdPacket() setter method.
- */
- @Test
- public void testSetLastDdPacket() throws Exception {
- ospfNbr.setLastDdPacket(new DdPacket());
- assertThat(ospfNbr.lastDdPacket(), is(notNullValue()));
- }
-
- /**
- * Tests neighborId() getter method.
- */
- @Test
- public void testNeighborId() throws Exception {
- ospfNbr.setNeighborId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfNbr.neighborId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests neighborId() setter method.
- */
- @Test
- public void testSetNeighborId() throws Exception {
- ospfNbr.setNeighborId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfNbr.neighborId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests neighborDr() getter method.
- */
- @Test
- public void testNeighborDr() throws Exception {
- ospfNbr.setNeighborDr(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfNbr.neighborDr(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests neighborDr() setter method.
- */
- @Test
- public void testSetNeighborDr() throws Exception {
- ospfNbr.setNeighborDr(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfNbr.neighborDr(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests neighborBdr() getter method.
- */
- @Test
- public void testNeighborBdr() throws Exception {
- ospfNbr.setNeighborBdr(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfNbr.neighborBdr(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests neighborBdr() setter method.
- */
- @Test
- public void testSetNeighborBdr() throws Exception {
- ospfNbr.setNeighborBdr(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfNbr.neighborBdr(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests routerPriority() getter method.
- */
- @Test
- public void testRouterPriority() throws Exception {
- ospfNbr.setRouterPriority(1);
- assertThat(ospfNbr.routerPriority(), is(1));
- }
-
- /**
- * Tests routerPriority() setter method.
- */
- @Test
- public void testSetRouterPriority() throws Exception {
- ospfNbr.setRouterPriority(1);
- assertThat(ospfNbr.routerPriority(), is(1));
- }
-
- /**
- * Tests options() getter method.
- */
- @Test
- public void testGetOptions() throws Exception {
- ospfNbr.setOptions(1);
- assertThat(ospfNbr.options(), is(1));
- }
-
- /**
- * Tests options() setter method.
- */
- @Test
- public void testSetOptions() throws Exception {
- ospfNbr.setOptions(1);
- assertThat(ospfNbr.options(), is(1));
- }
-
- /**
- * Tests ddSeqNum() getter method.
- */
- @Test
- public void testGetDdSeqNum() throws Exception {
- ospfNbr.setDdSeqNum(1);
- assertThat(ospfNbr.ddSeqNum(), is(1L));
- }
-
- /**
- * Tests ddSeqNum() setter method.
- */
- @Test
- public void testSetDdSeqNum() throws Exception {
- ospfNbr.setDdSeqNum(1);
- assertThat(ospfNbr.ddSeqNum(), is(1L));
- }
-
- /**
- * Tests isMaster() getter method.
- */
- @Test
- public void testIsMaster() throws Exception {
- ospfNbr.setIsMaster(1);
- assertThat(ospfNbr.isMaster(), is(1));
- }
-
- /**
- * Tests lastDdPacket() getter method.
- */
- @Test
- public void testGetLastSentDdPacket() throws Exception {
- ospfNbr.setLastDdPacket(new DdPacket());
- assertThat(ospfNbr.lastDdPacket(), is(notNullValue()));
- }
-
- /**
- * Tests lastDdPacket() setter method.
- */
- @Test
- public void testSetLastSentDdPacket() throws Exception {
- ospfNbr.setLastDdPacket(new DdPacket());
- assertThat(ospfNbr.lastDdPacket(), is(notNullValue()));
- }
-
- /**
- * Tests getLastSentLsrPacket() getter method.
- */
- @Test
- public void testGetLastSentLsrPacket() throws Exception {
- ospfNbr.setLastSentLsrPacket(new LsRequest());
- assertThat(ospfNbr.getLastSentLsrPacket(), is(notNullValue()));
- }
-
- /**
- * Tests getLastSentLsrPacket() setter method.
- */
- @Test
- public void testSetLastSentLsrPacket() throws Exception {
- ospfNbr.setLastSentLsrPacket(new LsRequest());
- assertThat(ospfNbr.getLastSentLsrPacket(), is(notNullValue()));
- }
-
- /**
- * Tests getState() getter method.
- */
- @Test
- public void testGetState() throws Exception {
- ospfNbr.setState(OspfNeighborState.EXCHANGE);
- assertThat(ospfNbr.getState(), is(OspfNeighborState.EXCHANGE));
- }
-
- /**
- * Tests getState() setter method.
- */
- @Test
- public void testSetState() throws Exception {
- ospfNbr.setState(OspfNeighborState.EXCHANGE);
- assertThat(ospfNbr.getState(), is(OspfNeighborState.EXCHANGE));
- }
-
- /**
- * Tests isMaster() setter method.
- */
- @Test
- public void testSetIsMaster() throws Exception {
- ospfNbr.setIsMaster(1);
- assertThat(ospfNbr.isMaster(), is(1));
- }
-
- /**
- * Tests getLsReqList() method.
- */
- @Test
- public void testGetLsReqList() throws Exception {
- assertThat(ospfNbr.getLsReqList(), is(notNullValue()));
- }
-
- /**
- * Tests getReTxList() method.
- */
- @Test
- public void testGetReTxList() throws Exception {
- assertThat(ospfNbr.getReTxList(), is(notNullValue()));
- }
-
- /**
- * Tests getPendingReTxList() method.
- */
- @Test
- public void testGetPendingReTxList() throws Exception {
- assertThat(ospfNbr.getPendingReTxList(), is(notNullValue()));
- }
-
- /**
- * Utility for test method.
- */
- private OspfAreaImpl createOspfArea() throws UnknownHostException {
- OspfAreaAddressRangeImpl ospfAreaAddressRange;
- ospfAreaAddressRange = createOspfAreaAddressRange();
- addressRanges.add(ospfAreaAddressRange);
- OspfAreaImpl ospfArea = new OspfAreaImpl();
- ospfArea.setAreaId(Ip4Address.valueOf("10.226.165.164"));
- ospfArea.setExternalRoutingCapability(true);
- OspfInterfaceImpl ospfInterface = createOspfInterface();
- ospfInterfaces.add(ospfInterface);
- ospfArea.setOspfInterfaceList(ospfInterfaces);
- RouterLsa routerLsa = new RouterLsa();
- routerLsa.setLsType(1);
- routerLsa.setLinkStateId("2.2.2.2");
- routerLsa.setAdvertisingRouter(Ip4Address.valueOf("2.2.2.2"));
- OpaqueLsaHeader opaqueLsaHeader = new OpaqueLsaHeader();
- OpaqueLsa10 opaqueLsa10 = new OpaqueLsa10(opaqueLsaHeader);
- opaqueLsa10.setLsType(OspfLsaType.AREA_LOCAL_OPAQUE_LSA.value());
- opaqueLsa10.setLinkStateId("2.2.2.2");
- opaqueLsa10.setAdvertisingRouter(Ip4Address.valueOf("2.2.2.2"));
- try {
- ospfArea.addLsa(routerLsa, false, ospfInterface);
- ospfArea.addLsa(opaqueLsa10, false, ospfInterface);
- } catch (Exception e) {
- System.out.println("ospfAreaImpl createOspfArea");
- }
- ospfArea.setRouterId(Ip4Address.valueOf("111.111.111.111"));
-
- return ospfArea;
- }
-
- /**
- * Utility for test method.
- */
- private OspfAreaAddressRangeImpl createOspfAreaAddressRange() {
- OspfAreaAddressRangeImpl ospfAreaAddressRange = new OspfAreaAddressRangeImpl();
- ospfAreaAddressRange.setIpAddress(Ip4Address.valueOf("10.226.165.164"));
- ospfAreaAddressRange.setAdvertise(true);
- ospfAreaAddressRange.setMask("mask");
- return ospfAreaAddressRange;
- }
-
- /**
- * Utility for test method.
- */
- private OspfInterfaceImpl createOspfInterface() throws UnknownHostException {
- ospfInterface = new OspfInterfaceImpl();
- OspfAreaImpl ospfArea = new OspfAreaImpl();
- OspfInterfaceChannelHandler ospfInterfaceChannelHandler = EasyMock.createMock(
- OspfInterfaceChannelHandler.class);
- ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.226.165.164"),
- Ip4Address.valueOf("1.1.1.1"), 2,
- topologyForDeviceAndLink);
- ospfNbr.setState(OspfNeighborState.EXSTART);
- ospfNbr.setNeighborId(Ip4Address.valueOf("10.226.165.100"));
- this.ospfInterface = new OspfInterfaceImpl();
- this.ospfInterface.setIpAddress(Ip4Address.valueOf("10.226.165.164"));
- this.ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- this.ospfInterface.setBdr(Ip4Address.valueOf("111.111.111.111"));
- this.ospfInterface.setDr(Ip4Address.valueOf("111.111.111.111"));
- this.ospfInterface.setHelloIntervalTime(20);
- this.ospfInterface.setInterfaceType(2);
- this.ospfInterface.setReTransmitInterval(2000);
- this.ospfInterface.setMtu(6500);
- this.ospfInterface.setRouterDeadIntervalTime(1000);
- this.ospfInterface.setRouterPriority(1);
- this.ospfInterface.setInterfaceType(1);
- this.ospfInterface.addNeighbouringRouter(ospfNbr);
- return this.ospfInterface;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfPipelineFactoryTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfPipelineFactoryTest.java
deleted file mode 100644
index c1a546b..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfPipelineFactoryTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.jboss.netty.channel.ChannelPipeline;
-import org.junit.After;
-import org.junit.Before;
-
-/**
- * Unit test class for OspfPipelineFactory.
- */
-public class OspfPipelineFactoryTest {
-
- private OspfPipelineFactory ospfPipelineFactory;
- private ChannelPipeline channelPipeline;
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- ospfPipelineFactory = null;
- channelPipeline = null;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfRouterImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfRouterImplTest.java
deleted file mode 100644
index 3221260..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfRouterImplTest.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.impl;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpAddress;
-import org.onosproject.ospf.controller.OspfDeviceTed;
-
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for OspfRouterImpl.
- */
-public class OspfRouterImplTest {
- private OspfRouterImpl ospfRouter;
- private OspfDeviceTed ospfDeviceTed;
- private List<OspfDeviceTed> list;
-
- @Before
- public void setUp() throws Exception {
- ospfRouter = new OspfRouterImpl();
- }
-
- @After
- public void tearDown() throws Exception {
- ospfRouter = null;
- }
-
- /**
- * Tests routerIp() getter method.
- */
- @Test
- public void testRouterIp() throws Exception {
- ospfRouter.setRouterIp(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfRouter.routerIp(), is(IpAddress.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests routerIp() setter method.
- */
- @Test
- public void testSetRouterIp() throws Exception {
- ospfRouter.setRouterIp(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfRouter.routerIp(), is(IpAddress.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests areaIdOfInterface() getter method.
- */
- @Test
- public void testAreaIdOfInterface() throws Exception {
- ospfRouter.setAreaIdOfInterface(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfRouter.areaIdOfInterface(), is(IpAddress.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests areaIdOfInterface() setter method.
- */
- @Test
- public void testSetAreaIdOfInterface() throws Exception {
- ospfRouter.setAreaIdOfInterface(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfRouter.areaIdOfInterface(), is(IpAddress.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests interfaceId() getter method.
- */
- @Test
- public void testInterfaceId() throws Exception {
- ospfRouter.setInterfaceId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfRouter.interfaceId(), is(IpAddress.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests interfaceId() setter method.
- */
- @Test
- public void testSetInterfaceId() throws Exception {
- ospfRouter.setInterfaceId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfRouter.interfaceId(), is(IpAddress.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests isDr() setter method.
- */
- @Test
- public void testSetDr() throws Exception {
- ospfRouter.setDr(true);
- assertThat(ospfRouter.isDr(), is(true));
- }
-
- /**
- * Tests isDr() getter method.
- */
- @Test
- public void testIsDr() throws Exception {
- ospfRouter.setDr(true);
- assertThat(ospfRouter.isDr(), is(true));
- }
-
- /**
- * Tests isOpaque() setter method.
- */
- @Test
- public void testSetOpaque() throws Exception {
- ospfRouter.setOpaque(true);
- assertThat(ospfRouter.isOpaque(), is(true));
- }
-
- /**
- * Tests isOpaque() getter method.
- */
- @Test
- public void testisOpaque() throws Exception {
- ospfRouter.setOpaque(true);
- assertThat(ospfRouter.isOpaque(), is(true));
- }
-
- /**
- * Tests deviceTed() getter method.
- */
- @Test
- public void testDeviceTed() throws Exception {
- ospfRouter.setDeviceTed(new OspfDeviceTedImpl());
- assertThat(ospfRouter.deviceTed(), is(notNullValue()));
- }
-
- /**
- * Tests deviceTed() Setter method.
- */
- @Test
- public void testSetDeviceTed() throws Exception {
- ospfRouter.setDeviceTed(new OspfDeviceTedImpl());
- assertThat(ospfRouter.deviceTed(), is(notNullValue()));
- }
-
- /**
- * Tests neighborRouterId() getter method.
- */
- @Test
- public void testNeighborRouterId() throws Exception {
- ospfRouter.setNeighborRouterId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfRouter.neighborRouterId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests neighborRouterId() Setter method.
- */
- @Test
- public void testSetNeighborRouterId() throws Exception {
- ospfRouter.setNeighborRouterId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfRouter.neighborRouterId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/TopologyForDeviceAndLinkImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/TopologyForDeviceAndLinkImplTest.java
deleted file mode 100644
index 6955a2c..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/TopologyForDeviceAndLinkImplTest.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
-* Copyright 2016-present Open Networking Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.onosproject.ospf.controller.impl;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.DeviceInformation;
-import org.onosproject.ospf.controller.OspfLinkTed;
-import org.onosproject.ospf.controller.OspfLsa;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.lsa.subtypes.OspfLsaLink;
-import org.onosproject.ospf.protocol.lsa.tlvtypes.LinkTlv;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for TopologyForDeviceAndLinkImpl.
- */
-public class TopologyForDeviceAndLinkImplTest {
- private final byte[] packet = {0, 9, 0, 4, 0, 0, 0, 1,
- 0, 9, 0, 4, 0, 0, 0, 1,
- 0, 1, 0, 4, 0, 0, 0, 1,
- 0, 2, 0, 4, 0, 0, 0, 1,
- 0, 3, 0, 4, 0, 0, 0, 1,
- 0, 4, 0, 4, 0, 0, 0, 1,
- 0, 6, 0, 4, 0, 0, 0, 1,
- 0, 7, 0, 4, 0, 0, 0, 1,
- 0, 8, 0, 4, 0, 0, 0, 1,
- };
- private TopologyForDeviceAndLinkImpl topologyForDeviceAndLink;
- private Map result;
- private LinkTlv linkTlv;
- private TlvHeader header;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- topologyForDeviceAndLink = new TopologyForDeviceAndLinkImpl();
- }
-
- @After
- public void tearDown() throws Exception {
- topologyForDeviceAndLink = null;
- }
-
- /**
- * Tests deviceInformationMap() method.
- */
- @Test
- public void testDeviceInformationMap() throws Exception {
- result = topologyForDeviceAndLink.deviceInformationMap();
- assertThat(result.size(), is(0));
- }
-
- /**
- * Tests setDeviceInformationMap() method.
- */
- @Test
- public void testSetDeviceInformationMap() throws Exception {
- topologyForDeviceAndLink.setDeviceInformationMap("1.1.1.1", new DeviceInformationImpl());
- result = topologyForDeviceAndLink.deviceInformationMap();
- assertThat(result.size(), is(1));
- }
-
- /**
- * Tests deviceInformation() method.
- */
- @Test
- public void testDeviceInformation() throws Exception {
- topologyForDeviceAndLink.setDeviceInformationMap("1.1.1.1", new DeviceInformationImpl());
- DeviceInformation deviceInformation = topologyForDeviceAndLink.deviceInformation("1.1.1.1");
- assertThat(deviceInformation, is(notNullValue()));
- }
-
- /**
- * Tests removeDeviceInformationMap() method.
- */
- @Test
- public void testRemoveDeviceInformationMap() throws Exception {
- topologyForDeviceAndLink.setDeviceInformationMap("1.1.1.1", new DeviceInformationImpl());
- topologyForDeviceAndLink.deviceInformation("1.1.1.1");
- result = topologyForDeviceAndLink.deviceInformationMap();
- topologyForDeviceAndLink.removeDeviceInformationMap("1.1.1.1");
- assertThat(result.size(), is(0));
- }
-
- /**
- * Tests linkInformationMap() method.
- */
- @Test
- public void testLinkInformationMap() throws Exception {
- result = topologyForDeviceAndLink.linkInformationMap();
- assertThat(result.size(), is(0));
- }
-
- /**
- * Tests setLinkInformationMap() method.
- */
- @Test
- public void testSetLinkInformationMap() throws Exception {
- topologyForDeviceAndLink.setLinkInformationMap("1.1.1.1", new LinkInformationImpl());
- result = topologyForDeviceAndLink.linkInformationMap();
- assertThat(result.size(), is(1));
- }
-
- /**
- * Tests removeLinkInformationMap() method.
- */
- @Test
- public void testRemoveLinkInformationMap() throws Exception {
- topologyForDeviceAndLink.setLinkInformationMap("1.1.1.1", new LinkInformationImpl());
- topologyForDeviceAndLink.removeLinkInformationMap("1.1.1.1");
- result = topologyForDeviceAndLink.linkInformationMap();
- assertThat(result.size(), is(0));
- }
-
- /**
- * Tests getOspfLinkTedHashMap() method.
- */
- @Test
- public void testGetOspfLinkTedHashMap() throws Exception {
- OspfLinkTed ospfLinkTed = topologyForDeviceAndLink.getOspfLinkTedHashMap("1.1.1.1");
- assertThat(ospfLinkTed, is(nullValue()));
- }
-
- /**
- * Tests addLocalDevice() method.
- */
- @Test
- public void testAddLocalDevice() throws Exception {
- OspfAreaImpl ospfArea = new OspfAreaImpl();
- ospfArea.setRouterId(Ip4Address.valueOf("5.5.5.5"));
- topologyForDeviceAndLink.addLocalDevice(createOspfLsa(), new OspfInterfaceImpl(), ospfArea);
- topologyForDeviceAndLink.addLocalDevice(createOspfLsa1(), new OspfInterfaceImpl(), ospfArea);
- assertThat(topologyForDeviceAndLink, is(notNullValue()));
- }
-
- /**
- * Tests addLocalLink() method.
- */
- @Test
- public void testAddLocalLink() throws Exception {
- Ip4Address linkData = Ip4Address.valueOf("1.1.1.1");
- Ip4Address linkSrc = Ip4Address.valueOf("2.2.2.2");
- Ip4Address linkDest = Ip4Address.valueOf("3.3.3.3");
- boolean opaqueEnabled = true;
- boolean linkSrcIdNotRouterId = true;
- topologyForDeviceAndLink.addLocalLink("10.10.10.10", linkData, linkSrc,
- linkDest, opaqueEnabled, linkSrcIdNotRouterId);
- assertThat(topologyForDeviceAndLink, is(notNullValue()));
- }
-
- /**
- * Tests removeLinks() method.
- */
- @Test
- public void testRemoveLinks() throws Exception {
- Ip4Address linkData = Ip4Address.valueOf("1.1.1.1");
- Ip4Address linkSrc = Ip4Address.valueOf("2.2.2.2");
- Ip4Address linkDest = Ip4Address.valueOf("3.3.3.3");
- boolean opaqueEnabled = true;
- boolean linkSrcIdNotRouterId = true;
- topologyForDeviceAndLink.addLocalLink("10.10.10.10", linkData, linkSrc,
- linkDest, opaqueEnabled, linkSrcIdNotRouterId);
- topologyForDeviceAndLink.removeLinks(Ip4Address.valueOf("10.10.10.10"));
- assertThat(topologyForDeviceAndLink, is(notNullValue()));
- }
-
- /**
- * Tests updateLinkInformation() method.
- */
- @Test
- public void testUpdateLinkInformation() throws Exception {
- OspfAreaImpl ospfArea = new OspfAreaImpl();
- ospfArea.setRouterId(Ip4Address.valueOf("5.5.5.5"));
- topologyForDeviceAndLink.updateLinkInformation(createOspfLsa(), ospfArea);
- assertThat(topologyForDeviceAndLink, is(notNullValue()));
- }
-
- /**
- * Tests getDeleteRouterInformation() method.
- */
- @Test
- public void testGetDeleteRouterInformation() throws Exception {
- OspfAreaImpl ospfArea = new OspfAreaImpl();
- ospfArea.setRouterId(Ip4Address.valueOf("5.5.5.5"));
- topologyForDeviceAndLink.updateLinkInformation(createOspfLsa(), ospfArea);
- List list = topologyForDeviceAndLink.getDeleteRouterInformation(createOspfLsa(), ospfArea);
- assertThat(list, is(notNullValue()));
- }
-
- /**
- * Utility for test methods.
- */
- private OspfLsa createOspfLsa() {
- RouterLsa routerLsa = new RouterLsa();
- routerLsa.setLsType(1);
- routerLsa.setAdvertisingRouter(Ip4Address.valueOf("6.6.6.6"));
- OspfLsaLink ospfLsaLink = new OspfLsaLink();
- ospfLsaLink.setLinkData("192.168.7.77");
- ospfLsaLink.setLinkId("9.9.9.9");
- ospfLsaLink.setLinkType(1);
- OspfLsaLink ospfLsaLink0 = new OspfLsaLink();
- ospfLsaLink0.setLinkData("7.7.7.7");
- ospfLsaLink0.setLinkId("7.7.7.7");
- ospfLsaLink0.setLinkType(2);
- OspfLsaLink ospfLsaLink120 = new OspfLsaLink();
- ospfLsaLink120.setLinkData("192.168.7.77");
- ospfLsaLink120.setLinkId("1.1.1.1");
- ospfLsaLink120.setLinkType(1);
- OspfLsaLink lsaLink = new OspfLsaLink();
- lsaLink.setLinkData("192.168.7.77");
- lsaLink.setLinkId("14.14.14.14");
- lsaLink.setLinkType(2);
- routerLsa.addRouterLink(lsaLink);
- routerLsa.addRouterLink(ospfLsaLink);
- routerLsa.addRouterLink(ospfLsaLink0);
- routerLsa.addRouterLink(ospfLsaLink120);
- return routerLsa;
- }
-
- /**
- * Utility for test methods.
- */
- private OspfLsa createOspfLsa1() throws Exception {
- OpaqueLsa10 opaqueLsa10 = new OpaqueLsa10(new OpaqueLsaHeader());
- opaqueLsa10.setLsType(10);
- header = new TlvHeader();
- header.setTlvLength(8);
- header.setTlvType(9);
- linkTlv = new LinkTlv(header);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- linkTlv.readFrom(channelBuffer);
- opaqueLsa10.addValue(linkTlv);
- return opaqueLsa10;
- }
-}
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaBinImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaBinImplTest.java
deleted file mode 100644
index 9d8582d..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaBinImplTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.lsdb;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.controller.LsaWrapper;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for LsaBinImpl.
- */
-public class LsaBinImplTest {
- private LsaBinImpl lsaBin;
- private LsaHeader ospflsa1;
- private LsaWrapper lsaWrapper;
-
-
- @Before
- public void setUp() throws Exception {
- ospflsa1 = new LsaHeader();
- ospflsa1.setAge(20);
- lsaBin = new LsaBinImpl(1);
- }
-
- @After
- public void tearDown() throws Exception {
- ospflsa1 = null;
- lsaBin = null;
- }
-
- /**
- * Tests binNumber() getter method.
- */
- @Test
- public void testGetBinNumber() throws Exception {
- lsaWrapper = new LsaWrapperImpl();
- lsaBin.addOspfLsa("lsa1", lsaWrapper);
- assertThat(lsaBin.binNumber(), is(1));
- }
-
- /**
- * Tests addOspfLsa() method.
- */
- @Test
- public void testAddOspfLsa() throws Exception {
- LsaWrapper lsaWrapper = new LsaWrapperImpl();
- lsaBin.addOspfLsa("lsa1", lsaWrapper);
- assertThat(lsaBin, is(notNullValue()));
- }
-
- /**
- * Tests ospfLsa() getter method.
- */
- @Test
- public void testGetOspfLsa() throws Exception {
- lsaWrapper = new LsaWrapperImpl();
- lsaBin.addOspfLsa("lsa1", lsaWrapper);
- assertThat(lsaBin, is(notNullValue()));
- assertThat(lsaBin.ospfLsa("lsa1"), is(lsaWrapper));
- }
-
- /**
- * Tests removeOspfLsa() method.
- */
- @Test
- public void testRemoveOspfLsa() throws Exception {
- lsaWrapper = new LsaWrapperImpl();
- lsaBin.addOspfLsa("lsa1", lsaWrapper);
- lsaBin.removeOspfLsa("lsa1", lsaWrapper);
- assertThat(lsaBin, is(notNullValue()));
- }
-
- /**
- * Tests listOfLsa() method.
- */
- @Test
- public void testGetListOfLsa() throws Exception {
- lsaWrapper = new LsaWrapperImpl();
- lsaBin.addOspfLsa("lsa1", lsaWrapper);
- assertThat(lsaBin.listOfLsa().size(), is(1));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(lsaBin.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaQueueConsumerTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaQueueConsumerTest.java
deleted file mode 100644
index c624e02..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaQueueConsumerTest.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.lsdb;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.channel.Channel;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.controller.LsaWrapper;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.util.OspfInterfaceState;
-
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for LsaQueueConsumer.
- */
-public class LsaQueueConsumerTest {
- private LsaQueueConsumer lsaQueueConsumer;
- private BlockingQueue<LsaWrapper> blockingQueue;
- private Channel channel;
- private LsaWrapperImpl lsaWrapper;
- private OspfArea ospfArea;
- private RouterLsa routerLsa;
- private OspfInterfaceImpl ospfInterface;
- private LsaHeader lsaHeader;
- private LsdbAgeImpl lsdbAge;
-
- @Before
- public void setUp() throws Exception {
- lsaQueueConsumer = EasyMock.createMock(LsaQueueConsumer.class);
- }
-
- @After
- public void tearDown() throws Exception {
- lsaQueueConsumer = null;
- blockingQueue = null;
- channel = null;
- lsaWrapper = null;
- lsdbAge = null;
- lsaHeader = null;
- ospfInterface = null;
- ospfArea = null;
- routerLsa = null;
- }
-
- /**
- * Tests run() method.
- */
- @Test
- public void testRun() throws Exception {
- blockingQueue = new ArrayBlockingQueue(5);
- ospfArea = new OspfAreaImpl();
- lsdbAge = new LsdbAgeImpl(ospfArea);
- channel = EasyMock.createMock(Channel.class);
- lsaWrapper = new LsaWrapperImpl();
- lsaWrapper.setLsaProcessing("verifyChecksum");
- blockingQueue.add(lsaWrapper);
- lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea);
- lsaQueueConsumer.run();
- assertThat(lsaQueueConsumer, is(notNullValue()));
- }
-
- /**
- * Tests run() method.
- */
- @Test
- public void testRun1() throws Exception {
- blockingQueue = new ArrayBlockingQueue(5);
- channel = EasyMock.createMock(Channel.class);
- ospfArea = new OspfAreaImpl();
- lsaWrapper = new LsaWrapperImpl();
- routerLsa = new RouterLsa();
- routerLsa.setLsType(1);
- lsaWrapper.addLsa(OspfLsaType.ROUTER, routerLsa);
- ospfInterface = new OspfInterfaceImpl();
- ospfInterface.setState(OspfInterfaceState.DR);
- lsaWrapper.setOspfInterface(ospfInterface);
- lsaWrapper.setIsSelfOriginated(true);
- lsaHeader = new LsaHeader();
- lsaHeader.setLsType(1);
- lsaWrapper.setLsaHeader(lsaHeader);
- lsaWrapper.setLsaProcessing("refreshLsa");
- lsaWrapper.setLsdbAge(new LsdbAgeImpl(ospfArea));
- blockingQueue.add(lsaWrapper);
- lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea);
- lsaQueueConsumer.run();
- assertThat(lsaQueueConsumer, is(notNullValue()));
- }
-
- @Test
- public void testRun3() throws Exception {
- blockingQueue = new ArrayBlockingQueue(5);
- channel = EasyMock.createMock(Channel.class);
- ospfArea = new OspfAreaImpl();
- lsaWrapper = new LsaWrapperImpl();
- routerLsa = new RouterLsa();
- routerLsa.setLsType(2);
- lsaWrapper.addLsa(OspfLsaType.NETWORK, routerLsa);
- ospfInterface = new OspfInterfaceImpl();
- ospfInterface.setState(OspfInterfaceState.BDR);
- lsaWrapper.setOspfInterface(ospfInterface);
- lsaWrapper.setIsSelfOriginated(true);
- lsaHeader = new LsaHeader();
- lsaHeader.setLsType(2);
- lsaWrapper.setLsaHeader(lsaHeader);
- lsaWrapper.setLsaProcessing("refreshLsa");
- lsaWrapper.setLsdbAge(new LsdbAgeImpl(ospfArea));
- blockingQueue.add(lsaWrapper);
- lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea);
- lsaQueueConsumer.run();
- assertThat(lsaQueueConsumer, is(notNullValue()));
- }
-
- /**
- * Tests run() method.
- */
- @Test
- public void testRun5() throws Exception {
- blockingQueue = new ArrayBlockingQueue(5);
- channel = EasyMock.createMock(Channel.class);
- ospfArea = new OspfAreaImpl();
- lsaWrapper = new LsaWrapperImpl();
- routerLsa = new RouterLsa();
- routerLsa.setLsType(2);
- lsaWrapper.addLsa(OspfLsaType.NETWORK, routerLsa);
- ospfInterface = new OspfInterfaceImpl();
- ospfInterface.setState(OspfInterfaceState.DR);
- lsaWrapper.setOspfInterface(ospfInterface);
- lsaWrapper.setIsSelfOriginated(true);
- lsaHeader = new LsaHeader();
- lsaHeader.setLsType(2);
- lsaWrapper.setLsaHeader(lsaHeader);
- lsaWrapper.setLsaProcessing("maxAgeLsa");
- lsaWrapper.setLsdbAge(new LsdbAgeImpl(ospfArea));
- blockingQueue.add(lsaWrapper);
- lsaQueueConsumer = new LsaQueueConsumer(blockingQueue, channel, ospfArea);
- lsaQueueConsumer.run();
- assertThat(lsaQueueConsumer, is(notNullValue()));
- }
-
- /**
- * Tests setChannel() method.
- */
- @Test
- public void testSetChannel() throws Exception {
- channel = EasyMock.createMock(Channel.class);
- lsdbAge = new LsdbAgeImpl(ospfArea);
- lsdbAge.startDbAging();
- lsdbAge.setChannel(channel);
- assertThat(lsaQueueConsumer, is(notNullValue()));
- }
-
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImplTest.java
deleted file mode 100644
index 6aee39b..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImplTest.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.lsdb;
-
-import org.easymock.EasyMock;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for LsaWrapperImpl.
- */
-public class LsaWrapperImplTest {
-
- private LsaWrapperImpl lsaWrapper;
- private LsdbAgeImpl lsdbAge;
- private LsaHeader header;
- private OspfInterfaceImpl ospfInterfaceImpl;
-
- @Before
- public void setUp() throws Exception {
- lsaWrapper = new LsaWrapperImpl();
- }
-
- @After
- public void tearDown() throws Exception {
- lsaWrapper = null;
- header = null;
- lsdbAge = null;
- ospfInterfaceImpl = null;
- }
-
- /**
- * Tests lsaType() getter method.
- */
- @Test
- public void testGetLsaType() throws Exception {
- lsaWrapper.setLsaType(OspfLsaType.ROUTER);
- assertThat(lsaWrapper.lsaType(), is(OspfLsaType.ROUTER));
- }
-
- /**
- * Tests lsaType() setter method.
- */
- @Test
- public void testSetLsaType() throws Exception {
- lsaWrapper.setLsaType(OspfLsaType.ROUTER);
- assertThat(lsaWrapper.lsaType(), is(OspfLsaType.ROUTER));
- }
-
- /**
- * Tests isSelfOriginated() getter method.
- */
- @Test
- public void testIsSelfOriginated() throws Exception {
- lsaWrapper.setIsSelfOriginated(true);
- assertThat(lsaWrapper.isSelfOriginated(), is(true));
- }
-
- /**
- * Tests isSelfOriginated() setter method.
- */
- @Test
- public void testSetIsSelfOriginated() throws Exception {
- lsaWrapper.setIsSelfOriginated(true);
- assertThat(lsaWrapper.isSelfOriginated(), is(true));
- }
-
- /**
- * Tests addLsa() method.
- */
- @Test
- public void testAddLsa() throws Exception {
- lsaWrapper.addLsa(OspfLsaType.ROUTER, new RouterLsa());
- assertThat(lsaWrapper, is(notNullValue()));
- }
-
- /**
- * Tests lsaAgeReceived() getter method.
- */
- @Test
- public void testGetLsaAgeReceived() throws Exception {
- lsaWrapper.setLsaAgeReceived(10);
- assertThat(lsaWrapper.lsaAgeReceived(), is(10));
- }
-
- /**
- * Tests lsaAgeReceived() setter method.
- */
- @Test
- public void testSetLsaAgeReceived() throws Exception {
- lsaWrapper.setLsaAgeReceived(10);
- assertThat(lsaWrapper.lsaAgeReceived(), is(10));
- }
-
- /**
- * Tests lsaHeader() getter method.
- */
- @Test
- public void testGetLsaHeader() throws Exception {
- lsdbAge = new LsdbAgeImpl(new OspfAreaImpl());
- lsdbAge.ageLsaAndFlood();
- lsaWrapper.setLsdbAge(lsdbAge);
- header = new LsaHeader();
- lsaWrapper.setLsaHeader(header);
- assertThat(lsaWrapper.lsaHeader(), instanceOf(LsaHeader.class));
- }
-
- /**
- * Tests lsaHeader() setter method.
- */
- @Test
- public void testSetLsaHeader() throws Exception {
- lsdbAge = new LsdbAgeImpl(new OspfAreaImpl());
- lsdbAge.ageLsaAndFlood();
- lsaWrapper.setLsdbAge(lsdbAge);
- header = new LsaHeader();
- lsaWrapper.setLsaHeader(header);
- assertThat(lsaWrapper.lsaHeader(), instanceOf(LsaHeader.class));
- }
-
- /**
- * Tests setOspfLsa() setter method.
- */
- @Test
- public void testSetOspfLsa() throws Exception {
- lsaWrapper.setOspfLsa(new RouterLsa());
- assertThat(lsaWrapper, is(notNullValue()));
- }
-
- /**
- * Tests noReTransmissionLists() getter method.
- */
- @Test
- public void testGetNoReTransmissionLists() throws Exception {
- lsaWrapper.setNoReTransmissionLists(10);
- assertThat(lsaWrapper.noReTransmissionLists(), is(10));
- }
-
- /**
- * Tests noReTransmissionLists() setter method.
- */
- @Test
- public void testSetNoReTransmissionLists() throws Exception {
- lsaWrapper.setNoReTransmissionLists(10);
- assertThat(lsaWrapper.noReTransmissionLists(), is(10));
- }
-
- /**
- * Tests isInAnAgeBin() getter method.
- */
- @Test
- public void testIsInAnAgeBin() throws Exception {
- lsaWrapper.setInAnAgeBin(true);
- assertThat(lsaWrapper.isInAnAgeBin(), is(true));
- }
-
- /**
- * Tests isInAnAgeBin() setter method.
- */
- @Test
- public void testSetInAnAgeBin() throws Exception {
- lsaWrapper.setInAnAgeBin(true);
- assertThat(lsaWrapper.isInAnAgeBin(), is(true));
- }
-
- /**
- * Tests isChangedSinceLastFlood() getter method.
- */
- @Test
- public void testIsChangedSinceLastFlood() throws Exception {
- lsaWrapper.setChangedSinceLastFlood(true);
- assertThat(lsaWrapper.isChangedSinceLastFlood(), is(true));
- }
-
- /**
- * Tests isChangedSinceLastFlood() setter method.
- */
- @Test
- public void testSetChangedSinceLastFlood() throws Exception {
- lsaWrapper.setChangedSinceLastFlood(true);
- assertThat(lsaWrapper.isChangedSinceLastFlood(), is(true));
- }
-
- /**
- * Tests isSequenceRollOver() method.
- */
- @Test
- public void testIsSequenceRollOver() throws Exception {
- lsaWrapper.setIsSequenceRollOver(true);
- assertThat(lsaWrapper.isSequenceRollOver(), is(true));
- }
-
- /**
- * Tests isSentReplyForOlderLsa() method.
- */
- @Test
- public void testIsSentReplyForOlderLsa() throws Exception {
- lsaWrapper.setSentReplyForOlderLsa(true);
- assertThat(lsaWrapper.isSentReplyForOlderLsa(), is(true));
- }
-
- /**
- * Tests isCheckAge() getter method.
- */
- @Test
- public void testIsCheckAge() throws Exception {
- lsaWrapper.setCheckAge(true);
- assertThat(lsaWrapper.isCheckAge(), is(true));
- }
-
- /**
- * Tests isSentReplyForOlderLsa() getter method.
- */
- @Test
- public void testSetSentReplyForOlderLsa() throws Exception {
- lsaWrapper.setSentReplyForOlderLsa(true);
- assertThat(lsaWrapper.isSentReplyForOlderLsa(), is(true));
- }
-
- /**
- * Tests isSentReplyForOlderLsa() setter method.
- */
- @Test
- public void testSetCheckAge() throws Exception {
- lsaWrapper.setCheckAge(true);
- assertThat(lsaWrapper.isCheckAge(), is(true));
- }
-
- /**
- * Tests isAging() getter method.
- */
- @Test
- public void testIsAging() throws Exception {
- lsaWrapper.setIsAging(true);
- assertThat(lsaWrapper.isAging(), is(true));
- }
-
- /**
- * Tests isAging() setter method.
- */
- @Test
- public void testSetIsAging() throws Exception {
- lsaWrapper.setIsAging(true);
- assertThat(lsaWrapper.isAging(), is(true));
- }
-
- /**
- * Tests currentAge() method.
- */
- @Test
- public void testGetCurrentAge() throws Exception {
- lsdbAge = new LsdbAgeImpl(new OspfAreaImpl());
- lsdbAge.ageLsaAndFlood();
- lsaWrapper.setLsdbAge(lsdbAge);
- assertThat(lsaWrapper.currentAge(), is(notNullValue()));
- }
-
- /**
- * Tests ageCounterWhenReceived() getter method.
- */
- @Test
- public void testGetAgeCounterWhenReceived() throws Exception {
- lsaWrapper.setAgeCounterWhenReceived(10);
- assertThat(lsaWrapper.ageCounterWhenReceived(), is(10));
- }
-
- /**
- * Tests ageCounterWhenReceived() setter method.
- */
- @Test
- public void testSetAgeCounterWhenReceived() throws Exception {
- lsaWrapper.setAgeCounterWhenReceived(10);
- assertThat(lsaWrapper.ageCounterWhenReceived(), is(10));
- }
-
- /**
- * Tests lsaProcessing() getter method.
- */
- @Test
- public void testGetLsaProcessing() throws Exception {
- lsaWrapper.setLsaProcessing("router");
- assertThat(lsaWrapper.lsaProcessing(), is("router"));
- }
-
- /**
- * Tests lsaProcessing() setter method.
- */
- @Test
- public void testSetLsaProcessing() throws Exception {
- lsaWrapper.setLsaProcessing("router");
- assertThat(lsaWrapper.lsaProcessing(), is("router"));
- }
-
- /**
- * Tests binNumber() getter method.
- */
- @Test
- public void testGetBinNumber() throws Exception {
- lsaWrapper.setBinNumber(10);
- assertThat(lsaWrapper.binNumber(), is(10));
- }
-
- /**
- * Tests binNumber() setter method.
- */
- @Test
- public void testSetBinNumber() throws Exception {
- lsaWrapper.setBinNumber(10);
- assertThat(lsaWrapper.binNumber(), is(10));
- }
-
- /**
- * Tests ospfInterface() getter method.
- */
- @Test
- public void testGetOspfInterface() throws Exception {
- ospfInterfaceImpl = EasyMock.createMock(OspfInterfaceImpl.class);
- lsaWrapper.setOspfInterface(ospfInterfaceImpl);
- assertThat(lsaWrapper.ospfInterface(), is(notNullValue()));
- }
-
- /**
- * Tests ospfInterface() setter method.
- */
- @Test
- public void testSetOspfInterface() throws Exception {
- ospfInterfaceImpl = EasyMock.createMock(OspfInterfaceImpl.class);
- lsaWrapper.setOspfInterface(ospfInterfaceImpl);
- assertThat(lsaWrapper.ospfInterface(), is(notNullValue()));
- }
-
- /**
- * Tests getLsdbAge() method.
- */
- @Test
- public void testGetLsdbAge() throws Exception {
- assertThat(lsaWrapper.getLsdbAge(), is(nullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(lsaWrapper.toString(), is(notNullValue()));
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEquals() throws Exception {
- assertThat(lsaWrapper.equals(new LsaWrapperImpl()), is(true));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- int hashCode = lsaWrapper.hashCode();
- assertThat(hashCode, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsdbAgeImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsdbAgeImplTest.java
deleted file mode 100644
index 696ecb8..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsdbAgeImplTest.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.lsdb;
-
-import org.easymock.EasyMock;
-import org.jboss.netty.channel.Channel;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.controller.LsaBin;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for LsdbAgeImpl.
- */
-public class LsdbAgeImplTest {
- private LsdbAgeImpl lsdbAge;
- private OspfAreaImpl ospfAreaImpl;
- private LsaBinImpl lsaBin;
- private LsaBin lsaBin1;
- private LsaWrapperImpl lsaWrapper;
- private OspfArea ospfArea;
- private Channel channel;
-
- @Before
- public void setUp() throws Exception {
- ospfAreaImpl = EasyMock.createMock(OspfAreaImpl.class);
- lsdbAge = new LsdbAgeImpl(ospfAreaImpl);
- }
-
- @After
- public void tearDown() throws Exception {
- lsdbAge = null;
- lsaBin = null;
- lsaBin1 = null;
- ospfAreaImpl = null;
- lsaWrapper = null;
- channel = null;
- ospfArea = null;
- }
-
- /**
- * Tests getLsaBin() method.
- */
- @Test
- public void testGetLsaBin() throws Exception {
- lsaBin = new LsaBinImpl(1);
- lsdbAge.addLsaBin(1, lsaBin);
- assertThat(lsdbAge, is(notNullValue()));
- lsaBin1 = lsdbAge.getLsaBin(1);
- assertThat(lsaBin, instanceOf(LsaBin.class));
- assertThat(lsaBin1, instanceOf(LsaBin.class));
- }
-
- /**
- * Tests addLsaBin() method.
- */
- @Test
- public void testAddLsaBin() throws Exception {
- lsaBin = new LsaBinImpl(1);
- lsdbAge.addLsaBin(1, lsaBin);
- assertThat(lsdbAge, is(notNullValue()));
- assertThat(lsaBin, instanceOf(LsaBin.class));
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEquals() throws Exception {
- assertThat(lsdbAge.equals(lsdbAge), is(true));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- int hashCode = lsdbAge.hashCode();
- assertThat(hashCode, is(notNullValue()));
- }
-
- /**
- * Tests addLsaToMaxAgeBin() method.
- */
- @Test
- public void testAddLsaToMaxAgeBin() throws Exception {
- lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
- lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper);
- assertThat(lsdbAge, is(notNullValue()));
- }
-
- /**
- * Tests removeLsaFromBin() method.
- */
- @Test
- public void testRemoveLsaFromBin() throws Exception {
- lsaBin = EasyMock.createMock(LsaBinImpl.class);
- lsaWrapper = new LsaWrapperImpl();
- lsaWrapper.setBinNumber(-1);
- lsaBin.addOspfLsa("1", lsaWrapper);
- lsdbAge.startDbAging();
- lsdbAge.addLsaToMaxAgeBin("3600", lsaWrapper);
- lsdbAge.addLsaBin(-1, lsaBin);
- lsdbAge.removeLsaFromBin(lsaWrapper);
- assertThat(lsdbAge, is(notNullValue()));
- }
-
- /**
- * Tests startDbAging() method.
- */
- @Test
- public void testStartDbAging() throws Exception {
- lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
- lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper);
- lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
- lsdbAge.addLsaToMaxAgeBin("lsa2", lsaWrapper);
- lsdbAge.startDbAging();
- assertThat(lsdbAge, is(notNullValue()));
- }
-
- /**
- * Tests ageLsaAndFlood() method.
- */
- @Test
- public void testAgeLsaAndFlood() throws Exception {
- lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
- lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper);
- lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
- lsdbAge.addLsaToMaxAgeBin("lsa2", lsaWrapper);
- lsdbAge.startDbAging();
- lsdbAge.ageLsaAndFlood();
- Assert.assertNotNull(lsdbAge);
- }
-
- /**
- * Tests maxAgeLsa() method.
- */
- @Test
- public void testMaxageLsa() throws Exception {
- lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
- ospfArea = new OspfAreaImpl();
- lsdbAge = new LsdbAgeImpl(ospfArea);
- lsaWrapper.setLsdbAge(lsdbAge);
- lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper);
- lsaBin = new LsaBinImpl(1);
- lsaBin.addOspfLsa("1", lsaWrapper);
- lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
- lsdbAge.addLsaToMaxAgeBin("lsa2", lsaWrapper);
- lsaBin.addOspfLsa("2", lsaWrapper);
- lsdbAge.startDbAging();
- lsdbAge = new LsdbAgeImpl(new OspfAreaImpl());
- lsdbAge.ageLsaAndFlood();
- lsdbAge.maxAgeLsa();
- assertThat(lsdbAge, is(notNullValue()));
-
- }
-
- /**
- * Tests refreshLsa() method.
- */
- @Test
- public void testRefereshLsa() throws Exception {
- lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
- lsaWrapper.setBinNumber(0);
- lsaWrapper.setLsaType(OspfLsaType.NETWORK);
- lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper);
- lsdbAge.ageLsaAndFlood();
- lsdbAge.startDbAging();
- lsdbAge.refreshLsa();
- assertThat(lsdbAge, is(notNullValue()));
- }
-
- /**
- * Tests checkAges() method.
- */
- @Test
- public void testCheckAges() throws Exception {
- lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
- lsdbAge.addLsaToMaxAgeBin("lsa1", lsaWrapper);
- lsaWrapper = EasyMock.createMock(LsaWrapperImpl.class);
- lsdbAge.addLsaToMaxAgeBin("lsa2", lsaWrapper);
- lsdbAge.startDbAging();
- lsdbAge.checkAges();
- assertThat(lsdbAge, is(notNullValue()));
-
- }
-
- /**
- * Tests getChannel() getter method.
- */
- @Test
- public void testGetChannel() throws Exception {
- channel = EasyMock.createMock(Channel.class);
- lsdbAge.setChannel(channel);
- assertThat(lsdbAge.getChannel(), is(notNullValue()));
- }
-
- /**
- * Tests setChannel() setter method.
- */
- @Test
- public void testSetChannel() throws Exception {
- channel = EasyMock.createMock(Channel.class);
- lsdbAge.setChannel(channel);
- assertThat(lsdbAge.getChannel(), is(notNullValue()));
- }
-
- /**
- * Tests getAgeCounter() method.
- */
- @Test
- public void testGetAgeCounter() throws Exception {
- lsaBin = new LsaBinImpl(1);
- lsdbAge.addLsaBin(1, lsaBin);
- int age = lsdbAge.getAgeCounter();
- assertThat(age, is(notNullValue()));
- }
-
- /**
- * Tests getAgeCounterRollOver() method.
- */
- @Test
- public void testGetAgeCounterRollOver() throws Exception {
- lsaBin = new LsaBinImpl(1);
- lsdbAge.addLsaBin(1, lsaBin);
- lsdbAge.startDbAging();
- assertThat(lsdbAge.getAgeCounterRollOver(), is(notNullValue()));
- }
-
- /**
- * Tests getMaxAgeBin() method.
- */
- @Test
- public void testGetMaxAgeBin() throws Exception {
- lsaBin = new LsaBinImpl(1);
- lsdbAge.addLsaBin(1, lsaBin);
- lsdbAge.startDbAging();
- assertThat(lsdbAge.getMaxAgeBin(), is(notNullValue()));
- }
-
- /**
- * Tests age2Bin() method.
- */
- @Test
- public void testAge2Bin() throws Exception {
- int age = lsdbAge.age2Bin(0);
- assertThat(age, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/OspfLsdbImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/OspfLsdbImplTest.java
deleted file mode 100644
index f6e1a24..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/OspfLsdbImplTest.java
+++ /dev/null
@@ -1,456 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.lsdb;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.controller.area.OspfAreaImpl;
-import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.lsa.types.AsbrSummaryLsa;
-import org.onosproject.ospf.protocol.lsa.types.ExternalLsa;
-import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa11;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa9;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.lsa.types.SummaryLsa;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for OspfLsdbImpl.
- */
-public class OspfLsdbImplTest {
- private OspfLsdbImpl ospfLsdb;
- private RouterLsa routerLsa;
- private NetworkLsa networkLsa;
- private SummaryLsa summaryLsa;
- private AsbrSummaryLsa asbrSummaryLsa;
- private OpaqueLsa9 opaqueLsa9;
- private OpaqueLsa10 opaqueLsa10;
- private OpaqueLsa11 opaqueLsa11;
- private ExternalLsa externalLsa;
- private OpaqueLsaHeader opaqueLsaHeader;
- private LsaWrapperImpl lsaWrapper;
- private OpaqueLsaHeader opaqueLsaHeader1;
- private String key;
-
- @Before
- public void setUp() throws Exception {
- OspfAreaImpl ospfArea = new OspfAreaImpl();
- ospfLsdb = new OspfLsdbImpl(ospfArea);
- routerLsa = new RouterLsa();
- networkLsa = new NetworkLsa();
- summaryLsa = new SummaryLsa(new LsaHeader());
- asbrSummaryLsa = new AsbrSummaryLsa(new LsaHeader());
- opaqueLsa9 = new OpaqueLsa9(new OpaqueLsaHeader());
- opaqueLsa10 = new OpaqueLsa10(new OpaqueLsaHeader());
- opaqueLsa11 = new OpaqueLsa11(new OpaqueLsaHeader());
- externalLsa = new ExternalLsa(new LsaHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- ospfLsdb = null;
- routerLsa = null;
- externalLsa = null;
- summaryLsa = null;
- asbrSummaryLsa = null;
- opaqueLsa10 = null;
- opaqueLsa11 = null;
- opaqueLsa9 = null;
- networkLsa = null;
- lsaWrapper = null;
- opaqueLsaHeader = null;
- opaqueLsaHeader1 = null;
- key = null;
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEquals() throws Exception {
- assertThat(ospfLsdb.equals(new OspfLsdbImpl(new OspfAreaImpl())), is(false));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- int hashCode = ospfLsdb.hashCode();
- assertThat(hashCode, is(notNullValue()));
- }
-
- /**
- * Tests initializeDb() method.
- */
- @Test
- public void testInitializeDb() throws Exception {
- ospfLsdb.initializeDb();
- assertThat(ospfLsdb, is(notNullValue()));
- }
-
- /**
- * Tests getAllLsaHeaders() method.
- */
- @Test
- public void testGetAllLsaHeaders() throws Exception {
- ospfLsdb.initializeDb();
- routerLsa.setLsType(1);
- assertThat(ospfLsdb.addLsa(routerLsa, false, new OspfInterfaceImpl()), is(true));
- networkLsa.setLsType(2);
- assertThat(ospfLsdb.addLsa(networkLsa, false, new OspfInterfaceImpl()), is(true));
- summaryLsa.setLsType(3);
- assertThat(ospfLsdb.addLsa(summaryLsa, false, new OspfInterfaceImpl()), is(true));
- asbrSummaryLsa.setLsType(4);
- assertThat(ospfLsdb.addLsa(asbrSummaryLsa, false, new OspfInterfaceImpl()), is(true));
- externalLsa.setLsType(5);
- assertThat(ospfLsdb.addLsa(externalLsa, false, new OspfInterfaceImpl()), is(true));
- ospfLsdb.initializeDb();
- assertThat(ospfLsdb.getAllLsaHeaders(true, true).size(), is(5));
- }
-
- /**
- * Tests getLsaKey() method.
- */
- @Test
- public void testGetLsaKey() throws Exception {
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(1);
- assertThat(ospfLsdb.getLsaKey(opaqueLsaHeader), is(notNullValue()));
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(2);
- assertThat(ospfLsdb.getLsaKey(opaqueLsaHeader), is(notNullValue()));
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(3);
- assertThat(ospfLsdb.getLsaKey(opaqueLsaHeader), is(notNullValue()));
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(4);
- assertThat(ospfLsdb.getLsaKey(opaqueLsaHeader), is(notNullValue()));
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(5);
- assertThat(ospfLsdb.getLsaKey(opaqueLsaHeader), is(notNullValue()));
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(9);
- assertThat(ospfLsdb.getLsaKey(opaqueLsaHeader), is(notNullValue()));
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(10);
- assertThat(ospfLsdb.getLsaKey(opaqueLsaHeader), is(notNullValue()));
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(11);
- assertThat(ospfLsdb.getLsaKey(opaqueLsaHeader), is(notNullValue()));
- }
-
- /**
- * Tests lsaLookup() method.
- */
- @Test
- public void testLsaLookup() throws Exception {
- ospfLsdb.initializeDb();
- opaqueLsaHeader = new OpaqueLsaHeader();
- ospfLsdb.addLsa(opaqueLsaHeader, true, new OspfInterfaceImpl());
- opaqueLsaHeader.setLsType(1);
- String key = ospfLsdb.getLsaKey(opaqueLsaHeader);
- assertThat(ospfLsdb.lsaLookup(opaqueLsaHeader), is(nullValue()));
- }
-
- /**
- * Tests findLsa() method.
- */
- @Test
- public void testFindlsa() throws Exception {
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(1);
- key = ospfLsdb.getLsaKey(opaqueLsaHeader);
- ospfLsdb.addLsa(new RouterLsa(), false, new OspfInterfaceImpl());
- lsaWrapper = (LsaWrapperImpl) ospfLsdb.findLsa(opaqueLsaHeader.lsType(), key);
- assertThat(lsaWrapper, is(nullValue()));
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(2);
- key = ospfLsdb.getLsaKey(opaqueLsaHeader);
- ospfLsdb.addLsa(new RouterLsa(), false, new OspfInterfaceImpl());
- lsaWrapper = (LsaWrapperImpl) ospfLsdb.findLsa(opaqueLsaHeader.lsType(), key);
- assertThat(lsaWrapper, is(nullValue()));
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(3);
- key = ospfLsdb.getLsaKey(opaqueLsaHeader);
- ospfLsdb.addLsa(new RouterLsa(), false, new OspfInterfaceImpl());
- lsaWrapper = (LsaWrapperImpl) ospfLsdb.findLsa(opaqueLsaHeader.lsType(), key);
- assertThat(lsaWrapper, is(nullValue()));
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(4);
- key = ospfLsdb.getLsaKey(opaqueLsaHeader);
- ospfLsdb.addLsa(new RouterLsa(), false, new OspfInterfaceImpl());
- lsaWrapper = (LsaWrapperImpl) ospfLsdb.findLsa(opaqueLsaHeader.lsType(), key);
- assertThat(lsaWrapper, is(nullValue()));
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(5);
- key = ospfLsdb.getLsaKey(opaqueLsaHeader);
- ospfLsdb.addLsa(new RouterLsa(), false, new OspfInterfaceImpl());
- lsaWrapper = (LsaWrapperImpl) ospfLsdb.findLsa(opaqueLsaHeader.lsType(), key);
- assertThat(lsaWrapper, is(nullValue()));
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(9);
- key = ospfLsdb.getLsaKey(opaqueLsaHeader);
- ospfLsdb.addLsa(new RouterLsa(), false, new OspfInterfaceImpl());
- lsaWrapper = (LsaWrapperImpl) ospfLsdb.findLsa(opaqueLsaHeader.lsType(), key);
- assertThat(lsaWrapper, is(nullValue()));
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(10);
- key = ospfLsdb.getLsaKey(opaqueLsaHeader);
- ospfLsdb.addLsa(new RouterLsa(), false, new OspfInterfaceImpl());
- lsaWrapper = (LsaWrapperImpl) ospfLsdb.findLsa(opaqueLsaHeader.lsType(), key);
- assertThat(lsaWrapper, is(nullValue()));
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(11);
- key = ospfLsdb.getLsaKey(opaqueLsaHeader);
- ospfLsdb.addLsa(new RouterLsa(), false, new OspfInterfaceImpl());
- lsaWrapper = (LsaWrapperImpl) ospfLsdb.findLsa(opaqueLsaHeader.lsType(), key);
- assertThat(lsaWrapper, is(nullValue()));
- }
-
- /**
- * Tests addLSA() method.
- */
- @Test
- public void testAddLsa() throws Exception {
- routerLsa.setLsType(1);
- assertThat(ospfLsdb.addLsa(routerLsa, false, new OspfInterfaceImpl()), is(true));
- networkLsa.setLsType(2);
- assertThat(ospfLsdb.addLsa(networkLsa, false, new OspfInterfaceImpl()), is(true));
- summaryLsa.setLsType(3);
- assertThat(ospfLsdb.addLsa(summaryLsa, false, new OspfInterfaceImpl()), is(true));
- asbrSummaryLsa.setLsType(4);
- assertThat(ospfLsdb.addLsa(asbrSummaryLsa, false, new OspfInterfaceImpl()), is(true));
- externalLsa.setLsType(5);
- assertThat(ospfLsdb.addLsa(externalLsa, false, new OspfInterfaceImpl()), is(true));
- opaqueLsa9.setLsType(9);
- assertThat(ospfLsdb.addLsa(opaqueLsa9, false, new OspfInterfaceImpl()), is(true));
- opaqueLsa10.setLsType(10);
- assertThat(ospfLsdb.addLsa(opaqueLsa10, false, new OspfInterfaceImpl()), is(true));
- opaqueLsa11.setLsType(11);
- assertThat(ospfLsdb.addLsa(opaqueLsa11, false, new OspfInterfaceImpl()), is(true));
-
- }
-
- /**
- * Tests addLsaToMaxAgeBin() method.
- */
- @Test
- public void testAddLsaToMaxAgeBin() throws Exception {
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(1);
- key = ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader((OpaqueLsaHeader) opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(2);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(3);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(4);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(5);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(9);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(10);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(11);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- assertThat(ospfLsdb, is(notNullValue()));
- }
-
- /**
- * Tests removeLsaFromBin() method.
- */
- @Test
- public void testRemoveLsaFromBin() throws Exception {
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(1);
- key = ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- ospfLsdb.removeLsaFromBin(lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(2);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- ospfLsdb.removeLsaFromBin(lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(3);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- ospfLsdb.removeLsaFromBin(lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(4);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- ospfLsdb.removeLsaFromBin(lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(5);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- ospfLsdb.removeLsaFromBin(lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(9);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- ospfLsdb.removeLsaFromBin(lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(10);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- ospfLsdb.removeLsaFromBin(lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(11);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- ospfLsdb.removeLsaFromBin(lsaWrapper);
- assertThat(ospfLsdb, is(notNullValue()));
- }
-
- /**
- * Tests isNewerOrSameLsa() method.
- */
- @Test
- public void testIsNewerorSameLsa() throws Exception {
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader1 = new OpaqueLsaHeader();
- opaqueLsaHeader1.setLsType(1);
- key = ospfLsdb.getLsaKey(opaqueLsaHeader1);
- lsaWrapper.setLsaHeader(opaqueLsaHeader1);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- lsaWrapper = new LsaWrapperImpl();
- opaqueLsaHeader = new OpaqueLsaHeader();
- opaqueLsaHeader.setLsType(2);
- ospfLsdb.getLsaKey(opaqueLsaHeader);
- lsaWrapper.setLsaHeader(opaqueLsaHeader);
- ospfLsdb.addLsaToMaxAgeBin(key, lsaWrapper);
- assertThat(ospfLsdb.isNewerOrSameLsa(opaqueLsaHeader1, opaqueLsaHeader), is(notNullValue()));
- assertThat(ospfLsdb, is(notNullValue()));
- }
-
- /**
- * Tests getLsSequenceNumber() method.
- */
- @Test
- public void testGetLsSequenceNumber() throws Exception {
- assertThat(ospfLsdb.getLsSequenceNumber(OspfLsaType.NETWORK), is(notNullValue()));
- assertThat(ospfLsdb.getLsSequenceNumber(OspfLsaType.ROUTER), is(notNullValue()));
- }
-
- /**
- * Tests deleteLsa() method.
- */
- @Test
- public void testDeleteLsa() throws Exception {
- opaqueLsaHeader1 = new OpaqueLsaHeader();
- opaqueLsaHeader1.setLsType(1);
- ospfLsdb.deleteLsa(opaqueLsaHeader1);
- opaqueLsaHeader1 = new OpaqueLsaHeader();
- opaqueLsaHeader1.setLsType(2);
- ospfLsdb.deleteLsa(opaqueLsaHeader1);
- opaqueLsaHeader1 = new OpaqueLsaHeader();
- opaqueLsaHeader1.setLsType(3);
- ospfLsdb.deleteLsa(opaqueLsaHeader1);
- opaqueLsaHeader1 = new OpaqueLsaHeader();
- opaqueLsaHeader1.setLsType(4);
- ospfLsdb.deleteLsa(opaqueLsaHeader1);
- opaqueLsaHeader1 = new OpaqueLsaHeader();
- opaqueLsaHeader1.setLsType(5);
- ospfLsdb.deleteLsa(opaqueLsaHeader1);
- opaqueLsaHeader1 = new OpaqueLsaHeader();
- opaqueLsaHeader1.setLsType(9);
- ospfLsdb.deleteLsa(opaqueLsaHeader1);
- opaqueLsaHeader1 = new OpaqueLsaHeader();
- opaqueLsaHeader1.setLsType(10);
- ospfLsdb.deleteLsa(opaqueLsaHeader1);
- opaqueLsaHeader1 = new OpaqueLsaHeader();
- opaqueLsaHeader1.setLsType(11);
- ospfLsdb.deleteLsa(opaqueLsaHeader1);
- assertThat(ospfLsdb, is(notNullValue()));
-
- }
-
- /**
- * Tests getLsSequenceNumber() method.
- */
- @Test
- public void testSetRouterLsaSeqNo() throws Exception {
- ospfLsdb.setRouterLsaSeqNo(-2147483647);
- assertThat(ospfLsdb.getLsSequenceNumber(OspfLsaType.ROUTER), is(-2147483647L));
- }
-
- /**
- * Tests getLsSequenceNumber() method.
- */
- @Test
- public void testSetNetworkLsaSeqNo() throws Exception {
- ospfLsdb.setNetworkLsaSeqNo(111111);
- assertThat(ospfLsdb.getLsSequenceNumber(OspfLsaType.NETWORK), is(111111L));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/util/OspfEligibleRouterTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/util/OspfEligibleRouterTest.java
deleted file mode 100644
index 47bbb92..0000000
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/util/OspfEligibleRouterTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.controller.util;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for OspfEligibleRouter.
- */
-public class OspfEligibleRouterTest {
-
- private OspfEligibleRouter ospfEligibleRouter;
-
- @Before
- public void setUp() throws Exception {
- ospfEligibleRouter = new OspfEligibleRouter();
- }
-
- @After
- public void tearDown() throws Exception {
- ospfEligibleRouter = null;
- }
-
- /**
- * Tests getIpAddress() getter method.
- */
- @Test
- public void testGetIpAddress() throws Exception {
- ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfEligibleRouter.getIpAddress(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests setIpAddress() setter method.
- */
- @Test
- public void testSetIpAddress() throws Exception {
- ospfEligibleRouter.setIpAddress(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfEligibleRouter.getIpAddress(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests getRouterId() getter method.
- */
- @Test
- public void testGetRouterId() throws Exception {
- ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfEligibleRouter.getRouterId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests setRouterId() setter method.
- */
- @Test
- public void testSetRouterId() throws Exception {
- ospfEligibleRouter.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfEligibleRouter.getRouterId(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests getRouterPriority() getter method.
- */
- @Test
- public void testGetRouterPriority() throws Exception {
- ospfEligibleRouter.setRouterPriority(1);
- assertThat(ospfEligibleRouter.getRouterPriority(), is(1));
- }
-
- /**
- * Tests getRouterPriority() setter method.
- */
- @Test
- public void testSetRouterPriority() throws Exception {
- ospfEligibleRouter.setRouterPriority(1);
- assertThat(ospfEligibleRouter.getRouterPriority(), is(1));
- }
-
- /**
- * Tests isDr() getter method.
- */
- @Test
- public void testIsDr() throws Exception {
- ospfEligibleRouter.setIsDr(true);
- assertThat(ospfEligibleRouter.isDr(), is(true));
- }
-
- /**
- * Tests isDr() setter method.
- */
- @Test
- public void testSetIsDr() throws Exception {
- ospfEligibleRouter.setIsDr(true);
- assertThat(ospfEligibleRouter.isDr(), is(true));
- }
-
- /**
- * Tests isBdr() getter method.
- */
- @Test
- public void testIsBdr() throws Exception {
- ospfEligibleRouter.setIsBdr(true);
- assertThat(ospfEligibleRouter.isBdr(), is(true));
- }
-
- /**
- * Tests isBdr() setter method.
- */
- @Test
- public void testSetIsBdr() throws Exception {
- ospfEligibleRouter.setIsBdr(true);
- assertThat(ospfEligibleRouter.isBdr(), is(true));
- }
-}
diff --git a/protocols/ospf/protocol/BUILD b/protocols/ospf/protocol/BUILD
deleted file mode 100644
index 7de13a9..0000000
--- a/protocols/ospf/protocol/BUILD
+++ /dev/null
@@ -1,8 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + NETTY + JAXB + [
- "@io_netty_netty//jar",
- "//protocols/ospf/api:onos-protocols-ospf-api",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/exceptions/OspfErrorType.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/exceptions/OspfErrorType.java
deleted file mode 100644
index cab1240..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/exceptions/OspfErrorType.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.exceptions;
-
-/**
- * Defines all error codes and error sub codes.
- */
-public final class OspfErrorType {
-
- //Represents an invalid OSPF message header
- public static final byte MESSAGE_HEADER_ERROR = 1;
- //Represents an invalid OSPF message body
- public static final byte OSPF_MESSAGE_ERROR = 2;
- //Message Header error sub codes
- //Represents an invalid OSPF message length
- public static final byte BAD_MESSAGE_LENGTH = 2;
- //Represents an invalid OSPF message
- public static final byte BAD_MESSAGE = 4;
-
- /**
- * Creates an instance of OSPF error type.
- */
- private OspfErrorType() {
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/exceptions/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/exceptions/package-info.java
deleted file mode 100644
index db2cc81..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/exceptions/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the OSPF exception types.
- */
-package org.onosproject.ospf.exceptions;
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/package-info.java
deleted file mode 100644
index e55f1bd..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ospf protocol.
- */
-package org.onosproject.ospf;
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/LsaHeader.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/LsaHeader.java
deleted file mode 100644
index 864a746..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/LsaHeader.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ospf.protocol.lsa;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.primitives.Bytes;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfLsa;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Defines the LSA header, fields and the methods to access them.
- */
-public class LsaHeader implements OspfLsa {
-
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS age | Options | LS type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Link State ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Advertising Router |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS sequence number |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS checksum | length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- LSA header format
- REFERENCE : RFC 2328
- */
- public static final Logger log = LoggerFactory.getLogger(LsaHeader.class);
- private int age;
- private int options;
- private int lsType;
- private long lsSequenceNo;
- private int lsCheckSum;
- private int lsPacketLen;
- private String linkStateId;
- private Ip4Address advertisingRouter;
-
- /**
- * Gets LSA age.
- *
- * @return LSA age
- */
- public int age() {
- return age;
- }
-
- /**
- * Sets LSA age.
- *
- * @param age LSA age
- */
- public void setAge(int age) {
- this.age = age;
- }
-
- /**
- * Gets options value.
- *
- * @return options header value
- */
- public int options() {
- return options;
- }
-
- /**
- * Sets options header value.
- *
- * @param options header value
- */
- public void setOptions(int options) {
- this.options = options;
- }
-
- /**
- * Gets LSA type.
- *
- * @return LSA type
- */
- public int lsType() {
- return lsType;
- }
-
- /**
- * Sets LSA type.
- *
- * @param lsType LSA type
- */
- public void setLsType(int lsType) {
- this.lsType = lsType;
- }
-
- /**
- * Gets link state id.
- *
- * @return linkStateId link state id
- */
- public String linkStateId() {
- return linkStateId;
- }
-
- /**
- * Sets link state id.
- *
- * @param linkStateId link state id
- */
- public void setLinkStateId(String linkStateId) {
- this.linkStateId = linkStateId;
- }
-
- /**
- * Gets advertising router IP.
- *
- * @return advertising router
- */
- public Ip4Address advertisingRouter() {
- return advertisingRouter;
- }
-
- /**
- * Sets advertising router.
- *
- * @param advertisingRouter advertising router
- */
- public void setAdvertisingRouter(Ip4Address advertisingRouter) {
- this.advertisingRouter = advertisingRouter;
- }
-
- /**
- * Gets LSA sequence number.
- *
- * @return LSA sequence number
- */
- public long lsSequenceNo() {
- return lsSequenceNo;
- }
-
- /**
- * Sets LSA sequence number.
- *
- * @param lsSequenceNo LSA sequence number
- */
- public void setLsSequenceNo(long lsSequenceNo) {
- this.lsSequenceNo = lsSequenceNo;
- }
-
- /**
- * Gets LSA check sum.
- *
- * @return lsCheckSum LSA checksum
- */
- public int lsCheckSum() {
- return lsCheckSum;
- }
-
- /**
- * Sets LSA checksum.
- *
- * @param lsCheckSum LSA checksum
- */
- public void setLsCheckSum(int lsCheckSum) {
- this.lsCheckSum = lsCheckSum;
- }
-
- /**
- * Gets lsa packet length.
- *
- * @return lsPacketLen LSA packet length
- */
- public int lsPacketLen() {
- return lsPacketLen;
- }
-
- /**
- * Sets LSA packet length.
- *
- * @param lsPacketLen LSA packet length
- */
- public void setLsPacketLen(int lsPacketLen) {
- this.lsPacketLen = lsPacketLen;
- }
-
- @Override
- public OspfLsaType getOspfLsaType() {
- if (lsType == OspfLsaType.ROUTER.value()) {
- return OspfLsaType.ROUTER;
- } else if (lsType == OspfLsaType.NETWORK.value()) {
- return OspfLsaType.NETWORK;
- } else if (lsType == OspfLsaType.SUMMARY.value()) {
- return OspfLsaType.SUMMARY;
- } else if (lsType == OspfLsaType.ASBR_SUMMARY.value()) {
- return OspfLsaType.ASBR_SUMMARY;
- } else if (lsType == OspfLsaType.EXTERNAL_LSA.value()) {
- return OspfLsaType.EXTERNAL_LSA;
- } else if (lsType == OspfLsaType.LINK_LOCAL_OPAQUE_LSA.value()) {
- return OspfLsaType.LINK_LOCAL_OPAQUE_LSA;
- } else if (lsType == OspfLsaType.AREA_LOCAL_OPAQUE_LSA.value()) {
- return OspfLsaType.AREA_LOCAL_OPAQUE_LSA;
- } else if (lsType == OspfLsaType.AS_OPAQUE_LSA.value()) {
- return OspfLsaType.AS_OPAQUE_LSA;
- }
-
- return OspfLsaType.UNDEFINED;
- }
-
- @Override
- public OspfLsa lsaHeader() {
- return this;
- }
-
- /**
- * Gets the LSA header as bytes.
- *
- * @return LSA header as bytes
- */
- public byte[] getLsaHeaderAsByteArray() {
- List<Byte> headerLst = new ArrayList<>();
- try {
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.age())));
- headerLst.add((byte) this.options());
- headerLst.add((byte) this.lsType());
- headerLst.addAll(Bytes.asList(InetAddress.getByName(this.linkStateId()).getAddress()));
- headerLst.addAll(Bytes.asList(this.advertisingRouter().toOctets()));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.lsSequenceNo())));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.lsCheckSum())));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.lsPacketLen())));
- } catch (Exception e) {
- log.debug("Error::getLsaHeaderAsByteArray {}", e.getMessage());
- return Bytes.toArray(headerLst);
- }
- return Bytes.toArray(headerLst);
- }
-
- /**
- * Populates the header from the LSA header instance.
- *
- * @param lsaHeader LSA header instance
- */
- public void populateHeader(LsaHeader lsaHeader) {
- //assign all the header values
- this.setAge(lsaHeader.age());
- this.setOptions(lsaHeader.options());
- this.setLsType(lsaHeader.lsType());
- this.setLinkStateId(lsaHeader.linkStateId());
- this.setAdvertisingRouter(lsaHeader.advertisingRouter());
- this.setLsSequenceNo(lsaHeader.lsSequenceNo());
- this.setLsCheckSum(lsaHeader.lsCheckSum());
- this.setLsPacketLen(lsaHeader.lsPacketLen());
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- LsaHeader that = (LsaHeader) o;
- return Objects.equal(age, that.age) &&
- Objects.equal(options, that.options) &&
- Objects.equal(lsType, that.lsType) &&
- Objects.equal(lsSequenceNo, that.lsSequenceNo) &&
- Objects.equal(lsCheckSum, that.lsCheckSum) &&
- Objects.equal(lsPacketLen, that.lsPacketLen) &&
- Objects.equal(linkStateId, that.linkStateId) &&
- Objects.equal(advertisingRouter, that.advertisingRouter);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(age, options, lsType, lsSequenceNo, lsCheckSum,
- lsPacketLen, linkStateId, advertisingRouter);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("age", age)
- .add("options", options)
- .add("lsType", lsType)
- .add("lsSequenceNo", lsSequenceNo)
- .add("lsCheckSum", lsCheckSum)
- .add("lsPacketLen", lsPacketLen)
- .add("linkStateId;", linkStateId)
- .add("advertisingRouter", advertisingRouter)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/OpaqueLsaHeader.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/OpaqueLsaHeader.java
deleted file mode 100644
index c2da0c3..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/OpaqueLsaHeader.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.primitives.Bytes;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Defines the Opaque LSA header, fields and the methods to access them.
- */
-public class OpaqueLsaHeader extends LsaHeader {
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS age | Options | 9, 10, or 11 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Opaque Type | Opaque ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Advertising Router |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS Sequence Number |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS checksum | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Opaque LSA header format
- REFERENCE : RFC 5250
- */
- private int opaqueId;
- private int opaqueType;
-
- /**
- * Populates the header from the lsaHeader instance.
- *
- * @param lsaHeader lsa header instance.
- */
- public void populateHeader(OpaqueLsaHeader lsaHeader) {
- //assign all the header values
- this.setAge(lsaHeader.age());
- this.setOptions(lsaHeader.options());
- this.setLsType(lsaHeader.lsType());
- this.setLinkStateId(lsaHeader.linkStateId());
- this.setAdvertisingRouter(lsaHeader.advertisingRouter());
- this.setLsSequenceNo(lsaHeader.lsSequenceNo());
- this.setLsCheckSum(lsaHeader.lsCheckSum());
- this.setLsPacketLen(lsaHeader.lsPacketLen());
- this.setOpaqueId(lsaHeader.opaqueId());
- this.setOpaqueType(lsaHeader.opaqueType());
- }
-
- /**
- * Gets the opaque id.
- *
- * @return opaque id
- */
- public int opaqueId() {
- return opaqueId;
- }
-
- /**
- * Sets the opaque id.
- *
- * @param opaqueId opaque id
- */
- public void setOpaqueId(int opaqueId) {
- this.opaqueId = opaqueId;
- }
-
- /**
- * Gets opaque type.
- *
- * @return opaque type
- */
- public int opaqueType() {
- return opaqueType;
- }
-
- /**
- * Sets opaque type.
- *
- * @param opaqueType opaque type
- */
- public void setOpaqueType(int opaqueType) {
- this.opaqueType = opaqueType;
- }
-
- /**
- * Gets header as byte array.
- *
- * @return header as byte array
- */
- public byte[] getOpaqueLsaHeaderAsByteArray() {
- List<Byte> headerLst = new ArrayList<>();
- try {
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.age())));
- headerLst.add((byte) this.options());
- headerLst.add((byte) this.lsType());
- headerLst.add((byte) this.opaqueType());
- headerLst.addAll(Bytes.asList(OspfUtil.convertToThreeBytes(this.opaqueId())));
- headerLst.addAll(Bytes.asList(this.advertisingRouter().toOctets()));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.lsSequenceNo())));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.lsCheckSum())));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.lsPacketLen())));
- } catch (Exception e) {
- log.debug("Error::getLsaHeaderAsByteArray {}", e.getMessage());
- return Bytes.toArray(headerLst);
- }
- return Bytes.toArray(headerLst);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- OpaqueLsaHeader that = (OpaqueLsaHeader) o;
- return Objects.equal(opaqueId, that.opaqueId) &&
- Objects.equal(opaqueType, that.opaqueType) &&
- Objects.equal(age(), that.age()) &&
- Objects.equal(options(), that.options()) &&
- Objects.equal(lsType(), that.lsType()) &&
- Objects.equal(lsSequenceNo(), that.lsSequenceNo()) &&
- Objects.equal(lsCheckSum(), that.lsCheckSum()) &&
- Objects.equal(lsPacketLen(), that.lsPacketLen()) &&
- Objects.equal(linkStateId(), that.linkStateId()) &&
- Objects.equal(advertisingRouter(), that.advertisingRouter());
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(opaqueId, opaqueType);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("opaqueId", this.opaqueId)
- .add("opaqueType", opaqueType)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/TlvHeader.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/TlvHeader.java
deleted file mode 100644
index 22b0d67..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/TlvHeader.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of a TLV header.
- */
-public class TlvHeader {
- private int tlvType;
- private int tlvLength;
-
- /**
- * Gets TLV length.
- *
- * @return TLV length
- */
- public int tlvLength() {
- return tlvLength;
- }
-
- /**
- * Sets TLV length.
- *
- * @param tlvLength TLV length
- */
- public void setTlvLength(int tlvLength) {
- this.tlvLength = tlvLength;
- }
-
- /**
- * Gets TLV type.
- *
- * @return TLV type
- */
- public int tlvType() {
- return tlvType;
- }
-
- /**
- * Sets TLV type.
- *
- * @param tlvType TLV type
- */
- public void setTlvType(int tlvType) {
- this.tlvType = tlvType;
- }
-
- /**
- * Gets TLV header as bytes.
- *
- * @return TLV header as bytes
- */
- public byte[] getTlvHeaderAsByteArray() {
- List<Byte> headerLst = new ArrayList();
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.tlvType)));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.tlvLength)));
- return Bytes.toArray(headerLst);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("tlvType", tlvType)
- .add("tlvLength", tlvLength)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/AdministrativeGroup.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/AdministrativeGroup.java
deleted file mode 100644
index 16aa7c9..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/AdministrativeGroup.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-
-/**
- * Representation of an administrative group value of link tlv of Traffic Engineering..
- */
-public class AdministrativeGroup extends TlvHeader implements LinkSubType {
-
- private int administrativeGroup;
-
- /**
- * Creates an administrative group instance.
- *
- * @param header Tlv Header instance
- */
- public AdministrativeGroup(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Gets administrative group value.
- *
- * @return administrative group value
- */
- public int administrativeGroup() {
- return administrativeGroup;
- }
-
- /**
- * Sets administrative group value.
- *
- * @param administrativeGroup value
- */
- public void setAdministrativeGroup(int administrativeGroup) {
- this.administrativeGroup = administrativeGroup;
- }
-
- /**
- * Gets administrative group value.
- *
- * @return administrativeGroup value
- */
- public int getAdministrativeGroupValue() {
- return this.administrativeGroup;
- }
-
- /**
- * Reads bytes from channel buffer.
- *
- * @param channelBuffer Channel buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- byte[] tempByteArray = new byte[tlvLength()];
- channelBuffer.readBytes(tempByteArray, 0, tlvLength());
- this.setAdministrativeGroup(OspfUtil.byteToInteger(tempByteArray));
- }
-
- /**
- * Returns administrative group as byte array.
- *
- * @return administrative group instance as byte array
- */
- public byte[] asBytes() {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
- byte[] linkSubTlvBody = getLinkSubTypeTlvBodyAsByteArray();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
-
- return linkSubType;
- }
-
- /**
- * Gets administrative group body as byte array.
- *
- * @return byte array of sub tlv administrative group
- */
- public byte[] getLinkSubTypeTlvBodyAsByteArray() {
-
- byte[] linkSubTypeBody;
- linkSubTypeBody = OspfUtil.convertToFourBytes(this.administrativeGroup);
-
- return linkSubTypeBody;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("administrativeGroup", administrativeGroup)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkId.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkId.java
deleted file mode 100644
index e530097..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkId.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-/**
- * Representation of link id value of link tlv of Traffic Engineering.
- */
-public class LinkId extends TlvHeader implements LinkSubType {
- private static final Logger log =
- LoggerFactory.getLogger(LinkId.class);
- private String linkId;
-
- /**
- * Creates an instance of link id.
- *
- * @param header tlv header instance
- */
- public LinkId(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Sets link type.
- *
- * @param linkType link type value
- */
- public void setLinkId(String linkType) {
- this.linkId = linkType;
- }
-
- /**
- * Reads bytes from channel buffer.
- *
- * @param channelBuffer channel buffer instance
- * @throws OspfParseException might throws exception while parsing packet
- */
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
- try {
- byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- this.setLinkId(InetAddress.getByAddress(tempByteArray).getHostName());
- } catch (UnknownHostException e) {
- log.debug("Error::LinkId:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR,
- OspfErrorType.BAD_MESSAGE);
- }
- }
-
- /**
- * Returns instance as byte array.
- *
- * @return instance as bytes
- * @throws OspfParseException might throws exception while parsing packet
- */
- public byte[] asBytes() throws OspfParseException {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
- byte[] linkSubTlvBody = getLinkSubTypeTlvBodyAsByteArray();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
-
- return linkSubType;
- }
-
- /**
- * Gets byte array of link id sub tlv body.
- *
- * @return gets the body as byte array
- * @throws OspfParseException might throws exception while parsing packet
- */
- public byte[] getLinkSubTypeTlvBodyAsByteArray() throws OspfParseException {
- byte[] linkSubTypeBody = null;
- try {
- linkSubTypeBody = InetAddress.getByName(this.linkId).getAddress();
- } catch (Exception e) {
- log.debug("Error::LinkId:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR,
- OspfErrorType.BAD_MESSAGE);
- }
- return linkSubTypeBody;
- }
-
- /**
- * Returns this instance as string.
- *
- * @return this instance as string
- */
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("linkId", linkId)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkSubType.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkSubType.java
deleted file mode 100644
index 3703bfe..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkSubType.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-/**
- * Marker interface to represent TE Link sub types.
- */
-public interface LinkSubType {
-}
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkSubTypes.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkSubTypes.java
deleted file mode 100644
index f5cda35..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkSubTypes.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-/**
- * Representation of TE link sub types.
- */
-public enum LinkSubTypes {
- LINK_TYPE(1),
- LINK_ID(2),
- LOCAL_INTERFACE_IP_ADDRESS(3),
- REMOTE_INTERFACE_IP_ADDRESS(4),
- TRAFFIC_ENGINEERING_METRIC(5),
- MAXIMUM_BANDWIDTH(6),
- MAXIMUM_RESERVABLE_BANDWIDTH(7),
- UNRESERVED_BANDWIDTH(8),
- ADMINISTRATIVE_GROUP(9);
-
- private int value;
-
- /**
- * Creates an instance of link sub types.
- *
- * @param value link sub type value
- */
- LinkSubTypes(int value) {
- this.value = value;
- }
-
- /**
- * Gets the link sub type value.
- *
- * @return link sub type value
- */
- public int value() {
- return value;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkType.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkType.java
deleted file mode 100644
index a1a2ac9..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkType.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Representation of link type TE value.
- */
-public class LinkType extends TlvHeader implements LinkSubType {
- private static final Logger log =
- LoggerFactory.getLogger(LinkType.class);
- private int linkType;
-
- /**
- * Creates link type instance .
- */
- public LinkType() {
-
- }
-
- /**
- * Creates link type instance.
- *
- * @param header tlv header instance
- */
- public LinkType(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Sets link type.
- *
- * @param linkType value of link type
- */
- public void setLinkType(int linkType) {
- this.linkType = linkType;
- }
-
- /**
- * Reads from channel buffer.
- *
- * @param channelBuffer channel buffer instance
- * @throws OspfParseException might throws exception while parsing buffer
- */
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
- try {
- int len = channelBuffer.readableBytes();
- byte[] tempByteArray = new byte[len];
- channelBuffer.readBytes(tempByteArray, 0, len);
- this.setLinkType(OspfUtil.byteToInteger(tempByteArray));
- } catch (Exception e) {
- log.debug("Error::LinkType:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR,
- OspfErrorType.BAD_MESSAGE);
- }
- }
-
- /**
- * Gets link subtype as byte array.
- *
- * @return byte array of link subtype
- */
- public byte[] asBytes() {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
- byte[] linkSubTlvBody = getLinkSubTypeTlvBodyAsByteArray();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
- return linkSubType;
- }
-
- /**
- * Gets link subtype as bytes.
- *
- * @return byte array of link subtype
- */
- public byte[] getLinkSubTypeTlvBodyAsByteArray() {
- byte[] linkSubTypeBody = new byte[4];
- linkSubTypeBody[0] = (byte) this.linkType;
- linkSubTypeBody[1] = 0;
- linkSubTypeBody[2] = 0;
- linkSubTypeBody[3] = 0;
- return linkSubTypeBody;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("linkType", linkType)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddress.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddress.java
deleted file mode 100644
index 0214ccc..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddress.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of local interface ip address TE value.
- */
-public class LocalInterfaceIpAddress extends TlvHeader implements LinkSubType {
- private static final Logger log =
- LoggerFactory.getLogger(RemoteInterfaceIpAddress.class);
- private List<String> localInterfaceIPAddress = new ArrayList<>();
-
- /**
- * Creates an instance of local interface ip address.
- *
- * @param header tlv header instance
- */
- public LocalInterfaceIpAddress(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Adds local interface ip address.
- *
- * @param localAddress ip address
- */
- public void addLocalInterfaceIPAddress(String localAddress) {
- localInterfaceIPAddress.add(localAddress);
- }
-
- /**
- * Gets local interface ip address.
- *
- * @return localAddress ip address
- */
- public List<String> getLocalInterfaceIPAddress() {
- return localInterfaceIPAddress;
- }
-
- /**
- * Reads bytes from channel buffer.
- *
- * @param channelBuffer channel buffer instance
- * @throws OspfParseException might throws exception while parsing buffer
- */
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
- while (channelBuffer.readableBytes() >= OspfUtil.FOUR_BYTES) {
- try {
- byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- this.addLocalInterfaceIPAddress(InetAddress.getByAddress(tempByteArray).getHostName());
- } catch (UnknownHostException e) {
- log.debug("Error::readFrom:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR,
- OspfErrorType.BAD_MESSAGE);
- }
- }
- }
-
- /**
- * Gets local interface ip address as byte array.
- *
- * @return local interface ip address as byte array
- * @throws OspfParseException might throws exception while parsing packet
- */
- public byte[] asBytes() throws OspfParseException {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
- byte[] linkSubTlvBody = getLinkSubTypeTlvBodyAsByteArray();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
-
- return linkSubType;
- }
-
- /**
- * Gets byte array of local interface ip address.
- *
- * @return byte array of local interface ip address
- * @throws OspfParseException might throws exception while parsing packet
- */
- public byte[] getLinkSubTypeTlvBodyAsByteArray() throws OspfParseException {
-
- List<Byte> linkSubTypeBody = new ArrayList<>();
-
- for (String remoteAddress : this.localInterfaceIPAddress) {
- try {
- linkSubTypeBody.addAll(Bytes.asList(InetAddress.getByName(remoteAddress).getAddress()));
- } catch (Exception e) {
- log.debug("Error::getLinkSubTypeTlvBodyAsByteArray:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR,
- OspfErrorType.BAD_MESSAGE);
- }
- }
-
- return Bytes.toArray(linkSubTypeBody);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("localInterfaceIPAddress", localInterfaceIPAddress)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumBandwidth.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumBandwidth.java
deleted file mode 100644
index 495040c..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumBandwidth.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-
-/**
- * Representation of maximum bandwidth TE value.
- */
-public class MaximumBandwidth extends TlvHeader implements LinkSubType {
- private float maximumBandwidth;
-
- /**
- * Creates an instance of maximum bandwidth.
- *
- * @param header tlv header instance
- */
- public MaximumBandwidth(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Sets value of maximum bandwidth.
- *
- * @param maximumBandwidth value of maximum bandwidth
- */
- public void setMaximumBandwidth(float maximumBandwidth) {
- this.maximumBandwidth = maximumBandwidth;
- }
-
- /**
- * Gets value of maximum bandwidth.
- *
- * @return maximumBandwidth value of maximum bandwidth
- */
- public float getMaximumBandwidthValue() {
- return this.maximumBandwidth;
- }
-
- /**
- * Reads bytes from channel buffer.
- *
- * @param channelBuffer channel buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- byte[] tempByteArray = new byte[tlvLength()];
- channelBuffer.readBytes(tempByteArray, 0, tlvLength());
- int maxBandwidth = (OspfUtil.byteToInteger(tempByteArray));
- this.setMaximumBandwidth(Float.intBitsToFloat(maxBandwidth));
- }
-
- /**
- * Gets byte array of maximum bandwidth sub tlv.
- *
- * @return byte array of maximum bandwidth sub tlv
- */
- public byte[] asBytes() {
- byte[] linkSubType = null;
- byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
- byte[] linkSubTlvBody = getLinkSubTypeTlvBodyAsByteArray();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
-
- return linkSubType;
- }
-
- /**
- * Gets maximum bandwidth sub tlv byte array.
- *
- * @return byte array of maximum bandwidth sub tlv
- */
- public byte[] getLinkSubTypeTlvBodyAsByteArray() {
- byte[] linkSubTypeBody;
- linkSubTypeBody = OspfUtil.convertToFourBytes(Float.floatToIntBits(this.maximumBandwidth));
- return linkSubTypeBody;
- }
-
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("maximumBandwidth", maximumBandwidth)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumReservableBandwidth.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumReservableBandwidth.java
deleted file mode 100644
index 2b4e6d3..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumReservableBandwidth.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-
-/**
- * Representation of maximum reservable bandwidth TE value.
- */
-public class MaximumReservableBandwidth extends TlvHeader implements LinkSubType {
- private float maximumReservableBandwidth;
-
- /**
- * Creates an instance of maximum reservable bandwidth.
- *
- * @param header tlv header
- */
- public MaximumReservableBandwidth(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Sets value of maximum reversible bandwidth.
- *
- * @param maximumBandwidth maximum reversible bandwidth
- */
- public void setMaximumBandwidth(float maximumBandwidth) {
- this.maximumReservableBandwidth = maximumBandwidth;
- }
-
- /**
- * Gets value of maximum reversible bandwidth.
- *
- * @return maximumBandwidth maximum reversible bandwidth
- */
- public float getMaximumBandwidthValue() {
- return this.maximumReservableBandwidth;
- }
-
- /**
- * Reads bytes from channel buffer.
- *
- * @param channelBuffer channel buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- byte[] tempByteArray = new byte[tlvLength()];
- channelBuffer.readBytes(tempByteArray, 0, tlvLength());
- int maxBandwidth = (OspfUtil.byteToInteger(tempByteArray));
- this.setMaximumBandwidth(Float.intBitsToFloat(maxBandwidth));
- }
-
- /**
- * Returns byte array of maximum reservable bandwidth.
- *
- * @return byte array of maximum reservable bandwidth
- */
- public byte[] asBytes() {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
- byte[] linkSubTlvBody = getLinksubTypeTlvBodyAsByteArray();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
- return linkSubType;
-
- }
-
- /**
- * Gets maximum reservable bandwidth sub tlv body as byte array.
- *
- * @return byte of maximum reservable bandwidth sub tlv body
- */
- public byte[] getLinksubTypeTlvBodyAsByteArray() {
- byte[] linkSubTypeBody;
- linkSubTypeBody = OspfUtil.convertToFourBytes(Float.floatToIntBits(this.maximumReservableBandwidth));
- return linkSubTypeBody;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("maximumReservableBandwidth", maximumReservableBandwidth)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddress.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddress.java
deleted file mode 100644
index 7aaf9d9..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddress.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of remote interface ip address TE value.
- */
-public class RemoteInterfaceIpAddress extends TlvHeader implements LinkSubType {
- private static final Logger log =
- LoggerFactory.getLogger(RemoteInterfaceIpAddress.class);
- private List<String> remoteInterfaceAddress = new ArrayList<>();
-
- /**
- * Creates an instance of remote interface ip address.
- *
- * @param header tlv header instance
- */
- public RemoteInterfaceIpAddress(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Adds remote interface ip address.
- *
- * @param remoteAddress ip address
- */
- public void addRemoteInterfaceAddress(String remoteAddress) {
- remoteInterfaceAddress.add(remoteAddress);
- }
-
- /**
- * Gets remote interface ip address.
- *
- * @return remoteAddress ip address
- */
- public List<String> getRemoteInterfaceAddress() {
- return remoteInterfaceAddress;
- }
-
- /**
- * Reads bytes from channel buffer .
- *
- * @param channelBuffer channel buffer instance
- * @throws OspfParseException might throws exception while parsing packet
- */
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
- while (channelBuffer.readableBytes() >= OspfUtil.FOUR_BYTES) {
- try {
- byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- this.addRemoteInterfaceAddress(InetAddress.getByAddress(tempByteArray).getHostName());
- } catch (Exception e) {
- log.debug("Error::RemoteInterfaceIPAddress:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR,
- OspfErrorType.BAD_MESSAGE);
- }
- }
- }
-
- /**
- * Gets byte array of remote interface ip address .
- *
- * @return byte array of remote interface ip address
- * @throws OspfParseException might throws exception while parsing packet
- */
- public byte[] asBytes() throws OspfParseException {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
- byte[] linkSubTlvBody = getLinkSubTypeTlvBodyAsByteArray();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
-
- return linkSubType;
- }
-
- /**
- * Gets byte array of remote interface ip address.
- *
- * @return byte array of remote interface ip address
- * @throws OspfParseException might throws exception while parsing packet
- */
- public byte[] getLinkSubTypeTlvBodyAsByteArray() throws OspfParseException {
- List<Byte> linkSubTypeBody = new ArrayList<>();
-
- for (String remoteAddress : this.remoteInterfaceAddress) {
- try {
- linkSubTypeBody.addAll(Bytes.asList(InetAddress.getByName(remoteAddress).getAddress()));
- } catch (Exception e) {
- log.debug("Error::RemoteInterfaceIPAddress:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR,
- OspfErrorType.BAD_MESSAGE);
- }
- }
-
- return Bytes.toArray(linkSubTypeBody);
- }
-
- /**
- * Returns instance as string.
- *
- * @return instance as string
- */
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("RemoteInterfaceIPAddress", remoteInterfaceAddress)
- .toString();
- }
-
-}
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/TrafficEngineeringMetric.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/TrafficEngineeringMetric.java
deleted file mode 100644
index 8693eee..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/TrafficEngineeringMetric.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-
-/**
- * Representation of traffic engineering metric TE value.
- */
-public class TrafficEngineeringMetric extends TlvHeader implements LinkSubType {
- private long trafficEngineeringMetric;
-
- /**
- * Creates an instance of traffic engineering metric .
- *
- * @param header tlv header instance
- */
- public TrafficEngineeringMetric(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Sets TE metric value.
- *
- * @param trafficEngineeringMetric value of trafficEngineeringMetric
- */
- public void setTrafficEngineeringMetric(long trafficEngineeringMetric) {
- this.trafficEngineeringMetric = trafficEngineeringMetric;
- }
-
- /**
- * Gets TE metric value.
- *
- * @return value of traffic engineering metric
- */
- public long getTrafficEngineeringMetricValue() {
- return this.trafficEngineeringMetric;
- }
-
- /**
- * Reads bytes from channel buffer .
- *
- * @param channelBuffer channel buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- byte[] tempByteArray = new byte[tlvLength()];
- channelBuffer.readBytes(tempByteArray, 0, tlvLength());
- this.setTrafficEngineeringMetric(OspfUtil.byteToLong(tempByteArray));
- }
-
- /**
- * Gets instance as byte array.
- *
- * @return instance as byte array
- */
- public byte[] asBytes() {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
- byte[] linkSubTlvBody = getLinkSubTypeTlvBodyAsByteArray();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
-
- return linkSubType;
- }
-
- /**
- * Gets trafficEngineeringMetric as byte array .
- *
- * @return byte array of trafficEngineeringMetric
- */
- public byte[] getLinkSubTypeTlvBodyAsByteArray() {
-
- byte[] linkSubTypeBody;
- linkSubTypeBody = OspfUtil.convertToFourBytes(this.trafficEngineeringMetric);
-
- return linkSubTypeBody;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("trafficEngineeringMetric", trafficEngineeringMetric)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnknownLinkSubType.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnknownLinkSubType.java
deleted file mode 100644
index 12f4a73..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnknownLinkSubType.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-
-/**
- * Representation of an unknown or experimental TE value.
- */
-public class UnknownLinkSubType extends TlvHeader implements LinkSubType {
-
- private byte[] value;
-
- /**
- * Creates an instance of this.
- *
- * @param header tlv header
- */
- public UnknownLinkSubType(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Gets the unknown subtype value .
- *
- * @return unknown subtype value
- */
- public byte[] value() {
- return value;
- }
-
- /**
- * Sets unknown subtype value.
- *
- * @param value unknown subtype value.
- */
- public void setValue(byte[] value) {
- this.value = value;
- }
-
- /**
- * Reads bytes from channel buffer .
- *
- * @param channelBuffer channel buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- byte[] tempByteArray = new byte[tlvLength()];
- channelBuffer.readBytes(tempByteArray, 0, tlvLength());
- this.setValue(tempByteArray);
- }
-
- /**
- * Returns instance as byte array.
- *
- * @return instance as byte array
- */
- public byte[] asBytes() {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
- byte[] linkSubTlvBody = getLinkSubTypeTlvBodyAsByteArray();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
- return linkSubType;
-
- }
-
- /**
- * Gets instance body as byte array.
- *
- * @return instance body as byte array
- */
- public byte[] getLinkSubTypeTlvBodyAsByteArray() {
- return value;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("value", value)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidth.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidth.java
deleted file mode 100644
index 06bfa60..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidth.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of an unreserved band width TE value.
- */
-public class UnreservedBandwidth extends TlvHeader implements LinkSubType {
- private List<Float> unReservedBandwidth = new ArrayList<>();
-
- /**
- * Creates an instance of unreserved band width.
- *
- * @param header tlv header instance
- */
- public UnreservedBandwidth(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Adds value of un reserved bandwidth .
- *
- * @param unreservedBandwidth value of un reserved bandwidth
- */
- public void addUnReservedBandwidth(float unreservedBandwidth) {
- this.unReservedBandwidth.add(unreservedBandwidth);
- }
-
- /**
- * Gets list of un reserved bandwidth .
- *
- * @return List of un reserved bandwidth
- */
- public List<Float> getUnReservedBandwidthValue() {
- return this.unReservedBandwidth;
- }
-
- /**
- * Reads bytes from channel buffer .
- *
- * @param channelBuffer channel buffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- while (channelBuffer.readableBytes() >= OspfUtil.FOUR_BYTES) {
- int maxReversibleBandwidth = channelBuffer.readInt();
- this.addUnReservedBandwidth(Float.intBitsToFloat(maxReversibleBandwidth));
- }
- }
-
- /**
- * Gets instance as byte array.
- *
- * @return instance as byte array
- */
- public byte[] asBytes() {
- byte[] linkSubType = null;
-
- byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
- byte[] linkSubTlvBody = getLinkSubTypeTlvBodyAsByteArray();
- linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
-
- return linkSubType;
- }
-
- /**
- * Gets unreserved bandwidth as byte array.
- *
- * @return unreserved bandwidth as byte array
- */
- public byte[] getLinkSubTypeTlvBodyAsByteArray() {
- List<Byte> linkSubTypeBody = new ArrayList<>();
- if (this.unReservedBandwidth.size() < 8) {
- int size = OspfUtil.EIGHT_BYTES - this.unReservedBandwidth.size();
- for (int i = 0; i < size; i++) {
- linkSubTypeBody.addAll(Bytes.asList(OspfUtil.convertToFourBytes(OspfParameters.INITIAL_BANDWIDTH)));
- }
- }
- for (Float unreservedBandwidth : this.unReservedBandwidth) {
- int unresBandwidth = Float.floatToIntBits(unreservedBandwidth);
- linkSubTypeBody.addAll(Bytes.asList(OspfUtil.convertToFourBytes(unresBandwidth)));
- }
-
- return Bytes.toArray(linkSubTypeBody);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("unReservedBandwidth", unReservedBandwidth)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/package-info.java
deleted file mode 100644
index 980d260..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/linksubtype/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ospf TE link types.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/package-info.java
deleted file mode 100644
index 871fc16..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the OSPF LSA.
- */
-package org.onosproject.ospf.protocol.lsa;
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfExternalDestination.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfExternalDestination.java
deleted file mode 100644
index 0b377ab..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfExternalDestination.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.subtypes;
-
-import com.google.common.base.MoreObjects;
-import org.onlab.packet.Ip4Address;
-
-/**
- * Defines the OSPF external destination.
- */
-public class OspfExternalDestination {
-
- private boolean isType1orType2Metric;
- private int metric;
- private Ip4Address forwardingAddress;
- private int externalRouterTag;
-
- /**
- * Gets whether type1 or type 2 metric.
- *
- * @return true if Type1 or false if Type2 metric
- */
- public boolean isType1orType2Metric() {
- return isType1orType2Metric;
- }
-
- /**
- * Sets whether type1 or Type2 metric.
- *
- * @param isType1orType2Metric is type 1 or type 2 metric
- */
- public void setType1orType2Metric(boolean isType1orType2Metric) {
- this.isType1orType2Metric = isType1orType2Metric;
- }
-
- /**
- * Gets the metric value.
- *
- * @return metric value
- */
- public int metric() {
- return metric;
- }
-
- /**
- * Sets the metric value.
- *
- * @param metric metric value
- */
- public void setMetric(int metric) {
- this.metric = metric;
- }
-
- /**
- * Gets forwarding address.
- *
- * @return forwarding address
- */
- public Ip4Address forwardingAddress() {
- return forwardingAddress;
- }
-
- /**
- * Sets forwarding address.
- *
- * @param forwardingAddress forwarding address
- */
- public void setForwardingAddress(Ip4Address forwardingAddress) {
- this.forwardingAddress = forwardingAddress;
- }
-
- /**
- * Gets external router tag.
- *
- * @return external router tag
- */
- public int externalRouterTag() {
- return externalRouterTag;
- }
-
- /**
- * Sets external router tag.
- *
- * @param externalRouterTag external router tag
- */
- public void setExternalRouterTag(int externalRouterTag) {
- this.externalRouterTag = externalRouterTag;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("isType1orType2Metric", isType1orType2Metric)
- .add("metric", metric)
- .add("forwardingAddress", forwardingAddress)
- .add("externalRouterTag", externalRouterTag)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfLsaLink.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfLsaLink.java
deleted file mode 100644
index d0c40ff..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfLsaLink.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.subtypes;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Representation of an OSPF LSA link.
- */
-public class OspfLsaLink {
-
- private String linkId;
- private String linkData;
- private int linkType;
- private int metric;
- private int tos;
-
- /**
- * Gets link id.
- *
- * @return link id
- */
- public String linkId() {
- return linkId;
- }
-
- /**
- * Sets link id.
- *
- * @param linkId link id
- */
- public void setLinkId(String linkId) {
- this.linkId = linkId;
- }
-
- /**
- * Gets link data.
- *
- * @return link data
- */
- public String linkData() {
- return linkData;
- }
-
- /**
- * Sets link data.
- *
- * @param linkData link data
- */
- public void setLinkData(String linkData) {
- this.linkData = linkData;
- }
-
- /**
- * Gets link type.
- *
- * @return link type
- */
- public int linkType() {
- return linkType;
- }
-
- /**
- * Sets link type.
- *
- * @param linkType link type
- */
- public void setLinkType(int linkType) {
- this.linkType = linkType;
- }
-
- /**
- * Gets metric value.
- *
- * @return metric.
- */
- public int metric() {
- return metric;
- }
-
- /**
- * Sets metric value.
- *
- * @param metric metric
- */
- public void setMetric(int metric) {
- this.metric = metric;
- }
-
- /**
- * Gets tos.
- *
- * @return tos
- */
- public int tos() {
- return tos;
- }
-
- /**
- * Sets tos.
- *
- * @param tos tos
- */
- public void setTos(int tos) {
- this.tos = tos;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("linkID", linkId)
- .add("linkData", linkData)
- .add("linkType", linkType)
- .add("metric", metric)
- .add("tos", tos)
- .toString();
- }
-}
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/package-info.java
deleted file mode 100644
index c74d683..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/subtypes/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the OSPF LSA Sub Types.
- */
-package org.onosproject.ospf.protocol.lsa.subtypes;
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlv.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlv.java
deleted file mode 100644
index 6521ab2..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlv.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.tlvtypes;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.lsa.linksubtype.AdministrativeGroup;
-import org.onosproject.ospf.protocol.lsa.linksubtype.LinkId;
-import org.onosproject.ospf.protocol.lsa.linksubtype.LinkSubType;
-import org.onosproject.ospf.protocol.lsa.linksubtype.LinkSubTypes;
-import org.onosproject.ospf.protocol.lsa.linksubtype.LinkType;
-import org.onosproject.ospf.protocol.lsa.linksubtype.LocalInterfaceIpAddress;
-import org.onosproject.ospf.protocol.lsa.linksubtype.MaximumBandwidth;
-import org.onosproject.ospf.protocol.lsa.linksubtype.MaximumReservableBandwidth;
-import org.onosproject.ospf.protocol.lsa.linksubtype.RemoteInterfaceIpAddress;
-import org.onosproject.ospf.protocol.lsa.linksubtype.TrafficEngineeringMetric;
-import org.onosproject.ospf.protocol.lsa.linksubtype.UnknownLinkSubType;
-import org.onosproject.ospf.protocol.lsa.linksubtype.UnreservedBandwidth;
-import org.onosproject.ospf.protocol.lsa.types.TopLevelTlv;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of an OSPF Opaque link tlv.
- */
-public class LinkTlv extends TlvHeader implements TopLevelTlv {
- private List<LinkSubType> subTlv = new ArrayList<>();
-
- /**
- * Creates an instance of link tlv.
- *
- * @param header tlv header
- */
- public LinkTlv(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Gets sub tlv lists.
- *
- * @return sub tlv lists
- */
- public List<LinkSubType> subTlvList() {
- return this.subTlv;
- }
-
- /**
- * Reads bytes from channel buffer .
- *
- * @param channelBuffer channel buffer instance
- * @throws OspfParseException might throws exception while parsing packet
- */
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
- while (channelBuffer.readableBytes() > 0) {
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(channelBuffer.readUnsignedShort());
- tlvHeader.setTlvLength(channelBuffer.readUnsignedShort());
-
- if (LinkSubTypes.LINK_TYPE.value() == tlvHeader.tlvType()) {
- LinkType linktype = new LinkType(tlvHeader);
- linktype.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
- subTlv.add(linktype);
- if (tlvHeader.tlvLength() < OspfUtil.FOUR_BYTES) {
- int readerIndex = channelBuffer.readerIndex() + (OspfUtil.FOUR_BYTES - tlvHeader.tlvLength());
- channelBuffer.readerIndex(readerIndex);
- }
- } else if (LinkSubTypes.LINK_ID.value() == tlvHeader.tlvType()) {
- LinkId linkId = new LinkId(tlvHeader);
- linkId.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
- subTlv.add(linkId);
- } else if (LinkSubTypes.LOCAL_INTERFACE_IP_ADDRESS.value() == tlvHeader.tlvType()) {
- LocalInterfaceIpAddress localInterfaceIpAddress = new LocalInterfaceIpAddress(tlvHeader);
- localInterfaceIpAddress.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
- subTlv.add(localInterfaceIpAddress);
- } else if (LinkSubTypes.REMOTE_INTERFACE_IP_ADDRESS.value() == tlvHeader.tlvType()) {
- RemoteInterfaceIpAddress remoteInterfaceIpAddress = new RemoteInterfaceIpAddress(tlvHeader);
- remoteInterfaceIpAddress.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
- subTlv.add(remoteInterfaceIpAddress);
- } else if (LinkSubTypes.TRAFFIC_ENGINEERING_METRIC.value() == tlvHeader.tlvType()) {
- TrafficEngineeringMetric trafficEngineeringMetric = new TrafficEngineeringMetric(tlvHeader);
- trafficEngineeringMetric.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
- subTlv.add(trafficEngineeringMetric);
- } else if (LinkSubTypes.MAXIMUM_BANDWIDTH.value() == tlvHeader.tlvType()) {
- MaximumBandwidth maximumBandwidth = new MaximumBandwidth(tlvHeader);
- maximumBandwidth.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
- subTlv.add(maximumBandwidth);
- } else if (LinkSubTypes.MAXIMUM_RESERVABLE_BANDWIDTH.value() == tlvHeader.tlvType()) {
- MaximumReservableBandwidth maximumReservableBandwidth = new MaximumReservableBandwidth(tlvHeader);
- maximumReservableBandwidth.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
- subTlv.add(maximumReservableBandwidth);
- } else if (LinkSubTypes.UNRESERVED_BANDWIDTH.value() == tlvHeader.tlvType()) {
- UnreservedBandwidth unreservedBandwidth = new UnreservedBandwidth(tlvHeader);
- unreservedBandwidth.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
- subTlv.add(unreservedBandwidth);
- } else if (LinkSubTypes.ADMINISTRATIVE_GROUP.value() == tlvHeader.tlvType()) {
- AdministrativeGroup administrativeGroup = new AdministrativeGroup(tlvHeader);
- administrativeGroup.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
- subTlv.add(administrativeGroup);
- } else {
- UnknownLinkSubType unknownLinkSubType = new UnknownLinkSubType(tlvHeader);
- unknownLinkSubType.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
- subTlv.add(unknownLinkSubType);
- }
- }
- }
-
- /**
- * Gets link tlv as byte array.
- *
- * @return link tlv as byte array
- * @throws OspfParseException if the packet can't be parsed
- */
- public byte[] asBytes() throws OspfParseException {
- byte[] lsaMessage = null;
-
- byte[] tlvHeader = getTlvHeaderAsByteArray();
- byte[] tlvBody = getTlvBodyAsByteArray();
- lsaMessage = Bytes.concat(tlvHeader, tlvBody);
-
- return lsaMessage;
- }
-
- /**
- * Gets tlv body as byte array.
- *
- * @return tlv body as byte array
- * @throws OspfParseException might throws exception while parsing buffer
- */
- public byte[] getTlvBodyAsByteArray() throws OspfParseException {
-
- List<Byte> bodyLst = new ArrayList<>();
- for (LinkSubType tlv : subTlv) {
- //Check the type of tlv and build bytes accordingly
- if (tlv instanceof LinkType) {
- LinkType linkType = (LinkType) tlv;
- bodyLst.addAll(Bytes.asList(linkType.asBytes()));
- } else if (tlv instanceof LinkId) {
- LinkId linkId = (LinkId) tlv;
- bodyLst.addAll(Bytes.asList(linkId.asBytes()));
- } else if (tlv instanceof LocalInterfaceIpAddress) {
- LocalInterfaceIpAddress localInterfaceIpAddress = (LocalInterfaceIpAddress) tlv;
- bodyLst.addAll(Bytes.asList(localInterfaceIpAddress.asBytes()));
- } else if (tlv instanceof RemoteInterfaceIpAddress) {
- RemoteInterfaceIpAddress remoteInterfaceIpAddress = (RemoteInterfaceIpAddress) tlv;
- bodyLst.addAll(Bytes.asList(remoteInterfaceIpAddress.asBytes()));
- } else if (tlv instanceof TrafficEngineeringMetric) {
- TrafficEngineeringMetric trafficEngineeringMetric = (TrafficEngineeringMetric) tlv;
- bodyLst.addAll(Bytes.asList(trafficEngineeringMetric.asBytes()));
- } else if (tlv instanceof MaximumBandwidth) {
- MaximumBandwidth maximumBandwidth = (MaximumBandwidth) tlv;
- bodyLst.addAll(Bytes.asList(maximumBandwidth.asBytes()));
- } else if (tlv instanceof MaximumReservableBandwidth) {
- MaximumReservableBandwidth maximumReservableBandwidth = (MaximumReservableBandwidth) tlv;
- bodyLst.addAll(Bytes.asList(maximumReservableBandwidth.asBytes()));
- } else if (tlv instanceof UnreservedBandwidth) {
- UnreservedBandwidth unreservedBandwidth = (UnreservedBandwidth) tlv;
- bodyLst.addAll(Bytes.asList(unreservedBandwidth.asBytes()));
- } else if (tlv instanceof AdministrativeGroup) {
- AdministrativeGroup administrativeGroup = (AdministrativeGroup) tlv;
- bodyLst.addAll(Bytes.asList(administrativeGroup.asBytes()));
- } else {
- UnknownLinkSubType unknownLinkSubType = (UnknownLinkSubType) tlv;
- bodyLst.addAll(Bytes.asList(unknownLinkSubType.asBytes()));
- }
- }
- return Bytes.toArray(bodyLst);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("subTlv", subTlv)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/OpaqueTopLevelTlvTypes.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/OpaqueTopLevelTlvTypes.java
deleted file mode 100644
index cc52a7d..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/OpaqueTopLevelTlvTypes.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.tlvtypes;
-
-/**
- * Representation of an OSPF Opaque top level tlv types.
- */
-public enum OpaqueTopLevelTlvTypes {
-
- ROUTER(1),
- LINK(2);
-
- private int value;
-
- /**
- * Creates an instance of Opaque top level tlv types.
- *
- * @param value opaque TLV value
- */
- OpaqueTopLevelTlvTypes(int value) {
- this.value = value;
- }
-
- /**
- * Gets the tlv type value.
- *
- * @return tlv type value
- */
- public int value() {
- return value;
- }
-
-}
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlv.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlv.java
deleted file mode 100644
index 8ac443b..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlv.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.tlvtypes;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.lsa.types.TopLevelTlv;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of an OSPF Opaque router tlv.
- */
-public class RouterTlv extends TlvHeader implements TopLevelTlv {
-
- private static final Logger log =
- LoggerFactory.getLogger(RouterTlv.class);
- private Ip4Address routerAddress;
-
- /**
- * Creates an instance of Opaque router tlv.
- *
- * @param header tlv header
- */
- public RouterTlv(TlvHeader header) {
- this.setTlvType(header.tlvType());
- this.setTlvLength(header.tlvLength());
- }
-
- /**
- * Gets router address.
- *
- * @return router address
- */
- public Ip4Address routerAddress() {
- return routerAddress;
- }
-
- /**
- * Sets router address.
- *
- * @param routerAddress router address.
- */
- public void setRouterAddress(Ip4Address routerAddress) {
- this.routerAddress = routerAddress;
- }
-
- /**
- * Reads bytes from channel buffer .
- *
- * @param channelBuffer channel buffer instance
- * @throws OspfParseException might throws exception while parsing buffer
- */
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
- try {
- byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- this.setRouterAddress(Ip4Address.valueOf(tempByteArray));
- } catch (Exception e) {
- log.debug("Error::RouterTLV:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR,
- OspfErrorType.BAD_MESSAGE);
- }
- }
-
- /**
- * Gets router tlv as byte array.
- *
- * @return router tlv as byte array
- */
- public byte[] asBytes() {
- byte[] lsaMessage = null;
-
- byte[] tlvHeader = getTlvHeaderAsByteArray();
- byte[] tlvBody = getTlvBodyAsByteArray();
- lsaMessage = Bytes.concat(tlvHeader, tlvBody);
-
- return lsaMessage;
- }
-
- /**
- * Gets tlv body as byte array.
- *
- * @return tlv body as byte array
- */
- public byte[] getTlvBodyAsByteArray() {
- List<Byte> bodyLst = new ArrayList<>();
- bodyLst.addAll(Bytes.asList(this.routerAddress().toOctets()));
-
- return Bytes.toArray(bodyLst);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("routerAddress", routerAddress)
- .toString();
- }
-}
-
-
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/package-info.java
deleted file mode 100644
index 0820d7a..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/tlvtypes/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the OSPF Opaque Tlv Types.
- */
-package org.onosproject.ospf.protocol.lsa.tlvtypes;
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/AsbrSummaryLsa.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/AsbrSummaryLsa.java
deleted file mode 100644
index 435c423..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/AsbrSummaryLsa.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of an ASBR Summary LSA and methods to access them.
- */
-public class AsbrSummaryLsa extends LsaHeader {
-
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS age | Options | 3 or 4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Link State ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Advertising Router |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS sequence number |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS checksum | length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Network Mask |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | 0 | metric |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | TOS | TOS metric |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ... |
-
- Summary LSA format
- REFERENCE : RFC 2328
- */
- private Ip4Address networkMask;
- private int metric;
-
- /**
- * Creates an instance of ASBR Summary LSA.
- *
- * @param lsaHeader lsa header instance.
- */
- public AsbrSummaryLsa(LsaHeader lsaHeader) {
- populateHeader(lsaHeader);
- }
-
- /**
- * Gets network mask.
- *
- * @return networkMask network mask
- */
- public Ip4Address networkMask() {
- return networkMask;
- }
-
- /**
- * Sets network mask.
- *
- * @param networkMask network mask
- */
- public void setNetworkMask(Ip4Address networkMask) {
- this.networkMask = networkMask;
- }
-
- /**
- * Gets metric value.
- *
- * @return metric value
- */
- public int metric() {
- return metric;
- }
-
- /**
- * Sets metric value.
- *
- * @param metric metric value
- */
- public void setMetric(int metric) {
- this.metric = metric;
- }
-
- /**
- * Reads from channel buffer and populate instance.
- *
- * @param channelBuffer channelBuffer instance.
- * @throws OspfParseException might throws exception while parsing buffer
- */
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
- try {
- byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- this.setNetworkMask(Ip4Address.valueOf(tempByteArray));
- int unusedByte = channelBuffer.readByte();
- this.setMetric(channelBuffer.readUnsignedMedium());
- } catch (Exception e) {
- log.debug("Error::AsbrSummaryLsa:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE);
- }
- }
-
- /**
- * Gets LSA bytes as array.
- *
- * @return LSA message as bytes
- * @throws OspfParseException might throws exception while parsing packet
- */
- public byte[] asBytes() throws OspfParseException {
- byte[] lsaMessage = null;
-
- byte[] lsaHeader = getLsaHeaderAsByteArray();
- byte[] lsaBody = getLsaBodyAsByteArray();
- lsaMessage = Bytes.concat(lsaHeader, lsaBody);
-
- return lsaMessage;
- }
-
- /**
- * Get LSA body as byte array.
- *
- * @return byte array contains lsa body
- * @throws OspfParseException might throws exception while parsing packet
- */
- public byte[] getLsaBodyAsByteArray() throws OspfParseException {
- List<Byte> bodyLst = new ArrayList<>();
-
- try {
- bodyLst.addAll(Bytes.asList(this.networkMask().toOctets()));
- bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.metric())));
- } catch (Exception e) {
- log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE);
- }
-
- return Bytes.toArray(bodyLst);
- }
-
- @Override
- public OspfLsaType getOspfLsaType() {
- return OspfLsaType.ASBR_SUMMARY;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- AsbrSummaryLsa that = (AsbrSummaryLsa) o;
- return Objects.equal(networkMask, that.networkMask) &&
- Objects.equal(metric, that.metric);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(networkMask, metric);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("networkMask", networkMask)
- .add("metric", metric)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/ExternalLsa.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/ExternalLsa.java
deleted file mode 100644
index 765b2bb..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/ExternalLsa.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.subtypes.OspfExternalDestination;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of an External LSA and the fields and methods to access them.
- */
-public class ExternalLsa extends LsaHeader {
-
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS age | Options | 5 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Link State ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Advertising Router |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS sequence number |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS checksum | length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Network Mask |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |E| 0 | metric |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Forwarding address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | External Route Tag |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |E| TOS | TOS metric |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Forwarding address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | External Route Tag |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ... |
-
- External LSA format
- REFERENCE : RFC 2328
- */
- private static final Logger log =
- LoggerFactory.getLogger(ExternalLsa.class);
- private Ip4Address networkMask;
- private List<OspfExternalDestination> externalDestinations = new ArrayList<>();
-
- /**
- * Creates an instance of External LSA.
- *
- * @param lsaHeader lsa header instance.
- */
- public ExternalLsa(LsaHeader lsaHeader) {
- populateHeader(lsaHeader);
- }
-
-
- /**
- * Gets the network mask.
- *
- * @return networkMask
- */
- public Ip4Address networkMask() {
- return networkMask;
- }
-
- /**
- * Sets network mask.
- *
- * @param networkMask network mask
- */
- public void setNetworkMask(Ip4Address networkMask) {
- this.networkMask = networkMask;
- }
-
- /**
- * Adds the external destination details to the list.
- *
- * @param externalDestination external destination details
- */
- public void addExternalDestination(OspfExternalDestination externalDestination) {
- if (!externalDestinations.contains(externalDestination)) {
- externalDestinations.add(externalDestination);
- }
- }
-
- /**
- * Reads from channel buffer and populate instance.
- *
- * @param channelBuffer channelBuffer instance
- * @throws OspfParseException might throws exception while parsing buffer
- */
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
-
- try {
- byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- this.setNetworkMask(Ip4Address.valueOf(tempByteArray));
-
- while (channelBuffer.readableBytes() >= OspfUtil.EXTERNAL_DESTINATION_LENGTH) {
- OspfExternalDestination externalDestination = new OspfExternalDestination();
-
- //E Bit - use to find type1 or type2
- int eIsSet = channelBuffer.readByte();
- if (eIsSet != 0) {
- externalDestination.setType1orType2Metric(true);
- } else {
- externalDestination.setType1orType2Metric(false);
- }
- externalDestination.setMetric(channelBuffer.readUnsignedMedium());
- tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- externalDestination.setForwardingAddress(Ip4Address.valueOf(tempByteArray));
- externalDestination.setExternalRouterTag(channelBuffer.readInt());
-
- this.addExternalDestination(externalDestination);
- }
- } catch (Exception e) {
- log.debug("Error::ExternalLSA:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE);
- }
- }
-
- /**
- * Gets LSA as bytes.
- *
- * @return LSA as bytes.
- * @throws OspfParseException might throws exception while parsing packet
- */
- public byte[] asBytes() throws OspfParseException {
- byte[] lsaMessage = null;
-
- byte[] lsaHeader = getLsaHeaderAsByteArray();
- byte[] lsaBody = getLsaBodyAsByteArray();
- lsaMessage = Bytes.concat(lsaHeader, lsaBody);
-
- return lsaMessage;
- }
-
- /**
- * Gets LSA body as byte array.
- *
- * @return byte array contains LSA body
- * @throws OspfParseException might throws exception while parsing buffer
- */
- public byte[] getLsaBodyAsByteArray() throws OspfParseException {
- List<Byte> bodyLst = new ArrayList<>();
-
- try {
- bodyLst.addAll(Bytes.asList(this.networkMask().toOctets()));
-
- //add each OSPFExternalDestination details
- for (OspfExternalDestination externalDest : externalDestinations) {
- if (externalDest.isType1orType2Metric()) {
- //add 1 followed by 7 zeros equals to decimal 128
- bodyLst.add((byte) 128);
- } else {
- bodyLst.add((byte) 0);
- }
-
- bodyLst.addAll(Bytes.asList(OspfUtil.convertToThreeBytes(externalDest.metric())));
- bodyLst.addAll(Bytes.asList(externalDest.forwardingAddress().toOctets()));
- bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(externalDest.externalRouterTag())));
- }
- } catch (Exception e) {
- log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage());
- return Bytes.toArray(bodyLst);
- }
-
- return Bytes.toArray(bodyLst);
- }
-
- @Override
- public OspfLsaType getOspfLsaType() {
- return OspfLsaType.EXTERNAL_LSA;
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
- if (other == null || getClass() != other.getClass()) {
- return false;
- }
- ExternalLsa that = (ExternalLsa) other;
- return Objects.equal(networkMask, that.networkMask) &&
- Objects.equal(externalDestinations, that.externalDestinations);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(networkMask, externalDestinations);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("networkMask", networkMask)
- .add("externalDestinations", externalDestinations)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsa.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsa.java
deleted file mode 100644
index 577da33..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsa.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of a Network LSA and fields and methods to access them.
- */
-public class NetworkLsa extends LsaHeader {
-
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS age | Options | 2 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Link State ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Advertising Router |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS sequence number |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS checksum | length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Network Mask |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Attached Router |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ... |
- */
- private static final Logger log =
- LoggerFactory.getLogger(NetworkLsa.class);
- private Ip4Address networkMask;
- private List<Ip4Address> attachedRouters = new ArrayList<>();
-
- /**
- * Creates an instance of Network LSA.
- */
- public NetworkLsa() {
- }
-
- /**
- * Creates an instance of Network LSA.
- *
- * @param lsaHeader lsa header instance.
- */
- public NetworkLsa(LsaHeader lsaHeader) {
- populateHeader(lsaHeader);
- }
-
- /**
- * Gets network mask.
- *
- * @return network mask
- */
- public Ip4Address networkMask() {
- return networkMask;
- }
-
- /**
- * Sets network mask.
- *
- * @param networkMask network mask
- */
- public void setNetworkMask(Ip4Address networkMask) {
- this.networkMask = networkMask;
- }
-
- /**
- * Adds attached router to list.
- *
- * @param attachedRouter attached router ip address.
- */
- public void addAttachedRouter(Ip4Address attachedRouter) {
- attachedRouters.add(attachedRouter);
- }
-
- /**
- * Gets the list of attached routers.
- *
- * @return list of attached routers
- */
- public List<Ip4Address> attachedRouters() {
-
- return attachedRouters;
- }
-
- /**
- * Reads from channel buffer and populate instance.
- *
- * @param channelBuffer channel buffer instance
- * @throws OspfParseException might throws exception while parsing buffer
- */
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
-
- try {
- byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- this.setNetworkMask(Ip4Address.valueOf(tempByteArray));
- //add all the attached routers
- while (channelBuffer.readableBytes() > 0) {
- tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- this.addAttachedRouter(Ip4Address.valueOf(tempByteArray));
- }
- } catch (Exception e) {
- log.debug("Error::NetworkLSA::readFrom:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE);
- }
- }
-
- /**
- * Gets LSA as bytes.
- *
- * @return LSA as byte array
- * @throws OspfParseException might throws exception while parsing packet
- */
- public byte[] asBytes() throws OspfParseException {
- byte[] lsaMessage = null;
-
- byte[] lsaHeader = getLsaHeaderAsByteArray();
- byte[] lsaBody = getLsaBodyAsByteArray();
- lsaMessage = Bytes.concat(lsaHeader, lsaBody);
-
- return lsaMessage;
- }
-
- /**
- * Gets LSA body as byte array.
- *
- * @return LSA body as byte array
- * @throws OspfParseException might throws exception while parsing packet
- */
- public byte[] getLsaBodyAsByteArray() throws OspfParseException {
- List<Byte> bodyLst = new ArrayList<>();
-
- try {
- bodyLst.addAll(Bytes.asList(this.networkMask().toOctets()));
- //add each attachedRouters details
- for (Ip4Address attachedRouter : attachedRouters) {
- //attached router
- bodyLst.addAll(Bytes.asList(attachedRouter.toOctets()));
- }
- } catch (Exception e) {
- log.debug("Error::NetworkLSA::getLsrBodyAsByteArray {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE);
- }
-
- return Bytes.toArray(bodyLst);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- NetworkLsa that = (NetworkLsa) o;
- return Objects.equal(networkMask, that.networkMask) &&
- Objects.equal(attachedRouters, that.attachedRouters);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(networkMask, attachedRouters);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("networkMask", networkMask)
- .add("attachedRouters", attachedRouters)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa10.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa10.java
deleted file mode 100644
index b0fd4b6..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa10.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.lsa.tlvtypes.LinkTlv;
-import org.onosproject.ospf.protocol.lsa.tlvtypes.OpaqueTopLevelTlvTypes;
-import org.onosproject.ospf.protocol.lsa.tlvtypes.RouterTlv;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Representation of an Opaque LSA of type area local (10).
- */
-public class OpaqueLsa10 extends OpaqueLsaHeader {
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS age | Options | 9, 10 or 11 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Opaque Type | Opaque ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Advertising Router |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS Sequence Number |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS checksum | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- + +
- | Opaque Information |
- + +
- | ... |
-
- Opaque LSA format
- REFERENCE : RFC 5250
- */
- private List<TopLevelTlv> topLevelValues = new ArrayList<>();
- private byte[] opaqueInfo = null;
-
- /**
- * Creates an instance of Opaque type 10 LSA.
- *
- * @param lsaHeader LSA header instance
- */
- public OpaqueLsa10(OpaqueLsaHeader lsaHeader) {
- populateHeader(lsaHeader);
- }
-
- /**
- * Returns the list of top level TLVs.
- *
- * @return list of top level TLVs
- */
- public List<TopLevelTlv> topLevelValues() {
- return topLevelValues;
- }
-
- /**
- * Adds TLV value.
- *
- * @param value TLV value
- */
- public void addValue(TopLevelTlv value) {
- topLevelValues.add(value);
- }
-
- /**
- * Reads from channel buffer and populate instance.
- *
- * @param channelBuffer channelBuffer instance
- * @throws OspfParseException might throws exception while parsing buffer
- */
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
-
- try {
- if (this.opaqueId() == OspfParameters.TRAFFIC_ENGINEERING) {
- while (channelBuffer.readableBytes() > 0) {
- TlvHeader tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(channelBuffer.readUnsignedShort());
- tlvHeader.setTlvLength(channelBuffer.readUnsignedShort());
- if (tlvHeader.tlvType() == OpaqueTopLevelTlvTypes.ROUTER.value()) {
- RouterTlv routerTlv = new RouterTlv(tlvHeader);
- routerTlv.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
- this.addValue(routerTlv);
- } else if (tlvHeader.tlvType() == OpaqueTopLevelTlvTypes.LINK.value()) {
- LinkTlv linkTlv = new LinkTlv(tlvHeader);
- linkTlv.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
- this.addValue(linkTlv);
- }
- }
- } else {
- int length = channelBuffer.readableBytes();
- opaqueInfo = new byte[length];
- channelBuffer.readBytes(opaqueInfo, 0, length);
- }
-
- } catch (Exception e) {
- log.debug("Error::OpaqueLsa10:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR,
- OspfErrorType.BAD_MESSAGE);
- }
- }
-
- /**
- * Returns instance as bytes.
- *
- * @return instance as bytes
- * @throws OspfParseException might throws exception while parsing packet
- */
- public byte[] asBytes() throws OspfParseException {
-
- byte[] lsaMessage = null;
- byte[] lsaHeader = getOpaqueLsaHeaderAsByteArray();
- byte[] lsaBody = getLsaBodyAsByteArray();
- lsaMessage = Bytes.concat(lsaHeader, lsaBody);
- return lsaMessage;
-
- }
-
- /**
- * Gets the LSA body as byte array.
- *
- * @return the lsa body as byte array
- * @throws OspfParseException might throws exception while parsing packet
- */
- public byte[] getLsaBodyAsByteArray() throws OspfParseException {
- List<Byte> bodyLst = new ArrayList<>();
- if (this.opaqueId() == 1) {
- for (TopLevelTlv tlv : this.topLevelValues) {
- //Check the sub type of lsa and build bytes accordingly
- if (tlv instanceof RouterTlv) {
- RouterTlv routerTlv = (RouterTlv) tlv;
- bodyLst.addAll(Bytes.asList(routerTlv.asBytes()));
- } else if (tlv instanceof LinkTlv) {
- LinkTlv linkTlv = (LinkTlv) tlv;
- bodyLst.addAll(Bytes.asList(linkTlv.asBytes()));
- }
- }
- } else {
- return opaqueInfo;
- }
-
- return Bytes.toArray(bodyLst);
- }
-
- @Override
- public OspfLsaType getOspfLsaType() {
- return OspfLsaType.AREA_LOCAL_OPAQUE_LSA;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("topLevelValues", topLevelValues)
- .add("opaqueInfo", opaqueInfo)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- OpaqueLsa10 that = (OpaqueLsa10) o;
- return Objects.equal(topLevelValues, that.topLevelValues) &&
- Arrays.equals(opaqueInfo, that.opaqueInfo);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(Arrays.hashCode(opaqueInfo), topLevelValues);
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa11.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa11.java
deleted file mode 100644
index 69f8bfd..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa11.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-
-/**
- * Representation of an Opaque LSA of type AS (11).
- */
-public class OpaqueLsa11 extends OpaqueLsaHeader {
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS age | Options | 9, 10 or 11 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Opaque Type | Opaque ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Advertising Router |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS Sequence Number |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS checksum | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- + +
- | Opaque Information |
- + +
- | ... |
- */
- private byte[] opaqueInfo = null;
-
- /**
- * Creates an instance of Opaque type 11 LSA.
- *
- * @param lsaHeader LSA header instance
- */
- public OpaqueLsa11(OpaqueLsaHeader lsaHeader) {
- populateHeader(lsaHeader);
- }
-
- /**
- * Reads from channel buffer and populate this.
- *
- * @param channelBuffer channelBuffer instance.
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- int length = channelBuffer.readableBytes();
- opaqueInfo = new byte[length];
- channelBuffer.readBytes(opaqueInfo, 0, length);
- }
-
- /**
- * Returns instance as bytes.
- *
- * @return instance as bytes
- */
- public byte[] asBytes() {
- byte[] lsaMessage = null;
-
- byte[] lsaHeader = getOpaqueLsaHeaderAsByteArray();
- byte[] lsaBody = getLsaBodyAsByteArray();
- lsaMessage = Bytes.concat(lsaHeader, lsaBody);
-
- return lsaMessage;
- }
-
- /**
- * Get the LSA body as byte array.
- *
- * @return LSA body as byte array
- */
- public byte[] getLsaBodyAsByteArray() {
- return opaqueInfo;
- }
-
- @Override
- public OspfLsaType getOspfLsaType() {
- return OspfLsaType.AS_OPAQUE_LSA;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- OpaqueLsa11 that = (OpaqueLsa11) o;
- return Arrays.equals(opaqueInfo, that.opaqueInfo);
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(opaqueInfo);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("opaqueInfo", opaqueInfo)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa9.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa9.java
deleted file mode 100644
index e311fce..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa9.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-
-/**
- * Representation of an Opaque LSA of type link local (9).
- */
-public class OpaqueLsa9 extends OpaqueLsaHeader {
-
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS age | Options | 9, 10 or 11 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Opaque Type | Opaque ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Advertising Router |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS Sequence Number |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS checksum | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- + +
- | Opaque Information |
- + +
- | ... |
- */
- private byte[] opaqueInfo = null;
-
- /**
- * Creates an instance of Opaque type 9 LSA.
- *
- * @param lsaHeader LSA header instance
- */
- public OpaqueLsa9(OpaqueLsaHeader lsaHeader) {
- populateHeader(lsaHeader);
- }
-
- /**
- * Reads from channel buffer and populate instance.
- *
- * @param channelBuffer channelBuffer instance
- */
- public void readFrom(ChannelBuffer channelBuffer) {
- int length = channelBuffer.readableBytes();
- opaqueInfo = new byte[length];
- channelBuffer.readBytes(opaqueInfo, 0, length);
- }
-
- /**
- * Returns instance as bytes.
- *
- * @return instance as bytes
- */
- public byte[] asBytes() {
- byte[] lsaMessage = null;
-
- byte[] lsaHeader = getOpaqueLsaHeaderAsByteArray();
- byte[] lsaBody = getLsaBodyAsByteArray();
- lsaMessage = Bytes.concat(lsaHeader, lsaBody);
-
- return lsaMessage;
- }
-
- /**
- * Gets the LSA body.
- *
- * @return the LSA body
- */
- public byte[] getLsaBodyAsByteArray() {
- return opaqueInfo;
-
- }
-
- @Override
- public OspfLsaType getOspfLsaType() {
- return OspfLsaType.LINK_LOCAL_OPAQUE_LSA;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- OpaqueLsa9 that = (OpaqueLsa9) o;
- return Arrays.equals(opaqueInfo, that.opaqueInfo);
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(opaqueInfo);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("opaqueInfo", opaqueInfo)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/RouterLsa.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/RouterLsa.java
deleted file mode 100644
index e8cc39f..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/RouterLsa.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.subtypes.OspfLsaLink;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of a Router LSA, and the fields and methods to access them.
- */
-public class RouterLsa extends LsaHeader {
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS age | Options | 1 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Link State ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Advertising Router |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS sequence number |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS checksum | length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | 0 |V|E|B| 0 | # links |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Link ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Link Data |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type | # TOS | metric |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ... |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | TOS | 0 | TOS metric |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Link ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Link Data |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ... |
- */
- private static final Logger log =
- LoggerFactory.getLogger(RouterLsa.class);
- private boolean isVirtualEndPoint;
- private boolean isAsBoundaryRouter;
- private boolean isAreaBorderRouter;
- private int noLink;
- private List<OspfLsaLink> routerLinks = new ArrayList<>();
-
- /**
- * Creates an instance of Router LSA.
- */
- public RouterLsa() {
- }
-
- /**
- * Creates an instance of Router LSA.
- *
- * @param lsaHeader lsa header instance
- */
- public RouterLsa(LsaHeader lsaHeader) {
- populateHeader(lsaHeader);
- }
-
- /**
- * Sets virtual endpoint or not.
- *
- * @param isVirtualEndPoint true or false
- */
- public void setVirtualEndPoint(boolean isVirtualEndPoint) {
- this.isVirtualEndPoint = isVirtualEndPoint;
- }
-
- /**
- * Sets if it is an AS boundary router or not.
- *
- * @param isAsBoundaryRouter true if AS boundary router else false
- */
- public void setAsBoundaryRouter(boolean isAsBoundaryRouter) {
- this.isAsBoundaryRouter = isAsBoundaryRouter;
- }
-
- /**
- * Sets whether it is an ABR or not.
- *
- * @param isAreaBorderRouter true if ABR else false
- */
- public void setAreaBorderRouter(boolean isAreaBorderRouter) {
- this.isAreaBorderRouter = isAreaBorderRouter;
- }
-
- /**
- * Gets number of links.
- *
- * @return number of links
- */
- public int noLink() {
- return noLink;
- }
-
- /**
- * Sets number of links.
- *
- * @param noLink number of links
- */
- public void setNoLink(int noLink) {
- this.noLink = noLink;
- }
-
-
- /**
- * Adds router link.
- *
- * @param lsaLink LSA link
- */
- public void addRouterLink(OspfLsaLink lsaLink) {
- if (!this.routerLinks.contains(lsaLink)) {
- this.routerLinks.add(lsaLink);
- }
- }
-
- /**
- * Gets router link.
- *
- * @return routerLinks LSA link list
- */
- public List<OspfLsaLink> routerLink() {
- return this.routerLinks;
- }
-
- /**
- * Reads from channel buffer and populate this.
- *
- * @param channelBuffer channelBuffer instance.
- * @throws OspfParseException might throws exception while parsing buffer
- */
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
-
- try {
- int veb = channelBuffer.readByte();
- int unUsed = channelBuffer.readByte();
- //Convert the byte to veb bits
- String strVeb = Integer.toBinaryString(veb);
- if (strVeb.length() == 3) {
- this.setVirtualEndPoint((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false);
- this.setAsBoundaryRouter((Integer.parseInt(Character.toString(strVeb.charAt(1))) == 1) ? true : false);
- this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(2))) == 1) ? true : false);
- } else if (strVeb.length() == 2) {
- this.setVirtualEndPoint(false);
- this.setAsBoundaryRouter((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false);
- this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(1))) == 1) ? true : false);
- } else if (strVeb.length() == 1) {
- this.setVirtualEndPoint(false);
- this.setAsBoundaryRouter(false);
- this.setAreaBorderRouter((Integer.parseInt(Character.toString(strVeb.charAt(0))) == 1) ? true : false);
- }
- this.setNoLink(channelBuffer.readUnsignedShort());
- while (channelBuffer.readableBytes() >= OspfUtil.TWELVE_BYTES) {
- OspfLsaLink ospfLsaLink = new OspfLsaLink();
-
- byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- ospfLsaLink.setLinkId(InetAddress.getByAddress(tempByteArray).getHostName());
- tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- ospfLsaLink.setLinkData(InetAddress.getByAddress(tempByteArray).getHostName());
- ospfLsaLink.setLinkType(channelBuffer.readByte());
- ospfLsaLink.setTos(channelBuffer.readByte());
- ospfLsaLink.setMetric(channelBuffer.readUnsignedShort());
- //add the link
- this.addRouterLink(ospfLsaLink);
- }
- } catch (Exception e) {
- log.debug("Error::RouterLsa:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE);
- }
- }
-
- /**
- * Returns instance as bytes.
- *
- * @return instance as bytes
- * @throws OspfParseException might throws exception while parsing packet
- */
- public byte[] asBytes() throws OspfParseException {
- byte[] lsaMessage = null;
-
- byte[] lsaHeader = getLsaHeaderAsByteArray();
- byte[] lsaBody = getLsaBodyAsByteArray();
- lsaMessage = Bytes.concat(lsaHeader, lsaBody);
-
- return lsaMessage;
- }
-
- /**
- * Gets the LSA body as bytes.
- *
- * @return LSA body as bytes
- */
- public byte[] getLsaBodyAsByteArray() {
- List<Byte> bodyLst = new ArrayList<>();
-
- try {
- int isVirtualEndPointVal = this.isVirtualEndPoint ? 1 : 0;
- int isASBoundaryRouterVal = this.isAsBoundaryRouter ? 1 : 0;
- int isAreaBorderRouterVal = this.isAreaBorderRouter ? 1 : 0;
-
- StringBuilder sb = new StringBuilder();
- sb.append(Integer.toBinaryString(isVirtualEndPointVal));
- sb.append(Integer.toBinaryString(isASBoundaryRouterVal));
- sb.append(Integer.toBinaryString(isAreaBorderRouterVal));
-
- //added VEB
- bodyLst.add((byte) Integer.parseInt(sb.toString(), 2));
- //second byte is 0.
- bodyLst.add((byte) 0);
- //Number of links
- bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.noLink())));
-
- //add each link details
- for (OspfLsaLink lsaLink : routerLinks) {
- bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsaLink.linkId()).getAddress()));
- bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsaLink.linkData()).getAddress()));
- bodyLst.add((byte) lsaLink.linkType());
- bodyLst.add((byte) lsaLink.tos());
- bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(lsaLink.metric())));
- }
- } catch (Exception e) {
- log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage());
- return Bytes.toArray(bodyLst);
- }
-
- return Bytes.toArray(bodyLst);
- }
-
- /**
- * Increment the link by 1.
- */
- public void incrementLinkNo() {
- this.noLink++;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("isVirtualEndPoint", isVirtualEndPoint)
- .add("isAsBoundaryRouter", isAsBoundaryRouter)
- .add("isAreaBorderRouter", isAreaBorderRouter)
- .add("noLink", noLink)
- .add("routerLinks", routerLinks)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- RouterLsa that = (RouterLsa) o;
- return Objects.equal(isVirtualEndPoint, that.isVirtualEndPoint) &&
- Objects.equal(isAsBoundaryRouter, that.isAsBoundaryRouter) &&
- Objects.equal(isAreaBorderRouter, that.isAreaBorderRouter) &&
- Objects.equal(noLink, that.noLink) &&
- Objects.equal(routerLinks, that.routerLinks);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(isVirtualEndPoint, isAsBoundaryRouter, isAreaBorderRouter,
- noLink, routerLinks);
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/SummaryLsa.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/SummaryLsa.java
deleted file mode 100644
index ec0ffe7..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/SummaryLsa.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Objects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of a Summary LSA, fields and methods to access them.
- */
-public class SummaryLsa extends LsaHeader {
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS age | Options | 3 or 4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Link State ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Advertising Router |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS sequence number |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS checksum | length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Network Mask |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | 0 | metric |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | TOS | TOS metric |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ... |
-
- */
- private static final Logger log = LoggerFactory.getLogger(SummaryLsa.class);
- private Ip4Address networkMask;
- private int metric;
-
- /**
- * Creates an instance of Summary LSA.
- *
- * @param lsaHeader LSA header instance
- */
- public SummaryLsa(LsaHeader lsaHeader) {
- populateHeader(lsaHeader);
- }
-
- /**
- * Gets network mask.
- *
- * @return network mask
- */
- public Ip4Address networkMask() {
- return networkMask;
- }
-
- /**
- * Sets network mask.
- *
- * @param networkMask network mask
- */
- public void setNetworkMask(Ip4Address networkMask) {
- this.networkMask = networkMask;
- }
-
- /**
- * Gets metric value.
- *
- * @return metric
- */
- public int metric() {
- return metric;
- }
-
- /**
- * Sets metric value.
- *
- * @param metric metric value
- */
- public void setMetric(int metric) {
- this.metric = metric;
- }
-
- /**
- * Reads from channel buffer and populate instance.
- *
- * @param channelBuffer channelBuffer instance
- * @throws OspfParseException might throws exception while parsing buffer
- */
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
-
- try {
- byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- this.setNetworkMask(Ip4Address.valueOf(tempByteArray));
- int unsedByte = channelBuffer.readByte();
- this.setMetric(channelBuffer.readUnsignedMedium());
- } catch (Exception e) {
- log.debug("Error::SummaryLsa:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE);
- }
- }
-
- /**
- * Returns instance as bytes.
- *
- * @return instance as bytes
- */
- public byte[] asBytes() {
- byte[] lsaMessage = null;
- byte[] lsaHeader = getLsaHeaderAsByteArray();
- byte[] lsaBody = getLsaBodyAsByteArray();
- lsaMessage = Bytes.concat(lsaHeader, lsaBody);
-
- return lsaMessage;
- }
-
- /**
- * Get the LSA body.
- *
- * @return LSA body
- */
- public byte[] getLsaBodyAsByteArray() {
- List<Byte> bodyLst = new ArrayList<>();
-
- try {
- bodyLst.addAll(Bytes.asList(this.networkMask().toOctets()));
- bodyLst.add((byte) 0);
- bodyLst.addAll(Bytes.asList(OspfUtil.convertToThreeBytes(this.metric())));
- } catch (Exception e) {
- log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage());
- return Bytes.toArray(bodyLst);
- }
-
- return Bytes.toArray(bodyLst);
- }
-
- @Override
- public OspfLsaType getOspfLsaType() {
- return OspfLsaType.SUMMARY;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("networkMask", networkMask)
- .add("metric", metric)
- .toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- SummaryLsa that = (SummaryLsa) o;
- return Objects.equal(networkMask, that.networkMask) &&
- Objects.equal(metric, that.metric);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(networkMask, metric);
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/TopLevelTlv.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/TopLevelTlv.java
deleted file mode 100644
index d9e83116..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/TopLevelTlv.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-/**
- * Marker interface represents a top level TLV in an Opaque LSA.
- */
-public interface TopLevelTlv {
-}
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/package-info.java
deleted file mode 100644
index 3ec9e2a..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the OSPF LSA types.
- */
-package org.onosproject.ospf.protocol.lsa.types;
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReader.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReader.java
deleted file mode 100644
index e51672f..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReader.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.ospf.protocol.ospfpacket;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfMessage;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A message reader which reads OSPF messages from ChannelBuffer and converts to OspfMessage instances.
- */
-public class OspfMessageReader {
- private static final Logger log = LoggerFactory.getLogger(OspfMessageReader.class);
-
- /**
- * Reads and Converts the channel buffer to OspfMessage instance.
- *
- * @param channelBuffer channel buffer instance.
- * @return OSPF message instance.
- * @throws OspfParseException might throws exception while parsing buffer
- */
- public OspfMessage readFromBuffer(ChannelBuffer channelBuffer)
- throws OspfParseException {
-
- try {
- OspfPacketHeader ospfHeader = getOspfHeader(channelBuffer);
- OspfMessage ospfMessage = null;
- switch (ospfHeader.ospfType()) {
- case OspfParameters.HELLO:
- ospfMessage = new HelloPacket(ospfHeader);
- break;
- case OspfParameters.DD:
- ospfMessage = new DdPacket(ospfHeader);
- break;
- case OspfParameters.LSREQUEST:
- ospfMessage = new LsRequest(ospfHeader);
- break;
- case OspfParameters.LSUPDATE:
- ospfMessage = new LsUpdate(ospfHeader);
- break;
- case OspfParameters.LSACK:
- ospfMessage = new LsAcknowledge(ospfHeader);
- break;
- default:
- log.debug("Message Reader[Decoder] - Unknown LSA type..!!!");
- break;
- }
-
- if (ospfMessage != null) {
- try {
- log.debug("{} Received::Message Length :: {} ", ospfMessage.ospfMessageType(),
- ospfHeader.ospfPacLength());
- ospfMessage.readFrom(channelBuffer.readBytes(ospfHeader.ospfPacLength() -
- OspfUtil.OSPF_HEADER_LENGTH));
- } catch (Exception e) {
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR,
- OspfErrorType.BAD_MESSAGE);
- }
-
- }
-
- return ospfMessage;
- } catch (Exception e) {
- throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR,
- OspfErrorType.BAD_MESSAGE);
- }
- }
-
- /**
- * Gets the OSPF packet Header.
- *
- * @param channelBuffer channel buffer instance.
- * @return Ospf Header instance.
- */
- private OspfPacketHeader getOspfHeader(ChannelBuffer channelBuffer) {
- OspfPacketHeader ospfPacketHeader = new OspfPacketHeader();
-
- // Determine OSPF version & Packet Type
- int version = channelBuffer.readByte(); //byte 1 is ospf version
- int packetType = channelBuffer.readByte(); //byte 2 is ospf packet type
-
- // byte 3 & 4 combine is packet length.
- int packetLength = channelBuffer.readShort();
-
- byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- Ip4Address routerId = Ip4Address.valueOf(tempByteArray);
-
- tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- Ip4Address areaId = Ip4Address.valueOf(tempByteArray);
-
- int checkSum = channelBuffer.readUnsignedShort();
- int auType = channelBuffer.readUnsignedShort();
- int authentication = (int) channelBuffer.readLong();
-
- ospfPacketHeader.setOspfVer(version);
- ospfPacketHeader.setOspftype(packetType);
- ospfPacketHeader.setOspfPacLength(packetLength);
- ospfPacketHeader.setRouterId(routerId);
- ospfPacketHeader.setAreaId(areaId);
- ospfPacketHeader.setChecksum(checkSum);
- ospfPacketHeader.setAuthType(auType);
- ospfPacketHeader.setAuthentication(authentication);
-
- return ospfPacketHeader;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriter.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriter.java
deleted file mode 100644
index 1a69a3b..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriter.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-* Copyright 2016-present Open Networking Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.onosproject.ospf.protocol.ospfpacket;
-
-import org.onosproject.ospf.controller.OspfMessage;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A message writer which writes an OSPF message to byte array.
- */
-public class OspfMessageWriter {
- private static final Logger log = LoggerFactory.getLogger(OspfMessageWriter.class);
-
- /**
- * Writes OSPF message to byte array.
- *
- * @param ospfMessage OSPF message
- * @param interfaceIndex interface index
- * @param interfaceState interface state
- * @return message as byte array
- */
- public byte[] getMessage(OspfMessage ospfMessage, int interfaceIndex, int interfaceState) {
-
- byte[] buf = null;
- switch (ospfMessage.ospfMessageType().value()) {
- case OspfParameters.HELLO:
- case OspfParameters.LSACK:
- case OspfParameters.DD:
- case OspfParameters.LSREQUEST:
- case OspfParameters.LSUPDATE:
- buf = writeMessageToBytes(ospfMessage, interfaceIndex, interfaceState);
- break;
- default:
- log.debug("Message Writer[Encoder] - Unknown Message to encode..!!!");
- break;
- }
-
- return buf;
- }
-
- /**
- * Writes an OSPF Message to byte array.
- *
- * @param ospfMessage OSPF Message instance
- * @param interfaceState interface state
- * @return message as byte array
- */
- private byte[] writeMessageToBytes(OspfMessage ospfMessage, int interfaceIndex, int interfaceState) {
- byte[] ospfMessageAsByte = ospfMessage.asBytes();
- //Add the length and checksum in byte array at length position 2 & 3 and Checksum position
- ospfMessageAsByte = OspfUtil.addLengthAndCheckSum(ospfMessageAsByte, OspfUtil.OSPFPACKET_LENGTH_POS1,
- OspfUtil.OSPFPACKET_LENGTH_POS2,
- OspfUtil.OSPFPACKET_CHECKSUM_POS1,
- OspfUtil.OSPFPACKET_CHECKSUM_POS2);
- //Add Interface State Info and destination IP as metadata
- if (interfaceState == OspfParameters.DR || interfaceState == OspfParameters.BDR) {
- ospfMessageAsByte = OspfUtil.addMetadata(interfaceIndex, ospfMessageAsByte, OspfUtil.JOIN_ALL_DROUTERS,
- ospfMessage.destinationIp());
- } else {
- ospfMessageAsByte = OspfUtil.addMetadata(interfaceIndex, ospfMessageAsByte, OspfUtil.ONLY_ALL_SPF_ROUTERS,
- ospfMessage.destinationIp());
- }
-
- return ospfMessageAsByte;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfPacketHeader.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfPacketHeader.java
deleted file mode 100644
index 2d76cf9..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/OspfPacketHeader.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket;
-
-import com.google.common.base.MoreObjects;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfMessage;
-import org.onosproject.ospf.controller.OspfPacketType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-
-/**
- * Defines the OSPF Packet Header, fields and access methods.
- * Every OSPF packet starts with a standard 24 byte header.
- * This header contains all the information necessary to determine whether
- * the packet should be accepted for further processing
- */
-public class OspfPacketHeader implements OspfMessage {
-
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version # | Type | Packet length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Router ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Area ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Checksum | AuType |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Authentication |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Authentication |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private int ospfVer;
- private int ospfType;
- private int ospfPackLength;
- private Ip4Address routerId;
- private Ip4Address areaId;
- private int checkSum;
- private int auType;
- private int authentication;
- private Ip4Address destinationIp;
- private Ip4Address sourceIp;
- private int interfaceIndex;
-
- /**
- * Gets the source IP.
- *
- * @return source IP address
- */
- public Ip4Address sourceIp() {
- return sourceIp;
- }
-
- /**
- * Sets the source IP address.
- *
- * @param sourceIp source IP address
- */
- public void setSourceIp(Ip4Address sourceIp) {
- this.sourceIp = sourceIp;
- }
-
- @Override
- public OspfPacketType ospfMessageType() {
- //default impl
- return null;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
- //default impl
- }
-
- @Override
- public byte[] asBytes() {
- //default impl
- return new byte[0];
- }
-
- /**
- * Gets OSPF version.
- *
- * @return OSPF version
- */
- public int ospfVersion() {
- return ospfVer;
- }
-
- /**
- * Sets OSPF version.
- *
- * @param ospfVer OSPF version
- */
- public void setOspfVer(int ospfVer) {
- this.ospfVer = ospfVer;
- }
-
- /**
- * Gets OSPF packet type.
- *
- * @return OSPF packet type
- */
- public int ospfType() {
- return ospfType;
- }
-
- /**
- * Sets OSPF packet type.
- *
- * @param ospfType packet type
- */
- public void setOspftype(int ospfType) {
- this.ospfType = ospfType;
- }
-
- /**
- * Gets ospf packet length.
- *
- * @return OSPF packet length
- */
- public int ospfPacLength() {
- return ospfPackLength;
- }
-
- /**
- * Sets OSPF packet length.
- *
- * @param ospfPacLength packet length
- */
- public void setOspfPacLength(int ospfPacLength) {
- this.ospfPackLength = ospfPacLength;
- }
-
- /**
- * Gets router id.
- *
- * @return routerId
- */
- public Ip4Address routerId() {
- return routerId;
- }
-
- /**
- * Sets router id.
- *
- * @param routerId router id
- */
- public void setRouterId(Ip4Address routerId) {
- this.routerId = routerId;
- }
-
- /**
- * Gets area id.
- *
- * @return areaId area id
- */
- public Ip4Address areaId() {
- return areaId;
- }
-
- /**
- * Sets area id.
- *
- * @param areaId area id
- */
- public void setAreaId(Ip4Address areaId) {
- this.areaId = areaId;
- }
-
- /**
- * Gets checksum value.
- *
- * @return checkSum check sum value
- */
- public int checksum() {
- return checkSum;
- }
-
- /**
- * Sets checksum.
- *
- * @param checkSum check sum value
- */
- public void setChecksum(int checkSum) {
- this.checkSum = checkSum;
- }
-
- /**
- * Gets auth type.
- *
- * @return authType authentication type
- */
- public int authType() {
- return auType;
- }
-
- /**
- * Sets auth Type.
- *
- * @param auType authentication type
- */
- public void setAuthType(int auType) {
- this.auType = auType;
- }
-
- /**
- * Gets authentication.
- *
- * @return authentication
- */
- public int authentication() {
- return authentication;
- }
-
- /**
- * Sets authentication.
- *
- * @param authentication authentication
- */
- public void setAuthentication(int authentication) {
- this.authentication = authentication;
- }
-
- /**
- * Gets destination IP.
- *
- * @return destination IP
- */
- public Ip4Address destinationIp() {
- return destinationIp;
- }
-
- /**
- * Sets destination IP.
- *
- * @param destinationIp destination IP
- */
- public void setDestinationIp(Ip4Address destinationIp) {
- this.destinationIp = destinationIp;
- }
-
- /**
- * Returns the interface index on which the message received.
- *
- * @return interface index on which the message received
- */
- public int interfaceIndex() {
- return interfaceIndex;
- }
-
- /**
- * Sets the interface index on which the message received.
- *
- * @param interfaceIndex interface index on which the message received
- */
- public void setInterfaceIndex(int interfaceIndex) {
- this.interfaceIndex = interfaceIndex;
- }
-
- /**
- * Populates the header from the packetHeader instance.
- *
- * @param ospfPacketHeader packet header instance.
- */
- public void populateHeader(OspfPacketHeader ospfPacketHeader) {
- this.setInterfaceIndex(ospfPacketHeader.interfaceIndex());
- this.setSourceIp(ospfPacketHeader.sourceIp());
- this.setOspfVer(ospfPacketHeader.ospfVersion());
- this.setOspftype(ospfPacketHeader.ospfType());
- this.setOspfPacLength(ospfPacketHeader.ospfPacLength());
- this.setRouterId(ospfPacketHeader.routerId());
- this.setAreaId(ospfPacketHeader.areaId());
- this.setChecksum(ospfPacketHeader.checksum());
- this.setAuthType(ospfPacketHeader.authType());
- this.setAuthentication(ospfPacketHeader.authentication());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("ospfVersion", ospfVer)
- .add("ospfType", ospfType)
- .add("ospfPackLength", ospfPackLength)
- .add("routerId", routerId)
- .add("areaId", areaId)
- .add("checkSum", checkSum)
- .add("auType", auType)
- .add("authentication", authentication)
- .add("destinationIP", destinationIp)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/package-info.java
deleted file mode 100644
index e408789..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the different types of OSPF Packets.
- */
-package org.onosproject.ospf.protocol.ospfpacket;
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/subtype/LsRequestPacket.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/subtype/LsRequestPacket.java
deleted file mode 100644
index e8ce640..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/subtype/LsRequestPacket.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket.subtype;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Representation of an LS Request packet and fields and access methods to access it.
- */
-public class LsRequestPacket {
-
- private int lsType;
- private String linkStateId;
- private String ownRouterId;
-
- /**
- * Gets the LSA type.
- *
- * @return LSA type
- */
- public int lsType() {
- return lsType;
- }
-
- /**
- * Sets the LSA type.
- *
- * @param lsType LSA type
- */
- public void setLsType(int lsType) {
- this.lsType = lsType;
- }
-
- /**
- * Gets the link state id.
- *
- * @return link state id
- */
- public String linkStateId() {
- return linkStateId;
- }
-
- /**
- * Sets link state id.
- *
- * @param linkStateId state id
- */
- public void setLinkStateId(String linkStateId) {
- this.linkStateId = linkStateId;
- }
-
- /**
- * Gets the router id.
- *
- * @return router id
- */
- public String ownRouterId() {
- return ownRouterId;
- }
-
- /**
- * Sets the router id.
- *
- * @param ownRouterId router id
- */
- public void setOwnRouterId(String ownRouterId) {
- this.ownRouterId = ownRouterId;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("lsType", lsType)
- .add("linkStateId", linkStateId)
- .add("ownRouterId", ownRouterId)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/subtype/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/subtype/package-info.java
deleted file mode 100644
index 2b29614..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/subtype/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the OSPF packet sub types which is used in OSPF packets..
- */
-package org.onosproject.ospf.protocol.ospfpacket.subtype;
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/DdPacket.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/DdPacket.java
deleted file mode 100644
index c38b383..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/DdPacket.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.controller.OspfPacketType;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of an OSPF Database Description packet.
- * Database Description packets are OSPF packet type 2.
- * These packets are exchanged when an adjacency is being initialized.
- * They describe the contents of the link-state database.
- */
-public class DdPacket extends OspfPacketHeader {
-
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version # | 2 | Packet length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Router ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Area ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Checksum | AuType |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Authentication |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Authentication |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Interface MTU | Options |0|0|0|0|0|I|M|MS
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | DD sequence number |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- +- -+
- | |
- +- An LSA Header -+
- | |
- +- -+
- | |
- +- -+
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ... |
- */
- private static final Logger log = LoggerFactory.getLogger(DdPacket.class);
- private int imtu;
- private int options;
- private int ims; // initialize , more but / master slave bit
- private int isMaster;
- private int isInitialize;
- private int isMore;
- private long sequenceNo;
- private boolean isOpaqueCapable;
- private List<LsaHeader> lsaHeaderList = new ArrayList<>();
-
- /**
- * Creates an instance of DD packet.
- */
- public DdPacket() {
- }
-
- /**
- * Creates an instance of DD packet.
- *
- * @param ospfHeader OSPF header instance
- */
- public DdPacket(OspfPacketHeader ospfHeader) {
- populateHeader(ospfHeader);
- }
-
- /**
- * Gets is opaque capable or not.
- *
- * @return true if opaque capable else false
- */
- public boolean isOpaqueCapable() {
- return isOpaqueCapable;
- }
-
- /**
- * Sets is opaque capable or not.
- *
- * @param isOpaqueCapable true or false
- */
- public void setIsOpaqueCapable(boolean isOpaqueCapable) {
- this.isOpaqueCapable = isOpaqueCapable;
- }
-
- /**
- * Gets IMS value.
- *
- * @return IMS bits as an int value
- */
- public int ims() {
- return ims;
- }
-
- /**
- * Sets IMS value.
- *
- * @param ims IMS value
- */
- public void setIms(int ims) {
- this.ims = ims;
- }
-
- /**
- * Gets master bit value.
- *
- * @return 1 if master else 0
- */
- public int isMaster() {
- return isMaster;
- }
-
- /**
- * Sets master value.
- *
- * @param isMaster 1 represents master
- */
- public void setIsMaster(int isMaster) {
- this.isMaster = isMaster;
- }
-
- /**
- * Gets Initialize bit value.
- *
- * @return 1 if initialize else 0
- */
- public int isInitialize() {
- return isInitialize;
- }
-
- /**
- * Sets initialize value.
- *
- * @param isInitialize 1 is initialize else 0
- */
- public void setIsInitialize(int isInitialize) {
- this.isInitialize = isInitialize;
- }
-
- /**
- * Gets is more bit set or not.
- *
- * @return 1 if more set else 0
- */
- public int isMore() {
- return isMore;
- }
-
- /**
- * Sets more bit value to 0 or 1.
- *
- * @param isMore 1 if more set else 0
- */
- public void setIsMore(int isMore) {
- this.isMore = isMore;
- }
-
-
- /**
- * Gets IMTU value.
- *
- * @return IMTU value
- */
- public int imtu() {
- return imtu;
- }
-
- /**
- * Sets IMTU value.
- *
- * @param imtu value
- */
- public void setImtu(int imtu) {
- this.imtu = imtu;
- }
-
- /**
- * Gets options value.
- *
- * @return options
- */
- public int options() {
- return options;
- }
-
- /**
- * Sets options value.
- *
- * @param options options value
- */
- public void setOptions(int options) {
- this.options = options;
- }
-
- /**
- * Gets sequence number.
- *
- * @return sequenceNo
- */
- public long sequenceNo() {
- return sequenceNo;
- }
-
- /**
- * Sets Sequence number.
- *
- * @param sequenceNo sequence number
- */
- public void setSequenceNo(long sequenceNo) {
- this.sequenceNo = sequenceNo;
- }
-
- /**
- * Gets LSA header list.
- *
- * @return LSA header
- */
- public List<LsaHeader> getLsaHeaderList() {
- return lsaHeaderList;
- }
-
- /**
- * Adds LSA header to header list.
- *
- * @param lsaHeader lsa header instance
- */
- public void addLsaHeader(LsaHeader lsaHeader) {
-
- if (!lsaHeaderList.contains(lsaHeader)) {
- lsaHeaderList.add(lsaHeader);
- }
- }
-
- @Override
- public OspfPacketType ospfMessageType() {
- return OspfPacketType.DD;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
-
- try {
- this.setImtu(channelBuffer.readShort());
-
- int options = channelBuffer.readByte();
- String obit = Integer.toHexString(options);
- if (obit.length() == 1) {
- obit = "0" + obit;
- }
- String toBinary = Integer.toBinaryString(Integer.parseInt(new Character(obit.charAt(0)).toString()));
- if (toBinary.length() == 1) {
- toBinary = "000" + toBinary;
- } else if (toBinary.length() == 2) {
- toBinary = "00" + toBinary;
- } else if (toBinary.length() == 3) {
- toBinary = "0" + toBinary;
- }
- if (Integer.parseInt(new Character(toBinary.charAt(1)).toString()) == 1) {
- this.setIsOpaqueCapable(true);
- }
- this.setOptions(options);
- this.setIms(channelBuffer.readByte());
- //Convert the byte to ims bits
- String strIms = Integer.toBinaryString(this.ims());
- if (strIms.length() == 3) {
- this.setIsInitialize(Integer.parseInt(Character.toString(strIms.charAt(0))));
- this.setIsMore(Integer.parseInt(Character.toString(strIms.charAt(1))));
- this.setIsMaster(Integer.parseInt(Character.toString(strIms.charAt(2))));
- } else if (strIms.length() == 2) {
- this.setIsInitialize(0);
- this.setIsMore(Integer.parseInt(Character.toString(strIms.charAt(0))));
- this.setIsMaster(Integer.parseInt(Character.toString(strIms.charAt(1))));
- } else if (strIms.length() == 1) {
- this.setIsInitialize(0);
- this.setIsMore(0);
- this.setIsMaster(Integer.parseInt(Character.toString(strIms.charAt(0))));
- }
- this.setSequenceNo(channelBuffer.readInt());
-
- //add all the LSA Headers - header is of 20 bytes
- while (channelBuffer.readableBytes() >= OspfUtil.LSA_HEADER_LENGTH) {
- LsaHeader header = OspfUtil.readLsaHeader(channelBuffer.readBytes(OspfUtil.LSA_HEADER_LENGTH));
- //add the LSAHeader to DDPacket
- addLsaHeader(header);
- }
-
- } catch (Exception e) {
- log.debug("Error::DdPacket:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.MESSAGE_HEADER_ERROR, OspfErrorType.BAD_MESSAGE_LENGTH);
- }
- }
-
- @Override
- public byte[] asBytes() {
-
- byte[] ddMessage = null;
-
- byte[] ddHeader = getDdHeaderAsByteArray();
- byte[] ddBody = getDdBodyAsByteArray();
- ddMessage = Bytes.concat(ddHeader, ddBody);
-
- return ddMessage;
- }
-
- /**
- * Gets DD Header as byte array.
- *
- * @return dd header as byte array.
- */
- public byte[] getDdHeaderAsByteArray() {
- List<Byte> headerLst = new ArrayList<>();
-
- try {
- headerLst.add((byte) this.ospfVersion());
- headerLst.add((byte) this.ospfType());
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.ospfPacLength())));
- headerLst.addAll(Bytes.asList(this.routerId().toOctets()));
- headerLst.addAll(Bytes.asList(this.areaId().toOctets()));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.checksum())));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.authType())));
- //Authentication is 0 always. Total 8 bytes consist of zero
- byte[] auth = new byte[OspfUtil.EIGHT_BYTES];
- headerLst.addAll(Bytes.asList(auth));
-
- } catch (Exception e) {
- log.debug("Error");
-
- }
-
- return Bytes.toArray(headerLst);
- }
-
-
- /**
- * Gets DD body as byte array.
- *
- * @return DD body
- */
- public byte[] getDdBodyAsByteArray() {
- List<Byte> bodyLst = new ArrayList<>();
-
- try {
- bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.imtu())));
- bodyLst.add((byte) this.options());
-
- StringBuilder sb = new StringBuilder();
- sb.append(this.isInitialize());
- sb.append(this.isMore());
- sb.append(this.isMaster());
-
- bodyLst.add((byte) Integer.parseInt(sb.toString(), 2));
- bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.sequenceNo()))); // passing long value
-
- for (LsaHeader lsaHeader : lsaHeaderList) {
- if (lsaHeader.lsType() == OspfParameters.LINK_LOCAL_OPAQUE_LSA ||
- lsaHeader.lsType() == OspfParameters.AREA_LOCAL_OPAQUE_LSA ||
- lsaHeader.lsType() == OspfParameters.AS_OPAQUE_LSA) {
- OpaqueLsaHeader header = (OpaqueLsaHeader) lsaHeader;
- bodyLst.addAll(Bytes.asList(header.getOpaqueLsaHeaderAsByteArray()));
- } else {
- bodyLst.addAll(Bytes.asList(lsaHeader.getLsaHeaderAsByteArray()));
- }
- }
- } catch (Exception e) {
- log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage());
- return Bytes.toArray(bodyLst);
- }
-
- return Bytes.toArray(bodyLst);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("imtu", imtu)
- .add("options", options)
- .add("ims", ims)
- .add("isMaster", isMaster)
- .add("isInitialize", isInitialize)
- .add("isMore", isMore)
- .add("sequenceNo", sequenceNo)
- .add("isOpaqueCapable", isOpaqueCapable)
- .add("lsaHeaderList", lsaHeaderList)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/HelloPacket.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/HelloPacket.java
deleted file mode 100644
index ab7e885..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/HelloPacket.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.controller.OspfPacketType;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Defines an OSPF Hello Message, and the fields and methods to access it.
- * Hello packets are OSPF packet type 1. These packets are sent
- * periodically on all interfaces in order to establish and
- * maintain neighbor relationships.
- */
-public class HelloPacket extends OspfPacketHeader {
-
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version # | 1 | Packet length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Router ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Area ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Checksum | AuType |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Authentication |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Authentication |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Network Mask |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | HelloInterval | Options | Rtr Pri |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | RouterDeadInterval |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Designated Router |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Backup Designated Router |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Neighbor |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ... |
-
- Hello Message Format
- REFERENCE : RFC 2328
- */
-
- private static final Logger log = LoggerFactory.getLogger(HelloPacket.class);
- private Ip4Address networkMask;
- private int options;
- private int helloInterval;
- private int routerPriority;
- private int routerDeadInterval;
- private Ip4Address bdr;
- private Ip4Address dr;
- private List<Ip4Address> neighborAddress = new ArrayList<>();
-
- /**
- * Creates an instance of Hello packet.
- */
- public HelloPacket() {
- }
-
- /**
- * Creates an instance of Hello packet.
- *
- * @param ospfHeader OSPF header instance.
- */
- public HelloPacket(OspfPacketHeader ospfHeader) {
- populateHeader(ospfHeader);
- }
-
- /**
- * Gets network mask.
- *
- * @return network mask
- */
- public Ip4Address networkMask() {
- return networkMask;
- }
-
- /**
- * Sets network mask.
- *
- * @param networkMask network mask
- */
- public void setNetworkMask(Ip4Address networkMask) {
- this.networkMask = networkMask;
- }
-
- /**
- * Gets BDRs IP address.
- *
- * @return BDRs IP address
- */
- public Ip4Address bdr() {
- return bdr;
- }
-
- /**
- * Sets BDR IP address.
- *
- * @param bdr BDR IP address
- */
- public void setBdr(Ip4Address bdr) {
- this.bdr = bdr;
- }
-
- /**
- * Gets DRs IP address.
- *
- * @return DRs IP address
- */
- public Ip4Address dr() {
- return dr;
- }
-
- /**
- * Sets DRs IP address.
- *
- * @param dr DRs IP address
- */
- public void setDr(Ip4Address dr) {
- this.dr = dr;
- }
-
- /**
- * Adds neighbor to map.
- *
- * @param neighborID neighbors id
- */
- public void addNeighbor(Ip4Address neighborID) {
- if (!neighborAddress.contains(neighborID)) {
- neighborAddress.add(neighborID);
- }
- }
-
- /**
- * Checks neighbor is in map or not.
- *
- * @param neighborID neighbors id
- * @return true if neighbor exist else false
- */
- public boolean containsNeighbour(Ip4Address neighborID) {
- return (neighborAddress.contains(neighborID)) ? true : false;
- }
-
- /**
- * Gets options value.
- *
- * @return options value
- */
- public int options() {
- return options;
- }
-
- /**
- * Sets options value.
- *
- * @param options options value
- */
- public void setOptions(int options) {
- this.options = options;
- }
-
- /**
- * Gets router priority.
- *
- * @return routerPriority
- */
- public int routerPriority() {
- return routerPriority;
- }
-
- /**
- * Sets router priority.
- *
- * @param routerPriority router priority
- */
- public void setRouterPriority(int routerPriority) {
- this.routerPriority = routerPriority;
- }
-
- /**
- * Gets hello interval.
- *
- * @return hello Interval
- */
- public int helloInterval() {
- return helloInterval;
- }
-
- /**
- * Sets hello Interval.
- *
- * @param helloInterval hello Interval
- */
- public void setHelloInterval(int helloInterval) {
- this.helloInterval = helloInterval;
- }
-
- /**
- * Gets router dead interval.
- *
- * @return router dead interval
- */
- public int routerDeadInterval() {
- return routerDeadInterval;
- }
-
- /**
- * Sets router dead interval.
- *
- * @param routerDeadInterval router dead interval
- */
- public void setRouterDeadInterval(int routerDeadInterval) {
- this.routerDeadInterval = routerDeadInterval;
- }
-
- @Override
- public OspfPacketType ospfMessageType() {
- return OspfPacketType.HELLO;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
-
- try {
- byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- this.setNetworkMask(Ip4Address.valueOf(tempByteArray));
- this.setHelloInterval(channelBuffer.readShort());
- this.setOptions(channelBuffer.readByte());
- this.setRouterPriority(channelBuffer.readByte() & 0xff);
- this.setRouterDeadInterval(channelBuffer.readInt());
- tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- this.setDr(Ip4Address.valueOf(tempByteArray));
- tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- this.setBdr(Ip4Address.valueOf(tempByteArray));
-
- while (channelBuffer.readableBytes() > 0) {
- tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- this.addNeighbor(Ip4Address.valueOf(tempByteArray));
- }
-
- } catch (Exception e) {
- log.debug("Error::HelloPacket:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.MESSAGE_HEADER_ERROR, OspfErrorType.BAD_MESSAGE_LENGTH);
- }
- }
-
- @Override
- public byte[] asBytes() {
-
- byte[] helloMessage = null;
- byte[] helloHeader = getHelloHeaderAsByteArray();
- byte[] helloBody = getHelloBodyAsByteArray();
- helloMessage = Bytes.concat(helloHeader, helloBody);
-
- log.debug("HelloPacket::asBytes::Hello asBytes:: {}", helloMessage);
-
- return helloMessage;
- }
-
- /**
- * Gets hello header as byte array.
- *
- * @return hello header
- */
- public byte[] getHelloHeaderAsByteArray() {
- List<Byte> headerLst = new ArrayList<>();
- try {
- headerLst.add((byte) this.ospfVersion());
- headerLst.add((byte) this.ospfType());
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.ospfPacLength())));
- headerLst.addAll(Bytes.asList(this.routerId().toOctets()));
- headerLst.addAll(Bytes.asList(this.areaId().toOctets()));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.checksum())));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.authType())));
- //Authentication is 0 always. Total 8 bytes consist of zero
- byte[] auth = new byte[OspfUtil.EIGHT_BYTES];
- headerLst.addAll(Bytes.asList(auth));
- } catch (Exception e) {
- log.debug("Error::getHelloHeaderAsByteArray {}", e.getMessage());
- return Bytes.toArray(headerLst);
- }
-
- return Bytes.toArray(headerLst);
- }
-
- /**
- * Gets hello body as byte array.
- *
- * @return hello body as byte array
- */
- public byte[] getHelloBodyAsByteArray() {
- List<Byte> bodyLst = new ArrayList<>();
-
- try {
- bodyLst.addAll(Bytes.asList(this.networkMask().toOctets()));
- bodyLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.helloInterval())));
- bodyLst.add((byte) this.options());
- bodyLst.add((byte) this.routerPriority());
- bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.routerDeadInterval())));
- bodyLst.addAll(Bytes.asList(this.dr().toOctets()));
- bodyLst.addAll(Bytes.asList(this.bdr().toOctets()));
- for (Ip4Address neighbour : neighborAddress) {
- bodyLst.addAll(Bytes.asList(neighbour.toOctets()));
- }
-
- } catch (Exception e) {
- log.debug("Error::getHelloBodyAsByteArray {}", e.getMessage());
- return Bytes.toArray(bodyLst);
- }
-
- return Bytes.toArray(bodyLst);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("networkMask", networkMask)
- .add("options", options)
- .add("helloInterval", helloInterval)
- .add("routerPriority", routerPriority)
- .add("routerDeadInterval", routerDeadInterval)
- .add("bdr", bdr)
- .add("dr", dr)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledge.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledge.java
deleted file mode 100644
index 5dd63aa..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledge.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.controller.OspfPacketType;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of an OSPF Link State Acknowledgment Message.
- * Link State Acknowledgment Packets are OSPF packet type 5.
- * To make the flooding of LSAs reliable, flooded LSAs are explicitly
- * acknowledged. This acknowledgment is accomplished through the
- * sending and receiving of Link State Acknowledgment packets.
- * Multiple LSAs can be acknowledged in a single Link State Acknowledgment packet.
- */
-public class LsAcknowledge extends OspfPacketHeader {
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version # | 5 | Packet length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Router ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Area ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Checksum | AuType |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Authentication |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Authentication |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- +- -+
- | |
- +- An LSA Header -+
- | |
- +- -+
- | |
- +- -+
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ... |
- */
- private static final Logger log = LoggerFactory.getLogger(LsAcknowledge.class);
- private List<LsaHeader> linkStateHeaders = new ArrayList<>();
-
- /**
- * Creates an instance of Link State Acknowledgment instance.
- */
- public LsAcknowledge() {
- }
-
- /**
- * Creates an instance of Link State Acknowledgment instance.
- *
- * @param ospfHeader OSPF header instance.
- */
- public LsAcknowledge(OspfPacketHeader ospfHeader) {
- populateHeader(ospfHeader);
- }
-
- /**
- * Gets ls headers.
- *
- * @return ls headers
- */
- public List<LsaHeader> getLinkStateHeaders() {
- return linkStateHeaders;
- }
-
- /**
- * Adds link state header to list.
- *
- * @param lsaHeader LSA header
- */
- public void addLinkStateHeader(LsaHeader lsaHeader) {
- if (!linkStateHeaders.contains(lsaHeader)) {
- linkStateHeaders.add(lsaHeader);
- }
- }
-
- @Override
- public OspfPacketType ospfMessageType() {
- return OspfPacketType.LSAACK;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
- try {
- //add all the LSA Headers - one header is of 20 bytes
- while (channelBuffer.readableBytes() >= OspfUtil.LSA_HEADER_LENGTH) {
- LsaHeader header = OspfUtil.readLsaHeader(channelBuffer);
- //add the LSAHeader to acknowledge
- addLinkStateHeader(header);
- }
-
- } catch (Exception e) {
- log.debug("Error::LsAckPacket:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.MESSAGE_HEADER_ERROR, OspfErrorType.BAD_MESSAGE_LENGTH);
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] lsAckMessage = null;
-
- byte[] lsAckHeader = getLsAckAsByteArray();
- byte[] lsAckBody = getLsAckBodyAsByteArray();
- lsAckMessage = Bytes.concat(lsAckHeader, lsAckBody);
-
- return lsAckMessage;
- }
-
- /**
- * Gets LSAcknowledge as byte array.
- *
- * @return byte array
- */
- public byte[] getLsAckAsByteArray() {
- List<Byte> headerLst = new ArrayList<>();
- try {
- headerLst.add((byte) this.ospfVersion());
- headerLst.add((byte) this.ospfType());
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.ospfPacLength())));
- headerLst.addAll(Bytes.asList(this.routerId().toOctets()));
- headerLst.addAll(Bytes.asList(this.areaId().toOctets()));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.checksum())));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.authType())));
- //Authentication is 0 always. Total 8 bytes consist of zero
- byte[] auth = new byte[OspfUtil.EIGHT_BYTES];
- headerLst.addAll(Bytes.asList(auth));
- } catch (Exception e) {
- log.debug("Error::LsAckPacket:: {}", e.getMessage());
- return Bytes.toArray(headerLst);
- }
-
- return Bytes.toArray(headerLst);
- }
-
- /**
- * Gets LsAck body as byte array.
- *
- * @return byte array
- */
- public byte[] getLsAckBodyAsByteArray() {
- List<Byte> bodyLst = new ArrayList<>();
-
- try {
- for (LsaHeader lsaHeader : linkStateHeaders) {
- if (lsaHeader.lsType() == OspfParameters.LINK_LOCAL_OPAQUE_LSA ||
- lsaHeader.lsType() == OspfParameters.AREA_LOCAL_OPAQUE_LSA ||
- lsaHeader.lsType() == OspfParameters.AS_OPAQUE_LSA) {
- OpaqueLsaHeader header = (OpaqueLsaHeader) lsaHeader;
- bodyLst.addAll(Bytes.asList(header.getOpaqueLsaHeaderAsByteArray()));
- } else {
- bodyLst.addAll(Bytes.asList(lsaHeader.getLsaHeaderAsByteArray()));
- }
- }
- } catch (Exception e) {
- log.debug("Error::getLsAckBodyAsByteArray {}", e.getMessage());
- return Bytes.toArray(bodyLst);
- }
-
- return Bytes.toArray(bodyLst);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("linkStateHeaders", linkStateHeaders)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequest.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequest.java
deleted file mode 100644
index 9f7e884..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequest.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket;
-import org.onosproject.ospf.controller.OspfPacketType;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Representation of an OSPF Link State Request packet.
- * Link State Request packets are OSPF packet type 3. After exchanging
- * database description packets with a neighboring router, a router may
- * find that parts of its link-state database are out-of-date. The
- * Link State Request packet is used to request the pieces of the
- * neighbor's database that are more up-to-date.
- */
-public class LsRequest extends OspfPacketHeader {
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version # | 3 | Packet length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Router ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Area ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Checksum | AuType |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Authentication |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Authentication |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Link State ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Advertising Router |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | ... |
-
- LsRequest Message Format
- REFERENCE : RFC 2328
- */
- private static final Logger log = LoggerFactory.getLogger(LsRequest.class);
- private List<LsRequestPacket> linkStateRequests = new ArrayList<>();
-
- /**
- * Creates an instance of link state request packet.
- */
- public LsRequest() {
- }
-
- /**
- * Creates an instance of link state request packet.
- *
- * @param ospfHeader OSPF header instance.
- */
- public LsRequest(OspfPacketHeader ospfHeader) {
- populateHeader(ospfHeader);
- }
-
- /**
- * Adds link state request.
- *
- * @param lsRequestPacket ls request packet instance
- */
- public void addLinkStateRequests(LsRequestPacket lsRequestPacket) {
- if (!linkStateRequests.contains(lsRequestPacket)) {
- linkStateRequests.add(lsRequestPacket);
- }
- }
-
- /**
- * Gets link state request packet instance.
- *
- * @return link state request packet instance
- */
- public List<LsRequestPacket> getLinkStateRequests() {
- return linkStateRequests;
- }
-
- @Override
- public OspfPacketType ospfMessageType() {
- return OspfPacketType.LSREQUEST;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
-
- while (channelBuffer.readableBytes() >= OspfUtil.LSREQUEST_LENGTH) {
- LsRequestPacket lsRequestPacket = new LsRequestPacket();
- lsRequestPacket.setLsType(channelBuffer.readInt());
- byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- lsRequestPacket.setLinkStateId(Ip4Address.valueOf(tempByteArray).toString());
- tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- lsRequestPacket.setOwnRouterId(Ip4Address.valueOf(tempByteArray).toString());
-
- this.addLinkStateRequests(lsRequestPacket);
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] lsrMessage = null;
- byte[] lsrHeader = getLsrHeaderAsByteArray();
- byte[] lsrBody = getLsrBodyAsByteArray();
- lsrMessage = Bytes.concat(lsrHeader, lsrBody);
-
- return lsrMessage;
- }
-
- /**
- * Gets LS request packet header as byte array.
- *
- * @return LS request packet header as byte array
- */
- public byte[] getLsrHeaderAsByteArray() {
- List<Byte> headerLst = new ArrayList<>();
-
- try {
- headerLst.add((byte) this.ospfVersion());
- headerLst.add((byte) this.ospfType());
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.ospfPacLength())));
- headerLst.addAll(Bytes.asList(this.routerId().toOctets()));
- headerLst.addAll(Bytes.asList(this.areaId().toOctets()));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.checksum())));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.authType())));
- //Authentication is 0 always. Total 8 bytes consist of zero
- byte[] auth = new byte[OspfUtil.EIGHT_BYTES];
- headerLst.addAll(Bytes.asList(auth));
- } catch (Exception e) {
- log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage());
- return Bytes.toArray(headerLst);
- }
-
- return Bytes.toArray(headerLst);
- }
-
- /**
- * Gets LS request packet body as byte array.
- *
- * @return LS request packet body as byte array
- */
- public byte[] getLsrBodyAsByteArray() {
- List<Byte> bodyLst = new ArrayList<>();
-
- try {
- for (LsRequestPacket lsrPacket : linkStateRequests) {
- bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(lsrPacket.lsType())));
- bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsrPacket.linkStateId()).getAddress()));
- bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsrPacket.ownRouterId()).getAddress()));
- }
- } catch (Exception e) {
- log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage());
- return Bytes.toArray(bodyLst);
- }
-
- return Bytes.toArray(bodyLst);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("linkStateRequests", linkStateRequests)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdate.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdate.java
deleted file mode 100644
index a0e9b32..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdate.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.ospf.controller.OspfLsa;
-import org.onosproject.ospf.exceptions.OspfErrorType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.lsa.types.AsbrSummaryLsa;
-import org.onosproject.ospf.protocol.lsa.types.ExternalLsa;
-import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa11;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa9;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.lsa.types.SummaryLsa;
-import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.controller.OspfPacketType;
-import org.onosproject.ospf.protocol.util.OspfParameters;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Representation of an OSPF Link State Update packet.
- * Link State Update packets are OSPF packet type 4. These packets
- * implement the flooding of LSAs. Each Link State Update packet
- * carries a collection of LSAs one hop further from their origin.
- * Several LSAs may be included in a single packet.
- */
-public class LsUpdate extends OspfPacketHeader {
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Version # | 4 | Packet length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Router ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Area ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Checksum | AuType |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Authentication |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Authentication |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | # LSAs |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- +- +-+
- | LSAs |
- +- +-+
- | ... |
- */
- private static final Logger log = LoggerFactory.getLogger(LsUpdate.class);
- private int numberOfLsa;
- private List<OspfLsa> lsaList = new LinkedList<>();
-
- /**
- * Creates an instance of Link State Update packet.
- */
- public LsUpdate() {
- }
-
- /**
- * Creates an instance of Link State Update packet.
- *
- * @param ospfHeader ospf header instance.
- */
- public LsUpdate(OspfPacketHeader ospfHeader) {
- populateHeader(ospfHeader);
- }
-
- /**
- * Gets the LSA list.
- *
- * @return list of LSA
- */
- public List getLsaList() {
- return lsaList;
- }
-
- /**
- * Adds the LSA to list.
- *
- * @param lsa LSA
- */
- public void addLsa(OspfLsa lsa) {
- if (!lsaList.contains(lsa)) {
- lsaList.add(lsa);
- }
- }
-
- /**
- * Gets the number of LSA.
- *
- * @return number of LSA
- */
- public int noLsa() {
- return numberOfLsa;
- }
-
- /**
- * Sets number of LSA.
- *
- * @param numberOfLsa number of LSA
- */
- public void setNumberOfLsa(int numberOfLsa) {
- this.numberOfLsa = numberOfLsa;
- }
-
-
- @Override
- public OspfPacketType ospfMessageType() {
- return OspfPacketType.LSUPDATE;
- }
-
- @Override
- public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
- try {
- //From header 4 bytes is number of lsa's
- this.setNumberOfLsa(channelBuffer.readInt());
- //get the remaining bytes represents Number of LSA's present. Add all the LSA's
- while (channelBuffer.readableBytes() > OspfUtil.LSA_HEADER_LENGTH) {
-
- LsaHeader header = OspfUtil.readLsaHeader(channelBuffer.readBytes(OspfUtil.LSA_HEADER_LENGTH));
- int lsaLength = header.lsPacketLen();
- int lsType = header.lsType();
-
- switch (lsType) {
- case OspfParameters.LINK_LOCAL_OPAQUE_LSA:
- OpaqueLsa9 opaqueLsa9 = new OpaqueLsa9((OpaqueLsaHeader) header);
- opaqueLsa9.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
- addLsa(opaqueLsa9);
- break;
- case OspfParameters.AREA_LOCAL_OPAQUE_LSA:
- OpaqueLsa10 opaqueLsa10 = new OpaqueLsa10((OpaqueLsaHeader) header);
- opaqueLsa10.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
- addLsa(opaqueLsa10);
- break;
- case OspfParameters.AS_OPAQUE_LSA:
- OpaqueLsa11 opaqueLsa11 = new OpaqueLsa11((OpaqueLsaHeader) header);
- opaqueLsa11.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
- addLsa(opaqueLsa11);
- break;
- case OspfParameters.ROUTER:
- RouterLsa routerLsa = new RouterLsa(header);
- routerLsa.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
- addLsa(routerLsa);
- break;
- case OspfParameters.NETWORK:
- NetworkLsa networkLsa = new NetworkLsa(header);
- networkLsa.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
- addLsa(networkLsa);
- break;
- case OspfParameters.ASBR_SUMMARY:
- AsbrSummaryLsa asbrSummaryLsa = new AsbrSummaryLsa(header);
- asbrSummaryLsa.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
- addLsa(asbrSummaryLsa);
- break;
- case OspfParameters.SUMMARY:
- SummaryLsa summaryLsa = new SummaryLsa(header);
- summaryLsa.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
- addLsa(summaryLsa);
- break;
- case OspfParameters.EXTERNAL_LSA:
- ExternalLsa externalLsa = new ExternalLsa(header);
- externalLsa.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
- addLsa(externalLsa);
- break;
- default:
- log.debug("LSUpdate::readLsUpdateBody::UnKnown LS Type: {}", lsType);
- break;
- }
- }
- } catch (Exception e) {
- log.debug("Error::LsUpdate:: {}", e.getMessage());
- throw new OspfParseException(OspfErrorType.MESSAGE_HEADER_ERROR, OspfErrorType.BAD_MESSAGE_LENGTH);
- }
- }
-
- @Override
- public byte[] asBytes() {
- byte[] lsuMessage = null;
-
- byte[] ospfHeader = getLsuHeaderAsByteArray();
- byte[] lsuBody = getLsuBodyAsByteArray();
- lsuMessage = Bytes.concat(ospfHeader, lsuBody);
-
- return lsuMessage;
- }
-
- /**
- * Gets lsu header.
- *
- * @return lsu header as byte array
- */
- public byte[] getLsuHeaderAsByteArray() {
- List<Byte> headerLst = new ArrayList<>();
- try {
- headerLst.add((byte) this.ospfVersion());
- headerLst.add((byte) this.ospfType());
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.ospfPacLength())));
- headerLst.addAll(Bytes.asList(this.routerId().toOctets()));
- headerLst.addAll(Bytes.asList(this.areaId().toOctets()));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.checksum())));
- headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.authType())));
- //Authentication is 0 always. Total 8 bytes consist of zero
- byte[] auth = new byte[OspfUtil.EIGHT_BYTES];
- headerLst.addAll(Bytes.asList(auth));
- } catch (Exception e) {
- log.debug("Error::LSUpdate::getLsuHeaderAsByteArray:: {}", e.getMessage());
- return Bytes.toArray(headerLst);
- }
-
- return Bytes.toArray(headerLst);
- }
-
- /**
- * Get lsu body as byte array.
- *
- * @return lsu body as byte array
- */
- public byte[] getLsuBodyAsByteArray() {
- List<Byte> bodyLst = new ArrayList<>();
-
- try {
- //add number of LSA's
- bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(this.noLsa())));
- //for each type of LSA's from the list get lsa bytes
- for (OspfLsa ospfLsa : lsaList) {
- //Check the type of lsa and build bytes accordingly
- switch (ospfLsa.getOspfLsaType().value()) {
- case OspfParameters.LINK_LOCAL_OPAQUE_LSA:
- OpaqueLsa9 opaqueLsa9 = (OpaqueLsa9) ospfLsa;
- bodyLst.addAll(Bytes.asList(opaqueLsa9.asBytes()));
- break;
- case OspfParameters.AREA_LOCAL_OPAQUE_LSA:
- OpaqueLsa10 opaqueLsa10 = (OpaqueLsa10) ospfLsa;
- bodyLst.addAll(Bytes.asList(opaqueLsa10.asBytes()));
- break;
- case OspfParameters.AS_OPAQUE_LSA:
- OpaqueLsa11 opaqueLsa11 = (OpaqueLsa11) ospfLsa;
- bodyLst.addAll(Bytes.asList(opaqueLsa11.asBytes()));
- break;
- case OspfParameters.ROUTER:
- RouterLsa routerLsa = (RouterLsa) ospfLsa;
- bodyLst.addAll(Bytes.asList(routerLsa.asBytes()));
- break;
- case OspfParameters.NETWORK:
- NetworkLsa networkLsa = (NetworkLsa) ospfLsa;
- bodyLst.addAll(Bytes.asList(networkLsa.asBytes()));
- break;
- case OspfParameters.ASBR_SUMMARY:
- AsbrSummaryLsa asbrSummaryLsa = (AsbrSummaryLsa) ospfLsa;
- bodyLst.addAll(Bytes.asList(asbrSummaryLsa.asBytes()));
- break;
- case OspfParameters.SUMMARY:
- SummaryLsa summaryLsa = (SummaryLsa) ospfLsa;
- bodyLst.addAll(Bytes.asList(summaryLsa.asBytes()));
- break;
- case OspfParameters.EXTERNAL_LSA:
- ExternalLsa externalLsa = (ExternalLsa) ospfLsa;
- bodyLst.addAll(Bytes.asList(externalLsa.asBytes()));
- break;
- default:
- log.debug("LSUpdate::getLsuBodyAsByteArray::UnKnown ospfLsa: {}", ospfLsa);
- break;
- }
- }
-
- } catch (Exception e) {
- log.debug("Error::getLsuBodyAsByteArray {}", e.getMessage());
- return Bytes.toArray(bodyLst);
- }
-
- return Bytes.toArray(bodyLst);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("noLsa", numberOfLsa)
- .add("lsaList", lsaList)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/package-info.java
deleted file mode 100644
index e5c55b0..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the OSPF Packet.
- */
-package org.onosproject.ospf.protocol.ospfpacket.types;
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/package-info.java
deleted file mode 100644
index 6ff02a9..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the OSPF protocol..
- */
-package org.onosproject.ospf.protocol;
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java
deleted file mode 100644
index bddb853..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.util;
-
-import org.onosproject.ospf.controller.OspfLsa;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.exceptions.OspfParseException;
-import org.onosproject.ospf.protocol.lsa.types.AsbrSummaryLsa;
-import org.onosproject.ospf.protocol.lsa.types.ExternalLsa;
-import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa11;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa9;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.lsa.types.SummaryLsa;
-import org.onosproject.ospf.controller.OspfMessage;
-import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
-import org.slf4j.Logger;
-
-import java.util.Arrays;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Calculates checksum for different types of OSPF packets.
- */
-public class ChecksumCalculator {
-
- private static final Logger log = getLogger(ChecksumCalculator.class);
-
- /**
- * Converts given string to sixteen bits integer.
- * If hexasum is more than 16 bit value, needs to be reduced to 16 bit value.
- *
- * @param strToConvert hexasum value to convert
- * @return 16 bit integer value
- */
- public static int convertToSixteenBits(String strToConvert) {
- StringBuilder sb = new StringBuilder(strToConvert);
- sb = sb.reverse();
- StringBuilder s1 = new StringBuilder(sb.substring(0, 4));
- s1 = s1.reverse();
- StringBuilder s2 = new StringBuilder(sb.substring(4, sb.length()));
- s2 = s2.reverse();
- int num = Integer.parseInt(s1.toString(), 16) + Integer.parseInt(s2.toString(), 16);
- return num;
- }
-
- /**
- * Checks whether checksum is valid or not in the given OSPF message.
- *
- * @param ospfMessage ospf message instance
- * @param checksumPos1 position of checksum bit in packet
- * @param checksumPos2 position of checksum bit in packet
- * @return true if valid else false
- */
- public boolean isValidOspfCheckSum(OspfMessage ospfMessage, int checksumPos1, int checksumPos2) {
-
- switch (ospfMessage.ospfMessageType().value()) {
- case OspfParameters.HELLO:
- ospfMessage = (HelloPacket) ospfMessage;
- break;
- case OspfParameters.DD:
- ospfMessage = (DdPacket) ospfMessage;
- break;
- case OspfParameters.LSREQUEST:
- ospfMessage = (LsRequest) ospfMessage;
- break;
- case OspfParameters.LSUPDATE:
- ospfMessage = (LsUpdate) ospfMessage;
- break;
- case OspfParameters.LSACK:
- ospfMessage = (LsAcknowledge) ospfMessage;
- break;
- default:
- break;
- }
-
- byte[] messageAsBytes = ospfMessage.asBytes();
- return validateOspfCheckSum(messageAsBytes, checksumPos1, checksumPos2);
- }
-
- /**
- * Checks whether checksum is valid or not in the given OSPF LSA.
- *
- * @param ospfLsa lsa instance
- * @param lsType lsa type
- * @param lsaChecksumPos1 lsa checksum position in packet
- * @param lsaChecksumPos2 lsa checksum position in packet
- * @throws OspfParseException if packet can't be parsed
- * @return true if valid else false
- */
- public boolean isValidLsaCheckSum(OspfLsa ospfLsa, int lsType, int lsaChecksumPos1,
- int lsaChecksumPos2) throws OspfParseException {
-
- if (lsType == OspfLsaType.ROUTER.value()) {
- RouterLsa lsa = (RouterLsa) ospfLsa;
- return validateLsaCheckSum(lsa.asBytes(), lsaChecksumPos1, lsaChecksumPos2);
- } else if (lsType == OspfLsaType.NETWORK.value()) {
- NetworkLsa lsa = (NetworkLsa) ospfLsa;
- return validateLsaCheckSum(lsa.asBytes(), lsaChecksumPos1, lsaChecksumPos2);
- } else if (lsType == OspfLsaType.SUMMARY.value()) {
- SummaryLsa lsa = (SummaryLsa) ospfLsa;
- return validateLsaCheckSum(lsa.asBytes(), lsaChecksumPos1, lsaChecksumPos2);
- } else if (lsType == OspfLsaType.ASBR_SUMMARY.value()) {
- AsbrSummaryLsa lsa = (AsbrSummaryLsa) ospfLsa;
- return validateLsaCheckSum(lsa.asBytes(), lsaChecksumPos1, lsaChecksumPos2);
- } else if (lsType == OspfLsaType.EXTERNAL_LSA.value()) {
- ExternalLsa lsa = (ExternalLsa) ospfLsa;
- return validateLsaCheckSum(lsa.asBytes(), lsaChecksumPos1, lsaChecksumPos2);
- } else if (lsType == OspfLsaType.LINK_LOCAL_OPAQUE_LSA.value()) {
- OpaqueLsa9 lsa = (OpaqueLsa9) ospfLsa;
- return validateLsaCheckSum(lsa.asBytes(), lsaChecksumPos1, lsaChecksumPos2);
- } else if (lsType == OspfLsaType.AREA_LOCAL_OPAQUE_LSA.value()) {
- OpaqueLsa10 lsa = (OpaqueLsa10) ospfLsa;
- return validateLsaCheckSum(lsa.asBytes(), lsaChecksumPos1, lsaChecksumPos2);
- } else if (lsType == OspfLsaType.AS_OPAQUE_LSA.value()) {
- OpaqueLsa11 lsa = (OpaqueLsa11) ospfLsa;
- return validateLsaCheckSum(lsa.asBytes(), lsaChecksumPos1, lsaChecksumPos2);
- }
-
-
- return false;
- }
-
- /**
- * Verifies the checksum is valid in given LSA packet bytes.
- *
- * @param lsaPacket lsa as byte array
- * @param lsaChecksumPos1 position of checksum bit in packet
- * @param lsaChecksumPos2 position of checksum bit in packet
- * @return true if valid else false
- */
- public boolean validateLsaCheckSum(byte[] lsaPacket, int lsaChecksumPos1, int lsaChecksumPos2) {
-
- byte[] checksum = calculateLsaChecksum(lsaPacket, lsaChecksumPos1, lsaChecksumPos2);
-
- if (lsaPacket[lsaChecksumPos1] == checksum[0] && lsaPacket[lsaChecksumPos2] == checksum[1]) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Verifies the checksum is valid in given OSPF packet bytes.
- *
- * @param ospfPacket as byte array
- * @param checksumPos1 position of checksum bit in packet
- * @param checksumPos2 position of checksum bit in packet
- * @return true if valid else false
- */
- public boolean validateOspfCheckSum(byte[] ospfPacket, int checksumPos1, int checksumPos2) {
-
- byte[] checkSum = calculateOspfCheckSum(ospfPacket, checksumPos1, checksumPos2);
-
- if (ospfPacket[checksumPos1] == checkSum[0] && ospfPacket[checksumPos2] == checkSum[1]) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Calculates the LSA checksum.
- *
- * @param lsaBytes as byte array
- * @param lsaChecksumPos1 position of checksum bit in packet
- * @param lsaChecksumPos2 position of checksum bit in packet
- * @return checksum bytes
- */
- public byte[] calculateLsaChecksum(byte[] lsaBytes, int lsaChecksumPos1, int lsaChecksumPos2) {
-
- byte[] tempLsaByte = Arrays.copyOf(lsaBytes, lsaBytes.length);
-
- int[] checksumOut = {0, 0};
- tempLsaByte[lsaChecksumPos1] = 0;
- tempLsaByte[lsaChecksumPos2] = 0;
- byte[] byteCheckSum = {0, 0};
- for (int i = 2; i < tempLsaByte.length; i++) {
- checksumOut[0] = checksumOut[0] + ((int) tempLsaByte[i] & 0xFF);
- checksumOut[1] = checksumOut[1] + checksumOut[0];
- }
- checksumOut[0] = checksumOut[0] % 255;
- checksumOut[1] = checksumOut[1] % 255;
- int byte1 = (int) ((tempLsaByte.length - lsaChecksumPos1 - 1) * checksumOut[0] - checksumOut[1]) % 255;
- if (byte1 <= 0) {
- byte1 += 255;
- }
- int byte2 = 510 - checksumOut[0] - byte1;
- if (byte2 > 255) {
- byte2 -= 255;
- }
-
- byteCheckSum[0] = (byte) byte1;
- byteCheckSum[1] = (byte) byte2;
-
- return byteCheckSum;
- }
-
- /**
- * Calculate checksum from hexasum.
- *
- * @param hexasum total of 16 bits hexadecimal values
- * @return checksum value
- */
- private int calculateChecksum(int hexasum) {
-
- char[] tempZeros = {'0', '0', '0', '0'};
- StringBuffer hexaAsBinaryStr = new StringBuffer(Integer.toBinaryString(hexasum));
- int length = hexaAsBinaryStr.length();
- while (length > 16) {
- if (hexaAsBinaryStr.length() % 4 != 0) {
- int offset = hexaAsBinaryStr.length() % 4;
- hexaAsBinaryStr.insert(0, tempZeros, 0, 4 - offset);
- }
- StringBuffer hexaStr1 = new StringBuffer(hexaAsBinaryStr.reverse().substring(0, 16));
- String revHexaStr1 = hexaStr1.reverse().toString();
- StringBuffer hexaStr2 = new StringBuffer(hexaAsBinaryStr.reverse());
- StringBuffer hexaStr3 = new StringBuffer(hexaStr2.reverse().substring(16, hexaStr2.length()));
- String revHexaStr3 = hexaStr3.reverse().toString();
- int lastSixteenHexaBits = Integer.parseInt(revHexaStr1, 2);
- int remainingHexaBits = Integer.parseInt(revHexaStr3, 2);
- int totalCheckSum = lastSixteenHexaBits + remainingHexaBits;
- hexaAsBinaryStr = new StringBuffer(Integer.toBinaryString(totalCheckSum));
- length = hexaAsBinaryStr.length();
- }
- if (hexaAsBinaryStr.length() < 16) {
- int count = 16 - hexaAsBinaryStr.length();
- String s = hexaAsBinaryStr.toString();
- for (int i = 0; i < count; i++) {
- s = "0" + s;
- }
-
- hexaAsBinaryStr = new StringBuffer(s);
-
- }
- StringBuffer checksum = negate(hexaAsBinaryStr);
- return Integer.parseInt(checksum.toString(), 2);
- }
-
- /**
- * Negates given hexasum.
- *
- * @param binaryString binary form of hexasum
- * @return binary from of calculateChecksum
- */
- private StringBuffer negate(StringBuffer binaryString) {
- for (int i = 0; i < binaryString.length(); i++) {
- if (binaryString.charAt(i) == '1') {
- binaryString.replace(i, i + 1, "0");
- } else {
- binaryString.replace(i, i + 1, "1");
- }
- }
-
- return binaryString;
- }
-
- /**
- * Calculates the OSPF checksum for the given packet.
- *
- * @param packet as byte array
- * @param checksumPos1 position of checksum bit in packet
- * @param checksumPos2 position of checksum bit in packet
- * @return checksum bytes
- */
- public byte[] calculateOspfCheckSum(byte[] packet, int checksumPos1, int checksumPos2) {
-
- int hexasum = 0;
- for (int i = 0; i < packet.length; i = i + 2) {
- if (i != 12) {
- byte b1 = packet[i];
- String s1 = String.format("%8s", Integer.toBinaryString(b1 & 0xFF)).replace(' ', '0');
- b1 = packet[i + 1];
- String s2 = String.format("%8s", Integer.toBinaryString(b1 & 0xFF)).replace(' ', '0');
- String hexa = s1 + s2;
- int num1 = Integer.parseInt(hexa, 2);
- hexasum = hexasum + num1;
- String convertTo16 = Integer.toHexString(hexasum);
- if (convertTo16.length() > 4) {
- hexasum = convertToSixteenBits(convertTo16);
- }
- }
- }
- StringBuilder sb = new StringBuilder(Integer.toHexString(hexasum));
- if (sb.length() > 4) {
- sb = sb.reverse();
- StringBuilder s1 = new StringBuilder(sb.substring(0, 4));
- s1 = s1.reverse();
- StringBuilder s2 = new StringBuilder(sb.substring(4, sb.length()));
- s2 = s2.reverse();
- hexasum = Integer.parseInt(s1.toString(), 16) + Integer.parseInt(s2.toString(), 16);
- }
- int finalChecksum = calculateChecksum(hexasum);
- return OspfUtil.convertToTwoBytes(finalChecksum);
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfInterfaceState.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfInterfaceState.java
deleted file mode 100644
index 794dc24..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfInterfaceState.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.util;
-
-/**
- * Representation of an OSPF Interface states.
- */
-public enum OspfInterfaceState {
-
- DOWN(1),
- LOOPBACK(2),
- WAITING(3),
- POINT2POINT(4),
- DROTHER(5),
- BDR(6),
- DR(7);
-
- private int value;
-
- /**
- * Creates an instance of interface state.
- *
- * @param value Interface state value
- */
- OspfInterfaceState(int value) {
- this.value = value;
- }
-
- /**
- * Gets value for Interface state.
- *
- * @return value Interface state
- */
- public int value() {
- return value;
- }
-
- /**
- * Gets interface state.
- *
- * @return interface state
- */
- public String interfaceState() {
- String state = null;
- switch (value) {
- case 1:
- state = "DOWN";
- break;
- case 2:
- state = "LOOPBACK";
- break;
- case 3:
- state = "WAITING";
- break;
- case 4:
- state = "POINT2POINT";
- break;
- case 5:
- state = "DROTHER";
- break;
- case 6:
- state = "BDR";
- break;
- case 7:
- state = "DR";
- break;
- default:
- break;
- }
- return state;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfParameters.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfParameters.java
deleted file mode 100644
index c8c3382..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfParameters.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.util;
-
-/**
- * Representation of an OSPF configuration parameters and constants.
- */
-public final class OspfParameters {
-
- public static final int LSREFRESHTIME = 1800; //max time between updates;
- public static final int MINLSINTERVAL = 5; // set to 5 second
- public static final int MINLSARRIVAL = 1; // set to 1 second
- public static final int MAXAGE = 3600; // set to 1 hour in seconds
- public static final int CHECKAGE = 300; // set to 5 mins
- public static final int MAXAGEDIFF = 900; // set to 15 mins
- public static final long MAXSEQUENCENUMBER = 2147483647;
- public static final long STARTLSSEQUENCENUM = -2147483647;
- public static final int AGECOUNTER = 1;
- public static final String VERIFYCHECKSUM = "verifyChecksum";
- public static final String REFRESHLSA = "refreshLsa";
- public static final String MAXAGELSA = "maxAgeLsa";
- public static final int START_NOW = 0;
- public static final int TRAFFIC_ENGINEERING = 1;
- public static final int INITIAL_BANDWIDTH = 12500000;
- public static final int ROUTER = 1;
- public static final int NETWORK = 2;
- public static final int SUMMARY = 3;
- public static final int ASBR_SUMMARY = 4;
- public static final int EXTERNAL_LSA = 5;
- public static final int LINK_LOCAL_OPAQUE_LSA = 9;
- public static final int AREA_LOCAL_OPAQUE_LSA = 10;
- public static final int AS_OPAQUE_LSA = 11;
- public static final int HELLO = 1;
- public static final int DD = 2;
- public static final int LSREQUEST = 3;
- public static final int LSUPDATE = 4;
- public static final int LSACK = 5;
- public static final int INFTRA_NS_DELAY = 1;
- public static final int BDR = 6;
- public static final int DR = 7;
- public static final String OPAQUE_ENABLED_OPTION_VALUE = "01000010";
-
- private OspfParameters() {
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java
deleted file mode 100644
index 182b827..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.util;
-
-import com.google.common.primitives.Bytes;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.xml.bind.DatatypeConverter;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.security.SecureRandom;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
-import java.util.StringTokenizer;
-
-/**
- * Representation of an OSPF constants and utility methods.
- */
-public final class OspfUtil {
- public static final int OSPF_VERSION_2 = 2;
- public static final int OSPF_VERSION = OSPF_VERSION_2;
- public static final int PACKET_MINIMUM_LENGTH = 24;
- public static final int METADATA_LEN = 5;
- public static final int MINIMUM_FRAME_LEN = 1487;
- public static final int OSPF_HEADER_LENGTH = 24;
- public static final int LSA_HEADER_LENGTH = 20;
- public static final int DD_HEADER_LENGTH = OSPF_HEADER_LENGTH + 8;
- public static final int LSREQUEST_LENGTH = 12;
- public static final int OSPFPACKET_LENGTH_POS1 = 2;
- public static final int OSPFPACKET_LENGTH_POS2 = 3;
- public static final int OSPFPACKET_CHECKSUM_POS1 = 12;
- public static final int OSPFPACKET_CHECKSUM_POS2 = 13;
- public static final int LSAPACKET_CHECKSUM_POS1 = 16;
- public static final int LSAPACKET_CHECKSUM_POS2 = 17;
- public static final Ip4Address ALL_SPF_ROUTERS = Ip4Address.valueOf("224.0.0.5");
- public static final Ip4Address ALL_DROUTERS = Ip4Address.valueOf("224.0.0.6");
- public static final Ip4Address DEFAULTIP = Ip4Address.valueOf("0.0.0.0");
- public static final int RETRANSMITINTERVAL = 5;
- public static final int ONLY_ALL_SPF_ROUTERS = 1;
- public static final int JOIN_ALL_DROUTERS = 2;
- public static final int INITIALIZE_SET = 1;
- public static final int INITIALIZE_NOTSET = 0;
- public static final int MORE_SET = 1;
- public static final int MORE_NOTSET = 0;
- public static final int IS_MASTER = 1;
- public static final int NOT_MASTER = 0;
- public static final int NOT_ASSIGNED = 0;
- public static final int FOUR_BYTES = 4;
- public static final int FIVE_BYTES = 5;
- public static final int EIGHT_BYTES = 8;
- public static final int TWELVE_BYTES = 12;
- public static final int EXTERNAL_DESTINATION_LENGTH = 12;
- public static final String SHOST = "127.0.0.1";
- public static final int SPORT = 7000;
- public static final int MTU = 1500;
- public static final char CONFIG_LENGTH = 1498;
- public static final char ROUTER_PRIORITY = 0;
- public static final int HELLO_PACKET_OPTIONS = 2;
- private static final Logger log =
- LoggerFactory.getLogger(OspfUtil.class);
-
- /**
- * Creates an instance.
- */
- private OspfUtil() {
-
- }
-
- /**
- * Checks given IPs are in same network or not.
- *
- * @param ip1 IP address
- * @param ip2 IP address
- * @param mask network mask
- * @return true if both are in same network else false
- */
- public static boolean sameNetwork(Ip4Address ip1, Ip4Address ip2, Ip4Address mask) {
-
- byte[] a1 = ip1.toOctets();
- byte[] a2 = ip2.toOctets();
- byte[] m = mask.toOctets();
-
- for (int i = 0; i < a1.length; i++) {
- if ((a1[i] & m[i]) != (a2[i] & m[i])) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Converts IP address to long.
- *
- * @param ipAddress IP address
- * @return long value represents IP address
- */
- public static long ipAddressToLong(String ipAddress) {
- StringTokenizer st = new StringTokenizer(ipAddress, ".");
- long ipAsNumber = Long.parseLong(st.nextToken()) * (long) Math.pow(256, 3);
- ipAsNumber += Long.parseLong(st.nextToken()) * (long) Math.pow(256, 2);
- ipAsNumber += Long.parseLong(st.nextToken()) * 256;
- ipAsNumber += +Long.parseLong(st.nextToken());
-
- return ipAsNumber;
- }
-
- /**
- * Checks option field to see whether opaque enabled or not.
- * 2nd Bit in options field of DdPacket represents Opaque.
- * 7th bit is external capability.
- * This method checks Opaque bit is set in the options or not.
- *
- * @param options options value
- * @return true if opaque enabled else false.
- */
- public static boolean isOpaqueEnabled(int options) {
- Boolean[] bits = new Boolean[8];
- for (int i = 7; i >= 0; i--) {
- bits[i] = (options & (1 << i)) != 0;
- }
-
- List<Boolean> list = Arrays.asList(bits);
- Collections.reverse(list);
-
- //2nd bit is Opaque.
- return list.get(1);
- }
-
- /**
- * Converts a byte to integer variable.
- *
- * @param bytesToConvert bytes to convert
- * @return integer representation of bytes
- */
- public static int byteToInteger(byte[] bytesToConvert) {
- final StringBuilder builder = new StringBuilder();
- for (byte eachByte : bytesToConvert) {
- builder.append(String.format("%02x", eachByte));
- }
- int num = Integer.parseInt(builder.toString(), 16);
- return num;
- }
-
- /**
- * Converts a byte to long variable.
- *
- * @param bytesToConvert bytes to convert
- * @return long representation of bytes
- */
- public static long byteToLong(byte[] bytesToConvert) {
- final StringBuilder builder = new StringBuilder();
- for (byte eachByte : bytesToConvert) {
- builder.append(String.format("%02x", eachByte));
- }
- long num = Long.parseLong(builder.toString(), 16);
- return num;
- }
-
- /**
- * Creates a random number.
- *
- * @return random number
- */
- public static int createRandomNumber() {
- Random rnd = new SecureRandom();
- int randomNumber = 10000000 + rnd.nextInt(90000000);
- return randomNumber;
- }
-
- /**
- * Reads the LSA header from channel buffer.
- *
- * @param channelBuffer channel buffer instance
- * @return LSA header instance.
- */
- public static LsaHeader readLsaHeader(ChannelBuffer channelBuffer) {
- //add all the LSA Headers - one header is of 20 bytes
- LsaHeader lsaHeader = null;
- if (channelBuffer.readableBytes() >= OspfUtil.LSA_HEADER_LENGTH) {
- byte[] byteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(byteArray, 0, OspfUtil.FOUR_BYTES);
- ChannelBuffer tempBuffer = ChannelBuffers.copiedBuffer(byteArray);
- int lsType = byteArray[3];
- if (lsType == OspfParameters.AREA_LOCAL_OPAQUE_LSA || lsType == OspfParameters.LINK_LOCAL_OPAQUE_LSA
- || lsType == OspfParameters.AS_OPAQUE_LSA) {
- OpaqueLsaHeader header = new OpaqueLsaHeader();
- header.setAge(tempBuffer.readShort());
- header.setOptions(tempBuffer.readByte());
- header.setLsType(tempBuffer.readByte());
- header.setOpaqueType(channelBuffer.readByte());
- header.setOpaqueId(channelBuffer.readUnsignedMedium());
- byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- header.setAdvertisingRouter(Ip4Address.valueOf(tempByteArray));
- header.setLsSequenceNo(channelBuffer.readInt());
- header.setLsCheckSum(channelBuffer.readUnsignedShort());
- header.setLsPacketLen(channelBuffer.readShort());
- byte[] opaqueIdBytes = OspfUtil.convertToTwoBytes(header.opaqueId());
- header.setLinkStateId(header.opaqueType() + "." + "0" + "." +
- opaqueIdBytes[0] + "." + opaqueIdBytes[1]);
- lsaHeader = header;
- } else {
- LsaHeader header = new LsaHeader();
- header.setAge(tempBuffer.readShort());
- header.setOptions(tempBuffer.readByte());
- header.setLsType(tempBuffer.readByte());
- byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- try {
- header.setLinkStateId(InetAddress.getByAddress(tempByteArray).getHostName());
- } catch (UnknownHostException uhe) {
- log.warn("Can't look up host", uhe);
- }
- tempByteArray = new byte[OspfUtil.FOUR_BYTES];
- channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
- header.setAdvertisingRouter(Ip4Address.valueOf(tempByteArray));
- header.setLsSequenceNo(channelBuffer.readInt());
- header.setLsCheckSum(channelBuffer.readUnsignedShort());
- header.setLsPacketLen(channelBuffer.readShort());
- lsaHeader = header;
- }
- }
- return lsaHeader;
- }
-
-
- /**
- * Converts an integer to two bytes.
- *
- * @param numberToConvert number to convert
- * @return given number as bytes
- */
- public static byte[] convertToTwoBytes(int numberToConvert) {
-
- byte[] numInBytes = new byte[2];
- String s1 = Integer.toHexString(numberToConvert);
- if (s1.length() % 2 != 0) {
- s1 = "0" + s1;
- }
- byte[] hexas = DatatypeConverter.parseHexBinary(s1);
- if (hexas.length == 1) {
- numInBytes[0] = 0;
- numInBytes[1] = hexas[0];
- } else {
- numInBytes[0] = hexas[0];
- numInBytes[1] = hexas[1];
- }
- return numInBytes;
- }
-
- /**
- * Converts a number to three bytes.
- *
- * @param numberToConvert number to convert
- * @return given number as bytes
- */
- public static byte[] convertToThreeBytes(int numberToConvert) {
- byte[] numInBytes = new byte[3];
- String s1 = Integer.toHexString(numberToConvert);
- if (s1.length() % 2 != 0) {
- s1 = "0" + s1;
- }
- byte[] hexas = DatatypeConverter.parseHexBinary(s1);
- if (hexas.length == 1) {
- numInBytes[0] = 0;
- numInBytes[1] = 0;
- numInBytes[2] = hexas[0];
- } else if (hexas.length == 2) {
- numInBytes[0] = 0;
- numInBytes[1] = hexas[0];
- numInBytes[2] = hexas[1];
- } else {
- numInBytes[0] = hexas[0];
- numInBytes[1] = hexas[1];
- numInBytes[2] = hexas[2];
- }
- return numInBytes;
- }
-
- /**
- * Converts a number to four bytes.
- *
- * @param numberToConvert number to convert
- * @return given number as bytes
- */
- public static byte[] convertToFourBytes(int numberToConvert) {
-
- byte[] numInBytes = new byte[4];
- String s1 = Integer.toHexString(numberToConvert);
- if (s1.length() % 2 != 0) {
- s1 = "0" + s1;
- }
- byte[] hexas = DatatypeConverter.parseHexBinary(s1);
- if (hexas.length == 1) {
- numInBytes[0] = 0;
- numInBytes[1] = 0;
- numInBytes[2] = 0;
- numInBytes[3] = hexas[0];
- } else if (hexas.length == 2) {
- numInBytes[0] = 0;
- numInBytes[1] = 0;
- numInBytes[2] = hexas[0];
- numInBytes[3] = hexas[1];
- } else if (hexas.length == 3) {
- numInBytes[0] = 0;
- numInBytes[1] = hexas[0];
- numInBytes[2] = hexas[1];
- numInBytes[3] = hexas[2];
- } else {
- numInBytes[0] = hexas[0];
- numInBytes[1] = hexas[1];
- numInBytes[2] = hexas[2];
- numInBytes[3] = hexas[3];
- }
- return numInBytes;
- }
-
- /**
- * Converts a number to four bytes.
- *
- * @param numberToConvert number to convert
- * @return given number as bytes
- */
- public static byte[] convertToFourBytes(long numberToConvert) {
-
- byte[] numInBytes = new byte[4];
- String s1 = Long.toHexString(numberToConvert);
- if (s1.length() % 2 != 0) {
- s1 = "0" + s1;
- }
- if (s1.length() == 16) {
- s1 = s1.substring(8, s1.length());
- }
- byte[] hexas = DatatypeConverter.parseHexBinary(s1);
- if (hexas.length == 1) {
- numInBytes[0] = 0;
- numInBytes[1] = 0;
- numInBytes[2] = 0;
- numInBytes[3] = hexas[0];
- } else if (hexas.length == 2) {
- numInBytes[0] = 0;
- numInBytes[1] = 0;
- numInBytes[2] = hexas[0];
- numInBytes[3] = hexas[1];
- } else if (hexas.length == 3) {
- numInBytes[0] = 0;
- numInBytes[1] = hexas[0];
- numInBytes[2] = hexas[1];
- numInBytes[3] = hexas[2];
- } else {
- numInBytes[0] = hexas[0];
- numInBytes[1] = hexas[1];
- numInBytes[2] = hexas[2];
- numInBytes[3] = hexas[3];
- }
- return numInBytes;
- }
-
- /**
- * Adds the checksum and length in packet.
- *
- * @param ospfPacket ospf packet
- * @param lengthBytePos1 length byte position
- * @param lengthBytePos2 length byte position
- * @param checksumBytePos1 checksum byte position
- * @param checksumBytePos2 checksum byte position
- * @return byte array with checksum and length
- */
- public static byte[] addLengthAndCheckSum(byte[] ospfPacket, int lengthBytePos1, int lengthBytePos2,
- int checksumBytePos1, int checksumBytePos2) {
- //Set the length of the packet
- //Get the total length of the packet
- int length = ospfPacket.length;
- //Convert the lenth to two bytes as the length field is 2 bytes
- byte[] lenthInTwoBytes = OspfUtil.convertToTwoBytes(length);
- //ospf header 3rd and 4th position represents length
- ospfPacket[lengthBytePos1] = lenthInTwoBytes[0]; //assign 1st byte in lengthBytePos1
- ospfPacket[lengthBytePos2] = lenthInTwoBytes[1]; //assign 2st byte in lengthBytePos2
-
- //Get the checksum as two bytes.
- byte[] checkSumInTwoBytes = new ChecksumCalculator().calculateOspfCheckSum(ospfPacket,
- checksumBytePos1, checksumBytePos2);
- ospfPacket[checksumBytePos1] = checkSumInTwoBytes[0]; //assign 1st byte in checksumBytePos1
- ospfPacket[checksumBytePos2] = checkSumInTwoBytes[1]; //assign 2st byte in checksumBytePos2
-
- return ospfPacket;
- }
-
- /**
- * Adds metadata to ospf packet like whether to join multi cast group and destination IP.
- *
- * @param interfaceIndex interface index
- * @param ospfPacket OSPF packet
- * @param allDroutersValue whether to join multi cast or not
- * @param destinationIp destination ip address
- * @return byte array
- */
- public static byte[] addMetadata(int interfaceIndex, byte[] ospfPacket, int allDroutersValue,
- Ip4Address destinationIp) {
- byte[] packet;
- byte[] interfaceIndexByteVal = {(byte) interfaceIndex};
- byte[] allDroutersByteVal = {(byte) allDroutersValue};
- byte[] destIpAsBytes = destinationIp.toOctets();
- byte[] metadata = Bytes.concat(interfaceIndexByteVal, allDroutersByteVal);
- metadata = Bytes.concat(metadata, destIpAsBytes);
- packet = Bytes.concat(ospfPacket, metadata);
-
- return packet;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/package-info.java
deleted file mode 100644
index 28c19e0..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the ospf protocol utilities.
- */
-package org.onosproject.ospf.protocol.util;
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/LsaHeaderTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/LsaHeaderTest.java
deleted file mode 100644
index 065a2dfa..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/LsaHeaderTest.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfLsaType;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
-
-/**
- * Unit test class for LsaHeader.
- */
-public class LsaHeaderTest {
-
- private LsaHeader lsaHeader;
- private int result;
- private Ip4Address result1;
- private long result2;
- private OspfLsaType ospflsaType;
- private LsaHeader header;
- private byte[] result3;
- private LsaHeader lsaHeader1;
- private String result4;
-
- @Before
- public void setUp() throws Exception {
- lsaHeader = new LsaHeader();
- }
-
- @After
- public void tearDown() throws Exception {
- lsaHeader = null;
- result1 = null;
- ospflsaType = null;
- header = null;
- result3 = null;
- lsaHeader1 = null;
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEquals() throws Exception {
- assertThat(lsaHeader.equals(new LsaHeader()), is(true));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- result = lsaHeader.hashCode();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests age() getter method.
- */
- @Test
- public void testGetAge() throws Exception {
- lsaHeader.setAge(10);
- result = lsaHeader.age();
- assertThat(result, is(10));
- }
-
- /**
- * Tests age() setter method.
- */
- @Test
- public void testSetAge() throws Exception {
- lsaHeader.setAge(10);
- result = lsaHeader.age();
- assertThat(result, is(10));
- }
-
- /**
- * Tests options() getter method.
- */
- @Test
- public void testGetOptions() throws Exception {
- lsaHeader.setOptions(2);
- result = lsaHeader.options();
- assertThat(result, is(2));
- }
-
- /**
- * Tests options() setter method.
- */
- @Test
- public void testSetOptions() throws Exception {
- lsaHeader.setOptions(2);
- result = lsaHeader.options();
- assertThat(result, is(2));
- }
-
- /**
- * Tests lsType() getter method.
- */
- @Test
- public void testGetLsType() throws Exception {
- lsaHeader.setLsType(1);
- result = lsaHeader.lsType();
- assertThat(result, is(1));
- }
-
- /**
- * Tests lsType() setter method.
- */
- @Test
- public void testSetLsType() throws Exception {
- lsaHeader.setLsType(1);
- result = lsaHeader.lsType();
- assertThat(result, is(1));
- }
-
- /**
- * Tests linkStateId() getter method.
- */
- @Test
- public void testGetLinkStateId() throws Exception {
- lsaHeader.setLinkStateId("10.226.165.164");
- result4 = lsaHeader.linkStateId();
- assertThat(result4, is("10.226.165.164"));
- }
-
- /**
- * Tests linkStateId() setter method.
- */
- @Test
- public void testSetLinkStateId() throws Exception {
- lsaHeader.setLinkStateId("10.226.165.164");
- result4 = lsaHeader.linkStateId();
- assertThat(result4, is("10.226.165.164"));
- }
-
- /**
- * Tests advertisingRouter() setter method.
- */
- @Test
- public void testGetAdvertisingRouter() throws Exception {
- lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("10.226.165.164"));
- result1 = lsaHeader.advertisingRouter();
- assertThat(result1, is(Ip4Address.valueOf("10.226.165.164")));
- }
-
- /**
- * Tests advertisingRouter() setter method.
- */
- @Test
- public void testSetAdvertisingRouter() throws Exception {
- lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("10.226.165.164"));
- result1 = lsaHeader.advertisingRouter();
- assertThat(result1, is(Ip4Address.valueOf("10.226.165.164")));
- }
-
- /**
- * Tests lsSequenceNo() getter method.
- */
- @Test
- public void testGetLsSequenceNo() throws Exception {
- lsaHeader.setLsSequenceNo(222);
- result2 = lsaHeader.lsSequenceNo();
- assertThat(result2, is(222L));
- }
-
- /**
- * Tests lsSequenceNo() setter method.
- */
- @Test
- public void testSetLsSequenceNo() throws Exception {
- lsaHeader.setLsSequenceNo(222);
- result2 = lsaHeader.lsSequenceNo();
- assertThat(result2, is(222L));
- }
-
- /**
- * Tests lsCheckSum() getter method.
- */
- @Test
- public void testGetLsChecksum() throws Exception {
- lsaHeader.setLsCheckSum(2);
- result = lsaHeader.lsCheckSum();
- assertThat(result, is(2));
- }
-
- /**
- * Tests lsCheckSum() setter method.
- */
- @Test
- public void testSetLsChecksum() throws Exception {
- lsaHeader.setLsCheckSum(2);
- result = lsaHeader.lsCheckSum();
- assertThat(result, is(2));
- }
-
- /**
- * Tests lsPacketLen() getter method.
- */
- @Test
- public void testGetLsPacketLen() throws Exception {
- lsaHeader.setLsPacketLen(48);
- result = lsaHeader.lsPacketLen();
- assertThat(result, is(48));
- }
-
- /**
- * Tests lsPacketLen() getter method.
- */
- @Test
- public void testSetLsPacketLen() throws Exception {
- lsaHeader.setLsPacketLen(48);
- result = lsaHeader.lsPacketLen();
- assertThat(result, is(48));
- }
-
- /**
- * Tests getOspfLsaType() getter method.
- */
- @Test
- public void testGetOspfLsaType() throws Exception {
- lsaHeader.setLsType(1);
- ospflsaType = lsaHeader.getOspfLsaType();
- assertThat(ospflsaType, is(notNullValue()));
- assertThat(ospflsaType, is(OspfLsaType.ROUTER));
- lsaHeader.setLsType(2);
- ospflsaType = lsaHeader.getOspfLsaType();
- assertThat(ospflsaType, is(notNullValue()));
- assertThat(ospflsaType, is(OspfLsaType.NETWORK));
- lsaHeader.setLsType(3);
- ospflsaType = lsaHeader.getOspfLsaType();
- assertThat(ospflsaType, is(notNullValue()));
- assertThat(ospflsaType, is(OspfLsaType.SUMMARY));
- lsaHeader.setLsType(4);
- ospflsaType = lsaHeader.getOspfLsaType();
- assertThat(ospflsaType, is(notNullValue()));
- assertThat(ospflsaType, is(OspfLsaType.ASBR_SUMMARY));
- lsaHeader.setLsType(5);
- ospflsaType = lsaHeader.getOspfLsaType();
- assertThat(ospflsaType, is(notNullValue()));
- assertThat(ospflsaType, is(OspfLsaType.EXTERNAL_LSA));
- lsaHeader.setLsType(6);
- ospflsaType = lsaHeader.getOspfLsaType();
- assertThat(ospflsaType, is(notNullValue()));
- assertThat(ospflsaType, is(OspfLsaType.UNDEFINED));
- }
-
- /**
- * Tests lsaHeader() getter method.
- */
- @Test
- public void testGetLsaHeader() throws Exception {
- header = (LsaHeader) lsaHeader.lsaHeader();
- assertThat(header, instanceOf(LsaHeader.class));
- }
-
- /**
- * Tests getLsaHeaderAsByteArray() method.
- */
- @Test
- public void testGetLsaHeaderAsByteArray() throws Exception {
- result3 = lsaHeader.getLsaHeaderAsByteArray();
- assertThat(result3, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(lsaHeader.toString(), is(notNullValue()));
- }
-
- /**
- * Tests populateHeader() method.
- */
- @Test
- public void testPopulateHeader() throws Exception {
- lsaHeader1 = new LsaHeader();
- lsaHeader1.setLsPacketLen(10);
- lsaHeader1.setAdvertisingRouter(Ip4Address.valueOf("1.1.1.1"));
- lsaHeader1.setOptions(2);
- lsaHeader1.setAge(20);
- lsaHeader1.setLsType(3);
- lsaHeader1.setLinkStateId("2.2.2.2");
- lsaHeader1.setLsCheckSum(1234);
- lsaHeader1.setLsSequenceNo(456789);
- lsaHeader.populateHeader(lsaHeader1);
- assertThat(lsaHeader1, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/OpaqueLsaHeaderTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/OpaqueLsaHeaderTest.java
deleted file mode 100644
index f439af4..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/OpaqueLsaHeaderTest.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa;
-
-import org.hamcrest.Matchers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for OpaqueLsaHeader.
- */
-public class OpaqueLsaHeaderTest {
-
- private OpaqueLsaHeader opaqueHeader;
- private OpaqueLsaHeader opaqueLsaHeader1;
- private int num;
- private byte[] result;
- private int result1;
-
- @Before
- public void setUp() throws Exception {
- opaqueHeader = new OpaqueLsaHeader();
- }
-
- @After
- public void tearDown() throws Exception {
- opaqueHeader = null;
- opaqueLsaHeader1 = null;
- result = null;
- }
-
- /**
- * Tests populateHeader() method.
- */
- @Test
- public void testPopulateHeader() throws Exception {
- opaqueLsaHeader1 = new OpaqueLsaHeader();
- opaqueLsaHeader1.setLsPacketLen(10);
- opaqueLsaHeader1.setAdvertisingRouter(Ip4Address.valueOf("1.1.1.1"));
- opaqueLsaHeader1.setOptions(2);
- opaqueLsaHeader1.setAge(20);
- opaqueLsaHeader1.setLsType(3);
- opaqueLsaHeader1.setOpaqueId(1);
- opaqueLsaHeader1.setOpaqueType(3);
- opaqueLsaHeader1.setLsCheckSum(1234);
- opaqueLsaHeader1.setLsSequenceNo(456789);
- opaqueLsaHeader1.populateHeader(opaqueLsaHeader1);
- assertThat(opaqueLsaHeader1, is(notNullValue()));
- }
-
- /**
- * Tests opaqueId() getter method.
- */
- @Test
- public void testGetOpaqueId() throws Exception {
- opaqueHeader.setOpaqueId(1);
- num = opaqueHeader.opaqueId();
- assertThat(num, is(1));
- }
-
- /**
- * Tests opaqueId() setter method.
- */
- @Test
- public void testSetOpaqueId() throws Exception {
- opaqueHeader.setOpaqueId(1);
- num = opaqueHeader.opaqueId();
- assertThat(num, is(1));
- }
-
- /**
- * Tests opaqueType() getter method.
- */
- @Test
- public void testGetOpaqueType() throws Exception {
- opaqueHeader.setOpaqueType(1);
- num = opaqueHeader.opaqueType();
- assertThat(num, is(1));
- }
-
- /**
- * Tests opaqueType() setter method.
- */
- @Test
- public void testSetOpaqueType() throws Exception {
- opaqueHeader.setOpaqueType(1);
- num = opaqueHeader.opaqueType();
- assertThat(num, is(1));
- }
-
- /**
- * Tests getOpaqueLsaHeaderAsByteArray() method.
- */
- @Test
- public void testGetOpaqueLsaHeaderAsByteArray() throws Exception {
- result = opaqueHeader.getOpaqueLsaHeaderAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(opaqueHeader.toString(), is(notNullValue()));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashcode() throws Exception {
-
- result1 = opaqueHeader.hashCode();
- assertThat(result1, is(Matchers.notNullValue()));
-
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/TlvHeaderTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/TlvHeaderTest.java
deleted file mode 100644
index 0b232c3..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/TlvHeaderTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for Tlv Header.
- */
-public class TlvHeaderTest {
-
- private TlvHeader tlvHeader;
- private byte[] result;
-
-
- @Before
- public void setUp() throws Exception {
- tlvHeader = new TlvHeader();
- }
-
- @After
- public void tearDown() throws Exception {
- tlvHeader = null;
- result = null;
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(tlvHeader.toString(), is(notNullValue()));
- }
-
- /**
- * Tests tlvLength() getter method.
- */
- @Test
- public void testGetTlvLength() throws Exception {
- tlvHeader.setTlvLength(2);
- assertThat(tlvHeader.tlvLength(), is(2));
- }
-
- /**
- * Tests tlvLength() setter method.
- */
- @Test
- public void testSetTlvLength() throws Exception {
- tlvHeader.setTlvLength(2);
- assertThat(tlvHeader.tlvLength(), is(2));
- }
-
- /**
- * Tests tlvType() getter method.
- */
- @Test
- public void testGetTlvType() throws Exception {
- tlvHeader.setTlvType(2);
- assertThat(tlvHeader.tlvType(), is(2));
- }
-
- /**
- * Tests tlvType() setter method.
- */
- @Test
- public void testSetTlvType() throws Exception {
- tlvHeader.setTlvType(2);
- assertThat(tlvHeader.tlvType(), is(2));
- }
-
- /**
- * Tests getTlvHeaderAsByteArray() method.
- */
- @Test
- public void testGetTlvHeaderAsByteArray() throws Exception {
- result = tlvHeader.getTlvHeaderAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/AdministrativeGroupTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/AdministrativeGroupTest.java
deleted file mode 100644
index 778588b..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/AdministrativeGroupTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for AdministrativeGroup.
- */
-public class AdministrativeGroupTest {
-
- private final byte[] packet = {0, 0, 0, 1};
- private AdministrativeGroup administrativeGroup;
- private ChannelBuffer channelBuffer;
- private TlvHeader tlvHeader;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- administrativeGroup = new AdministrativeGroup(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- administrativeGroup = null;
- channelBuffer = null;
- tlvHeader = null;
- }
-
- /**
- * Tests administrativeGroup() getter method.
- */
- @Test
- public void testGetAdministrativeGroup() throws Exception {
- administrativeGroup.setAdministrativeGroup(1);
- assertThat(administrativeGroup.administrativeGroup(), is(1));
- }
-
- /**
- * Tests administrativeGroup() setter method.
- */
- @Test
- public void testSetAdministrativeGroup() throws Exception {
- administrativeGroup.setAdministrativeGroup(1);
- assertThat(administrativeGroup.administrativeGroup(), is(1));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(9);
- tlvHeader.setTlvLength(4);
- administrativeGroup = new AdministrativeGroup(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- administrativeGroup.readFrom(channelBuffer);
- assertThat(administrativeGroup.administrativeGroup(), is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = administrativeGroup.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
-
- /**
- * Tests getLinkSubTypeTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
- result = administrativeGroup.getLinkSubTypeTlvBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(administrativeGroup.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkIdTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkIdTest.java
deleted file mode 100644
index 718492f..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkIdTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for LinkId.
- */
-public class LinkIdTest {
-
- private final byte[] packet = {1, 1, 1, 1};
- private final byte[] packet1 = {0, 0, 1};
- private LinkId linkId;
- private TlvHeader tlvHeader;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- linkId = new LinkId(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- linkId = null;
- channelBuffer = null;
- tlvHeader = null;
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(linkId.toString(), is(notNullValue()));
- }
-
- /**
- * Tests linkId() getter method.
- */
- @Test
- public void testGetLinkId() throws Exception {
- linkId.setLinkId("1.1.1.1");
- assertThat(linkId, is(notNullValue()));
- }
-
- /**
- * Tests linkId() setter method.
- */
- @Test
- public void testSetLinkId() throws Exception {
- linkId.setLinkId("1.1.1.1");
- assertThat(linkId, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(2);
- tlvHeader.setTlvLength(4);
- linkId = new LinkId(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- linkId.readFrom(channelBuffer);
- assertThat(linkId, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test(expected = Exception.class)
- public void testReadFrom1() throws Exception {
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(2);
- tlvHeader.setTlvLength(4);
- linkId = new LinkId(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- linkId.readFrom(channelBuffer);
- assertThat(linkId, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = linkId.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getLinkSubTypeTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
- result = linkId.getLinkSubTypeTlvBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkTypeTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkTypeTest.java
deleted file mode 100644
index 727b0d1..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LinkTypeTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for LinkType.
- */
-public class LinkTypeTest {
-
- private final byte[] packet = {0, 0, 0, 1};
- private final byte[] packet1 = {0, 0, 1};
- private LinkType linkType;
- private byte[] result;
- private ChannelBuffer channelBuffer;
- private TlvHeader tlvHeader;
-
- @Before
- public void setUp() throws Exception {
- linkType = new LinkType();
- }
-
- @After
- public void tearDown() throws Exception {
- linkType = null;
- channelBuffer = null;
- tlvHeader = null;
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(linkType.toString(), is(notNullValue()));
- }
-
- /**
- * Tests linkType() getter method.
- */
- @Test
- public void testGetLinkType() throws Exception {
- linkType.setLinkType(1);
- assertThat(linkType, is(notNullValue()));
- }
-
- /**
- * Tests linkType() setter method.
- */
- @Test
- public void testSetLinkType() throws Exception {
- linkType.setLinkType(1);
- assertThat(linkType, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(1);
- tlvHeader.setTlvLength(4);
- linkType = new LinkType(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- linkType.readFrom(channelBuffer);
- assertThat(linkType, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom1() throws Exception {
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(1);
- tlvHeader.setTlvLength(4);
- linkType = new LinkType(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- linkType.readFrom(channelBuffer);
- assertThat(linkType, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = linkType.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
-
- /**
- * Tests getLinkSubTypeTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
- result = linkType.getLinkSubTypeTlvBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddressTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddressTest.java
deleted file mode 100644
index 7e551ce..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/LocalInterfaceIpAddressTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for LocalInterfaceIpAddress.
- */
-public class LocalInterfaceIpAddressTest {
-
- private final byte[] packet = {1, 1, 1, 1};
- private final byte[] packet1 = {};
- private LocalInterfaceIpAddress localInterfaceIpAddress;
- private TlvHeader tlvHeader;
- private byte[] result;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- localInterfaceIpAddress = new LocalInterfaceIpAddress(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- localInterfaceIpAddress = null;
- tlvHeader = null;
- result = null;
- channelBuffer = null;
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(localInterfaceIpAddress.toString(), is(notNullValue()));
- }
-
- /**
- * Tests addLocalInterfaceIPAddress() method.
- */
- @Test
- public void testAddLocalInterfaceIPAddress() throws Exception {
- localInterfaceIpAddress.addLocalInterfaceIPAddress("1.1.1.1");
- assertThat(localInterfaceIpAddress, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(3);
- tlvHeader.setTlvLength(4);
- localInterfaceIpAddress = new LocalInterfaceIpAddress(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- localInterfaceIpAddress.readFrom(channelBuffer);
- assertThat(localInterfaceIpAddress, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom1() throws Exception {
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(3);
- tlvHeader.setTlvLength(4);
- localInterfaceIpAddress = new LocalInterfaceIpAddress(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- localInterfaceIpAddress.readFrom(channelBuffer);
- assertThat(localInterfaceIpAddress, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = localInterfaceIpAddress.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
-
- /**
- * Tests getLinkSubTypeTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
- result = localInterfaceIpAddress.getLinkSubTypeTlvBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumBandwidthTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumBandwidthTest.java
deleted file mode 100644
index 090988a..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumBandwidthTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for MaximumBandwidth.
- */
-public class MaximumBandwidthTest {
-
- private final byte[] packet = {0, 0, 0, 0};
- private MaximumBandwidth maximumBandwidth;
- private TlvHeader header;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- maximumBandwidth = new MaximumBandwidth(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- maximumBandwidth = null;
- header = null;
- channelBuffer = null;
- result = null;
- }
-
- /**
- * Tests maximumBandwidth() setter method.
- */
- @Test
- public void testSetMaximumBandwidth() throws Exception {
- maximumBandwidth.setMaximumBandwidth(123456.00f);
- assertThat(maximumBandwidth, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- header = new TlvHeader();
- header.setTlvType(6);
- header.setTlvLength(4);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- maximumBandwidth = new MaximumBandwidth(header);
- maximumBandwidth.readFrom(channelBuffer);
- assertThat(maximumBandwidth, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = maximumBandwidth.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(maximumBandwidth.toString(), is(notNullValue()));
- }
-}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumReservableBandwidthTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumReservableBandwidthTest.java
deleted file mode 100644
index e0a00ed..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/MaximumReservableBandwidthTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for MaximumReservableBandwidth.
- */
-public class MaximumReservableBandwidthTest {
-
- private final byte[] packet = {0, 0, 0, 0};
- private MaximumReservableBandwidth maximumReservableBandwidth;
- private TlvHeader header;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- maximumReservableBandwidth = new MaximumReservableBandwidth(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- maximumReservableBandwidth = null;
- header = null;
- channelBuffer = null;
- result = null;
- }
-
-
- /**
- * Tests maximumBandwidth() setter method.
- */
- @Test
- public void testSetMaximumBandwidth() throws Exception {
- maximumReservableBandwidth.setMaximumBandwidth(123456.78f);
- assertThat(maximumReservableBandwidth, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- header = new TlvHeader();
- header.setTlvType(6);
- header.setTlvLength(4);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- maximumReservableBandwidth = new MaximumReservableBandwidth(header);
- maximumReservableBandwidth.readFrom(channelBuffer);
- assertThat(maximumReservableBandwidth, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = maximumReservableBandwidth.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
-
- /**
- * Tests getLinkSubTypeTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
- result = maximumReservableBandwidth.getLinksubTypeTlvBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(maximumReservableBandwidth.toString(), is(notNullValue()));
- }
-}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddressTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddressTest.java
deleted file mode 100644
index b534f5e..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/RemoteInterfaceIpAddressTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-
-/**
- * Unit test class for RemoteInterfaceIpAddress.
- */
-public class RemoteInterfaceIpAddressTest {
-
- private final byte[] packet = {1, 1, 1, 1};
- private final byte[] packet1 = {};
- private byte[] result;
- private TlvHeader tlvHeader;
- private RemoteInterfaceIpAddress remoteInterfaceIpAddress;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- remoteInterfaceIpAddress = new RemoteInterfaceIpAddress(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- remoteInterfaceIpAddress = null;
- result = null;
- tlvHeader = null;
- channelBuffer = null;
- }
-
- /**
- * Tests addRemoteInterfaceAddress() method.
- */
- @Test
- public void testAddRemoteInterfaceIpAddress() throws Exception {
- remoteInterfaceIpAddress.addRemoteInterfaceAddress("1.1.1.1");
- assertThat(remoteInterfaceIpAddress, is(notNullValue()));
- }
-
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(4);
- tlvHeader.setTlvLength(4);
- remoteInterfaceIpAddress = new RemoteInterfaceIpAddress(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- remoteInterfaceIpAddress.readFrom(channelBuffer);
- assertThat(remoteInterfaceIpAddress, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom1() throws Exception {
- tlvHeader = new TlvHeader();
- tlvHeader.setTlvType(4);
- tlvHeader.setTlvLength(4);
- remoteInterfaceIpAddress = new RemoteInterfaceIpAddress(tlvHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- remoteInterfaceIpAddress.readFrom(channelBuffer);
- assertThat(remoteInterfaceIpAddress, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = remoteInterfaceIpAddress.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
-
- /**
- * Tests getLinkSubTypeTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
- result = remoteInterfaceIpAddress.getLinkSubTypeTlvBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(remoteInterfaceIpAddress.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/TrafficEngineeringMetricTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/TrafficEngineeringMetricTest.java
deleted file mode 100644
index 078ef4e..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/TrafficEngineeringMetricTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for TrafficEngineeringMetric.
- */
-public class TrafficEngineeringMetricTest {
-
- private final byte[] packet = {0, 0, 1, 1};
- private TrafficEngineeringMetric trafficEngineeringMetric;
- private TlvHeader header;
- private byte[] result;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- trafficEngineeringMetric = new TrafficEngineeringMetric(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- trafficEngineeringMetric = null;
- header = null;
- result = null;
- channelBuffer = null;
- }
-
-
- /**
- * Tests trafficEngineeringMetric() setter method.
- */
- @Test
- public void testSetTrafficEngineeringMetric() throws Exception {
- trafficEngineeringMetric.setTrafficEngineeringMetric(123456789L);
- assertThat(trafficEngineeringMetric, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- header = new TlvHeader();
- header.setTlvLength(4);
- header.setTlvType(5);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- trafficEngineeringMetric = new TrafficEngineeringMetric(header);
- trafficEngineeringMetric.readFrom(channelBuffer);
- assertThat(trafficEngineeringMetric, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = trafficEngineeringMetric.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
-
- /**
- * Tests getLinkSubTypeTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
- result = trafficEngineeringMetric.getLinkSubTypeTlvBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(trafficEngineeringMetric.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnknownLinkSubTypeTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnknownLinkSubTypeTest.java
deleted file mode 100644
index 7ff01de..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnknownLinkSubTypeTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for UnknownLinkSubType.
- */
-public class UnknownLinkSubTypeTest {
- private final byte[] packet = {0, 114, 0, 4, 0, 0, 0, 1};
- private UnknownLinkSubType unknownLinkSubType;
- private TlvHeader header;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- unknownLinkSubType = new UnknownLinkSubType(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- unknownLinkSubType = null;
- header = null;
- }
-
- /**
- * Tests value() getter method.
- */
- @Test
- public void testValue() throws Exception {
- unknownLinkSubType.setValue(packet);
- assertThat(unknownLinkSubType.value(), is(notNullValue()));
- }
-
- /**
- * Tests value() setter method.
- */
- @Test
- public void testSetValue() throws Exception {
- unknownLinkSubType.setValue(packet);
- assertThat(unknownLinkSubType.value(), is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- header = new TlvHeader();
- header.setTlvLength(8);
- header.setTlvType(114);
- unknownLinkSubType = new UnknownLinkSubType(header);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- unknownLinkSubType.readFrom(channelBuffer);
- assertThat(unknownLinkSubType, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test(expected = Exception.class)
- public void testAsBytes() throws Exception {
- result = unknownLinkSubType.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
-
- /**
- * Tests getLinkSubTypeTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- unknownLinkSubType.readFrom(channelBuffer);
- result = unknownLinkSubType.getLinkSubTypeTlvBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(unknownLinkSubType.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidthTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidthTest.java
deleted file mode 100644
index 9287546..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidthTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.linksubtype;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for OspfRouterId.
- */
-public class UnreservedBandwidthTest {
-
- private final byte[] packet = {0, 0, 0, 1};
- private UnreservedBandwidth unreservedBandwidth;
- private TlvHeader header;
- private byte[] result;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- unreservedBandwidth = new UnreservedBandwidth(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- unreservedBandwidth = null;
- header = null;
- result = null;
- channelBuffer = null;
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(unreservedBandwidth.toString(), is(notNullValue()));
- }
-
- /**
- * Tests addUnReservedBandwidth() method.
- */
- @Test
- public void testAddUnReservedBandwidth() throws Exception {
- unreservedBandwidth.addUnReservedBandwidth(123456.78f);
- assertThat(unreservedBandwidth, is(notNullValue()));
- }
-
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- header = new TlvHeader();
- header.setTlvLength(4);
- header.setTlvType(8);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- unreservedBandwidth = new UnreservedBandwidth(header);
- unreservedBandwidth.readFrom(channelBuffer);
- unreservedBandwidth.readFrom(channelBuffer);
- assertThat(unreservedBandwidth, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = unreservedBandwidth.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
-
- /**
- * Tests getLinkSubTypeTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
- result = unreservedBandwidth.getLinkSubTypeTlvBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfExternalDestinationTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfExternalDestinationTest.java
deleted file mode 100644
index 30e393dd..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfExternalDestinationTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.subtypes;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for OspfRouterId.
- */
-public class OspfExternalDestinationTest {
-
- private static final Ip4Address LOCAL_ADDRESS = Ip4Address.valueOf("127.0.0.1");
-
- private OspfExternalDestination ospfExternalDestination;
-
- @Before
- public void setUp() throws Exception {
- ospfExternalDestination = new OspfExternalDestination();
- }
-
- @After
- public void tearDown() throws Exception {
- ospfExternalDestination = null;
- }
-
- /**
- * Tests isType1orType2Metric() getter method.
- */
- @Test
- public void testIsType1orType2Metric() throws Exception {
- ospfExternalDestination.setType1orType2Metric(true);
- assertThat(ospfExternalDestination.isType1orType2Metric(), is(true));
- }
-
- /**
- * Tests isType1orType2Metric() setter method.
- */
- @Test
- public void testSetType1orType2Metric() throws Exception {
- ospfExternalDestination.setType1orType2Metric(true);
- assertThat(ospfExternalDestination.isType1orType2Metric(), is(true));
- }
-
- /**
- * Tests metric() getter method.
- */
- @Test
- public void testGetMetric() throws Exception {
- ospfExternalDestination.setMetric(100);
- assertThat(ospfExternalDestination.metric(), is(100));
- }
-
- /**
- * Tests metric() setter method.
- */
- @Test
- public void testSetMetric() throws Exception {
- ospfExternalDestination.setMetric(100);
- assertThat(ospfExternalDestination.metric(), is(100));
- }
-
- /**
- * Tests forwardingAddress() getter method.
- */
- @Test
- public void testGetForwardingAddress() throws Exception {
- ospfExternalDestination.setForwardingAddress(LOCAL_ADDRESS);
- assertThat(ospfExternalDestination.forwardingAddress(), is(LOCAL_ADDRESS));
-
- }
-
- /**
- * Tests forwardingAddress() setter method.
- */
- @Test
- public void testSetForwardingAddress() throws Exception {
- ospfExternalDestination.setForwardingAddress(LOCAL_ADDRESS);
- assertThat(ospfExternalDestination.forwardingAddress(), is(LOCAL_ADDRESS));
- }
-
- /**
- * Tests externalRouterTag() getter method.
- */
- @Test
- public void testGetExternalRouterTag() throws Exception {
- ospfExternalDestination.setExternalRouterTag(100);
- assertThat(ospfExternalDestination.externalRouterTag(), is(100));
- }
-
- /**
- * Tests externalRouterTag() setter method.
- */
- @Test
- public void testSetExternalRouterTag() throws Exception {
- ospfExternalDestination.setExternalRouterTag(100);
- assertThat(ospfExternalDestination.externalRouterTag(), is(100));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(ospfExternalDestination.toString(), is(notNullValue()));
- }
-}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfLsaLinkTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfLsaLinkTest.java
deleted file mode 100644
index a129ed0..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/subtypes/OspfLsaLinkTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.subtypes;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for OspfLsaLink.
- */
-public class OspfLsaLinkTest {
-
- private OspfLsaLink ospfLsaLink;
-
- @Before
- public void setUp() throws Exception {
- ospfLsaLink = new OspfLsaLink();
- }
-
- @After
- public void tearDown() throws Exception {
- ospfLsaLink = null;
- }
-
- /**
- * Tests linkId() getter method.
- */
- @Test
- public void testGetLinkID() throws Exception {
- ospfLsaLink.setLinkId("1.1.1.1");
- assertThat(ospfLsaLink.linkId(), is("1.1.1.1"));
- }
-
- /**
- * Tests linkId() setter method.
- */
- @Test
- public void testSetLinkID() throws Exception {
- ospfLsaLink.setLinkId("1.1.1.1");
- assertThat(ospfLsaLink.linkId(), is("1.1.1.1"));
- }
-
- /**
- * Tests linkData() getter method.
- */
- @Test
- public void testGetLinkData() throws Exception {
- ospfLsaLink.setLinkData("1.1.1.1");
- assertThat(ospfLsaLink.linkData(), is("1.1.1.1"));
- }
-
- /**
- * Tests linkData() setter method.
- */
- @Test
- public void testSetLinkData() throws Exception {
- ospfLsaLink.setLinkData("1.1.1.1");
- assertThat(ospfLsaLink.linkData(), is("1.1.1.1"));
- }
-
- /**
- * Tests linkType() getter method.
- */
- @Test
- public void testGetLinkType() throws Exception {
- ospfLsaLink.setLinkType(1);
- assertThat(ospfLsaLink.linkType(), is(1));
- }
-
- /**
- * Tests linkType() setter method.
- */
- @Test
- public void testSetLinkType() throws Exception {
- ospfLsaLink.setLinkType(1);
- assertThat(ospfLsaLink.linkType(), is(1));
- }
-
- /**
- * Tests metric() getter method.
- */
- @Test
- public void testGetMetric() throws Exception {
- ospfLsaLink.setMetric(100);
- assertThat(ospfLsaLink.metric(), is(100));
- }
-
- /**
- * Tests metric() setter method.
- */
- @Test
- public void testSetMetric() throws Exception {
- ospfLsaLink.setMetric(100);
- assertThat(ospfLsaLink.metric(), is(100));
- }
-
- /**
- * Tests tos() getter method.
- */
- @Test
- public void testGetTos() throws Exception {
- ospfLsaLink.setTos(100);
- assertThat(ospfLsaLink.tos(), is(100));
- }
-
- /**
- * Tests tos() setter method.
- */
- @Test
- public void testSetTos() throws Exception {
- ospfLsaLink.setTos(100);
- assertThat(ospfLsaLink.tos(), is(100));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(ospfLsaLink.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlvTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlvTest.java
deleted file mode 100644
index b28e7e0..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/LinkTlvTest.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.tlvtypes;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
-
-/**
- * Unit test class for LinkTlv.
- */
-public class LinkTlvTest {
-
- private final byte[] packet1 = {0, 9, 0, 4, 0, 0, 0, 1};
- private final byte[] packet2 = {0, 1, 0, 4, 0, 0, 0, 1};
- private final byte[] packet3 = {0, 2, 0, 4, 0, 0, 0, 1};
- private final byte[] packet4 = {0, 3, 0, 4, 0, 0, 0, 1};
- private final byte[] packet5 = {0, 4, 0, 4, 0, 0, 0, 1};
- private final byte[] packet6 = {0, 6, 0, 4, 0, 0, 0, 1};
- private final byte[] packet7 = {0, 7, 0, 4, 0, 0, 0, 1};
- private final byte[] packet8 = {0, 8, 0, 4, 0, 0, 0, 1};
- private final byte[] packet9 = {0, 9, 0, 4, 0, 0, 0, 1,
- 0, 9, 0, 4, 0, 0, 0, 1,
- 0, 1, 0, 4, 0, 0, 0, 1,
- 0, 2, 0, 4, 0, 0, 0, 1,
- 0, 3, 0, 4, 0, 0, 0, 1,
- 0, 4, 0, 4, 0, 0, 0, 1,
- 0, 6, 0, 4, 0, 0, 0, 1,
- 0, 7, 0, 4, 0, 0, 0, 1,
- 0, 8, 0, 4, 0, 0, 0, 1,
- };
- private LinkTlv linkTlv;
- private TlvHeader header;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- linkTlv = new LinkTlv(new TlvHeader());
-
- }
-
- @After
- public void tearDown() throws Exception {
- linkTlv = null;
- header = null;
- channelBuffer = null;
- result = null;
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(linkTlv.toString(), is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
-
- header = new TlvHeader();
- header.setTlvLength(8);
- header.setTlvType(9);
- linkTlv = new LinkTlv(header);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- linkTlv.readFrom(channelBuffer);
- assertThat(linkTlv, is(notNullValue()));
-
- header = new TlvHeader();
- header.setTlvLength(8);
- header.setTlvType(1);
- linkTlv = new LinkTlv(header);
- channelBuffer = ChannelBuffers.copiedBuffer(packet2);
- linkTlv.readFrom(channelBuffer);
- assertThat(linkTlv, is(notNullValue()));
-
- header = new TlvHeader();
- header.setTlvLength(8);
- header.setTlvType(2);
- linkTlv = new LinkTlv(header);
- channelBuffer = ChannelBuffers.copiedBuffer(packet3);
- linkTlv.readFrom(channelBuffer);
- assertThat(linkTlv, is(notNullValue()));
-
- header = new TlvHeader();
- header.setTlvLength(8);
- header.setTlvType(3);
- linkTlv = new LinkTlv(header);
- channelBuffer = ChannelBuffers.copiedBuffer(packet4);
- linkTlv.readFrom(channelBuffer);
- assertThat(linkTlv, is(notNullValue()));
-
- header = new TlvHeader();
- header.setTlvLength(8);
- header.setTlvType(4);
- linkTlv = new LinkTlv(header);
- channelBuffer = ChannelBuffers.copiedBuffer(packet5);
- linkTlv.readFrom(channelBuffer);
- assertThat(linkTlv, is(notNullValue()));
-
- header = new TlvHeader();
- header.setTlvLength(8);
- header.setTlvType(5);
- linkTlv = new LinkTlv(header);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- linkTlv.readFrom(channelBuffer);
- assertThat(linkTlv, is(notNullValue()));
-
- header = new TlvHeader();
- header.setTlvLength(8);
- header.setTlvType(6);
- linkTlv = new LinkTlv(header);
- channelBuffer = ChannelBuffers.copiedBuffer(packet6);
- linkTlv.readFrom(channelBuffer);
- assertThat(linkTlv, is(notNullValue()));
-
- header = new TlvHeader();
- header.setTlvLength(8);
- header.setTlvType(7);
- linkTlv = new LinkTlv(header);
- channelBuffer = ChannelBuffers.copiedBuffer(packet7);
- linkTlv.readFrom(channelBuffer);
- assertThat(linkTlv, is(notNullValue()));
-
- header = new TlvHeader();
- header.setTlvLength(8);
- header.setTlvType(8);
- linkTlv = new LinkTlv(header);
- channelBuffer = ChannelBuffers.copiedBuffer(packet8);
- linkTlv.readFrom(channelBuffer);
- assertThat(linkTlv, is(notNullValue()));
- assertThat(linkTlv, instanceOf(LinkTlv.class));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = linkTlv.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
-
- /**
- * Tests getTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetTlvBodyAsByteArray() throws Exception {
-
- channelBuffer = ChannelBuffers.copiedBuffer(packet9);
- linkTlv.readFrom(channelBuffer);
-
- result = linkTlv.getTlvBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlvTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlvTest.java
deleted file mode 100644
index 8a250c9..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlvTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.tlvtypes;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
-
-/**
- * Unit test class for RouterTlv.
- */
-public class RouterTlvTest {
-
- private final byte[] packet = {1, 1, 1, 1};
- private final byte[] packet1 = {1, 1, 1};
- private RouterTlv rtlv;
- private TlvHeader header;
- private ChannelBuffer channelBuffer;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- rtlv = new RouterTlv(new TlvHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- rtlv = null;
- header = null;
- channelBuffer = null;
- result = null;
- }
-
- /**
- * Tests routerAddress() getter method.
- */
- @Test
- public void testGetRouterAddress() throws Exception {
- rtlv.setRouterAddress(Ip4Address.valueOf("1.1.1.1"));
- assertThat(rtlv.routerAddress(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests routerAddress() setter method.
- */
- @Test
- public void testSetRouterAddress() throws Exception {
- rtlv.setRouterAddress(Ip4Address.valueOf("1.1.1.1"));
- assertThat(rtlv.routerAddress(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- header = new TlvHeader();
- header.setTlvType(1);
- header.setTlvLength(4);
- rtlv = new RouterTlv(header);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- rtlv.readFrom(channelBuffer);
- assertThat(rtlv, is(notNullValue()));
- assertThat(rtlv, instanceOf(RouterTlv.class));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test(expected = Exception.class)
- public void testReadFrom1() throws Exception {
- header = new TlvHeader();
- header.setTlvType(1);
- header.setTlvLength(4);
- rtlv = new RouterTlv(header);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- rtlv.readFrom(channelBuffer);
- assertThat(rtlv, is(notNullValue()));
- assertThat(rtlv, instanceOf(RouterTlv.class));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test(expected = Exception.class)
- public void testAsBytes() throws Exception {
- result = rtlv.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getTlvBodyAsByteArray() method.
- */
- @Test(expected = Exception.class)
- public void testGetTlvBodyAsByteArray() throws Exception {
- result = rtlv.getTlvBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(rtlv.toString(), is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/AsbrSummaryLsaTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/AsbrSummaryLsaTest.java
deleted file mode 100644
index 5bf7d01..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/AsbrSummaryLsaTest.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for AsbrSummaryLsa.
- */
-public class AsbrSummaryLsaTest {
-
- private final Ip4Address ipAddress = Ip4Address.valueOf("10.226.165.164");
- private AsbrSummaryLsa asbrSummaryLsa;
- private Ip4Address result;
- private int result1;
- private int num;
- private byte[] inputByteArray;
- private byte[] result2;
- private ChannelBuffer channelBuffer;
- private LsaHeader lsaHeader;
- private OspfLsaType ospflsaType;
- private String result3;
- private boolean result4;
-
- @Before
- public void setUp() throws Exception {
- asbrSummaryLsa = new AsbrSummaryLsa(new LsaHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- asbrSummaryLsa = null;
- }
-
- /**
- * Tests networkMask() getter method.
- */
- @Test
- public void testGetNetworkMask() throws Exception {
- asbrSummaryLsa.setNetworkMask(ipAddress);
- result = asbrSummaryLsa.networkMask();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(ipAddress));
- }
-
- /**
- * Tests networkMask() setter method.
- */
- @Test
- public void testSetNetworkMask() throws Exception {
- asbrSummaryLsa.setNetworkMask(ipAddress);
- result = asbrSummaryLsa.networkMask();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(ipAddress));
- }
-
- /**
- * Tests metric() getter method.
- */
- @Test
- public void testGetMetric() throws Exception {
- num = 10;
- asbrSummaryLsa.setMetric(num);
- result1 = asbrSummaryLsa.metric();
- assertThat(result1, is(notNullValue()));
- assertThat(result1, is(num));
- }
-
- /**
- * Tests metric() setter method.
- */
- @Test
- public void testSetMetric() throws Exception {
- num = 20;
- asbrSummaryLsa.setMetric(num);
- result1 = asbrSummaryLsa.metric();
- assertThat(result1, is(notNullValue()));
- assertThat(result1, is(num));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- inputByteArray = createByteForNetworkLsa();
- lsaHeader = createLsaHeader();
- asbrSummaryLsa = new AsbrSummaryLsa(lsaHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
- asbrSummaryLsa.readFrom(channelBuffer);
- assertThat(asbrSummaryLsa, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test(expected = Exception.class)
- public void testReadFrom1() throws Exception {
- byte[] temp = {0, 1, 2, 3};
- inputByteArray = temp;
- lsaHeader = createLsaHeader();
- asbrSummaryLsa = new AsbrSummaryLsa(lsaHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
- asbrSummaryLsa.readFrom(channelBuffer);
- assertThat(asbrSummaryLsa, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test(expected = Exception.class)
- public void testAsBytes() throws Exception {
- result2 = asbrSummaryLsa.asBytes();
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests getLsaBodyAsByteArray() method.
- */
- @Test(expected = Exception.class)
- public void testGetLsaBodyAsByteArray() throws Exception {
- result2 = asbrSummaryLsa.getLsaBodyAsByteArray();
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests ospfLsaType() getter method.
- */
- @Test
- public void testGetOspfLsaType() throws Exception {
-
- ospflsaType = asbrSummaryLsa.getOspfLsaType();
- assertThat(ospflsaType, is(notNullValue()));
- assertThat(ospflsaType, is(OspfLsaType.ASBR_SUMMARY));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
-
- result3 = asbrSummaryLsa.toString();
- assertThat(result3, is(notNullValue()));
-
- }
-
- /**
- * Tests hashcode() method.
- */
- @Test
- public void testHashcode() throws Exception {
-
- result1 = asbrSummaryLsa.hashCode();
- assertThat(result1, is(notNullValue()));
-
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEqual() throws Exception {
-
- result4 = asbrSummaryLsa.equals(new AsbrSummaryLsa(new LsaHeader()));
- assertThat(result4, is(true));
-
- }
-
- /**
- * Utility method used by junit methods.
- */
- private byte[] createByteForNetworkLsa() {
- byte[] packet = {2, 1, 1, 52, -64, -88, 56, 1, -64, -88, 56, 1, 0, 100, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, -64,
- -88, 56, 1, 0, 10, 1, 1, 0, 0, 0, 40, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56,
- 1};
- return packet;
- }
-
- /**
- * Utility method used by junit methods.
- */
- private LsaHeader createLsaHeader() {
- lsaHeader = new LsaHeader();
- lsaHeader.setLsType(1);
- lsaHeader.setLsPacketLen(48);
- lsaHeader.setLsCheckSum(10);
- lsaHeader.setAge(4);
- lsaHeader.setLinkStateId("10.226.165.164");
- lsaHeader.setLsSequenceNo(250);
- lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- lsaHeader.setOptions(2);
- return lsaHeader;
- }
-}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/ExternalLsaTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/ExternalLsaTest.java
deleted file mode 100644
index d5a4256..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/ExternalLsaTest.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.subtypes.OspfExternalDestination;
-
-import java.net.UnknownHostException;
-import java.util.Vector;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for ExternalLsa.
- */
-public class ExternalLsaTest {
-
- private static final Ip4Address LOCAL_ADDRESS = Ip4Address.valueOf("127.0.0.1");
-
- private ExternalLsa externalLsa;
- private Vector<OspfExternalDestination> externalDestinations = new Vector<OspfExternalDestination>();
- private Ip4Address result;
- private OspfExternalDestination ospfExternalDestination;
- private OspfExternalDestination ospfExternalDestination1;
- private LsaHeader lsaHeader;
- private byte[] inputByteArray;
- private ChannelBuffer channelBuffer;
- private byte[] result1;
- private OspfLsaType ospflsaType;
- private int result2;
-
- @Before
- public void setUp() throws Exception {
- externalLsa = new ExternalLsa(new LsaHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- externalLsa = null;
- externalDestinations = null;
- result = null;
- ospfExternalDestination = null;
- ospfExternalDestination1 = null;
- lsaHeader = null;
- inputByteArray = null;
- channelBuffer = null;
- result1 = null;
- ospflsaType = null;
- }
-
- /**
- * Tests networkMask() getter method.
- */
- @Test
- public void testGetNetworkMask() throws Exception {
- externalLsa.setNetworkMask(Ip4Address.valueOf("10.226.165.164"));
- result = externalLsa.networkMask();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(Ip4Address.valueOf("10.226.165.164")));
- }
-
- /**
- * Tests networkMask() setter method.
- */
- @Test
- public void testSetNetworkMask() throws Exception {
- externalLsa.setNetworkMask(Ip4Address.valueOf("10.226.165.164"));
- result = externalLsa.networkMask();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(Ip4Address.valueOf("10.226.165.164")));
- }
-
- /**
- * Tests addExternalDesitnation() method.
- */
- @Test
- public void testAddExternalDesitnation() throws Exception {
- externalLsa.addExternalDestination(createOspfExternalDestination());
- assertThat(externalLsa, is(notNullValue()));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashcode() throws Exception {
-
- result2 = externalLsa.hashCode();
- assertThat(result2, is(notNullValue()));
-
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- ospfExternalDestination = new OspfExternalDestination();
- ospfExternalDestination.setExternalRouterTag(2);
- ospfExternalDestination.setMetric(100);
- ospfExternalDestination.setType1orType2Metric(true);
- externalLsa.addExternalDestination(ospfExternalDestination);
- ospfExternalDestination1 = new OspfExternalDestination();
- ospfExternalDestination.setExternalRouterTag(3);
- ospfExternalDestination.setMetric(50);
- ospfExternalDestination.setType1orType2Metric(true);
- externalLsa.addExternalDestination(ospfExternalDestination1);
- ospfExternalDestination.setForwardingAddress(LOCAL_ADDRESS);
- inputByteArray = createByteForNetworkLsa();
- lsaHeader = createLsaHeader();
- externalLsa = new ExternalLsa(lsaHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
- externalLsa.readFrom(channelBuffer);
- assertThat(externalLsa, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test(expected = Exception.class)
- public void testReadFrom1() throws Exception {
- ospfExternalDestination = new OspfExternalDestination();
- ospfExternalDestination.setExternalRouterTag(2);
- ospfExternalDestination.setMetric(100);
- ospfExternalDestination.setType1orType2Metric(true);
- externalLsa.addExternalDestination(ospfExternalDestination);
- ospfExternalDestination1 = new OspfExternalDestination();
- ospfExternalDestination.setExternalRouterTag(3);
- ospfExternalDestination.setMetric(50);
- ospfExternalDestination.setType1orType2Metric(true);
- externalLsa.addExternalDestination(ospfExternalDestination1);
- ospfExternalDestination.setForwardingAddress(LOCAL_ADDRESS);
- byte[] temp = {0, 0, 0};
- inputByteArray = temp;
- lsaHeader = createLsaHeader();
- externalLsa = new ExternalLsa(lsaHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
- externalLsa.readFrom(channelBuffer);
- assertThat(externalLsa, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result1 = externalLsa.asBytes();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests getLsaBodyAsByteArray() method.
- */
- @Test
- public void testGetLsaBodyAsByteArray() throws Exception {
- ospfExternalDestination = new OspfExternalDestination();
- ospfExternalDestination.setExternalRouterTag(2);
- ospfExternalDestination.setMetric(100);
- ospfExternalDestination.setType1orType2Metric(true);
- externalLsa.addExternalDestination(ospfExternalDestination);
- ospfExternalDestination1 = new OspfExternalDestination();
- ospfExternalDestination.setExternalRouterTag(3);
- ospfExternalDestination.setMetric(100);
- ospfExternalDestination.setType1orType2Metric(true);
- externalLsa.addExternalDestination(ospfExternalDestination1);
- result1 = externalLsa.getLsaBodyAsByteArray();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests getLsaBodyAsByteArray() method.
- */
- @Test
- public void testGetLsaBodyAsByteArray1() throws Exception {
- externalLsa.setNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- ospfExternalDestination = new OspfExternalDestination();
- ospfExternalDestination.setExternalRouterTag(2);
- ospfExternalDestination.setMetric(100);
- ospfExternalDestination.setType1orType2Metric(true);
- externalLsa.addExternalDestination(ospfExternalDestination);
- ospfExternalDestination1 = new OspfExternalDestination();
- ospfExternalDestination.setExternalRouterTag(3);
- ospfExternalDestination.setMetric(100);
- ospfExternalDestination.setType1orType2Metric(true);
- externalLsa.addExternalDestination(ospfExternalDestination1);
- result1 = externalLsa.getLsaBodyAsByteArray();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests getOspfLsaType() getter method.
- */
- @Test
- public void testGetOspfLsaType() throws Exception {
- ospflsaType = externalLsa.getOspfLsaType();
- assertThat(ospflsaType, is(notNullValue()));
- assertThat(ospflsaType, is(OspfLsaType.EXTERNAL_LSA));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(externalLsa.toString(), is(notNullValue()));
- }
-
- /**
- * Utility method used by junit methods.
- */
- private byte[] createByteForNetworkLsa() {
- byte[] packet = {2, 1, 1, 52, -64, -88, 56, 1, -64, -88, 56, 1, 0, 100, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, -64,
- -88, 56, 1, 0, 10, 1, 1, 0, 0, 0, 40, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56,
- 1};
- return packet;
- }
-
- /**
- * Utility method used by junit methods.
- */
- private LsaHeader createLsaHeader() {
- lsaHeader = new LsaHeader();
- lsaHeader.setLsType(1);
- lsaHeader.setLsPacketLen(48);
- lsaHeader.setLsCheckSum(10);
- lsaHeader.setAge(4);
- lsaHeader.setLinkStateId("10.226.165.164");
- lsaHeader.setLsSequenceNo(250);
- lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- lsaHeader.setOptions(2);
- return lsaHeader;
- }
-
- /**
- * Utility method used by junit methods.
- */
- private OspfExternalDestination createOspfExternalDestination() throws UnknownHostException {
- ospfExternalDestination = new OspfExternalDestination();
- ospfExternalDestination.setExternalRouterTag(1);
- ospfExternalDestination.setMetric(10);
- ospfExternalDestination.setType1orType2Metric(true);
- ospfExternalDestination.setForwardingAddress(LOCAL_ADDRESS);
- return ospfExternalDestination;
- }
-}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsaTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsaTest.java
deleted file mode 100644
index 7924cd3..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsaTest.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-
-import java.util.Vector;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for NetworkLsa.
- */
-public class NetworkLsaTest {
-
- private static final Ip4Address LOCAL_ADDRESS = Ip4Address.valueOf("127.0.0.1");
-
- private Vector<String> attachedRouters = new Vector();
- private NetworkLsa networkLsa;
- private Ip4Address result;
- private Ip4Address inetAddres;
- private byte[] inputByteArray;
- private LsaHeader lsaHeader;
- private ChannelBuffer channelBuffer;
- private byte[] result1;
- private OspfLsaType ospflsaType;
- private int result2;
-
- @Before
- public void setUp() throws Exception {
- networkLsa = new NetworkLsa();
- }
-
- @After
- public void tearDown() throws Exception {
- networkLsa = null;
- attachedRouters = null;
- result = null;
- inetAddres = null;
- inputByteArray = null;
- lsaHeader = null;
- channelBuffer = null;
- result1 = null;
- ospflsaType = null;
- }
-
- /**
- * Tests networkMask() getter method.
- */
- @Test
- public void testGetNetworkMask() throws Exception {
- networkLsa.setNetworkMask(Ip4Address.valueOf("10.226.165.164"));
- result = networkLsa.networkMask();
- assertThat(result, is(Ip4Address.valueOf("10.226.165.164")));
- }
-
- /**
- * Tests networkMask() setter method.
- */
- @Test
- public void testSetNetworkMask() throws Exception {
- networkLsa.setNetworkMask(Ip4Address.valueOf("10.226.165.165"));
- result = networkLsa.networkMask();
- result = networkLsa.networkMask();
- assertThat(result, is(Ip4Address.valueOf("10.226.165.165")));
- }
-
- /**
- * Tests addAttachedRouter() getter method.
- */
- @Test
- public void testGetAttachedRouters() throws Exception {
- attachedRouters.add("1.1.1.1");
- networkLsa.addAttachedRouter(Ip4Address.valueOf("1.1.1.1"));
- assertThat(attachedRouters, is(notNullValue()));
- }
-
- /**
- * Tests addAttachedRouter() setter method.
- */
- @Test
- public void testSetAttachedRouters() throws Exception {
- attachedRouters.add("1.1.1.1");
- networkLsa.addAttachedRouter(Ip4Address.valueOf("1.1.1.1"));
- assertThat(attachedRouters, is(notNullValue()));
- }
-
- /**
- * Tests addAttachedRouter() method.
- */
- @Test
- public void testAddAttachedRouter() throws Exception {
- networkLsa.addAttachedRouter(LOCAL_ADDRESS);
- networkLsa.addAttachedRouter(LOCAL_ADDRESS);
- assertThat(networkLsa, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
-
- @Test
- public void testReadFrom() throws Exception {
- inputByteArray = createByteForNetworkLsa();
- lsaHeader = createLsaHeader();
- networkLsa = new NetworkLsa(lsaHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
- networkLsa.readFrom(channelBuffer);
- assertThat(networkLsa, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test(expected = Exception.class)
- public void testReadFrom1() throws Exception {
- byte[] temp = {0, 0, 0};
- inputByteArray = temp;
- lsaHeader = createLsaHeader();
- networkLsa = new NetworkLsa(lsaHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
- networkLsa.readFrom(channelBuffer);
- assertThat(networkLsa, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test(expected = Exception.class)
- public void testAsBytes() throws Exception {
- result1 = networkLsa.asBytes();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests getLsaBodyAsByteArray() method.
- */
- @Test(expected = Exception.class)
- public void testGetLsaBodyAsByteArray() throws Exception {
- networkLsa.addAttachedRouter(Ip4Address.valueOf("1.1.1.1"));
- networkLsa.addAttachedRouter(Ip4Address.valueOf("2.2.2.2"));
- networkLsa.addAttachedRouter(Ip4Address.valueOf("3.3.3.3"));
- result1 = networkLsa.getLsaBodyAsByteArray();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests getLsaBodyAsByteArray() method.
- */
- @Test
- public void testGetLsaBodyAsByteArray1() throws Exception {
- networkLsa.setNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- networkLsa.addAttachedRouter(Ip4Address.valueOf("1.1.1.1"));
- networkLsa.addAttachedRouter(Ip4Address.valueOf("2.2.2.2"));
- networkLsa.addAttachedRouter(Ip4Address.valueOf("3.3.3.3"));
- result1 = networkLsa.getLsaBodyAsByteArray();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests getOspfLsaType() getter method.
- */
- @Test
- public void testGetOspfLsaType() throws Exception {
- networkLsa.setLsType(2);
- ospflsaType = networkLsa.getOspfLsaType();
- assertThat(ospflsaType, is(OspfLsaType.NETWORK));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashcode() throws Exception {
-
- result2 = networkLsa.hashCode();
- assertThat(result2, is(notNullValue()));
-
- }
-
- /**
- * Utility method used by junit methods.
- */
- private byte[] createByteForNetworkLsa() {
- byte[] packet = {2, 1, 1, 52, -64, -88, 56, 1, -64, -88, 56, 1, 0, 100, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, -64,
- -88, 56, 1, 0, 10, 1, 1, 0, 0, 0, 40, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56,
- 1};
- return packet;
- }
-
- /**
- * Utility method used by junit methods.
- */
- private LsaHeader createLsaHeader() {
- lsaHeader = new LsaHeader();
- lsaHeader.setLsType(2);
- lsaHeader.setLsPacketLen(48);
- lsaHeader.setLsCheckSum(10);
- lsaHeader.setAge(4);
- lsaHeader.setLinkStateId("10.226.165.164");
- lsaHeader.setLsSequenceNo(250);
- lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- lsaHeader.setOptions(2);
- return lsaHeader;
- }
-}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa10Test.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa10Test.java
deleted file mode 100644
index 172863a..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa10Test.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.lsa.TlvHeader;
-import org.onosproject.ospf.protocol.lsa.tlvtypes.LinkTlv;
-import org.onosproject.ospf.protocol.lsa.tlvtypes.RouterTlv;
-
-
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for OpaqueLsa10.
- */
-public class OpaqueLsa10Test {
-
- private final byte[] packet = {0, 1, 0, 4, 1, 1, 1, 1, 0, 2, 0, 84, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- private OpaqueLsa10 opaqueLsa10;
- private TopLevelTlv tlv;
- private OpaqueLsaHeader opqueHeader;
- private ChannelBuffer channelBuffer;
- private byte[] result;
- private RouterTlv routerTlv;
- private RouterTlv routerTlv1;
- private LinkTlv linkTlv;
- private LinkTlv linkTlv1;
- private OspfLsaType ospflsaType;
- private int result1;
- private List result2;
-
- @Before
- public void setUp() throws Exception {
- opaqueLsa10 = new OpaqueLsa10(new OpaqueLsaHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- opaqueLsa10 = null;
- tlv = null;
- opqueHeader = null;
- channelBuffer = null;
- result = null;
- routerTlv = null;
- routerTlv1 = null;
- linkTlv1 = null;
- ospflsaType = null;
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(opaqueLsa10.toString(), is(notNullValue()));
- }
-
- /**
- * Tests addValue() method.
- */
- @Test
- public void testAddValue() throws Exception {
- tlv = new RouterTlv(new TlvHeader());
- opaqueLsa10.addValue(tlv);
- assertThat(opaqueLsa10, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test(expected = Exception.class)
- public void testReadFrom() throws Exception {
- opqueHeader = new OpaqueLsaHeader();
- opqueHeader.setLsType(10);
- opqueHeader.setLsPacketLen(48);
- opqueHeader.setLsCheckSum(10);
- opqueHeader.setAge(4);
- opqueHeader.setOpaqueId(1);
- opqueHeader.setOpaqueType(10);
- opqueHeader.setLsSequenceNo(250);
- opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader.setOptions(66);
- opaqueLsa10 = new OpaqueLsa10(opqueHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- opaqueLsa10.readFrom(channelBuffer);
- result = opaqueLsa10.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test(expected = Exception.class)
- public void testAsBytes() throws Exception {
- opqueHeader = new OpaqueLsaHeader();
- opqueHeader.setLsType(10);
- opqueHeader.setLsPacketLen(48);
- opqueHeader.setLsCheckSum(10);
- opqueHeader.setAge(4);
- opqueHeader.setOpaqueId(1);
- opqueHeader.setOpaqueType(10);
- opqueHeader.setLsSequenceNo(250);
- opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader.setOptions(66);
- opaqueLsa10 = new OpaqueLsa10(opqueHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- opaqueLsa10.readFrom(channelBuffer);
- result = opaqueLsa10.getLsaBodyAsByteArray();
- result = opaqueLsa10.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getLsaBodyAsByteArray() method.
- */
- @Test(expected = Exception.class)
- public void testGetLsaBodyAsByteArray() throws Exception {
- opqueHeader = new OpaqueLsaHeader();
- opqueHeader.setLsType(10);
- opqueHeader.setLsPacketLen(48);
- opqueHeader.setLsCheckSum(10);
- opqueHeader.setAge(4);
- opqueHeader.setOpaqueId(1);
- opqueHeader.setOpaqueType(10);
- opqueHeader.setLsSequenceNo(250);
- opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader.setOptions(2);
- opaqueLsa10 = new OpaqueLsa10(opqueHeader);
- routerTlv = new RouterTlv(new TlvHeader());
- linkTlv = new LinkTlv(new TlvHeader());
- opaqueLsa10.addValue(routerTlv);
- opaqueLsa10.addValue(linkTlv);
- routerTlv1 = new RouterTlv(new TlvHeader());
- linkTlv1 = new LinkTlv(new TlvHeader());
- opaqueLsa10.addValue(routerTlv1);
- opaqueLsa10.addValue(linkTlv1);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- opaqueLsa10.readFrom(channelBuffer);
- result = opaqueLsa10.getLsaBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getLsaBodyAsByteArray() method.
- */
- @Test(expected = Exception.class)
- public void testGetLsaBodyAsByteArray1() throws Exception {
- opqueHeader = new OpaqueLsaHeader();
- opqueHeader.setLsType(10);
- opqueHeader.setLsPacketLen(48);
- opqueHeader.setLsCheckSum(10);
- opqueHeader.setAge(4);
- opqueHeader.setOpaqueId(1);
- opqueHeader.setOpaqueType(10);
- opqueHeader.setLsSequenceNo(250);
- opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader.setOptions(2);
- opaqueLsa10 = new OpaqueLsa10(opqueHeader);
- routerTlv = new RouterTlv(new TlvHeader());
- opaqueLsa10.addValue(routerTlv);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- result = opaqueLsa10.getLsaBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getLsaBodyAsByteArray() method.
- */
- @Test(expected = Exception.class)
- public void testGetLsaBodyAsByteArray2() throws Exception {
- opqueHeader = new OpaqueLsaHeader();
- opqueHeader.setLsType(10);
- opqueHeader.setLsPacketLen(48);
- opqueHeader.setLsCheckSum(10);
- opqueHeader.setAge(4);
- opqueHeader.setOpaqueId(1);
- opqueHeader.setOpaqueType(10);
- opqueHeader.setLsSequenceNo(250);
- opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader.setOptions(2);
- opaqueLsa10 = new OpaqueLsa10(opqueHeader);
- linkTlv = new LinkTlv(new TlvHeader());
- opaqueLsa10.addValue(linkTlv);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- opaqueLsa10.readFrom(channelBuffer);
- result = opaqueLsa10.getLsaBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getOspfLsaType() getter method.
- */
- @Test
- public void testGetOspfLsaType() throws Exception {
- opaqueLsa10.setLsType(10);
- ospflsaType = opaqueLsa10.getOspfLsaType();
- assertThat(ospflsaType, is(notNullValue()));
- assertThat(ospflsaType, is(OspfLsaType.AREA_LOCAL_OPAQUE_LSA));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashcode() throws Exception {
-
- result1 = opaqueLsa10.hashCode();
- assertThat(result1, is(notNullValue()));
-
- }
-
- /**
- * Tests topLevelValues() method.
- */
- @Test
- public void testTopLevelValues() throws Exception {
-
- result2 = opaqueLsa10.topLevelValues();
- assertThat(result2, is(notNullValue()));
-
- }
-
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa11Test.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa11Test.java
deleted file mode 100644
index 07b50c5..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa11Test.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for OpaqueLsa11.
- */
-public class OpaqueLsa11Test {
-
- private final byte[] packet = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- private OpaqueLsa11 opaqueLsa11;
- private OpaqueLsaHeader opqueHeader;
- private ChannelBuffer channelBuffer;
- private byte[] result;
- private int result1;
- private String result2;
- private OspfLsaType ospflsaType;
-
- @Before
- public void setUp() throws Exception {
- opaqueLsa11 = new OpaqueLsa11(new OpaqueLsaHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- opaqueLsa11 = null;
- opqueHeader = null;
- channelBuffer = null;
- result = null;
- ospflsaType = null;
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- opqueHeader = new OpaqueLsaHeader();
- opqueHeader.setLsType(11);
- opqueHeader.setLsPacketLen(48);
- opqueHeader.setLsCheckSum(10);
- opqueHeader.setAge(4);
- opqueHeader.setOpaqueId(1);
- opqueHeader.setOpaqueType(11);
- opqueHeader.setLsSequenceNo(250);
- opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader.setOptions(2);
- opaqueLsa11 = new OpaqueLsa11(opqueHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- opaqueLsa11.readFrom(channelBuffer);
- assertThat(opaqueLsa11, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- opqueHeader = new OpaqueLsaHeader();
- opqueHeader.setLsType(11);
- opqueHeader.setLsPacketLen(48);
- opqueHeader.setLsCheckSum(10);
- opqueHeader.setAge(4);
- opqueHeader.setOpaqueId(1);
- opqueHeader.setOpaqueType(11);
- opqueHeader.setLsSequenceNo(250);
- opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader.setOptions(2);
- opaqueLsa11 = new OpaqueLsa11(opqueHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- opaqueLsa11.readFrom(channelBuffer);
- result = opaqueLsa11.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getLsaBodyAsByteArray() method.
- */
- @Test
- public void testGetLsaBodyAsByteArray() throws Exception {
- opqueHeader = new OpaqueLsaHeader();
- opqueHeader.setLsType(11);
- opqueHeader.setLsPacketLen(48);
- opqueHeader.setLsCheckSum(10);
- opqueHeader.setAge(4);
- opqueHeader.setOpaqueId(1);
- opqueHeader.setOpaqueType(11);
- opqueHeader.setLsSequenceNo(250);
- opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader.setOptions(2);
- opaqueLsa11 = new OpaqueLsa11(opqueHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- opaqueLsa11.readFrom(channelBuffer);
- result = opaqueLsa11.getLsaBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getOspfLsaType() method.
- */
- @Test
- public void testGetOspfLsaType() throws Exception {
- opaqueLsa11.setLsType(11);
- ospflsaType = opaqueLsa11.getOspfLsaType();
- assertThat(ospflsaType, is(notNullValue()));
- assertThat(ospflsaType, is(OspfLsaType.AS_OPAQUE_LSA));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashcode() throws Exception {
-
- result1 = opaqueLsa11.hashCode();
- assertThat(result1, is(notNullValue()));
-
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
-
- result2 = opaqueLsa11.toString();
- assertThat(result2, is(notNullValue()));
-
- }
-}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa9Test.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa9Test.java
deleted file mode 100644
index 0c6fa41..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/OpaqueLsa9Test.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for OpaqueLsa9.
- */
-public class OpaqueLsa9Test {
-
- private final byte[] packet = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0};
- private byte[] result;
- private String result1;
- private OpaqueLsaHeader opqueHeader;
- private OpaqueLsa9 opaqueLsa9;
- private ChannelBuffer channelBuffer;
- private OspfLsaType ospflsaType;
- private int result2;
-
- @Before
- public void setUp() throws Exception {
- opaqueLsa9 = new OpaqueLsa9(new OpaqueLsaHeader());
-
- }
-
- @After
- public void tearDown() throws Exception {
- opaqueLsa9 = null;
- opqueHeader = null;
- channelBuffer = null;
- result = null;
- ospflsaType = null;
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- opqueHeader = new OpaqueLsaHeader();
- opqueHeader.setLsType(1);
- opqueHeader.setLsPacketLen(48);
- opqueHeader.setLsCheckSum(10);
- opqueHeader.setAge(4);
- opqueHeader.setOpaqueId(9);
- opqueHeader.setOpaqueType(9);
- opqueHeader.setLsSequenceNo(250);
- opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader.setOptions(2);
- opaqueLsa9 = new OpaqueLsa9(opqueHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- opaqueLsa9.readFrom(channelBuffer);
- assertThat(opaqueLsa9, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- opqueHeader = new OpaqueLsaHeader();
- opqueHeader.setLsType(9);
- opqueHeader.setLsPacketLen(48);
- opqueHeader.setLsCheckSum(10);
- opqueHeader.setAge(4);
- opqueHeader.setOpaqueId(9);
- opqueHeader.setOpaqueType(9);
- opqueHeader.setLsSequenceNo(250);
- opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader.setOptions(2);
- opaqueLsa9 = new OpaqueLsa9(opqueHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- opaqueLsa9.readFrom(channelBuffer);
- result = opaqueLsa9.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getLsaBodyAsByteArray() method.
- */
- @Test
- public void testGetLsaBodyAsByteArray() throws Exception {
- opqueHeader = new OpaqueLsaHeader();
- opqueHeader.setLsType(9);
- opqueHeader.setLsPacketLen(48);
- opqueHeader.setLsCheckSum(10);
- opqueHeader.setAge(4);
- opqueHeader.setOpaqueId(9);
- opqueHeader.setOpaqueType(9);
- opqueHeader.setLsSequenceNo(250);
- opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader.setOptions(2);
- opaqueLsa9 = new OpaqueLsa9(opqueHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- opaqueLsa9.readFrom(channelBuffer);
- result = opaqueLsa9.getLsaBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashcode() throws Exception {
-
- result2 = opaqueLsa9.hashCode();
- assertThat(result2, is(notNullValue()));
-
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
-
- result1 = opaqueLsa9.toString();
- assertThat(result1, is(notNullValue()));
-
- }
-
- /**
- * Tests to getOspfLsaType() getter method.
- */
- @Test
- public void testGetOspfLsaType() throws Exception {
- opaqueLsa9.setLsType(9);
- ospflsaType = opaqueLsa9.getOspfLsaType();
- assertThat(ospflsaType, is(notNullValue()));
- assertThat(ospflsaType, is(OspfLsaType.LINK_LOCAL_OPAQUE_LSA));
- }
-}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/RouterLsaTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/RouterLsaTest.java
deleted file mode 100644
index 4611976..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/RouterLsaTest.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.subtypes.OspfLsaLink;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.*;
-
-/**
- * Unit test class for RouterLsa.
- */
-public class RouterLsaTest {
-
- private RouterLsa routerLsa;
- private int result1;
- private OspfLsaLink ospflsaLink;
- private byte[] inputArray;
- private LsaHeader lsaHeader;
- private ChannelBuffer channelBuffer;
- private byte[] result2;
- private OspfLsaType result3;
-
- @Before
- public void setUp() throws Exception {
- routerLsa = new RouterLsa();
- }
-
- @After
- public void tearDown() throws Exception {
- routerLsa = null;
- ospflsaLink = null;
- inputArray = null;
- lsaHeader = null;
- channelBuffer = null;
- result2 = null;
- result3 = null;
- }
-
-
- /**
- * Tests virtualEndPoint() setter method.
- */
- @Test
- public void testSetVirtualEndPoint() throws Exception {
- routerLsa.setVirtualEndPoint(true);
- assertThat(routerLsa, is(notNullValue()));
- }
-
-
- /**
- * Tests isAsBoundaryRouter() setter method.
- */
- @Test
- public void testSetAsBoundaryRouter() throws Exception {
- routerLsa.setAsBoundaryRouter(true);
- assertThat(routerLsa, is(notNullValue()));
- }
-
- /**
- * Tests areaBorderRouter() setter method.
- */
- @Test
- public void testSetAreaBorderRouter() throws Exception {
- routerLsa.setAreaBorderRouter(true);
- assertThat(routerLsa, is(notNullValue()));
- }
-
- /**
- * Tests noLink() getter method.
- */
- @Test
- public void testGetNoLink() throws Exception {
- routerLsa.setNoLink(10);
- result1 = routerLsa.noLink();
- assertThat(result1, is(10));
- }
-
- /**
- * Tests noLink() setter method.
- */
- @Test
- public void testSetNoLink() throws Exception {
- routerLsa.setNoLink(10);
- result1 = routerLsa.noLink();
- assertThat(result1, is(10));
- }
-
- /**
- * Tests addRouterLink() method.
- */
- @Test
- public void testAddRouterLink() throws Exception {
- routerLsa.setNoLink(0);
- ospflsaLink = createOspfLsaLink();
- routerLsa.addRouterLink(ospflsaLink);
- routerLsa.incrementLinkNo();
- result1 = routerLsa.noLink();
- assertThat(result1, is(1));
-
- }
-
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- ospflsaLink = createOspfLsaLink();
- routerLsa.addRouterLink(ospflsaLink);
- inputArray = createByteForRouterLsa();
- lsaHeader = createLsaHeader();
- routerLsa = new RouterLsa(lsaHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(inputArray);
- routerLsa.readFrom(channelBuffer);
- assertThat(routerLsa, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test(expected = Exception.class)
- public void testReadFrom1() throws Exception {
- byte[] temp = {0, 0, 0};
- ospflsaLink = createOspfLsaLink();
- routerLsa.addRouterLink(ospflsaLink);
- inputArray = temp;
- lsaHeader = createLsaHeader();
- routerLsa = new RouterLsa(lsaHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(inputArray);
- routerLsa.readFrom(channelBuffer);
- assertThat(routerLsa, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result2 = routerLsa.asBytes();
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests getLsaBodyAsByteArray() method.
- */
- @Test
- public void testGetLsaBodyAsByteArray() throws Exception {
- routerLsa.setAreaBorderRouter(true);
- routerLsa.setVirtualEndPoint(true);
- routerLsa.setAreaBorderRouter(true);
- ospflsaLink = createOspfLsaLink();
- routerLsa.addRouterLink(ospflsaLink);
- result2 = routerLsa.getLsaBodyAsByteArray();
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests getOspfLsaType() getter method.
- */
- @Test
- public void testGetOspfLsaType() throws Exception {
- routerLsa.setLsType(1);
- result3 = routerLsa.getOspfLsaType();
- assertThat(result3, is(OspfLsaType.ROUTER));
- }
-
- /**
- * Tests incrementLinkNo() method.
- */
- @Test
- public void testIncrementLinkNo() throws Exception {
- routerLsa.setNoLink(1);
- routerLsa.incrementLinkNo();
- assertThat(routerLsa.noLink(), is(2));
- }
-
- /**
- * Tests lsaHeader() method.
- */
- @Test
- public void testGetLsaHeader() throws Exception {
- lsaHeader = (LsaHeader) routerLsa.lsaHeader();
- assertThat(lsaHeader, instanceOf(RouterLsa.class));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(routerLsa.toString(), is(notNullValue()));
-
- }
-
- /**
- * Utility method used by junit methods.
- */
- private OspfLsaLink createOspfLsaLink() {
- ospflsaLink = new OspfLsaLink();
- ospflsaLink.setLinkId("10.226.165.164");
- ospflsaLink.setMetric(10);
- ospflsaLink.setTos(50);
- ospflsaLink.setLinkType(2);
- ospflsaLink.setLinkData("10.226.165.170");
- return ospflsaLink;
- }
-
- /**
- * Utility method used by junit methods.
- */
- private byte[] createByteForRouterLsa() {
- byte[] packet = {2, 1, 1, 52, -64, -88, 56, 1, -64, -88, 56, 1, 0, 100, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, -64,
- -88, 56, 1, 0, 10, 1, 1, 0, 0, 0, 40, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56,
- 1};
- return packet;
- }
-
- /**
- * Utility method used by junit methods.
- */
- private LsaHeader createLsaHeader() {
- lsaHeader = new LsaHeader();
- lsaHeader.setLsType(1);
- lsaHeader.setLsPacketLen(48);
- lsaHeader.setLsCheckSum(10);
- lsaHeader.setAge(4);
- lsaHeader.setLinkStateId("10.226.165.164");
- lsaHeader.setLsSequenceNo(250);
- lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- lsaHeader.setOptions(2);
- return lsaHeader;
- }
-
- /**
- * Tests hashcode() method.
- */
- @Test
- public void testHashcode() throws Exception {
-
- result1 = routerLsa.hashCode();
- assertThat(result1, is(notNullValue()));
-
- }
-}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/SummaryLsaTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/SummaryLsaTest.java
deleted file mode 100644
index eb06192..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/SummaryLsaTest.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.lsa.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Unit test class for SummaryLsa.
- */
-public class SummaryLsaTest {
-
- private SummaryLsa summaryLsa;
- private Ip4Address result;
- private int result1;
- private byte[] inputByteArray;
- private LsaHeader lsaHeader;
- private ChannelBuffer channelBuffer;
- private byte[] result2;
- private OspfLsaType ospflsaType;
-
- @Before
- public void setUp() throws Exception {
- summaryLsa = new SummaryLsa(new LsaHeader());
- }
-
- @After
- public void tearDown() throws Exception {
- summaryLsa = null;
- result = null;
- inputByteArray = null;
- lsaHeader = null;
- channelBuffer = null;
- result2 = null;
- ospflsaType = null;
- }
-
- /**
- * Tests networkMask() getter method.
- */
- @Test
- public void testGetNetworkMask() throws Exception {
- summaryLsa.setNetworkMask(Ip4Address.valueOf("10.226.165.164"));
- result = summaryLsa.networkMask();
- assertThat(result, is(Ip4Address.valueOf("10.226.165.164")));
- }
-
- /**
- * Tests networkMask() setter method.
- */
- @Test
- public void testSetNetworkMask() throws Exception {
- summaryLsa.setNetworkMask(Ip4Address.valueOf("10.226.165.164"));
- result = summaryLsa.networkMask();
- assertThat(result, is(Ip4Address.valueOf("10.226.165.164")));
- }
-
- /**
- * Tests metric() getter method.
- */
- @Test
- public void testGetMetric() throws Exception {
- summaryLsa.setMetric(10);
- result1 = summaryLsa.metric();
- assertThat(result1, is(10));
- }
-
- /**
- * Tests metric() setter method.
- */
- @Test
- public void testSetMetric() throws Exception {
- summaryLsa.setMetric(20);
- result1 = summaryLsa.metric();
- assertThat(result1, is(20));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- inputByteArray = createByteForNetworkLsa();
- lsaHeader = createLsaHeader();
- summaryLsa = new SummaryLsa(lsaHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
- summaryLsa.readFrom(channelBuffer);
- assertThat(summaryLsa, is(notNullValue()));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test(expected = Exception.class)
- public void testReadFrom1() throws Exception {
- byte[] temp = {0, 0, 0};
- inputByteArray = temp;
- lsaHeader = createLsaHeader();
- summaryLsa = new SummaryLsa(lsaHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(inputByteArray);
- summaryLsa.readFrom(channelBuffer);
- assertThat(summaryLsa, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result2 = summaryLsa.asBytes();
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests getLsaBodyAsByteArray() method.
- */
- @Test
- public void testGetLsaBodyAsByteArray() throws Exception {
- result2 = summaryLsa.getLsaBodyAsByteArray();
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests getOspfLsaType() getter method.
- */
- @Test
- public void testGetOspfLsaType() throws Exception {
- ospflsaType = summaryLsa.getOspfLsaType();
- assertThat(ospflsaType, is(notNullValue()));
- assertThat(ospflsaType, is(OspfLsaType.SUMMARY));
- }
-
- /**
- * Utility method used by junit methods.
- */
- private byte[] createByteForNetworkLsa() {
- byte[] packet = {2, 1, 1, 52, -64, -88, 56, 1, -64, -88, 56, 1, 0, 100, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, -64,
- -88, 56, 1, 0, 10, 1, 1, 0, 0, 0, 40, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56,
- 1};
- return packet;
- }
-
- /**
- * Utility method used by junit methods.
- */
- private LsaHeader createLsaHeader() {
- lsaHeader = new LsaHeader();
- lsaHeader.setLsType(3);
- lsaHeader.setLsPacketLen(48);
- lsaHeader.setLsCheckSum(10);
- lsaHeader.setAge(4);
- lsaHeader.setLinkStateId("10.226.165.164");
- lsaHeader.setLsSequenceNo(250);
- lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- lsaHeader.setOptions(2);
- return lsaHeader;
- }
-
- /**
- * Tests hashcode() method.
- */
- @Test
- public void testHashcode() throws Exception {
-
- result1 = summaryLsa.hashCode();
- assertThat(result1, is(notNullValue()));
-
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReaderTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReaderTest.java
deleted file mode 100644
index 8cf0aef..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReaderTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.ospf.protocol.util.OspfUtil;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for OspfMessageReader.
- */
-
-public class OspfMessageReaderTest {
-
- private final byte[] packet1 = {2, 1, 0, 44, -64, -88, -86, 8,
- 0, 0, 0, 1, 39, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0,
- 10, 2, 1, 0, 0, 0, 40, -64, -88, -86, 8, 0, 0, 0, 0};
- private final byte[] packet2 = {2, 2, 0, 52, -64, -88, -86, 8, 0,
- 0, 0, 1, -96, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, -36, 2, 7, 65, 119,
- -87, 126, 0, 23, 2, 1, 10, 10, 10, 10, 10, 10, 10, 10, -128, 0, 0, 6,
- -69, 26, 0, 36};
- private final byte[] packet3 = {2, 3, 0, 36, -64, -88, -86, 3, 0,
- 0, 0, 1, -67, -57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -64, -88,
- -86, 8, -64, -88, -86, 8};
- private final byte[] packet4 = {2, 4, 1, 36, -64, -88, -86, 3, 0,
- 0, 0, 1, 54, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
- 2, 2, 1, -64, -88, -86, 3, -64, -88, -86, 3, -128, 0,
- 0, 1, 58, -100, 0, 48, 2, 0, 0, 2, -64, -88, -86,
- 0, -1, -1, -1, 0, 3, 0, 0, 10, -64, -88, -86, 0,
- -1, -1, -1, 0, 3, 0, 0, 10, 0, 3, 2, 5, 80, -44,
- 16, 0, -64, -88, -86, 2, -128, 0, 0, 1, 42, 73, 0,
- 36, -1, -1, -1, -1, -128, 0, 0, 20, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 3, 2, 5, -108, 121, -85, 0, -64, -88,
- -86, 2, -128, 0, 0, 1, 52, -91, 0, 36, -1, -1, -1,
- 0, -128, 0, 0, 20, -64, -88, -86, 1, 0, 0, 0, 0, 0,
- 3, 2, 5, -64, -126, 120, 0, -64, -88, -86, 2, -128, 0,
- 0, 1, -45, 25, 0, 36, -1, -1, -1, 0, -128, 0, 0, 20,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -64, -88, 0, 0,
- -64, -88, -86, 2, -128, 0, 0, 1, 55, 8, 0, 36, -1, -1,
- -1, 0, -128, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 3, 2, 5, -64, -88, 1, 0, -64, -88, -86, 2, -128, 0, 0,
- 1, 44, 18, 0, 36, -1, -1, -1, 0, -128, 0, 0, 20, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -64, -88, -84, 0, -64,
- -88, -86, 2, -128, 0, 0, 1, 51, 65, 0, 36, -1, -1, -1, 0,
- -128, 0, 0, 20, -64, -88, -86, 10, 0, 0, 0, 0};
- private final byte[] packet5 = {2, 5, 0, 44, -64, -88, -86, 8, 0, 0,
- 0, 1, -30, -12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 16, 2, 1, -64, -88, -86,
- 2, -64, -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48};
- private OspfMessageReader ospfMessageReader;
- private ChannelBuffer channelBuffer;
-
- @Before
- public void setUp() throws Exception {
- ospfMessageReader = new OspfMessageReader();
- }
-
- @After
- public void tearDown() throws Exception {
- ospfMessageReader = null;
- channelBuffer = null;
- }
-
- /**
- * Tests readFromBuffer() method.
- */
- @Test
- public void testReadFromBuffer() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet1));
- ospfMessageReader.readFromBuffer(channelBuffer);
-
- channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet2));
- ospfMessageReader.readFromBuffer(channelBuffer);
-
- channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet3));
- ospfMessageReader.readFromBuffer(channelBuffer);
-
- channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet4));
- ospfMessageReader.readFromBuffer(channelBuffer);
-
- channelBuffer = ChannelBuffers.copiedBuffer(framePacket(packet5));
- ospfMessageReader.readFromBuffer(channelBuffer);
- assertThat(ospfMessageReader, is(notNullValue()));
- }
-
- /**
- * Frames the packet to min frame length.
- *
- * @param ospfPacket OSPF packet
- * @return OSPF packet as byte array
- */
- private byte[] framePacket(byte[] ospfPacket) {
- //Set the length of the packet
- //Get the total length of the packet
- int length = ospfPacket.length;
- //PDU_LENGTH + 1 byte for interface index
- if (length < OspfUtil.MINIMUM_FRAME_LEN) {
- byte[] bytes = new byte[OspfUtil.MINIMUM_FRAME_LEN + 5];
- System.arraycopy(ospfPacket, 0, bytes, 0, length);
- return bytes;
- }
- return ospfPacket;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriterTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriterTest.java
deleted file mode 100644
index 94f8702..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageWriterTest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for OspfMessageWriter.
- */
-public class OspfMessageWriterTest {
-
- private OspfMessageWriter ospfMessageWriter;
- private HelloPacket helloPacket;
- private DdPacket ddPacket;
- private LsAcknowledge lsAck;
- private LsRequest lsReq;
- private LsUpdate lsUpdate;
-
- @Before
- public void setUp() throws Exception {
- ospfMessageWriter = new OspfMessageWriter();
- }
-
- @After
- public void tearDown() throws Exception {
- ospfMessageWriter = null;
- helloPacket = null;
- ddPacket = null;
- lsAck = null;
- lsReq = null;
- lsUpdate = null;
- }
-
- /**
- * Tests getMessage() method.
- */
- @Test
- public void testGetMessage() throws Exception {
- helloPacket = new HelloPacket();
- helloPacket.setAuthType(1);
- helloPacket.setOspftype(1);
- helloPacket.setRouterId(Ip4Address.valueOf("10.226.165.164"));
- helloPacket.setAreaId(Ip4Address.valueOf("10.226.165.100"));
- helloPacket.setChecksum(201);
- helloPacket.setAuthentication(2);
- helloPacket.setOspfPacLength(48);
- helloPacket.setOspfVer(2);
- helloPacket.setNetworkMask(Ip4Address.valueOf("255.255.255.255"));
- helloPacket.setOptions(2); //not setting now
- helloPacket.setHelloInterval(10);
- helloPacket.setRouterPriority(1);
- helloPacket.setRouterDeadInterval(40);
- helloPacket.setDr(Ip4Address.valueOf("1.1.1.1"));
- helloPacket.setBdr(Ip4Address.valueOf("2.2.2.2"));
- helloPacket.addNeighbor(Ip4Address.valueOf("8.8.8.8"));
- helloPacket.setDestinationIp(Ip4Address.valueOf("5.5.5.5"));
- ospfMessageWriter.getMessage(helloPacket, 7, 1);
- assertThat(ospfMessageWriter, is(notNullValue()));
- }
-
- @Test(expected = Exception.class)
- public void testGetMessage1() throws Exception {
-
- ddPacket = new DdPacket();
- ddPacket.setAuthType(1);
- ddPacket.setOspftype(2);
- ddPacket.setRouterId(Ip4Address.valueOf("10.226.165.164"));
- ddPacket.setAreaId(Ip4Address.valueOf("10.226.165.100"));
- ddPacket.setChecksum(201);
- ddPacket.setAuthentication(2);
- ddPacket.setOspfPacLength(48);
- ddPacket.setOspfVer(2);
- ospfMessageWriter.getMessage(ddPacket, 1, 1);
- assertThat(ospfMessageWriter, is(notNullValue()));
- }
-
- @Test(expected = Exception.class)
- public void testGetMessage2() throws Exception {
-
- lsAck = new LsAcknowledge();
- lsAck.setAuthType(1);
- lsAck.setOspftype(5);
- lsAck.setRouterId(Ip4Address.valueOf("10.226.165.164"));
- lsAck.setAreaId(Ip4Address.valueOf("10.226.165.100"));
- lsAck.setChecksum(201);
- lsAck.setAuthentication(2);
- lsAck.setOspfPacLength(48);
- lsAck.setOspfVer(2);
- ospfMessageWriter.getMessage(lsAck, 1, 1);
- assertThat(ospfMessageWriter, is(notNullValue()));
- }
-
- @Test(expected = Exception.class)
- public void testGetMessage3() throws Exception {
- lsReq = new LsRequest();
- lsReq.setAuthType(1);
- lsReq.setOspftype(3);
- lsReq.setRouterId(Ip4Address.valueOf("10.226.165.164"));
- lsReq.setAreaId(Ip4Address.valueOf("10.226.165.100"));
- lsReq.setChecksum(201);
- lsReq.setAuthentication(2);
- lsReq.setOspfPacLength(48);
- lsReq.setOspfVer(2);
- ospfMessageWriter.getMessage(lsReq, 1, 1);
- assertThat(ospfMessageWriter, is(notNullValue()));
- }
-
- /**
- * Tests getMessage() method.
- */
- @Test(expected = Exception.class)
- public void testGetMessage4() throws Exception {
- lsUpdate = new LsUpdate();
- lsUpdate.setAuthType(1);
- lsUpdate.setOspftype(3);
- lsUpdate.setRouterId(Ip4Address.valueOf("10.226.165.164"));
- lsUpdate.setAreaId(Ip4Address.valueOf("10.226.165.100"));
- lsUpdate.setChecksum(201);
- lsUpdate.setAuthentication(2);
- lsUpdate.setOspfPacLength(48);
- lsUpdate.setOspfVer(2);
- ospfMessageWriter.getMessage(lsUpdate, 1, 1);
- assertThat(ospfMessageWriter, is(notNullValue()));
- }
-
- /**
- * Tests getMessage() method.
- */
- @Test(expected = Exception.class)
- public void testGetMessage5() throws Exception {
- lsAck = new LsAcknowledge();
- lsAck.setAuthType(1);
- lsAck.setOspftype(5);
- lsAck.setRouterId(Ip4Address.valueOf("10.226.165.164"));
- lsAck.setAreaId(Ip4Address.valueOf("10.226.165.100"));
- lsAck.setChecksum(201);
- lsAck.setAuthentication(2);
- lsAck.setOspfPacLength(48);
- lsAck.setOspfVer(2);
- ospfMessageWriter.getMessage(lsAck, 1, 1);
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfPacketHeaderTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfPacketHeaderTest.java
deleted file mode 100644
index e4852a1..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfPacketHeaderTest.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for OspfPacketHeader.
- */
-public class OspfPacketHeaderTest {
-
- private final byte[] packet = {0, 0, 0, 0};
- private OspfPacketHeader ospfPacketHeader;
- private ChannelBuffer channelBuffer;
- private byte[] result2;
- private int result;
- private Ip4Address result1;
-
- @Before
- public void setUp() throws Exception {
- ospfPacketHeader = new OspfPacketHeader();
- }
-
- @After
- public void tearDown() throws Exception {
- ospfPacketHeader = null;
- ospfPacketHeader = null;
- channelBuffer = null;
- result2 = null;
- result1 = null;
- }
-
- /**
- * Tests sourceIp() getter method.
- */
- @Test
- public void testGetSourceIP() throws Exception {
- ospfPacketHeader.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- assertThat(ospfPacketHeader.sourceIp(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests sourceIp() setter method.
- */
- @Test
- public void testSetSourceIP() throws Exception {
- ospfPacketHeader.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
- assertThat(result, is(notNullValue()));
- assertThat(ospfPacketHeader.sourceIp(), is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests ospfMessageType() getter method.
- */
- @Test
- public void testGetOspfMessageType() throws Exception {
- assertThat(ospfPacketHeader.ospfMessageType(), nullValue());
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- ospfPacketHeader.readFrom(channelBuffer);
- assertThat(ospfPacketHeader, is(notNullValue()));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result2 = ospfPacketHeader.asBytes();
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests ospfVersion() getter method.
- */
- @Test
- public void testGetOspfVer() throws Exception {
- ospfPacketHeader.setOspfVer(2);
- result = ospfPacketHeader.ospfVersion();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(2));
- }
-
- /**
- * Tests ospfVersion() setter method.
- */
- @Test
- public void testSetOspfVer() throws Exception {
- ospfPacketHeader.setOspfVer(2);
- result = ospfPacketHeader.ospfVersion();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(2));
- }
-
- /**
- * Tests ospfType() getter method.
- */
- @Test
- public void testGetOspfType() throws Exception {
- ospfPacketHeader.setOspftype(3);
- result = ospfPacketHeader.ospfType();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(3));
- }
-
- /**
- * Tests ospfType() setter method.
- */
- @Test
- public void testSetOspfType() throws Exception {
- ospfPacketHeader.setOspftype(3);
- result = ospfPacketHeader.ospfType();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(3));
- }
-
- /**
- * Tests ospfPacLength() getter method.
- */
- @Test
- public void testGetOspfPacLength() throws Exception {
- ospfPacketHeader.setOspfPacLength(3);
- result = ospfPacketHeader.ospfPacLength();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(3));
- }
-
- /**
- * Tests ospfPacLength() setter method.
- */
- @Test
- public void testSetOspfPacLength() throws Exception {
- ospfPacketHeader.setOspfPacLength(3);
- int result = ospfPacketHeader.ospfPacLength();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(3));
- }
-
- /**
- * Tests routerId()getter method.
- */
- @Test
- public void testGetRouterId() throws Exception {
-
- ospfPacketHeader.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- result1 = ospfPacketHeader.routerId();
- assertThat(result1, is(notNullValue()));
- assertThat(result1, is(Ip4Address.valueOf("1.1.1.1")));
-
- }
-
- /**
- * Tests routerId() setter method.
- */
- @Test
- public void testSetRouterId() throws Exception {
- ospfPacketHeader.setRouterId(Ip4Address.valueOf("1.1.1.1"));
- result1 = ospfPacketHeader.routerId();
- assertThat(result1, is(notNullValue()));
- assertThat(result1, is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests areaId() getter method.
- */
- @Test
- public void testGetAreaId() throws Exception {
- ospfPacketHeader.setAreaId(Ip4Address.valueOf("1.1.1.1"));
- result1 = ospfPacketHeader.areaId();
- assertThat(result1, is(notNullValue()));
- assertThat(result1, is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests areaId() setter method.
- */
- @Test
- public void testSetAreaId() throws Exception {
- ospfPacketHeader.setAreaId(Ip4Address.valueOf("1.1.1.1"));
- result1 = ospfPacketHeader.areaId();
- assertThat(result1, is(notNullValue()));
- assertThat(result1, is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests checksum() getter method.
- */
- @Test
- public void testGetChecksum() throws Exception {
- ospfPacketHeader.setChecksum(3);
- result = ospfPacketHeader.checksum();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(3));
- }
-
- /**
- * Tests checksum() setter method.
- */
- @Test
- public void testSetChecksum() throws Exception {
- ospfPacketHeader.setChecksum(3);
- result = ospfPacketHeader.checksum();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(3));
- }
-
- /**
- * Tests authType() getter method.
- */
- @Test
- public void testGetAutype() throws Exception {
- ospfPacketHeader.setAuthType(3);
- result = ospfPacketHeader.authType();
- Assert.assertNotNull(result);
- Assert.assertEquals(3, result);
- }
-
- /**
- * Tests authType() setter method.
- */
- @Test
- public void testSetAutype() throws Exception {
- ospfPacketHeader.setAuthType(3);
- result = ospfPacketHeader.authType();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(3));
- }
-
- /**
- * Tests authentication() getter method.
- */
- @Test
- public void testGetAuthentication() throws Exception {
- ospfPacketHeader.setAuthentication(3);
- result = ospfPacketHeader.authentication();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(3));
- }
-
- /**
- * Tests authentication() setter method.
- */
- @Test
- public void testSetAuthentication() throws Exception {
- ospfPacketHeader.setAuthentication(3);
- result = ospfPacketHeader.authentication();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(3));
- }
-
- /**
- * Tests destinationIp() getter method.
- */
- @Test
- public void testGetDestinationIP() throws Exception {
- ospfPacketHeader.setDestinationIp(Ip4Address.valueOf("1.1.1.1"));
- result1 = ospfPacketHeader.destinationIp();
- assertThat(result1, is(notNullValue()));
- assertThat(result1, is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests destinationIp() setter method.
- */
- @Test
- public void testSetDestinationIP() throws Exception {
- ospfPacketHeader.setDestinationIp(Ip4Address.valueOf("1.1.1.1"));
- result1 = ospfPacketHeader.destinationIp();
- assertThat(result1, is(notNullValue()));
- assertThat(result1, is(Ip4Address.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(ospfPacketHeader.toString(), is(notNullValue()));
- }
-
- /**
- * Tests populateHeader() method.
- */
- @Test
- public void testPopulateHeader() throws Exception {
- ospfPacketHeader.populateHeader(new OspfPacketHeader());
- assertThat(ospfPacketHeader, is(notNullValue()));
- }
-
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/subtype/LsRequestPacketTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/subtype/LsRequestPacketTest.java
deleted file mode 100644
index 34809d6..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/subtype/LsRequestPacketTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket.subtype;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for LsRequestPacket.
- */
-public class LsRequestPacketTest {
-
- private LsRequestPacket lsrPacket;
- private int result;
-
- @Before
- public void setUp() throws Exception {
- lsrPacket = new LsRequestPacket();
- }
-
- @After
- public void tearDown() throws Exception {
- lsrPacket = null;
- }
-
- /**
- * Tests lsType() getter method.
- */
- @Test
- public void testGetLsType() throws Exception {
- lsrPacket.setLsType(1);
- assertThat(lsrPacket.lsType(), is(1));
- }
-
- /**
- * Tests lsType() setter method.
- */
- @Test
- public void testSetLsType() throws Exception {
- lsrPacket.setLsType(1);
- assertThat(lsrPacket.lsType(), is(1));
- }
-
- /**
- * Tests linkStateId() getter method.
- */
- @Test
- public void testGetLinkStateId() throws Exception {
- lsrPacket.setLinkStateId("1.1.1.1");
- assertThat(lsrPacket.linkStateId(), is("1.1.1.1"));
- }
-
- /**
- * Tests linkStateId() setter method.
- */
- @Test
- public void testSetLinkStateId() throws Exception {
- lsrPacket.setLinkStateId("1.1.1.1");
- assertThat(lsrPacket.linkStateId(), is("1.1.1.1"));
- }
-
- /**
- * Tests ownRouterId() getter method.
- */
- @Test
- public void testGetOwnRouterId() throws Exception {
- lsrPacket.setOwnRouterId("1.1.1.1");
- assertThat(lsrPacket.ownRouterId(), is("1.1.1.1"));
- }
-
- /**
- * Tests ownRouterId() setter method.
- */
- @Test
- public void testSetOwnRouterId() throws Exception {
- lsrPacket.setOwnRouterId("1.1.1.1");
- assertThat(lsrPacket.ownRouterId(), is("1.1.1.1"));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(lsrPacket.toString(), is(notNullValue()));
- }
-
- /**
- * Tests equals() method.
- */
- @Test
- public void testEquals() throws Exception {
- assertThat(lsrPacket.equals(new LsRequestPacket()), is(false));
- }
-
- /**
- * Tests hashCode() method.
- */
- @Test
- public void testHashCode() throws Exception {
- result = lsrPacket.hashCode();
- assertThat(result, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/DdPacketTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/DdPacketTest.java
deleted file mode 100644
index 166cffa..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/DdPacketTest.java
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfPacketType;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-
-import java.util.List;
-import java.util.Vector;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for OspfRouterId.
- */
-public class DdPacketTest {
-
- private byte[] packet;
- private byte[] result2;
- private DdPacket ddPacket;
- private Vector<LsaHeader> lsaHeaderList = new Vector<LsaHeader>();
- private int result;
- private long result1;
- private OpaqueLsaHeader opqueHeader;
- private OpaqueLsaHeader opqueHeader1;
- private List<LsaHeader> header;
- private OspfPacketHeader ospfPacketHeader;
- private ChannelBuffer channelBuffer;
- private LsaHeader lsaHeader;
- private long result3;
- private OspfPacketType ospfPacketType;
-
- @Before
- public void setUp() throws Exception {
- ddPacket = new DdPacket();
- ddPacket.setAuthType(1);
- ddPacket.setOspftype(2);
- ddPacket.setRouterId(Ip4Address.valueOf("10.226.165.164"));
- ddPacket.setAreaId(Ip4Address.valueOf("10.226.165.100"));
- ddPacket.setChecksum(201);
- ddPacket.setAuthentication(2);
- ddPacket.setOspfPacLength(48);
- ddPacket.setOspfVer(2);
- }
-
- @After
- public void tearDown() throws Exception {
- ddPacket = null;
- lsaHeaderList.clear();
- opqueHeader = null;
- opqueHeader1 = null;
- header = null;
- ospfPacketHeader = null;
- channelBuffer = null;
- lsaHeader = null;
- ospfPacketType = null;
- }
-
- /**
- * Tests isOpaqueCapable() getter method.
- */
- @Test
- public void testIsOpaqueCapable() throws Exception {
- ddPacket.setIsOpaqueCapable(true);
- assertThat(ddPacket.isOpaqueCapable(), is(true));
- }
-
- /**
- * Tests isOpaqueCapable() setter method.
- */
- @Test
- public void testSetIsOpaqueCapable() throws Exception {
- ddPacket.setIsOpaqueCapable(true);
- assertThat(ddPacket.isOpaqueCapable(), is(true));
- }
-
- /**
- * Tests ims() getter method.
- */
- @Test
- public void testGetIms() throws Exception {
- ddPacket.setIms(1);
- result = ddPacket.ims();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(1));
- }
-
- /**
- * Tests ims() setter method.
- */
- @Test
- public void testSetIms() throws Exception {
- ddPacket.setIms(1);
- result = ddPacket.ims();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(1));
- }
-
- /**
- * Tests isMaster() getter method.
- */
- @Test
- public void testGetIsMaster() throws Exception {
- ddPacket.setIsMaster(2);
- result = ddPacket.isMaster();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(2));
- }
-
- /**
- * Tests isMaster() setter method.
- */
- @Test
- public void testSetIsMaster() throws Exception {
- ddPacket.setIsMaster(2);
- result = ddPacket.isMaster();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(2));
- }
-
- /**
- * Tests isInitialize() getter method.
- */
- @Test
- public void testGetIsInitialize() throws Exception {
- ddPacket.setIsInitialize(3);
- result = ddPacket.isInitialize();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(3));
- }
-
- /**
- * Tests isInitialize() setter method.
- */
- @Test
- public void testSetIsInitialize() throws Exception {
- ddPacket.setIsInitialize(3);
- int result = ddPacket.isInitialize();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(3));
- }
-
- /**
- * Tests isMore() getter method.
- */
- @Test
- public void testGetIsMore() throws Exception {
- ddPacket.setIsMore(4);
- result = ddPacket.isMore();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(4));
- }
-
- /**
- * Tests isMore() setter method.
- */
- @Test
- public void testSetIsMore() throws Exception {
- ddPacket.setIsMore(4);
- int result = ddPacket.isMore();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(4));
- }
-
- /**
- * Tests imtu() getter method.
- */
- @Test
- public void testGetImtu() throws Exception {
- ddPacket.setImtu(5);
- result = ddPacket.imtu();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(5));
- }
-
- /**
- * Tests imtu() setter method.
- */
- @Test
- public void testSetImtu() throws Exception {
- ddPacket.setImtu(5);
- result = ddPacket.imtu();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(5));
- }
-
- /**
- * Tests options() getter method.
- */
- @Test
- public void testGetOptions() throws Exception {
- ddPacket.setOptions(2);
- result = ddPacket.options();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(2));
- }
-
- /**
- * Tests options() setter method.
- */
- @Test
- public void testSetOptions() throws Exception {
- ddPacket.setOptions(2);
- result = ddPacket.options();
- Assert.assertNotNull(result);
- Assert.assertEquals(2, result);
- }
-
- /**
- * Tests sequenceNo() getter method.
- */
- @Test
- public void testGetSequenceno() throws Exception {
- ddPacket.setSequenceNo(2020);
- result1 = ddPacket.sequenceNo();
- assertThat(result1, is(notNullValue()));
- assertThat(result1, is(2020L));
- }
-
- /**
- * Tests sequenceNo() setter method.
- */
- @Test
- public void testSetSequenceno() throws Exception {
- ddPacket.setSequenceNo(2020);
- result3 = ddPacket.sequenceNo();
- assertThat(result3, is(notNullValue()));
- assertThat(result3, is(2020L));
- }
-
- /**
- * Tests getLsaHeaderList() getter method.
- */
- @Test
- public void testGetLsaHeaderList() throws Exception {
- ddPacket.addLsaHeader(createLsaHeader());
- opqueHeader = new OpaqueLsaHeader();
- opqueHeader.setLsType(9);
- opqueHeader.setLsPacketLen(48);
- opqueHeader.setLsCheckSum(10);
- opqueHeader.setAge(4);
- opqueHeader.setOpaqueId(9);
- opqueHeader.setOpaqueType(9);
- opqueHeader.setLsSequenceNo(250);
- opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader.setOptions(2);
- ddPacket.setIsOpaqueCapable(true);
- ddPacket.addLsaHeader(opqueHeader);
- opqueHeader1 = new OpaqueLsaHeader();
- opqueHeader1.setLsType(10);
- opqueHeader1.setLsPacketLen(48);
- opqueHeader1.setLsCheckSum(10);
- opqueHeader1.setAge(4);
- opqueHeader1.setOpaqueId(9);
- opqueHeader1.setOpaqueType(9);
- opqueHeader1.setLsSequenceNo(250);
- opqueHeader1.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader1.setOptions(66);
- ddPacket.addLsaHeader(opqueHeader1);
- header = ddPacket.getLsaHeaderList();
- assertThat(header, is(notNullValue()));
- }
-
- /**
- * Tests getLsaHeaderList() setter method.
- */
- @Test
- public void testSetLsaHeaderList() throws Exception {
- ddPacket.addLsaHeader(createLsaHeader());
- opqueHeader = new OpaqueLsaHeader();
- opqueHeader.setLsType(9);
- opqueHeader.setLsPacketLen(48);
- opqueHeader.setLsCheckSum(10);
- opqueHeader.setAge(4);
- opqueHeader.setOpaqueId(9);
- opqueHeader.setOpaqueType(9);
- opqueHeader.setLsSequenceNo(250);
- opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader.setOptions(66);
- ddPacket.addLsaHeader(opqueHeader);
- opqueHeader1 = new OpaqueLsaHeader();
- opqueHeader1.setLsType(10);
- opqueHeader1.setLsPacketLen(48);
- opqueHeader1.setLsCheckSum(10);
- opqueHeader1.setAge(4);
- opqueHeader1.setOpaqueId(9);
- opqueHeader1.setOpaqueType(9);
- opqueHeader1.setLsSequenceNo(250);
- opqueHeader1.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader1.setOptions(2);
- ddPacket.addLsaHeader(opqueHeader1);
- header = ddPacket.getLsaHeaderList();
- assertThat(header.contains(createLsaHeader()), is(true));
- }
-
- /**
- * Tests addLsaHeader() method.
- */
- @Test
- public void testAddLsaHeader() throws Exception {
- ddPacket.addLsaHeader(createLsaHeader());
- assertThat(ddPacket, is(notNullValue()));
- }
-
- /**
- * Tests ospfMessageType() getter method.
- */
- @Test
- public void testGetOspfMessageType() throws Exception {
- ospfPacketType = ddPacket.ospfMessageType();
- assertThat(ospfPacketType, is(notNullValue()));
- assertThat(ospfPacketType, is(OspfPacketType.DD));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- ospfPacketHeader = new OspfPacketHeader();
- ospfPacketHeader.setAreaId(Ip4Address.valueOf("1.1.1.1"));
- ospfPacketHeader.setAuthentication(0);
- ospfPacketHeader.setAuthType(0);
- ospfPacketHeader.setChecksum(12345);
- ospfPacketHeader.setDestinationIp(Ip4Address.valueOf("10.10.10.10"));
- ospfPacketHeader.setOspfPacLength(56);
- ospfPacketHeader.setOspftype(2);
- ospfPacketHeader.setOspfVer(2);
- ospfPacketHeader.setRouterId(Ip4Address.valueOf("2.2.2.2"));
- ospfPacketHeader.setSourceIp(Ip4Address.valueOf("3.3.3.3"));
- ddPacket.setIsOpaqueCapable(true);
- ddPacket.setOptions(66);
- ddPacket = new DdPacket(ospfPacketHeader);
- packet = createByteForDdPacket();
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- ddPacket.readFrom(channelBuffer);
- assertThat(ddPacket, is(notNullValue()));
- assertThat(ddPacket.ospfMessageType(), is(OspfPacketType.DD));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result2 = ddPacket.asBytes();
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests getDdHeaderAsByteArray() method.
- */
- @Test
- public void testGetDdHeaderAsByteArray() throws Exception {
- opqueHeader = new OpaqueLsaHeader();
- opqueHeader.setLsType(9);
- opqueHeader.setLsPacketLen(48);
- opqueHeader.setLsCheckSum(10);
- opqueHeader.setAge(4);
- opqueHeader.setOpaqueId(9);
- opqueHeader.setOpaqueType(9);
- opqueHeader.setLsSequenceNo(250);
- opqueHeader.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader.setOptions(66);
- ddPacket.addLsaHeader(opqueHeader);
- opqueHeader1 = new OpaqueLsaHeader();
- opqueHeader1.setLsType(10);
- opqueHeader1.setLsPacketLen(48);
- opqueHeader1.setLsCheckSum(10);
- opqueHeader1.setAge(4);
- opqueHeader1.setOpaqueId(9);
- opqueHeader1.setOpaqueType(9);
- opqueHeader1.setLsSequenceNo(250);
- opqueHeader1.setAdvertisingRouter(Ip4Address.valueOf("100.226.165.165"));
- opqueHeader1.setOptions(2);
- ddPacket.addLsaHeader(opqueHeader1);
- result2 = ddPacket.getDdHeaderAsByteArray();
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests getDdBodyAsByteArray() method.
- */
- @Test
- public void testGetDdBodyAsByteArray() throws Exception {
- lsaHeader = createLsaHeader();
- ddPacket.addLsaHeader(lsaHeader);
- result2 = ddPacket.getDdBodyAsByteArray();
- assertThat(result2, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(ddPacket.toString(), is(notNullValue()));
- }
-
- /**
- * Utility method used by junit methods.
- */
- private LsaHeader createLsaHeader() {
- lsaHeader = new LsaHeader();
- lsaHeader.setAge(10);
- lsaHeader.setLinkStateId("10.226.165.164");
- lsaHeader.setLsCheckSum(222);
- lsaHeader.setLsPacketLen(48);
- lsaHeader.setLsSequenceNo(2020);
- lsaHeader.setLsType(2);
- lsaHeader.setOptions(2);
- lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("10.226.165.165"));
- return lsaHeader;
- }
-
- /**
- * Utility method used by junit methods.
- */
- private byte[] createByteForDdPacket() {
- byte[] ddPacket = {5, -36, 66, 1, 65, 119, -87, 126, 0, 23, 2, 1, 10, 10,
- 10, 10, 10, 10, 10, 10, -128, 0, 0, 6, -69, 26, 0, 36};
-
- return ddPacket;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/HelloPacketTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/HelloPacketTest.java
deleted file mode 100644
index f4dd79e..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/HelloPacketTest.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfPacketType;
-import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-
-import java.util.Vector;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for HelloPacket.
- */
-public class HelloPacketTest {
-
- private boolean result1;
- private OspfPacketType ospfPacketType;
- private OspfPacketHeader ospfPacketHeader;
- private HelloPacket helloPacket;
- private Vector<String> neighborAddress = new Vector();
- private Ip4Address result;
- private int result2;
- private byte[] packet;
- private ChannelBuffer channelBuffer;
- private byte[] result3;
-
- @Before
- public void setUp() throws Exception {
- helloPacket = new HelloPacket();
- helloPacket.setAuthType(1);
- helloPacket.setOspftype(2);
- helloPacket.setRouterId(Ip4Address.valueOf("10.226.165.164"));
- helloPacket.setAreaId(Ip4Address.valueOf("10.226.165.100"));
- helloPacket.setChecksum(201);
- helloPacket.setAuthentication(2);
- helloPacket.setOspfPacLength(48);
- helloPacket.setOspfVer(2);
-
- }
-
- @After
- public void tearDown() throws Exception {
- helloPacket = null;
- result = null;
- ospfPacketType = null;
- ospfPacketHeader = null;
- packet = null;
- channelBuffer = null;
- result3 = null;
- }
-
- /**
- * Tests networkMask() getter method.
- */
- @Test
- public void testGetNetworkMask() throws Exception {
- helloPacket.setNetworkMask(Ip4Address.valueOf("10.226.165.164"));
- result = helloPacket.networkMask();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(Ip4Address.valueOf("10.226.165.164")));
- }
-
- /**
- * Tests networkMask() setter method.
- */
- @Test
- public void testSetNetworkMask() throws Exception {
- helloPacket.setNetworkMask(Ip4Address.valueOf("10.226.165.164"));
- result = helloPacket.networkMask();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(Ip4Address.valueOf("10.226.165.164")));
- }
-
- /**
- * Tests bdr() setter method.
- */
- @Test
- public void testSetBdr() throws Exception {
- helloPacket.setBdr(Ip4Address.valueOf("10.226.165.166"));
- result = helloPacket.bdr();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(Ip4Address.valueOf("10.226.165.166")));
- }
-
- /**
- * Tests dr() getter method.
- */
- @Test
- public void testGetDr() throws Exception {
- helloPacket.setDr(Ip4Address.valueOf("10.226.165.167"));
- result = helloPacket.dr();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(Ip4Address.valueOf("10.226.165.167")));
- }
-
- /**
- * Tests dr() setter method.
- */
- @Test
- public void testSetDr() throws Exception {
- helloPacket.setDr(Ip4Address.valueOf("10.226.165.167"));
- result = helloPacket.dr();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(Ip4Address.valueOf("10.226.165.167")));
- }
-
- /**
- * Tests addNeighbor() method.
- */
- @Test
- public void testAddNeighbor() throws Exception {
- helloPacket.addNeighbor(Ip4Address.valueOf("10.226.165.170"));
- result1 = helloPacket.containsNeighbour(Ip4Address.valueOf("10.226.165.170"));
- assertThat(result1, is(true));
- }
-
- /**
- * Tests containsNeighbour() method.
- */
- @Test
- public void testContainsNeighbour() throws Exception {
- helloPacket.addNeighbor(Ip4Address.valueOf("10.226.165.200"));
- result1 = helloPacket.containsNeighbour(Ip4Address.valueOf("10.226.165.200"));
- assertThat(result1, is(true));
- }
-
-
- /**
- * Tests options() getter method.
- */
- @Test
- public void testGetOptions() throws Exception {
- helloPacket.setOptions(10);
- result2 = helloPacket.options();
- assertThat(result2, is(notNullValue()));
- assertThat(result2, is(10));
- }
-
- /**
- * Tests options() setter method.
- */
- @Test
- public void testSetOptions() throws Exception {
- helloPacket.setOptions(11);
- result2 = helloPacket.options();
- assertThat(result2, is(notNullValue()));
- assertThat(result2, is(11));
- }
-
- /**
- * Tests routerPriority() getter method.
- */
- @Test
- public void testGetRouterPriority() throws Exception {
- helloPacket.setRouterPriority(1);
- result2 = helloPacket.routerPriority();
- assertThat(result2, is(notNullValue()));
- assertThat(result2, is(1));
- }
-
- /**
- * Tests routerPriority() setter method.
- */
- @Test
- public void testSetRouterPriority() throws Exception {
- helloPacket.setRouterPriority(2);
- result2 = helloPacket.routerPriority();
- assertThat(result2, is(notNullValue()));
- assertThat(result2, is(2));
- }
-
- /**
- * Tests helloInterval() getter method.
- */
- @Test
- public void testGetHelloInterval() throws Exception {
- helloPacket.setHelloInterval(10);
- result2 = helloPacket.helloInterval();
- assertThat(result2, is(notNullValue()));
- assertThat(result2, is(10));
- }
-
- /**
- * Tests helloInterval() setter method.
- */
- @Test
- public void testSetHelloInterval() throws Exception {
- helloPacket.setHelloInterval(10);
- result2 = helloPacket.helloInterval();
- assertThat(result2, is(notNullValue()));
- assertThat(result2, is(10));
- }
-
- /**
- * Tests routerDeadInterval() getter method.
- */
- @Test
- public void testGetRouterDeadInterval() throws Exception {
- helloPacket.setRouterDeadInterval(50);
- result2 = helloPacket.routerDeadInterval();
- assertThat(result2, is(notNullValue()));
- assertThat(result2, is(50));
- }
-
- /**
- * Tests routerDeadInterval() setter method.
- */
- @Test
- public void testSetRouterDeadInterval() throws Exception {
- helloPacket.setRouterDeadInterval(50);
- result2 = helloPacket.routerDeadInterval();
- assertThat(result2, is(notNullValue()));
- assertThat(result2, is(50));
- }
-
- /**
- * Tests ospfMessageType() getter method.
- */
- @Test
- public void testGetOspfMessageType() throws Exception {
- ospfPacketType = helloPacket.ospfMessageType();
- assertThat(ospfPacketType, is(notNullValue()));
- assertThat(ospfPacketType, is(OspfPacketType.HELLO));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- ospfPacketHeader = new OspfPacketHeader();
- ospfPacketHeader.setAreaId(Ip4Address.valueOf("1.1.1.1"));
- ospfPacketHeader.setAuthentication(0);
- ospfPacketHeader.setAuthType(0);
- ospfPacketHeader.setChecksum(12345);
- ospfPacketHeader.setDestinationIp(Ip4Address.valueOf("10.10.10.10"));
- ospfPacketHeader.setOspfPacLength(56);
- ospfPacketHeader.setOspftype(1);
- ospfPacketHeader.setOspfVer(2);
- ospfPacketHeader.setRouterId(Ip4Address.valueOf("2.2.2.2"));
- ospfPacketHeader.setSourceIp(Ip4Address.valueOf("3.3.3.3"));
- packet = createByteForHelloPacket();
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- helloPacket.readFrom(channelBuffer);
- assertThat(helloPacket, is(notNullValue()));
- assertThat(helloPacket.ospfMessageType(), is(OspfPacketType.HELLO));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result3 = helloPacket.asBytes();
- assertThat(result3, is(notNullValue()));
- }
-
- /**
- * Tests getHelloHeaderAsByteArray() method.
- */
- @Test
- public void testGetHelloHeaderAsByteArray() throws Exception {
- result3 = helloPacket.getHelloHeaderAsByteArray();
- assertThat(result3, is(notNullValue()));
- }
-
- /**
- * Tests getHelloBodyAsByteArray() method.
- */
- @Test
- public void testGetHelloBodyAsByteArray() throws Exception {
- neighborAddress.add("10.226.165.100");
- result3 = helloPacket.getHelloBodyAsByteArray();
- assertThat(result3, is(notNullValue()));
- }
-
- /**
- * Tests getHelloBodyAsByteArray() method.
- */
- @Test
- public void testReadHelloBody() throws Exception {
- helloPacket.getHelloBodyAsByteArray();
- assertThat(helloPacket, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(helloPacket.toString(), is(notNullValue()));
- }
-
- /**
- * Utility method used by junit methods.
- */
- private byte[] createByteForHelloPacket() {
- byte[] helloPacket = {2, 1, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, 39, 59, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 10, 2, 1, 0, 0, 0, 40, -64, -88, -86, 8, 0, 0, 0, 0};
-
- return helloPacket;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledgeTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledgeTest.java
deleted file mode 100644
index f25b66a..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledgeTest.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket.types;
-
-import org.hamcrest.MatcherAssert;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfPacketType;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for LsAck.
- */
-public class LsAcknowledgeTest {
-
- private LsaHeader lsaHeader;
- private LsAcknowledge lsAck;
- private OspfPacketType ospfPacketType;
- private OspfPacketHeader ospfPacketHeader;
- private byte[] result;
- private ChannelBuffer channelBuffer;
- private OpaqueLsaHeader opaqueLsaHeader;
-
- @Before
- public void setUp() throws Exception {
- lsaHeader = new LsaHeader();
- lsAck = new LsAcknowledge();
- lsAck.setAuthType(1);
- lsAck.setOspftype(5);
- lsAck.setRouterId(Ip4Address.valueOf("10.226.165.164"));
- lsAck.setAreaId(Ip4Address.valueOf("10.226.165.100"));
- lsAck.setChecksum(201);
- lsAck.setAuthentication(2);
- lsAck.setOspfPacLength(48);
- lsAck.setOspfVer(2);
- }
-
- @After
- public void tearDown() throws Exception {
- lsaHeader = null;
- lsAck = null;
- ospfPacketType = null;
- ospfPacketHeader = null;
- result = null;
- channelBuffer = null;
- opaqueLsaHeader = null;
- }
-
- /**
- * Tests getLinkStateHeaders() getter method.
- */
- @Test
- public void testGetLinkStateHeaders() throws Exception {
- lsaHeader = createLsaHeader();
- lsAck.addLinkStateHeader(lsaHeader);
- lsAck.addLinkStateHeader(lsaHeader);
- List headers = lsAck.getLinkStateHeaders();
- assertThat(headers.size(), is(1));
-
- }
-
- /**
- * Tests addLinkStateHeader() method.
- */
- @Test
- public void testAddLinkStateHeader() throws Exception {
- lsaHeader = createLsaHeader();
- lsAck.addLinkStateHeader(lsaHeader);
- lsAck.addLinkStateHeader(lsaHeader);
- assertThat(lsAck, is(notNullValue()));
- }
-
- /**
- * Tests ospfMessageType() getter method.
- */
- @Test
- public void testGetOspfMessageType() throws Exception {
- ospfPacketType = lsAck.ospfMessageType();
- assertThat(ospfPacketType, is(notNullValue()));
- assertThat(ospfPacketType, is(OspfPacketType.LSAACK));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- ospfPacketHeader = new OspfPacketHeader();
- ospfPacketHeader.setAreaId(Ip4Address.valueOf("1.1.1.1"));
- ospfPacketHeader.setAuthentication(0);
- ospfPacketHeader.setAuthType(0);
- ospfPacketHeader.setChecksum(12345);
- ospfPacketHeader.setDestinationIp(Ip4Address.valueOf("10.10.10.10"));
- ospfPacketHeader.setOspfPacLength(56);
- ospfPacketHeader.setOspftype(5);
- ospfPacketHeader.setOspfVer(2);
- ospfPacketHeader.setRouterId(Ip4Address.valueOf("2.2.2.2"));
- ospfPacketHeader.setSourceIp(Ip4Address.valueOf("3.3.3.3"));
- result = createByteForLSAck();
- lsAck = new LsAcknowledge(ospfPacketHeader);
- channelBuffer = ChannelBuffers.copiedBuffer(result);
- lsAck.readFrom(channelBuffer);
- assertThat(lsAck, is(notNullValue()));
- assertThat(lsAck.ospfMessageType(), is(OspfPacketType.LSAACK));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = lsAck.asBytes();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getLsAckAsByteArray() method.
- */
- @Test
- public void testGetLsAckAsByteArray() throws Exception {
- result = lsAck.getLsAckAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests getLsAckBodyAsByteArray() method.
- */
- @Test
- public void testGetLsAckBodyAsByteArray() throws Exception {
- lsaHeader = createLsaHeader();
- opaqueLsaHeader = new OpaqueLsaHeader();
- lsAck.addLinkStateHeader(lsaHeader);
- lsAck.addLinkStateHeader(opaqueLsaHeader);
- result = lsAck.getLsAckBodyAsByteArray();
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- MatcherAssert.assertThat(lsAck.toString(), is(notNullValue()));
- }
-
- /**
- * Utility method used by junit methods.
- */
- private LsaHeader createLsaHeader() {
- lsaHeader = new LsaHeader();
- lsaHeader.setAge(10);
- lsaHeader.setLinkStateId("10.226.165.164");
- lsaHeader.setLsCheckSum(222);
- lsaHeader.setLsPacketLen(48);
- lsaHeader.setLsSequenceNo(2020);
- lsaHeader.setLsType(5);
- lsaHeader.setOptions(2);
- lsaHeader.setAdvertisingRouter(Ip4Address.valueOf("10.226.165.165"));
- return lsaHeader;
- }
-
- /**
- * Utility method used by junit methods.
- */
- private byte[] createByteForLSAck() {
- byte[] lsAckPacket = {2, 5, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, -30,
- -12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 16, 2, 1, -64, -88, -86,
- 2, -64, -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48};
-
- return lsAckPacket;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequestTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequestTest.java
deleted file mode 100644
index af6320f..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequestTest.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfPacketType;
-import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket;
-
-import java.net.UnknownHostException;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for LsRequest.
- */
-public class LsRequestTest {
-
- private LsRequest lsRequest;
- private List<LsRequestPacket> result;
- private OspfPacketType ospfMessageType;
- private OspfPacketHeader ospfPacketHeader;
- private byte[] result1;
- private String result2;
- private ChannelBuffer channelBuffer;
- private LsRequestPacket lsRequestPacket;
-
- @Before
- public void setUp() throws Exception {
- lsRequest = new LsRequest();
- lsRequest.setAuthType(1);
- lsRequest.setOspftype(3);
- lsRequest.setRouterId(Ip4Address.valueOf("10.226.165.164"));
- lsRequest.setAreaId(Ip4Address.valueOf("10.226.165.163"));
- lsRequest.setChecksum(201);
- lsRequest.setAuthentication(2);
- lsRequest.setOspfPacLength(48);
- lsRequest.setOspfVer(2);
- }
-
- @After
- public void tearDown() throws Exception {
- lsRequest = null;
- result = null;
- ospfMessageType = null;
- ospfPacketHeader = null;
- result1 = null;
- channelBuffer = null;
- lsRequestPacket = null;
- }
-
- /**
- * Tests addLinkStateRequests() method.
- */
- @Test
- public void testAddLinkStateRequests() throws Exception {
- lsRequest.addLinkStateRequests(createLsRequestPacket());
- result = lsRequest.getLinkStateRequests();
- assertThat(result, is(notNullValue()));
- assertThat(result.size(), is(1));
- }
-
- /**
- * Tests getLinkStateRequests() method.
- */
- @Test
- public void testGetLinkStateRequests() throws Exception {
- lsRequest.addLinkStateRequests(createLsRequestPacket());
- lsRequest.addLinkStateRequests(new LsRequestPacket());
- result = lsRequest.getLinkStateRequests();
- assertThat(result, is(notNullValue()));
- assertThat(result.size(), is(2));
- }
-
- /**
- * Tests ospfMessageType()getter method.
- */
- @Test
- public void testGetOspfMessageType() throws Exception {
- ospfMessageType = lsRequest.ospfMessageType();
- assertThat(ospfMessageType, is(notNullValue()));
- assertThat(ospfMessageType, is(OspfPacketType.LSREQUEST));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- ospfPacketHeader = new OspfPacketHeader();
- ospfPacketHeader.setAreaId(Ip4Address.valueOf("1.1.1.1"));
- ospfPacketHeader.setAuthentication(0);
- ospfPacketHeader.setAuthType(0);
- ospfPacketHeader.setChecksum(12345);
- ospfPacketHeader.setDestinationIp(Ip4Address.valueOf("10.10.10.10"));
- ospfPacketHeader.setOspfPacLength(56);
- ospfPacketHeader.setOspftype(3);
- ospfPacketHeader.setOspfVer(2);
- ospfPacketHeader.setRouterId(Ip4Address.valueOf("2.2.2.2"));
- ospfPacketHeader.setSourceIp(Ip4Address.valueOf("3.3.3.3"));
- lsRequest = new LsRequest(ospfPacketHeader);
- result1 = createByteLsReqestPacket();
- channelBuffer = ChannelBuffers.copiedBuffer(result1);
- lsRequest.readFrom(channelBuffer);
- assertThat(lsRequest, is(notNullValue()));
- assertThat(lsRequest.ospfMessageType(), is(OspfPacketType.LSREQUEST));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result1 = lsRequest.asBytes();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests getLsrHeaderAsByteArray() method.
- */
- @Test
- public void testGetLsrHeaderAsByteArray() throws Exception {
- result1 = lsRequest.getLsrHeaderAsByteArray();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests getLsrBodyAsByteArray() method.
- */
- @Test
- public void testGetLsrBodyAsByteArray() throws Exception {
- lsRequest.addLinkStateRequests(createLsRequestPacket());
- lsRequest.addLinkStateRequests(new LsRequestPacket());
- result1 = lsRequest.getLsrBodyAsByteArray();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- result2 = lsRequest.toString();
- assertThat(result2, is(notNullValue()));
- }
-
- private LsRequestPacket createLsRequestPacket() throws UnknownHostException {
- lsRequestPacket = new LsRequestPacket();
- lsRequestPacket.setOwnRouterId("165");
- lsRequestPacket.setLinkStateId("10.226.165.164");
- lsRequestPacket.setLsType(2);
- return lsRequestPacket;
- }
-
- private byte[] createByteLsReqestPacket() {
- byte[] lsRequestPacket = {2, 3, 0, 36, -64, -88, -86, 3, 0, 0, 0, 1, -67,
- -57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -64, -88, -86, 8,
- -64, -88, -86, 8};
- return lsRequestPacket;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdateTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdateTest.java
deleted file mode 100644
index b45821b..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdateTest.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.ospfpacket.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.controller.OspfLsa;
-import org.onosproject.ospf.controller.OspfPacketType;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.lsa.types.AsbrSummaryLsa;
-import org.onosproject.ospf.protocol.lsa.types.ExternalLsa;
-import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa11;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa9;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.lsa.types.SummaryLsa;
-import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
-
-import java.util.List;
-import java.util.Vector;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for LsUpdate.
- */
-public class LsUpdateTest {
-
- private final byte[] packet1 = {0, 0, 0, 2, 0, 10, 2, 1, 7, 7, 7, 7, 7, 7, 7, 7,
- -128, 0, 0, 2, 46, -126, 0, 48, 0, 0, 0, 2, 1, 1, 1, 1, 10, 10, 10, 7, 1,
- 0, 0, 10, 10, 10, 10, 0, -1, -1, -1, 0, 3, 0, 0, 10, 0, 10, 66, 10, 1, 0,
- 0, 1, 7, 7, 7, 7, -128, 0, 0, 1, -64, 79, 0, 116, 0, 1, 0, 4, 0, 0, 0, 0,
- 0, 2, 0, 84, 0, 1, 0, 1, 1, 0, 0, 0, 0, 2, 0, 4, 10, 10, 10, 0, 0, 5, 0,
- 4, 0, 0, 0, 0, 0, 6, 0, 4, 73, -104, -106, -128, 0, 7, 0, 4, 73, -104, -106,
- -128, 0, 8, 0, 32, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106,
- -128, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106, -128, 73,
- -104, -106, -128, 73, -104, -106, -128, 0, 9, 0, 4, 0, 0, 0, 0};
- private final byte[] packet3 = {0, 0, 0, 1, 0, 100, 2, 10, 1, 0, 0, 1, 9, 9, 9, 9,
- -128, 0, 0, 1, -7, 62, 0, -124, 0, 2, 0, 108, 0, 1, 0, 1, 2, 0, 0, 0, 0, 2,
- 0, 4, -64, -88, 7, -91, 0, 3, 0, 4, -64, -88, 7, -91, 0, 4, 0, 4, 0, 0, 0,
- 0, 0, 5, 0, 4, 0, 0, 0, 1, 0, 6, 0, 4, 0, 0, 0, 0, 0, 7, 0, 4, 0, 0, 0, 0,
- 0, 8, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 4, 0, 0, 0, 0, -128, 2, 0, 4, 0,
- 0, 0, 1};
- private final byte[] packet2 = {0, 0,
- 0, 1, 0, 1, 2, 2, -64, -88,
- -86, 8, -64, -88, -86, 8, -128, 0, 0, 1, 55, -73, 0, 32, -1, -1, -1, 0, -64,
- -88, -86, 3, -64, -88, -86, 8};
- private final byte[] packet4 = {0, 0, 0, 1, 0, 100, 2, 9, 1, 0, 0, 1, 9, 9, 9, 9, -128,
- 0, 0, 1, -7, 62, 0, -124, 0, 2, 0, 108, 0, 1, 0, 1, 2, 0, 0, 0, 0, 2, 0, 4, -64,
- -88, 7, -91, 0, 3, 0, 4, -64, -88, 7, -91, 0, 4, 0, 4, 0, 0, 0, 0, 0, 5, 0, 4, 0,
- 0, 0, 1, 0, 6, 0, 4, 0, 0, 0, 0, 0, 7, 0, 4, 0, 0, 0, 0, 0, 8, 0, 32, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 9, 0, 4, 0, 0, 0, 0, -128, 2, 0, 4, 0, 0, 0, 1};
-
- private final byte[] packet5 = {0, 0, 0, 1, 0, 100, 2, 11, 1, 0, 0, 1, 9, 9, 9, 9, -128, 0,
- 0, 1, -7, 62, 0, -124, 0, 2, 0, 108, 0, 1, 0, 1, 2, 0, 0, 0, 0, 2, 0, 4, -64, -88,
- 7, -91, 0, 3, 0, 4, -64, -88, 7, -91, 0, 4, 0, 4, 0, 0, 0, 0, 0, 5, 0, 4, 0, 0, 0,
- 1, 0, 6, 0, 4, 0, 0, 0, 0, 0, 7, 0, 4, 0, 0, 0, 0, 0, 8, 0, 32, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 9, 0, 4, 0, 0, 0, 0, -128, 2, 0, 4, 0, 0, 0, 1};
- private final byte[] packet6 = {0, 0, 0, 1, 0, 100, 2, 3, 1, 0, 0, 1, 9, 9, 9, 9, -128,
- 0, 0, 1, -7, 62, 0, -124, 0, 2, 0, 108, 0, 1, 0, 1, 2, 0, 0, 0, 0, 2, 0, 4, -64,
- -88, 7, -91, 0, 3, 0, 4, -64, -88, 7, -91, 0, 4, 0, 4, 0, 0, 0, 0, 0, 5, 0, 4,
- 0, 0, 0, 1, 0, 6, 0, 4, 0, 0, 0, 0, 0, 7, 0, 4, 0, 0, 0, 0, 0, 8, 0, 32, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 9, 0, 4, 0, 0, 0, 0, -128, 2, 0, 4, 0, 0, 0, 1};
- private final byte[] packet7 = {0, 0, 0, 1, 0, 100, 2, 4, 1, 0, 0, 1, 9, 9, 9, 9, -128,
- 0, 0, 1, -7, 62, 0, -124, 0, 2, 0, 108, 0, 1, 0, 1, 2, 0, 0, 0, 0, 2, 0, 4, -64,
- -88, 7, -91, 0, 3, 0, 4, -64, -88, 7, -91, 0, 4, 0, 4, 0, 0, 0, 0, 0, 5, 0, 4, 0,
- 0, 0, 1, 0, 6, 0, 4, 0, 0, 0, 0, 0, 7, 0, 4, 0, 0, 0, 0, 0, 8, 0, 32, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 9, 0, 4, 0, 0, 0, 0, -128, 2, 0, 4, 0, 0, 0, 1};
-
- private final byte[] packet8 = {0, 0, 0, 2, 1, 4, 2, 1, 5, 5, 5, 5, 5, 5, 5, 5, -128, 0, 0,
- 4, -39, -84, 0, 36, 1, 0, 0, 1, -64, -88, 7, 90, -64, -88, 7, 92, 2, 0, 0, 10, 1, 4,
- 2, 4, -34, -34, -34, -34, 5, 5, 5, 5, -128, 0, 0, 1, 31, -93, 0, 28, 0, 0, 0, 0, 0,
- 0, 0, 10};
- private LsUpdate lsUpdate;
- private RouterLsa ospflsa;
- private NetworkLsa ospflsa1;
- private SummaryLsa ospflsa2;
- private AsbrSummaryLsa ospflsa3;
- private ExternalLsa ospflsa4;
- private Vector<OspfLsa> listLsa = new Vector();
- private List lsa;
- private int result;
- private OspfPacketType ospfMessageType;
- private OspfPacketHeader ospfPacketHeader;
- private byte[] result1;
- private ChannelBuffer channelBuffer;
- private OpaqueLsa10 opaqueLsa10;
- private OpaqueLsa9 opaqueLsa9;
- private OpaqueLsa11 opaqueLsa11;
-
- @Before
- public void setUp() throws Exception {
- lsUpdate = new LsUpdate();
- ospflsa = new RouterLsa();
- lsUpdate.setAuthType(1);
- lsUpdate.setOspftype(2);
- lsUpdate.setRouterId(Ip4Address.valueOf("10.226.165.164"));
- lsUpdate.setAreaId(Ip4Address.valueOf("10.226.165.100"));
- lsUpdate.setChecksum(201);
- lsUpdate.setAuthentication(2);
- lsUpdate.setOspfPacLength(48);
- lsUpdate.setOspfVer(2);
- ospflsa.setLsType(1);
- lsUpdate.addLsa(ospflsa);
- ospflsa1 = new NetworkLsa();
- ospflsa1.setNetworkMask(Ip4Address.valueOf("10.226.165.164"));
- ospflsa1.setLsType(2);
- lsUpdate.addLsa(ospflsa1);
- ospflsa2 = new SummaryLsa(new LsaHeader());
- ospflsa2.setLsType(3);
- lsUpdate.addLsa(ospflsa2);
- ospflsa3 = new AsbrSummaryLsa(new LsaHeader());
- ospflsa3.setNetworkMask(Ip4Address.valueOf("10.226.165.164"));
- ospflsa3.setLsType(4);
- lsUpdate.addLsa(ospflsa3);
- ospflsa4 = new ExternalLsa(new LsaHeader());
- ospflsa4.setLsType(5);
- lsUpdate.addLsa(ospflsa4);
- }
-
- @After
- public void tearDown() throws Exception {
- lsUpdate = null;
- ospflsa = null;
- ospflsa1 = null;
- ospflsa2 = null;
- ospflsa3 = null;
- ospflsa4 = null;
- listLsa.clear();
- lsa = null;
- ospfMessageType = null;
- ospfPacketHeader = null;
- result1 = null;
- channelBuffer = null;
- opaqueLsa9 = null;
- opaqueLsa10 = null;
- opaqueLsa11 = null;
- }
-
- /**
- * Tests getLsaList() getter method.
- */
- @Test
- public void testGetListLsa() throws Exception {
- lsUpdate.addLsa(ospflsa);
- lsUpdate.addLsa(ospflsa);
- lsa = lsUpdate.getLsaList();
- assertThat(lsa, is(notNullValue()));
- assertThat(lsa.size(), is(5));
- }
-
- /**
- * Tests addLsa() method.
- */
- @Test
- public void testAddLsa() throws Exception {
- lsUpdate.addLsa(ospflsa);
- assertThat(lsUpdate, is(notNullValue()));
- }
-
- /**
- * Tests noLsa() getter method.
- */
- @Test
- public void testGetNoLsa() throws Exception {
- lsUpdate.setNumberOfLsa(5);
- result = lsUpdate.noLsa();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(5));
- }
-
- /**
- * Tests noLsa() setter method.
- */
- @Test
- public void testSetNoLsa() throws Exception {
- lsUpdate.setNumberOfLsa(5);
- result = lsUpdate.noLsa();
- assertThat(result, is(notNullValue()));
- assertThat(result, is(5));
- }
-
- /**
- * Tests ospfMessageType() getter method.
- */
- @Test
- public void testGetOspfMessageType() throws Exception {
- ospfMessageType = lsUpdate.ospfMessageType();
- assertThat(ospfMessageType, is(OspfPacketType.LSUPDATE));
- }
-
- /**
- * Tests readFrom() method.
- */
- @Test
- public void testReadFrom() throws Exception {
- ospfPacketHeader = new OspfPacketHeader();
- ospfPacketHeader.setAreaId(Ip4Address.valueOf("1.1.1.1"));
- ospfPacketHeader.setAuthentication(0);
- ospfPacketHeader.setAuthType(0);
- ospfPacketHeader.setChecksum(12345);
- ospfPacketHeader.setDestinationIp(Ip4Address.valueOf("10.10.10.10"));
- ospfPacketHeader.setOspfPacLength(56);
- ospfPacketHeader.setOspftype(4);
- ospfPacketHeader.setOspfVer(2);
- ospfPacketHeader.setRouterId(Ip4Address.valueOf("2.2.2.2"));
- ospfPacketHeader.setSourceIp(Ip4Address.valueOf("3.3.3.3"));
- lsUpdate = new LsUpdate(ospfPacketHeader);
- result1 = createLsUpdatePacket();
- channelBuffer = ChannelBuffers.copiedBuffer(result1);
- lsUpdate.readFrom(channelBuffer);
- channelBuffer = ChannelBuffers.copiedBuffer(packet1);
- lsUpdate.readFrom(channelBuffer);
- channelBuffer = ChannelBuffers.copiedBuffer(packet2);
- lsUpdate.readFrom(channelBuffer);
- channelBuffer = ChannelBuffers.copiedBuffer(packet3);
- lsUpdate.readFrom(channelBuffer);
- channelBuffer = ChannelBuffers.copiedBuffer(packet4);
- lsUpdate.readFrom(channelBuffer);
- channelBuffer = ChannelBuffers.copiedBuffer(packet5);
- lsUpdate.readFrom(channelBuffer);
- channelBuffer = ChannelBuffers.copiedBuffer(packet6);
- lsUpdate.readFrom(channelBuffer);
- channelBuffer = ChannelBuffers.copiedBuffer(packet7);
- lsUpdate.readFrom(channelBuffer);
- channelBuffer = ChannelBuffers.copiedBuffer(packet8);
- lsUpdate.readFrom(channelBuffer);
- assertThat(lsUpdate, is(notNullValue()));
- assertThat(lsUpdate.ospfMessageType(), is(OspfPacketType.LSUPDATE));
- }
-
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result1 = lsUpdate.asBytes();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests getLsuHeaderAsByteArray() method.
- */
- @Test
- public void testGetLsuHeaderAsByteArray() throws Exception {
- result1 = lsUpdate.getLsuHeaderAsByteArray();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests getLsuBodyAsByteArray() method.
- */
- @Test
- public void testGetLsuBodyAsByteArray() throws Exception {
- lsUpdate.setNumberOfLsa(8);
- lsUpdate.addLsa(ospflsa3);
- opaqueLsa9 = new OpaqueLsa9(new OpaqueLsaHeader());
- opaqueLsa9.setLsType(9);
- lsUpdate.addLsa(opaqueLsa9);
- opaqueLsa10 = new OpaqueLsa10(new OpaqueLsaHeader());
- opaqueLsa10.setLsType(10);
- lsUpdate.addLsa(opaqueLsa10);
- opaqueLsa11 = new OpaqueLsa11(new OpaqueLsaHeader());
- opaqueLsa10.setLsType(11);
- lsUpdate.addLsa(opaqueLsa11);
- result1 = lsUpdate.getLsuBodyAsByteArray();
- assertThat(result1, is(notNullValue()));
- }
-
- @Test
- public void testGetLsuBodyAsByteArray1() throws Exception {
- lsUpdate.setNumberOfLsa(8);
- opaqueLsa10 = new OpaqueLsa10(new OpaqueLsaHeader());
- opaqueLsa10.setLsType(10);
- lsUpdate.addLsa(opaqueLsa10);
- assertThat(result1, is(nullValue()));
- }
-
- @Test
- public void testGetLsuBodyAsByteArray2() throws Exception {
- opaqueLsa11 = new OpaqueLsa11(new OpaqueLsaHeader());
- opaqueLsa11.setLsType(11);
- lsUpdate.addLsa(opaqueLsa11);
- result1 = lsUpdate.getLsuBodyAsByteArray();
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests to string method.
- */
- @Test
- public void testToString() throws Exception {
- assertThat(lsUpdate.toString(), is(notNullValue()));
- }
-
- /**
- * Utility method used by junit methods.
- */
- private byte[] createLsUpdatePacket() {
- byte[] lsUpdatePacket = {0, 0, 0, 7, 0, 2, 2,
- 1, -64, -88, -86, 3, -64, -88, -86, 3, -128, 0, 0, 1, 58,
- -100, 0, 48, 2, 0, 0, 2, -64, -88, -86, 0, -1, -1, -1, 0,
- 3, 0, 0, 10, -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10,
- 0, 3, 2, 5, 80, -44, 16, 0, -64, -88, -86, 2, -128, 0, 0,
- 1, 42, 73, 0, 36, -1, -1, -1, -1, -128, 0, 0, 20, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -108, 121, -85, 0, -64, -88,
- -86, 2, -128, 0, 0, 1, 52, -91, 0, 36, -1, -1, -1, 0,
- -128, 0, 0, 20, -64, -88, -86, 1, 0, 0, 0, 0, 0, 3, 2, 5,
- -64, -126, 120, 0, -64, -88, -86, 2, -128, 0, 0, 1, -45,
- 25, 0, 36, -1, -1, -1, 0, -128, 0, 0, 20, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 3, 2, 5, -64, -88, 0, 0, -64, -88, -86, 2,
- -128, 0, 0, 1, 55, 8, 0, 36, -1, -1, -1, 0, -128, 0, 0,
- 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -64, -88, 1, 0,
- -64, -88, -86, 2, -128, 0, 0, 1, 44, 18, 0, 36, -1, -1, -1, 0, -128, 0,
- 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -64, -88, -84, 0, -64, -88,
- -86, 2, -128, 0, 0, 1, 51, 65, 0, 36, -1, -1, -1, 0, -128, 0, 0, 20, -64,
- -88, -86, 10, 0, 0, 0, 0};
- return lsUpdatePacket;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/util/ChecksumCalculatorTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/util/ChecksumCalculatorTest.java
deleted file mode 100644
index 5f96afc..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/util/ChecksumCalculatorTest.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.util;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
-import org.onosproject.ospf.protocol.lsa.types.AsbrSummaryLsa;
-import org.onosproject.ospf.protocol.lsa.types.ExternalLsa;
-import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa10;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa11;
-import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa9;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-import org.onosproject.ospf.protocol.lsa.types.SummaryLsa;
-import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
-import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Unit test class for ChecksumCalculator.
- */
-public class ChecksumCalculatorTest {
-
- private final int ospfChecksumPos1 = 12;
- private final int ospfChecksumPos2 = 13;
- private final int lsaChecksumPos1 = 16;
- private final int lsaChecksumPos2 = 17;
- private final byte[] updatePacket = {1, 1, 1, 1, 2, 4, 0, -96, 9, 9, 9, 9, 5, 5, 5, 5, 62, 125,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 100, 2, 10, 1, 0, 0, 1, 9, 9, 9, 9, -128,
- 0, 0, 1, -7, 62, 0, -124, 0, 2, 0, 108, 0, 1, 0, 1, 2, 0, 0, 0, 0, 2, 0, 4, -64, -88,
- 7, -91, 0, 3, 0, 4, -64, -88, 7, -91, 0, 4, 0, 4, 0, 0, 0, 0, 0, 5, 0, 4, 0, 0, 0, 1,
- 0, 6, 0, 4, 0, 0, 0, 0, 0, 7, 0, 4, 0, 0, 0, 0, 0, 8, 0, 32, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
- 0, 4, 0, 0, 0, 0, -128, 2, 0, 4, 0, 0, 0, 1};
-
- private final byte[] helloPacket = {2, 1, 0, 44, -64, -88, -86, 8, 0, 0, 0, 1, 39, 59,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 10, 2, 1, 0, 0, 0, 40, -64, -88,
- -86, 8, 0, 0, 0, 0};
- private final byte[] rlsa = {14, 16, 2, 1, -64, -88, -86, 2, -64, -88, -86, 2, -128, 0,
- 0, 1, 74, -114, 0, 48, 2, 0, 0, 2, -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10,
- -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10};
- private ChecksumCalculator checksumCalculator;
- private boolean validate;
- private HelloPacket hello;
- private LsUpdate message;
- private DdPacket message1;
- private LsRequest message2;
- private RouterLsa router;
- private LsAcknowledge lsack;
- private ExternalLsa external;
- private NetworkLsa external1;
- private SummaryLsa external2;
- private AsbrSummaryLsa external3;
- private OpaqueLsa9 external4;
- private OpaqueLsa10 external5;
- private OpaqueLsa11 external6;
- private byte[] result;
-
- @Before
- public void setUp() throws Exception {
- checksumCalculator = new ChecksumCalculator();
- }
-
- @After
- public void tearDown() throws Exception {
- checksumCalculator = null;
- hello = null;
- message = null;
- message1 = null;
- message2 = null;
- router = null;
- lsack = null;
- external = null;
- external1 = null;
- external2 = null;
- external3 = null;
- result = null;
- }
-
- /**
- * Tests convertToSixteenBits() method.
- */
- @Test
- public void testConvertToSixteenBits() throws Exception {
- int num = checksumCalculator.convertToSixteenBits("16cdd");
- assertThat(num, is(27870));
- }
-
- /**
- * Tests isValidOspfCheckSum() method.
- */
- @Test
- public void testIsValidOspfCheckSum() throws Exception {
- hello = new HelloPacket();
- hello.setOspfVer(2);
- hello.setOspftype(1);
- hello.setOspfPacLength(172);
- hello.setRouterId(Ip4Address.valueOf("192.168.170.3"));
- hello.setAreaId(Ip4Address.valueOf("0.0.0.1"));
- hello.setChecksum(5537);
- hello.setAuthType(0);
- hello.setAuthentication(0);
- validate = checksumCalculator.isValidOspfCheckSum(hello, ospfChecksumPos1, ospfChecksumPos2);
- assertThat(validate, is(false));
- lsack = new LsAcknowledge();
- lsack.setOspfVer(2);
- lsack.setOspftype(5);
- lsack.setOspfPacLength(172);
- lsack.setRouterId(Ip4Address.valueOf("192.168.170.3"));
- lsack.setAreaId(Ip4Address.valueOf("0.0.0.1"));
- lsack.setChecksum(37537);
- lsack.setAuthType(0);
- lsack.setAuthentication(0);
- validate = checksumCalculator.isValidOspfCheckSum(lsack, ospfChecksumPos1, ospfChecksumPos2);
- assertThat(validate, is(true));
- message = new LsUpdate();
- message.setOspfVer(2);
- message.setOspftype(5);
- message.setOspfPacLength(172);
- message.setRouterId(Ip4Address.valueOf("192.168.170.3"));
- message.setAreaId(Ip4Address.valueOf("0.0.0.1"));
- message.setChecksum(37537);
- message.setAuthType(0);
- message.setAuthentication(0);
- validate = checksumCalculator.isValidOspfCheckSum(message, ospfChecksumPos1, ospfChecksumPos2);
- assertThat(validate, is(true));
- message1 = new DdPacket();
- message1.setOspfVer(2);
- message1.setOspftype(5);
- message1.setOspfPacLength(172);
- message1.setRouterId(Ip4Address.valueOf("192.168.170.3"));
- message1.setAreaId(Ip4Address.valueOf("0.0.0.1"));
- message1.setChecksum(37537);
- message1.setAuthType(0);
- message1.setAuthentication(0);
- validate = checksumCalculator.isValidOspfCheckSum(message1, ospfChecksumPos1, ospfChecksumPos2);
- assertThat(validate, is(true));
- message2 = new LsRequest();
- message2.setOspfVer(2);
- message2.setOspftype(5);
- message2.setOspfPacLength(172);
- message2.setRouterId(Ip4Address.valueOf("192.168.170.3"));
- message2.setAreaId(Ip4Address.valueOf("0.0.0.1"));
- message2.setChecksum(37537);
- message2.setAuthType(0);
- message2.setAuthentication(0);
- validate = checksumCalculator.isValidOspfCheckSum(message2, ospfChecksumPos1, ospfChecksumPos2);
- assertThat(validate, is(true));
- }
-
- /**
- * Tests isValidLsaCheckSum() method.
- */
- @Test
- public void testIsValidLsaCheckSum() throws Exception {
- router = new RouterLsa();
- router.setAge(1);
- router.setOptions(2);
- router.setLsType(1);
- router.setLinkStateId("192.168.170.3");
- router.setAdvertisingRouter(Ip4Address.valueOf("192.168.170.3"));
- router.setLsSequenceNo(2147483649L);
- router.setLsCheckSum(49499);
- router.setLsPacketLen(48);
- validate = checksumCalculator.isValidLsaCheckSum(router, router.lsType(), lsaChecksumPos1, lsaChecksumPos2);
- assertThat(validate, is(true));
-
- }
-
- /**
- * Tests isValidLsaCheckSum() method.
- */
- @Test
- public void testIsValidLsaCheckSum4() throws Exception {
- external = new ExternalLsa(new LsaHeader());
- external.setAge(2);
- external.setOptions(2);
- external.setLsType(5);
- external.setLinkStateId("80.212.16.0");
- external.setAdvertisingRouter(Ip4Address.valueOf("192.168.170.2"));
- external.setLsSequenceNo(2147483649L);
- external.setLsCheckSum(25125);
- external.setLsPacketLen(36);
- validate = checksumCalculator.isValidLsaCheckSum(external, external.lsType(), lsaChecksumPos1, lsaChecksumPos2);
- assertThat(validate, is(false));
- }
-
- /**
- * Tests isValidLsaCheckSum() method.
- */
- @Test(expected = Exception.class)
- public void testIsValidLsaCheckSum5() throws Exception {
- external1 = new NetworkLsa();
- external1.setAge(2);
- external1.setOptions(2);
- external1.setLsType(2);
- external1.setLinkStateId("80.212.16.0");
- external1.setAdvertisingRouter(Ip4Address.valueOf("192.168.170.2"));
- external1.setLsSequenceNo(2147483649L);
- external1.setLsCheckSum(25125);
- external1.setLsPacketLen(36);
- validate = checksumCalculator.isValidLsaCheckSum(external1, external1.lsType(),
- lsaChecksumPos1, lsaChecksumPos2);
- assertThat(validate, is(false));
- }
-
- /**
- * Tests isValidLsaCheckSum() method.
- */
- @Test
- public void testIsValidLsaCheckSum6() throws Exception {
-
- external2 = new SummaryLsa(new LsaHeader());
- external2.setAge(2);
- external2.setOptions(2);
- external2.setLsType(3);
- external2.setLinkStateId("80.212.16.0");
- external2.setAdvertisingRouter(Ip4Address.valueOf("192.168.170.2"));
- external2.setLsSequenceNo(2147483649L);
- external2.setLsCheckSum(25125);
- external2.setLsPacketLen(36);
- validate = checksumCalculator.isValidLsaCheckSum(external2, external2.lsType(),
- lsaChecksumPos1, lsaChecksumPos2);
- assertThat(validate, is(false));
- }
-
- /**
- * Tests isValidLsaCheckSum() method.
- */
- @Test(expected = Exception.class)
- public void testIsValidLsaCheckSum7() throws Exception {
- external3 = new AsbrSummaryLsa(new LsaHeader());
- external3.setAge(2);
- external3.setOptions(2);
- external3.setLsType(4);
- external3.setLinkStateId("80.212.16.0");
- external3.setAdvertisingRouter(Ip4Address.valueOf("192.168.170.2"));
- external3.setLsSequenceNo(2147483649L);
- external3.setLsCheckSum(25125);
- external3.setLsPacketLen(36);
- validate = checksumCalculator.isValidLsaCheckSum(external3, external3.lsType(),
- lsaChecksumPos1, lsaChecksumPos2);
- assertThat(validate, is(false));
- }
-
- /**
- * Tests isValidLsaCheckSum() method.
- */
- @Test(expected = Exception.class)
- public void testIsValidLsaCheckSum1() throws Exception {
- external4 = new OpaqueLsa9(new OpaqueLsaHeader());
- external4.setAge(2);
- external4.setOptions(2);
- external4.setLsType(9);
- external4.setLinkStateId("80.212.16.0");
- external4.setAdvertisingRouter(Ip4Address.valueOf("192.168.170.2"));
- external4.setLsSequenceNo(2147483649L);
- external4.setLsCheckSum(25125);
- external4.setLsPacketLen(36);
- validate = checksumCalculator.isValidLsaCheckSum(external4, external4.lsType(),
- lsaChecksumPos1, lsaChecksumPos2);
- assertThat(validate, is(false));
- }
-
- /**
- * Tests isValidLsaCheckSum() method.
- */
- @Test(expected = Exception.class)
- public void testIsValidLsaCheckSum2() throws Exception {
- external5 = new OpaqueLsa10(new OpaqueLsaHeader());
- external5.setAge(2);
- external5.setOptions(2);
- external5.setLsType(10);
- external5.setLinkStateId("80.212.16.0");
- external5.setAdvertisingRouter(Ip4Address.valueOf("192.168.170.2"));
- external5.setLsSequenceNo(2147483649L);
- external5.setLsCheckSum(25125);
- external5.setLsPacketLen(36);
- validate = checksumCalculator.isValidLsaCheckSum(external5, external5.lsType(),
- lsaChecksumPos1, lsaChecksumPos2);
-
- assertThat(validate, is(false));
- }
-
- /**
- * Tests isValidLsaCheckSum() method.
- */
- @Test(expected = Exception.class)
- public void testIsValidLsaCheckSum3() throws Exception {
- external6 = new OpaqueLsa11(new OpaqueLsaHeader());
- external6.setAge(2);
- external6.setOptions(2);
- external6.setLsType(10);
- external6.setLinkStateId("80.212.16.0");
- external6.setAdvertisingRouter(Ip4Address.valueOf("192.168.170.2"));
- external6.setLsSequenceNo(2147483649L);
- external6.setLsCheckSum(25125);
- external6.setLsPacketLen(36);
- validate = checksumCalculator.isValidLsaCheckSum(external6, external6.lsType(),
- lsaChecksumPos1, lsaChecksumPos2);
- assertThat(validate, is(false));
- }
-
- /**
- * Tests validateLsaCheckSum() method.
- */
- @Test
- public void testValidateLsaCheckSum() throws Exception {
- assertThat(checksumCalculator.validateLsaCheckSum(rlsa, lsaChecksumPos1,
- lsaChecksumPos2), is(true));
-
- }
-
- /**
- * Tests validateOspfCheckSum() method.
- */
- @Test
- public void testValidateOspfCheckSum() throws Exception {
- assertThat(checksumCalculator.validateOspfCheckSum(helloPacket, ospfChecksumPos1,
- ospfChecksumPos2), is(true));
- }
-
- /**
- * Tests calculateLsaChecksum() method.
- */
- @Test
- public void testCalculateLsaChecksum() throws Exception {
- result = checksumCalculator.calculateLsaChecksum(rlsa, lsaChecksumPos1, lsaChecksumPos2);
- assertThat(result, is(notNullValue()));
- }
-
- /**
- * Tests calculateOspfCheckSum() method.
- */
- @Test
- public void testCalculateOspfCheckSum() throws Exception {
- result = checksumCalculator.calculateOspfCheckSum(helloPacket, ospfChecksumPos1,
- ospfChecksumPos2);
- assertThat(result, is(notNullValue()));
- result = checksumCalculator.calculateOspfCheckSum(updatePacket, ospfChecksumPos1,
- ospfChecksumPos2);
- assertThat(result, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/util/OspfUtilTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/util/OspfUtilTest.java
deleted file mode 100644
index 4c192a3..0000000
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/util/OspfUtilTest.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ospf.protocol.util;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * Unit test class for OspfUtil.
- */
-public class OspfUtilTest {
-
- private final int ospfChecksumPos1 = 12;
- private final int ospfChecksumPos2 = 13;
- private final int lsaChecksumPos1 = 16;
- private final int lsaChecksumPos2 = 17;
- private final int ospfLengthPos1 = 2;
- private final int ospfLengthPos2 = 3;
- private final int lsaLengthPos1 = 18;
- private final int lsaLengthPos2 = 19;
- private final byte[] input = {0, 2};
- private final byte[] packet = {2, 1, 0, 52, -64, -88, 56, 1, -64, -88, 56, 1, 0, 100, 0, 100, 0, 0, 0, 0, 0, 0,
- 0, 0, -64, -88, 56, 1, 0, 10, 1, 1, 0, 0, 0, 40, -64, -88, 56, 1, -64, -88, 56, 1, -64, -88, 56, 1, -64,
- -88, 56, 1};
- private final byte[] rLsa = {14, 16, 2, 1, -64, -88, -86, 2, -64, -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48, 2,
- 0, 0, 2, -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10, -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10};
- private final byte[] opaqueheader = {14, 16, 2, 1, -64, -88, -86, 2, -64, -88, -86, 2, -128, 0, 0, 1, 74, -114,
- 0, 48};
- private int num;
- private int result;
- private int input2;
- private long input4;
- private ChannelBuffer channelBuffer;
- private byte[] result1;
- private LsaHeader lsaHeader;
- private boolean result2;
- private long result3;
-
-
- @Before
- public void setUp() throws Exception {
-
- }
-
- @After
- public void tearDown() throws Exception {
- channelBuffer = null;
- result1 = null;
- lsaHeader = null;
- }
-
-
- /**
- * Tests byteToInteger() method.
- */
- @Test
- public void testByteToInteger() throws Exception {
- result = OspfUtil.byteToInteger(input);
- assertThat(result, is(notNullValue()));
- assertThat(result, is(2));
-
- }
-
- /**
- * Tests byteToLong() method.
- */
- @Test
- public void testByteToLong() throws Exception {
- result3 = OspfUtil.byteToLong(input);
- assertThat(result3, is(notNullValue()));
- assertThat(result3, is(2L));
- }
-
- /**
- * Tests byteToInteger() method.
- */
- @Test
- public void testByteToLong1() throws Exception {
- result3 = OspfUtil.byteToLong(input);
- assertThat(result3, is(notNullValue()));
- assertThat(result3, is(2L));
- }
-
- /**
- * Tests byteToInteger() method.
- */
- @Test
- public void testByteToInteger1() throws Exception {
- result = OspfUtil.byteToInteger(input);
- assertThat(result, is(notNullValue()));
- assertThat(result, is(2));
- }
-
- /**
- * Tests to createRandomNumber() method.
- */
- @Test
- public void testCreateRandomNumber() throws Exception {
- num = OspfUtil.createRandomNumber();
- assertThat(num, is(notNullValue()));
- }
-
- /**
- * Tests readLsaHeader() method.
- */
- @Test
- public void testReadLsaHeader2() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(packet);
- lsaHeader = OspfUtil.readLsaHeader(channelBuffer);
- assertThat(lsaHeader, is(notNullValue()));
- }
-
- /**
- * Tests to readLsaHeader method.
- */
- @Test
- public void testReadLsaHeader1() throws Exception {
- channelBuffer = ChannelBuffers.copiedBuffer(opaqueheader);
- lsaHeader = OspfUtil.readLsaHeader(channelBuffer);
- assertThat(lsaHeader, is(notNullValue()));
- }
-
- /**
- * Tests convertToTwoBytes() method.
- */
- @Test
- public void testConvertToTwoBytes() throws Exception {
- input2 = 4;
- result1 = OspfUtil.convertToTwoBytes(input2);
- assertThat(result1.length, is(2));
- input2 = 1000;
- result1 = OspfUtil.convertToTwoBytes(input2);
- assertThat(result1.length, is(2));
- }
-
- /**
- * Tests convertToThreeBytes() method.
- */
- @Test
- public void testConvertToThreeBytes() throws Exception {
- input2 = 1000000;
- result1 = OspfUtil.convertToThreeBytes(input2);
- assertThat(result1.length, is(3));
- input2 = 1000;
- result1 = OspfUtil.convertToThreeBytes(input2);
- assertThat(result1.length, is(3));
- input2 = 1;
- result1 = OspfUtil.convertToThreeBytes(input2);
- assertThat(result1.length, is(3));
- }
-
- /**
- * Tests convertToFourBytes() method.
- */
- @Test
- public void testConvertToFourBytes() throws Exception {
- input4 = 214748364110L;
- result1 = OspfUtil.convertToFourBytes(input4);
- assertThat(result1.length, is(4));
- input4 = 1000000;
- result1 = OspfUtil.convertToFourBytes(input4);
- assertThat(result1.length, is(4));
- input4 = 10000;
- result1 = OspfUtil.convertToFourBytes(input4);
- assertThat(result1.length, is(4));
- input4 = 1;
- result1 = OspfUtil.convertToFourBytes(input4);
- assertThat(result1.length, is(4));
-
- }
-
- /**
- * Tests convertToFourBytes() method.
- */
- @Test
- public void testConvertToFourBytes1() throws Exception {
- input4 = 2147483635;
- result1 = OspfUtil.convertToFourBytes(this.input4);
- assertThat(result1.length, is(4));
- this.input4 = 1000000;
- result1 = OspfUtil.convertToFourBytes(this.input4);
- assertThat(result1.length, is(4));
- this.input4 = 10000;
- result1 = OspfUtil.convertToFourBytes(this.input4);
- assertThat(result1.length, is(4));
- this.input4 = 1;
- result1 = OspfUtil.convertToFourBytes(this.input4);
- assertThat(result1.length, is(4));
-
- }
-
- /**
- * Tests addLengthAndCheckSum() method.
- */
- @Test
- public void testAddLengthAndCheckSum() throws Exception {
- result1 = OspfUtil.addLengthAndCheckSum(packet, ospfLengthPos1, ospfLengthPos2,
- ospfChecksumPos1, ospfChecksumPos2);
- assertThat(result1[ospfChecksumPos1], is(packet[ospfChecksumPos1]));
- assertThat(result1[ospfChecksumPos2], is(packet[ospfChecksumPos2]));
- assertThat(result1[ospfLengthPos1], is(packet[ospfLengthPos1]));
- assertThat(result1[ospfLengthPos2], is(packet[ospfLengthPos2]));
- }
-
- /**
- * Tests addMetadata() method.
- */
- @Test
- public void testAddMetadata() throws Exception {
- result1 = OspfUtil.addMetadata(2, packet, 1, Ip4Address.valueOf("1.1.1.1"));
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests addLengthAndCheckSum() method.
- */
- @Test
- public void testAddLsaLengthAndCheckSum() throws Exception {
- result1 = OspfUtil.addLengthAndCheckSum(rLsa, lsaLengthPos1, lsaLengthPos2,
- lsaChecksumPos1, lsaChecksumPos2);
- assertThat(result1[lsaLengthPos1], is(rLsa[lsaLengthPos1]));
- assertThat(result1[lsaLengthPos2], is(rLsa[lsaLengthPos2]));
- assertThat(result1[lsaChecksumPos1], is(rLsa[lsaChecksumPos1]));
- assertThat(result1[lsaChecksumPos2], is(rLsa[lsaChecksumPos2]));
- }
-
- /**
- * Tests addMetadata() method.
- */
- @Test
- public void testAddMetaData() throws Exception {
- result1 = OspfUtil.addMetadata(2, packet, 1, Ip4Address.valueOf("2.2.2.2"));
- assertThat(result1, is(notNullValue()));
- }
-
- /**
- * Tests sameNetwork() method.
- */
- @Test
- public void testSameNetwork() throws Exception {
- result2 = OspfUtil.sameNetwork(Ip4Address.valueOf("10.10.10.10"), Ip4Address.valueOf("10.10.10.11"),
- Ip4Address.valueOf("255.255.255.255"));
- assertThat(result2, is(false));
- result2 = OspfUtil.sameNetwork(Ip4Address.valueOf("10.10.10.10"), Ip4Address.valueOf("10.10.10.10"),
- Ip4Address.valueOf("255.255.255.255"));
- assertThat(result2, is(true));
- }
-
- /**
- * Tests isOpaqueEnabled() method.
- */
- @Test
- public void testIsOpaqueEnabled() throws Exception {
- result2 = OspfUtil.isOpaqueEnabled(2);
- assertThat(result2, is(false));
- }
-
- /**
- * Tests sameNetwork() method.
- */
- @Test
- public void testisIsOpaqueEnabled() throws Exception {
- result2 = OspfUtil.isOpaqueEnabled(2);
- assertThat(result2, is(false));
- }
-
- /**
- * Tests readLsaHeader() method.
- */
- @Test
- public void testReadLsaHeader() throws Exception {
- byte[] header = {0, 10, 2, 1, 7, 7, 7, 7, 7, 7, 7, 7, -128, 0, 0, 2, 46, -126, 0,
- 48, 0, 0, 0, 2, 1, 1, 1, 1, 10, 10, 10, 7, 1, 0, 0, 10, 10, 10, 10, 0, -1, -1, -1,
- 0, 3, 0, 0, 10, 0, 10, 66, 10, 1, 0, 0, 1, 7, 7, 7, 7, -128, 0, 0, 1, -64, 79, 0,
- 116, 0, 1, 0, 4, 0, 0, 0, 0, 0, 2, 0, 84, 0, 1, 0, 1, 1, 0, 0, 0, 0, 2, 0, 4, 10,
- 10, 10, 0, 0, 5, 0, 4, 0, 0, 0, 0, 0, 6, 0, 4, 73, -104, -106, -128, 0, 7, 0, 4, 73,
- -104, -106, -128, 0, 8, 0, 32, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106,
- -128, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106, -128,
- 73, -104, -106, -128, 0, 9, 0, 4, 0, 0, 0, 0};
- channelBuffer = ChannelBuffers.copiedBuffer(header);
- lsaHeader = OspfUtil.readLsaHeader(channelBuffer);
- assertThat(lsaHeader, is(notNullValue()));
- }
-
- /**
- * Tests readLsaHeader() method.
- */
- @Test
- public void testReadreadLsaHeader() throws Exception {
- byte[] header = {0, 2, 2, 1, -64, -88, -86, 3, -64, -88, -86, 3, -128, 0, 0, 1, 58, -100, 0, 48};
- channelBuffer = ChannelBuffers.copiedBuffer(header);
- lsaHeader = OspfUtil.readLsaHeader(channelBuffer);
- assertThat(lsaHeader, is(notNullValue()));
- }
-}
\ No newline at end of file
diff --git a/protocols/pcep/pcepio/BUILD b/protocols/pcep/pcepio/BUILD
deleted file mode 100644
index cfea318..0000000
--- a/protocols/pcep/pcepio/BUILD
+++ /dev/null
@@ -1,8 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
- "@org_apache_karaf_shell_console//jar",
- "@io_netty_netty//jar",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepOutOfBoundMessageException.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepOutOfBoundMessageException.java
deleted file mode 100644
index 27d5502..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepOutOfBoundMessageException.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.exceptions;
-
-/**
- * Custom exception for message out-of-bound.
- */
-public class PcepOutOfBoundMessageException extends Exception {
-
- private static final long serialVersionUID = 3L;
-
- /**
- * Default constructor to create a new exception.
- */
- public PcepOutOfBoundMessageException() {
- super();
- }
-
- /**
- * Constructor to create exception from message and cause.
- *
- * @param message the detail of exception in string
- * @param cause underlying cause of the error
- */
- public PcepOutOfBoundMessageException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Constructor to create exception from message.
- *
- * @param message the detail of exception in string
- */
- public PcepOutOfBoundMessageException(final String message) {
- super(message);
- }
-
- /**
- * Constructor to create exception from cause.
- *
- * @param cause underlying cause of the error
- */
- public PcepOutOfBoundMessageException(final Throwable cause) {
- super(cause);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepParseException.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepParseException.java
deleted file mode 100644
index e1798a3..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepParseException.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.exceptions;
-
-/**
- * Custom Exception for PCEP IO.
- */
-public class PcepParseException extends Exception {
-
- private static final long serialVersionUID = 1L;
- private byte errType = 0;
- private byte errValue = 0;
-
- /**
- * Default constructor to create a new exception.
- */
- public PcepParseException() {
- super();
- }
-
- /**
- * Constructor to create exception from message and cause.
- *
- * @param message the detail of exception in string
- * @param cause underlying cause of the error
- */
- public PcepParseException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Constructor to create exception from message.
- *
- * @param message the detail of exception in string
- */
- public PcepParseException(final String message) {
- super(message);
- }
-
- /**
- * Constructor to create exception from error type and error value.
- *
- * @param errType error type of pcep
- * @param errValue error value of pcep
- */
- public PcepParseException(final byte errType, final byte errValue) {
- super();
- this.errType = errType;
- this.errValue = errValue;
- }
-
- /**
- * Constructor to create exception from cause.
- *
- * @param cause underlying cause of the error
- */
- public PcepParseException(final Throwable cause) {
- super(cause);
- }
-
- /**
- * Returns error type for this exception.
- *
- * @return ErrorType
- */
- public byte getErrorType() {
- return this.errType;
- }
-
- /**
- * Returns error value for this exception.
- *
- * @return ErrorValue
- */
- public byte getErrorValue() {
- return this.errValue;
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepTunnelAttributeException.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepTunnelAttributeException.java
deleted file mode 100644
index d573109..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepTunnelAttributeException.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.exceptions;
-
-/**
- * Custom exception for Tunnel Attributes.
- */
-public class PcepTunnelAttributeException extends Exception {
-
- private static final long serialVersionUID = 2L;
-
- /**
- * Default constructor to create a new exception.
- */
- public PcepTunnelAttributeException() {
- super();
- }
-
- /**
- * Constructor to create exception from message and cause.
- *
- * @param message the detail of exception in string
- * @param cause underlying cause of the error
- */
- public PcepTunnelAttributeException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Constructor to create exception from message.
- *
- * @param message the detail of exception in string
- */
- public PcepTunnelAttributeException(final String message) {
- super(message);
- }
-
- /**
- * Constructor to create exception from cause.
- *
- * @param cause underlying cause of the error
- */
- public PcepTunnelAttributeException(final Throwable cause) {
- super(cause);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/package-info.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/package-info.java
deleted file mode 100644
index b3d452e..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCEP custom exceptions.
- */
-package org.onosproject.pcepio.exceptions;
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcInitiatedLspRequest.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcInitiatedLspRequest.java
deleted file mode 100644
index 4905665..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcInitiatedLspRequest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity Provides PcInitiatedLspRequest for PCEP Initiate message.
- * Reference : PCE initiated tunnel setup draft-ietf-pce-pce-initiated-lsp-03.
- */
-public interface PcInitiatedLspRequest {
-
- /**
- * Returns object of PcepSrpObject.
- *
- * @return srpObject PCEP SRP object
- */
- PcepSrpObject getSrpObject();
-
- /**
- * Returns object of PcepLspObject.
- *
- * @return lspObject PCEP LSP object
- */
- PcepLspObject getLspObject();
-
- /**
- * Returns object of PcepEndPointsObject.
- *
- * @return endPointsObject PCEP EndPoints object
- */
- PcepEndPointsObject getEndPointsObject();
-
- /**
- * Returns object of PcepEroObject.
- *
- * @return eroObject PCEP ERO object
- */
- PcepEroObject getEroObject();
-
- /**
- * Returns object of PcepAttribute.
- *
- * @return pcepAttribute PCEP Attributes
- */
- PcepAttribute getPcepAttribute();
-
- /**
- * Sets PcepSrpObject.
- *
- * @param srpobj PCEP SRP object
- */
- void setSrpObject(PcepSrpObject srpobj);
-
- /**
- * Sets PcepLspObject.
- *
- * @param lspObject PCEP LSP object
- */
- void setLspObject(PcepLspObject lspObject);
-
- /**
- * Sets PcepEndPointsObject.
- *
- * @param endPointsObject PCEP EndPoints object
- */
- void setEndPointsObject(PcepEndPointsObject endPointsObject);
-
- /**
- * Sets PcepEroObject.
- *
- * @param eroObject PCEP ERO object
- */
- void setEroObject(PcepEroObject eroObject);
-
- /**
- * Sets PcepAttribute.
- *
- * @param pcepAttribute PCEP Attributes
- */
- void setPcepAttribute(PcepAttribute pcepAttribute);
-
- /**
- * Builder interface with get and set functions to build PcInitiatedLspRequest.
- */
- interface Builder {
-
- /**
- * Builds PcInitiatedLspRequest.
- *
- * @return PcInitiatedLspRequest
- * @throws PcepParseException when mandatory object is not set
- */
- PcInitiatedLspRequest build() throws PcepParseException;
-
- /**
- * Returns object of PcepSrpObject.
- *
- * @return srpObject
- */
- PcepSrpObject getSrpObject();
-
- /**
- * Returns object of PcepLspObject.
- *
- * @return lspObject
- */
- PcepLspObject getLspObject();
-
- /**
- * Returns object of PcepEndPointsObject.
- *
- * @return endPointsObject
- */
- PcepEndPointsObject getEndPointsObject();
-
- /**
- * Returns object of PcepEroObject.
- *
- * @return eroObject
- */
- PcepEroObject getEroObject();
-
- /**
- * Returns object of PcepAttribute.
- *
- * @return pcepAttribute
- */
- PcepAttribute getPcepAttribute();
-
- /**
- * Sets PcepSrpObject.
- *
- * @param srpobj PCEP SRP Object
- * @return builder by setting PcepSrpObject
- */
- Builder setSrpObject(PcepSrpObject srpobj);
-
- /**
- * Sets PcepLspObject.
- *
- * @param lspObject PCEP LSP Object
- * @return builder by setting PcepLspObject
- */
- Builder setLspObject(PcepLspObject lspObject);
-
- /**
- * Sets PcepEndPointsObject.
- *
- * @param endPointsObject EndPoints Object
- * @return builder by setting PcepEndPointsObject
- */
- Builder setEndPointsObject(PcepEndPointsObject endPointsObject);
-
- /**
- * Sets PcepEroObject.
- *
- * @param eroObject PCEP ERO Object
- * @return builder by setting PcepEroObject
- */
- Builder setEroObject(PcepEroObject eroObject);
-
- /**
- * Sets PcepAttribute.
- *
- * @param pcepAttribute PCEP Attributes
- * @return builder by setting PcepAttribute
- */
- Builder setPcepAttribute(PcepAttribute pcepAttribute);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepAttribute.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepAttribute.java
deleted file mode 100644
index 0c51002..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepAttribute.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity which Provides List of PCEP Attributes.
- */
-public interface PcepAttribute {
-
- /**
- * writes lspa , bandwidth , Metriclist and Iro objects to the channel.
- *
- * @param bb of type channel buffer.
- * @return object length index.
- * @throws PcepParseException while writing objects to channel buffer
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Returns PcepLspaObject.
- *
- * @return LspaObject
- */
- PcepLspaObject getLspaObject();
-
- /**
- * Returns PcepBandwidthObject.
- *
- * @return BandwidthObject
- */
- PcepBandwidthObject getBandwidthObject();
-
- /**
- * Returns PcepIroObject.
- *
- * @return iroObject
- */
- PcepIroObject getIroObject();
-
- /**
- * Sets the PcepBandwidthObject.
- *
- * @param bandwidthObject bandwidth object
- */
- void setBandwidthObject(PcepBandwidthObject bandwidthObject);
-
- /**
- * Sets the PcepLspaObject.
- *
- * @param lspaObject lspa object
- */
- void setLspaObject(PcepLspaObject lspaObject);
-
- /**
- * Sets the PcepIroObject.
- *
- * @param iroObject iro object
- */
- void setIroObject(PcepIroObject iroObject);
-
- /**
- * Returns PcepMetricObject List.
- *
- * @return list of metric objects
- */
- LinkedList<PcepMetricObject> getMetricObjectList();
-
- /**
- * Sets PcepMetricObject List.
- *
- * @param llMetricList list of metric objects
- */
- void setMetricObjectList(LinkedList<PcepMetricObject> llMetricList);
-
- /**
- * Builder interface with get and set functions to build PcepAttribute.
- */
- interface Builder {
-
- /**
- * Builds PcepAttribute.
- *
- * @return PcepAttribute
- */
- PcepAttribute build();
-
- /**
- * Returns PcepLspaObject.
- *
- * @return LspaObject
- */
- PcepLspaObject getLspaObject();
-
- /**
- * Returns PcepBandwidthObject.
- *
- * @return BandwidthObject
- */
- PcepBandwidthObject getBandwidthObject();
-
- /**
- * Returns PcepIroObject.
- *
- * @return iroObject
- */
- PcepIroObject getIroObject();
-
- /**
- * Sets the PcepBandwidthObject.
- *
- * @param bandwidthObject bandwidth object
- * @return Builder object for PcepAttrubute
- */
- Builder setBandwidthObject(PcepBandwidthObject bandwidthObject);
-
- /**
- * Sets the PcepLspaObject.
- *
- * @param lspaObject lspa object
- * @return Builder object for PcepAttrubute
- */
- Builder setLspaObject(PcepLspaObject lspaObject);
-
- /**
- * Sets the PcepIroObject.
- *
- * @param iroObject iro object
- * @return Builder object for PcepAttrubute
- */
- Builder setIroObject(PcepIroObject iroObject);
-
- /**
- * Returns PcepMetricObject List.
- *
- * @return list of metric objects
- */
- LinkedList<PcepMetricObject> getMetricObjectList();
-
- /**
- * Sets PcepMetricObject List.
- *
- * @param llMetricList list of metric objects
- * @return Builder object for PcepAttrubute
- */
- Builder setMetricObjectList(LinkedList<PcepMetricObject> llMetricList);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepBandwidthObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepBandwidthObject.java
deleted file mode 100644
index 03b84b4..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepBandwidthObject.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-
-/**
- * Abstraction of an entity providing PCEP Bandwidth Object.
- */
-public interface PcepBandwidthObject {
-
- /**
- * Returns bandwidth value.
- *
- * @return bandwidth value
- */
- float getBandwidth();
-
- /**
- * Sets bandwidth with specified value.
- *
- * @param iBandwidth Bandwidth's value
- */
- void setBandwidth(float iBandwidth);
-
- /**
- * Writes the BandwidthObject into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException if bandwidth object header fails to write in channel buffer
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build bandwidth object.
- */
- interface Builder {
-
- /**
- * Builds BandwidthObject.
- *
- * @return BandwidthObject
- * @throws PcepParseException if build fails while creating PcepBandwidthObject
- */
- PcepBandwidthObject build() throws PcepParseException;
-
- /**
- * Returns bandwidth object header.
- *
- * @return bandwidth object header
- */
- PcepObjectHeader getBandwidthObjHeader();
-
- /**
- * Sets bandwidth object header and returns its builder.
- *
- * @param obj Bandwidth object header
- * @return Builder by setting Bandwidth object header
- */
- Builder setBandwidthObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns bandwidth value.
- *
- * @return bandwidth
- */
- float getBandwidth();
-
- /**
- * Sets bandwidth value and return its builder.
- *
- * @param iBandwidth bandwidth value
- * @return Builder by setting bandwidth
- */
- Builder setBandwidth(float iBandwidth);
-
- /**
- * Sets P flag in Bandwidth object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in Bandwidth object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepCloseMsg.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepCloseMsg.java
deleted file mode 100644
index 72d94d9..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepCloseMsg.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-
-/**
- * Abstraction of an entity providing PCEP Close Message.
- */
-public interface PcepCloseMsg extends PcepObject, PcepMessage {
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns reason field in Close message.
- *
- * @return reason field
- */
- byte getReason();
-
- /**
- * Sets reason field in Close message with specified value.
- *
- * @param value of Reason field
- */
- void setReason(byte value);
-
- /**
- * Returns LinkedList of Optional Tlv in Close Message.
- *
- * @return list of optional tlv
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Sets LinkedList of Optional Tlvs in Close Message.
- *
- * @param llOptionalTlv LinkedList of type PcepValueType
- */
- void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- @Override
- void writeTo(ChannelBuffer channelBuffer) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build Close message.
- */
- interface Builder extends PcepMessage.Builder {
-
- @Override
- PcepCloseMsg build();
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns Close Object header.
- *
- * @return Close Object header
- */
- PcepObjectHeader getCloseObjHeader();
-
- /**
- * Sets close object header and returns its builder.
- *
- * @param obj close object header
- * @return Builder by setting Close object header
- */
- Builder setCloseObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns reason field in Close message.
- *
- * @return reason field in Close message
- */
- byte getReason();
-
- /**
- * Sets reason field and return its builder.
- *
- * @param value of Reason field
- * @return builder by setting reason field
- */
- Builder setReason(byte value);
-
- /**
- * Returns LinkedList of Optional Tlvs.
- *
- * @return list of optional tlv
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Sets LinkedList of Optional Tlvs in Close Message.
- *
- * @param llOptionalTlv list of optional tlv
- * @return Builder by setting Optional Tlvs
- */
- Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Sets P flag in Close object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in Close object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEndPointsObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEndPointsObject.java
deleted file mode 100644
index 1a41129..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEndPointsObject.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-
-/**
- * Abstraction of an entity providing PCEP End Points Object.
- */
-public interface PcepEndPointsObject {
-
- /**
- * Returns Source IpAddress from End Points Object.
- *
- * @return Source IpAddress from End Points Object
- */
- int getSourceIpAddress();
-
- /**
- * Sets Source IpAddress in End Points Object.
- *
- * @param sourceIpAddress Source IP Address
- */
- void setSourceIpAddress(int sourceIpAddress);
-
- /**
- * Returns Destination IpAddress from End Points Object.
- *
- * @return Destination IpAddress from End Points Object
- */
- int getDestIpAddress();
-
- /**
- * Sets Destination IpAddress in End Points Object.
- *
- * @param destIpAddress Destination IP Address
- */
- void setDestIpAddress(int destIpAddress);
-
- /**
- * Writes the EndPointsObject into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException while writing EndPointObject into ChannelBuffer
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build EndPoints object.
- */
- interface Builder {
-
- /**
- * Builds End Points Object.
- *
- * @return End Points Object
- * @throws PcepParseException while building EndPointObject
- */
- PcepEndPointsObject build() throws PcepParseException;
-
- /**
- * Returns End Points Object header.
- *
- * @return End Points Object header
- */
- PcepObjectHeader getEndPointsObjHeader();
-
- /**
- * Sets End Points Object header and returns its builder.
- *
- * @param obj End Points Object header
- * @return Builder by setting End Points Object header
- */
- Builder setEndPointsObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns Source IpAddress from End Points Object.
- *
- * @return Source IpAddress from End Points Object
- */
- int getSourceIpAddress();
-
- /**
- * Sets Source IpAddress in End Points Object and returns builder.
- *
- * @param sourceIpAddress Source IP Address
- * @return Builder by setting Source IpAddress in End Points Object
- */
- Builder setSourceIpAddress(int sourceIpAddress);
-
- /**
- * Returns Destination IpAddress from End Points Object.
- *
- * @return Destination IpAddress from End Points Object
- */
- int getDestIpAddress();
-
- /**
- * Sets Destination IpAddress in End Points Object.
- *
- * @param destIpAddress Destination IP Address
- * @return Builder by setting Destination IpAddress in End Points Object
- */
- Builder setDestIpAddress(int destIpAddress);
-
- /**
- * Sets P flag in Bandwidth object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in Bandwidth object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEroObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEroObject.java
deleted file mode 100644
index 69b7271..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEroObject.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-
-/**
- * Abstraction of an entity providing PCEP ERO Object.
- */
-public interface PcepEroObject {
-
- /**
- * Return LinkedList of SubObjects of ERO Object.
- *
- * @return list of subobjects
- */
- LinkedList<PcepValueType> getSubObjects();
-
- /**
- * Sets LinkedList of SubObjects in ERO Object.
- *
- * @param llSubObjects list of subobjects
- */
- void setSubObjects(LinkedList<PcepValueType> llSubObjects);
-
- /**
- * Writes the ERO Object into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException while writing ERO Object into ChannelBuffer
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build ERO object.
- */
- interface Builder {
-
- /**
- * Builds ERO Object.
- *
- * @return ERO Object
- */
- PcepEroObject build();
-
- /**
- * Returns ERO Object Header.
- *
- * @return ERO Object Header
- */
- PcepObjectHeader getEroObjHeader();
-
- /**
- * Sets ERO Object header and returns its builder.
- *
- * @param obj ERO Object header
- * @return Builder by setting ERO Object header
- */
- Builder setEroObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns LinkedList of SubObjects in ERO Objects.
- *
- * @return list of subobjects
- */
- LinkedList<PcepValueType> getSubObjects();
-
- /**
- * Sets LinkedList of SubObjects and returns its builder.
- *
- * @param llSubObjects list of SubObjects
- * @return Builder by setting list of SubObjects
- */
- Builder setSubObjects(LinkedList<PcepValueType> llSubObjects);
-
- /**
- * Sets P flag in ERO object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in ERO object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepError.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepError.java
deleted file mode 100644
index 86220aa..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepError.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity which provides PCEP error for PCEP error message.
- */
-public interface PcepError {
-
- /**
- * Returns the PcepRPObject List.
- *
- * @return list of type PcepRPObject
- */
- List<PcepRPObject> getRPObjList();
-
- /**
- * Sets the RP Objects lists.
- *
- * @param rpObjList list of type PcepRPObject
- */
- void setRPObjList(List<PcepRPObject> rpObjList);
-
- /**
- * Returns the PcepLSObject List.
- *
- * @return list of type PcepLSObject
- */
- List<PcepLSObject> getLSObjList();
-
- /**
- * Sets the LS Objects lists.
- *
- * @param lsObjList list of type PcepLSObject
- */
- void setLSObjList(List<PcepLSObject> lsObjList);
-
- /**
- * Returns the PcepErrorObject.
- *
- * @return list of type PcepErrorObject
- */
- List<PcepErrorObject> getErrorObjList();
-
- /**
- * Sets the Error Objects lists.
- *
- * @param errorObjList list of type PcepErrorObject
- */
- void setErrorObjList(List<PcepErrorObject> errorObjList);
-
- /**
- * Writes the byte stream of PCEP error to the channel buffer.
- *
- * @param bb of type channel buffer
- * @return object length index
- * @throws PcepParseException while writing Error part into ChannelBuffer
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build PcepError.
- */
- interface Builder {
-
- /**
- * Builds PcepError Object.
- *
- * @return PcepError Object
- */
- PcepError build();
-
- /**
- * Returns the PcepRPObject.
- *
- * @return list of type PcepRPObject
- */
- List<PcepRPObject> getRPObjList();
-
- /**
- * Sets RP Object lists and returns its builder.
- *
- * @param rpObjList list of type PcepRpObject
- * @return builder by setting Linked list of RP Object
- */
- Builder setRPObjList(List<PcepRPObject> rpObjList);
-
- /**
- * Returns the PcepLSObject.
- *
- * @return lsObjList of type PcepLSObject
- */
- List<PcepLSObject> getLSObjList();
-
- /**
- * Sets LS Object lists and returns its builder.
- *
- * @param lsObjList list of type PcepLSObject
- * @return builder by setting list of type PcepLSObject
- */
- Builder setLSObjList(List<PcepLSObject> lsObjList);
-
- /**
- * Returns the PcepErrorObject.
- *
- * @return list of type PcepErrorObject
- */
- List<PcepErrorObject> getErrorObjList();
-
- /**
- * Sets Error Object lists and returns its builder.
- *
- * @param errorObjList list of type PcepErrorObject
- * @return builder by setting list of type PcepErrorObject
- */
- Builder setErrorObjList(List<PcepErrorObject> errorObjList);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorInfo.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorInfo.java
deleted file mode 100644
index 3f2cdaf..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorInfo.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity which provides PCEP Error Info.
- * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02.
- */
-public interface PcepErrorInfo {
-
- /**
- * Returns whether error info list is present or not.
- *
- * @return true if error info present, false otherwise
- */
- boolean isErrorInfoPresent();
-
- /**
- * Reads from channel buffer for TE and RP objects.
- *
- * @param bb of channel buffer
- * @throws PcepParseException while parsing Error info part.
- */
- void read(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Writes byte stream of PCEP error info to channel buffer.
- *
- * @param bb of type channel buffer
- * @throws PcepParseException while writing Error info part into Channel Buffer.
- */
- void write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Returns Error Value in PCEP-ERROR Object.
- *
- * @return list of Error Value in PCEP-ERROR Object
- */
- List<Integer> getErrorValue();
-
- /**
- * Returns Error Type in PCEP-ERROR Object.
- *
- * @return list of Error Type in PCEP-ERROR Object
- */
- List<Integer> getErrorType();
-
- /**
- * Builder interface with get and set functions to build ErrorInfo.
- */
- interface Builder {
-
- /**
- * Builds ErrorInfo Object.
- *
- * @return ErrorInfo Object.
- */
- PcepErrorInfo build();
-
- /**
- * Returns list of PcepError.
- *
- * @return list of PcepError
- */
- List<PcepError> getPcepErrorList();
-
- /**
- * Sets PcepError lists and returns its builder.
- *
- * @param llPcepErrorList list of PcepError
- * @return builder by setting list of PcepError.
- */
- Builder setPcepErrorList(List<PcepError> llPcepErrorList);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorMsg.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorMsg.java
deleted file mode 100644
index 15c5163..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorMsg.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.ErrorObjListWithOpen;
-
-/**
- * Abstraction of an entity providing PCEP Error Message.
- */
-public interface PcepErrorMsg extends PcepMessage {
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns Object of ErrorObjListWithOpen.
- *
- * @return Object of ErrorObjListWithOpen
- */
- ErrorObjListWithOpen getErrorObjListWithOpen();
-
- /**
- * Sets errObjListWithOpen object.
- *
- * @param errObjListWithOpen error object List with open object
- */
- void setErrorObjListWithOpen(ErrorObjListWithOpen errObjListWithOpen);
-
- /**
- * Returns Object of PcepErrorInfo.
- *
- * @return Object of PcepErrorInfo
- */
- PcepErrorInfo getPcepErrorInfo();
-
- /**
- * Sets errInfo Object.
- *
- * @param errInfo error information
- */
- void setPcepErrorInfo(PcepErrorInfo errInfo);
-
- @Override
- void writeTo(ChannelBuffer channelBuffer) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build PCEP Error message.
- */
- interface Builder extends PcepMessage.Builder {
-
- @Override
- PcepErrorMsg build();
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns Object of ErrorObjListWithOpen.
- *
- * @return Object of ErrorObjListWithOpen
- */
- ErrorObjListWithOpen getErrorObjListWithOpen();
-
- /**
- * Sets errObjListWithOpen object.
- *
- * @param errObjListWithOpen error object with open object
- * @return builder by setting Object of ErrorObjListWithOpen
- */
- Builder setErrorObjListWithOpen(ErrorObjListWithOpen errObjListWithOpen);
-
- /**
- * Returns Object of PcepErrorInfo.
- *
- * @return Object of PcepErrorInfo
- */
- PcepErrorInfo getPcepErrorInfo();
-
- /**
- * Sets errInfo Object.
- *
- * @param errInfo error information
- * @return builder by getting Object of PcepErrorInfo
- */
- Builder setPcepErrorInfo(PcepErrorInfo errInfo);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorObject.java
deleted file mode 100644
index 3dc7ceb..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorObject.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-
-/**
- * Abstraction of an entity providing PCEP Error Object.
- */
-public interface PcepErrorObject {
-
- /**
- * Returns Error Type in Error Object.
- *
- * @return Error Type in Error Object
- */
- int getErrorType();
-
- /**
- * Sets Error Type in Error Object.
- *
- * @param value Error Type
- */
- void setErrorType(byte value);
-
- /**
- * Returns Error Value in Error Object.
- *
- * @return Error Value
- */
- byte getErrorValue();
-
- /**
- * Sets Error Value in Error Object.
- *
- * @param value Error Value
- */
- void setErrorValue(byte value);
-
- /**
- * Returns Optional Tlvs in Error Object.
- *
- * @return list of Optional Tlvs in Error Object
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Sets Optional Tlvs in Error Object.
- *
- * @param llOptionalTlv list of Optional Tlvs
- */
- void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Writes the Error Object into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException while writing Error Object into ChannelBuffer
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build Error object.
- */
- interface Builder {
-
- /**
- * Builds Error Object.
- *
- * @return Error Object.
- */
- PcepErrorObject build();
-
- /**
- * Returns Error Object header.
- *
- * @return Error Object header
- */
- PcepObjectHeader getErrorObjHeader();
-
- /**
- * Sets Error Object header and returns its Builder.
- *
- * @param obj Error Object header
- * @return Builder by setting Error Object header
- */
- Builder setErrorObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns Error Type in Error Object.
- *
- * @return Error Type in Error Object
- */
- int getErrorType();
-
- /**
- * Sets Error Type and returns its builder.
- *
- * @param value of Error-Type field
- * @return builder by setting Error Type field.
- */
- Builder setErrorType(byte value);
-
- /**
- * Returns Error Value in Error Object.
- *
- * @return Error Value
- */
- byte getErrorValue();
-
- /**
- * Sets Error Value and returns its builder.
- *
- * @param value of Error-Value field
- * @return Builder by setting Error Value field.
- */
- Builder setErrorValue(byte value);
-
- /**
- * Returns list of Optional Tlvs of Error Object.
- *
- * @return list of Optional Tlvs of Error Object
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Sets Optional Tlvs of Error Object and returns its Builder.
- *
- * @param llOptionalTlv Optional Tlvs of Error Object
- * @return Builder by setting Optional Tlvs.
- */
- Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Sets P flag in Error object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in Error object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactories.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactories.java
deleted file mode 100644
index 4f6f24e..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactories.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.ver1.PcepFactoryVer1;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstraction to provide the version for PCEP.
- */
-public final class PcepFactories {
-
- private static final Logger log = LoggerFactory.getLogger(PcepFactories.class);
-
- private static final GenericReader GENERIC_READER = new GenericReader();
-
- public static final byte SHIFT_FLAG = 5;
-
- private PcepFactories() {
- }
-
- /**
- * Returns the instance of PCEP Version.
- *
- * @param version PCEP version
- * @return PCEP version
- */
- public static PcepFactory getFactory(PcepVersion version) {
- switch (version) {
- case PCEP_1:
- return PcepFactoryVer1.INSTANCE;
- default:
- throw new IllegalArgumentException("Unknown version: " + version);
- }
- }
-
- private static class GenericReader implements PcepMessageReader<PcepMessage> {
-
- @Override
- public PcepMessage readFrom(ChannelBuffer bb) throws PcepParseException, PcepOutOfBoundMessageException {
-
- if (!bb.readable()) {
- throw new PcepParseException("Empty message received");
- }
-
- /*
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Ver | Flags | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- * Currently Version 1 is supported
- * Currently no flags are used, it is all ignored
- */
-
- byte packetVersion = bb.getByte(bb.readerIndex());
- packetVersion = (byte) (packetVersion >> SHIFT_FLAG);
- PcepFactory factory;
-
- switch (packetVersion) {
-
- case 1:
- factory = org.onosproject.pcepio.protocol.ver1.PcepFactoryVer1.INSTANCE;
- break;
- default:
- throw new PcepParseException("Unknown Packet version: " + packetVersion);
- }
- return factory.getReader().readFrom(bb);
- }
- }
-
- /**
- * Returns GENERIC_READER.
- *
- * @return GENERIC_READER
- */
- public static PcepMessageReader<PcepMessage> getGenericReader() {
- return GENERIC_READER;
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactory.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactory.java
deleted file mode 100644
index 3f7bd85..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactory.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-/**
- * Abstraction of an Message factory providing Builder functions to PCEP Messages and Objects.
- */
-public interface PcepFactory {
-
- /**
- * Returns Builder Object for Open Message.
- *
- * @return Builder Object for Open Message
- */
- PcepOpenMsg.Builder buildOpenMsg();
-
- /**
- * Returns Builder Object for Open Object.
- *
- * @return Builder Object for Open Object
- */
- PcepOpenObject.Builder buildOpenObject();
-
- /**
- * Returns Builder Object for Keepalive Message.
- *
- * @return Builder Object for Keepalive Message
- */
- PcepKeepaliveMsg.Builder buildKeepaliveMsg();
-
- /**
- * Returns Builder Object for Close Message.
- *
- * @return Builder Object for Close Message
- */
- PcepCloseMsg.Builder buildCloseMsg();
-
- /**
- * Returns Builder Object for Report Message.
- *
- * @return Builder Object for Report Message
- */
- PcepReportMsg.Builder buildReportMsg();
-
- /**
- * Returns Builder Object for Update Message.
- *
- * @return Builder Object for Update Message
- */
- PcepUpdateMsg.Builder buildUpdateMsg();
-
- /**
- * Returns Builder Object for Initiate Message.
- *
- * @return Builder Object for Initiate Message
- */
- PcepInitiateMsg.Builder buildPcepInitiateMsg();
-
- /**
- * Returns Builder Object for LSP Object.
- *
- * @return Builder Object for LSP Object
- */
- PcepLspObject.Builder buildLspObject();
-
- /**
- * Returns Builder Object for SRP Object.
- *
- * @return Builder Object for SRP Object
- */
- PcepSrpObject.Builder buildSrpObject();
-
- /**
- * Returns Builder Object for EndPoints Object.
- *
- * @return Builder Object for EndPoints Object
- */
- PcepEndPointsObject.Builder buildEndPointsObject();
-
- /**
- * Returns Builder Object for ERO Object.
- *
- * @return Builder Object for ERO Object
- */
- PcepEroObject.Builder buildEroObject();
-
- /**
- * Returns Builder Object for RRO Object.
- *
- * @return Builder Object for RRO Object
- */
- PcepRroObject.Builder buildRroObject();
-
- /**
- * Returns Builder Object for LSPA Object.
- *
- * @return Builder Object for LSPA Object
- */
- PcepLspaObject.Builder buildLspaObject();
-
- /**
- * Returns Builder Object for IRO Object.
- *
- * @return Builder Object for IRO Object
- */
- PcepIroObject.Builder buildIroObject();
-
- /**
- * Returns Builder Object for METRIC Object.
- *
- * @return Builder Object for METRIC Object
- */
- PcepMetricObject.Builder buildMetricObject();
-
- /**
- * Returns Builder Object for Bandwidth Object.
- *
- * @return Builder Object for Bandwidth Object
- */
- PcepBandwidthObject.Builder buildBandwidthObject();
-
- /**
- * Returns PCEP Message Reader.
- *
- * @return PCEP Message Reader
- */
- PcepMessageReader<PcepMessage> getReader();
-
- /**
- * Returns PCEP version.
- *
- * @return PCEP version
- */
- PcepVersion getVersion();
-
- /**
- * Returns PcepStateReport.
- *
- * @return PcepStateReport
- */
- PcepStateReport.Builder buildPcepStateReport();
-
- /**
- * Returns PcepUpdateRequest.
- *
- * @return PcepUpdateRequest
- */
- PcepUpdateRequest.Builder buildPcepUpdateRequest();
-
- /**
- * Returns PcInitiatedLspRequest.
- *
- * @return PcInitiatedLspRequest
- */
- PcInitiatedLspRequest.Builder buildPcInitiatedLspRequest();
-
- /**
- * Returns PcepMsgPath.
- *
- * @return PcepMsgPath
- */
- PcepMsgPath.Builder buildPcepMsgPath();
-
- /**
- * Return PcepAttribute list.
- *
- * @return PcepAttribute
- */
- PcepAttribute.Builder buildPcepAttribute();
-
- /**
- * Returns Builder Object for LabelUpdate message.
- *
- * @return Builder Object for LabelUpdate message
- */
- PcepLabelUpdateMsg.Builder buildPcepLabelUpdateMsg();
-
- /**
- * Returns Builder Object for PcepLabelUpdate Object.
- *
- * @return Builder Object for PcepLabelUpdate Object
- */
- PcepLabelUpdate.Builder buildPcepLabelUpdateObject();
-
- /**
- * Returns Builder Object for PcepLabel Object.
- *
- * @return Builder Object for PcepLabel Object
- */
- PcepLabelObject.Builder buildLabelObject();
-
- /**
- * Returns Builder Object for Error Message.
- *
- * @return Builder Object for Error Message
- */
- PcepErrorMsg.Builder buildPcepErrorMsg();
-
- /**
- * Returns Builder Object for Error Object.
- *
- * @return Builder Object for Error Object
- */
- PcepErrorObject.Builder buildPcepErrorObject();
-
- /**
- * Returns Builder Object for FecIpv4Adjacency.
- *
- * @return Builder Object for FecIpv4Adjacency
- */
- PcepFecObjectIPv4Adjacency.Builder buildFecIpv4Adjacency();
-
- /**
- * Returns Builder Object for FecObjectIPv4.
- *
- * @return Builder Object for FecObjectIPv4
- */
- PcepFecObjectIPv4.Builder buildFecObjectIpv4();
-
- /**
- * Returns Builder Object for ErrorInfo.
- *
- * @return Builder Object for ErrorInfo
- */
- PcepErrorInfo.Builder buildPcepErrorInfo();
-
- /**
- * Returns Builder Object for PcepError.
- *
- * @return Builder Object for PcepError
- */
- PcepError.Builder buildPcepError();
-
- /**
- * Returns Builder Object for PcepLabelRangeObject.
- *
- * @return Builder Object for PcepLabelRangeObject
- */
- PcepLabelRangeObject.Builder buildPcepLabelRangeObject();
-
- /**
- * Returns Builder Object for PcepLabelRangeResvMsg.
- *
- * @return Builder Object for PcepLabelRangeResvMsg
- */
- PcepLabelRangeResvMsg.Builder buildPcepLabelRangeResvMsg();
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObject.java
deleted file mode 100644
index 71cf87a..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObject.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity providing PCEP FEC Object.
- */
-public interface PcepFecObject {
-
- /**
- * Returns PCEP Version of FEC Object.
- *
- * @return PCEP Version of FEC Object
- */
- PcepVersion getVersion();
-
- /**
- * Returns FEC Object type.
- *
- * @return FEC Object type
- */
- int getType();
-
- /**
- * Writes the FEC into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException while writing FEC Object into Channel Buffer.
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4.java
deleted file mode 100644
index b15b039..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-
-/**
- * Abstraction of an entity providing PCEP FEC Object of Type 1 IPv4 Node ID.
- */
-public interface PcepFecObjectIPv4 extends PcepFecObject {
-
- /**
- * Returns NodeID of FEC Object.
- *
- * @return NodeID of FEC Object
- */
- int getNodeID();
-
- /**
- * Sets NodeID with specified value.
- *
- * @param value node id
- */
- void setNodeID(int value);
-
- @Override
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build FEC object.
- */
- interface Builder {
-
- /**
- * Builds FEC Object IPv4.
- *
- * @return FEC Object IPv4
- * @throws PcepParseException while creating FEC IPv4 Object.
- */
- PcepFecObjectIPv4 build() throws PcepParseException;
-
- /**
- * Returns FEC Object IPv4 header.
- *
- * @return FEC Object IPv4 header
- */
- PcepObjectHeader getFecIpv4ObjHeader();
-
- /**
- * Sets FEC Object IPv4 header and returns its builder.
- *
- * @param obj FEC Object IPv4 header
- * @return Builder by setting FEC Object IPv4 header
- */
- Builder setFecIpv4ObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns NodeID of FEC Object.
- *
- * @return NodeID of FEC Object
- */
- int getNodeID();
-
- /**
- * Sets NodeID and returns its builder.
- *
- * @param value node id
- * @return builder by setting NodeID
- */
- Builder setNodeID(int value);
-
- /**
- * Sets P flag in FEC object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in FEC object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4Adjacency.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4Adjacency.java
deleted file mode 100644
index b1ed6a3..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4Adjacency.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-
-/**
- * Abstraction of an entity providing FEC Object of Type 3 IPv4 Adjacency.
- */
-public interface PcepFecObjectIPv4Adjacency extends PcepFecObject {
-
- /**
- * Returns Local IPv4Address of FEC Object.
- *
- * @return Local IPv4Address of FEC Object
- */
- int getLocalIPv4Address();
-
- /**
- * Sets Local IPv4Address with specified value.
- *
- * @param value Local IPv4Address
- */
- void seLocalIPv4Address(int value);
-
- /**
- * Returns Remote IPv4Address of FEC Object.
- *
- * @return Remote IPv4Address of FEC Object
- */
- int getRemoteIPv4Address();
-
- /**
- * Sets Remote IPv4Address with specified value.
- *
- * @param value Remote IPv4Address
- */
- void seRemoteIPv4Address(int value);
-
- @Override
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build FEC object.
- */
- interface Builder {
-
- /**
- * Builds FEC Object IPv4 Adjacency.
- *
- * @return FEC Object IPv4 Adjacency
- * @throws PcepParseException while building FEC IPv4 Adjacency object.
- */
- PcepFecObjectIPv4Adjacency build() throws PcepParseException;
-
- /**
- * Returns FEC Object IPv4 Adjacency header.
- *
- * @return FEC Object IPv4 Adjacency header
- */
- PcepObjectHeader getFecIpv4AdjacencyObjHeader();
-
- /**
- * Sets FEC Object IPv4 Adjacency header and returns its builder.
- *
- * @param obj FEC Object IPv4 Adjacency header
- * @return Builder by setting FEC Object IPv4 header
- */
- Builder setFecIpv4AdjacencyObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns Local IPv4Address of FEC Object.
- *
- * @return Local IPv4Address of FEC Object
- */
- int getLocalIPv4Address();
-
- /**
- * Sets Local IPv4Address and returns its builder.
- *
- * @param value Local IPv4Address
- * @return Builder by setting Local IPv4Address
- */
- Builder seLocalIPv4Address(int value);
-
- /**
- * Sets Remote IPv4Address with specified value.
- *
- * @return Remote IPv4 Address
- */
- int getRemoteIPv4Address();
-
- /**
- * Sets Remote IPv4Address and returns its builder.
- *
- * @param value Remote IPv4Address
- * @return Builder by setting Remote IPv4Address
- */
- Builder seRemoteIPv4Address(int value);
-
- /**
- * Sets P flag in FEC object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in FEC object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4UnnumberedAdjacency.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4UnnumberedAdjacency.java
deleted file mode 100644
index 2de5550..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4UnnumberedAdjacency.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-
-/**
- * Abstraction of an entity providing PCEP FEC Object of Type is 5 Unnumbered Adjacency with IPv4 NodeIDs.
- */
-public interface PcepFecObjectIPv4UnnumberedAdjacency extends PcepFecObject {
-
- /**
- * Returns Local NodeID of FEC Object.
- *
- * @return Local NodeID of FEC Object
- */
- int getLocalNodeID();
-
- /**
- * Sets Local NodeID with specified value.
- *
- * @param value Local NodeID
- */
- void setLocalNodeID(int value);
-
- /**
- * Returns Local InterfaceID of FEC Object.
- *
- * @return Local InterfaceID of FEC Object
- */
- int getLocalInterfaceID();
-
- /**
- * Sets Local InterfaceID with specified value.
- *
- * @param value Local InterfaceID
- */
- void setLocalInterfaceID(int value);
-
- /**
- * Returns Remote NodeID of FEC Object.
- *
- * @return Remote NodeID of FEC Object
- */
- int getRemoteNodeID();
-
- /**
- * Sets Remote NodeID with specified value.
- *
- * @param value Remote NodeID
- */
- void setRemoteNodeID(int value);
-
- /**
- * Returns Remote InterfaceID of FEC Object.
- *
- * @return Remote InterfaceID of FEC Object
- */
- int getRemoteInterfaceID();
-
- /**
- * Sets Remote InterfaceID with specified value.
- *
- * @param value Remote InterfaceID
- */
- void setRemoteInterfaceID(int value);
-
- @Override
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build bandwidth object.
- */
- interface Builder {
-
- /**
- * Builds FEC Unnumbered Adjacency with IPv4 Object.
- *
- * @return FEC Unnumbered Adjacency with IPv4 Object
- * @throws PcepParseException when building FEC IPv4 Unnumbered Adjacency object.
- */
- PcepFecObjectIPv4UnnumberedAdjacency build() throws PcepParseException;
-
- /**
- * Returns FEC Unnumbered Adjacency with IPv4 header.
- *
- * @return FEC Unnumbered Adjacency with IPv4 header
- */
- PcepObjectHeader getFecIpv4UnnumberedAdjacencyObjHeader();
-
- /**
- * Sets FEC Unnumbered Adjacency with IPv4 header and returns its builder.
- *
- * @param obj FEC Unnumbered Adjacency with IPv4 header
- * @return Builder by setting FEC Unnumbered Adjacency with IPv4 header
- */
- Builder setFecIpv4UnnumberedAdjacencyObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns Local NodeID of FEC Object.
- *
- * @return Local NodeID of FEC Object
- */
- int getLocalNodeID();
-
- /**
- * Sets Local NodeID and returns its builder.
- *
- * @param value Local NodeID
- * @return Builder by setting Local NodeID
- */
- Builder setLocalNodeID(int value);
-
- /**
- * Returns Local InterfaceID of FEC Object.
- *
- * @return Local InterfaceID of FEC Object
- */
- int getLocalInterfaceID();
-
- /**
- * Sets Local InterfaceID and returns its builder.
- *
- * @param value Local InterfaceID
- * @return Builder by setting Local InterfaceID
- */
- Builder setLocalInterfaceID(int value);
-
- /**
- * Returns Remote NodeID of FEC Object.
- *
- * @return Remote NodeID of FEC Object
- */
- int getRemoteNodeID();
-
- /**
- * Sets Remote NodeID and returns its builder.
- *
- * @param value Remote NodeID
- * @return Builder by setting Remote NodeID
- */
- Builder setRemoteNodeID(int value);
-
- /**
- * Returns Remote InterfaceID of FEC Object.
- *
- * @return Remote InterfaceID of FEC Object
- */
- int getRemoteInterfaceID();
-
- /**
- * Sets Remote InterfaceID and returns its builder.
- *
- * @param value Remote InterfaceID
- * @return Builder by setting Remote InterfaceID
- */
- Builder setRemoteInterfaceID(int value);
-
- /**
- * Sets P flag in FEC object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in FEC object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6.java
deleted file mode 100644
index 5e97a8d..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-
-/**
- * Abstraction of an entity providing FEC Object of Type is 2 IPv6 Node ID.
- */
-public interface PcepFecObjectIPv6 extends PcepFecObject {
-
- /**
- * Returns NodeID of FEC Object.
- *
- * @return NodeID of FEC Object
- */
- byte[] getNodeID();
-
- /**
- * Sets NodeID with specified value.
- *
- * @param value node id
- */
- void setNodeID(byte[] value);
-
- @Override
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build FEC object.
- */
- interface Builder {
-
- /**
- * Builds FEC Object IPv6.
- *
- * @return FEC Object IPv6
- * @throws PcepParseException while building FEC IPv6 Object.
- */
- PcepFecObjectIPv6 build() throws PcepParseException;
-
- /**
- * Returns FEC Object IPv6 header.
- *
- * @return FEC Object IPv6 header
- */
- PcepObjectHeader getFecIpv6ObjHeader();
-
- /**
- * Sets FEC Object IPv6 header and returns its builder.
- *
- * @param obj FEC Object IPv6 header
- * @return Builder by setting FEC Object IPv6 header
- */
- Builder setFecIpv6ObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns NodeID of FEC Object.
- *
- * @return NodeID of FEC Object
- */
- byte[] getNodeID();
-
- /**
- * Sets NodeID and returns its builder.
- *
- * @param value node id
- * @return Builder by setting NodeID
- */
- Builder setNodeID(byte[] value);
-
- /**
- * Sets P flag in FEC object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in FEC object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6Adjacency.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6Adjacency.java
deleted file mode 100644
index 57338ea..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6Adjacency.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-
-/**
- * Abstraction of an entity providing FEC Object of Type is 4 IPv6 Adjacency.
- */
-public interface PcepFecObjectIPv6Adjacency extends PcepFecObject {
-
- /**
- * Returns Local IPv6Address of FEC Object.
- *
- * @return Local IPv6Address of FEC Object
- */
- byte[] getLocalIPv6Address();
-
- /**
- * Sets Local IPv6Address with specified value.
- *
- * @param value Local IPv6Address
- */
- void seLocalIPv6Address(byte[] value);
-
- /**
- * Returns Remote IPv6Address of FEC Object.
- *
- * @return Remote IPv6Address of FEC Object
- */
- byte[] getRemoteIPv6Address();
-
- /**
- * Sets Remote IPv6Address with specified value.
- *
- * @param value Remote IPv6Address
- */
- void seRemoteIPv6Address(byte[] value);
-
- @Override
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build FEC object.
- */
- interface Builder {
-
- /**
- * Builds FEC Object IPv6 Adjacency.
- *
- * @return FEC Object IPv6 Adjacency
- * @throws PcepParseException while building FEC IPv6 Adjacency object.
- */
- PcepFecObjectIPv6Adjacency build() throws PcepParseException;
-
- /**
- * Returns FEC Object IPv6 Adjacency header.
- *
- * @return FEC Object IPv6 Adjacency header
- */
- PcepObjectHeader getFecIpv6AdjacencyObjHeader();
-
- /**
- * Sets FEC Object IPv6 Adjacency header and returns its builder.
- *
- * @param obj FEC Object IPv6 Adjacency header
- * @return Builder by setting FEC Object IPv6 Adjacency header
- */
- Builder setFecIpv6AdjacencyObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns Local IPv6Address of FEC Object.
- *
- * @return Local IPv6Address of FEC Object
- */
- byte[] getLocalIPv6Address();
-
- /**
- * Sets Local IPv6Address and returns its builder.
- *
- * @param value Local IPv6Address
- * @return Builder by setting Local IPv6Address
- */
- Builder setLocalIPv6Address(byte[] value);
-
- /**
- * Returns Remote IPv6Address of FEC Object.
- *
- * @return Remote IPv6Address of FEC Object
- */
- byte[] getRemoteIPv6Address();
-
- /**
- * Sets Remote IPv6Address and returns its builder.
- *
- * @param value Remote IPv6Address
- * @return Builder by setting Remote IPv6Address
- */
- Builder setRemoteIPv6Address(byte[] value);
-
- /**
- * Sets P flag in FEC object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in FEC object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInitiateMsg.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInitiateMsg.java
deleted file mode 100644
index 082b13a..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInitiateMsg.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity providing PCEP Initiate Message.
- */
-public interface PcepInitiateMsg extends PcepObject, PcepMessage {
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns list of PcInitiatedLspRequestList.
- *
- * @return list of PcInitiatedLspRequestList
- */
- LinkedList<PcInitiatedLspRequest> getPcInitiatedLspRequestList();
-
- /**
- * Sets list of PcInitiatedLspRequestList.
- *
- * @param llPcInitiatedLspRequestList list of PcInitiatedLspRequestList
- */
- void setPcInitiatedLspRequestList(LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList);
-
- @Override
- void writeTo(ChannelBuffer channelBuffer) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build Initiate message.
- */
- interface Builder extends PcepMessage.Builder {
-
- @Override
- PcepInitiateMsg build();
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns list of PcInitiatedLspRequestList.
- *
- * @return list of PcInitiatedLspRequestList
- */
- LinkedList<PcInitiatedLspRequest> getPcInitiatedLspRequestList();
-
- /**
- * Sets PcInitiatedLspRequestList.
- *
- * @param llPcInitiatedLspRequestList list of PcInitiatedLspRequestList
- * @return builder by setting list of PcInitiatedLspRequestList
- */
- Builder setPcInitiatedLspRequestList(LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInterLayerObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInterLayerObject.java
deleted file mode 100644
index 9794ffe..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInterLayerObject.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-
-/**
- * Abstraction of an entity providing PCEP INTER Layer Object.
- */
-public interface PcepInterLayerObject {
-
- /**
- * Returns N Flag in INTER Layer Object.
- *
- * @return N Flag in INTER Layer Object
- */
- boolean getbNFlag();
-
- /**
- * Sets N Flag in INTER Layer Object with specified value.
- *
- * @param value N Flag
- */
- void setbNFlag(boolean value);
-
- /**
- * Returns I Flag in INTER Layer Object.
- *
- * @return I Flag in INTER Layer Object
- */
- boolean getbIFlag();
-
- /**
- * Sets I Flag in INTER Layer Object with specified value.
- *
- * @param value I Flag
- */
- void setbIFlag(boolean value);
-
- /**
- * Writes the INTER Layer Object into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException while writing Inter Layer Object.
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build INTER Layer object.
- */
- interface Builder {
-
- /**
- * Builds INTER Layer object.
- *
- * @return INTER Layer object
- */
- PcepInterLayerObject build();
-
- /**
- * Returns INTER Layer object header.
- *
- * @return INTER Layer object header
- */
- PcepObjectHeader getInterLayerObjHeader();
-
- /**
- * Sets INTER Layer object header and returns its builder.
- *
- * @param obj INTER Layer object header
- * @return Builder by setting INTER Layer object header
- */
- Builder setInterLayerObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns N Flag in INTER Layer Object.
- *
- * @return N Flag in INTER Layer Object
- */
- boolean getbNFlag();
-
- /**
- * Sets N flag and return its builder.
- *
- * @param value N flag
- * @return Builder by setting N flag
- */
- Builder setbNFlag(boolean value);
-
- /**
- * Returns I Flag in INTER Layer Object.
- *
- * @return I Flag in INTER Layer Object
- */
- boolean getbIFlag();
-
- /**
- * Sets I flag and return its builder.
- *
- * @param value I flag
- * @return Builder by setting N flag
- */
- Builder setbIFlag(boolean value);
-
- /**
- * Sets P flag in INTER Layer object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in INTER Layer object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepIroObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepIroObject.java
deleted file mode 100644
index 105c545..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepIroObject.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-
-/**
- * Abstraction of an entity providing PCEP IRO Object.
- */
-public interface PcepIroObject {
-
- /**
- * Returns list of SubObjects.
- *
- * @return list of SubObjects
- */
- LinkedList<PcepValueType> getSubObjects();
-
- /**
- * Sets list of SubObjects.
- *
- * @param llSubObjects list of SubObjects
- */
- void setSubObjects(LinkedList<PcepValueType> llSubObjects);
-
- /**
- * Writes the IRO into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException while writing IRO object.
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build IRO object.
- */
- interface Builder {
-
- /**
- * Builds IRO Object.
- *
- * @return IRO Object
- */
- PcepIroObject build();
-
- /**
- * Returns IRO object header.
- *
- * @return IRO object header
- */
- PcepObjectHeader getIroObjHeader();
-
- /**
- * Sets IRO object header and returns its builder.
- *
- * @param obj IRO object header
- * @return Builder by setting IRO object header
- */
- Builder setIroObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns list of SubObjects.
- *
- * @return list of SubObjects
- */
- LinkedList<PcepValueType> getSubObjects();
-
- /**
- * Sets list of SubObjects in IRO Object and returns its builder.
- *
- * @param llSubObjects list of SubObjects
- * @return Builder by setting list of SubObjects
- */
- Builder setSubObjects(LinkedList<PcepValueType> llSubObjects);
-
- /**
- * Sets P flag in IRO object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in IRO object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsg.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsg.java
deleted file mode 100644
index 9c7c4f1..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsg.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Abstraction of an entity providing PCEP Keepalive Message.
- */
-public interface PcepKeepaliveMsg extends PcepObject, PcepMessage {
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- @Override
- void writeTo(ChannelBuffer channelBuffer);
-
- /**
- * Builder interface with get and set functions to build Keepalive message.
- */
- interface Builder extends PcepMessage.Builder {
-
- @Override
- PcepKeepaliveMsg build();
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLSObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLSObject.java
deleted file mode 100644
index 520246e..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLSObject.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-
-/**
- * Abstraction of an entity providing PCEP LS Object.
- */
-public interface PcepLSObject {
-
- /**
- * Returns LS object header.
- *
- * @return LS object header
- */
- PcepObjectHeader getLSObjHeader();
-
- /**
- * Sets LS Object header.
- *
- * @param obj LS Object header
- */
- void setLSObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns ProtocolId in LS Object.
- *
- * @return ProtocolId in LS Object
- */
- byte getProtocolId();
-
- /**
- * Sets ProtocolId in LS Object.
- *
- * @param protId ProtocolId in LS Object
- */
- void setProtocolId(byte protId);
-
- /**
- * Returns R flag in LS Object.
- *
- * @return R flag in LS Object
- */
- boolean getRemoveFlag();
-
- /**
- * Sets R flag in LS Object.
- *
- * @param removeFlag R flag in LS Object
- */
- void setRemoveFlag(boolean removeFlag);
-
- /**
- * Returns sync flag in LS Object.
- *
- * @return sync flag in LS Object
- */
- boolean getSyncFlag();
-
- /**
- * Sets sync flag in LS Object.
- *
- * @param syncFlag sync flag in LS Object
- */
- void setSyncFlag(boolean syncFlag);
-
- /**
- * Returns LS ID in LS Object.
- *
- * @return LS ID in LS Object
- */
- long getLSId();
-
- /**
- * Sets LS ID in LS Object.
- *
- * @param lsId LS ID in LS Object
- */
- void setLSId(long lsId);
-
- /**
- * Returns list of Optional Tlvs in LS Object.
- *
- * @return list of Optional Tlvs
- */
- List<PcepValueType> getOptionalTlv();
-
- /**
- * Sets list of Optional Tlvs in LS Object.
- *
- * @param optionalTlvList list of Optional Tlvs
- */
- void setOptionalTlv(List<PcepValueType> optionalTlvList);
-
- /**
- * Writes the LS Object into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException when object header is not written to channel buffer
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build LS object.
- */
- interface Builder {
-
- /**
- * Builds LS Object.
- *
- * @return LS Object
- */
- PcepLSObject build();
-
- /**
- * Returns LS object header.
- *
- * @return LS object header
- */
- PcepObjectHeader getLSObjHeader();
-
- /**
- * Sets LS object header and returns its builder.
- *
- * @param obj LS object header
- * @return Builder by setting LS object header
- */
- Builder setLSObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns ProtocolId in LS Object.
- *
- * @return ProtocolId in LS Object
- */
- byte getProtocolId();
-
- /**
- * Sets ProtocolId in LS Object and returns its builder.
- *
- * @param protId ProtocolId in LS Object
- * @return Builder by setting ProtocolId
- */
- Builder setProtocolId(byte protId);
-
- /**
- * Returns R flag in LS Object.
- *
- * @return R flag in LS Object
- */
- boolean getRemoveFlag();
-
- /**
- * Sets R flag in LS Object and returns its builder.
- *
- * @param removeFlag R flag in LS Object
- * @return Builder by setting R flag
- */
- Builder setRemoveFlag(boolean removeFlag);
-
- /**
- * Returns sync flag in LS Object.
- *
- * @return sync flag in LS Object
- */
- boolean getSyncFlag();
-
- /**
- * Sets sync flag in LS Object and returns its builder.
- *
- * @param syncFlag sync flag in LS Object
- * @return Builder by setting sync flag
- */
- Builder setSyncFlag(boolean syncFlag);
-
- /**
- * Returns LS ID in LS Object.
- *
- * @return LS ID in LS Object
- */
- long getLSId();
-
- /**
- * Sets LS ID in LS Object and returns its builder.
- *
- * @param lsId LS ID in LS Object
- * @return Builder by setting LS ID
- */
- Builder setLSId(long lsId);
-
- /**
- * Returns list of Optional Tlvs in LS Object.
- *
- * @return list of Optional Tlvs
- */
- List<PcepValueType> getOptionalTlv();
-
- /**
- * Sets list of Optional Tlvs in LS Object and returns its builder.
- *
- * @param optionalTlvList list of Optional Tlvs
- * @return Builder by setting list of Optional Tlvs
- */
- Builder setOptionalTlv(List<PcepValueType> optionalTlvList);
-
- /**
- * Sets Processing rule flag in LS object header and returns its builder.
- *
- * @param value boolean value to set Processing rule flag
- * @return Builder by setting Processing rule flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets Ignore flag in LS object header and returns its builder.
- *
- * @param value boolean value to set Ignore flag
- * @return Builder by setting Ignore flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLSReportMsg.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLSReportMsg.java
deleted file mode 100644
index e257613..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLSReportMsg.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity providing PCEP LS-Report Message.
- */
-public interface PcepLSReportMsg extends PcepObject, PcepMessage {
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns list of PCEP LS Objects.
- *
- * @return list of PCEP LS Objects
- */
- List<PcepLSObject> getLSReportList();
-
- /**
- * Sets list of Optional Tlvs in LS-Report Message.
- *
- * @param lsReportList list of optional Tlvs
- */
- void setLSReportList(List<PcepLSObject> lsReportList);
-
- @Override
- void writeTo(ChannelBuffer channelBuffer) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build LS-Report message.
- */
- interface Builder extends PcepMessage.Builder {
-
- @Override
- PcepLSReportMsg build();
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns list of LS Object in LS Report Message.
- *
- * @return list of LS Objects
- */
- List<PcepLSObject> getLSReportList();
-
- /**
- * Sets list of LS Objects and returns its builder.
- *
- * @param lsReportList list of LS Objects
- * @return Builder object for LS-Report message
- */
- Builder setLSReportList(List<PcepLSObject> lsReportList);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelObject.java
deleted file mode 100644
index 70dad22..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelObject.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-
-/**
- * Abstraction of an entity providing PCEP Label Object.
- */
-public interface PcepLabelObject {
-
- /**
- * Returns O flag in Label Object.
- *
- * @return Boolean value
- */
- boolean getOFlag();
-
- /**
- * Sets O flag in Label Object with specified value.
- *
- * @param value O flag
- */
- void setOFlag(boolean value);
-
- /**
- * Returns Label from Label Object.
- *
- * @return Label value
- */
- int getLabel();
-
- /**
- * Sets Label field in Label Object with specified value.
- *
- * @param value Label
- */
- void setLabel(int value);
-
- /**
- * Returns list of Optional Tlvs.
- *
- * @return list of Optional Tlvs
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Sets Optional Tlvs in Label Object.
- *
- * @param llOptionalTlv list of Optional Tlvs
- */
- void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Writes the Label Object into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException while writing LABEL object into Channel Buffer.
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build Label object.
- */
- interface Builder {
-
- /**
- * Builds Label Object.
- *
- * @return Label Object
- * @throws PcepParseException while building LABEL object.
- */
- PcepLabelObject build() throws PcepParseException;
-
- /**
- * Returns Label object header.
- *
- * @return Label object header
- */
- PcepObjectHeader getLabelObjHeader();
-
- /**
- * Sets Label object header and returns its builder.
- *
- * @param obj Label object header
- * @return Builder by setting Label object header
- */
- Builder setLabelObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns O flag in Label Object.
- *
- * @return Label value
- */
- boolean getOFlag();
-
- /**
- * Sets O flag and return its builder.
- *
- * @param value O flag
- * @return Builder by setting O flag
- */
- Builder setOFlag(boolean value);
-
- /**
- * Returns Label from Label Object.
- *
- * @return Label value
- */
- int getLabel();
-
- /**
- * Sets Label field and return its builder.
- *
- * @param value Label field
- * @return Builder by setting Label field
- */
- Builder setLabel(int value);
-
- /**
- * Returns list of Optional Tlvs.
- *
- * @return list of Optional Tlvs
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Sets list of Optional Tlvs and return its builder.
- *
- * @param llOptionalTlv list of Optional Tlvs
- * @return Builder by setting list of Optional Tlvs
- */
- Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Sets P flag in Label object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in Label object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRange.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRange.java
deleted file mode 100644
index 49aa14a..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRange.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity providing PCEP Label Range.
- */
-public interface PcepLabelRange {
-
- /**
- * Returns object of PCEP SRP Object.
- *
- * @return srpObject
- */
- PcepSrpObject getSrpObject();
-
- /**
- * Sets PCEP SRP Object.
- *
- * @param srpObject SRP object.
- */
- void setSrpObject(PcepSrpObject srpObject);
-
- /**
- * Returns list of PcepLabelRangeObject.
- *
- * @return Label Range List
- */
- LinkedList<PcepLabelRangeObject> getLabelRangeList();
-
- /**
- * Sets list of PcepLabelRangeObject.
- *
- * @param llLabelRangeList Label Range List
- */
- void setLabelRangeList(LinkedList<PcepLabelRangeObject> llLabelRangeList);
-
- /**
- * Write the byte stream of PcepLabelRange to channel buffer.
- *
- * @param bb of type channel buffer
- * @return object length index
- * @throws PcepParseException while writing LABEL RANGE into Channel Buffer.
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeObject.java
deleted file mode 100644
index 74e9eba..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeObject.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-
-/**
- * Abstraction of an entity providing PCEP LabelRange Object.
- */
-public interface PcepLabelRangeObject {
-
- /**
- * Sets LabelRange Object header.
- *
- * @param obj LabelRange Object header
- */
- void setLabelRangeObjHeader(PcepObjectHeader obj);
-
- /**
- * Sets LabelType in LabelRange Object.
- *
- * @param labelType label type value
- */
- void setLabelType(byte labelType);
-
- /**
- * Sets RangeSize in LabelRange Object.
- *
- * @param rangeSize range size value
- */
- void setRangeSize(int rangeSize);
-
- /**
- * Sets LabelBase in LabelRange Object.
- *
- * @param labelBase label base value
- */
- void setLabelBase(int labelBase);
-
- /**
- * Returns LabelRange object header.
- *
- * @return LabelRange object header
- */
- PcepObjectHeader getLabelRangeObjHeader();
-
- /**
- * Returns LabelType field in LabelRange object.
- *
- * @return LabelType field in LabelRange object
- */
- byte getLabelType();
-
- /**
- * Returns RangeSize field in LabelRange object.
- *
- * @return RangeSize field in LabelRange object
- */
- int getRangeSize();
-
- /**
- * Returns LabelBase field in LabelRange object.
- *
- * @return LabelBase field in LabelRange object
- */
- int getLabelBase();
-
- /**
- * Writes the LabelRange Object into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException while writing LABEL RANGE object into Channel Buffer.
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build LabelRange object.
- */
- interface Builder {
-
- /**
- * Builds LabelRange Object.
- *
- * @return LabelRange Object
- * @throws PcepParseException while building LABEL RANGE object.
- */
- PcepLabelRangeObject build() throws PcepParseException;
-
- /**
- * Returns LabelRange object header.
- *
- * @return LabelRange object header
- */
- PcepObjectHeader getLabelRangeObjHeader();
-
- /**
- * Sets LabelRange object header and returns its builder.
- *
- * @param obj LabelRange object header
- * @return Builder by setting LabelRange object header
- */
- Builder setLabelRangeObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns LabelType field in LabelRange object.
- *
- * @return LabelType field in LabelRange object
- */
- byte getLabelType();
-
- /**
- * Sets LabelType field and returns its builder.
- *
- * @param labelType LabelType field
- * @return Builder by setting LabelType field
- */
- Builder setLabelType(byte labelType);
-
- /**
- * Returns RangeSize field in LabelRange object.
- *
- * @return RangeSize field in LabelRange object
- */
- int getRangeSize();
-
- /**
- * Sets RangeSize field and returns its builder.
- *
- * @param rangeSize RangeSize field
- * @return Builder by setting RangeSize field
- */
- Builder setRangeSize(int rangeSize);
-
- /**
- * Returns LabelBase field in LabelRange object.
- *
- * @return LabelBase field in LabelRange object
- */
- int getLabelBase();
-
- /**
- * Sets LabelBase field and returns its builder.
- *
- * @param labelBase LabelBase field
- * @return Builder by setting LabelBase field
- */
- Builder setLabelBase(int labelBase);
-
- /**
- * Sets P flag in TE object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in TE object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeResvMsg.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeResvMsg.java
deleted file mode 100644
index f4ef81f..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeResvMsg.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity providing PCEP Label Range Reservation Message.
- */
-public interface PcepLabelRangeResvMsg extends PcepObject, PcepMessage {
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns LabelRange field in Label Range Reservation message.
- *
- * @return LabelRange field
- */
- PcepLabelRange getLabelRange();
-
- /**
- * Sets LabelRange field in Label Range Reservation message with specified value.
- *
- * @param lR label range object
- */
- void setLabelRange(PcepLabelRange lR);
-
- @Override
- void writeTo(ChannelBuffer channelBuffer) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build Label Range Reservation message.
- */
- interface Builder extends PcepMessage.Builder {
-
- @Override
- PcepLabelRangeResvMsg build();
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns LabelRange field in Label Range Reservation message.
- *
- * @return LabelRange object
- */
- PcepLabelRange getLabelRange();
-
- /**
- * Sets LabelRange field and returns its Builder.
- *
- * @param lR label range object
- * @return builder by setting LabelRange field
- */
- Builder setLabelRange(PcepLabelRange lR);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdate.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdate.java
deleted file mode 100644
index 3e3b40e..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdate.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepLabelDownload;
-import org.onosproject.pcepio.types.PcepLabelMap;
-
-/***
- * Abstraction to provide PCEP Label Updates.
- */
-public interface PcepLabelUpdate {
-
- /**
- * Writes the byte stream of PcepLabelUpdate into channel buffer.
- *
- * @param bb of type channel buffer
- * @throws PcepParseException while writing LABEL UPDATE.
- */
- void write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Sets the Label Download object.
- *
- * @param labelDownload PCEP Label Download object
- */
- void setLabelDownload(PcepLabelDownload labelDownload);
-
- /**
- * Returns the PcepLabelDownload object.
- *
- * @return labelDownload PCEP Label Download
- */
- PcepLabelDownload getLabelDownload();
-
- /**
- * Sets the Label map object.
- *
- * @param labelMap PCEP Label Map object
- */
- void setLabelMap(PcepLabelMap labelMap);
-
- /**
- * Returns the PcepLabelMap object.
- *
- * @return labelMap PCEP Label Map
- */
- PcepLabelMap getLabelMap();
-
- /**
- * Builder interface with get and set functions to build Label Update message.
- */
- interface Builder {
-
- /**
- * Builds PcepLableUpdate Object.
- *
- * @return PcepLableUpdate Object
- * @throws PcepParseException while building LABEL-UPDATE.
- */
- PcepLabelUpdate build() throws PcepParseException;
-
- /**
- * Sets the Label Download object.
- *
- * @param labelDownload PCEP Label Download object
- * @return Builder by setting labelDownload object
- */
- Builder setLabelDownload(PcepLabelDownload labelDownload);
-
- /**
- * Returns the PcepLabelDownload object.
- *
- * @return labelDownload PCEP Label Download
- */
- PcepLabelDownload getLabelDownload();
-
- /**
- * Sets the Label map object.
- *
- * @param labelMap PCEP Label Map object
- * @return Builder by setting PcepLabelMap object
- */
- Builder setLabelMap(PcepLabelMap labelMap);
-
- /**
- * Returns the PcepLabelMap object.
- *
- * @return labelMap PCEP Label Map
- */
- PcepLabelMap getLabelMap();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsg.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsg.java
deleted file mode 100644
index 3aa94b7..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsg.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity providing PCEP Label Update Message.
- */
-public interface PcepLabelUpdateMsg extends PcepObject, PcepMessage {
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns list of PcLabelUpdateList.
- *
- * @return list of PcLabelUpdateList.
- */
- LinkedList<PcepLabelUpdate> getPcLabelUpdateList();
-
- /**
- * Sets list of PcLabelUpdateList.
- *
- * @param llPcLabelUpdateList list of PcLabelUpdateList
- */
- void setPcLabelUpdateList(LinkedList<PcepLabelUpdate> llPcLabelUpdateList);
-
- @Override
- void writeTo(ChannelBuffer channelBuffer) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build Label Update message.
- */
- interface Builder extends PcepMessage.Builder {
-
- @Override
- PcepLabelUpdateMsg build();
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns list of PcLabelUpdateList.
- *
- * @return list of PcLabelUpdateList.
- */
- LinkedList<PcepLabelUpdate> getPcLabelUpdateList();
-
- /**
- * Sets list of PcLabelUpdateList.
- *
- * @param llPcLabelUpdateList list of PcLabelUpdateList.
- * @return Builder by setting list of PcLabelUpdateList.
- */
- Builder setPcLabelUpdateList(LinkedList<PcepLabelUpdate> llPcLabelUpdateList);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspObject.java
deleted file mode 100644
index 52ff95f..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspObject.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-
-/**
- * Abstraction of an entity providing PCEP LSP Object.
- */
-public interface PcepLspObject {
-
- /**
- * Returns PlspId of LSP Object.
- *
- * @return PlspId of LSP Object
- */
- int getPlspId();
-
- /**
- * Sets PlspId with specified value.
- *
- * @param value PlspId
- */
- void setPlspId(int value);
-
- /**
- * Returns O flag in LSP Object.
- *
- * @return O flag in LSP Object
- */
- byte getOFlag();
-
- /**
- * Sets O flag with specified value.
- *
- * @param value O flag
- */
- void setOFlag(byte value);
-
- /**
- * Returns C flag in LSP Object.
- *
- * @return C flag in LSP Object
- */
- boolean getCFlag();
-
- /**
- * Sets C flag with specified value.
- *
- * @param value C flag
- */
- void setCFlag(boolean value);
-
- /**
- * Returns A flag in LSP Object.
- *
- * @return A flag in LSP Object
- */
- boolean getAFlag();
-
- /**
- * Sets A flag with specified value.
- *
- * @param value A flag
- */
- void setAFlag(boolean value);
-
- /**
- * Returns R flag in LSP Object.
- *
- * @return R flag in LSP Object
- */
- boolean getRFlag();
-
- /**
- * Sets R flag with specified value.
- *
- * @param value R flag
- */
- void setRFlag(boolean value);
-
- /**
- * Returns S flag in LSP Object.
- *
- * @return S flag in LSP Object
- */
- boolean getSFlag();
-
- /**
- * Sets S flag with specified value.
- *
- * @param value S flag
- */
- void setSFlag(boolean value);
-
- /**
- * Returns D flag in LSP Object.
- *
- * @return D flag in LSP Object
- */
- boolean getDFlag();
-
- /**
- * Sets D flag with specified value.
- *
- * @param value D flag
- */
- void setDFlag(boolean value);
-
- /**
- * Returns list of Optional Tlvs in LSP Object.
- *
- * @return list of Optional Tlvs
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Sets list of Optional Tlvs in LSP Object.
- *
- * @param llOptionalTlv list of Optional Tlvs
- */
- void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Writes the LSP Object into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException while writing LSP object into Channel Buffer.
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build LSP object.
- */
- interface Builder {
-
- /**
- * Builds LSP Object.
- *
- * @return LSP Object
- */
- PcepLspObject build();
-
- /**
- * Returns LSP object header.
- *
- * @return LSP object header
- */
- PcepObjectHeader getLspObjHeader();
-
- /**
- * Sets LSP object header and returns its builder.
- *
- * @param obj LSP object header
- * @return Builder by setting LSP object header
- */
- Builder setLspObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns PlspId of LSP Object.
- *
- * @return PlspId of LSP Object
- */
- int getPlspId();
-
- /**
- * Sets PlspId with specific value and return its builder.
- *
- * @param value PlspId
- * @return Builder by setting PlspId
- */
- Builder setPlspId(int value);
-
- /**
- * Returns C flag in LSP Object.
- *
- * @return C flag in LSP Object
- */
- boolean getCFlag();
-
- /**
- * Sets C flag with specific value and return its builder.
- *
- * @param value C flag
- * @return Builder by setting C flag
- */
- Builder setCFlag(boolean value);
-
- /**
- * Returns O flag in LSP Object.
- *
- * @return O flag in LSP Object
- */
- byte getOFlag();
-
- /**
- * Sets O flag with specific value and return its builder.
- *
- * @param value O flag
- * @return Builder by setting O flag
- */
- Builder setOFlag(byte value);
-
- /**
- * Returns A flag in LSP Object.
- *
- * @return A flag in LSP Object
- */
- boolean getAFlag();
-
- /**
- * Sets A flag with specific value and return its builder.
- *
- * @param value A flag
- * @return Builder by setting A flag
- */
- Builder setAFlag(boolean value);
-
- /**
- * Returns A flag in LSP Object.
- *
- * @return A flag in LSP Object
- */
- boolean getRFlag();
-
- /**
- * Sets R flag with specific value and return its builder.
- *
- * @param value r flag
- * @return Builder by setting r flag
- */
- Builder setRFlag(boolean value);
-
- /**
- * Returns S flag in LSP Object.
- *
- * @return S flag in LSP Object
- */
- boolean getSFlag();
-
- /**
- * Sets S flag with specific value and return its builder.
- *
- * @param value s flag
- * @return Builder by setting S flag
- */
- Builder setSFlag(boolean value);
-
- /**
- * Returns D flag in LSP Object.
- *
- * @return D flag in LSP Object
- */
- boolean getDFlag();
-
- /**
- * Sets D flag with specific value and return its builder.
- *
- * @param value D flag
- * @return Builder by setting D flag
- */
- Builder setDFlag(boolean value);
-
- /**
- * Returns list of Optional Tlvs in LSP Object.
- *
- * @return list of Optional Tlvs in LSP Object
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Sets list of Optional Tlvs and return its builder.
- *
- * @param llOptionalTlv list of Optional Tlvs
- * @return Builder by setting list of Optional Tlvs
- */
- Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Sets P flag in LSP object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in LSP object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspaObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspaObject.java
deleted file mode 100644
index 9314bb7..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspaObject.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-
-/**
- * Abstraction of an entity providing PCEP LSPA Object.
- */
-public interface PcepLspaObject {
-
- /**
- * Returns L flag in LSPA Object.
- *
- * @return L flag in LSPA Object
- */
- boolean getLFlag();
-
- /**
- * Sets L flag in LSPA Object.
- *
- * @param value L flag
- */
- void setLFlag(boolean value);
-
- /**
- * Returns Exclude Any field in LSPA Object.
- *
- * @return Exclude Any field in LSPA Object
- */
- int getExcludeAny();
-
- /**
- * Sets Exclude Any field in LSPA Object.
- *
- * @param value Exclude Any field
- */
- void setExcludeAny(int value);
-
- /**
- * Returns Include Any field in LSPA Object.
- *
- * @return Include Any field in LSPA Object
- */
- int getIncludeAny();
-
- /**
- * Sets Include Any field in LSPA Object.
- *
- * @param value Include Any field
- */
- void setIncludeAny(int value);
-
- /**
- * Returns Include All field in LSPA Object.
- *
- * @return Include All field in LSPA Object
- */
- int getIncludeAll();
-
- /**
- * Sets Include All field in LSPA Object.
- *
- * @param value Include All field
- */
- void setIncludeAll(int value);
-
- /**
- * Returns Setup Priority field in LSPA Object.
- *
- * @return Setup Priority field in LSPA Object
- */
- byte getSetupPriority();
-
- /**
- * Sets Setup Priority field in LSPA Object.
- *
- * @param value Setup Priority field
- */
- void setSetupPriority(byte value);
-
- /**
- * Returns Hold Priority field in LSPA Object.
- *
- * @return Hold Priority field in LSPA Object
- */
- byte getHoldPriority();
-
- /**
- * Sets Hold Priority field in LSPA Object.
- *
- * @param value Hold Priority field
- */
- void setHoldPriority(byte value);
-
- /**
- * Returns list of Optional Tlvs in LSPA Object.
- *
- * @return list of Optional Tlvs in LSPA Object
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Sets Optional Tlvs in LSPA Object.
- *
- * @param llOptionalTlv Optional Tlvs in LSPA Object
- */
- void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Writes the LSPA Object into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException while writing LSPA object into Channel Buffer.
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build bandwidth object.
- */
- interface Builder {
-
- /**
- * Builds LSPA Object.
- *
- * @return LSPA Object
- * @throws PcepParseException while building LSPA object.
- */
- PcepLspaObject build() throws PcepParseException;
-
- /**
- * Returns LSPA object header.
- *
- * @return LSPA object header
- */
- PcepObjectHeader getLspaObjHeader();
-
- /**
- * Sets LSPA object header and returns its builder.
- *
- * @param obj LSPA object header
- * @return Builder by setting LSPA object header
- */
- Builder setLspaObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns L flag in LSPA Object.
- *
- * @return L flag in LSPA Object
- */
- boolean getLFlag();
-
- /**
- * Sets L flag in LSPA Object and return its builder.
- *
- * @param value L flag in LSPA Object
- * @return Builder by setting L flag
- */
- Builder setLFlag(boolean value);
-
- /**
- * Returns Exclude Any field in LSPA Object.
- *
- * @return Exclude Any field in LSPA Object
- */
- int getExcludeAny();
-
- /**
- * Sets Exclude Any field in LSPA Object and return its builder.
- *
- * @param value Exclude Any field in LSPA Object
- * @return Builder by setting Exclude Any field
- */
- Builder setExcludeAny(int value);
-
- /**
- * Returns Include Any field in LSPA Object.
- *
- * @return Include Any field in LSPA Object
- */
- int getIncludeAny();
-
- /**
- * Sets Include Any field in LSPA Object and return its builder.
- *
- * @param value Include Any field in LSPA Object
- * @return Builder by setting Include Any field
- */
- Builder setIncludeAny(int value);
-
- /**
- * Returns Include All field in LSPA Object.
- *
- * @return Include All field in LSPA Object
- */
- int getIncludeAll();
-
- /**
- * Sets Include All field in LSPA Object and return its builder.
- *
- * @param value Include All field in LSPA Object
- * @return Builder by setting Include All field
- */
- Builder setIncludeAll(int value);
-
- /**
- * Returns Setup Priority field in LSPA Object.
- *
- * @return Setup Priority field in LSPA Object
- */
- byte getSetupPriority();
-
- /**
- * Sets Setup Priority field in LSPA Object and return its builder.
- *
- * @param value Setup Priority field in LSPA Object
- * @return Builder by setting Setup Priority field
- */
- Builder setSetupPriority(byte value);
-
- /**
- * Returns Hold Priority field in LSPA Object.
- *
- * @return Hold Priority field in LSPA Object
- */
- byte getHoldPriority();
-
- /**
- * Sets Hold Priority field in LSPA Object and return its builder.
- *
- * @param value Hold Priority field in LSPA Object
- * @return Builder by setting Hold Priority field
- */
- Builder setHoldPriority(byte value);
-
- /**
- * Returns list of Optional Tlvs in LSPA Object.
- *
- * @return list of Optional Tlvs in LSPA Object
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Sets list of Optional Tlvs in LSPA Object.
- *
- * @param llOptionalTlv list of Optional Tlvs
- * @return builder by setting list of Optional Tlvs
- */
- Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Sets P flag in LSPA object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in LSPA object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessage.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessage.java
deleted file mode 100644
index 3b0c729..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessage.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity providing PCEP Messages.
- */
-public interface PcepMessage extends PcepObject {
-
- @Override
- PcepVersion getVersion();
-
- /**
- * Returns Type of PCEP Message.
- *
- * @return Type of PCEP Message
- */
- PcepType getType();
-
- @Override
- void writeTo(ChannelBuffer channelBuffer) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build PCEP Message.
- */
- interface Builder {
-
- /**
- * Builds PCEP Message.
- *
- * @return PCEP Message
- * @throws PcepParseException when build fails to create PCEP message
- */
- PcepMessage build() throws PcepParseException;
-
- /**
- * Returns Version of PCEP Message.
- *
- * @return Version of PCEP Message
- */
- PcepVersion getVersion();
-
- /**
- * Returns Type of PCEP Message.
- *
- * @return Type of PCEP Message
- */
- PcepType getType();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageReader.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageReader.java
deleted file mode 100644
index 30196ac..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageReader.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity providing PCEP Message Reader.
- */
-public interface PcepMessageReader<T> {
-
- /**
- * Reads the Objects in the PCEP Message and Returns PCEP Message.
- *
- * @param bb Channel Buffer
- * @return PCEP Message
- * @throws PcepParseException while parsing PCEP message
- * @throws PcepOutOfBoundMessageException if out-of-bound message is received
- */
- T readFrom(ChannelBuffer bb) throws PcepParseException, PcepOutOfBoundMessageException;
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageWriter.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageWriter.java
deleted file mode 100644
index b10951b..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageWriter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity providing PCEP Message Writer.
- */
-public interface PcepMessageWriter<T> {
-
- /**
- * Writes the Objects of the PCEP Message into Channel Buffer.
- *
- * @param bb Channel Buffer
- * @param message PCEP Message
- * @throws PcepParseException while writing PCEP message.
- */
- void write(ChannelBuffer bb, T message) throws PcepParseException;
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMetricObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMetricObject.java
deleted file mode 100644
index 54fffe2..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMetricObject.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-
-/**
- * Abstraction of an entity providing PCEP Metric Object.
- */
-public interface PcepMetricObject {
-
- /**
- * Returns Metric value in Metric Object.
- *
- * @return Metric value
- */
- int getMetricVal();
-
- /**
- * Sets Metric value in Metric Object with specified value.
- *
- * @param value Metric value
- */
- void setMetricVal(int value);
-
- /**
- * Returns Y flag in Metric Object.
- *
- * @return Y flag in Metric Object
- */
- byte getYFlag();
-
- /**
- * Sets Y flag in Metric Object with specified value.
- *
- * @param value Y flag
- */
- void setYFlag(byte value);
-
- /**
- * Returns C flag in Metric Object.
- *
- * @return C flag in Metric Object
- */
- boolean getCFlag();
-
- /**
- * Sets C flag in Metric Object with specified value.
- *
- * @param value C flag
- */
- void setCFlag(boolean value);
-
- /**
- * Returns B flag in Metric Object.
- *
- * @return B flag in Metric Object
- */
- boolean getBFlag();
-
- /**
- * Sets B flag in Metric Object with specified value.
- *
- * @param value B flag
- */
- void setBFlag(boolean value);
-
- /**
- * Returns BType field in Metric Object.
- *
- * @return BType field in Metric Object
- */
- byte getBType();
-
- /**
- * Sets BType field in Metric Object with specified value.
- *
- * @param value BType field
- */
- void setBType(byte value);
-
- /**
- * Writes the Metric Object into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException while writing METRIC object into Channel Buffer.
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build Metric object.
- */
- interface Builder {
-
- /**
- * Builds Metric Object.
- *
- * @return Metric Object
- * @throws PcepParseException when mandatory object is not set
- */
- PcepMetricObject build() throws PcepParseException;
-
- /**
- * Returns Metric object header.
- *
- * @return Metric object header
- */
- PcepObjectHeader getMetricObjHeader();
-
- /**
- * Sets Metric object header and returns its builder.
- *
- * @param obj Metric object header
- * @return Builder by setting Metric object header
- */
- Builder setMetricObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns Metric value in Metric Object.
- *
- * @return Metric value
- */
- int getMetricVal();
-
- /**
- * Sets Metric Value in Metric Object and returns its builder.
- *
- * @param value Metric Value
- * @return Builder by setting Metric Value
- */
- Builder setMetricVal(int value);
-
- /**
- * Returns Flags in Metric Object.
- *
- * @return Flags in Metric Object
- */
- byte getYFlag();
-
- /**
- * Sets Flags in Metric Object and returns its builder.
- *
- * @param value Flags
- * @return Builder by setting Flags
- */
- Builder setYFlag(byte value);
-
- /**
- * Returns C flag in Metric Object.
- *
- * @return C flag in Metric Object
- */
- boolean getCFlag();
-
- /**
- * Sets C flag in Metric Object and returns its builder.
- *
- * @param value C flag
- * @return Builder by setting C flag
- */
- Builder setCFlag(boolean value);
-
- /**
- * Returns B flag in Metric Object.
- *
- * @return B flag in Metric Object
- */
- boolean getBFlag();
-
- /**
- * Sets B flag in Metric Object and returns its builder.
- *
- * @param value B flag
- * @return Builder by setting B flag
- */
- Builder setBFlag(boolean value);
-
- /**
- * Returns BType field in Metric Object.
- *
- * @return BType field in Metric Object
- */
- byte getBType();
-
- /**
- * Sets B Type field in Metric Object and returns its builder.
- *
- * @param value B Type field
- * @return Builder by setting B Type field
- */
- Builder setBType(byte value);
-
- /**
- * Sets P flag in Metric object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in Metric object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMsgPath.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMsgPath.java
deleted file mode 100644
index 97091e0..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMsgPath.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity Provides PCEP Message PAth for update message.
- * Reference :PCE extensions for stateful draft-ietf-pce-stateful-pce-10.
- */
-public interface PcepMsgPath {
-
- /**
- * Returns object of PcepEroObject.
- *
- * @return eroObject
- */
- PcepEroObject getEroObject();
-
- /**
- * Returns object of PcepAttribute.
- *
- * @return pcepAttribute
- */
- PcepAttribute getPcepAttribute();
-
- /**
- * Sets PcepEroObject.
- *
- * @param eroObject PCEP ERO Object.
- */
- void setEroObject(PcepEroObject eroObject);
-
- /**
- * Sets PcepAttribute.
- *
- * @param pcepAttribute PCEP-Attribute.
- */
- void setPcepAttribute(PcepAttribute pcepAttribute);
-
- /**
- * reads ERO object and attribute list.
- *
- * @param bb of type channel buffer
- * @return PcepMsgPath
- * @throws PcepParseException while parsing Message Path from Channel Buffer.
- */
- PcepMsgPath read(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * writes ERO object and attribute list to channel.
- *
- * @param bb of type channel buffer
- * @return object length index
- * @throws PcepParseException while writing Message Path into Channel Buffer.
- */
-
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build PcepMsgPath.
- */
- interface Builder {
-
- /**
- * Builds PcepMsgPath.
- *
- * @return PcepMsgPath
- * @throws PcepParseException when mandatory object is not set
- */
- PcepMsgPath build() throws PcepParseException;
-
- /**
- * Returns object of PcepEroObject.
- *
- * @return PcepEroObject
- */
- PcepEroObject getEroObject();
-
- /**
- * Returns object of PcepAttribute.
- *
- * @return pcepAttribute
- */
- PcepAttribute getPcepAttribute();
-
- /**
- * Sets PcepEroObject.
- *
- * @param eroObject PcepEroObject
- * @return Builder by setting ERO object.
- */
- Builder setEroObject(PcepEroObject eroObject);
-
- /**
- * Sets PcepAttribute.
- *
- * @param pcepAttribute PCEP-Attribute
- * @return Builder by setting PCEP-Attribute.
- */
- Builder setPcepAttribute(PcepAttribute pcepAttribute);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepNai.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepNai.java
deleted file mode 100644
index ab33547..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepNai.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Abstraction of an entity provides NAI information in SR ERO Object.
- */
-public interface PcepNai {
-
- /**
- * To get the ST type of the NAI information.
- *
- * @return type of ST info
- */
- byte getType();
-
- /**
- * To write the object information to channelBuffer.
- *
- * @param cb of type channel buffer
- * @return length of written bytes.
- */
- int write(ChannelBuffer cb);
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepObject.java
deleted file mode 100644
index 09ffdc3..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepObject.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-/**
- * Abstraction of an entity providing PCEP Object.
- */
-public interface PcepObject extends Writeable {
-
- /**
- * Returns Version of PCEP Object.
- *
- * @return Version of PCEP Object
- */
- PcepVersion getVersion();
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenMsg.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenMsg.java
deleted file mode 100644
index d3ea78b..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenMsg.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity providing PCEP Open Message.
- */
-public interface PcepOpenMsg extends PcepObject, PcepMessage {
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Sets OpenObject in Open Message with Specified Obj.
- *
- * @param obj OpenObject
- */
- void setPcepOpenObject(PcepOpenObject obj);
-
- /**
- * Returns OpenObject in Open Message.
- *
- * @return OpenObject in Open Message
- */
- PcepOpenObject getPcepOpenObject();
-
- @Override
- void writeTo(ChannelBuffer channelBuffer) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build Open message.
- */
- interface Builder extends PcepMessage.Builder {
-
- @Override
- PcepOpenMsg build() throws PcepParseException;
-
- /**
- * Sets Open Object in Open Message and return its builder.
- *
- * @param obj Open Object
- * @return builder by setting Open Object
- */
- Builder setPcepOpenObj(PcepOpenObject obj);
-
- /**
- * Returns OpenObject in Open Message.
- *
- * @return OpenObject in Open Message
- */
- PcepOpenObject getPcepOpenObj();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenObject.java
deleted file mode 100644
index 73228f0..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenObject.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-
-/**
- * Abstraction of an entity providing PCEP Open Object.
- */
-public interface PcepOpenObject {
-
- /**
- * Returns Open object header.
- *
- * @return Open object header
- */
- PcepObjectHeader getOpenObjHeader();
-
- /**
- * Sets Open object header in Open Object.
- *
- * @param obj Open object header
- */
- void setOpenObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns version of Open Object.
- *
- * @return Version of Open Object
- */
- PcepVersion getVersion();
-
- /**
- * Returns KeepAlive Time in Open Object.
- *
- * @return KeepAlive Time in Open Object
- */
- byte getKeepAliveTime();
-
- /**
- * Sets KeepAlive Time in Open Object with specified value.
- *
- * @param value KeepAlive Time
- */
- void setKeepAliveTime(byte value);
-
- /**
- * Returns Dead Time in Open Object.
- *
- * @return Dead Time in Open Object
- */
- byte getDeadTime();
-
- /**
- * Sets Dead Time in Open Object with specified value.
- *
- * @param value Dead Time
- */
- void setDeadTime(byte value);
-
- /**
- * Returns SessionId in Open Object.
- *
- * @return SessionId in Open Object
- */
- byte getSessionId();
-
- /**
- * Sets SessionId in Open Object with specified value.
- *
- * @param value SessionId
- */
- void setSessionId(byte value);
-
- /**
- * Returns list of Optional Tlvs in Open Object.
- *
- * @return list of Optional Tlvs
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Sets list of Optional Tlvs in Open Object.
- *
- * @param llOptionalTlv list of Optional Tlvs
- */
- void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Writes the Open into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException while writing Open Object into Channel Buffer.
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build Open object.
- */
- interface Builder {
-
- /**
- * Builds Open Object.
- *
- * @return Open Object
- * @throws PcepParseException while building PCEP-Open object
- */
- PcepOpenObject build() throws PcepParseException;
-
- /**
- * Returns Open object header.
- *
- * @return Open object header
- */
- PcepObjectHeader getOpenObjHeader();
-
- /**
- * Sets Open object header and returns its builder.
- *
- * @param obj Open object header
- * @return Builder by setting Open object header
- */
- Builder setOpenObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns KeepAlive Time in Open Object.
- *
- * @return KeepAlive Time in Open Object
- */
- byte getKeepAliveTime();
-
- /**
- * Sets KeepAlive Time and returns its builder.
- *
- * @param value KeepAlive Time
- * @return Builder by setting KeepAlive Time
- */
- Builder setKeepAliveTime(byte value);
-
- /**
- * Returns Dead Time in Open Object.
- *
- * @return Dead Time in Open Object
- */
- byte getDeadTime();
-
- /**
- * Sets Dead Time and returns its builder.
- *
- * @param value Dead Time
- * @return Builder by setting Dead Time
- */
- Builder setDeadTime(byte value);
-
- /**
- * Returns SessionId in Open Object.
- *
- * @return SessionId in Open Object
- */
- byte getSessionId();
-
- /**
- * Sets SessionId and returns its builder.
- *
- * @param value SessionId
- * @return Builder by setting SessionId
- */
- Builder setSessionId(byte value);
-
- /**
- * Returns list of Optional Tlvs in Open Object.
- *
- * @return list of Optional Tlvs in Open Object
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Sets list of Optional Tlvs and return its Builder.
- *
- * @param llOptionalTlv list of Optional Tlvs
- * @return builder by setting list of Optional Tlvs
- */
- Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Sets P flag in Open object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in Open object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRPObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRPObject.java
deleted file mode 100644
index 932a225..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRPObject.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-
-/**
- * Abstraction of an entity providing PCEP RP Object.
- */
-public interface PcepRPObject {
-
- /**
- * Returns RequestId Number in RP Object.
- *
- * @return RequestId Number in RP Object
- */
- int getRequestIdNum();
-
- /**
- * Sets RequestId Number with specified value.
- *
- * @param value RequestId Number
- */
- void setRequestIdNum(int value);
-
- /**
- * Returns O flag in RP Object.
- *
- * @return O flag in RP Object
- */
- boolean getOFlag();
-
- /**
- * Sets O flag with specified value.
- *
- * @param value O flag
- */
- void setOFlag(boolean value);
-
- /**
- * Returns B flag in RP Object.
- *
- * @return B flag in RP Object
- */
- boolean getBFlag();
-
- /**
- * Sets B flag with specified value.
- *
- * @param value B flag
- */
- void setBFlag(boolean value);
-
- /**
- * Returns R flag in RP Object.
- *
- * @return R flag in RP Object
- */
- boolean getRFlag();
-
- /**
- * Sets R flag with specified value.
- *
- * @param value R flag
- */
- void setRFlag(boolean value);
-
- /**
- * Returns Priority Flag in RP Object.
- *
- * @return Priority Flag in RP Object
- */
- byte getPriFlag();
-
- /**
- * Sets Priority Flag with specified value.
- *
- * @param value Priority Flag
- */
- void setPriFlag(byte value);
-
- /**
- * Returns list of Optional Tlvs in RP Object.
- *
- * @return list of Optional Tlvs in RP Object
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Sets list of Optional Tlvs in RP Object and returns its builder.
- *
- * @param llOptionalTlv list of Optional Tlvs
- */
- void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Writes the RP Object into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException while writing RP object into Channel Buffer.
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build bandwidth object.
- */
- interface Builder {
-
- /**
- * Builds RP Object.
- *
- * @return RP Object
- */
- PcepRPObject build();
-
- /**
- * Returns RP object header.
- *
- * @return RP object header
- */
- PcepObjectHeader getRPObjHeader();
-
- /**
- * Sets RP object header and returns its builder.
- *
- * @param obj RP object header
- * @return Builder by setting RP object header
- */
- Builder setRPObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns Request Id Number in RP Object.
- *
- * @return Request Id Number in RP Object
- */
- int getRequestIdNum();
-
- /**
- * Sets Request Id Number and returns its builder.
- *
- * @param value Request Id Number
- * @return Builder by setting Request Id Number
- */
- Builder setRequestIdNum(int value);
-
- /**
- * Returns O flag in RP Object.
- *
- * @return O flag in RP Object
- */
- boolean getOFlag();
-
- /**
- * Sets O flag and returns its builder.
- *
- * @param value O flag
- * @return Builder by setting O flag
- */
- Builder setOFlag(boolean value);
-
- /**
- * Returns B flag in RP Object.
- *
- * @return B flag in RP Object
- */
- boolean getBFlag();
-
- /**
- * Sets B flag and returns its builder.
- *
- * @param value B flag
- * @return Builder by setting B flag
- */
- Builder setBFlag(boolean value);
-
- /**
- * Returns R flag in RP Object.
- *
- * @return R flag in RP Object
- */
- boolean getRFlag();
-
- /**
- * Sets R flag and returns its builder.
- *
- * @param value R flag
- * @return Builder by setting R flag
- */
- Builder setRFlag(boolean value);
-
- /**
- * Returns Priority Flag in RP Object.
- *
- * @return Priority Flag in RP Object
- */
- byte getPriFlag();
-
- /**
- * Sets Priority Flag and returns its builder.
- *
- * @param value Priority Flag
- * @return Builder by setting Priority Flag
- */
- Builder setPriFlag(byte value);
-
- /**
- * Returns list of Optional Tlvs in RP Object.
- *
- * @return list of Optional Tlvs
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Sets list of Optional Tlvs and returns its builder.
- *
- * @param llOptionalTlv list of Optional Tlvs
- * @return Builder by setting list of Optional Tlvs
- */
- Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Sets P flag in RP object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in RP object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepReportMsg.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepReportMsg.java
deleted file mode 100644
index f4d8bf6..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepReportMsg.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity providing PCEP Report Message.
- */
-public interface PcepReportMsg extends PcepObject, PcepMessage {
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns PcepStateReport list.
- *
- * @return list of PcepStateReport
- */
- LinkedList<PcepStateReport> getStateReportList();
-
- /**
- * Sets StateReportList.
- *
- * @param llStateReportList list of PcepStateReport.
- */
- void setStateReportList(LinkedList<PcepStateReport> llStateReportList);
-
- @Override
- void writeTo(ChannelBuffer channelBuffer) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build Report message.
- */
- interface Builder extends PcepMessage.Builder {
-
- @Override
- PcepReportMsg build();
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns StateReportList.
- *
- * @return StateReportList.
- */
- LinkedList<PcepStateReport> getStateReportList();
-
- /**
- * Sets list of PcepStateReport and returns builder.
- *
- * @param llStateReportList list of PcepStateReport.
- * @return Builder by setting list of PcepStateReport.
- */
- Builder setStateReportList(LinkedList<PcepStateReport> llStateReportList);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRroObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRroObject.java
deleted file mode 100644
index a93a1b7..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRroObject.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-
-/**
- * Abstraction of an entity providing PCEP RRO Object.
- */
-public interface PcepRroObject {
-
- /**
- * Returns list of SubObjects.
- *
- * @return list of SubObjects
- */
- LinkedList<PcepValueType> getSubObjects();
-
- /**
- * Sets list of SubObjects and return its builder.
- *
- * @param llSubObjects list of SubObjects
- */
- void setSubObjects(LinkedList<PcepValueType> llSubObjects);
-
- /**
- * Writes the RRO Object into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException when object header failed to write in channel buffer
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build RRO object.
- */
- interface Builder {
-
- /**
- * Builds RRO Object.
- *
- * @return RRO Object
- */
- PcepRroObject build();
-
- /**
- * Returns RRO object header.
- *
- * @return RRO object header
- */
- PcepObjectHeader getRroObjHeader();
-
- /**
- * Sets RRO object header and returns its builder.
- *
- * @param obj RRO object header
- * @return Builder by setting RRO object header
- */
- Builder setRroObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns list of SubObjects.
- *
- * @return list of SubObjects
- */
- LinkedList<PcepValueType> getSubObjects();
-
- /**
- * Sets list of SubObjects in RRO Object and returns its builder.
- *
- * @param llSubObjects list of SubObjects
- * @return Builder by setting list of SubObjects
- */
- Builder setSubObjects(LinkedList<PcepValueType> llSubObjects);
-
- /**
- * Sets P flag in RRO object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in RRO object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepSrpObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepSrpObject.java
deleted file mode 100644
index b3ba03f..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepSrpObject.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-
-/**
- * Abstraction of an entity providing PCEP SRP Object.
- */
-public interface PcepSrpObject {
-
- /**
- * Returns SRP ID of SRP Object.
- *
- * @return SRP ID of SRP Object
- */
- int getSrpID();
-
- /**
- * Sets SRP ID with specified value.
- *
- * @param srpID SRP ID of SRP Object
- */
- void setSrpID(int srpID);
-
- /**
- * Returns R flag of SRP Object.
- *
- * @return R flag of SRP Object
- */
- boolean getRFlag();
-
- /**
- * Sets R flag with specified value.
- *
- * @param bRFlag R Flag of SRP Object
- */
- void setRFlag(boolean bRFlag);
-
- /**
- * Returns S flag of SRP Object.
- *
- * @return S flag of SRP Object
- */
- boolean getSFlag();
-
- /**
- * Sets S(sync) flag with specified value.
- *
- * @param bSFlag S Flag of SRP Object
- */
- void setSFlag(boolean bSFlag);
-
- /**
- * sets the optional TLvs.
- *
- * @param llOptionalTlv list of optional tlvs
- */
- void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Returns list of optional tlvs.
- *
- * @return llOptionalTlv list of optional tlvs
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * Writes the SRP Object into channel buffer.
- *
- * @param bb channel buffer
- * @return Returns the writerIndex of this buffer
- * @throws PcepParseException when tlv is null
- */
- int write(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Builder interface with get and set functions to build SRP object.
- */
- interface Builder {
-
- /**
- * Builds SRP Object.
- *
- * @return SRP Object
- * @throws PcepParseException when mandatory object is not set
- */
- PcepSrpObject build() throws PcepParseException;
-
- /**
- * Returns SRP object header.
- *
- * @return SRP object header
- */
- PcepObjectHeader getSrpObjHeader();
-
- /**
- * Sets SRP object header and returns its builder.
- *
- * @param obj SRP object header
- * @return Builder by setting SRP object header
- */
- Builder setSrpObjHeader(PcepObjectHeader obj);
-
- /**
- * Returns SRP ID of SRP Object.
- *
- * @return SRP ID of SRP Object
- */
- int getSrpID();
-
- /**
- * Sets SRP ID and returns its builder.
- *
- * @param srpID SRP ID
- * @return Builder by setting SRP ID
- */
- Builder setSrpID(int srpID);
-
- /**
- * Returns R flag of SRP Object.
- *
- * @return R flag of SRP Object
- */
- boolean getRFlag();
-
- /**
- * Returns S(sync) flag of SRP Object.
- *
- * @return S flag of SRP Object
- */
- boolean getSFlag();
-
- /**
- * Sets R flag and returns its builder.
- *
- * @param bRFlag R flag
- * @return Builder by setting R flag
- */
- Builder setRFlag(boolean bRFlag);
-
- /**
- * Sets S flag and returns its builder.
- *
- * @param bSFlag S flag
- * @return Builder by setting S flag
- */
- Builder setSFlag(boolean bSFlag);
-
- /**
- * Returns list of optional tlvs.
- *
- * @return llOptionalTlv list of optional tlvs
- */
- LinkedList<PcepValueType> getOptionalTlv();
-
- /**
- * sets the optional TLvs.
- *
- * @param llOptionalTlv List of optional tlv
- * @return builder by setting list of optional tlv.
- */
- Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
-
- /**
- * Sets P flag in SRP object header and returns its builder.
- *
- * @param value boolean value to set P flag
- * @return Builder by setting P flag
- */
- Builder setPFlag(boolean value);
-
- /**
- * Sets I flag in SRP object header and returns its builder.
- *
- * @param value boolean value to set I flag
- * @return Builder by setting I flag
- */
- Builder setIFlag(boolean value);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepStateReport.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepStateReport.java
deleted file mode 100644
index 555fe07..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepStateReport.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity provides State Report for PCEP Report Message.
- */
-public interface PcepStateReport {
-
- /**
- * Provides PCEP Message path for report message.
- */
- interface PcepMsgPath {
-
- /**
- * Returns PcepEroObject.
- *
- * @return eroObj
- */
- PcepEroObject getEroObject();
-
- /**
- * Sets PcepEroObject.
- *
- * @param eroObject Ero Object
- */
- void setEroObject(PcepEroObject eroObject);
-
- /**
- * Returns PcepAttribute.
- *
- * @return attrList
- */
- PcepAttribute getPcepAttribute();
-
- /**
- * Sets PcepAttribute.
- *
- * @param pcepAttribute Pcep Attribute object
- */
- void setPcepAttribute(PcepAttribute pcepAttribute);
-
- /**
- * Returns PcepRroObject.
- *
- * @return rroObj
- */
- PcepRroObject getRroObject();
-
- /**
- * Sets PcepRroObject.
- *
- * @param rroObject Rro object
- */
- void setRroObject(PcepRroObject rroObject);
-
- /**
- * Returns PcepBandwidthObject.
- *
- * @return bandwidth object
- */
- PcepBandwidthObject getBandwidthObject();
-
- /**
- * Sets PcepBandwidthObject.
- *
- * @param bandwidth bandwidth object
- */
- void setBandwidthObject(PcepBandwidthObject bandwidth);
-
- /**
- * Reads all the Objects for PCEP Message Path.
- *
- * @param bb of type channel buffer
- * @return PCEP Message path
- * @throws PcepParseException when invalid buffer received
- */
- PcepMsgPath read(ChannelBuffer bb) throws PcepParseException;
-
- /**
- * Writes all the objects for pcep message path.
- *
- * @param bb of type channel buffer.
- * @return object length index
- * @throws PcepParseException when mandatory object is not set
- */
- int write(ChannelBuffer bb) throws PcepParseException;
- }
-
- /**
- * Returns PcepSrpObject.
- *
- * @return srpObject
- */
- PcepSrpObject getSrpObject();
-
- /**
- * Returns PcepLspObject.
- *
- * @return lspObject
- */
- PcepLspObject getLspObject();
-
- /**
- * Returns PcepMsgPath.
- *
- * @return msgPath
- */
- PcepMsgPath getMsgPath();
-
- /**
- * Sets the SRP Object.
- *
- * @param srpObj Pcep Srp Object
- */
- void setSrpObject(PcepSrpObject srpObj);
-
- /**
- * Sets the LSP Object.
- *
- * @param lspObject Pcep Lsp Object
- */
- void setLspObject(PcepLspObject lspObject);
-
- /**
- * Sets the Path Object.
- *
- * @param msgPath Pcep MsgPath object
- */
- void setMsgPath(PcepMsgPath msgPath);
-
- /**
- * Builder interface with get and set functions to build PcepStateReport.
- */
- interface Builder {
-
- /**
- * Builds PcepStateReport.
- *
- * @return PcepStateReport
- * @throws PcepParseException when mandatory object is not set
- */
- PcepStateReport build() throws PcepParseException;
-
- /**
- * Returns PcepSrpObject.
- *
- * @return srpObject
- */
- PcepSrpObject getSrpObject();
-
- /**
- * Returns PcepLspObject.
- *
- * @return lspObject
- */
- PcepLspObject getLspObject();
-
- /**
- * Returns PcepMsgPath.
- *
- * @return msgPath
- */
- PcepMsgPath getMsgPath();
-
- /**
- * Sets the SRP Object.
- *
- * @param srpObj Pcep Srp Object
- * @return builder by setting PcepSrpObject
- */
- Builder setSrpObject(PcepSrpObject srpObj);
-
- /**
- * Sets the LSP Object.
- *
- * @param lspObject Pcep Lsp Object
- * @return builder by setting PcepLspObject
- */
- Builder setLspObject(PcepLspObject lspObject);
-
- /**
- * Sets the Path Object.
- *
- * @param msgPath Pcep MsgPath object
- * @return builder by setting PcepMsgPath
- */
- Builder setMsgPath(PcepMsgPath msgPath);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepType.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepType.java
deleted file mode 100644
index 1cf6b11..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepType.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-/**
- * Enum to Provide the Different types of PCEP messages.
- */
-public enum PcepType {
-
- NONE(0), OPEN(1), KEEP_ALIVE(2), PATH_COMPUTATION_REQUEST(3), PATH_COMPUTATION_REPLY(4),
- NOTIFICATION(5), ERROR(6), CLOSE(7), REPORT(10), UPDATE(11), INITIATE(12),
- LS_REPORT(224), LABEL_RANGE_RESERV(225), LABEL_UPDATE(226), MAX(227), END(228);
-
- int iValue;
-
- /**
- * Assign iValue with the value iVal as the types of PCEP message.
- *
- * @param iVal type of pcep message
- */
- PcepType(int iVal) {
-
- iValue = iVal;
- }
-
- /**
- * Returns iValue as type of PCEP message.
- *
- * @return iValue type of pcep message
- */
- public byte getType() {
-
- return (byte) iValue;
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateMsg.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateMsg.java
deleted file mode 100644
index 59d0076..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateMsg.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import java.util.LinkedList;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity providing PCEP Update Message.
- */
-public interface PcepUpdateMsg extends PcepObject, PcepMessage {
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns the update request list for PCEP Update Message.
- *
- * @return list of Update Requests
- */
- LinkedList<PcepUpdateRequest> getUpdateRequestList();
-
- /**
- * Sets the update request list for PCEP update message.
- *
- * @param llUpdateRequestList is a list of PCEP Update Requests
- */
- void setUpdateRequestList(LinkedList<PcepUpdateRequest> llUpdateRequestList);
-
- @Override
- void writeTo(ChannelBuffer channelBuffer) throws PcepParseException;
-
- /**
- * Builder interface with Get and Set Functions to build the PCEP update Message.
- */
- interface Builder extends PcepMessage.Builder {
-
- @Override
- PcepUpdateMsg build();
-
- @Override
- PcepVersion getVersion();
-
- @Override
- PcepType getType();
-
- /**
- * Returns the update request list for the PCEP update message.
- *
- * @return list of Update Requests
- */
- LinkedList<PcepUpdateRequest> getUpdateRequestList();
-
- /**
- * Sets the update request list for the PCEP update message.
- *
- * @param llUpdateRequestList list of Update requests
- * @return builder by setting list llUpdateRequestList of PcepUpdateRequest.
- */
- Builder setUpdateRequestList(LinkedList<PcepUpdateRequest> llUpdateRequestList);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateRequest.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateRequest.java
deleted file mode 100644
index fbed59b..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateRequest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity providing PCEP Update Request List.
- */
-public interface PcepUpdateRequest {
-
- /**
- * Returns object of PCEP SRP Object.
- *
- * @return srpObject of type PCEP SRP Object
- */
- PcepSrpObject getSrpObject();
-
- /**
- * Returns object of PCEP LSP Object.
- *
- * @return lspObject of type PCEP LSP Object
- */
- PcepLspObject getLspObject();
-
- /**
- * Returns object of PCEP MSG PATH.
- *
- * @return msgPath of type PCEP MSG PATH
- */
- PcepMsgPath getMsgPath();
-
- /**
- * Sets the PCEP SRP Object.
- *
- * @param srpObject object of type PCEP SRP Object
- */
- void setSrpObject(PcepSrpObject srpObject);
-
- /**
- * Sets the PCEP LSP Object.
- *
- * @param lspObject object of type PCEP LSP Object
- */
- void setLspObject(PcepLspObject lspObject);
-
- /**
- * sets the PCEP MSG PATH.
- *
- * @param msgPath object of type PCEP MSG PATH
- */
- void setMsgPath(PcepMsgPath msgPath);
-
- /**
- * Builder interface with get and set functions to build PcepUpdateRequest.
- */
- interface Builder {
-
- /**
- * Builds PcepUpdateRequest.
- *
- * @return PcepUpdateRequest
- * @throws PcepParseException if mandatory object is not set
- */
- PcepUpdateRequest build() throws PcepParseException;
-
- /**
- * Returns PcepSrpObject.
- *
- * @return srpObject
- */
- PcepSrpObject getSrpObject();
-
- /**
- * Returns PcepLspObject.
- *
- * @return lspObject
- */
- PcepLspObject getLspObject();
-
- /**
- * Returns PcepMsgPath.
- *
- * @return msgPath
- */
- PcepMsgPath getMsgPath();
-
- /**
- * Sets the SRP Object.
- *
- * @param srpObj of type PcepSrpObject
- * @return builder by setting PcepSrpObject
- */
- Builder setSrpObject(PcepSrpObject srpObj);
-
- /**
- * Sets the LSP Object.
- *
- * @param lspObject of type PcepLspObject
- * @return builder by setting PcepLspObject
- */
- Builder setLspObject(PcepLspObject lspObject);
-
- /**
- * Sets the Path Object.
- *
- * @param msgPath of type PcepMsgPath
- * @return builder by setting PcepMsgPath
- */
- Builder setMsgPath(PcepMsgPath msgPath);
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepVersion.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepVersion.java
deleted file mode 100644
index 691847a..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepVersion.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-/**
- * Enum to provide PCEP Message Version.
- */
-public enum PcepVersion {
-
- PCEP_1(1);
-
- public final int packetVersion;
-
- /**
- * Assign PCEP PacketVersion with WireVersion.
- *
- * @param wireVersion version of pcep
- */
- PcepVersion(final int wireVersion) {
-
- this.packetVersion = wireVersion;
- }
-
- /**
- * Returns Wire version of PCEP Message.
- *
- * @return packetVersion
- */
- public int getWireVersion() {
- return packetVersion;
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/Writeable.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/Writeable.java
deleted file mode 100644
index a589f9b..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/Writeable.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-/**
- * Abstraction of an entity providing functionality to write byte streams of
- * Messages to channel buffer.
- */
-public interface Writeable {
-
- /**
- * Writes byte streams of messages to channel buffer.
- *
- * @param bb parameter of type channel buffer
- * @throws PcepParseException when error occurs while writing pcep message to channel buffer
- */
- void writeTo(ChannelBuffer bb) throws PcepParseException;
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/package-info.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/package-info.java
deleted file mode 100644
index 5d0c6aa..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Abstraction of an entity providing PCEP messages.
- */
-package org.onosproject.pcepio.protocol;
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcInitiatedLspRequestVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcInitiatedLspRequestVer1.java
deleted file mode 100644
index 11d6ffb..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcInitiatedLspRequestVer1.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
-import org.onosproject.pcepio.protocol.PcepAttribute;
-import org.onosproject.pcepio.protocol.PcepEndPointsObject;
-import org.onosproject.pcepio.protocol.PcepEroObject;
-import org.onosproject.pcepio.protocol.PcepLspObject;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PcInitiatedLspRequest for PCEP Initiate message.
- * Reference : PCE initiated tunnel setup draft-ietf-pce-pce-initiated-lsp-03.
- */
-public class PcInitiatedLspRequestVer1 implements PcInitiatedLspRequest {
-
- /*
- * <PCE-initiated-lsp-request> ::= (<PCE-initiated-lsp-instantiation>|<PCE-initiated-lsp-deletion>)
- <PCE-initiated-lsp-instantiation> ::= <SRP>
- <LSP>
- <END-POINTS>
- <ERO>
- [<attribute-list>]
- <PCE-initiated-lsp-deletion> ::= <SRP>
- <LSP>
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcInitiatedLspRequestVer1.class);
-
- //PCEP SRP Object
- private PcepSrpObject srpObject;
- //PCEP LSP Object
- private PcepLspObject lspObject;
- //PCEP End Point Object
- private PcepEndPointsObject endPointsObject;
- //PCEP ERO Object
- private PcepEroObject eroObject;
- //PCEP Attribute list
- private PcepAttribute pcepAttribute;
-
- /**
- * Default constructor.
- */
- public PcInitiatedLspRequestVer1() {
- srpObject = null;
- lspObject = null;
- endPointsObject = null;
- eroObject = null;
- pcepAttribute = null;
-
- }
-
- /**
- * Constructor to initialize all parameters of PC initiated lsp request.
- *
- * @param srpObject PCEP srp Object
- * @param lspObject PCEP lsp object
- * @param endPointsObject PCPE endpoints object
- * @param eroObject PCEP ero object
- * @param pcepAttribute PCEP attribute
- */
- public PcInitiatedLspRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject,
- PcepEndPointsObject endPointsObject, PcepEroObject eroObject, PcepAttribute pcepAttribute) {
- this.srpObject = srpObject;
- this.lspObject = lspObject;
- this.endPointsObject = endPointsObject;
- this.eroObject = eroObject;
- this.pcepAttribute = pcepAttribute;
-
- }
-
- @Override
- public PcepSrpObject getSrpObject() {
- return srpObject;
- }
-
- @Override
- public PcepLspObject getLspObject() {
- return lspObject;
- }
-
- @Override
- public PcepEndPointsObject getEndPointsObject() {
- return endPointsObject;
- }
-
- @Override
- public PcepEroObject getEroObject() {
- return eroObject;
- }
-
- @Override
- public PcepAttribute getPcepAttribute() {
- return pcepAttribute;
- }
-
- @Override
- public void setSrpObject(PcepSrpObject srpobj) {
- this.srpObject = srpobj;
-
- }
-
- @Override
- public void setLspObject(PcepLspObject lspObject) {
- this.lspObject = lspObject;
- }
-
- @Override
- public void setEndPointsObject(PcepEndPointsObject endPointsObject) {
- this.endPointsObject = endPointsObject;
- }
-
- @Override
- public void setEroObject(PcepEroObject eroObject) {
- this.eroObject = eroObject;
- }
-
- @Override
- public void setPcepAttribute(PcepAttribute pcepAttribute) {
- this.pcepAttribute = pcepAttribute;
- }
-
- /**
- * Builder class for PC initiated lsp reuqest.
- */
- public static class Builder implements PcInitiatedLspRequest.Builder {
-
- private boolean bIsSrpObjectSet = false;
- private boolean bIsLspObjectSet = false;
- private boolean bIsEndPointsObjectSet = false;
- private boolean bIsEroObjectSet = false;
- private boolean bIsPcepAttributeSet = false;
- private boolean bIsbRFlagSet = false;
-
- //PCEP SRP Object
- private PcepSrpObject srpObject;
- //PCEP LSP Object
- private PcepLspObject lspObject;
- //PCEP End Point Object
- private PcepEndPointsObject endPointsObject;
- //PCEP ERO Object
- private PcepEroObject eroObject;
- //PCEP Attribute list
- private PcepAttribute pcepAttribute;
-
- @Override
- public PcInitiatedLspRequest build() throws PcepParseException {
-
- //PCEP SRP Object
- PcepSrpObject srpObject = null;
- //PCEP LSP Object
- PcepLspObject lspObject = null;
- //PCEP End Point Object
- PcepEndPointsObject endPointsObject = null;
- //PCEP ERO Object
- PcepEroObject eroObject = null;
- //PCEP Attribute list
- PcepAttribute pcepAttribute = null;
- boolean bRFlag = false;
-
- if (!this.bIsSrpObjectSet) {
- throw new PcepParseException("Srp object NOT Set while building PcInitiatedLspRequest");
- } else {
- srpObject = this.srpObject;
- bRFlag = srpObject.getRFlag();
- }
-
- if (bRFlag) {
- this.bIsbRFlagSet = true;
- } else {
- this.bIsbRFlagSet = false;
- }
-
- if (!this.bIsLspObjectSet) {
- throw new PcepParseException("LSP Object NOT Set while building PcInitiatedLspRequest");
- } else {
- lspObject = this.lspObject;
- }
- if (!this.bIsbRFlagSet) {
-
- if (!this.bIsEndPointsObjectSet) {
- throw new PcepParseException("EndPoints Object NOT Set while building PcInitiatedLspRequest");
- } else {
- endPointsObject = this.endPointsObject;
- }
- if (!this.bIsEroObjectSet) {
- throw new PcepParseException("ERO Object NOT Set while building PcInitiatedLspRequest");
- } else {
- eroObject = this.eroObject;
- }
- if (bIsPcepAttributeSet) {
- pcepAttribute = this.pcepAttribute;
- }
- }
- return new PcInitiatedLspRequestVer1(srpObject, lspObject, endPointsObject, eroObject, pcepAttribute);
- }
-
- @Override
- public PcepSrpObject getSrpObject() {
- return this.srpObject;
- }
-
- @Override
- public PcepLspObject getLspObject() {
- return this.lspObject;
- }
-
- @Override
- public PcepEndPointsObject getEndPointsObject() {
- return this.endPointsObject;
- }
-
- @Override
- public PcepEroObject getEroObject() {
- return this.eroObject;
- }
-
- @Override
- public PcepAttribute getPcepAttribute() {
- return this.pcepAttribute;
- }
-
- @Override
- public Builder setSrpObject(PcepSrpObject srpobj) {
- this.srpObject = srpobj;
- this.bIsSrpObjectSet = true;
- return this;
-
- }
-
- @Override
- public Builder setLspObject(PcepLspObject lspObject) {
- this.lspObject = lspObject;
- this.bIsLspObjectSet = true;
- return this;
- }
-
- @Override
- public Builder setEndPointsObject(PcepEndPointsObject endPointsObject) {
- this.endPointsObject = endPointsObject;
- this.bIsEndPointsObjectSet = true;
- return this;
- }
-
- @Override
- public Builder setEroObject(PcepEroObject eroObject) {
- this.eroObject = eroObject;
- this.bIsEroObjectSet = true;
- return this;
- }
-
- @Override
- public Builder setPcepAttribute(PcepAttribute pcepAttribute) {
- this.pcepAttribute = pcepAttribute;
- this.bIsPcepAttributeSet = true;
- return this;
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("SrpObject", srpObject)
- .add("LspObject", lspObject)
- .add("EndPointObject", endPointsObject)
- .add("EroObject", eroObject)
- .add("PcepAttribute", pcepAttribute)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepAttributeVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepAttributeVer1.java
deleted file mode 100644
index cb07001..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepAttributeVer1.java
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepAttribute;
-import org.onosproject.pcepio.protocol.PcepBandwidthObject;
-import org.onosproject.pcepio.protocol.PcepIroObject;
-import org.onosproject.pcepio.protocol.PcepLspaObject;
-import org.onosproject.pcepio.protocol.PcepMetricObject;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP Attribute List.
- */
-public class PcepAttributeVer1 implements PcepAttribute {
-
- /* Reference : RFC5440
- * where:
- * <attribute-list> ::=[<LSPA>]
- * [<BANDWIDTH>]
- * [<metric-list>]
- * [<IRO>]
- *
- * <metric-list> ::=<METRIC>[<metric-list>]
- */
- private static final Logger log = LoggerFactory.getLogger(PcepAttributeVer1.class);
-
- public static final int OBJECT_HEADER_LENGTH = 4;
-
- //PCEP LSPA Object
- private PcepLspaObject lspaObject;
- private boolean isLspaObjectSet;
-
- //PCEP Bandwidth Object
- private PcepBandwidthObject bandwidthObject;
- private boolean isBandwidthObjectSet;
-
- //PCEP Metric list
- private LinkedList<PcepMetricObject> llMetricList;
- private boolean isMetricListSet;
-
- //PCEP IRO object
- private PcepIroObject iroObject;
- private boolean isIroObjectSet;
-
- /**
- * Default constructor to initialize member variables.
- */
- public PcepAttributeVer1() {
-
- lspaObject = null;
- bandwidthObject = null;
- llMetricList = null;
- iroObject = null;
- this.isLspaObjectSet = false;
- this.isBandwidthObjectSet = false;
- this.isMetricListSet = false;
- this.isIroObjectSet = false;
- }
-
- /**
- * Constructor to initialize all parameters for PCEP attribute.
- *
- * @param lspaObject PCEP lspa Object.
- * @param bandwidthObject PCEP bandwidth object.
- * @param llMetricList list of PCEP metric objects.
- * @param iroObject PCEP iro object.
- */
- public PcepAttributeVer1(PcepLspaObject lspaObject, PcepBandwidthObject bandwidthObject,
- LinkedList<PcepMetricObject> llMetricList, PcepIroObject iroObject) {
-
- this.lspaObject = lspaObject;
- this.bandwidthObject = bandwidthObject;
- this.llMetricList = llMetricList;
- this.iroObject = iroObject;
- if (lspaObject == null) {
- this.isLspaObjectSet = false;
- } else {
- this.isLspaObjectSet = true;
- }
- if (bandwidthObject == null) {
- this.isBandwidthObjectSet = false;
- } else {
- this.isBandwidthObjectSet = true;
- }
- if (llMetricList == null) {
- this.isMetricListSet = false;
- } else {
- this.isMetricListSet = true;
- }
- if (iroObject == null) {
- this.isIroObjectSet = false;
- } else {
- this.isIroObjectSet = true;
- }
- }
-
- /**
- * constructor to initialize bandwidthObject.
- *
- * @param bandwidthObject bandwidth object
- */
- public PcepAttributeVer1(PcepBandwidthObject bandwidthObject) {
- this.isLspaObjectSet = false;
-
- this.bandwidthObject = bandwidthObject;
- this.isBandwidthObjectSet = true;
-
- this.isMetricListSet = false;
-
- this.isIroObjectSet = false;
- }
-
- /**
- * Parse list for MeticObject.
- *
- * @param cb of type channel buffer
- * @return true if parsing metric list is success
- * @throws PcepParseException when a non metric object is received
- */
- public boolean parseMetricList(ChannelBuffer cb) throws PcepParseException {
-
- if (llMetricList == null) {
- llMetricList = new LinkedList<>();
- }
-
- PcepMetricObject metriclist;
-
- //caller should verify for metric object
- byte yObjClass = PcepMetricObjectVer1.METRIC_OBJ_CLASS;
- byte yObjType = PcepMetricObjectVer1.METRIC_OBJ_TYPE;
-
- while ((yObjClass == PcepMetricObjectVer1.METRIC_OBJ_CLASS)
- && (yObjType == PcepMetricObjectVer1.METRIC_OBJ_TYPE)) {
-
- metriclist = PcepMetricObjectVer1.read(cb);
- llMetricList.add(metriclist);
- yObjClass = 0;
- yObjType = 0;
-
- if (cb.readableBytes() > OBJECT_HEADER_LENGTH) {
- cb.markReaderIndex();
- PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
- yObjClass = tempObjHeader.getObjClass();
- yObjType = tempObjHeader.getObjType();
- }
- }
- return true;
- }
-
- /**
- * Reads lspa , bandwidth , Metriclist and Iro objects and sets the objects.
- *
- * @param cb of type channel buffer
- * @return instance of Pcep Attribute
- * @throws PcepParseException while parsing Pcep Attributes from channel buffer
- */
-
- public static PcepAttribute read(ChannelBuffer cb) throws PcepParseException {
- if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
- return null;
- }
- //check whether any pcep attribute is present
- cb.markReaderIndex();
- PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
- byte yObjClass = tempObjHeader.getObjClass();
-
- if (PcepLspaObjectVer1.LSPA_OBJ_CLASS != yObjClass && PcepBandwidthObjectVer1.BANDWIDTH_OBJ_CLASS != yObjClass
- && PcepMetricObjectVer1.METRIC_OBJ_CLASS != yObjClass && PcepIroObjectVer1.IRO_OBJ_CLASS != yObjClass) {
- //No PCEP attribute is present
- return null;
- }
-
- PcepAttributeVer1 pcepAttribute = new PcepAttributeVer1();
-
- //If LSPA present then store it.LSPA is optional
- if (yObjClass == PcepLspaObjectVer1.LSPA_OBJ_CLASS) {
- pcepAttribute.setLspaObject(PcepLspaObjectVer1.read(cb));
- yObjClass = checkNextObject(cb);
- }
-
- //If BANDWIDTH present then store it.BANDWIDTH is optional
- if (yObjClass == PcepBandwidthObjectVer1.BANDWIDTH_OBJ_CLASS) {
- pcepAttribute.setBandwidthObject(PcepBandwidthObjectVer1.read(cb));
- yObjClass = checkNextObject(cb);
- }
-
- //If Metric list present then store it.MetricList is optional
- if (yObjClass == PcepMetricObjectVer1.METRIC_OBJ_CLASS) {
- pcepAttribute.parseMetricList(cb);
- yObjClass = checkNextObject(cb);
- }
-
- //If IRO present then store it.IRO is optional
- if (yObjClass == PcepIroObjectVer1.IRO_OBJ_CLASS) {
- pcepAttribute.setIroObject(PcepIroObjectVer1.read(cb));
- }
-
- PcepLspaObject lspaObject = pcepAttribute.getLspaObject();
- PcepBandwidthObject bandwidthObject = pcepAttribute.getBandwidthObject();
- LinkedList<PcepMetricObject> metriclist = pcepAttribute.llMetricList;
- PcepIroObject iroObject = pcepAttribute.getIroObject();
-
- return new PcepAttributeVer1(lspaObject, bandwidthObject, metriclist, iroObject);
- }
-
- /**
- * Checks whether there is a more object or not.
- *
- * @param cb of type channel buffer
- * @return instance of object header
- */
- private static byte checkNextObject(ChannelBuffer cb) {
- if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
- return 0;
- }
- cb.markReaderIndex();
- PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
- return tempObjHeader.getObjClass();
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
- int iLenStartIndex = cb.writerIndex();
- //PCEP LSPA object is optional
- if (this.isLspaObjectSet) {
- this.lspaObject.write(cb);
- }
-
- //PCEP BANDWIDTH object is optional
- if (this.isBandwidthObjectSet) {
- this.bandwidthObject.write(cb);
- }
-
- //PCEP Metric list is optional
- if (this.isMetricListSet) {
- ListIterator<PcepMetricObject> listIterator = this.llMetricList.listIterator();
- while (listIterator.hasNext()) {
- listIterator.next().write(cb);
- }
- }
-
- //PCEP IRO object is optional
- if (this.isIroObjectSet) {
- this.iroObject.write(cb);
- }
- return cb.writerIndex() - iLenStartIndex;
- }
-
- @Override
- public PcepLspaObject getLspaObject() {
- return lspaObject;
- }
-
- @Override
- public PcepBandwidthObject getBandwidthObject() {
- return bandwidthObject;
- }
-
- @Override
- public LinkedList<PcepMetricObject> getMetricObjectList() {
- return llMetricList;
- }
-
- @Override
- public PcepIroObject getIroObject() {
- return iroObject;
- }
-
- @Override
- public void setBandwidthObject(PcepBandwidthObject bandwidthObject) {
- this.isBandwidthObjectSet = true;
- this.bandwidthObject = bandwidthObject;
- }
-
- @Override
- public void setMetricObjectList(LinkedList<PcepMetricObject> llMetricList) {
- this.isMetricListSet = true;
- this.llMetricList = llMetricList;
-
- }
-
- @Override
- public void setLspaObject(PcepLspaObject lspaObject) {
- this.isLspaObjectSet = true;
- this.lspaObject = lspaObject;
- }
-
- @Override
- public void setIroObject(PcepIroObject iroObject) {
- this.isIroObjectSet = true;
- this.iroObject = iroObject;
- }
-
- /**
- * Builder class for PCEP attributes.
- */
- public static class Builder implements PcepAttribute.Builder {
-
- //PCEP LSPA Object
- private PcepLspaObject lspaObject;
- private boolean isLspaObjectSet;
-
- //PCEP BANDWIDTH Object
- private PcepBandwidthObject bandwidthObject;
- private boolean isBandwidthObjectSet;
-
- //PCEP Metric list
- private LinkedList<PcepMetricObject> llMetricList;
- private boolean isMetricListSet;
-
- //PCEP IRO object
- private PcepIroObject iroObject;
- private boolean isIroObjectSet;
-
- @Override
- public PcepAttribute build() {
-
- //PCEP LSPA Object
- PcepLspaObject lspaObject = null;
-
- //PCEP BANDWIDTH Object
- PcepBandwidthObject bandwidthObject = null;
-
- //PCEP Metric list
- LinkedList<PcepMetricObject> llMetricList = null;
-
- //PCEP IRO object
- PcepIroObject iroObject = null;
-
- if (this.isLspaObjectSet) {
- lspaObject = this.lspaObject;
- }
- if (this.isBandwidthObjectSet) {
- bandwidthObject = this.bandwidthObject;
- }
- if (this.isMetricListSet) {
- llMetricList = this.llMetricList;
- }
- if (this.isIroObjectSet) {
- iroObject = this.iroObject;
- }
- return new PcepAttributeVer1(lspaObject, bandwidthObject, llMetricList, iroObject);
- }
-
- @Override
- public PcepLspaObject getLspaObject() {
- return this.lspaObject;
- }
-
- @Override
- public PcepBandwidthObject getBandwidthObject() {
- return this.bandwidthObject;
- }
-
- @Override
- public LinkedList<PcepMetricObject> getMetricObjectList() {
- return this.llMetricList;
- }
-
- @Override
- public PcepIroObject getIroObject() {
- return this.iroObject;
- }
-
- @Override
- public Builder setBandwidthObject(PcepBandwidthObject bandwidthObject) {
- this.isBandwidthObjectSet = true;
- this.bandwidthObject = bandwidthObject;
- return this;
- }
-
- @Override
- public Builder setMetricObjectList(LinkedList<PcepMetricObject> llMetricList) {
- this.isMetricListSet = true;
- this.llMetricList = llMetricList;
- return this;
- }
-
- @Override
- public Builder setLspaObject(PcepLspaObject lspaObject) {
- this.isLspaObjectSet = true;
- this.lspaObject = lspaObject;
- return this;
- }
-
- @Override
- public Builder setIroObject(PcepIroObject iroObject) {
- this.isIroObjectSet = true;
- this.iroObject = iroObject;
- return this;
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("lspaObject", lspaObject)
- .add("bandwidthObject", bandwidthObject)
- .add("MetricObjectList", llMetricList)
- .add("IroObject", iroObject)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepBandwidthObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepBandwidthObjectVer1.java
deleted file mode 100644
index 090c96f..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepBandwidthObjectVer1.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepBandwidthObject;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PcepBandwidthObject.
- */
-public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
-
- /*
- * RFC : 5440 , section : 7.7.
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Bandwidth |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- The BANDWIDTH Object format
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepBandwidthObjectVer1.class);
- /*
- * Requested bandwidth: BANDWIDTH Object-Type is 1.
- Bandwidth of an existing TE LSP for which a re-optimization is
- requested. BANDWIDTH Object-Type is 2.
- */
- //Right now handling type 1
- public static final byte BANDWIDTH_OBJ_TYPE = 1;
- public static final byte BANDWIDTH_OBJ_CLASS = 5;
- public static final byte BANDWIDTH_OBJECT_VERSION = 1;
- public static final int NO_OF_BITS = 8;
- public static final short BANDWIDTH_OBJ_MINIMUM_LENGTH = 8;
-
- static final PcepObjectHeader DEFAULT_BANDWIDTH_OBJECT_HEADER = new PcepObjectHeader(BANDWIDTH_OBJ_CLASS,
- BANDWIDTH_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
- BANDWIDTH_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader bandwidthObjHeader;
- private float iBandwidth;
-
- /**
- * Constructor to bandwidth object header and bandwidth.
- *
- * @param bandwidthObjHeader bandwidth object header
- * @param iBandwidth bandwidth value
- */
- public PcepBandwidthObjectVer1(PcepObjectHeader bandwidthObjHeader, float iBandwidth) {
- this.bandwidthObjHeader = bandwidthObjHeader;
- this.iBandwidth = iBandwidth;
- }
-
- /**
- * Constructor to initialize bandwidth.
- *
- * @param iBandwidth bandwidth value
- */
- public PcepBandwidthObjectVer1(float iBandwidth) {
- this.bandwidthObjHeader = DEFAULT_BANDWIDTH_OBJECT_HEADER;
- this.iBandwidth = iBandwidth;
- }
-
- /**
- * Returns Object Header.
- *
- * @return bandwidthObjHeader
- */
- public PcepObjectHeader getBandwidthObjHeader() {
- return this.bandwidthObjHeader;
- }
-
- /**
- * Sets Object Header.
- *
- * @param obj bandwidth object header
- */
- public void setBandwidthObjHeader(PcepObjectHeader obj) {
- this.bandwidthObjHeader = obj;
- }
-
- @Override
- public float getBandwidth() {
- return this.iBandwidth;
- }
-
- @Override
- public void setBandwidth(float iBandwidth) {
- this.iBandwidth = iBandwidth;
- }
-
- /**
- * Reads from channel buffer and returns object of PcepBandwidthObject.
- *
- * @param cb channel buffer to parse
- * @return object of PcepBandwidthObject
- * @throws PcepParseException while parsing channel buffer
- */
- public static PcepBandwidthObject read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader bandwidthObjHeader;
- float bandwidth;
-
- bandwidthObjHeader = PcepObjectHeader.read(cb);
- bandwidth = ieeeToFloatRead(cb.readInt()) * NO_OF_BITS;
-
- return new PcepBandwidthObjectVer1(bandwidthObjHeader, bandwidth);
- }
-
- /**
- * Parse the IEEE floating point notation and returns it in normal float.
- *
- * @param iVal IEEE floating point number
- * @return normal float
- */
- public static float ieeeToFloatRead(int iVal) {
-
- return Float.intBitsToFloat(iVal);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- //write Object header
- int objStartIndex = cb.writerIndex();
- int objLenIndex = bandwidthObjHeader.write(cb);
-
- if (objLenIndex <= 0) {
- throw new PcepParseException("Failed to write bandwidth object header. Index " + objLenIndex);
- }
-
- //Convert to bytes per second
- float bwBytes = iBandwidth / 8.0f;
- //Bytes/sec to IEEE floating format
- int bandwidth = Float.floatToIntBits(bwBytes);
-
- cb.writeByte(bandwidth >>> 24);
- cb.writeByte(bandwidth >> 16 & 0xff);
- cb.writeByte(bandwidth >> 8 & 0xff);
- cb.writeByte(bandwidth & 0xff);
-
- short hLength = (short) (cb.writerIndex() - objStartIndex);
- cb.setShort(objLenIndex, hLength);
- //will be helpful during print().
- bandwidthObjHeader.setObjLen(hLength);
-
- return cb.writerIndex() - objStartIndex;
- }
-
- /**
- * builder class for PCEP bandwidth object.
- */
- public static class Builder implements PcepBandwidthObject.Builder {
-
- private PcepObjectHeader bandwidthObjHeader;
- private boolean bIsHeaderSet = false;
-
- private float iBandwidth;
- private boolean bIsBandwidthSet = false;
-
- private boolean bPFlag;
- private boolean bIsPFlagSet = false;
-
- private boolean bIFlag;
- private boolean bIsIFlagSet = false;
-
- @Override
- public PcepBandwidthObject build() throws PcepParseException {
-
- PcepObjectHeader bandwidthObjHeader = this.bIsHeaderSet ? this.bandwidthObjHeader
- : DEFAULT_BANDWIDTH_OBJECT_HEADER;
-
- if (bIsPFlagSet) {
- bandwidthObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- bandwidthObjHeader.setIFlag(bIFlag);
- }
-
- if (!this.bIsBandwidthSet) {
- throw new PcepParseException("bandwidth not Set while building Bandwidth Object.");
- }
-
- return new PcepBandwidthObjectVer1(bandwidthObjHeader, iBandwidth);
- }
-
- @Override
- public float getBandwidth() {
- return this.iBandwidth;
- }
-
- @Override
- public PcepObjectHeader getBandwidthObjHeader() {
- return this.bandwidthObjHeader;
- }
-
- @Override
- public Builder setBandwidthObjHeader(PcepObjectHeader obj) {
- this.bandwidthObjHeader = obj;
- return this;
- }
-
- @Override
- public Builder setBandwidth(float iBandwidth) {
- this.iBandwidth = iBandwidth;
- this.bIsBandwidthSet = true;
- return this;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
-
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("BandwidthObjectHeader", bandwidthObjHeader)
- .add("Bandwidth", iBandwidth).toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepCloseMsgVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepCloseMsgVer1.java
deleted file mode 100644
index fcf3421..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepCloseMsgVer1.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepCloseMsg;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepMessageWriter;
-import org.onosproject.pcepio.protocol.PcepType;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP Close Message.
- */
-class PcepCloseMsgVer1 implements PcepCloseMsg {
-
- /*
- * RFC : 5440 , section : 6.8
- * <Close Message> ::= <Common Header> <CLOSE>
- *
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Ver | Flags | Message-Type | Message-Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Object-Class | OT |Res|P|I| Object Length (bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Reserved | Flags | Reason |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Optional TLVs //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepCloseMsgVer1.class);
-
- // Pcep version: 1
- public static final byte PACKET_VERSION = 1;
- public static final int PACKET_MINIMUM_LENGTH = 12;
- public static final PcepType MSG_TYPE = PcepType.CLOSE;
- public static final byte CLOSE_OBJ_TYPE = 1;
- public static final byte CLOSE_OBJ_CLASS = 15;
- public static final byte CLOSE_OBJECT_VERSION = 1;
- public static final byte DEFAULT_REASON = 1; // Default reason to close
- public static final short CLOSE_OBJ_MINIMUM_LENGTH = 8;
- public static final int SHIFT_FLAG = 5;
- static final PcepObjectHeader DEFAULT_CLOSE_HEADER = new PcepObjectHeader(CLOSE_OBJ_CLASS, CLOSE_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, CLOSE_OBJ_MINIMUM_LENGTH);
-
- private final PcepObjectHeader closeObjHeader;
- private byte yReason;
- private LinkedList<PcepValueType> llOptionalTlv;
-
- public static final PcepCloseMsgVer1.Reader READER = new Reader();
-
- /**
- * Reader class for reading close message for channel buffer.
- */
- static class Reader implements PcepMessageReader<PcepCloseMsg> {
- PcepObjectHeader closeObjHeader;
- byte yReason;
- // Optional TLV
- private LinkedList<PcepValueType> llOptionalTlv;
-
- @Override
- public PcepCloseMsg readFrom(ChannelBuffer cb) throws PcepParseException {
-
- if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Packet size is less than the minimum length.");
- }
- // fixed value property version == 1
- byte version = cb.readByte();
- version = (byte) (version >> SHIFT_FLAG);
- if (version != PACKET_VERSION) {
- throw new PcepParseException("Wrong version. Expected=PcepVersion.PCEP_1(1), got=" + version);
- }
- // fixed value property type == 7
- byte type = cb.readByte();
- if (type != MSG_TYPE.getType()) {
- throw new PcepParseException("Wrong type. Expected=PcepType.CLOSE(7), got=" + type);
- }
- short length = cb.readShort();
- if (length < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Wrong length. Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: "
- + length);
- }
- closeObjHeader = PcepObjectHeader.read(cb);
- // Reserved
- cb.readShort();
- // Flags
- cb.readByte();
- // Reason
- yReason = cb.readByte();
- // parse optional TLV
- llOptionalTlv = parseOptionalTlv(cb);
- return new PcepCloseMsgVer1(closeObjHeader, yReason, llOptionalTlv);
- }
- }
-
- /**
- * Parse the list of Optional Tlvs.
- *
- * @param cb channel buffer
- * @return list of Optional Tlvs
- * @throws PcepParseException when fails to parse optional tlvs
- */
- public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
-
- LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
- /*
- rfc 5440:
- Optional TLVs may be included within the CLOSE object body. The
- specification of such TLVs is outside the scope of this document.
- */
- return llOptionalTlv;
- }
-
- /**
- * constructor to initialize PCEP close Message with all the parameters.
- *
- * @param closeObjHeader object header for close message
- * @param yReason reason for closing the channel
- * @param llOptionalTlv list of optional tlvs
- */
- PcepCloseMsgVer1(PcepObjectHeader closeObjHeader, byte yReason, LinkedList<PcepValueType> llOptionalTlv) {
-
- this.closeObjHeader = closeObjHeader;
- this.yReason = yReason;
- this.llOptionalTlv = llOptionalTlv;
- }
-
- /**
- * Builder class for PCEP close message.
- */
- static class Builder implements PcepCloseMsg.Builder {
-
- // PCEP Close message fields
- private boolean bIsHeaderSet = false;
- private PcepObjectHeader closeObjHeader;
- private boolean bIsReasonSet = false;
- private byte yReason;
- private LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return PcepType.CLOSE;
- }
-
- @Override
- public PcepCloseMsg build() {
-
- PcepObjectHeader closeObjHeader = this.bIsHeaderSet ? this.closeObjHeader : DEFAULT_CLOSE_HEADER;
- byte yReason = this.bIsReasonSet ? this.yReason : DEFAULT_REASON;
-
- if (bIsPFlagSet) {
- closeObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- closeObjHeader.setIFlag(bIFlag);
- }
- return new PcepCloseMsgVer1(closeObjHeader, yReason, this.llOptionalTlv);
- }
-
- @Override
- public PcepObjectHeader getCloseObjHeader() {
- return this.closeObjHeader;
- }
-
- @Override
- public Builder setCloseObjHeader(PcepObjectHeader obj) {
- this.closeObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public byte getReason() {
- return this.yReason;
- }
-
- @Override
- public Builder setReason(byte value) {
- this.yReason = value;
- this.bIsReasonSet = true;
- return this;
- }
-
- @Override
- public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
- this.llOptionalTlv = llOptionalTlv;
- return this;
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.llOptionalTlv;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
- }
-
- @Override
- public void writeTo(ChannelBuffer cb) throws PcepParseException {
- WRITER.write(cb, this);
- }
-
- static final Writer WRITER = new Writer();
-
- /**
- * Writer class for writing close message to channel buffer.
- */
- static class Writer implements PcepMessageWriter<PcepCloseMsgVer1> {
-
- @Override
- public void write(ChannelBuffer cb, PcepCloseMsgVer1 message) throws PcepParseException {
- int startIndex = cb.writerIndex();
- // first 3 bits set to version
- cb.writeByte((byte) (PACKET_VERSION << SHIFT_FLAG));
- // message type
- cb.writeByte(MSG_TYPE.getType());
- // length is length of variable message, will be updated at the end
- // Store the position of message
- // length in buffer
- int msgLenIndex = cb.writerIndex();
- cb.writeShort((short) 0);
- int objStartIndex = cb.writerIndex();
- int objLenIndex = message.closeObjHeader.write(cb);
- if (objLenIndex <= 0) {
- throw new PcepParseException("Failed to write Close object header.");
- }
- // first 3 bits set to version
- cb.writeShort(0); // Reserved
- cb.writeByte(0); // Flags
- cb.writeByte(message.yReason);
- // Pack optional TLV
- packOptionalTlv(cb, message);
- int length = cb.writerIndex() - objStartIndex;
- cb.setShort(objLenIndex, (short) length);
- // will be helpful during print().
- message.closeObjHeader.setObjLen((short) length);
- // As per RFC the length of object should be
- // multiples of 4
- int pad = length % 4;
- if (pad != 0) {
- pad = 4 - pad;
- for (int i = 0; i < pad; i++) {
- cb.writeByte((byte) 0);
- }
- length = length + pad;
- }
- // update message length field
- length = cb.writerIndex() - startIndex;
- cb.setShort(msgLenIndex, (short) length);
- }
-
- public void packOptionalTlv(ChannelBuffer cb, PcepCloseMsgVer1 message) {
-
- LinkedList<PcepValueType> llOptionalTlv = message.llOptionalTlv;
- ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
- while (listIterator.hasNext()) {
- listIterator.next().write(cb);
- }
- }
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return MSG_TYPE;
- }
-
- @Override
- public byte getReason() {
- return this.yReason;
- }
-
- @Override
- public void setReason(byte value) {
- this.yReason = value;
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.llOptionalTlv;
- }
-
- @Override
- public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
- this.llOptionalTlv = llOptionalTlv;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("closeObjectHeader", closeObjHeader).add("Reason", yReason)
- .add("OptionalTlvlist", llOptionalTlv).toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEndPointsObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEndPointsObjectVer1.java
deleted file mode 100644
index 4690626..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEndPointsObjectVer1.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepEndPointsObject;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP Endpoints Object.
- */
-public class PcepEndPointsObjectVer1 implements PcepEndPointsObject {
-
- /*
- * RFC : 5440 , section : 7.6
- * An End point is defined as follows:
- END-POINTS Object-Class is 4.
-
- END-POINTS Object-Type is 1 for IPv4 and 2 for IPv6.
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Object-Class | OT |Res|P|I| Object Length (bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Source IPv4 address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Destination IPv4 address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- */
- private static final Logger log = LoggerFactory.getLogger(PcepEndPointsObjectVer1.class);
-
- static final byte END_POINTS_OBJ_TYPE = 1;
- static final byte END_POINTS_OBJ_CLASS = 4;
- static final byte END_POINTS_OBJECT_VERSION = 1;
- static final short END_POINTS_OBJ_MINIMUM_LENGTH = 12;
- static byte endPointObjType;
-
- static final PcepObjectHeader DEFAULT_END_POINTS_OBJECT_HEADER = new PcepObjectHeader(END_POINTS_OBJ_CLASS,
- END_POINTS_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
- END_POINTS_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader endPointsObjHeader;
- int sourceIpAddress;
- int destIpAddress;
-
- /**
- * Constructor to initialize all variables.
- *
- * @param endPointsObjHeader end points object header
- * @param sourceIpAddress source IP address
- * @param destIpAddress destination IP address
- */
- public PcepEndPointsObjectVer1(PcepObjectHeader endPointsObjHeader, int sourceIpAddress, int destIpAddress) {
-
- this.endPointsObjHeader = endPointsObjHeader;
- this.sourceIpAddress = sourceIpAddress;
- this.destIpAddress = destIpAddress;
- }
-
- /**
- * Sets End Points Object Header.
- *
- * @param obj of PcepObjectHeader
- */
- public void setEndPointsObjHeader(PcepObjectHeader obj) {
- this.endPointsObjHeader = obj;
- }
-
- @Override
- public void setSourceIpAddress(int sourceIpAddress) {
- this.sourceIpAddress = sourceIpAddress;
- }
-
- @Override
- public void setDestIpAddress(int destIpAddress) {
- this.destIpAddress = destIpAddress;
- }
-
- @Override
- public int getSourceIpAddress() {
- return this.sourceIpAddress;
- }
-
- @Override
- public int getDestIpAddress() {
- return this.destIpAddress;
- }
-
- /**
- * Reads from channel buffer and returns object of PcepEndPointsObject.
- *
- * @param cb of channel buffer
- * @return object of PcepEndPointsObject
- * @throws PcepParseException while parsing channel buffer
- */
- public static PcepEndPointsObject read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader endPointsObjHeader;
- int sourceIpAddress;
- int destIpAddress;
-
- endPointsObjHeader = PcepObjectHeader.read(cb);
- if (endPointsObjHeader.getObjType() == END_POINTS_OBJ_TYPE
- && endPointsObjHeader.getObjClass() == END_POINTS_OBJ_CLASS) {
- sourceIpAddress = cb.readInt();
- destIpAddress = cb.readInt();
- } else {
- throw new PcepParseException("Expected PcepEndPointsObject.");
- }
- return new PcepEndPointsObjectVer1(endPointsObjHeader, sourceIpAddress, destIpAddress);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- int objStartIndex = cb.writerIndex();
- //write common header
- int objLenIndex = endPointsObjHeader.write(cb);
-
- //write source IPv4 IP
- cb.writeInt(sourceIpAddress);
- //write destination IPv4 IP
- cb.writeInt(destIpAddress);
-
- int length = cb.writerIndex() - objStartIndex;
- //now write EndPoints Object Length
- cb.setShort(objLenIndex, (short) length);
- //will be helpful during print().
- endPointsObjHeader.setObjLen((short) length);
-
- return cb.writerIndex();
-
- }
-
- /**
- * Builder class for PCEP end points objects.
- */
- public static class Builder implements PcepEndPointsObject.Builder {
-
- private boolean bIsHeaderSet = false;
- private boolean bIsSourceIpAddressset = false;
- private boolean bIsDestIpAddressset = false;
- private PcepObjectHeader endpointsObjHeader;
- private int sourceIpAddress;
- private int destIpAddress;
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepEndPointsObject build() throws PcepParseException {
-
- PcepObjectHeader endpointsObjHeader = this.bIsHeaderSet ? this.endpointsObjHeader
- : DEFAULT_END_POINTS_OBJECT_HEADER;
-
- if (bIsPFlagSet) {
- endpointsObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- endpointsObjHeader.setIFlag(bIFlag);
- }
-
- if (!this.bIsSourceIpAddressset) {
- throw new PcepParseException("SourceIpAddress not set while building EndPoints object");
- }
-
- if (!this.bIsDestIpAddressset) {
- throw new PcepParseException("DestIpAddress not set while building EndPoints object");
- }
-
- return new PcepEndPointsObjectVer1(endpointsObjHeader, this.sourceIpAddress, this.destIpAddress);
- }
-
- @Override
- public PcepObjectHeader getEndPointsObjHeader() {
- return this.endpointsObjHeader;
- }
-
- @Override
- public Builder setEndPointsObjHeader(PcepObjectHeader obj) {
- this.endpointsObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public int getSourceIpAddress() {
- return this.sourceIpAddress;
- }
-
- @Override
- public Builder setSourceIpAddress(int sourceIpAddress) {
- this.sourceIpAddress = sourceIpAddress;
- this.bIsSourceIpAddressset = true;
- return this;
- }
-
- @Override
- public int getDestIpAddress() {
- return this.destIpAddress;
- }
-
- @Override
- public Builder setDestIpAddress(int destIpAddress) {
- this.destIpAddress = destIpAddress;
- this.bIsDestIpAddressset = true;
- return this;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("sourceIpAddress", sourceIpAddress)
- .add("destIpAddress", destIpAddress).toString();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEroObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEroObjectVer1.java
deleted file mode 100644
index 76dc1fa..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEroObjectVer1.java
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.ListIterator;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepEroObject;
-import org.onosproject.pcepio.types.AutonomousSystemNumberSubObject;
-import org.onosproject.pcepio.types.IPv4SubObject;
-import org.onosproject.pcepio.types.IPv6SubObject;
-import org.onosproject.pcepio.types.PathKeySubObject;
-import org.onosproject.pcepio.types.PcepErrorDetailInfo;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.onosproject.pcepio.types.SrEroSubObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP Ero Object.
- */
-public class PcepEroObjectVer1 implements PcepEroObject {
- /*
- * rfc3209
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Object-Class | OT |Res|P|I| Object Length (bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // (Subobjects) //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- If a Path message contains multiple EXPLICIT_ROUTE objects, only the
- first object is meaningful. Subsequent EXPLICIT_ROUTE objects MAY be
- ignored and SHOULD NOT be propagated.
-
- In current implementation, only strict hops are supported. So,
- empty ERO with no sub-objects is considered illegal.
-
- Subobjects:
- 0 1
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------//----------------+
- |L| Type | Length | (Subobject contents) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------//----------------+
-
- L
-
- The L bit is an attribute of the subobject. The L bit is set
- if the subobject represents a loose hop in the explicit route.
- If the bit is not set, the subobject represents a strict hop in
- the explicit route.
-
- Type
-
- The Type indicates the type of contents of the subobject.
-
-
- Subobject 1: IPv4 address
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |L| Type | Length | IPv4 address (4 bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv4 address (continued) | Prefix Length | Resvd |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Subobject 2: IPv6 Prefix
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |L| Type | Length | IPv6 address (16 bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv6 address (continued) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv6 address (continued) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv6 address (continued) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv6 address (continued) | Prefix Length | Resvd |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Subobject 3: Autonomous System Number
-
- The contents of an Autonomous System (AS) number subobject are a 2-
- octet AS number. The abstract node represented by this subobject is
- the set of nodes belonging to the autonomous system.
-
- The length of the AS number subobject is 4 octets.
-
- Subobject 4: PATH_KEY_32_BIT_SUB_OBJ_TYPE:
-
- Pathkey subobject(RFC 5520):
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |L| Type | Length | Path-Key |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | PCE ID (4 bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Subobject 5: SR_ERO_SUB_OBJ_TYPE:
-
- SR-ERO subobject: (draft-ietf-pce-segment-routing-00)
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |L| Type | Length | ST | Flags |F|S|C|M|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | SID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // NAI (variable) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepEroObjectVer1.class);
-
- public static final byte ERO_OBJ_TYPE = 1;
- public static final byte ERO_OBJ_CLASS = 7;
- public static final byte ERO_OBJECT_VERSION = 1;
- public static final short ERO_OBJ_MINIMUM_LENGTH = 12;
- public static final byte IPV4_TYPE = 1;
- public static final byte PATH_KEY_32_BIT_SUB_OBJ_TYPE = 64;
- public static final int LABEL_SUB_OBJ_TYPE = 3;
- public static final int SR_ERO_SUB_OBJ_TYPE = 96;
- public static final int OBJECT_HEADER_LENGTH = 4;
- public static final int TYPE_SHIFT_VALUE = 0x7F;
-
- public static final PcepObjectHeader DEFAULT_ERO_OBJECT_HEADER = new PcepObjectHeader(ERO_OBJ_CLASS, ERO_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, ERO_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader eroObjHeader;
- private LinkedList<PcepValueType> subObjectList = new LinkedList<>();
-
- /**
- * reset variables.
- */
- public PcepEroObjectVer1() {
- this.eroObjHeader = null;
- this.subObjectList = null;
- }
-
- /**
- * Constructor to initialize parameters of ERO object.
- *
- * @param eroObjHeader ERO object header
- * @param subObjectList list of sub objects.
- */
- public PcepEroObjectVer1(PcepObjectHeader eroObjHeader, LinkedList<PcepValueType> subObjectList) {
-
- this.eroObjHeader = eroObjHeader;
- this.subObjectList = subObjectList;
- }
-
- /**
- * Returns ERO object header.
- *
- * @return eroObjHeader ERO object header
- */
- public PcepObjectHeader getEroObjHeader() {
- return this.eroObjHeader;
- }
-
- /**
- * Sets Object Header.
- *
- * @param obj ERO object header
- */
- public void setEroObjHeader(PcepObjectHeader obj) {
- this.eroObjHeader = obj;
- }
-
- @Override
- public LinkedList<PcepValueType> getSubObjects() {
- return this.subObjectList;
- }
-
- @Override
- public void setSubObjects(LinkedList<PcepValueType> subObjectList) {
- this.subObjectList = subObjectList;
- }
-
- /**
- * Reads from channel buffer and returns object of PcepEroObject.
- *
- * @param cb channel buffer.
- * @return object of PcepEroObject
- * @throws PcepParseException when ERO object is not present in channel buffer
- */
- public static PcepEroObject read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader eroObjHeader;
- LinkedList<PcepValueType> subObjectList = new LinkedList<>();
-
- eroObjHeader = PcepObjectHeader.read(cb);
-
- if (eroObjHeader.getObjClass() != PcepEroObjectVer1.ERO_OBJ_CLASS) {
- log.debug("ErrorType:" + PcepErrorDetailInfo.ERROR_TYPE_6 + " ErrorValue:"
- + PcepErrorDetailInfo.ERROR_VALUE_9);
- throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_6, PcepErrorDetailInfo.ERROR_VALUE_9);
- }
-
- if (eroObjHeader.getObjLen() > OBJECT_HEADER_LENGTH) {
- ChannelBuffer tempCb = cb.readBytes(eroObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
- subObjectList = parseSubObjects(tempCb);
- }
- return new PcepEroObjectVer1(eroObjHeader, subObjectList);
- }
-
- /**
- * Parse list of Sub Objects.
- *
- * @param cb channel buffer
- * @return list of Sub Objects
- * @throws PcepParseException when fails to parse sub object list
- */
- protected static LinkedList<PcepValueType> parseSubObjects(ChannelBuffer cb) throws PcepParseException {
-
- LinkedList<PcepValueType> subObjectList = new LinkedList<>();
-
- while (0 < cb.readableBytes()) {
-
- //check the Type of the TLV
- short type = cb.readByte();
- type = (short) (type & (TYPE_SHIFT_VALUE));
- byte hLength = cb.readByte();
-
- PcepValueType subObj;
-
- switch (type) {
-
- case IPv4SubObject.TYPE:
- subObj = IPv4SubObject.read(cb);
- break;
- case IPv6SubObject.TYPE:
- byte[] ipv6Value = new byte[IPv6SubObject.VALUE_LENGTH];
- cb.readBytes(ipv6Value, 0, IPv6SubObject.VALUE_LENGTH);
- subObj = new IPv6SubObject(ipv6Value);
- break;
- case AutonomousSystemNumberSubObject.TYPE:
- subObj = AutonomousSystemNumberSubObject.read(cb);
- break;
- case PathKeySubObject.TYPE:
- subObj = PathKeySubObject.read(cb);
- break;
- case SrEroSubObject.TYPE:
- subObj = SrEroSubObject.read(cb);
- break;
- default:
- throw new PcepParseException("Unexpected sub object. Type: " + (int) type);
- }
- // Check for the padding
- int pad = hLength % 4;
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= cb.readableBytes()) {
- cb.skipBytes(pad);
- }
- }
-
- subObjectList.add(subObj);
- }
- if (0 < cb.readableBytes()) {
- throw new PcepParseException("Subobject parsing error. Extra bytes received.");
- }
- return subObjectList;
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- //write Object header
- int objStartIndex = cb.writerIndex();
-
- int objLenIndex = eroObjHeader.write(cb);
-
- if (objLenIndex <= 0) {
- throw new PcepParseException("Failed to write ERO object header. Index " + objLenIndex);
- }
-
- ListIterator<PcepValueType> listIterator = subObjectList.listIterator();
-
- while (listIterator.hasNext()) {
- listIterator.next().write(cb);
- }
-
- //Update object length now
- int length = cb.writerIndex() - objStartIndex;
- cb.setShort(objLenIndex, (short) length);
- //will be helpful during print().
- eroObjHeader.setObjLen((short) length);
-
- //As per RFC the length of object should be multiples of 4
- int pad = length % 4;
-
- if (pad != 0) {
- pad = 4 - pad;
- for (int i = 0; i < pad; i++) {
- cb.writeByte((byte) 0);
- }
- length = length + pad;
- }
-
- objLenIndex = cb.writerIndex();
- return objLenIndex;
- }
-
- /**
- * Builder class for PCEP ERO object.
- */
- public static class Builder implements PcepEroObject.Builder {
-
- private boolean bIsHeaderSet = false;
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- private PcepObjectHeader eroObjHeader;
- LinkedList<PcepValueType> subObjectList = new LinkedList<>();
-
- @Override
- public PcepEroObject build() {
-
- PcepObjectHeader eroObjHeader = this.bIsHeaderSet ? this.eroObjHeader : DEFAULT_ERO_OBJECT_HEADER;
-
- if (bIsPFlagSet) {
- eroObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- eroObjHeader.setIFlag(bIFlag);
- }
-
- return new PcepEroObjectVer1(eroObjHeader, this.subObjectList);
- }
-
- @Override
- public PcepObjectHeader getEroObjHeader() {
- return this.eroObjHeader;
- }
-
- @Override
- public Builder setEroObjHeader(PcepObjectHeader obj) {
- this.eroObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public LinkedList<PcepValueType> getSubObjects() {
- return this.subObjectList;
- }
-
- @Override
- public Builder setSubObjects(LinkedList<PcepValueType> subObjectList) {
- this.subObjectList = subObjectList;
- return this;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(eroObjHeader, subObjectList);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("EroObjHeader", eroObjHeader)
- .add("SubObjects", subObjectList)
- .toString();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof PcepEroObjectVer1) {
- int countObjSubTlv = 0;
- int countOtherSubTlv = 0;
- boolean isCommonSubTlv = true;
- PcepEroObjectVer1 other = (PcepEroObjectVer1) obj;
- Iterator<PcepValueType> objListIterator = other.subObjectList.iterator();
- countOtherSubTlv = other.subObjectList.size();
- countObjSubTlv = subObjectList.size();
- if (countObjSubTlv != countOtherSubTlv) {
- return false;
- } else {
- while (objListIterator.hasNext() && isCommonSubTlv) {
- PcepValueType subTlv = objListIterator.next();
- if (subObjectList.contains(subTlv)) {
- isCommonSubTlv = Objects.equals(subObjectList.get(subObjectList.indexOf(subTlv)),
- other.subObjectList.get(other.subObjectList.indexOf(subTlv)));
- } else {
- isCommonSubTlv = false;
- }
- }
- return isCommonSubTlv && Objects.equals(eroObjHeader, other.eroObjHeader);
- }
- }
- return false;
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorInfoVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorInfoVer1.java
deleted file mode 100644
index 43c9f3c..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorInfoVer1.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepError;
-import org.onosproject.pcepio.protocol.PcepErrorInfo;
-import org.onosproject.pcepio.protocol.PcepErrorObject;
-import org.onosproject.pcepio.protocol.PcepRPObject;
-import org.onosproject.pcepio.protocol.PcepLSObject;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP Error Info.
- * Reference : draft-dhodylee-pce-pcep-ls-01, section 8.2.
- */
-public class PcepErrorInfoVer1 implements PcepErrorInfo {
-
- private static final Logger log = LoggerFactory.getLogger(PcepErrorInfoVer1.class);
- //Error list is optional
- private List<PcepError> errList;
-
- /**
- * Constructor to add PCEP error object to the list.
- *
- * @param llRPObjList list of PCEP RP object
- * @param llLSObjList list of PCEP LS object
- * @param llErrObjList list of PCEP error object
- */
- public PcepErrorInfoVer1(List<PcepRPObject> llRPObjList, List<PcepLSObject> llLSObjList,
- List<PcepErrorObject> llErrObjList) {
- this.errList = new LinkedList<>();
- if ((llErrObjList != null) && (!llErrObjList.isEmpty())) {
- this.errList.add(new PcepErrorVer1(llRPObjList, llLSObjList, llErrObjList));
- }
- }
-
- /**
- * Constructor to initialize error info.
- *
- * @param errll linked list or pcep error
- */
- public PcepErrorInfoVer1(List<PcepError> errll) {
- this.errList = errll;
- }
-
- @Override
- public boolean isErrorInfoPresent() {
- return !this.errList.isEmpty();
- }
-
- @Override
- public void read(ChannelBuffer cb) throws PcepParseException {
- PcepObjectHeader tempObjHeader;
-
- while (0 < cb.readableBytes()) {
- cb.markReaderIndex();
- tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
- byte yObjClass = tempObjHeader.getObjClass();
- if ((yObjClass != PcepRPObjectVer1.RP_OBJ_CLASS) && (yObjClass != PcepLSObjectVer1.LS_OBJ_CLASS)
- && (yObjClass != PcepErrorObjectVer1.ERROR_OBJ_CLASS)) {
- throw new PcepParseException("Unknown Object is present in PCEP-ERROR. Object Class: " + yObjClass);
- }
-
- this.errList.add(PcepErrorVer1.read(cb));
- }
- }
-
- @Override
- public void write(ChannelBuffer cb) throws PcepParseException {
- //write <error>
- ListIterator<PcepError> listIterator = errList.listIterator();
- while (listIterator.hasNext()) {
- PcepError pcepError = listIterator.next();
-
- //RP Object list is optional
- List<PcepRPObject> llRPObjList = pcepError.getRPObjList();
- if (llRPObjList != null) {
- ListIterator<PcepRPObject> rpListIterator = llRPObjList.listIterator();
- while (rpListIterator.hasNext()) {
- rpListIterator.next().write(cb);
- }
- }
-
- //LS Object list is optional
- List<PcepLSObject> llLSObjList = pcepError.getLSObjList();
- if (llLSObjList != null) {
- ListIterator<PcepLSObject> teListIterator = llLSObjList.listIterator();
- while (teListIterator.hasNext()) {
- teListIterator.next().write(cb);
- }
- }
-
- // <error-obj-list> is mandatory
- boolean bIsErrorObjListFound = false;
-
- List<PcepErrorObject> llErrObjList = pcepError.getErrorObjList();
- if (llErrObjList != null) {
- ListIterator<PcepErrorObject> errObjListIterator = llErrObjList.listIterator();
- while (errObjListIterator.hasNext()) {
- errObjListIterator.next().write(cb);
- bIsErrorObjListFound = true;
- }
- }
-
- if (!bIsErrorObjListFound) {
- throw new PcepParseException("<error-obj-list> is mandatory.");
- }
- }
- }
-
- @Override
- public List<Integer> getErrorType() {
- List<Integer> errorType = new LinkedList<>();
- ListIterator<PcepError> listIterator = errList.listIterator();
- PcepErrorObject errObj;
- int error;
- while (listIterator.hasNext()) {
- PcepError pcepError = listIterator.next();
- List<PcepErrorObject> llErrObjList = pcepError.getErrorObjList();
- if (llErrObjList != null) {
- ListIterator<PcepErrorObject> errObjListIterator = llErrObjList.listIterator();
- while (errObjListIterator.hasNext()) {
- errObj = errObjListIterator.next();
- error = errObj.getErrorType();
- errorType.add(error);
- }
- }
- }
- return errorType;
- }
-
- @Override
- public List<Integer> getErrorValue() {
- List<Integer> errorValue = new LinkedList<>();
- ListIterator<PcepError> listIterator = errList.listIterator();
- PcepErrorObject errObj;
- int error;
- while (listIterator.hasNext()) {
- PcepError pcepError = listIterator.next();
- List<PcepErrorObject> llErrObjList = pcepError.getErrorObjList();
- if (llErrObjList != null) {
- ListIterator<PcepErrorObject> errObjListIterator = llErrObjList.listIterator();
- while (errObjListIterator.hasNext()) {
- errObj = errObjListIterator.next();
- error = errObj.getErrorValue();
- errorValue.add(error);
- }
- }
- }
- return errorValue;
- }
-
- /**
- * Builder class for PCEP error info.
- */
- public static class Builder implements PcepErrorInfo.Builder {
- private List<PcepError> errll;
-
- @Override
- public PcepErrorInfo build() {
- return new PcepErrorInfoVer1(errll);
- }
-
- @Override
- public List<PcepError> getPcepErrorList() {
- return this.errll;
- }
-
- @Override
- public Builder setPcepErrorList(List<PcepError> errll) {
- this.errll = errll;
- return this;
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("ErrorList", errList).toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java
deleted file mode 100644
index 036f1f4..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepErrorInfo;
-import org.onosproject.pcepio.protocol.PcepErrorMsg;
-import org.onosproject.pcepio.protocol.PcepErrorObject;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepMessageWriter;
-import org.onosproject.pcepio.protocol.PcepOpenObject;
-import org.onosproject.pcepio.protocol.PcepType;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.onosproject.pcepio.types.ErrorObjListWithOpen;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-
-/**
- * Provides PCEP Error Message.
- */
-public class PcepErrorMsgVer1 implements PcepErrorMsg {
-
- /*
- * PCE Error message format.
- Reference: draft-dhodylee-pce-pcep-ls-01, section 8.2.
-
- <PCErr Message> ::= <Common Header>
- ( <error-obj-list> [<Open>] ) | <error>
- [<error-list>]
-
- <error-obj-list> ::=<PCEP-ERROR>[<error-obj-list>]
-
- <error> ::=[<request-id-list> | <ls-id-list>]
- <error-obj-list>
-
- <request-id-list> ::=<RP>[<request-id-list>]
-
- <ls-id-list> ::=<LS>[<ls-id-list>]
-
- <error-list> ::=<error>[<error-list>]
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepOpenMsgVer1.class);
- public static final byte PACKET_VERSION = 1;
- public static final int PACKET_MINIMUM_LENGTH = 12;
- public static final PcepType MSG_TYPE = PcepType.ERROR;
-
- //Below either one should be present.
- private ErrorObjListWithOpen errObjListWithOpen; //optional ( <error-obj-list> [<Open>] )
- private PcepErrorInfo errInfo; //optional <error> [<error-list>]
-
- public static final PcepErrorMsgVer1.Reader READER = new Reader();
-
- /**
- * Constructor to initialize variables.
- */
- public PcepErrorMsgVer1() {
- errObjListWithOpen = null;
- errInfo = null;
- }
-
- /**
- * Constructor to initialize variables.
- *
- * @param errObjListWithOpen error-object-list with open object
- * @param errInfo error information
- */
- public PcepErrorMsgVer1(ErrorObjListWithOpen errObjListWithOpen, PcepErrorInfo errInfo) {
- this.errObjListWithOpen = errObjListWithOpen;
- this.errInfo = errInfo;
- }
-
- /**
- * Reader class for reading PCEP error Message from channel buffer.
- */
- public static class Reader implements PcepMessageReader<PcepErrorMsg> {
-
- ErrorObjListWithOpen errObjListWithOpen;
- PcepErrorInfo errInfo;
- PcepObjectHeader tempObjHeader;
-
- @Override
- public PcepErrorMsg readFrom(ChannelBuffer cb) throws PcepParseException {
-
- errObjListWithOpen = null;
- errInfo = null;
- tempObjHeader = null;
-
- if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Packet size is less than the minimum length.");
- }
-
- byte version = cb.readByte();
- version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
- if (version != PACKET_VERSION) {
- throw new PcepParseException("Wrong version: Expected=PcepVersion.PCEP_1(1), got=" + version);
- }
- // fixed value property type == 1
- byte type = cb.readByte();
- if (type != MSG_TYPE.getType()) {
- throw new PcepParseException("Wrong type: Expected=PcepType.ERROR(6), got=" + type);
- }
- int length = cb.readShort();
- if (length < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException(
- "Wrong length: Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: " + length);
- }
-
- //parse <PCErr Message>
- parsePCErrMsg(cb);
-
- // If other than RP or LS or PCEP-ERROR present then it is error.
- if (0 < cb.readableBytes()) {
- PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
- throw new PcepParseException("Unexpected Object found. Object Class : " + tempObjHeader.getObjClass());
- }
-
- return new PcepErrorMsgVer1(errObjListWithOpen, errInfo);
- }
-
- /**
- * Parsing PCErr Message.
- *
- * @param cb channel buffer.
- * @throws PcepParseException if mandatory fields are missing
- * output: this.errObjListWithOpen, this.errInfo
- */
- public void parsePCErrMsg(ChannelBuffer cb) throws PcepParseException {
- //If PCEP-ERROR list is followed by OPEN Object then store into ErrorObjListWithOpen.
- // ( <error-obj-list> [<Open>]
- //If PCEP-ERROR list is followed by RP or LS Object then store into errInfo. <error> [<error-list>]
- //If only PCEP-ERROR list is present then store into ErrorObjListWithOpen.
- PcepObjectHeader tempObjHeader;
- List<PcepErrorObject> llErrObjList;
-
- if (0 >= cb.readableBytes()) {
- throw new PcepParseException("PCEP-ERROR message came with empty objects.");
- }
-
- //parse PCEP-ERROR list
- llErrObjList = new LinkedList<>();
- tempObjHeader = parseErrorObjectList(llErrObjList, cb);
-
- //check whether OPEN-OBJECT is present.
- if ((tempObjHeader != null)
- && (tempObjHeader.getObjClass() == PcepOpenObjectVer1.OPEN_OBJ_CLASS)) {
-
- if (llErrObjList.isEmpty()) {
- throw new PcepParseException("<error-obj-list> should be present if OPEN-OBJECT exists");
- }
-
- PcepOpenObject pcepOpenObj = PcepOpenObjectVer1.read(cb);
- this.errObjListWithOpen = new ErrorObjListWithOpen(llErrObjList, pcepOpenObj);
-
- } else if ((tempObjHeader != null) //check whether RP or LS Object is present.
- && ((tempObjHeader.getObjClass() == PcepRPObjectVer1.RP_OBJ_CLASS)
- || (tempObjHeader.getObjClass() == PcepLSObjectVer1.LS_OBJ_CLASS))) {
-
- this.errInfo = new PcepErrorInfoVer1(null, null, llErrObjList);
- this.errInfo.read(cb);
-
- } else if (!llErrObjList.isEmpty()) {
- //If only PCEP-ERROR list is present then store it in errObjListWithOpen.
- this.errObjListWithOpen = new ErrorObjListWithOpen(llErrObjList);
- } else {
- throw new PcepParseException("Empty PCEP-ERROR message.");
- }
- }
-
- /**
- * Parse error-obj-list.
- *
- * @param llErrObjList error object list output
- * @param cb channel buffer input
- * @throws PcepParseException if mandatory fields are missing
- * @return error object header
- */
- public PcepObjectHeader parseErrorObjectList(List<PcepErrorObject> llErrObjList, ChannelBuffer cb)
- throws PcepParseException {
- PcepObjectHeader tempObjHeader = null;
-
- while (0 < cb.readableBytes()) {
- cb.markReaderIndex();
- tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
- if (tempObjHeader.getObjClass() == PcepErrorObjectVer1.ERROR_OBJ_CLASS) {
- llErrObjList.add(PcepErrorObjectVer1.read(cb));
- } else {
- break;
- }
- }
- return tempObjHeader;
- }
- }
-
- /**
- * Builder class for PCEP error message.
- */
- public static class Builder implements PcepErrorMsg.Builder {
- // Pcep error message fields
-
- private ErrorObjListWithOpen errObjListWithOpen = null; //optional ( <error-obj-list> [<Open>] )
- private PcepErrorInfo errInfo = null; //optional <error> [<error-list>]
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return PcepType.ERROR;
- }
-
- @Override
- public PcepErrorMsg build() {
- return new PcepErrorMsgVer1(this.errObjListWithOpen, this.errInfo);
- }
-
- @Override
- public ErrorObjListWithOpen getErrorObjListWithOpen() {
- return this.errObjListWithOpen;
- }
-
- @Override
- public Builder setErrorObjListWithOpen(ErrorObjListWithOpen errObjListWithOpen) {
- this.errObjListWithOpen = errObjListWithOpen;
- return this;
- }
-
- @Override
- public PcepErrorInfo getPcepErrorInfo() {
- return this.errInfo;
- }
-
- @Override
- public Builder setPcepErrorInfo(PcepErrorInfo errInfo) {
- this.errInfo = errInfo;
- return this;
- }
- }
-
- @Override
- public void writeTo(ChannelBuffer cb) throws PcepParseException {
- WRITER.write(cb, this);
- }
-
- public static final Writer WRITER = new Writer();
-
- /**
- * Writer class for writing PCEP error Message to channel buffer.
- */
- static class Writer implements PcepMessageWriter<PcepErrorMsgVer1> {
- @Override
- public void write(ChannelBuffer cb, PcepErrorMsgVer1 message) throws PcepParseException {
- int startIndex = cb.writerIndex();
- // first 3 bits set to version
- cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
- // message type 0xC
- cb.writeByte(MSG_TYPE.getType());
- // length is length of variable message, will be updated at the end
- // Store the position of message
- // length in buffer
- int msgLenIndex = cb.writerIndex();
- cb.writeShort(0);
- ErrorObjListWithOpen errObjListWithOpen = message.getErrorObjListWithOpen();
- PcepErrorInfo errInfo = message.getPcepErrorInfo();
-
- // write ( <error-obj-list> [<Open>] ) if exists.
- // otherwise write <error> [<error-list>]
-
- if ((errObjListWithOpen != null)
- && (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
- errObjListWithOpen.write(cb);
- } else if ((errInfo != null) && (errInfo.isErrorInfoPresent())) {
- errInfo.write(cb);
- } else {
- throw new PcepParseException("Empty PCEP-ERROR message.");
- }
- // PcepErrorMessage message length field
- int length = cb.writerIndex() - startIndex;
- cb.setShort(msgLenIndex, (short) length);
- }
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return MSG_TYPE;
- }
-
- @Override
- public ErrorObjListWithOpen getErrorObjListWithOpen() {
- return this.errObjListWithOpen;
- }
-
- @Override
- public void setErrorObjListWithOpen(ErrorObjListWithOpen errObjListWithOpen) {
- this.errObjListWithOpen = errObjListWithOpen;
- }
-
- @Override
- public PcepErrorInfo getPcepErrorInfo() {
- return this.errInfo;
- }
-
- @Override
- public void setPcepErrorInfo(PcepErrorInfo errInfo) {
- this.errInfo = errInfo;
- }
-
- /**
- * Return list of Error types.
- *
- * @return error types list
- */
- public List<Integer> getErrorType() {
- List<Integer> llErrorType = new LinkedList<>();
- if ((errObjListWithOpen != null)
- && (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
- llErrorType = errObjListWithOpen.getErrorType();
- } else if ((errInfo != null) && (errInfo.isErrorInfoPresent())) {
- llErrorType = errInfo.getErrorType();
- }
-
- return llErrorType;
- }
-
- /**
- * Return list of Error values.
- *
- * @return error value list
- */
- public List<Integer> getErrorValue() {
- List<Integer> llErrorValue = new LinkedList<>();
- if ((errObjListWithOpen != null)
- && (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
- llErrorValue = errObjListWithOpen.getErrorValue();
- } else if ((errInfo != null) && (errInfo.isErrorInfoPresent())) {
- llErrorValue = errInfo.getErrorValue();
- }
-
- return llErrorValue;
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()).omitNullValues();
-
- if ((errObjListWithOpen != null)
- && (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
- toStrHelper.add("ErrorObjectListWithOpen", errObjListWithOpen);
- }
- if ((errInfo != null) && (errInfo.isErrorInfoPresent())) {
- toStrHelper.add("ErrorInfo", errInfo);
- }
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorObjectVer1.java
deleted file mode 100644
index b6b0a42..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorObjectVer1.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepErrorObject;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP Error Object.
- */
-public class PcepErrorObjectVer1 implements PcepErrorObject {
-
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Object-Class | OT |Res|P|I| Object Length (bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Reserved | Flags | Error-Type | Error-value |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Optional TLVs //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
- private static final Logger log = LoggerFactory.getLogger(PcepErrorObjectVer1.class);
-
- public static final byte ERROR_OBJ_TYPE = 1;
- public static final byte ERROR_OBJ_CLASS = 13;
- public static final byte ERROR_OBJECT_VERSION = 1;
- //ERROR_OBJ_MINIMUM_LENGTH = CommonHeaderLen(4)+ErrorObjectHeaderLen(4)
- public static final short ERROR_OBJ_MINIMUM_LENGTH = 8;
- public static final int OBJECT_HEADER_LENGTH = 4;
-
- public static final PcepObjectHeader DEFAULT_ERROR_OBJECT_HEADER = new PcepObjectHeader(ERROR_OBJ_CLASS,
- ERROR_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
- ERROR_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader errorObjHeader;
- private byte errorType;
- private byte errorValue;
- private LinkedList<PcepValueType> optionalTlv; // Optional TLV
-
- /**
- * Constructor to initialize variables.
- *
- * @param errorObjHeader ERROR Object header
- * @param errorType Error Type
- * @param errorValue Error Value
- * @param optionalTlv list of optional TLV
- */
-
- public PcepErrorObjectVer1(PcepObjectHeader errorObjHeader, byte errorType, byte errorValue,
- LinkedList<PcepValueType> optionalTlv) {
- this.errorObjHeader = errorObjHeader;
- this.errorType = errorType;
- this.errorValue = errorValue;
- this.optionalTlv = optionalTlv;
- }
-
- /**
- * sets Object Header.
- *
- * @param obj Error-Object header
- */
- public void setLspObjHeader(PcepObjectHeader obj) {
- this.errorObjHeader = obj;
- }
-
- @Override
- public void setErrorType(byte errorType) {
- this.errorType = errorType;
- }
-
- @Override
- public void setErrorValue(byte errorValue) {
- this.errorValue = errorValue;
- }
-
- /**
- * returns object header.
- *
- * @return errorObjHeader Error-Object header
- */
- public PcepObjectHeader getErrorObjHeader() {
- return this.errorObjHeader;
- }
-
- @Override
- public int getErrorType() {
- return this.errorType;
- }
-
- @Override
- public byte getErrorValue() {
- return this.errorValue;
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.optionalTlv;
- }
-
- @Override
- public void setOptionalTlv(LinkedList<PcepValueType> optionalTlv) {
- this.optionalTlv = optionalTlv;
- }
-
- /**
- * Reads from channel buffer and returns object of PcepErrorObject.
- *
- * @param cb of channel buffer.
- * @return object of PCEP-ERROR-OBJECT
- */
- public static PcepErrorObject read(ChannelBuffer cb) {
-
- PcepObjectHeader errorObjHeader;
- byte errorType;
- byte errorValue;
- LinkedList<PcepValueType> optionalTlv;
-
- errorObjHeader = PcepObjectHeader.read(cb);
-
- //take only ErrorObject buffer.
- ChannelBuffer tempCb = cb.readBytes(errorObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
- tempCb.readByte(); //ignore Reserved
- tempCb.readByte(); //ignore Flags
- errorType = tempCb.readByte();
- errorValue = tempCb.readByte();
-
- optionalTlv = parseOptionalTlv(tempCb);
-
- return new PcepErrorObjectVer1(errorObjHeader, errorType, errorValue, optionalTlv);
- }
-
- /**
- * returns Linked list of optional tlvs.
- *
- * @param cb channel buffer.
- * @return Linked list of optional tlvs
- */
- protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) {
-
- LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<>();
-
- byte[] yTemp = new byte[cb.readableBytes()];
- cb.readBytes(yTemp);
-
- return llOutOptionalTlv;
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- //write Object header
- int objStartIndex = cb.writerIndex();
-
- int objLenIndex = errorObjHeader.write(cb);
-
- if (objLenIndex <= 0) {
- throw new PcepParseException("While writing Error Object Header.");
- }
-
- //write Reserved
- cb.writeByte(0);
- //write Flags
- cb.writeByte(0);
- //write ErrorType and ErrorValue
- cb.writeByte(this.errorType);
- cb.writeByte(this.errorValue);
-
- // Add optional TLV
- packOptionalTlv(cb);
-
- //Update object length now
- int length = cb.writerIndex() - objStartIndex;
- //will be helpful during print().
- errorObjHeader.setObjLen((short) length);
- // As per RFC the length of object should be
- // multiples of 4
- int pad = length % 4;
- if (pad != 0) {
- pad = 4 - pad;
- for (int i = 0; i < pad; i++) {
- cb.writeByte((byte) 0);
- }
- length = length + pad;
- }
-
- cb.setShort(objLenIndex, (short) length);
- return length;
- }
-
- /**
- * Pack the Optional tlvs.
- *
- * @param cb channel buffer.
- * @return writer index.
- */
- protected int packOptionalTlv(ChannelBuffer cb) {
-
- ListIterator<PcepValueType> listIterator = optionalTlv.listIterator();
- int startIndex = cb.writerIndex();
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
-
- if (tlv == null) {
- log.debug("TLV is null from OptionalTlv list");
- continue;
- }
- tlv.write(cb);
- }
-
- return cb.writerIndex() - startIndex;
- }
-
- /**
- * Builder class for PCEP error object.
- */
- public static class Builder implements PcepErrorObject.Builder {
-
- private boolean bIsHeaderSet = false;
-
- private PcepObjectHeader errorObjHeader;
- private byte errorType;
- private byte errorValue;
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- private LinkedList<PcepValueType> optionalTlv = new LinkedList<>();
-
- @Override
- public PcepErrorObject build() {
-
- PcepObjectHeader errorObjHeader = this.bIsHeaderSet ? this.errorObjHeader : DEFAULT_ERROR_OBJECT_HEADER;
-
- if (bIsPFlagSet) {
- errorObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- errorObjHeader.setIFlag(bIFlag);
- }
-
- return new PcepErrorObjectVer1(errorObjHeader, errorType, errorValue, optionalTlv);
- }
-
- @Override
- public PcepObjectHeader getErrorObjHeader() {
- return this.errorObjHeader;
- }
-
- @Override
- public Builder setErrorObjHeader(PcepObjectHeader obj) {
- this.errorObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public int getErrorType() {
- return this.errorType;
- }
-
- @Override
- public Builder setErrorType(byte value) {
- this.errorType = value;
- return this;
- }
-
- @Override
- public byte getErrorValue() {
- return this.errorValue;
- }
-
- @Override
- public Builder setErrorValue(byte value) {
- this.errorValue = value;
- return this;
- }
-
- @Override
- public Builder setOptionalTlv(LinkedList<PcepValueType> optionalTlv) {
- this.optionalTlv = optionalTlv;
- return this;
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.optionalTlv;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("ObjectHeader", errorObjHeader).add("ErrorType", errorType)
- .add("ErrorValue", errorValue).add("OptionalTlv", optionalTlv).toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorVer1.java
deleted file mode 100644
index 7eb711c..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorVer1.java
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepError;
-import org.onosproject.pcepio.protocol.PcepErrorObject;
-import org.onosproject.pcepio.protocol.PcepRPObject;
-import org.onosproject.pcepio.protocol.PcepLSObject;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PcepError list which contains RP or LS objects.
- * Reference: draft-dhodylee-pce-pcep-ls-01, section 8.2.
- */
-public class PcepErrorVer1 implements PcepError {
-
- /*
- <error>::=[<request-id-list> | <ls-id-list>]
- <error-obj-list>
-
- <request-id-list>::=<RP>[<request-id-list>]
-
- <ls-id-list>::=<LS>[<ls-id-list>]
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepErrorVer1.class);
-
- private boolean isErroInfoSet;
- //PcepErrorObject list
- private List<PcepErrorObject> errObjList;
- //PcepRPObject list
- private List<PcepRPObject> rpObjList;
- //PcepLSObject list
- private List<PcepLSObject> lsObjList;
- private boolean isLSObjListSet;
-
- public static final int OBJECT_HEADER_LENGTH = 4;
-
- /**
- * Constructor to initialize variable.
- */
- public PcepErrorVer1() {
- this.rpObjList = null;
- this.lsObjList = null;
- this.errObjList = null;
- }
-
- /**
- * Constructor to initialize variable.
- *
- * @param rpObjList list of PcepRPObject
- * @param lsObjList list of PcepLSObject
- * @param errObjListObjList list of PcepErrorObject
- */
- public PcepErrorVer1(List<PcepRPObject> rpObjList, List<PcepLSObject> lsObjList,
- List<PcepErrorObject> errObjListObjList) {
- this.rpObjList = rpObjList;
- this.lsObjList = lsObjList;
- this.errObjList = errObjListObjList;
- }
-
- /**
- * Constructor to initialize PcepError.
- *
- * @param errObjList list of PcepErrorObject
- */
- public PcepErrorVer1(List<PcepErrorObject> errObjList) {
- this.rpObjList = null;
- this.lsObjList = null;
- this.errObjList = errObjList;
- }
-
- @Override
- public List<PcepRPObject> getRPObjList() {
- return this.rpObjList;
- }
-
- @Override
- public List<PcepLSObject> getLSObjList() {
- return this.lsObjList;
- }
-
- @Override
- public List<PcepErrorObject> getErrorObjList() {
- return this.errObjList;
- }
-
- /**
- * Parse RP List from the channel buffer.
- *
- * @param cb of type channel buffer
- * @throws PcepParseException if mandatory fields are missing
- */
- public void parseRPList(ChannelBuffer cb) throws PcepParseException {
- byte yObjClass;
- byte yObjType;
-
- rpObjList = new LinkedList<>();
-
- // caller should verify for RP object
- if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
- log.debug("Unable to find RP Object");
- return;
- }
-
- cb.markReaderIndex();
- PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
- yObjClass = tempObjHeader.getObjClass();
- yObjType = tempObjHeader.getObjType();
- PcepRPObject rpObj;
- while ((yObjClass == PcepRPObjectVer1.RP_OBJ_CLASS) && (yObjType == PcepRPObjectVer1.RP_OBJ_TYPE)) {
- rpObj = PcepRPObjectVer1.read(cb);
- rpObjList.add(rpObj);
-
- if (cb.readableBytes() > OBJECT_HEADER_LENGTH) {
- cb.markReaderIndex();
- tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
- yObjClass = tempObjHeader.getObjClass();
- yObjType = tempObjHeader.getObjType();
- } else {
- break;
- }
- }
- }
-
- /**
- * Parse LS List from the channel buffer.
- *
- * @param cb of type channel buffer
- * @throws PcepParseException if mandatory fields are missing
- */
- public void parseLSList(ChannelBuffer cb) throws PcepParseException {
- byte yObjClass;
- byte yObjType;
-
- lsObjList = new LinkedList<>();
-
- // caller should verify for LS object
- if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
- log.debug("Unable to find LS Object");
- return;
- }
-
- cb.markReaderIndex();
- PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
- yObjClass = tempObjHeader.getObjClass();
- yObjType = tempObjHeader.getObjType();
- PcepLSObject lsObj;
- while ((yObjClass == PcepLSObjectVer1.LS_OBJ_CLASS) && ((yObjType == PcepLSObjectVer1.LS_OBJ_TYPE_NODE_VALUE)
- || (yObjType == PcepLSObjectVer1.LS_OBJ_TYPE_LINK_VALUE))) {
- lsObj = PcepLSObjectVer1.read(cb);
- lsObjList.add(lsObj);
-
- if (cb.readableBytes() > OBJECT_HEADER_LENGTH) {
- cb.markReaderIndex();
- tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
- yObjClass = tempObjHeader.getObjClass();
- yObjType = tempObjHeader.getObjType();
- } else {
- break;
- }
- }
- }
-
- /**
- * parseErrObjList from the channel buffer.
- *
- * @param cb of type channel buffer
- * @throws PcepParseException if mandatory fields are missing
- */
- public void parseErrObjList(ChannelBuffer cb) throws PcepParseException {
- byte yObjClass;
- byte yObjType;
- boolean bIsErrorObjFound = false;
-
- errObjList = new LinkedList<>();
-
- // caller should verify for RP object
- if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
- throw new PcepParseException("Unable to find PCEP-ERROR Object");
- }
-
- cb.markReaderIndex();
- PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
- yObjClass = tempObjHeader.getObjClass();
- yObjType = tempObjHeader.getObjType();
- PcepErrorObject errorObject;
- while ((yObjClass == PcepErrorObjectVer1.ERROR_OBJ_CLASS) && (yObjType == PcepErrorObjectVer1.ERROR_OBJ_TYPE)) {
- errorObject = PcepErrorObjectVer1.read(cb);
- errObjList.add(errorObject);
- bIsErrorObjFound = true;
-
- if (cb.readableBytes() > OBJECT_HEADER_LENGTH) {
- cb.markReaderIndex();
- tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
- yObjClass = tempObjHeader.getObjClass();
- yObjType = tempObjHeader.getObjType();
- } else {
- break;
- }
- }
-
- if (!bIsErrorObjFound) {
- throw new PcepParseException("At least one PCEP-ERROR Object should be present.");
- }
- }
-
- /**
- * Reads the byte stream of PcepError from channel buffer.
- *
- * @param cb of type channel buffer
- * @return PcepError error part of PCEP-ERROR
- * @throws PcepParseException if mandatory fields are missing
- */
- public static PcepErrorVer1 read(ChannelBuffer cb) throws PcepParseException {
- if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
- throw new PcepParseException("Unknown Object");
- }
-
- PcepErrorVer1 pcepError = new PcepErrorVer1();
- // check whether any PCEP Error Info is present
- cb.markReaderIndex();
- PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
- byte yObjClass = tempObjHeader.getObjClass();
-
- //If RPlist present then store it.RPList and LSList are optional
- if (yObjClass == PcepRPObjectVer1.RP_OBJ_CLASS) {
- log.debug("RP_LIST");
- pcepError.parseRPList(cb);
- yObjClass = checkNextObject(cb);
- } else if (yObjClass == PcepLSObjectVer1.LS_OBJ_CLASS) {
- log.debug("LS_LIST");
- pcepError.parseLSList(cb);
- yObjClass = checkNextObject(cb);
- }
-
- if (yObjClass == PcepErrorObjectVer1.ERROR_OBJ_CLASS) {
- log.debug("PCEP-ERROR obj list");
- pcepError.parseErrObjList(cb);
- yObjClass = checkNextObject(cb);
- }
-
- return pcepError;
- }
-
- /**
- * Checks Next Object.
- *
- * @param cb of type channel buffer.
- * @return object type class.
- */
- private static byte checkNextObject(ChannelBuffer cb) {
- if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
- return 0;
- }
- cb.markReaderIndex();
- PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
- return tempObjHeader.getObjClass();
- }
-
- /**
- * Writes the byte stream of PCEP error to the channel buffer.
- *
- * @param cb of type channel buffer
- * @return object length index
- * @throws PcepParseException if mandatory fields are missing
- */
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
- int iLenStartIndex = cb.writerIndex();
-
- // RPlist is optional
- if (this.isErroInfoSet) {
- ListIterator<PcepRPObject> rpObjlistIterator = this.rpObjList.listIterator();
- while (rpObjlistIterator.hasNext()) {
- rpObjlistIterator.next().write(cb);
- }
- }
-
- // LSlist is optional
- if (this.isLSObjListSet) {
- ListIterator<PcepLSObject> teObjlistIterator = this.lsObjList.listIterator();
- while (teObjlistIterator.hasNext()) {
- teObjlistIterator.next().write(cb);
- }
- }
- //ErrList is mandatory
- ListIterator<PcepErrorObject> errlistIterator = this.errObjList.listIterator();
- while (errlistIterator.hasNext()) {
- errlistIterator.next().write(cb);
- }
-
- return cb.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Builder for error part of PCEP-ERROR.
- */
- public static class Builder implements PcepError.Builder {
-
- private List<PcepRPObject> rpObjList;
- private List<PcepLSObject> lsObjList;
- private List<PcepErrorObject> errObjList;
-
- @Override
- public PcepError build() {
- return new PcepErrorVer1(rpObjList, lsObjList, errObjList);
- }
-
- @Override
- public List<PcepRPObject> getRPObjList() {
- return this.rpObjList;
- }
-
- @Override
- public Builder setRPObjList(List<PcepRPObject> rpObjList) {
- this.rpObjList = rpObjList;
- return this;
- }
-
- @Override
- public List<PcepLSObject> getLSObjList() {
- return this.lsObjList;
- }
-
- @Override
- public Builder setLSObjList(List<PcepLSObject> lsObjList) {
- this.lsObjList = lsObjList;
- return this;
- }
-
- @Override
- public List<PcepErrorObject> getErrorObjList() {
- return this.errObjList;
- }
-
- @Override
- public Builder setErrorObjList(List<PcepErrorObject> errObjList) {
- this.errObjList = errObjList;
- return this;
- }
-
- }
-
- @Override
- public void setRPObjList(List<PcepRPObject> rpObjList) {
- this.rpObjList = rpObjList;
- }
-
- @Override
- public void setLSObjList(List<PcepLSObject> lsObjList) {
- this.lsObjList = lsObjList;
- }
-
- @Override
- public void setErrorObjList(List<PcepErrorObject> errObjList) {
- this.errObjList = errObjList;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("RpObjectList", rpObjList)
- .add("LsObjectList", lsObjList)
- .add("ErrorObjectList", errObjList)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFactoryVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFactoryVer1.java
deleted file mode 100644
index ff3d1f3..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFactoryVer1.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
-import org.onosproject.pcepio.protocol.PcepAttribute;
-import org.onosproject.pcepio.protocol.PcepBandwidthObject;
-import org.onosproject.pcepio.protocol.PcepCloseMsg;
-import org.onosproject.pcepio.protocol.PcepEndPointsObject;
-import org.onosproject.pcepio.protocol.PcepEroObject;
-import org.onosproject.pcepio.protocol.PcepErrorInfo;
-import org.onosproject.pcepio.protocol.PcepError;
-import org.onosproject.pcepio.protocol.PcepErrorMsg;
-import org.onosproject.pcepio.protocol.PcepErrorObject;
-import org.onosproject.pcepio.protocol.PcepFactory;
-import org.onosproject.pcepio.protocol.PcepFecObjectIPv4.Builder;
-import org.onosproject.pcepio.protocol.PcepFecObjectIPv4Adjacency;
-import org.onosproject.pcepio.protocol.PcepInitiateMsg;
-import org.onosproject.pcepio.protocol.PcepIroObject;
-import org.onosproject.pcepio.protocol.PcepKeepaliveMsg;
-import org.onosproject.pcepio.protocol.PcepLabelObject;
-import org.onosproject.pcepio.protocol.PcepLabelRangeObject;
-import org.onosproject.pcepio.protocol.PcepLabelRangeResvMsg;
-import org.onosproject.pcepio.protocol.PcepLabelUpdate;
-import org.onosproject.pcepio.protocol.PcepLabelUpdateMsg;
-import org.onosproject.pcepio.protocol.PcepLspObject;
-import org.onosproject.pcepio.protocol.PcepLspaObject;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepMetricObject;
-import org.onosproject.pcepio.protocol.PcepMsgPath;
-import org.onosproject.pcepio.protocol.PcepOpenMsg;
-import org.onosproject.pcepio.protocol.PcepOpenObject;
-import org.onosproject.pcepio.protocol.PcepReportMsg;
-import org.onosproject.pcepio.protocol.PcepRroObject;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.onosproject.pcepio.protocol.PcepStateReport;
-import org.onosproject.pcepio.protocol.PcepUpdateMsg;
-import org.onosproject.pcepio.protocol.PcepUpdateRequest;
-import org.onosproject.pcepio.protocol.PcepVersion;
-
-/**
- * Provides PCEP Factory and returns builder classes for all objects and messages.
- */
-public class PcepFactoryVer1 implements PcepFactory {
-
- public static final PcepFactoryVer1 INSTANCE = new PcepFactoryVer1();
-
- @Override
- public PcepOpenMsg.Builder buildOpenMsg() {
- return new PcepOpenMsgVer1.Builder();
- }
-
- @Override
- public PcepOpenObject.Builder buildOpenObject() {
- return new PcepOpenObjectVer1.Builder();
- }
-
- @Override
- public PcepKeepaliveMsg.Builder buildKeepaliveMsg() {
- return new PcepKeepaliveMsgVer1.Builder();
- }
-
- @Override
- public PcepCloseMsg.Builder buildCloseMsg() {
- return new PcepCloseMsgVer1.Builder();
- }
-
- @Override
- public PcepUpdateMsg.Builder buildUpdateMsg() {
- return new PcepUpdateMsgVer1.Builder();
- }
-
- @Override
- public PcepReportMsg.Builder buildReportMsg() {
- return new PcepReportMsgVer1.Builder();
- }
-
- @Override
- public PcepInitiateMsg.Builder buildPcepInitiateMsg() {
- return new PcepInitiateMsgVer1.Builder();
- }
-
- @Override
- public PcepLspObject.Builder buildLspObject() {
- return new PcepLspObjectVer1.Builder();
- }
-
- @Override
- public PcepMessageReader<PcepMessage> getReader() {
- return PcepMessageVer1.READER;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepSrpObject.Builder buildSrpObject() {
- return new PcepSrpObjectVer1.Builder();
- }
-
- @Override
- public PcepEndPointsObject.Builder buildEndPointsObject() {
- return new PcepEndPointsObjectVer1.Builder();
- }
-
- @Override
- public PcepEroObject.Builder buildEroObject() {
- return new PcepEroObjectVer1.Builder();
- }
-
- @Override
- public PcepRroObject.Builder buildRroObject() {
- return new PcepRroObjectVer1.Builder();
- }
-
- @Override
- public PcepLspaObject.Builder buildLspaObject() {
- return new PcepLspaObjectVer1.Builder();
- }
-
- @Override
- public PcepIroObject.Builder buildIroObject() {
- return new PcepIroObjectVer1.Builder();
- }
-
- @Override
- public PcepMetricObject.Builder buildMetricObject() {
- return new PcepMetricObjectVer1.Builder();
- }
-
- @Override
- public PcepBandwidthObject.Builder buildBandwidthObject() {
- return new PcepBandwidthObjectVer1.Builder();
- }
-
- @Override
- public PcepMsgPath.Builder buildPcepMsgPath() {
- return new PcepMsgPathVer1.Builder();
- }
-
- @Override
- public PcepStateReport.Builder buildPcepStateReport() {
- return new PcepStateReportVer1.Builder();
- }
-
- @Override
- public PcepUpdateRequest.Builder buildPcepUpdateRequest() {
- return new PcepUpdateRequestVer1.Builder();
- }
-
- @Override
- public PcInitiatedLspRequest.Builder buildPcInitiatedLspRequest() {
- return new PcInitiatedLspRequestVer1.Builder();
- }
-
- @Override
- public PcepAttribute.Builder buildPcepAttribute() {
- return new PcepAttributeVer1.Builder();
- }
-
- @Override
- public PcepLabelUpdateMsg.Builder buildPcepLabelUpdateMsg() {
- return new PcepLabelUpdateMsgVer1.Builder();
- }
-
- @Override
- public PcepLabelUpdate.Builder buildPcepLabelUpdateObject() {
- return new PcepLabelUpdateVer1.Builder();
- }
-
- @Override
- public PcepLabelObject.Builder buildLabelObject() {
- return new PcepLabelObjectVer1.Builder();
- }
-
- @Override
- public PcepErrorMsg.Builder buildPcepErrorMsg() {
- return new PcepErrorMsgVer1.Builder();
- }
-
- @Override
- public PcepErrorObject.Builder buildPcepErrorObject() {
- return new PcepErrorObjectVer1.Builder();
- }
-
- @Override
- public PcepFecObjectIPv4Adjacency.Builder buildFecIpv4Adjacency() {
- return new PcepFecObjectIPv4AdjacencyVer1.Builder();
- }
-
- @Override
- public PcepErrorInfo.Builder buildPcepErrorInfo() {
- return new PcepErrorInfoVer1.Builder();
- }
-
- @Override
- public PcepError.Builder buildPcepError() {
- return new PcepErrorVer1.Builder();
- }
-
- @Override
- public PcepLabelRangeObject.Builder buildPcepLabelRangeObject() {
- return new PcepLabelRangeObjectVer1.Builder();
- }
-
- @Override
- public PcepLabelRangeResvMsg.Builder buildPcepLabelRangeResvMsg() {
- return new PcepLabelRangeResvMsgVer1.Builder();
- }
-
- @Override
- public Builder buildFecObjectIpv4() {
- return new PcepFecObjectIPv4Ver1.Builder();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4AdjacencyVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4AdjacencyVer1.java
deleted file mode 100644
index bde6596..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4AdjacencyVer1.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepFecObjectIPv4Adjacency;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP fec Object IPv4 Adjacency object.
- */
-public class PcepFecObjectIPv4AdjacencyVer1 implements PcepFecObjectIPv4Adjacency {
-
- /*
- * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5
- *
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Local IPv4 address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Remote IPv4 address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- FEC Object-Type is 3 IPv4 Adjacency
- */
- private static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv4AdjacencyVer1.class);
-
- public static final byte FEC_OBJ_TYPE = 3;
- public static final byte FEC_OBJ_CLASS = (byte) 226;
- public static final byte FEC_OBJECT_VERSION = 1;
- public static final short FEC_OBJ_MINIMUM_LENGTH = 12;
- public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
-
- public static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader fecObjHeader;
- private int localIPv4Address;
- private int remoteIPv4Address;
-
- /**
- * Constructor to initialize parameters for PCEP fec object .
- *
- * @param fecObjHeader FEC Object header
- * @param localIPv4Address Local IPv4 Address
- * @param remoteIPv4Address Remote IPv4 Address
- */
- public PcepFecObjectIPv4AdjacencyVer1(PcepObjectHeader fecObjHeader, int localIPv4Address, int remoteIPv4Address) {
- this.fecObjHeader = fecObjHeader;
- this.localIPv4Address = localIPv4Address;
- this.remoteIPv4Address = remoteIPv4Address;
- }
-
- /**
- * Sets Object header.
- *
- * @param obj Pcep fec Object Header
- */
- public void setFecIpv4ObjHeader(PcepObjectHeader obj) {
- this.fecObjHeader = obj;
- }
-
- @Override
- public int getLocalIPv4Address() {
- return this.localIPv4Address;
- }
-
- @Override
- public void seLocalIPv4Address(int value) {
- this.localIPv4Address = value;
- }
-
- @Override
- public int getRemoteIPv4Address() {
- return this.remoteIPv4Address;
- }
-
- @Override
- public void seRemoteIPv4Address(int value) {
- this.remoteIPv4Address = value;
- }
-
- /**
- * Reads from channel buffer and Returns object of PcepFecObjectIPv4Adjacency.
- *
- * @param cb of channel buffer.
- * @return object of PcepFecObjectIPv4Adjacency
- * @throws PcepParseException when fails to read from channel buffer
- */
- public static PcepFecObjectIPv4Adjacency read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader fecObjHeader;
- int localIPv4Address;
- int remoteIPv4Address;
-
- fecObjHeader = PcepObjectHeader.read(cb);
-
- //take only FEC IPv4 Adjacency Object buffer.
- ChannelBuffer tempCb = cb.readBytes(fecObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH);
- localIPv4Address = tempCb.readInt();
- remoteIPv4Address = tempCb.readInt();
-
- return new PcepFecObjectIPv4AdjacencyVer1(fecObjHeader, localIPv4Address, remoteIPv4Address);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- int objStartIndex = cb.writerIndex();
-
- //Write common header
- int objLenIndex = fecObjHeader.write(cb);
- cb.writeInt(localIPv4Address);
- cb.writeInt(remoteIPv4Address);
-
- //Now write FEC IPv4 Adjacency Object Length
- cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
- return cb.writerIndex();
- }
-
- /**
- * Builder class for PCEP fec object IPv4 Adjacency.
- */
- public static class Builder implements PcepFecObjectIPv4Adjacency.Builder {
- private boolean bIsHeaderSet = false;
- private boolean bIsLocalIPv4Addressset = false;
- private boolean bIsRemoteIPv4Addressset = false;
-
- private PcepObjectHeader fecObjHeader;
- int localIPv4Address;
- int remoteIPv4Address;
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepFecObjectIPv4Adjacency build() throws PcepParseException {
- PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER;
-
- if (!this.bIsLocalIPv4Addressset) {
- throw new PcepParseException(
- "Local IPv4 Address not set while building PcepFecObjectIPv4Adjacency object.");
- }
-
- if (!this.bIsRemoteIPv4Addressset) {
- throw new PcepParseException(
- " Remote IPv4 Address not set while building PcepFecObjectIPv4Adjacency object.");
- }
-
- if (bIsPFlagSet) {
- fecObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- fecObjHeader.setIFlag(bIFlag);
- }
- return new PcepFecObjectIPv4AdjacencyVer1(fecObjHeader, this.localIPv4Address, this.remoteIPv4Address);
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
-
- @Override
- public PcepObjectHeader getFecIpv4AdjacencyObjHeader() {
- return this.fecObjHeader;
- }
-
- @Override
- public Builder setFecIpv4AdjacencyObjHeader(PcepObjectHeader obj) {
- this.fecObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public int getLocalIPv4Address() {
- return this.localIPv4Address;
- }
-
- @Override
- public Builder seLocalIPv4Address(int value) {
- this.localIPv4Address = value;
- this.bIsLocalIPv4Addressset = true;
- return this;
- }
-
- @Override
- public int getRemoteIPv4Address() {
- return this.remoteIPv4Address;
- }
-
- @Override
- public Builder seRemoteIPv4Address(int value) {
- this.remoteIPv4Address = value;
- this.bIsRemoteIPv4Addressset = true;
- return this;
- }
-
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public int getType() {
- return FEC_OBJ_TYPE;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("fecObjHeader", fecObjHeader)
- .add("localIPv4Address", localIPv4Address)
- .add("remoteIPv4Address", remoteIPv4Address).toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4UnnumberedAdjacencyVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4UnnumberedAdjacencyVer1.java
deleted file mode 100644
index e66b2fd..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4UnnumberedAdjacencyVer1.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepFecObjectIPv4UnnumberedAdjacency;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Pcep Fec Object IPv4 Unnumbered Adjacency object.
- */
-public class PcepFecObjectIPv4UnnumberedAdjacencyVer1 implements PcepFecObjectIPv4UnnumberedAdjacency {
-
- /*
- * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5
- *
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Local Node-ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Local Interface ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Remote Node-ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Remote Interface ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- FEC Object-Type is 5, Unnumbered Adjacency with IPv4 NodeIDs
- */
- private static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv4UnnumberedAdjacencyVer1.class);
-
- public static final byte FEC_OBJ_TYPE = 5;
- public static final byte FEC_OBJ_CLASS = (byte) 226;
- public static final byte FEC_OBJECT_VERSION = 1;
- public static final short FEC_OBJ_MINIMUM_LENGTH = 20;
- public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
-
- static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader fecObjHeader;
- private int localNodeID;
- private int localInterfaceID;
- private int remoteNodeID;
- private int remoteInterfaceID;
-
- /**
- * Constructor to initialize parameter for PCEP fec object.
- *
- * @param fecObjHeader fec object header
- * @param localNodeID local node ID
- * @param localInterfaceID local interface ID
- * @param remoteNodeID remote node ID
- * @param remoteInterfaceID remote interface ID
- */
- public PcepFecObjectIPv4UnnumberedAdjacencyVer1(PcepObjectHeader fecObjHeader, int localNodeID,
- int localInterfaceID, int remoteNodeID, int remoteInterfaceID) {
- this.fecObjHeader = fecObjHeader;
- this.localNodeID = localNodeID;
- this.localInterfaceID = localInterfaceID;
- this.remoteNodeID = remoteNodeID;
- this.remoteInterfaceID = remoteInterfaceID;
- }
-
- /**
- * Sets Object Header.
- *
- * @param obj object header
- */
- public void setFecIpv4UnnumberedAdjacencyObjHeader(PcepObjectHeader obj) {
- this.fecObjHeader = obj;
- }
-
- @Override
- public void setLocalNodeID(int localNodeID) {
- this.localNodeID = localNodeID;
- }
-
- /**
- * Returns Object Header.
- *
- * @return fecObjHeader fec object header
- */
- public PcepObjectHeader getFecIpv4UnnumberedAdjacencyObjHeader() {
- return this.fecObjHeader;
- }
-
- @Override
- public int getLocalNodeID() {
- return this.localNodeID;
- }
-
- @Override
- public int getLocalInterfaceID() {
- return this.localInterfaceID;
- }
-
- @Override
- public void setLocalInterfaceID(int localInterfaceID) {
- this.localInterfaceID = localInterfaceID;
- }
-
- @Override
- public int getRemoteNodeID() {
- return this.remoteNodeID;
- }
-
- @Override
- public void setRemoteNodeID(int remoteNodeID) {
- this.remoteNodeID = remoteNodeID;
- }
-
- @Override
- public int getRemoteInterfaceID() {
- return this.remoteInterfaceID;
- }
-
- @Override
- public void setRemoteInterfaceID(int remoteInterfaceID) {
- this.remoteInterfaceID = remoteInterfaceID;
- }
-
- /**
- * Reads from channel buffer and returns object of PcepFecObjectIPv4UnnumberedAdjacency.
- *
- * @param cb of channel buffer
- * @return object of PcepFecObjectIPv4UnnumberedAdjacency
- * @throws PcepParseException when fails to read from channel buffer
- */
- public static PcepFecObjectIPv4UnnumberedAdjacency read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader fecObjHeader;
- int localNodeID;
- int localInterfaceID;
- int remoteNodeID;
- int remoteInterfaceID;
-
- fecObjHeader = PcepObjectHeader.read(cb);
-
- //take only FEC IPv4 Unnumbered Adjacency Object buffer.
- ChannelBuffer tempCb = cb.readBytes(fecObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH);
- localNodeID = tempCb.readInt();
- localInterfaceID = tempCb.readInt();
- remoteNodeID = tempCb.readInt();
- remoteInterfaceID = tempCb.readInt();
-
- return new PcepFecObjectIPv4UnnumberedAdjacencyVer1(fecObjHeader, localNodeID, localInterfaceID, remoteNodeID,
- remoteInterfaceID);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- int objStartIndex = cb.writerIndex();
-
- //Write common header
- int objLenIndex = fecObjHeader.write(cb);
- cb.writeInt(localNodeID);
- cb.writeInt(localInterfaceID);
- cb.writeInt(remoteNodeID);
- cb.writeInt(remoteInterfaceID);
-
- //Now write FEC IPv4 Unnumbered Adjacency Object Length
- cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
-
- return cb.writerIndex();
- }
-
- /**
- * Builder class for PCEP Fec object IPv4 unnumbered Adjacency.
- */
- public static class Builder implements PcepFecObjectIPv4UnnumberedAdjacency.Builder {
- private boolean bIsHeaderSet = false;
- private boolean bIsLocalNodeIDset = false;
- private boolean bIsLocalInterfaceIDset = false;
- private boolean bIsRemoteNodeIDset = false;
- private boolean bIsRemoteInterfaceIDset = false;
-
- private PcepObjectHeader fecObjHeader;
- private int localNodeID;
- private int localInterfaceID;
- private int remoteNodeID;
- private int remoteInterfaceID;
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepFecObjectIPv4UnnumberedAdjacency build() throws PcepParseException {
- PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER;
-
- if (!this.bIsLocalNodeIDset) {
- throw new PcepParseException(
- " Local Node ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object.");
- }
- if (!this.bIsLocalInterfaceIDset) {
- throw new PcepParseException(
- " Local Interface ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object.");
- }
- if (!this.bIsRemoteNodeIDset) {
- throw new PcepParseException(
- " Remote Node ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object.");
- }
- if (!this.bIsRemoteInterfaceIDset) {
- throw new PcepParseException(
- " Remote Interface ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object.");
- }
- if (bIsPFlagSet) {
- fecObjHeader.setPFlag(bPFlag);
- }
- if (bIsIFlagSet) {
- fecObjHeader.setIFlag(bIFlag);
- }
- return new PcepFecObjectIPv4UnnumberedAdjacencyVer1(fecObjHeader, this.localNodeID, this.localInterfaceID,
- this.remoteNodeID, this.remoteInterfaceID);
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
-
- @Override
- public PcepObjectHeader getFecIpv4UnnumberedAdjacencyObjHeader() {
- return this.fecObjHeader;
- }
-
- @Override
- public Builder setFecIpv4UnnumberedAdjacencyObjHeader(PcepObjectHeader obj) {
- this.fecObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public int getLocalNodeID() {
- return this.localNodeID;
- }
-
- @Override
- public Builder setLocalNodeID(int value) {
- this.localNodeID = value;
- this.bIsLocalNodeIDset = true;
- return this;
- }
-
- @Override
- public int getLocalInterfaceID() {
- return this.localInterfaceID;
- }
-
- @Override
- public Builder setLocalInterfaceID(int value) {
- this.localInterfaceID = value;
- this.bIsLocalInterfaceIDset = true;
- return this;
- }
-
- @Override
- public int getRemoteNodeID() {
- return this.remoteNodeID;
- }
-
- @Override
- public Builder setRemoteNodeID(int value) {
- this.remoteNodeID = value;
- this.bIsRemoteNodeIDset = true;
- return this;
- }
-
- @Override
- public int getRemoteInterfaceID() {
- return this.remoteInterfaceID;
- }
-
- @Override
- public Builder setRemoteInterfaceID(int value) {
- this.remoteInterfaceID = value;
- this.bIsRemoteInterfaceIDset = true;
- return this;
- }
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public int getType() {
- return FEC_OBJ_TYPE;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("LocalNodeID: ", localNodeID)
- .add("LocalInterfaceID: ", localInterfaceID).add("RemoteNodeID: ", remoteNodeID)
- .add("RemoteInterfaceID: ", remoteInterfaceID).toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4Ver1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4Ver1.java
deleted file mode 100644
index 63265f6..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4Ver1.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepFecObjectIPv4;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Pcep Fec Object IPv4 object.
- */
-public class PcepFecObjectIPv4Ver1 implements PcepFecObjectIPv4 {
-
- /*
- * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5
- *
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv4 Node ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- FEC Object-Type is 1 IPv4 Node ID
- */
- private static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv4Ver1.class);
-
- public static final byte FEC_OBJ_TYPE = 1;
- public static final byte FEC_OBJ_CLASS = (byte) 226;
- public static final byte FEC_OBJECT_VERSION = 1;
- public static final short FEC_OBJ_MINIMUM_LENGTH = 8;
- public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
-
- static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader fecObjHeader;
- private int nodeID;
-
- /**
- * Constructor to initialize parameters for PCEP fec object.
- *
- * @param fecObjHeader fec object header
- * @param nodeID node id
- */
- public PcepFecObjectIPv4Ver1(PcepObjectHeader fecObjHeader, int nodeID) {
- this.fecObjHeader = fecObjHeader;
- this.nodeID = nodeID;
- }
-
- /**
- * Sets the Object Header.
- *
- * @param obj object header
- */
- public void setFecIpv4ObjHeader(PcepObjectHeader obj) {
- this.fecObjHeader = obj;
- }
-
- @Override
- public void setNodeID(int nodeID) {
- this.nodeID = nodeID;
- }
-
- /**
- * Returns Object Header.
- *
- * @return fecObjHeader fec object header
- */
- public PcepObjectHeader getFecIpv4ObjHeader() {
- return this.fecObjHeader;
- }
-
- @Override
- public int getNodeID() {
- return this.nodeID;
- }
-
- /**
- * Reads from channel buffer and returns object of PcepFecObjectIPv4.
- *
- * @param cb of channel buffer
- * @return object of PcepFecObjectIPv4
- * @throws PcepParseException when fails to read from channel buffer
- */
- public static PcepFecObjectIPv4 read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader fecObjHeader;
- int nodeID;
- fecObjHeader = PcepObjectHeader.read(cb);
- nodeID = cb.readInt();
- return new PcepFecObjectIPv4Ver1(fecObjHeader, nodeID);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- int objStartIndex = cb.writerIndex();
-
- //write common header
- int objLenIndex = fecObjHeader.write(cb);
- cb.writeInt(nodeID);
-
- //now write FEC IPv4 Object Length
- cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
- return cb.writerIndex();
- }
-
- /**
- * Builder class for PCEP fec pobject IPv4.
- */
- public static class Builder implements PcepFecObjectIPv4.Builder {
- private boolean bIsHeaderSet = false;
- private boolean bIsNodeIdset = false;
-
- private PcepObjectHeader fecObjHeader;
- private int nodeID;
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepFecObjectIPv4 build() throws PcepParseException {
- PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER;
-
- if (!this.bIsNodeIdset) {
- throw new PcepParseException("NodeID not set while building PcepFecObjectIPv4 object.");
- }
- if (bIsPFlagSet) {
- fecObjHeader.setPFlag(bPFlag);
- }
- if (bIsIFlagSet) {
- fecObjHeader.setIFlag(bIFlag);
- }
- return new PcepFecObjectIPv4Ver1(fecObjHeader, this.nodeID);
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
-
- @Override
- public PcepObjectHeader getFecIpv4ObjHeader() {
- return this.fecObjHeader;
- }
-
- @Override
- public Builder setFecIpv4ObjHeader(PcepObjectHeader obj) {
- this.fecObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public int getNodeID() {
- return this.nodeID;
- }
-
- @Override
- public Builder setNodeID(int value) {
- this.nodeID = value;
- this.bIsNodeIdset = true;
- return this;
- }
-
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public int getType() {
- return FEC_OBJ_TYPE;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("fecObjHeader", fecObjHeader)
- .add("nodeID: ", nodeID)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6AdjacencyVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6AdjacencyVer1.java
deleted file mode 100644
index cd60d92..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6AdjacencyVer1.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepFecObjectIPv6Adjacency;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Pcep Fec Object IPv6 Adjacency object.
- */
-public class PcepFecObjectIPv6AdjacencyVer1 implements PcepFecObjectIPv6Adjacency {
-
- /*
- * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5
- *
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Local IPv6 address (16 bytes) //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Remote IPv6 address (16 bytes) //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- FEC Object-Type is 4 IPv6 Adjacency
- */
- private static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv6AdjacencyVer1.class);
-
- public static final byte FEC_OBJ_TYPE = 4;
- public static final byte FEC_OBJ_CLASS = (byte) 226;
- public static final byte FEC_OBJECT_VERSION = 1;
- public static final short FEC_OBJ_MINIMUM_LENGTH = 36;
- public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
- public static final int IPV6_ADDRESS_LENGTH = 16;
-
- static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader fecObjHeader;
- private byte[] localIPv6Address = new byte[IPV6_ADDRESS_LENGTH];
- private byte[] remoteIPv6Address = new byte[IPV6_ADDRESS_LENGTH];
-
- /**
- * Constructor to initialize parameters for PCEP fec object.
- *
- * @param fecObjHeader fec object header
- * @param localIPv6Address local IPv6 address
- * @param remoteIPv6Address remote IPv6 address
- */
- public PcepFecObjectIPv6AdjacencyVer1(PcepObjectHeader fecObjHeader, byte[] localIPv6Address,
- byte[] remoteIPv6Address) {
- this.fecObjHeader = fecObjHeader;
- this.localIPv6Address = localIPv6Address;
- this.remoteIPv6Address = remoteIPv6Address;
- }
-
- /**
- * Sets Object Header.
- *
- * @param obj object header
- */
- public void setFecIpv4ObjHeader(PcepObjectHeader obj) {
- this.fecObjHeader = obj;
- }
-
- @Override
- public byte[] getLocalIPv6Address() {
- return this.localIPv6Address;
- }
-
- @Override
- public void seLocalIPv6Address(byte[] value) {
- this.localIPv6Address = value;
- }
-
- @Override
- public byte[] getRemoteIPv6Address() {
- return this.remoteIPv6Address;
- }
-
- @Override
- public void seRemoteIPv6Address(byte[] value) {
- this.remoteIPv6Address = value;
- }
-
- /**
- * Reads channel buffer and Returns object of PcepFecObjectIPv6Adjacency.
- *
- * @param cb of channel buffer
- * @return object of PcepFecObjectIPv6Adjacency
- * @throws PcepParseException when fails tp read from channel buffer
- */
- public static PcepFecObjectIPv6Adjacency read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader fecObjHeader;
- byte[] localIPv6Address = new byte[IPV6_ADDRESS_LENGTH];
- byte[] remoteIPv6Address = new byte[IPV6_ADDRESS_LENGTH];
- fecObjHeader = PcepObjectHeader.read(cb);
- cb.readBytes(localIPv6Address, 0, IPV6_ADDRESS_LENGTH);
- cb.readBytes(remoteIPv6Address, 0, IPV6_ADDRESS_LENGTH);
- return new PcepFecObjectIPv6AdjacencyVer1(fecObjHeader, localIPv6Address, remoteIPv6Address);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- int objStartIndex = cb.writerIndex();
-
- //write common header
- int objLenIndex = fecObjHeader.write(cb);
- cb.writeBytes(localIPv6Address);
- cb.writeBytes(remoteIPv6Address);
- //now write FEC IPv6 Adjacency Object Length
- cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
- return cb.writerIndex();
- }
-
- /**
- * Builder class for PCEP fec object IPv6 Adjacency.
- */
- public static class Builder implements PcepFecObjectIPv6Adjacency.Builder {
- private boolean bIsHeaderSet = false;
- private boolean bIsLocalIPv6Addressset = false;
- private boolean bIsRemoteIPv6Addressset = false;
-
- private PcepObjectHeader fecObjHeader;
- byte[] localIPv6Address = new byte[IPV6_ADDRESS_LENGTH];
- byte[] remoteIPv6Address = new byte[IPV6_ADDRESS_LENGTH];
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepFecObjectIPv6Adjacency build() throws PcepParseException {
- PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER;
-
- if (!this.bIsLocalIPv6Addressset) {
- throw new PcepParseException(
- "Local IPv6 Address not set while building PcepFecObjectIPv6Adjacency object.");
- }
- if (!this.bIsRemoteIPv6Addressset) {
- throw new PcepParseException(
- "Remote IPv6 Address not set while building PcepFecObjectIPv6Adjacency object.");
- }
- if (bIsPFlagSet) {
- fecObjHeader.setPFlag(bPFlag);
- }
- if (bIsIFlagSet) {
- fecObjHeader.setIFlag(bIFlag);
- }
- return new PcepFecObjectIPv6AdjacencyVer1(fecObjHeader, this.localIPv6Address, this.remoteIPv6Address);
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
-
- @Override
- public PcepObjectHeader getFecIpv6AdjacencyObjHeader() {
- return this.fecObjHeader;
- }
-
- @Override
- public Builder setFecIpv6AdjacencyObjHeader(PcepObjectHeader obj) {
- this.fecObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public byte[] getLocalIPv6Address() {
- return this.localIPv6Address;
- }
-
- @Override
- public Builder setLocalIPv6Address(byte[] value) {
- this.localIPv6Address = value;
- this.bIsLocalIPv6Addressset = true;
- return this;
- }
-
- @Override
- public byte[] getRemoteIPv6Address() {
- return this.remoteIPv6Address;
- }
-
- @Override
- public Builder setRemoteIPv6Address(byte[] value) {
- this.remoteIPv6Address = value;
- this.bIsRemoteIPv6Addressset = true;
- return this;
- }
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public int getType() {
- return FEC_OBJ_TYPE;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("localIPv6Address", localIPv6Address)
- .add("remoteIPv6Address: ", remoteIPv6Address)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6Ver1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6Ver1.java
deleted file mode 100644
index 1975b04..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6Ver1.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepFecObjectIPv6;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Pcep Fec Object IPv6 object.
- */
-public class PcepFecObjectIPv6Ver1 implements PcepFecObjectIPv6 {
-
- /*
- * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5
- *
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // IPv6 Node ID (16 bytes) //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- FEC Object-Type is 2 IPv6 Node ID
- */
- private static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv6Ver1.class);
-
- public static final byte FEC_OBJ_TYPE = 2;
- public static final byte FEC_OBJ_CLASS = (byte) 226;
- public static final byte FEC_OBJECT_VERSION = 1;
- public static final short FEC_OBJ_MINIMUM_LENGTH = 20;
- public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
- public static final int IPV6_ADDRESS_LENGTH = 16;
-
- static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader fecObjHeader;
- private byte[] nodeID = new byte[IPV6_ADDRESS_LENGTH];
-
- /**
- * Constructor to initialize parameters for PCEP fec object.
- *
- * @param fecObjHeader Fec object header
- * @param nodeID node ID
- */
- public PcepFecObjectIPv6Ver1(PcepObjectHeader fecObjHeader, byte[] nodeID) {
- this.fecObjHeader = fecObjHeader;
- this.nodeID = nodeID;
- }
-
- /**
- * Sets the Object header.
- *
- * @param obj object header
- */
- public void setFecIpv6ObjHeader(PcepObjectHeader obj) {
- this.fecObjHeader = obj;
- }
-
- @Override
- public void setNodeID(byte[] nodeID) {
- this.nodeID = nodeID;
- }
-
- /**
- * Returns object header.
- *
- * @return fec Object Header
- */
- public PcepObjectHeader getFecIpv6ObjHeader() {
- return this.fecObjHeader;
- }
-
- @Override
- public byte[] getNodeID() {
- return this.nodeID;
- }
-
- /**
- * reads the channel buffer and returns object of PcepFecObjectIPv6.
- *
- * @param cb of channel buffer.
- * @return object of PcepFecObjectIPv6
- * @throws PcepParseException when fails to read from channel buffer
- */
- public static PcepFecObjectIPv6 read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader fecObjHeader;
- byte[] nodeID = new byte[IPV6_ADDRESS_LENGTH];
- fecObjHeader = PcepObjectHeader.read(cb);
- cb.readBytes(nodeID, 0, IPV6_ADDRESS_LENGTH);
- return new PcepFecObjectIPv6Ver1(fecObjHeader, nodeID);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- int objStartIndex = cb.writerIndex();
-
- //write common header
- int objLenIndex = fecObjHeader.write(cb);
- cb.writeBytes(nodeID);
-
- //now write FEC IPv4 Object Length
- cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
- return cb.writerIndex();
- }
-
- /**
- * Builder class for PCEP fec object IPv6.
- */
- public static class Builder implements PcepFecObjectIPv6.Builder {
- private boolean bIsHeaderSet = false;
- private boolean bIsNodeIdset = false;
-
- private PcepObjectHeader fecObjHeader;
- private byte[] nodeID = new byte[IPV6_ADDRESS_LENGTH];
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepFecObjectIPv6 build() throws PcepParseException {
- PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER;
-
- if (!this.bIsNodeIdset) {
- throw new PcepParseException(" NodeID not set while building PcepFecObjectIPv6 object.");
- }
- if (bIsPFlagSet) {
- fecObjHeader.setPFlag(bPFlag);
- }
- if (bIsIFlagSet) {
- fecObjHeader.setIFlag(bIFlag);
- }
- return new PcepFecObjectIPv6Ver1(fecObjHeader, this.nodeID);
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
-
- @Override
- public PcepObjectHeader getFecIpv6ObjHeader() {
- return this.fecObjHeader;
- }
-
- @Override
- public Builder setFecIpv6ObjHeader(PcepObjectHeader obj) {
- this.fecObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public byte[] getNodeID() {
- return this.nodeID;
- }
-
- @Override
- public Builder setNodeID(byte[] value) {
- this.nodeID = value;
- this.bIsNodeIdset = true;
- return this;
- }
-
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public int getType() {
- return FEC_OBJ_TYPE;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("fecObjHeader", fecObjHeader)
- .add("NodeID: ", nodeID)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInitiateMsgVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInitiateMsgVer1.java
deleted file mode 100644
index f50a8d4..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInitiateMsgVer1.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
-import org.onosproject.pcepio.protocol.PcepAttribute;
-import org.onosproject.pcepio.protocol.PcepEndPointsObject;
-import org.onosproject.pcepio.protocol.PcepEroObject;
-import org.onosproject.pcepio.protocol.PcepInitiateMsg;
-import org.onosproject.pcepio.protocol.PcepLspObject;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepMessageWriter;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.onosproject.pcepio.protocol.PcepType;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP initiate message.
- */
-class PcepInitiateMsgVer1 implements PcepInitiateMsg {
-
- private static final Logger log = LoggerFactory.getLogger(PcepInitiateMsgVer1.class);
-
- // Ref : PCE initiated tunnel setup draft-ietf-pce-pce-initiated-lsp-03, section 5.1
- /* <PCInitiate Message> ::= <Common Header>
- * <PCE-initiated-lsp-list>
- * Where:
- * <PCE-initiated-lsp-list> ::= <PCE-initiated-lsp-request>[<PCE-initiated-lsp-list>]
- * <PCE-initiated-lsp-request> ::= (<PCE-initiated-lsp-instantiation>|<PCE-initiated-lsp-deletion>)
- * <PCE-initiated-lsp-instantiation> ::= <SRP>
- * <LSP>
- * <END-POINTS>
- * <ERO>
- * [<attribute-list>]
- * <PCE-initiated-lsp-deletion> ::= <SRP>
- * <LSP>
- */
-
- static final byte PACKET_VERSION = 1;
- /* considering LspDelete Request PcInitiate msg will contain
- * common header
- * srp object
- * lsp object
- * so min length for this can be
- * PACKET_MINIMUM_LENGTH = CommonHeaderLen(4)+SrpObjectMinLen(12)+LspObjectMinLen(8)
- */
- public static final short PACKET_MINIMUM_LENGTH = 24;
- public static final short MINIMUM_COMMON_HEADER_LENGTH = 4;
- public static final PcepType MSG_TYPE = PcepType.INITIATE;
- private LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList;
- public static final PcepInitiateMsgVer1.Reader READER = new Reader();
-
- /**
- * Reader class for reading of Pcep initiate message from channel buffer.
- */
- static class Reader implements PcepMessageReader<PcepInitiateMsg> {
-
- LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList;
-
- @Override
- public PcepInitiateMsg readFrom(ChannelBuffer cb) throws PcepParseException {
-
- if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
- return null;
- }
-
- llPcInitiatedLspRequestList = new LinkedList<>();
-
- byte version = cb.readByte();
- version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
- if (version != PACKET_VERSION) {
- throw new PcepParseException("Wrong version. Expected=PcepVersion.PCEP_1(1), received=" + version);
- }
- byte type = cb.readByte();
- if (type != MSG_TYPE.getType()) {
- throw new PcepParseException("Wrong type. Expected=PcepType.INITIATE(12), recived=" + type);
- }
- short length = cb.readShort();
-
- if (length < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Wrong length. Initiate message length expected to be >= "
- + PACKET_MINIMUM_LENGTH + ", but received=" + length);
- }
-
- log.debug("reading PcInitiate message of length " + length);
-
- // parse Start initiate/deletion list
- if (!parsePcInitiatedLspRequestList(cb)) {
- throw new PcepParseException("Parsing PCE-initiated-lsp-Request-list failed");
- }
-
- return new PcepInitiateMsgVer1(llPcInitiatedLspRequestList);
- }
-
- /**
- * To parse PcInitiatedLspRequestList from PcInitiate Message.
- *
- * @param cb of type channel buffer
- * @return true if parsing PcInitiatedLspRequestList is success, false otherwise
- * @throws PcepParseException while parsing from channel buffer
- */
- public boolean parsePcInitiatedLspRequestList(ChannelBuffer cb) throws PcepParseException {
-
- boolean isDelLspRequest = false;
-
- if (cb == null) {
- throw new PcepParseException("Channel buffer is empty");
- }
-
- while (0 < cb.readableBytes()) {
- PcInitiatedLspRequest pceInitLspReq = new PcInitiatedLspRequestVer1();
-
- //store SRP object
- PcepSrpObject srpObj;
- srpObj = PcepSrpObjectVer1.read(cb);
- pceInitLspReq.setSrpObject(srpObj);
- isDelLspRequest = srpObj.getRFlag();
-
- //store LSP object
- PcepLspObject lspObj;
- lspObj = PcepLspObjectVer1.read(cb);
- pceInitLspReq.setLspObject(lspObj);
-
- /* if R bit will be set then pcInitiate msg will contain only LSp and SRP objects
- * so if R bit is not set then we should read for Ero and EndPoint objects also.
- */
- if (!isDelLspRequest) {
-
- //store EndPoint object
- PcepEndPointsObject endPointObj;
- endPointObj = PcepEndPointsObjectVer1.read(cb);
- pceInitLspReq.setEndPointsObject(endPointObj);
-
- //store ERO object
- PcepEroObject eroObj;
- eroObj = PcepEroObjectVer1.read(cb);
- pceInitLspReq.setEroObject(eroObj);
-
- if (cb.readableBytes() > MINIMUM_COMMON_HEADER_LENGTH) {
- pceInitLspReq.setPcepAttribute(PcepAttributeVer1.read(cb));
- }
- }
- llPcInitiatedLspRequestList.add(pceInitLspReq);
- }
- return true;
- }
- }
-
- /**
- * Constructor to initialize PcInitiatedLspRequest.
- *
- * @param llPcInitiatedLspRequestList list of PcInitiatedLspRequest
- */
- PcepInitiateMsgVer1(LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList) {
-
- if (llPcInitiatedLspRequestList == null) {
- throw new NullPointerException("PcInitiatedLspRequestList cannot be null.");
- }
- this.llPcInitiatedLspRequestList = llPcInitiatedLspRequestList;
- }
-
- /**
- * Builder class for PCEP initiate message.
- */
- static class Builder implements PcepInitiateMsg.Builder {
-
- // Pcep initiate message fields
- LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList;
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return PcepType.INITIATE;
- }
-
- @Override
- public PcepInitiateMsg build() {
- return new PcepInitiateMsgVer1(this.llPcInitiatedLspRequestList);
- }
-
- @Override
- public LinkedList<PcInitiatedLspRequest> getPcInitiatedLspRequestList() {
- return this.llPcInitiatedLspRequestList;
- }
-
- @Override
- public Builder setPcInitiatedLspRequestList(LinkedList<PcInitiatedLspRequest> ll) {
- this.llPcInitiatedLspRequestList = ll;
- return this;
- }
- }
-
- @Override
- public void writeTo(ChannelBuffer cb) throws PcepParseException {
- WRITER.write(cb, this);
- }
-
- static final Writer WRITER = new Writer();
-
- /**
- * Writer class for writing pcep initiate message to channel buffer.
- */
- static class Writer implements PcepMessageWriter<PcepInitiateMsgVer1> {
-
- @Override
- public void write(ChannelBuffer cb, PcepInitiateMsgVer1 message) throws PcepParseException {
-
- boolean isDelLspRequest = false;
- int startIndex = cb.writerIndex();
- // first 3 bits set to version
- cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
- // message type 0xC
- cb.writeByte(MSG_TYPE.getType());
- // length is length of variable message, will be updated at the end
- // Store the position of message
- // length in buffer
- int msgLenIndex = cb.writerIndex();
- cb.writeShort(0);
-
- ListIterator<PcInitiatedLspRequest> listIterator = message.llPcInitiatedLspRequestList.listIterator();
-
- while (listIterator.hasNext()) {
-
- PcInitiatedLspRequest listReq = listIterator.next();
-
- //Srp Object is mandatory
- PcepSrpObject srpObj = listReq.getSrpObject();
- if (srpObj != null) {
- isDelLspRequest = srpObj.getRFlag();
- srpObj.write(cb);
- } else {
- throw new PcepParseException("SRP Object is mandatory for PcInitiate message.");
- }
-
- //LSP Object is mandatory
- PcepLspObject lspObj = listReq.getLspObject();
- if (lspObj != null) {
- lspObj.write(cb);
- } else {
- throw new PcepParseException("LSP Object is mandatory for PcInitiate message.");
- }
-
- /* if R bit will be set then pcInitiate msg will contain only LSp and SRP objects
- * so if R bit is not set then we should read for Ero and EndPoint objects also.
- */
-
- if (!isDelLspRequest) {
-
- //EndPoints object is mandatory
- PcepEndPointsObject endPointObj = listReq.getEndPointsObject();
- if (endPointObj != null) {
- endPointObj.write(cb);
- } else {
- throw new PcepParseException("End points Object is mandatory for PcInitiate message.");
- }
-
- //Ero object is mandatory
- PcepEroObject eroObj = listReq.getEroObject();
- if (eroObj != null) {
- eroObj.write(cb);
- } else {
- throw new PcepParseException("ERO Object is mandatory for PcInitiate message.");
- }
-
- //PcepAttribute is optional
- PcepAttribute pcepAttribute = listReq.getPcepAttribute();
- if (pcepAttribute != null) {
- pcepAttribute.write(cb);
- }
- }
- }
-
- // PCInitiate message length field
- int length = cb.writerIndex() - startIndex;
- cb.setShort(msgLenIndex, (short) length);
- }
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return MSG_TYPE;
- }
-
- @Override
- public LinkedList<PcInitiatedLspRequest> getPcInitiatedLspRequestList() {
- return this.llPcInitiatedLspRequestList;
- }
-
- @Override
- public void setPcInitiatedLspRequestList(LinkedList<PcInitiatedLspRequest> ll) {
- this.llPcInitiatedLspRequestList = ll;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("PcInitiaitedLspRequestList", llPcInitiatedLspRequestList)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInterLayerObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInterLayerObjectVer1.java
deleted file mode 100644
index f88fa14..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInterLayerObjectVer1.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepInterLayerObject;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP inter layer object.
- */
-public class PcepInterLayerObjectVer1 implements PcepInterLayerObject {
-
- /*
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Reserved |N|I|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
- private static final Logger log = LoggerFactory.getLogger(PcepInterLayerObjectVer1.class);
-
- public static final byte INTER_LAYER_OBJ_TYPE = 1;
- public static final byte INTER_LAYER_OBJ_CLASS = 18;
- public static final byte INTER_LAYER_OBJECT_VERSION = 1;
- public static final short INTER_LAYER_OBJ_MINIMUM_LENGTH = 8;
- public static final boolean DEFAULT_IFLAG = false;
- public static final boolean DEFAULT_NFLAG = false;
- public static final int OBJECT_HEADER_LENGTH = 4;
- public static final int NFLAG_SHIFT_VALUE = 0x02;
- public static final int IFLAG_SHIFT_VALUE = 0x01;
-
- static final PcepObjectHeader DEFAULT_INTER_LAYER_OBJECT_HEADER = new PcepObjectHeader(INTER_LAYER_OBJ_CLASS,
- INTER_LAYER_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
- INTER_LAYER_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader interLayerObjHeader;
- private boolean bNFlag;
- private boolean bIFlag;
-
- /**
- * Constructor to initialize all parameters for Pcep Inter Layer Object.
- *
- * @param interLayerObjHeader inter layer object header
- * @param bNFlag N flag
- * @param bIFlag I flag
- */
- public PcepInterLayerObjectVer1(PcepObjectHeader interLayerObjHeader, boolean bNFlag, boolean bIFlag) {
-
- this.interLayerObjHeader = interLayerObjHeader;
- this.bNFlag = bNFlag;
- this.bIFlag = bIFlag;
- }
-
- /**
- * Sets Object Header.
- *
- * @param obj object header
- */
- public void setInterLayerObjHeader(PcepObjectHeader obj) {
- this.interLayerObjHeader = obj;
- }
-
- @Override
- public void setbNFlag(boolean bNFlag) {
- this.bNFlag = bNFlag;
- }
-
- @Override
- public void setbIFlag(boolean bIFlag) {
- this.bIFlag = bIFlag;
- }
-
- /**
- * Returns object header.
- *
- * @return inter Layer Object Header
- */
- public PcepObjectHeader getInterLayerObjHeader() {
- return this.interLayerObjHeader;
- }
-
- @Override
- public boolean getbNFlag() {
- return this.bNFlag;
- }
-
- @Override
- public boolean getbIFlag() {
- return this.bIFlag;
- }
-
- /**
- * Reads channel buffer and returns object of PcepInterLayerObject.
- *
- * @param cb of type channel buffer
- * @return object of PcepInterLayerObject
- * @throws PcepParseException when fails to read from channel buffer
- */
- public static PcepInterLayerObject read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader interLayerObjHeader;
- boolean bNFlag;
- boolean bIFlag;
-
- interLayerObjHeader = PcepObjectHeader.read(cb);
-
- //take only InterLayerObject buffer.
- ChannelBuffer tempCb = cb.readBytes(interLayerObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
-
- int iTemp = tempCb.readInt();
- bIFlag = ((iTemp & (byte) IFLAG_SHIFT_VALUE) == IFLAG_SHIFT_VALUE);
- bNFlag = ((iTemp & (byte) NFLAG_SHIFT_VALUE) == NFLAG_SHIFT_VALUE);
-
- return new PcepInterLayerObjectVer1(interLayerObjHeader, bNFlag, bIFlag);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- //write Object header
- int objStartIndex = cb.writerIndex();
-
- int objLenIndex = interLayerObjHeader.write(cb);
-
- if (objLenIndex <= 0) {
- throw new PcepParseException(" ObjectLength Index is " + objLenIndex);
- }
-
- int iTemp = 0;
-
- if (bIFlag) {
- iTemp = iTemp | (byte) IFLAG_SHIFT_VALUE;
- }
- if (bNFlag) {
- iTemp = iTemp | (byte) NFLAG_SHIFT_VALUE;
- }
-
- cb.writeInt(iTemp);
-
- //Update object length now
- int length = cb.writerIndex() - objStartIndex;
- //will be helpful during print().
- interLayerObjHeader.setObjLen((short) length);
- cb.setShort(objLenIndex, (short) length);
-
- objLenIndex = cb.writerIndex();
- return objLenIndex;
- }
-
- /**
- * Builder class for PCEP inter layer object.
- */
- public static class Builder implements PcepInterLayerObject.Builder {
-
- private boolean bIsHeaderSet = false;
- private boolean bIsNFlagset = false;
- private boolean bIsIFlagset = false;
-
- private PcepObjectHeader interLayerObjHeader;
- private boolean bNFlag;
- private boolean bIFlag;
-
- private boolean bIsPFlagSet = false;
- private boolean bPFalg;
-
- private boolean bIsIFlagSet = false;
- private boolean iFlag;
-
- @Override
- public PcepInterLayerObject build() {
- PcepObjectHeader interLayerObjHeader = this.bIsHeaderSet ? this.interLayerObjHeader
- : DEFAULT_INTER_LAYER_OBJECT_HEADER;
-
- boolean bNFlag = this.bIsNFlagset ? this.bNFlag : DEFAULT_NFLAG;
- boolean bIFlag = this.bIsIFlagset ? this.bIFlag : DEFAULT_IFLAG;
-
- if (bIsPFlagSet) {
- interLayerObjHeader.setPFlag(bPFalg);
- }
-
- if (bIsIFlagSet) {
- interLayerObjHeader.setIFlag(iFlag);
- }
- return new PcepInterLayerObjectVer1(interLayerObjHeader, bNFlag, bIFlag);
- }
-
- @Override
- public PcepObjectHeader getInterLayerObjHeader() {
- return this.interLayerObjHeader;
- }
-
- @Override
- public Builder setInterLayerObjHeader(PcepObjectHeader obj) {
- this.interLayerObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public boolean getbNFlag() {
- return this.bNFlag;
- }
-
- @Override
- public Builder setbNFlag(boolean value) {
- this.bNFlag = value;
- this.bIsNFlagset = true;
- return this;
- }
-
- @Override
- public boolean getbIFlag() {
- return this.bIFlag;
- }
-
- @Override
- public Builder setbIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagset = true;
- return this;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFalg = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.iFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("IFlag", bIFlag)
- .add("NFlag", bNFlag).toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepIroObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepIroObjectVer1.java
deleted file mode 100644
index 78df1a9..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepIroObjectVer1.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepIroObject;
-import org.onosproject.pcepio.types.IPv4SubObject;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP iro object.
- */
-public class PcepIroObjectVer1 implements PcepIroObject {
-
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // (Sub-objects) //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- The IRO Object format
-
- Each IPV4 suboject
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |L| Type | Length | IPv4 address (4 bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv4 address (continued) | Prefix Length | Resvd |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
- private static final Logger log = LoggerFactory.getLogger(PcepIroObjectVer1.class);
-
- public static final byte IRO_OBJ_TYPE = 1;
- public static final byte IRO_OBJ_CLASS = 10;
- public static final byte IRO_OBJECT_VERSION = 1;
- public static final short IRO_OBJ_MINIMUM_LENGTH = 12;
- public static final int OBJECT_HEADER_LENGTH = 4;
- public static final int YTYPE_SHIFT_VALUE = 0x7F;
-
- public static final PcepObjectHeader DEFAULT_IRO_OBJECT_HEADER = new PcepObjectHeader(IRO_OBJ_CLASS, IRO_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, IRO_OBJ_MINIMUM_LENGTH);
-
- private short iroObjType = 0;
- private byte yLength;
- private byte yPrefixLength;
- private byte yResvd;
- private PcepObjectHeader iroObjHeader;
- private LinkedList<PcepValueType> llSubObjects = new LinkedList<>();
-
- /**
- * Default constructor.
- */
- public PcepIroObjectVer1() {
- this.iroObjHeader = null;
- this.iroObjType = 0;
- this.yLength = 0;
- }
-
- /**
- * Constructor to initialize member variables.
- *
- * @param iroObjHeader IRO object header
- * @param llSubObjects list of sub-objects
- */
- public PcepIroObjectVer1(PcepObjectHeader iroObjHeader, LinkedList<PcepValueType> llSubObjects) {
- this.iroObjHeader = iroObjHeader;
- this.llSubObjects = llSubObjects;
- }
-
- /**
- * Returns object header.
- *
- * @return iroObjHeader IRO object header
- */
- public PcepObjectHeader getIroObjHeader() {
- return this.iroObjHeader;
- }
-
- /**
- * Sets IRO Object Header.
- *
- * @param obj IRO object header
- */
- public void setIroObjHeader(PcepObjectHeader obj) {
- this.iroObjHeader = obj;
- }
-
- @Override
- public LinkedList<PcepValueType> getSubObjects() {
- return this.llSubObjects;
- }
-
- @Override
- public void setSubObjects(LinkedList<PcepValueType> llSubObjects) {
- this.llSubObjects = llSubObjects;
- }
-
- /**
- * Reads from channel buffer and return object of PcepIroObject.
- *
- * @param cb of type channel buffer
- * @return object of PcepIroObject
- * @throws PcepParseException while parsing from channel buffer
- */
- public static PcepIroObject read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader iroObjHeader;
- LinkedList<PcepValueType> llSubObjects;
-
- iroObjHeader = PcepObjectHeader.read(cb);
-
- //take only IroObject buffer.
- ChannelBuffer tempCb = cb.readBytes(iroObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
- llSubObjects = parseSubObjects(tempCb);
- return new PcepIroObjectVer1(iroObjHeader, llSubObjects);
- }
-
- /**
- * Returns linked list of sub objects.
- *
- * @param cb of type channel buffer
- * @return linked list of sub objects
- * @throws PcepParseException while parsing subobjects from channel buffer
- */
- protected static LinkedList<PcepValueType> parseSubObjects(ChannelBuffer cb) throws PcepParseException {
-
- LinkedList<PcepValueType> llSubObjects = new LinkedList<>();
-
- while (0 < cb.readableBytes()) {
-
- //check the Type of the Subobjects.
- byte yType = cb.readByte();
- yType = (byte) (yType & (YTYPE_SHIFT_VALUE));
- byte hLength = cb.readByte();
-
- PcepValueType subObj;
- switch (yType) {
-
- case IPv4SubObject.TYPE:
- subObj = IPv4SubObject.read(cb);
- break;
-
- default:
- throw new PcepParseException("Invalid sub object. Type: " + (int) yType);
- }
-
- // Check for the padding
- int pad = hLength % 4;
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= cb.readableBytes()) {
- cb.skipBytes(pad);
- }
- }
- llSubObjects.add(subObj);
- }
- return llSubObjects;
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
- //write Object header
- int objStartIndex = cb.writerIndex();
-
- int objLenIndex = iroObjHeader.write(cb);
-
- if (objLenIndex <= 0) {
- throw new PcepParseException(" ObjectLength is " + objLenIndex);
- }
-
- ListIterator<PcepValueType> listIterator = llSubObjects.listIterator();
- while (listIterator.hasNext()) {
- listIterator.next().write(cb);
- }
-
- //Update object length now
- int length = cb.writerIndex() - objStartIndex;
- //will be helpful during print().
- iroObjHeader.setObjLen((short) length);
- // As per RFC the length of object should be
- // multiples of 4
- int pad = length % 4;
- if (pad != 0) {
- pad = 4 - pad;
- for (int i = 0; i < pad; i++) {
- cb.writeByte((byte) 0);
- }
- length = length + pad;
- }
- cb.setShort(objLenIndex, (short) length);
- objLenIndex = cb.writerIndex();
- return objLenIndex;
- }
-
- /**
- * Builder class for PCEP iro object.
- */
- public static class Builder implements PcepIroObject.Builder {
-
- private boolean bIsHeaderSet = false;
-
- private PcepObjectHeader iroObjHeader;
- LinkedList<PcepValueType> llSubObjects = new LinkedList<>();
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepIroObject build() {
-
- PcepObjectHeader iroObjHeader = this.bIsHeaderSet ? this.iroObjHeader : DEFAULT_IRO_OBJECT_HEADER;
-
- if (bIsPFlagSet) {
- iroObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- iroObjHeader.setIFlag(bIFlag);
- }
-
- return new PcepIroObjectVer1(iroObjHeader, this.llSubObjects);
- }
-
- @Override
- public PcepObjectHeader getIroObjHeader() {
- return this.iroObjHeader;
- }
-
- @Override
- public Builder setIroObjHeader(PcepObjectHeader obj) {
- this.iroObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public LinkedList<PcepValueType> getSubObjects() {
- return this.llSubObjects;
- }
-
- @Override
- public Builder setSubObjects(LinkedList<PcepValueType> llSubObjects) {
- this.llSubObjects = llSubObjects;
- return this;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("IroObjectHeader", iroObjHeader)
- .add("SubObjects", llSubObjects).toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepKeepaliveMsgVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepKeepaliveMsgVer1.java
deleted file mode 100644
index ff930a4..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepKeepaliveMsgVer1.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepKeepaliveMsg;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepMessageWriter;
-import org.onosproject.pcepio.protocol.PcepType;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP keep alive message.
- */
-class PcepKeepaliveMsgVer1 implements PcepKeepaliveMsg {
-
- /*
- <Keepalive Message>::= <Common Header>
-
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Ver | Flags | Message-Type | Message-Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepKeepaliveMsgVer1.class);
- // Pcep version: 1
- public static final byte PACKET_VERSION = 1;
- public static final int PACKET_MINIMUM_LENGTH = 4;
- public static final PcepType MSG_TYPE = PcepType.KEEP_ALIVE;
-
- public static final PcepKeepaliveMsgVer1.Reader READER = new Reader();
-
- /**
- * Reader class for reading PCEP keepalive message from channel buffer.
- */
- static class Reader implements PcepMessageReader<PcepKeepaliveMsg> {
-
- @Override
- public PcepKeepaliveMsg readFrom(ChannelBuffer cb) throws PcepParseException {
-
- if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Packet size is less than the minimum required length.");
- }
- // fixed value property version == 1
- byte version = cb.readByte();
- version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
- if (version != PACKET_VERSION) {
- throw new PcepParseException("Wrong version: Expected=PcepVersion.KEEP_ALIVE_1(2), got=" + version);
- }
- // fixed value property type == 2
- byte type = cb.readByte();
- if (type != MSG_TYPE.getType()) {
- throw new PcepParseException("Wrong type: Expected=PcepType.KEEP_ALIVE_1(2), got=" + type);
- }
- short length = cb.readShort();
- if (length < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Wrong length: Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: "
- + length);
- }
- return new PcepKeepaliveMsgVer1();
- }
- }
-
- /**
- * Default constructor.
- */
- PcepKeepaliveMsgVer1() {
- }
-
- /**
- * Builder class for PCEP keepalive message.
- */
- static class Builder implements PcepKeepaliveMsg.Builder {
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return PcepType.KEEP_ALIVE;
- }
-
- @Override
- public PcepKeepaliveMsg build() {
- return new PcepKeepaliveMsgVer1();
- }
- }
-
- @Override
- public void writeTo(ChannelBuffer cb) {
- WRITER.write(cb, this);
- }
-
- static final Writer WRITER = new Writer();
-
- /**
- * Writer class for writing the PCEP keepalive message to channel buffer.
- */
- static class Writer implements PcepMessageWriter<PcepKeepaliveMsgVer1> {
-
- @Override
- public void write(ChannelBuffer cb, PcepKeepaliveMsgVer1 message) {
- int startIndex = cb.writerIndex();
- // first 3 bits set to version
- cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
- // message type
- cb.writeByte(MSG_TYPE.getType());
- // length is length of variable message, will be updated at the end
- // Store the position of message
- // length in buffer
- int msgLenIndex = cb.writerIndex();
- cb.writeShort((short) 0);
- // update message length field
- int length = cb.writerIndex() - startIndex;
- cb.setShort(msgLenIndex, (short) length);
- }
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return MSG_TYPE;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLSObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLSObjectVer1.java
deleted file mode 100644
index f902cc6..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLSObjectVer1.java
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.List;
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepLSObject;
-import org.onosproject.pcepio.types.LocalNodeDescriptorsTlv;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.onosproject.pcepio.types.RemoteNodeDescriptorsTlv;
-import org.onosproject.pcepio.types.RoutingUniverseTlv;
-import org.onosproject.pcepio.types.LinkAttributesTlv;
-import org.onosproject.pcepio.types.LinkDescriptorsTlv;
-import org.onosproject.pcepio.types.NodeAttributesTlv;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP LS (link-state) object.
- */
-public class PcepLSObjectVer1 implements PcepLSObject {
- /*
- *
- reference: draft-dhodylee-pce-pcep-ls-01, section 9.2.
-
- Two Object-Type values are defined for the LS object:
-
- o LS Node: LS Object-Type is 1.
-
- o LS Link: LS Object-Type is 2.
-
- o LS IPv4 Topology Prefix: LS Object-Type is 3.
-
- o LS IPv6 Topology Prefix: LS Object-Type is 4.
-
- The format of the LS object body is as follows:
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Protocol-ID | Flag |R|S|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LS-ID |
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // TLVs //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepLSObjectVer1.class);
-
- public static final byte LS_OBJ_TYPE_NODE_VALUE = 1;
- public static final byte LS_OBJ_TYPE_LINK_VALUE = 2;
-
- public static final byte LS_OBJ_CLASS = (byte) 224;
- public static final byte LS_OBJECT_VERSION = 1;
-
- // LS_OBJ_MINIMUM_LENGTH = LSObjectHeaderLen(4) + LSObjectLen(8)
- public static final short LS_OBJ_MINIMUM_LENGTH = 12;
-
- // Signaled, all default values to be checked.
- public static final byte DEFAULT_PROTOCOL_ID = 1; //IS-IS Level 1
- public static final boolean DEFAULT_R_FLAG = false;
- public static final boolean DEFAULT_S_FLAG = false;
- public static final int DEFAULT_LS_ID = 0;
-
- public static final int OBJECT_HEADER_LENGTH = 4;
- public static final int RIGHT_SHIFT_ONE = 1;
- public static final int RIGHT_FIRST_FLAG = 0x1;
- public static final int FLAG_SET_R_FLAG = 0x2;
- public static final int FLAG_SET_S_FLAG = 0x1;
- public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
- public static final int MINIMUM_TLV_HEADER_LENGTH = 4;
-
- public static final PcepObjectHeader DEFAULT_LS_OBJECT_HEADER = new PcepObjectHeader(LS_OBJ_CLASS,
- LS_OBJ_TYPE_NODE_VALUE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
- LS_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader lsObjHeader;
- private byte protocolId;
- // 2-flags
- private boolean removeFlag;
- private boolean syncFlag;
- private long lsId; //link-state identifier
- // Optional TLV
- private List<PcepValueType> optionalTlvList;
-
- /**
- * Constructor to initialize variables.
- *
- * @param lsObjHeader LS Object header
- * @param protocolId Protocol-ID
- * @param removeFlag R-flag
- * @param syncFlag S-flag
- * @param lsId LS-ID
- * @param optionalTlvList linked list of Optional TLV
- */
- public PcepLSObjectVer1(PcepObjectHeader lsObjHeader, byte protocolId, boolean removeFlag,
- boolean syncFlag, long lsId, List<PcepValueType> optionalTlvList) {
-
- this.lsObjHeader = lsObjHeader;
- this.protocolId = protocolId;
- this.removeFlag = removeFlag;
- this.syncFlag = syncFlag;
- this.lsId = lsId;
- this.optionalTlvList = optionalTlvList;
- }
-
- @Override
- public PcepObjectHeader getLSObjHeader() {
- return this.lsObjHeader;
- }
-
- @Override
- public void setLSObjHeader(PcepObjectHeader obj) {
- this.lsObjHeader = obj;
- }
-
- @Override
- public byte getProtocolId() {
- return this.protocolId;
- }
-
- @Override
- public void setProtocolId(byte protId) {
- this.protocolId = protId;
- }
-
- @Override
- public boolean getRemoveFlag() {
- return this.removeFlag;
- }
-
- @Override
- public void setRemoveFlag(boolean removeFlag) {
- this.removeFlag = removeFlag;
- }
-
- @Override
- public boolean getSyncFlag() {
- return this.syncFlag;
- }
-
- @Override
- public void setSyncFlag(boolean syncFlag) {
- this.syncFlag = syncFlag;
- }
-
- @Override
- public long getLSId() {
- return this.lsId;
- }
-
- @Override
- public void setLSId(long lsId) {
- this.lsId = lsId;
- }
-
- @Override
- public List<PcepValueType> getOptionalTlv() {
- return this.optionalTlvList;
- }
-
- @Override
- public void setOptionalTlv(List<PcepValueType> optionalTlvList) {
- this.optionalTlvList = optionalTlvList;
- }
-
- /**
- * Reads from the channel buffer and returns Object of PcepLSObject.
- *
- * @param cb of type channel buffer
- * @return Object of PcepLSObject
- * @throws PcepParseException if mandatory fields are missing
- */
- public static PcepLSObject read(ChannelBuffer cb) throws PcepParseException {
- log.debug("read");
-
- PcepObjectHeader lsObjHeader;
- byte protocolId;
- // 2-flags
- boolean removeFlag;
- boolean syncFlag;
- long lsId;
- List<PcepValueType> optionalTlvList;
-
- lsObjHeader = PcepObjectHeader.read(cb);
-
- //take only LSObject buffer.
- ChannelBuffer tempCb = cb.readBytes(lsObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
-
- protocolId = tempCb.readByte();
- //ignore first two bytes of Flags
- tempCb.readShort();
-
- Integer iTemp = (int) tempCb.readByte(); //read 3rd byte Flag
- syncFlag = (iTemp & FLAG_SET_S_FLAG) == FLAG_SET_S_FLAG;
- removeFlag = (iTemp & FLAG_SET_R_FLAG) == FLAG_SET_R_FLAG;
-
- lsId = tempCb.readLong();
-
- // parse optional TLV
- optionalTlvList = parseOptionalTlv(tempCb);
-
- return new PcepLSObjectVer1(lsObjHeader, protocolId, removeFlag, syncFlag, lsId, optionalTlvList);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- //write Object header
- int objStartIndex = cb.writerIndex();
- int objLenIndex = lsObjHeader.write(cb);
-
- if (objLenIndex <= 0) {
- throw new PcepParseException("ObjectLength Index is " + objLenIndex);
- }
-
- //write Protocol ID
- cb.writeByte(this.protocolId);
-
- //write Flag
- cb.writeShort(0);
-
- byte bTemp = 0;
- if (syncFlag) {
- bTemp = FLAG_SET_S_FLAG;
- }
-
- if (removeFlag) {
- bTemp = (byte) (bTemp | FLAG_SET_R_FLAG);
- }
- cb.writeByte(bTemp);
-
- //write LSId
- cb.writeLong(lsId);
-
- // Add optional TLV
- packOptionalTlv(cb);
-
- //Update object length now
- int length = cb.writerIndex() - objStartIndex;
-
- //will be helpful during print().
- lsObjHeader.setObjLen((short) length);
-
- cb.setShort(objLenIndex, (short) length);
-
- return cb.writerIndex();
- }
-
- /**
- * Returns Linked list of PCEP Value Type.
- *
- * @param cb of channel buffer
- * @return Linked list of PCEP Value Type
- * @throws PcepParseException if mandatory fields are missing
- */
- protected static List<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
-
- List<PcepValueType> llOutOptionalTlv;
-
- llOutOptionalTlv = new LinkedList<>();
-
- while (MINIMUM_TLV_HEADER_LENGTH <= cb.readableBytes()) {
-
- PcepValueType tlv;
- short hType = cb.readShort();
- short hLength = cb.readShort();
- long lValue = 0;
-
- switch (hType) {
-
- case RoutingUniverseTlv.TYPE:
- lValue = cb.readLong();
- tlv = new RoutingUniverseTlv(lValue);
- break;
- case LocalNodeDescriptorsTlv.TYPE:
- tlv = LocalNodeDescriptorsTlv.read(cb, hLength);
- break;
- case RemoteNodeDescriptorsTlv.TYPE:
- tlv = RemoteNodeDescriptorsTlv.read(cb, hLength);
- break;
- case LinkDescriptorsTlv.TYPE:
- tlv = LinkDescriptorsTlv.read(cb, hLength);
- break;
- case NodeAttributesTlv.TYPE:
- tlv = NodeAttributesTlv.read(cb, hLength);
- break;
- case LinkAttributesTlv.TYPE:
- tlv = LinkAttributesTlv.read(cb, hLength);
- break;
- default:
- throw new PcepParseException("Unsupported TLV type :" + hType);
- }
-
- // Check for the padding
- int pad = hLength % 4;
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= cb.readableBytes()) {
- cb.skipBytes(pad);
- }
- }
-
- llOutOptionalTlv.add(tlv);
- }
-
- if (0 < cb.readableBytes()) {
-
- throw new PcepParseException("Optional Tlv parsing error. Extra bytes received.");
- }
- return llOutOptionalTlv;
- }
-
- /**
- * Returns the writer index.
- *
- * @param cb of type channel buffer
- * @return the writer index.
- */
- protected int packOptionalTlv(ChannelBuffer cb) {
-
- ListIterator<PcepValueType> listIterator = optionalTlvList.listIterator();
-
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
-
- if (tlv == null) {
- log.debug("TLV is null from OptionalTlv list");
- continue;
- }
- tlv.write(cb);
-
- // need to take care of padding
- int pad = tlv.getLength() % 4;
-
- if (0 != pad) {
- pad = 4 - pad;
- for (int i = 0; i < pad; ++i) {
- cb.writeByte((byte) 0);
- }
- }
- }
- return cb.writerIndex();
- }
-
- /**
- * Builder class for PCEP LS (link-state) object.
- */
- public static class Builder implements PcepLSObject.Builder {
- private boolean isHeaderSet = false;
- private boolean isProtocolIdSet = false;
- private boolean isRemoveFlagSet = false;
- private boolean isSyncFlagSet = false;
- private boolean isLSIdSet = false;
-
- private PcepObjectHeader lsObjHeader;
- private byte protocolId;
- private boolean removeFlag;
- private boolean syncFlag;
- private long lsId;
- private List<PcepValueType> optionalTlvList = new LinkedList<>();
-
- private boolean isProcRuleFlagSet = false;
- private boolean procRuleFlag; //Processing rule flag
-
- private boolean isIgnoreFlagSet = false;
- private boolean ignoreFlag;
-
- @Override
- public PcepLSObject build() {
- PcepObjectHeader lsObjHeader = this.isHeaderSet ? this.lsObjHeader : DEFAULT_LS_OBJECT_HEADER;
-
- byte protocolId = this.isProtocolIdSet ? this.protocolId : DEFAULT_PROTOCOL_ID;
- boolean removeFlag = this.isRemoveFlagSet ? this.removeFlag : DEFAULT_R_FLAG;
- boolean syncFlag = this.isSyncFlagSet ? this.syncFlag : DEFAULT_S_FLAG;
- long lsId = this.isLSIdSet ? this.lsId : DEFAULT_LS_ID;
-
- if (isProcRuleFlagSet) {
- lsObjHeader.setPFlag(procRuleFlag);
- }
-
- if (isIgnoreFlagSet) {
- lsObjHeader.setIFlag(ignoreFlag);
- }
-
- return new PcepLSObjectVer1(lsObjHeader, protocolId, removeFlag, syncFlag, lsId, optionalTlvList);
-
- }
-
- @Override
- public PcepObjectHeader getLSObjHeader() {
- return this.lsObjHeader;
- }
-
- @Override
- public Builder setLSObjHeader(PcepObjectHeader obj) {
- this.lsObjHeader = obj;
- this.isHeaderSet = true;
- return this;
- }
-
- @Override
- public byte getProtocolId() {
- return this.protocolId;
- }
-
- @Override
- public Builder setProtocolId(byte protId) {
- this.protocolId = protId;
- this.isProtocolIdSet = true;
- return this;
- }
-
- @Override
- public boolean getRemoveFlag() {
- return this.removeFlag;
- }
-
- @Override
- public Builder setRemoveFlag(boolean removeFlag) {
- this.removeFlag = removeFlag;
- this.isRemoveFlagSet = true;
- return this;
- }
-
- @Override
- public boolean getSyncFlag() {
- return this.syncFlag;
- }
-
- @Override
- public Builder setSyncFlag(boolean syncFlag) {
- this.syncFlag = syncFlag;
- this.isSyncFlagSet = true;
- return this;
- }
-
- @Override
- public long getLSId() {
- return this.lsId;
- }
-
- @Override
- public Builder setLSId(long lsId) {
- this.lsId = lsId;
- this.isLSIdSet = true;
- return this;
- }
-
- @Override
- public List<PcepValueType> getOptionalTlv() {
- return this.optionalTlvList;
- }
-
- @Override
- public Builder setOptionalTlv(List<PcepValueType> optionalTlvList) {
- this.optionalTlvList = optionalTlvList;
- return this;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.procRuleFlag = value;
- this.isProcRuleFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.ignoreFlag = value;
- this.isIgnoreFlagSet = true;
- return this;
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).omitNullValues()
- .add("ObjectHeader", lsObjHeader)
- .add("ProtocolId", protocolId)
- .add("RFlag", (removeFlag) ? 1 : 0)
- .add("SFlag", (syncFlag) ? 1 : 0)
- .add("LsId", lsId)
- .add("OptionalTlv", optionalTlvList).toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLSReportMsgVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLSReportMsgVer1.java
deleted file mode 100644
index c466e59..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLSReportMsgVer1.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.List;
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepMessageWriter;
-import org.onosproject.pcepio.protocol.PcepLSObject;
-import org.onosproject.pcepio.protocol.PcepLSReportMsg;
-import org.onosproject.pcepio.protocol.PcepType;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP LS (link-state) Report Message.
- */
-class PcepLSReportMsgVer1 implements PcepLSReportMsg {
-
- /*
- * Ref : draft-dhodylee-pce-pcep-ls-01, section 8.1
-
- <LSRpt Message> ::= <Common Header>
- <ls-report-list>
- Where:
- <ls-report-list> ::= <LS>[<ls-report-list>]
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepLSReportMsgVer1.class);
- //PACKET_MINIMUM_LENGTH = CommonHeaderLen(4)+LSObjMinLen(12)
- public static final int PACKET_MINIMUM_LENGTH = 16;
- public static final PcepType MSG_TYPE = PcepType.LS_REPORT;
- // <ls-report-list>
- private List<PcepLSObject> lsReportList;
-
- public static final PcepLSReportMsgVer1.Reader READER = new Reader();
-
- /**
- * Reader class for reading PCEP LS-Report message form channel buffer.
- */
- static class Reader implements PcepMessageReader<PcepLSReportMsg> {
-
- List<PcepLSObject> lsReportList;
-
- @Override
- public PcepLSReportMsg readFrom(ChannelBuffer cb) throws PcepParseException {
-
- if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
- return null;
- }
-
- lsReportList = new LinkedList<>();
-
- byte version = cb.readByte();
- version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
- if (version != PcepMessageVer1.PACKET_VERSION) {
- throw new PcepParseException("Wrong version. Expected=PcepVersion.PCEP_1(1), got=" + version);
- }
-
- byte type = cb.readByte();
- if (type != MSG_TYPE.getType()) {
- throw new PcepParseException("Wrong type. Expected=PcepType.LS_REPORT(224), got=" + type);
- }
-
- short length = cb.readShort();
- if (length < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException(
- "Wrong length. Expected to be >= " + PACKET_MINIMUM_LENGTH + ", is: " + length);
- }
-
- // Parse <ls-report-list>
- parseLSReportList(cb);
-
- return new PcepLSReportMsgVer1(lsReportList);
- }
-
- /**
- * Parse ls-report-list.
- *
- * @param cb input Channel Buffer
- * @throws PcepParseException when fails to parse LS-Report list.
- */
- public void parseLSReportList(ChannelBuffer cb) throws PcepParseException {
- // <ls-report-list> ::= <LS>[<ls-report-list>]
-
- while (0 < cb.readableBytes()) {
- //store LS objects
- if (!lsReportList.add(PcepLSObjectVer1.read(cb))) {
- throw new PcepParseException("Failed to add LS object to LS-Report list");
- }
- }
- }
- }
-
- /**
- * Constructor to initialize LS-Report list.
- *
- * @param lsReportList list of PCEP LS Object
- */
- PcepLSReportMsgVer1(List<PcepLSObject> lsReportList) {
- this.lsReportList = lsReportList;
- }
-
- /**
- * Builder class for PCEP LS-Report message.
- */
- static class Builder implements PcepLSReportMsg.Builder {
- // PCEP LS Report message fields
- List<PcepLSObject> lsReportList;
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return PcepType.LS_REPORT;
- }
-
- @Override
- public PcepLSReportMsg build() {
- return new PcepLSReportMsgVer1(this.lsReportList);
- }
-
- @Override
- public List<PcepLSObject> getLSReportList() {
- return this.lsReportList;
- }
-
- @Override
- public Builder setLSReportList(List<PcepLSObject> ll) {
- this.lsReportList = ll;
- return this;
- }
- }
-
- @Override
- public void writeTo(ChannelBuffer bb) throws PcepParseException {
- WRITER.write(bb, this);
- }
-
- static final Writer WRITER = new Writer();
-
- /**
- * Writer class for writing PCEP LS-Report message to channel buffer.
- */
- static class Writer implements PcepMessageWriter<PcepLSReportMsgVer1> {
-
- @Override
- public void write(ChannelBuffer bb, PcepLSReportMsgVer1 message) throws PcepParseException {
-
- int startIndex = bb.writerIndex();
-
- // first 3 bits set to version
- bb.writeByte((byte) (PcepMessageVer1.PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
-
- // message type
- bb.writeByte(MSG_TYPE.getType());
-
- // Length of the message will be updated at the end
- // First write with 0s
- int msgLenIndex = bb.writerIndex();
- bb.writeShort((short) 0);
-
- ListIterator<PcepLSObject> listIterator = message.lsReportList.listIterator();
-
- while (listIterator.hasNext()) {
- PcepLSObject lsObj = listIterator.next();
- lsObj.write(bb);
- }
-
- // update message length field
- int length = bb.writerIndex() - startIndex;
- bb.setShort(msgLenIndex, (short) length);
- }
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return MSG_TYPE;
- }
-
- @Override
- public List<PcepLSObject> getLSReportList() {
- return this.lsReportList;
- }
-
- @Override
- public void setLSReportList(List<PcepLSObject> ll) {
- this.lsReportList = ll;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("LSReportList", lsReportList)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelObjectVer1.java
deleted file mode 100644
index 7e3e554..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelObjectVer1.java
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepLabelObject;
-import org.onosproject.pcepio.types.NexthopIPv4addressTlv;
-import org.onosproject.pcepio.types.NexthopIPv6addressTlv;
-import org.onosproject.pcepio.types.NexthopUnnumberedIPv4IDTlv;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP label object.
- */
-public class PcepLabelObjectVer1 implements PcepLabelObject {
-
- /*
- * ref : draft-zhao-pce-pcep-extension-for-pce-controller-03, section : 7.3.
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Reserved | Flags |O|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Label | Reserved |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Optional TLV //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- The LABEL Object format
- */
- private static final Logger log = LoggerFactory.getLogger(PcepLspObjectVer1.class);
-
- public static final byte LABEL_OBJ_TYPE = 1;
- public static final byte LABEL_OBJ_CLASS = (byte) 225;
- public static final byte LABEL_OBJECT_VERSION = 1;
- public static final byte OBJECT_HEADER_LENGTH = 4;
- public static final boolean DEFAULT_OFLAG = false;
-
- // LSP_OBJ_MINIMUM_LENGTH = CommonHeaderLen(4)+ LspObjectHeaderLen(8)
- public static final short LABEL_OBJ_MINIMUM_LENGTH = 12;
-
- public static final int OFLAG_SET = 1;
- public static final int SHIFT_LABEL = 12;
- public static final int OFLAG_RESET = 0;
- public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
-
- static final PcepObjectHeader DEFAULT_LABEL_OBJECT_HEADER = new PcepObjectHeader(LABEL_OBJ_CLASS, LABEL_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, LABEL_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader labelObjHeader;
- private boolean oBit;
- private int label;
- // Optional TLV
- private LinkedList<PcepValueType> optionalTlv;
-
- /**
- * Constructor to initialize parameters for PCEP label object.
- *
- * @param labelObjHeader label object header
- * @param oBit O flag
- * @param label label
- * @param optionalTlv list of optional tlvs
- */
- public PcepLabelObjectVer1(PcepObjectHeader labelObjHeader, boolean oBit, int label,
- LinkedList<PcepValueType> optionalTlv) {
- this.labelObjHeader = labelObjHeader;
- this.oBit = oBit;
- this.label = label;
- this.optionalTlv = optionalTlv;
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.optionalTlv;
- }
-
- @Override
- public void setOptionalTlv(LinkedList<PcepValueType> optionalTlv) {
- this.optionalTlv = optionalTlv;
- }
-
- @Override
- public boolean getOFlag() {
- return this.oBit;
- }
-
- @Override
- public void setOFlag(boolean value) {
- this.oBit = value;
- }
-
- @Override
- public int getLabel() {
- return this.label;
- }
-
- @Override
- public void setLabel(int value) {
- this.label = value;
- }
-
- /**
- * Reads form channel buffer and returns objects of PcepLabelObject.
- *
- * @param cb of type channel buffer
- * @return objects of PcepLabelObject
- * @throws PcepParseException when fails to read from channel buffer
- */
- public static PcepLabelObject read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader labelObjHeader;
-
- boolean oBit;
- int label;
-
- // Optional TLV
- LinkedList<PcepValueType> optionalTlv = new LinkedList<>();
- labelObjHeader = PcepObjectHeader.read(cb);
-
- //take only LspObject buffer.
- ChannelBuffer tempCb = cb.readBytes(labelObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
-
- int iTemp = tempCb.readInt();
- oBit = (iTemp & (byte) OFLAG_SET) == OFLAG_SET;
- iTemp = tempCb.readInt();
- label = (int) iTemp >> SHIFT_LABEL;
-
- // parse optional TLV
- optionalTlv = parseOptionalTlv(tempCb);
- return new PcepLabelObjectVer1(labelObjHeader, oBit, label, optionalTlv);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- //write Object header
- int objStartIndex = cb.writerIndex();
- int objLenIndex = labelObjHeader.write(cb);
-
- if (objLenIndex <= 0) {
- throw new PcepParseException(" ObjectLength Index is " + objLenIndex);
- }
-
- byte oFlag;
-
- oFlag = (byte) ((oBit) ? OFLAG_SET : OFLAG_RESET);
- cb.writeInt(oFlag);
- int temp = label;
- temp = (int) label << SHIFT_LABEL;
- cb.writeInt(temp);
-
- // Add optional TLV
- packOptionalTlv(cb);
-
- //Update object length now
- int length = cb.writerIndex() - objStartIndex;
-
- //will be helpful during print().
- labelObjHeader.setObjLen((short) length);
- cb.setShort(objLenIndex, (short) length);
- return cb.writerIndex();
- }
-
- /**
- * Returns list of optional tlvs.
- *
- * @param cb of type channel buffer
- * @return list of optional tlvs.
- * @throws PcepParseException when fails to parse list of optional tlvs
- */
- protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
-
- LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<>();
-
- while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) {
-
- PcepValueType tlv;
- short hType = cb.readShort();
- short hLength = cb.readShort();
- int iValue = 0;
-
- switch (hType) {
-
- case NexthopIPv4addressTlv.TYPE:
- iValue = cb.readInt();
- tlv = new NexthopIPv4addressTlv(iValue);
- break;
- case NexthopIPv6addressTlv.TYPE:
- byte[] ipv6Value = new byte[NexthopIPv6addressTlv.VALUE_LENGTH];
- cb.readBytes(ipv6Value, 0, NexthopIPv6addressTlv.VALUE_LENGTH);
- tlv = new NexthopIPv6addressTlv(ipv6Value);
- break;
- case NexthopUnnumberedIPv4IDTlv.TYPE:
- tlv = NexthopUnnumberedIPv4IDTlv.read(cb);
- break;
- default:
- throw new PcepParseException("Unsupported TLV type :" + hType);
- }
-
- // Check for the padding
- int pad = hLength % 4;
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= cb.readableBytes()) {
- cb.skipBytes(pad);
- }
- }
-
- llOutOptionalTlv.add(tlv);
- }
-
- if (0 < cb.readableBytes()) {
-
- throw new PcepParseException("Optional Tlv parsing error. Extra bytes received.");
- }
- return llOutOptionalTlv;
- }
-
- /**
- * Returns the writer index.
- *
- * @param cb of channel buffer.
- * @return writer index
- */
- protected int packOptionalTlv(ChannelBuffer cb) {
-
- ListIterator<PcepValueType> listIterator = optionalTlv.listIterator();
-
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
-
- if (tlv == null) {
- log.debug("tlv is null from OptionalTlv list");
- continue;
- }
- tlv.write(cb);
- }
- return cb.writerIndex();
- }
-
- /**
- * Builder class for PCEP label object.
- */
- public static class Builder implements PcepLabelObject.Builder {
-
- private boolean bIsHeaderSet = false;
- private boolean bIsOFlagSet = false;
- private boolean bIsLabelSet = false;
-
- private PcepObjectHeader labelObjHeader;
- private boolean oBit;
- private int label;
-
- LinkedList<PcepValueType> optionalTlv = new LinkedList<>();
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepLabelObject build() throws PcepParseException {
- PcepObjectHeader labelObjHeader = this.bIsHeaderSet ? this.labelObjHeader : DEFAULT_LABEL_OBJECT_HEADER;
- boolean oBit = this.bIsOFlagSet ? this.oBit : DEFAULT_OFLAG;
-
- if (!this.bIsLabelSet) {
- throw new PcepParseException(" Label NOT Set while building PcepLabelObject.");
- }
- if (bIsPFlagSet) {
- labelObjHeader.setPFlag(bPFlag);
- }
- if (bIsIFlagSet) {
- labelObjHeader.setIFlag(bIFlag);
- }
- return new PcepLabelObjectVer1(labelObjHeader, oBit, this.label, this.optionalTlv);
- }
-
- @Override
- public PcepObjectHeader getLabelObjHeader() {
- return this.labelObjHeader;
- }
-
- @Override
- public Builder setLabelObjHeader(PcepObjectHeader obj) {
- this.labelObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public boolean getOFlag() {
- return this.oBit;
- }
-
- @Override
- public Builder setOFlag(boolean value) {
- this.oBit = value;
- this.bIsOFlagSet = true;
- return this;
- }
-
- @Override
- public int getLabel() {
- return this.label;
- }
-
- @Override
- public Builder setLabel(int value) {
- this.label = value;
- this.bIsLabelSet = true;
- return this;
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.optionalTlv;
- }
-
- @Override
- public Builder setOptionalTlv(LinkedList<PcepValueType> optionalTlv) {
- this.optionalTlv = optionalTlv;
- return this;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("oBit", oBit)
- .add("label", label)
- .add("optionalTlv", optionalTlv)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeObjectVer1.java
deleted file mode 100644
index ea62367..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeObjectVer1.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepLabelRangeObject;
-import org.onosproject.pcepio.types.PathSetupTypeTlv;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP label range object.
- */
-public class PcepLabelRangeObjectVer1 implements PcepLabelRangeObject {
-
- /*
- * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01, section : 7.2
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | label type | range size |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | label base |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Optional TLVs //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- LABEL-RANGE Object
- */
- private static final Logger log = LoggerFactory.getLogger(PcepLabelRangeObjectVer1.class);
-
- public static final byte LABEL_RANGE_OBJ_TYPE = 1;
- public static final byte LABEL_RANGE_OBJ_CLASS = 60; //to be defined
- public static final byte LABEL_RANGE_OBJECT_VERSION = 1;
- public static final short LABEL_RANGE_OBJ_MINIMUM_LENGTH = 12;
- public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
- //P flag and I flag must be set to 0
- static final PcepObjectHeader DEFAULT_LABELRANGE_OBJECT_HEADER = new PcepObjectHeader(LABEL_RANGE_OBJ_CLASS,
- LABEL_RANGE_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
- LABEL_RANGE_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader labelRangeObjHeader;
- private byte labelType;
- private int rangeSize;
- private int labelBase;
- //Optional TLV
- private LinkedList<PcepValueType> llOptionalTlv;
-
- /**
- * Constructor to initialize parameters for PCEP label range object.
- *
- * @param labelRangeObjHeader label range object header
- * @param labelType label type
- * @param rangeSize range size
- * @param labelBase label base
- * @param llOptionalTlv list of optional tlvs
- */
- public PcepLabelRangeObjectVer1(PcepObjectHeader labelRangeObjHeader, byte labelType, int rangeSize, int labelBase,
- LinkedList<PcepValueType> llOptionalTlv) {
- this.labelRangeObjHeader = labelRangeObjHeader;
- this.labelType = labelType;
- this.rangeSize = rangeSize;
- this.llOptionalTlv = llOptionalTlv;
- this.labelBase = labelBase;
- }
-
- @Override
- public void setLabelRangeObjHeader(PcepObjectHeader obj) {
- this.labelRangeObjHeader = obj;
- }
-
- @Override
- public void setLabelType(byte labelType) {
- this.labelType = labelType;
- }
-
- @Override
- public void setRangeSize(int rangeSize) {
- this.rangeSize = rangeSize;
- }
-
- @Override
- public void setLabelBase(int labelBase) {
- this.labelBase = labelBase;
- }
-
- @Override
- public PcepObjectHeader getLabelRangeObjHeader() {
- return this.labelRangeObjHeader;
- }
-
- @Override
- public byte getLabelType() {
- return this.labelType;
- }
-
- @Override
- public int getRangeSize() {
- return this.rangeSize;
- }
-
- @Override
- public int getLabelBase() {
- return this.labelBase;
- }
-
- /**
- * Reads from the channel buffer and returns object of PcepLabelRangeObject.
- *
- * @param cb of type channel buffer
- * @return object of PcepLabelRangeObject
- * @throws PcepParseException when fails to read from channel buffer
- */
- public static PcepLabelRangeObject read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader labelRangeObjHeader;
- byte labelType;
- int rangeSize;
- int labelBase;
-
- LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
-
- labelRangeObjHeader = PcepObjectHeader.read(cb);
-
- //take only LabelRangeObject buffer.
- ChannelBuffer tempCb = cb.readBytes(labelRangeObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH);
- int temp = 0;
- temp = tempCb.readInt();
- rangeSize = temp & 0x00FFFFFF;
- labelType = (byte) (temp >> 24);
- labelBase = tempCb.readInt();
- llOptionalTlv = parseOptionalTlv(tempCb);
- return new PcepLabelRangeObjectVer1(labelRangeObjHeader, labelType, rangeSize, labelBase, llOptionalTlv);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- int objStartIndex = cb.writerIndex();
-
- //write common header
- int objLenIndex = labelRangeObjHeader.write(cb);
- int temp = 0;
- temp = labelType;
- temp = temp << 24;
- temp = temp | rangeSize;
- cb.writeInt(temp);
-
- // Add optional TLV
- if (!packOptionalTlv(cb)) {
- throw new PcepParseException("Error while writing Optional tlv.");
- }
-
- //now write LabelRange Object Length
- cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
- return cb.writerIndex() - objStartIndex;
- }
-
- /**
- * Returns list of optional tlvs.
- *
- * @param cb of type channle buffer
- * @return list of optional tlvs
- * @throws PcepParseException whne fails to parse list of optional tlvs
- */
- public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
-
- LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<>();
-
- while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) {
-
- PcepValueType tlv;
- int iValue;
- short hType = cb.readShort();
- short hLength = cb.readShort();
-
- switch (hType) {
-
- case PathSetupTypeTlv.TYPE:
- iValue = cb.readInt();
- tlv = new PathSetupTypeTlv(iValue);
- break;
-
- default:
- throw new PcepParseException("Unsupported TLV in LabelRange Object.");
- }
-
- // Check for the padding
- int pad = hLength % 4;
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= cb.readableBytes()) {
- cb.skipBytes(pad);
- }
- }
- llOutOptionalTlv.add(tlv);
- }
- return llOutOptionalTlv;
- }
-
- /**
- * Pack optional tlvs.
- *
- * @param cb of channel buffer
- * @return true
- */
- protected boolean packOptionalTlv(ChannelBuffer cb) {
-
- ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
-
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
-
- if (tlv == null) {
- log.debug("tlv is null from OptionalTlv list");
- continue;
- }
- tlv.write(cb);
-
- // need to take care of padding
- int pad = tlv.getLength() % 4;
- if (0 != pad) {
- pad = 4 - pad;
- for (int i = 0; i < pad; ++i) {
- cb.writeByte((byte) 0);
- }
- }
- }
- return true;
- }
-
- /**
- * Builder class for PCEP label range object.
- */
- public static class Builder implements PcepLabelRangeObject.Builder {
- private boolean bIsHeaderSet = false;
- private boolean bIsLabelType = false;
- private boolean bIsRangeSize = false;
- private boolean bIsLabelBase = false;
-
- byte labelType;
- int rangeSize;
- int labelBase;
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
- private PcepObjectHeader labelRangeObjHeader;
-
- LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
-
- @Override
- public PcepLabelRangeObject build() throws PcepParseException {
- PcepObjectHeader labelRangeObjHeader = this.bIsHeaderSet ? this.labelRangeObjHeader
- : DEFAULT_LABELRANGE_OBJECT_HEADER;
-
- if (!this.bIsLabelType) {
- throw new PcepParseException("LabelType NOT Set while building label range object.");
- }
-
- if (!this.bIsRangeSize) {
- throw new PcepParseException("RangeSize NOT Set while building label range object.");
- }
-
- if (!this.bIsLabelBase) {
- throw new PcepParseException("LabelBase NOT Set while building label range object.");
- }
-
- if (bIsPFlagSet) {
- labelRangeObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- labelRangeObjHeader.setIFlag(bIFlag);
- }
- return new PcepLabelRangeObjectVer1(labelRangeObjHeader, this.labelType, this.rangeSize, this.labelBase,
- this.llOptionalTlv);
- }
-
- @Override
- public PcepObjectHeader getLabelRangeObjHeader() {
- return this.labelRangeObjHeader;
- }
-
- @Override
- public Builder setLabelRangeObjHeader(PcepObjectHeader obj) {
- this.labelRangeObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public byte getLabelType() {
- return this.labelType;
- }
-
- @Override
- public Builder setLabelType(byte labelType) {
- this.labelType = labelType;
- this.bIsLabelType = true;
- return this;
- }
-
- @Override
- public int getRangeSize() {
- return this.rangeSize;
- }
-
- @Override
- public Builder setRangeSize(int rangeSize) {
- this.rangeSize = rangeSize;
- this.bIsRangeSize = true;
- return this;
- }
-
- @Override
- public int getLabelBase() {
- return this.labelBase;
- }
-
- @Override
- public Builder setLabelBase(int labelBase) {
- this.labelBase = labelBase;
- this.bIsLabelBase = true;
- return this;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("LabelType", labelType)
- .add("rangeSize", rangeSize)
- .add("labelBase", labelBase)
- .add("optionalTlvList", llOptionalTlv)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeResvMsgVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeResvMsgVer1.java
deleted file mode 100644
index b5789be..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeResvMsgVer1.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepLabelRange;
-import org.onosproject.pcepio.protocol.PcepLabelRangeResvMsg;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepMessageWriter;
-import org.onosproject.pcepio.protocol.PcepType;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP label range reserve message.
- */
-class PcepLabelRangeResvMsgVer1 implements PcepLabelRangeResvMsg {
-
- // Pcep version: 1
-
- /*
- The format of a PCLRResv message is as follows:
-
- PCLRResv Message>::= <Common Header>
- <label-range>
- Where:
-
- <label-range> ::= <SRP>
- <labelrange-list>
-
- Where
- <labelrange-list>::=<LABEL-RANGE>[<labelrange-list>]
- */
- private static final Logger log = LoggerFactory.getLogger(PcepLabelRangeResvMsgVer1.class);
-
- public static final byte PACKET_VERSION = 1;
- // LabelRangeResvMsgMinLength = COMMON-HEADER(4)+SrpObjMinLentgh(12)+LABEL-RANGE-MIN-LENGTH(12)
- public static final int PACKET_MINIMUM_LENGTH = 28;
- public static final PcepType MSG_TYPE = PcepType.LABEL_RANGE_RESERV;
- //<label-range>
- PcepLabelRange labelRange;
-
- public static final PcepLabelRangeResvMsgVer1.Reader READER = new Reader();
-
- /**
- * Reader reads LabelRangeResv Message from the channel.
- */
- static class Reader implements PcepMessageReader<PcepLabelRangeResvMsg> {
-
- @Override
- public PcepLabelRangeResvMsg readFrom(ChannelBuffer cb) throws PcepParseException {
-
- if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Channel buffer has less readable bytes than Packet minimum length.");
- }
- // fixed value property version == 1
- byte version = cb.readByte();
- version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
- if (version != PACKET_VERSION) {
- throw new PcepParseException("Wrong version. Expected=PcepVersion.PCEP_1(1), got=" + version);
- }
- // fixed value property type == 15
- byte type = cb.readByte();
- if (type != MSG_TYPE.getType()) {
- throw new PcepParseException("Wrong type. Expected=PcepType.LABEL_RANGE_RESERV(15), got=" + type);
- }
- short length = cb.readShort();
- if (length < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Wrong length.Expected to be >= " + PACKET_MINIMUM_LENGTH + ", is: "
- + length);
- }
- // parse <label-range>
- PcepLabelRange labelRange = PcepLabelRangeVer1.read(cb);
- return new PcepLabelRangeResvMsgVer1(labelRange);
- }
- }
-
- /**
- * Constructor to initialize PCEP label range.
- *
- * @param labelRange PCEP label range
- */
- PcepLabelRangeResvMsgVer1(PcepLabelRange labelRange) {
- this.labelRange = labelRange;
- }
-
- /**
- * Builder class for PCEP label range reserve message.
- */
- static class Builder implements PcepLabelRangeResvMsg.Builder {
-
- PcepLabelRange labelRange = new PcepLabelRangeVer1();
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return PcepType.LABEL_RANGE_RESERV;
- }
-
- @Override
- public PcepLabelRangeResvMsg build() {
- return new PcepLabelRangeResvMsgVer1(this.labelRange);
- }
-
- @Override
- public PcepLabelRange getLabelRange() {
- return this.labelRange;
- }
-
- @Override
- public Builder setLabelRange(PcepLabelRange labelRange) {
- this.labelRange = labelRange;
- return this;
- }
- }
-
- @Override
- public void writeTo(ChannelBuffer cb) throws PcepParseException {
- WRITER.write(cb, this);
- }
-
- static final Writer WRITER = new Writer();
-
- /**
- * Writer writes LabelRangeResv Message to the channel.
- */
- static class Writer implements PcepMessageWriter<PcepLabelRangeResvMsgVer1> {
-
- @Override
- public void write(ChannelBuffer cb, PcepLabelRangeResvMsgVer1 message) throws PcepParseException {
-
- int startIndex = cb.writerIndex();
- // first 3 bits set to version
- cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
- // message type
- cb.writeByte(MSG_TYPE.getType());
- // Length will be set after calculating length, but currently set it as 0.
- int msgLenIndex = cb.writerIndex();
-
- cb.writeShort((short) 0);
- //write Label Range
- message.labelRange.write(cb);
-
- // update message length field
- int length = cb.writerIndex() - startIndex;
- cb.setShort(msgLenIndex, (short) length);
- }
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return MSG_TYPE;
- }
-
- @Override
- public PcepLabelRange getLabelRange() {
- return this.labelRange;
- }
-
- @Override
- public void setLabelRange(PcepLabelRange lr) {
- this.labelRange = lr;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("labelRange", labelRange)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeVer1.java
deleted file mode 100644
index 83ec8aa..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeVer1.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepLabelRange;
-import org.onosproject.pcepio.protocol.PcepLabelRangeObject;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP Label Range.
- */
-public class PcepLabelRangeVer1 implements PcepLabelRange {
-
- private static final Logger log = LoggerFactory.getLogger(PcepLabelRangeVer1.class);
-
- /*
- <label-range> ::= <SRP>
- <labelrange-list>
- Where
- <labelrange-list>::=<LABEL-RANGE>[<labelrange-list>]
- */
-
- // PCEP SRP Object
- private PcepSrpObject srpObject;
- //<labelrange-list> of type PcepLabelRangeObject.
- private LinkedList<PcepLabelRangeObject> llLabelRangeList;
-
- /**
- * Default Constructor.
- */
- public PcepLabelRangeVer1() {
- srpObject = null;
- llLabelRangeList = null;
- }
-
- /**
- * Constructor to initialize objects.
- *
- * @param srpObj PCEP Srp object.
- * @param llLabelRangeList list of PcepLabelRangeObject.
- */
- PcepLabelRangeVer1(PcepSrpObject srpObj, LinkedList<PcepLabelRangeObject> llLabelRangeList) {
- this.srpObject = srpObj;
- this.llLabelRangeList = llLabelRangeList;
- }
-
- @Override
- public PcepSrpObject getSrpObject() {
- return srpObject;
- }
-
- @Override
- public void setSrpObject(PcepSrpObject srpObject) {
- this.srpObject = srpObject;
-
- }
-
- @Override
- public LinkedList<PcepLabelRangeObject> getLabelRangeList() {
- return llLabelRangeList;
- }
-
- @Override
- public void setLabelRangeList(LinkedList<PcepLabelRangeObject> ll) {
- this.llLabelRangeList = ll;
- }
-
- /**
- * Reads channel buffer and returns object of PcepLabelRange.
- *
- * @param cb of type channel buffer.
- * @return object of PcepLabelRange
- * @throws PcepParseException when fails to read from channel buffer
- */
- public static PcepLabelRange read(ChannelBuffer cb) throws PcepParseException {
-
- //parse and store SRP mandatory object
- PcepSrpObject srpObj = null;
- srpObj = PcepSrpObjectVer1.read(cb);
- if (srpObj == null) {
- throw new PcepParseException("Exception while parsing srp object");
- }
-
- LinkedList<PcepLabelRangeObject> llLabelRangeList = new LinkedList<>();
- boolean bFoundLabelRangeObj = false;
- while (0 < cb.readableBytes()) {
- //parse and store <labelrange-list>
- PcepLabelRangeObject lrObj;
- lrObj = PcepLabelRangeObjectVer1.read(cb);
- if (lrObj == null) {
- throw new PcepParseException("Exception while parsing label range object");
- } else {
- llLabelRangeList.add(lrObj);
- bFoundLabelRangeObj = true;
- }
- }
-
- if (!bFoundLabelRangeObj) {
- throw new PcepParseException("At least one LABEL-RANGE MUST be present.");
- }
- return new PcepLabelRangeVer1(srpObj, llLabelRangeList);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
- //write Object header
- int objStartIndex = cb.writerIndex();
-
- //write <SRP>
- int objLenIndex = srpObject.write(cb);
-
- if (objLenIndex <= 0) {
- throw new PcepParseException("bjectLength is " + objLenIndex);
- }
-
- //write <labelrange-list>
- ListIterator<PcepLabelRangeObject> listIterator = llLabelRangeList.listIterator();
- while (listIterator.hasNext()) {
- listIterator.next().write(cb);
- }
-
- //Update object length now
- int length = cb.writerIndex() - objStartIndex;
- // As per RFC the length of object should be
- // multiples of 4
- int pad = length % 4;
- if (pad != 0) {
- pad = 4 - pad;
- for (int i = 0; i < pad; i++) {
- cb.writeByte((byte) 0);
- }
- length = length + pad;
- }
- cb.setShort(objLenIndex, (short) length);
- return length;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("srpObject", srpObject)
- .add("LabelRangeList", llLabelRangeList)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateMsgVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateMsgVer1.java
deleted file mode 100644
index 0651c0b..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateMsgVer1.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepLabelUpdate;
-import org.onosproject.pcepio.protocol.PcepLabelUpdateMsg;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepMessageWriter;
-import org.onosproject.pcepio.protocol.PcepType;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP lable update message.
- */
-class PcepLabelUpdateMsgVer1 implements PcepLabelUpdateMsg {
-
- // Pcep version: 1
-
- /*
- The format of the PCLabelUpd message:
-
- <PCLabelUpd Message> ::= <Common Header>
- <pce-label-update-list>
- Where:
-
- <pce-label-update-list> ::= <pce-label-update>
- [<pce-label-update-list>]
- <pce-label-update> ::= (<pce-label-download>|<pce-label-map>)
-
- Where:
- <pce-label-download> ::= <SRP>
- <LSP>
- <label-list>
-
- <pce-label-map> ::= <SRP>
- <LABEL>
- <FEC>
-
- <label-list > ::= <LABEL>
- [<label-list>]
-
- */
- private static final Logger log = LoggerFactory.getLogger(PcepLabelUpdateMsgVer1.class);
-
- public static final byte PACKET_VERSION = 1;
-
- //LabelUpdateMsgMinLength = COMMON-HEADER(4)+SrpObjMinLentgh(12)+LabelObjectMinLength(12)+FECType1Object(8)
- public static final int PACKET_MINIMUM_LENGTH = 36;
- public static final PcepType MSG_TYPE = PcepType.LABEL_UPDATE;
- //pce-label-update-list
- private LinkedList<PcepLabelUpdate> llPcLabelUpdateList;
-
- static final PcepLabelUpdateMsgVer1.Reader READER = new Reader();
-
- /**
- * Reader reads LabelUpdate Message from the channel.
- */
- static class Reader implements PcepMessageReader<PcepLabelUpdateMsg> {
-
- @Override
- public PcepLabelUpdateMsg readFrom(ChannelBuffer cb) throws PcepParseException {
-
- if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Readable bytes are less than Packet minimum length.");
- }
-
- // fixed value property version == 1
- byte version = cb.readByte();
- version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
- if (version != PACKET_VERSION) {
- throw new PcepParseException("Wrong version.Expected=PcepVersion.PCEP_1(1), got=" + version);
- }
- // fixed value property type == 13
- byte type = cb.readByte();
- if (type != MSG_TYPE.getType()) {
- throw new PcepParseException("Wrong type. Expected=PcepType.LABEL_UPDATE(13), got=" + type);
- }
- short length = cb.readShort();
- if (length < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Wrong length. Expected to be >= " + PACKET_MINIMUM_LENGTH + ", is: "
- + length);
- }
- // parse <pce-label-download> / <pce-label-map>
- LinkedList<PcepLabelUpdate> llPcLabelUpdateList = parsePcLabelUpdateList(cb);
- return new PcepLabelUpdateMsgVer1(llPcLabelUpdateList);
- }
-
- /**
- * Returns list of PCEP Label Update object.
- *
- * @param cb of type channel buffer
- * @return llPcLabelUpdateList list of PCEP label update object
- * @throws PcepParseException when fails to parse list of PCEP label update object
- */
- public LinkedList<PcepLabelUpdate> parsePcLabelUpdateList(ChannelBuffer cb) throws PcepParseException {
-
- LinkedList<PcepLabelUpdate> llPcLabelUpdateList;
- llPcLabelUpdateList = new LinkedList<>();
-
- while (0 < cb.readableBytes()) {
- llPcLabelUpdateList.add(PcepLabelUpdateVer1.read(cb));
- }
- return llPcLabelUpdateList;
- }
- }
-
- /**
- * Constructor to initialize PCEP Label Update List.
- *
- * @param llPcLabelUpdateList list of PCEP Label Update object
- */
- PcepLabelUpdateMsgVer1(LinkedList<PcepLabelUpdate> llPcLabelUpdateList) {
- this.llPcLabelUpdateList = llPcLabelUpdateList;
- }
-
- /**
- * Builder class for PCEP label update message.
- */
- static class Builder implements PcepLabelUpdateMsg.Builder {
-
- LinkedList<PcepLabelUpdate> llPcLabelUpdateList;
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return PcepType.LABEL_UPDATE;
- }
-
- @Override
- public PcepLabelUpdateMsg build() {
- return new PcepLabelUpdateMsgVer1(this.llPcLabelUpdateList);
- }
-
- @Override
- public LinkedList<PcepLabelUpdate> getPcLabelUpdateList() {
- return this.llPcLabelUpdateList;
- }
-
- @Override
- public Builder setPcLabelUpdateList(LinkedList<PcepLabelUpdate> ll) {
- this.llPcLabelUpdateList = ll;
- return this;
- }
- }
-
- @Override
- public void writeTo(ChannelBuffer cb) throws PcepParseException {
- WRITER.write(cb, this);
- }
-
- static final Writer WRITER = new Writer();
-
- /**
- * Writer writes LabelUpdate Message to the channel.
- */
- static class Writer implements PcepMessageWriter<PcepLabelUpdateMsgVer1> {
-
- @Override
- public void write(ChannelBuffer cb, PcepLabelUpdateMsgVer1 message) throws PcepParseException {
-
- int startIndex = cb.writerIndex();
-
- // first 3 bits set to version
- cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
-
- // message type
- cb.writeByte(MSG_TYPE.getType());
-
- // Length will be set after calculating length, but currently set it as 0.
- int msgLenIndex = cb.writerIndex();
-
- cb.writeShort((short) 0);
- ListIterator<PcepLabelUpdate> listIterator = message.llPcLabelUpdateList.listIterator();
-
- while (listIterator.hasNext()) {
- PcepLabelUpdate labelUpdate = listIterator.next();
- labelUpdate.write(cb);
- }
-
- // update message length field
- int length = cb.writerIndex() - startIndex;
- cb.setShort(msgLenIndex, (short) length);
- }
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return MSG_TYPE;
- }
-
- @Override
- public LinkedList<PcepLabelUpdate> getPcLabelUpdateList() {
- return this.llPcLabelUpdateList;
- }
-
- @Override
- public void setPcLabelUpdateList(LinkedList<PcepLabelUpdate> ll) {
- this.llPcLabelUpdateList = ll;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("PcLabelUpdateList", llPcLabelUpdateList)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateVer1.java
deleted file mode 100644
index a6aa667..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateVer1.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepFecObject;
-import org.onosproject.pcepio.protocol.PcepLabelObject;
-import org.onosproject.pcepio.protocol.PcepLabelUpdate;
-import org.onosproject.pcepio.protocol.PcepLspObject;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.onosproject.pcepio.types.PcepLabelDownload;
-import org.onosproject.pcepio.types.PcepLabelMap;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP LABEL update .
- * Reference :draft-zhao-pce-pcep-extension-for-pce-controller-01.
- */
-public class PcepLabelUpdateVer1 implements PcepLabelUpdate {
-
- /*
- * <pce-label-update> ::= (<pce-label-download>|<pce-label-map>)
-
- Where:
- <pce-label-download> ::= <SRP>
- <LSP>
- <label-list>
-
- <pce-label-map> ::= <SRP>
- <LABEL>
- <FEC>
-
- <label-list > ::= <LABEL>
- [<label-list>]
- */
- private static final Logger log = LoggerFactory.getLogger(PcepLabelUpdateVer1.class);
-
- //Either PceLabelDownload or PceLabelMap is mandatory.
- //label Download
- private PcepLabelDownload labelDownload;
- private boolean isLabelDownloadSet;
- //label Map
- private PcepLabelMap labelMap;
- private boolean isLabelMapSet;
-
- /**
- * Constructor to reset parameters.
- */
- public PcepLabelUpdateVer1() {
- this.labelDownload = null;
- this.isLabelDownloadSet = false;
- this.labelMap = null;
- this.isLabelMapSet = false;
- }
-
- /**
- * Constructor to initialize PCEP label download.
- *
- * @param labelDownload PCEP label download
- */
- public PcepLabelUpdateVer1(PcepLabelDownload labelDownload) {
- this.labelDownload = labelDownload;
- this.isLabelDownloadSet = true;
- this.labelMap = null;
- this.isLabelMapSet = false;
- }
-
- /**
- * Constructor to initialize PCEP label map.
- *
- * @param labelMap PCEP label map
- */
- public PcepLabelUpdateVer1(PcepLabelMap labelMap) {
- this.labelDownload = null;
- this.isLabelDownloadSet = false;
- this.labelMap = labelMap;
- this.isLabelMapSet = true;
- }
-
- /**
- * builder class for PCEP label update.
- */
- static class Builder implements PcepLabelUpdate.Builder {
-
- private PcepLabelDownload labelDownload;
- private boolean isLabelDownloadSet;
- private PcepLabelMap labelMap;
- private boolean isLabelMapSet;
-
- @Override
- public PcepLabelUpdate build() throws PcepParseException {
-
- if (isLabelDownloadSet) {
- return new PcepLabelUpdateVer1(labelDownload);
- }
- if (isLabelMapSet) {
- return new PcepLabelUpdateVer1(labelMap);
- }
-
- return new PcepLabelUpdateVer1();
- }
-
- @Override
- public Builder setLabelDownload(PcepLabelDownload labelDownload) {
- this.labelDownload = labelDownload;
- this.isLabelDownloadSet = true;
- return this;
- }
-
- @Override
- public PcepLabelDownload getLabelDownload() {
- return labelDownload;
- }
-
- @Override
- public Builder setLabelMap(PcepLabelMap labelMap) {
- this.labelMap = labelMap;
- this.isLabelMapSet = true;
- return this;
- }
-
- @Override
- public PcepLabelMap getLabelMap() {
- return labelMap;
- }
- }
-
- /**
- * Reads PcepLabels from the byte stream received from channel buffer.
- *
- * @param cb of type channel buffer.
- * @return PcepLabelUpdate object.
- * @throws PcepParseException when fails to read from channel buffer
- */
- public static PcepLabelUpdate read(ChannelBuffer cb) throws PcepParseException {
-
- PcepLabelUpdateVer1 pceLabelUpdate = new PcepLabelUpdateVer1();
-
- PcepSrpObject srpObject;
- PcepObjectHeader tempObjHeader;
-
- //read SRP mandatory Object
- srpObject = PcepSrpObjectVer1.read(cb);
-
- //checking next object
- cb.markReaderIndex();
-
- tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
-
- if (tempObjHeader.getObjClass() == PcepLspObjectVer1.LSP_OBJ_CLASS) {
-
- //now it is belong to <pce-label-download>
- PcepLabelDownload labelDownload = new PcepLabelDownload();
-
- //set SRP
- labelDownload.setSrpObject(srpObject);
-
- //read and set LSP
- labelDownload.setLspObject(PcepLspObjectVer1.read(cb));
-
- //<label-list>
- LinkedList<PcepLabelObject> llLabelList = new LinkedList<>();
- PcepLabelObject labelObject;
-
- while (0 < cb.readableBytes()) {
-
- cb.markReaderIndex();
- tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
-
- if (tempObjHeader.getObjClass() != PcepLabelObjectVer1.LABEL_OBJ_CLASS) {
- break;
- }
- labelObject = PcepLabelObjectVer1.read(cb);
- llLabelList.add(labelObject);
- }
- labelDownload.setLabelList(llLabelList);
- pceLabelUpdate.setLabelDownload(labelDownload);
- } else if (tempObjHeader.getObjClass() == PcepLabelObjectVer1.LABEL_OBJ_CLASS) {
- //belong to <pce-label-map>
- PcepLabelMap labelMap = new PcepLabelMap();
-
- //set SRP Object
- labelMap.setSrpObject(srpObject);
-
- //read and set Label Object
- labelMap.setLabelObject(PcepLabelObjectVer1.read(cb));
-
- cb.markReaderIndex();
- tempObjHeader = PcepObjectHeader.read(cb);
- cb.resetReaderIndex();
-
- PcepFecObject fecObject = null;
- switch (tempObjHeader.getObjType()) {
- case PcepFecObjectIPv4Ver1.FEC_OBJ_TYPE:
- fecObject = PcepFecObjectIPv4Ver1.read(cb);
- break;
- case PcepFecObjectIPv6Ver1.FEC_OBJ_TYPE:
- fecObject = PcepFecObjectIPv6Ver1.read(cb);
- break;
- case PcepFecObjectIPv4AdjacencyVer1.FEC_OBJ_TYPE:
- fecObject = PcepFecObjectIPv4AdjacencyVer1.read(cb);
- break;
- case PcepFecObjectIPv6AdjacencyVer1.FEC_OBJ_TYPE:
- fecObject = PcepFecObjectIPv6AdjacencyVer1.read(cb);
- break;
- case PcepFecObjectIPv4UnnumberedAdjacencyVer1.FEC_OBJ_TYPE:
- fecObject = PcepFecObjectIPv4UnnumberedAdjacencyVer1.read(cb);
- break;
- default:
- throw new PcepParseException("Unkown FEC object type " + tempObjHeader.getObjType());
- }
- labelMap.setFecObject(fecObject);
- pceLabelUpdate.setLabelMap(labelMap);
- } else {
- throw new PcepParseException(
- "Either <pce-label-download> or <pce-label-map> should be present. Received Class: "
- + tempObjHeader.getObjClass());
- }
- return pceLabelUpdate;
- }
-
- @Override
- public void write(ChannelBuffer cb) throws PcepParseException {
-
- if ((labelDownload != null) && (labelMap != null)) {
- throw new PcepParseException("Label Download and Label Map both can't be present.");
- }
-
- if ((labelDownload == null) && (labelMap == null)) {
- throw new PcepParseException("Either Label Download or Label Map should be present.");
- }
-
- if (labelDownload != null) {
-
- PcepLspObject lspObject;
- PcepSrpObject srpObject;
- PcepLabelObject labelObject;
- LinkedList<PcepLabelObject> llLabelList;
-
- srpObject = labelDownload.getSrpObject();
- if (srpObject == null) {
- throw new PcepParseException("SRP Object is mandatory object for Label Download.");
- } else {
- srpObject.write(cb);
- }
-
- lspObject = labelDownload.getLspObject();
- if (lspObject == null) {
- throw new PcepParseException("LSP Object is mandatory object for Label Download.");
- } else {
- lspObject.write(cb);
- }
-
- llLabelList = labelDownload.getLabelList();
- if (llLabelList == null || llLabelList.isEmpty()) {
- throw new PcepParseException("Label list is mandatory object for Label Download.");
- } else {
- ListIterator<PcepLabelObject> listIterator = llLabelList.listIterator();
- while (listIterator.hasNext()) {
- labelObject = listIterator.next();
- labelObject.write(cb);
- }
- }
- }
-
- if (labelMap != null) {
-
- PcepSrpObject srpObject;
- PcepLabelObject labelObject;
- PcepFecObject fecObject;
-
- srpObject = labelMap.getSrpObject();
- if (srpObject == null) {
- throw new PcepParseException("SRP Object is mandatory object for Label map.");
- } else {
- srpObject.write(cb);
- }
- labelObject = labelMap.getLabelObject();
- if (labelObject == null) {
- throw new PcepParseException("label Object is mandatory object for Label map.");
- } else {
- labelObject.write(cb);
- }
- fecObject = labelMap.getFecObject();
- if (fecObject == null) {
- throw new PcepParseException("fec Object is mandatory object for Label map.");
- } else {
- fecObject.write(cb);
- }
- }
- }
-
- @Override
- public void setLabelDownload(PcepLabelDownload labelDownload) {
- if (this.isLabelMapSet) {
- return;
- }
- this.labelDownload = labelDownload;
- this.isLabelDownloadSet = true;
- }
-
- @Override
- public PcepLabelDownload getLabelDownload() {
- return this.labelDownload;
- }
-
- @Override
- public void setLabelMap(PcepLabelMap labelMap) {
- if (this.isLabelDownloadSet) {
- return;
- }
- this.labelMap = labelMap;
- this.isLabelMapSet = true;
- }
-
- @Override
- public PcepLabelMap getLabelMap() {
- return this.labelMap;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("LabelDownload", labelDownload)
- .add("LabelMap", labelMap)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspObjectVer1.java
deleted file mode 100644
index 2cf184d..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspObjectVer1.java
+++ /dev/null
@@ -1,618 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepLspObject;
-import org.onosproject.pcepio.types.PcepErrorDetailInfo;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
-import org.onosproject.pcepio.types.StatefulLspDbVerTlv;
-import org.onosproject.pcepio.types.StatefulLspErrorCodeTlv;
-import org.onosproject.pcepio.types.StatefulRsvpErrorSpecTlv;
-import org.onosproject.pcepio.types.SymbolicPathNameTlv;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP lsp object.
- */
-public class PcepLspObjectVer1 implements PcepLspObject {
-
- /*
- message format.
- Reference : draft-ietf-pce-stateful-pce-11, section 7.3.
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Object-Class | OT |Res|P|I| Object Length (bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | PLSP-ID | Flag |C| O|A|R|S|D|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // TLVs //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- The LSP Object format
- */
- private static final Logger log = LoggerFactory.getLogger(PcepLspObjectVer1.class);
-
- public static final byte LSP_OBJ_TYPE = 1;
- public static final byte LSP_OBJ_CLASS = 32;
- public static final byte LSP_OBJECT_VERSION = 1;
-
- // LSP_OBJ_MINIMUM_LENGTH = CommonHeaderLen(4)+ LspObjectHeaderLen(4)+TlvAssumedMinLength(8)
- public static final short LSP_OBJ_MINIMUM_LENGTH = 16;
-
- public static final int DEFAULT_PLSPID = 0;
- public static final byte DEFAULT_OFLAG = 1;
- public static final boolean DEFAULT_AFLAG = false;
- public static final boolean DEFAULT_RFLAG = false;
- public static final boolean DEFAULT_SFLAG = false;
- public static final boolean DEFAULT_DFLAG = false;
- public static final boolean DEFAULT_CFLAG = false;
- public static final int OBJECT_HEADER_LENGTH = 4;
- public static final int PLSPID_SHIFT_VALUE = 12;
- public static final int CFLAG_SHIFT_VALUE = 7;
- public static final int OFLAG_SHIFT_VALUE = 4;
- public static final int AFLAG_SHIFT_VALUE = 3;
- public static final int RFLAG_SHIFT_VALUE = 2;
- public static final int SFLAG_SHIFT_VALUE = 1;
- public static final int PLSPID_TEMP_SHIFT_VALUE = 0xFFFFF000;
- public static final int CFLAG_TEMP_SHIFT_VALUE = 0x80;
- public static final int OFLAG_TEMP_SHIFT_VALUE = 0x70;
- public static final int AFLAG_TEMP_SHIFT_VALUE = 0x08;
- public static final int RFLAG_TEMP_SHIFT_VALUE = 0x04;
- public static final int SFLAG_TEMP_SHIFT_VALUE = 0x02;
- public static final int DFLAG_TEMP_SHIFT_VALUE = 0x01;
- public static final int BIT_SET = 1;
- public static final int BIT_RESET = 0;
- public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
-
- static final PcepObjectHeader DEFAULT_LSP_OBJECT_HEADER = new PcepObjectHeader(LSP_OBJ_CLASS, LSP_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, LSP_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader lspObjHeader;
- private int iPlspId;
- // 3-bits
- private byte yOFlag;
- private boolean bAFlag;
- private boolean bRFlag;
- private boolean bSFlag;
- private boolean bDFlag;
- private boolean bCFlag;
-
- // Optional TLV
- private LinkedList<PcepValueType> llOptionalTlv;
-
- /**
- * Constructor to initialize all the member variables.
- *
- * @param lspObjHeader lsp object header
- * @param iPlspId plsp id
- * @param yOFlag O flag
- * @param bAFlag A flag
- * @param bRFlag R flag
- * @param bSFlag S flag
- * @param bDFlag D flag
- * @param bCFlag C flag
- * @param llOptionalTlv list of optional tlv
- */
- public PcepLspObjectVer1(PcepObjectHeader lspObjHeader, int iPlspId, byte yOFlag, boolean bAFlag, boolean bRFlag,
- boolean bSFlag, boolean bDFlag, boolean bCFlag, LinkedList<PcepValueType> llOptionalTlv) {
-
- this.lspObjHeader = lspObjHeader;
- this.iPlspId = iPlspId;
- this.yOFlag = yOFlag;
- this.bAFlag = bAFlag;
- this.bRFlag = bRFlag;
- this.bSFlag = bSFlag;
- this.bDFlag = bDFlag;
- this.bCFlag = bCFlag;
- this.llOptionalTlv = llOptionalTlv;
- }
-
- /**
- * Sets lsp Object Header.
- *
- * @param obj lsp object header
- */
- public void setLspObjHeader(PcepObjectHeader obj) {
- this.lspObjHeader = obj;
- }
-
- @Override
- public void setPlspId(int iPlspId) {
- this.iPlspId = iPlspId;
- }
-
- @Override
- public void setCFlag(boolean bCFlag) {
- this.bCFlag = bCFlag;
- }
-
- @Override
- public void setOFlag(byte yOFlag) {
- this.yOFlag = yOFlag;
- }
-
- @Override
- public void setAFlag(boolean bAFlag) {
- this.bAFlag = bAFlag;
- }
-
- @Override
- public void setRFlag(boolean bRFlag) {
- this.bRFlag = bRFlag;
- }
-
- @Override
- public void setSFlag(boolean bSFlag) {
- this.bSFlag = bSFlag;
- }
-
- @Override
- public void setDFlag(boolean bDFlag) {
- this.bDFlag = bDFlag;
- }
-
- /**
- * Returns lsp object header.
- *
- * @return lspObjHeader
- */
- public PcepObjectHeader getLspObjHeader() {
- return this.lspObjHeader;
- }
-
- @Override
- public int getPlspId() {
- return this.iPlspId;
- }
-
- @Override
- public boolean getCFlag() {
- return this.bCFlag;
- }
-
- @Override
- public byte getOFlag() {
- return this.yOFlag;
- }
-
- @Override
- public boolean getAFlag() {
- return this.bAFlag;
- }
-
- @Override
- public boolean getRFlag() {
- return this.bRFlag;
- }
-
- @Override
- public boolean getSFlag() {
- return this.bSFlag;
- }
-
- @Override
- public boolean getDFlag() {
- return this.bDFlag;
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.llOptionalTlv;
- }
-
- @Override
- public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
- this.llOptionalTlv = llOptionalTlv;
- }
-
- /**
- * Parse channel buffer and returns object of PcepLspObject.
- *
- * @param cb of type channel buffer
- * @return object of PcepLspObject
- * @throws PcepParseException when lsp object is not present in channel buffer
- */
- public static PcepLspObject read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader lspObjHeader;
- int iPlspId;
- // 3-bits
- byte yOFlag;
- boolean bAFlag;
- boolean bRFlag;
- boolean bSFlag;
- boolean bDFlag;
- boolean bCFlag;
-
- // Optional TLV
- LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
-
- lspObjHeader = PcepObjectHeader.read(cb);
-
- if (lspObjHeader.getObjClass() != PcepLspObjectVer1.LSP_OBJ_CLASS) {
- throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_6, PcepErrorDetailInfo.ERROR_VALUE_8);
- }
- //take only LspObject buffer.
- ChannelBuffer tempCb = cb.readBytes(lspObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
-
- Integer iTemp = tempCb.readInt();
- iPlspId = (iTemp & PLSPID_TEMP_SHIFT_VALUE) >> PLSPID_SHIFT_VALUE;
- bCFlag = ((iTemp & CFLAG_TEMP_SHIFT_VALUE) >> CFLAG_SHIFT_VALUE) > 0;
- Integer iX = (iTemp & OFLAG_TEMP_SHIFT_VALUE) >> OFLAG_SHIFT_VALUE;
- yOFlag = iX.byteValue();
- iX = (iTemp & AFLAG_TEMP_SHIFT_VALUE) >> AFLAG_SHIFT_VALUE;
- bAFlag = iX > 0;
- iX = (iTemp & RFLAG_TEMP_SHIFT_VALUE) >> RFLAG_SHIFT_VALUE;
- bRFlag = iX > 0;
- iX = (iTemp & SFLAG_TEMP_SHIFT_VALUE) >> SFLAG_SHIFT_VALUE;
- bSFlag = iX > 0;
- iX = iTemp & DFLAG_TEMP_SHIFT_VALUE;
- bDFlag = iX > 0;
-
- // parse optional TLV
- llOptionalTlv = parseOptionalTlv(tempCb);
-
- return new PcepLspObjectVer1(lspObjHeader, iPlspId, yOFlag, bAFlag, bRFlag, bSFlag, bDFlag, bCFlag,
- llOptionalTlv);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- //write Object header
- int objStartIndex = cb.writerIndex();
-
- int objLenIndex = lspObjHeader.write(cb);
-
- if (objLenIndex <= 0) {
- throw new PcepParseException("Failed to write lsp object header. Index " + objLenIndex);
- }
-
- int iTemp = iPlspId << PLSPID_SHIFT_VALUE;
-
- iTemp = iTemp | (((bCFlag) ? BIT_SET : BIT_RESET) << CFLAG_SHIFT_VALUE);
-
- iTemp = iTemp | (yOFlag << OFLAG_SHIFT_VALUE);
- byte bFlag;
- iTemp = bAFlag ? (iTemp | AFLAG_TEMP_SHIFT_VALUE) : iTemp;
-
- bFlag = (bRFlag) ? (byte) BIT_SET : BIT_RESET;
- iTemp = iTemp | (bFlag << RFLAG_SHIFT_VALUE);
- bFlag = (bSFlag) ? (byte) BIT_SET : BIT_RESET;
- iTemp = iTemp | (bFlag << SFLAG_SHIFT_VALUE);
- bFlag = (bDFlag) ? (byte) BIT_SET : BIT_RESET;
- iTemp = iTemp | bFlag;
- cb.writeInt(iTemp);
-
- // Add optional TLV
- packOptionalTlv(cb);
-
- //Update object length now
- int length = cb.writerIndex() - objStartIndex;
- //will be helpful during print().
- lspObjHeader.setObjLen((short) length);
- // As per RFC the length of object should be
- // multiples of 4
-
- cb.setShort(objLenIndex, (short) length);
-
- return length;
- }
-
- /**
- * Returns Linked list of optional tlvs.
- *
- * @param cb of channel buffer.
- * @return list of optional tlvs
- * @throws PcepParseException when unsupported tlv is received
- */
- protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
-
- LinkedList<PcepValueType> llOutOptionalTlv;
-
- llOutOptionalTlv = new LinkedList<>();
-
- while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) {
-
- PcepValueType tlv = null;
- short hType = cb.readShort();
- short hLength = cb.readShort();
- int iValue = 0;
-
- switch (hType) {
-
- case StatefulIPv4LspIdentifiersTlv.TYPE:
- tlv = StatefulIPv4LspIdentifiersTlv.read(cb);
- break;
- case StatefulLspErrorCodeTlv.TYPE:
- iValue = cb.readInt();
- tlv = new StatefulLspErrorCodeTlv(iValue);
- break;
- case StatefulRsvpErrorSpecTlv.TYPE:
- tlv = StatefulRsvpErrorSpecTlv.read(cb);
- break;
- case SymbolicPathNameTlv.TYPE:
- tlv = SymbolicPathNameTlv.read(cb, hLength);
- break;
- case StatefulLspDbVerTlv.TYPE:
- tlv = StatefulLspDbVerTlv.read(cb);
- break;
- default:
- // Skip the unknown TLV.
- cb.skipBytes(hLength);
- log.info("Received unsupported TLV type :" + hType + " in LSP object.");
- }
- // Check for the padding
- int pad = hLength % 4;
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= cb.readableBytes()) {
- cb.skipBytes(pad);
- }
- }
-
- if (tlv != null) {
- llOutOptionalTlv.add(tlv);
- }
- }
-
- if (0 < cb.readableBytes()) {
-
- throw new PcepParseException("Optional Tlv parsing error. Extra bytes received.");
- }
- return llOutOptionalTlv;
- }
-
- /**
- * returns writer index.
- *
- * @param cb of type channel buffer
- * @return length of bytes written to channel buffer
- */
- protected int packOptionalTlv(ChannelBuffer cb) {
-
- ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
- int startIndex = cb.writerIndex();
-
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
-
- if (tlv == null) {
- log.debug("tlv is null from OptionalTlv list");
- continue;
- }
-
- tlv.write(cb);
-
- // need to take care of padding
- int pad = tlv.getLength() % 4;
-
- if (0 != pad) {
- pad = 4 - pad;
- for (int i = 0; i < pad; ++i) {
- cb.writeByte((byte) 0);
- }
- }
- }
-
- return cb.writerIndex() - startIndex;
- }
-
- /**
- * Builder class for PCEP lsp Object.
- */
- public static class Builder implements PcepLspObject.Builder {
-
- private boolean bIsHeaderSet = false;
- private boolean bIsPlspIdSet = false;
- private boolean bIsOFlagSet = false;
- private boolean bIsRFlagSet = false;
- private boolean bIsAFlagSet = false;
- private boolean bIsDFlagSet = false;
- private boolean bIsSFlagSet = false;
- private boolean bIsCFlagSet = false;
-
- private PcepObjectHeader lspObjHeader;
- private byte yOFlag;
- private boolean bAFlag;
- private boolean bDFlag;
- private boolean bSFlag;
- private boolean bRFlag;
- private boolean bCFlag;
- LinkedList<PcepValueType> llOptionalTlv = null;
-
- private int plspId;
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepLspObject build() {
- PcepObjectHeader lspObjHeader = this.bIsHeaderSet ? this.lspObjHeader : DEFAULT_LSP_OBJECT_HEADER;
-
- int plspId = this.bIsPlspIdSet ? this.plspId : DEFAULT_PLSPID;
- byte yOFlag = this.bIsOFlagSet ? this.yOFlag : DEFAULT_OFLAG;
- boolean bAFlag = this.bIsAFlagSet ? this.bAFlag : DEFAULT_AFLAG;
- boolean bRFlag = this.bIsRFlagSet ? this.bRFlag : DEFAULT_RFLAG;
- boolean bSFlag = this.bIsSFlagSet ? this.bSFlag : DEFAULT_SFLAG;
- boolean bDFlag = this.bIsDFlagSet ? this.bDFlag : DEFAULT_DFLAG;
- boolean bCFlag = this.bIsCFlagSet ? this.bCFlag : DEFAULT_CFLAG;
-
- if (bIsPFlagSet) {
- lspObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- lspObjHeader.setIFlag(bIFlag);
- }
-
- return new PcepLspObjectVer1(lspObjHeader, plspId, yOFlag, bAFlag, bRFlag, bSFlag, bDFlag, bCFlag,
- llOptionalTlv);
- }
-
- @Override
- public PcepObjectHeader getLspObjHeader() {
- return this.lspObjHeader;
- }
-
- @Override
- public Builder setLspObjHeader(PcepObjectHeader obj) {
- this.lspObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public int getPlspId() {
- return this.plspId;
- }
-
- @Override
- public Builder setPlspId(int value) {
- this.plspId = value;
- this.bIsPlspIdSet = true;
- return this;
- }
-
- @Override
- public boolean getCFlag() {
- return this.bCFlag;
- }
-
- @Override
- public Builder setCFlag(boolean value) {
- this.bCFlag = value;
- this.bIsCFlagSet = true;
- return this;
- }
-
- @Override
- public byte getOFlag() {
- return this.yOFlag;
- }
-
- @Override
- public Builder setOFlag(byte value) {
- this.yOFlag = value;
- this.bIsOFlagSet = true;
- return this;
- }
-
- @Override
- public boolean getAFlag() {
- return this.bAFlag;
- }
-
- @Override
- public Builder setAFlag(boolean value) {
- this.bAFlag = value;
- this.bIsAFlagSet = true;
- return this;
- }
-
- @Override
- public boolean getRFlag() {
- return this.bRFlag;
- }
-
- @Override
- public Builder setRFlag(boolean value) {
- this.bRFlag = value;
- this.bIsRFlagSet = true;
- return this;
- }
-
- @Override
- public boolean getSFlag() {
- return this.bSFlag;
- }
-
- @Override
- public Builder setSFlag(boolean value) {
- this.bSFlag = value;
- this.bIsSFlagSet = true;
- return this;
- }
-
- @Override
- public boolean getDFlag() {
- return this.bDFlag;
- }
-
- @Override
- public Builder setDFlag(boolean value) {
- this.bDFlag = value;
- this.bIsDFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
- this.llOptionalTlv = llOptionalTlv;
- return this;
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.llOptionalTlv;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
-
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("PlspIDValue", iPlspId)
- .add("CFlag", bCFlag)
- .add("OFlag", yOFlag)
- .add("AFlag", bAFlag)
- .add("RFlag", bRFlag)
- .add("SFlag", bSFlag)
- .add("DFlag", bDFlag)
- .add("OptionalTlvList", llOptionalTlv)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspaObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspaObjectVer1.java
deleted file mode 100644
index 67e0942..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspaObjectVer1.java
+++ /dev/null
@@ -1,529 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepLspaObject;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP label Object .
- */
-public class PcepLspaObjectVer1 implements PcepLspaObject {
-
- /* LSPA Object Body Format
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Exclude-any |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Include-any |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Include-all |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Setup Prio | Holding Prio | Flags |L| Reserved |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- | Optional TLVs |
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepLspaObjectVer1.class);
-
- public static final byte LSPA_OBJ_TYPE = 1;
- public static final byte LSPA_OBJ_CLASS = 9;
- public static final byte LSPA_OBJECT_VERSION = 1;
- public static final short LSPA_OBJ_MINIMUM_LENGTH = 20;
- public static final int OBJECT_HEADER_LENGTH = 4;
-
- static final PcepObjectHeader DEFAULT_LSPA_OBJECT_HEADER = new PcepObjectHeader(LSPA_OBJ_CLASS, LSPA_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, LSPA_OBJ_MINIMUM_LENGTH);
-
- public static final int SETUP_PRIORITY_SHIFT_VALUE = 24;
- public static final int HOLD_PRIORITY_SHIFT_VALUE = 16;
- public static final int BFLAG_SHIFT_VALUE = 8;
- public static final int LFLAG_SET = 1;
- public static final int LFLAG_RESET = 0;
- private PcepObjectHeader lspaObjHeader;
- private int iExcludeAny;
- private int iIncludeAny;
- private int iIncludeAll;
- private byte cSetupPriority;
- private byte cHoldPriority;
- private boolean bLFlag;
- private LinkedList<PcepValueType> llOptionalTlv; //Optional TLV
-
- /**
- * Constructor to initialize member variables.
- *
- * @param lspaObjHeader lspa object header
- * @param bLFlag b l flag
- * @param iExcludeAny excludeAny value
- * @param iIncludeAny includeAny value
- * @param iIncludeAll includeAll value
- * @param cSetupPriority setup priority value
- * @param cHoldPriority hold priority value
- * @param llOptionalTlv list of optional tlv
- */
- public PcepLspaObjectVer1(PcepObjectHeader lspaObjHeader, boolean bLFlag, int iExcludeAny, int iIncludeAny,
- int iIncludeAll, byte cSetupPriority, byte cHoldPriority, LinkedList<PcepValueType> llOptionalTlv) {
-
- this.lspaObjHeader = lspaObjHeader;
- this.bLFlag = bLFlag;
- this.iExcludeAny = iExcludeAny;
- this.iIncludeAny = iIncludeAny;
- this.iIncludeAll = iIncludeAll;
- this.cSetupPriority = cSetupPriority;
- this.cHoldPriority = cHoldPriority;
- this.llOptionalTlv = llOptionalTlv;
- }
-
- /**
- * Sets Object Header.
- *
- * @param obj lspa object header
- */
- public void setLspaObjHeader(PcepObjectHeader obj) {
- this.lspaObjHeader = obj;
- }
-
- @Override
- public void setExcludeAny(int iExcludeAny) {
- this.iExcludeAny = iExcludeAny;
- }
-
- @Override
- public void setIncludeAny(int iIncludeAny) {
- this.iIncludeAny = iIncludeAny;
- }
-
- @Override
- public void setSetupPriority(byte cSetupPriority) {
- this.cSetupPriority = cSetupPriority;
- }
-
- @Override
- public void setHoldPriority(byte cHoldPriority) {
- this.cHoldPriority = cHoldPriority;
- }
-
- @Override
- public void setLFlag(boolean bLFlag) {
- this.bLFlag = bLFlag;
- }
-
- /**
- * Returns lspa Object Header.
- *
- * @return lspa Object Header
- */
- public PcepObjectHeader getLspaObjHeader() {
- return this.lspaObjHeader;
- }
-
- @Override
- public int getExcludeAny() {
- return this.iExcludeAny;
- }
-
- @Override
- public int getIncludeAny() {
- return this.iIncludeAny;
- }
-
- @Override
- public int getIncludeAll() {
- return this.iIncludeAll;
- }
-
- @Override
- public byte getSetupPriority() {
- return this.cSetupPriority;
- }
-
- @Override
- public byte getHoldPriority() {
- return this.cHoldPriority;
- }
-
- @Override
- public boolean getLFlag() {
- return this.bLFlag;
- }
-
- @Override
- public void setIncludeAll(int value) {
- this.iIncludeAll = value;
-
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.llOptionalTlv;
- }
-
- @Override
- public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
- this.llOptionalTlv = llOptionalTlv;
-
- }
-
- /**
- * Reads channel buffer and returns object of PcepLspaObject.
- *
- * @param cb of type channel buffer.
- * @return object of PcepLspaObject
- * @throws PcepParseException while parsing lspa object from channel buffer
- */
- public static PcepLspaObject read(ChannelBuffer cb) throws PcepParseException {
-
- log.debug("LspaObject::read");
- PcepObjectHeader lspaObjHeader;
- int iExcludeAny;
- int iIncludeAny;
- int iIncludeAll;
- byte cSetupPriority;
- byte cHoldPriority;
- boolean bLFlag;
- byte flags;
-
- // Optional TLV
- LinkedList<PcepValueType> llOptionalTlv;
-
- lspaObjHeader = PcepObjectHeader.read(cb);
-
- //take only Lspa Object buffer.
- ChannelBuffer tempCb = cb.readBytes(lspaObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
- iExcludeAny = tempCb.readInt();
- iIncludeAny = tempCb.readInt();
- iIncludeAll = tempCb.readInt();
- cSetupPriority = tempCb.readByte();
- cHoldPriority = tempCb.readByte();
- flags = tempCb.readByte();
- tempCb.readByte();
-
- bLFlag = (flags & (byte) LFLAG_SET) == LFLAG_SET;
-
- llOptionalTlv = parseOptionalTlv(tempCb);
-
- return new PcepLspaObjectVer1(lspaObjHeader, bLFlag, iExcludeAny, iIncludeAny, iIncludeAll, cSetupPriority,
- cHoldPriority, llOptionalTlv);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- //write Object header
- int objStartIndex = cb.writerIndex();
-
- int objLenIndex = lspaObjHeader.write(cb);
-
- if (objLenIndex <= 0) {
- throw new PcepParseException("Failed to write lspa object header. Index " + objLenIndex);
- }
-
- cb.writeInt(iExcludeAny);
- cb.writeInt(iIncludeAny);
- cb.writeInt(iIncludeAll);
-
- int iTemp = cSetupPriority << SETUP_PRIORITY_SHIFT_VALUE;
- iTemp = iTemp | (cHoldPriority << HOLD_PRIORITY_SHIFT_VALUE);
- byte bFlag;
- bFlag = (bLFlag) ? (byte) LFLAG_SET : LFLAG_RESET;
- iTemp = iTemp | (bFlag << BFLAG_SHIFT_VALUE);
- cb.writeInt(iTemp);
-
- // Add optional TLV
- if (!packOptionalTlv(cb)) {
- throw new PcepParseException("Faild to write lspa objects tlv to channel buffer");
- }
-
- short length = (short) (cb.writerIndex() - objStartIndex);
-
- lspaObjHeader.setObjLen(length); //will be helpful during print().
-
- //As per RFC the length of object should be multiples of 4
- short pad = (short) (length % 4);
-
- if (pad != 0) {
- pad = (short) (4 - pad);
- for (int i = 0; i < pad; i++) {
- cb.writeByte((byte) 0);
- }
- length = (short) (length + pad);
- }
- cb.setShort(objLenIndex, length);
- return cb.writerIndex();
- }
-
- /**
- * Parse list of optional tlvs.
- *
- * @param cb channel buffer
- * @return list of optional tlvs.
- * @throws PcepParseException when fails to parse optional tlv list.
- */
- public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
-
- LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<>();
-
- return llOutOptionalTlv;
- }
-
- /**
- * Writes optional tlvs to channel buffer.
- *
- * @param cb channel buffer
- * @return true
- */
- protected boolean packOptionalTlv(ChannelBuffer cb) {
- int hTlvType;
- int hTlvLength;
-
- ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
- if (tlv == null) {
- log.debug("Warning: tlv is null from OptionalTlv list");
- continue;
- }
- hTlvType = tlv.getType();
- hTlvLength = tlv.getLength();
- if (0 == hTlvLength) {
- log.debug("Warning: invalid length in tlv of OptionalTlv list");
- continue;
- }
-
- cb.writeShort(hTlvType);
- cb.writeShort(hTlvLength);
-
- switch (hTlvType) {
- //TODO: optional TLV for LSPA to be added
-
- default:
- log.debug("Warning: PcepLspaObject: unknown tlv");
- }
-
- // As per RFC the length of object should
- // be multiples of 4
- int pad = hTlvLength % 4;
-
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= cb.readableBytes()) {
- cb.skipBytes(pad);
- }
- }
- }
- return true;
- }
-
- /**
- * Builder class for PCEP lspa object.
- */
- public static class Builder implements PcepLspaObject.Builder {
- private boolean bIsHeaderSet = false;
-
- private PcepObjectHeader lspaObjHeader;
-
- private boolean bLFlag;
- private int iExcludeAny;
- private boolean bIsExcludeAnySet = false;
- private int iIncludeAny;
- private boolean bIsIncludeAnySet = false;
- private int iIncludeAll;
- private boolean bIsIncludeAllSet = false;
- private byte cSetupPriority;
- private boolean bIsSetupPrioritySet = false;
- private byte cHoldPriority;
- private boolean bIsHoldPrioritySet = false;
- private LinkedList<PcepValueType> llOptionalTlv;
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepLspaObject build() throws PcepParseException {
-
- PcepObjectHeader lspaObjHeader = this.bIsHeaderSet ? this.lspaObjHeader : DEFAULT_LSPA_OBJECT_HEADER;
-
- if (!this.bIsExcludeAnySet) {
- throw new PcepParseException("ExcludeAny NOT Set while building PcepLspaObject.");
- }
- if (!this.bIsIncludeAnySet) {
- throw new PcepParseException("IncludeAny NOT Set while building PcepLspaObject.");
- }
- if (!this.bIsIncludeAllSet) {
- throw new PcepParseException("IncludeAll NOT Set while building PcepLspaObject.");
- }
- if (!this.bIsSetupPrioritySet) {
- throw new PcepParseException("Setup Priority NOT Set while building PcepLspaObject.");
- }
- if (!this.bIsHoldPrioritySet) {
- throw new PcepParseException("Hold Priority NOT Set while building PcepLspaObject.");
- }
-
- if (bIsPFlagSet) {
- lspaObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- lspaObjHeader.setIFlag(bIFlag);
- }
-
- return new PcepLspaObjectVer1(lspaObjHeader, bLFlag, iExcludeAny, iIncludeAny, iIncludeAll, cSetupPriority,
- cHoldPriority, llOptionalTlv);
- }
-
- @Override
- public PcepObjectHeader getLspaObjHeader() {
- return this.lspaObjHeader;
- }
-
- @Override
- public Builder setLspaObjHeader(PcepObjectHeader obj) {
- this.lspaObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public boolean getLFlag() {
- return this.bLFlag;
- }
-
- @Override
- public Builder setLFlag(boolean value) {
- this.bLFlag = value;
- return this;
- }
-
- @Override
- public int getExcludeAny() {
- return this.iExcludeAny;
- }
-
- @Override
- public Builder setExcludeAny(int value) {
- this.iExcludeAny = value;
- this.bIsExcludeAnySet = true;
- return this;
- }
-
- @Override
- public int getIncludeAny() {
- return this.iIncludeAny;
- }
-
- @Override
- public Builder setIncludeAny(int value) {
- this.iIncludeAny = value;
- this.bIsIncludeAnySet = true;
- return this;
- }
-
- @Override
- public int getIncludeAll() {
- return this.iIncludeAll;
- }
-
- @Override
- public Builder setIncludeAll(int value) {
- this.iIncludeAll = value;
- this.bIsIncludeAllSet = true;
- return this;
- }
-
- @Override
- public byte getSetupPriority() {
- return this.cSetupPriority;
- }
-
- @Override
- public Builder setSetupPriority(byte value) {
- this.cSetupPriority = value;
- this.bIsSetupPrioritySet = true;
- return this;
- }
-
- @Override
- public byte getHoldPriority() {
- return this.cHoldPriority;
- }
-
- @Override
- public Builder setHoldPriority(byte value) {
- this.cHoldPriority = value;
- this.bIsHoldPrioritySet = true;
- return this;
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.llOptionalTlv;
- }
-
- @Override
- public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
- this.llOptionalTlv = llOptionalTlv;
-
- return this;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
-
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("LFlag", bLFlag)
- .add("SetupPriority", cSetupPriority)
- .add("HoldPriority", cHoldPriority)
- .add("IncludeAll", iIncludeAll)
- .add("IncludeAny", iIncludeAny)
- .add("ExcludeAny", iExcludeAny)
- .add("OptionalTlvList", llOptionalTlv)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMessageVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMessageVer1.java
deleted file mode 100644
index c2be8e5..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMessageVer1.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepFactories;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepType;
-import org.onosproject.pcepio.types.PcepErrorDetailInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Provides PCEP messages.
- */
-public abstract class PcepMessageVer1 {
-
- private static final Logger log = LoggerFactory.getLogger(PcepFactories.class);
-
- // version: 1.0
- public static final byte WIRE_VERSION = 1;
- public static final int MINIMUM_LENGTH = 4;
- public static final int PACKET_VERSION = 1;
- public static final int SHIFT_FLAG = 5;
- public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
-
- public static final PcepMessageVer1.Reader READER = new Reader();
-
- /**
- * Reader class for reading PCEP messages from channel buffer.
- */
- static class Reader implements PcepMessageReader<PcepMessage> {
- @Override
- public PcepMessage readFrom(ChannelBuffer cb) throws PcepParseException, PcepOutOfBoundMessageException {
-
- if (cb.readableBytes() < MINIMUM_LENGTH) {
- throw new PcepParseException("Packet should have minimum length: " + MINIMUM_LENGTH);
- }
-
- try {
- int start = cb.readerIndex();
- // fixed value property version == 1
- byte version = cb.readByte();
- version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
- if (version != (byte) PACKET_VERSION) {
- throw new PcepParseException("Wrong version. Expected=PcepVersion.Message_1(1), got=" + version);
- }
-
- byte type = cb.readByte();
- short length = cb.readShort();
- cb.readerIndex(start);
-
- // Check the out-of-bound message.
- // If the message is out-of-bound then throw PcepOutOfBoundException.
- if ((length - MINIMUM_COMMON_HEADER_LENGTH) > cb.readableBytes()) {
- throw new PcepOutOfBoundMessageException("Message is out-of-bound.");
- }
-
- if (type == (byte) PcepType.OPEN.getType()) {
- log.debug("OPEN MESSAGE is received");
- return PcepOpenMsgVer1.READER.readFrom(cb.readBytes(length));
- } else if (type == (byte) PcepType.KEEP_ALIVE.getType()) {
- log.debug("KEEPALIVE MESSAGE is received");
- return PcepKeepaliveMsgVer1.READER.readFrom(cb.readBytes(length));
- } else if (type == (byte) PcepType.ERROR.getType()) {
- log.debug("ERROR MESSAGE is received");
- return PcepErrorMsgVer1.READER.readFrom(cb.readBytes(length));
- } else if (type == (byte) PcepType.CLOSE.getType()) {
- log.debug("CLOSE MESSAGE is received");
- return PcepCloseMsgVer1.READER.readFrom(cb.readBytes(length));
- } else if (type == (byte) PcepType.REPORT.getType()) {
- log.debug("REPORT MESSAGE is received");
- return PcepReportMsgVer1.READER.readFrom(cb.readBytes(length));
- } else if (type == (byte) PcepType.UPDATE.getType()) {
- log.debug("UPDATE MESSAGE is received");
- return PcepUpdateMsgVer1.READER.readFrom(cb.readBytes(length));
- } else if (type == (byte) PcepType.INITIATE.getType()) {
- log.debug("INITIATE MESSAGE is received");
- return PcepInitiateMsgVer1.READER.readFrom(cb.readBytes(length));
- } else if (type == (byte) PcepType.LS_REPORT.getType()) {
- log.debug("LS REPORT MESSAGE is received");
- return PcepLSReportMsgVer1.READER.readFrom(cb.readBytes(length));
- } else if (type == (byte) PcepType.LABEL_RANGE_RESERV.getType()) {
- log.debug("LABEL RANGE RESERVE MESSAGE is received");
- return PcepLabelRangeResvMsgVer1.READER.readFrom(cb.readBytes(length));
- } else if (type == (byte) PcepType.LABEL_UPDATE.getType()) {
- log.debug("LABEL UPDATE MESSAGE is received");
- return PcepLabelUpdateMsgVer1.READER.readFrom(cb.readBytes(length));
- } else {
- throw new PcepParseException("ERROR: UNKNOWN MESSAGE is received. Msg Type: " + type);
- }
- } catch (IndexOutOfBoundsException e) {
- throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_1);
- }
- }
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMetricObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMetricObjectVer1.java
deleted file mode 100644
index d149189..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMetricObjectVer1.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepMetricObject;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP metric object.
- */
-public class PcepMetricObjectVer1 implements PcepMetricObject {
-
- /*
- METRIC Object Body Format.
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Reserved | Flags |C|B| T |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | metric-value |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepMetricObjectVer1.class);
-
- public static final byte METRIC_OBJ_TYPE = 1;
- public static final byte METRIC_OBJ_CLASS = 6;
- public static final byte METRIC_OBJECT_VERSION = 1;
- public static final short METRIC_OBJ_MINIMUM_LENGTH = 12;
- public static final int OBJECT_HEADER_LENGTH = 4;
- public static final int IFLAG_SHIFT_VALUE = 9;
- public static final int BTYPE_SHIFT_VALUE = 8;
- public static final int CFLAG_SET = 1;
- public static final int CFLAG_RESET = 0;
- public static final int BFLAG_SET = 1;
- public static final int BFLAG_RESET = 0;
- public static final byte CFLAG_CHECK = 0x02;
-
- public static final byte IGP_METRIC = 0x01;
- public static final byte TE_METRIC = 0x02;
- public static final byte HOP_COUNT_METRIC = 0x03;
-
- static final PcepObjectHeader DEFAULT_METRIC_OBJECT_HEADER = new PcepObjectHeader(METRIC_OBJ_CLASS,
- METRIC_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
- METRIC_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader metricObjHeader;
- private int iMetricVal;
- private byte yFlag; // 6-flags
- private boolean bCFlag;
- private boolean bBFlag;
- private byte bType;
-
- /**
- * Default constructor.
- */
- public PcepMetricObjectVer1() {
- this.metricObjHeader = null;
- this.iMetricVal = 0;
- this.yFlag = 0;
- this.bCFlag = false;
- this.bBFlag = false;
- this.bType = 0;
-
- }
-
- /**
- * Constructor to initialize all member variables.
- *
- * @param metricObjHeader metric object header
- * @param iMetricVal metric value
- * @param yFlag Y flag
- * @param bCFlag C flag
- * @param bBFlag B flag
- * @param bType Type value
- */
- public PcepMetricObjectVer1(PcepObjectHeader metricObjHeader, int iMetricVal, byte yFlag, boolean bCFlag,
- boolean bBFlag, byte bType) {
-
- this.metricObjHeader = metricObjHeader;
- this.iMetricVal = iMetricVal;
- this.yFlag = yFlag;
- this.bCFlag = bCFlag;
- this.bBFlag = bBFlag;
- this.bType = bType;
-
- }
-
- @Override
- public void setMetricVal(int value) {
- this.iMetricVal = value;
-
- }
-
- @Override
- public int getMetricVal() {
- return this.iMetricVal;
- }
-
- @Override
- public byte getYFlag() {
- return this.yFlag;
- }
-
- @Override
- public void setYFlag(byte value) {
- this.yFlag = value;
- }
-
- @Override
- public boolean getCFlag() {
- return this.bCFlag;
- }
-
- @Override
- public void setCFlag(boolean value) {
- this.bCFlag = value;
- }
-
- @Override
- public boolean getBFlag() {
- return this.bBFlag;
- }
-
- @Override
- public void setBFlag(boolean value) {
- this.bBFlag = value;
- }
-
- @Override
- public byte getBType() {
- return this.bType;
- }
-
- @Override
- public void setBType(byte value) {
- this.bType = value;
- }
-
- /**
- * Sets metric Object Header.
- *
- * @param obj metric object header
- */
- public void setMetricObjHeader(PcepObjectHeader obj) {
- this.metricObjHeader = obj;
- }
-
- /**
- * Returns metric Object Header.
- *
- * @return metricObjHeader
- */
- public PcepObjectHeader getMetricObjHeader() {
- return this.metricObjHeader;
- }
-
- /**
- * Reads from channel buffer and returns object of PcepMetricObject.
- *
- * @param cb of channel buffer.
- * @return object of PcepMetricObject
- * @throws PcepParseException when metric object is not present in channel buffer
- */
- public static PcepMetricObject read(ChannelBuffer cb) throws PcepParseException {
-
- log.debug("MetricObject::read");
- PcepObjectHeader metricObjHeader;
- int iMetricVal;
- byte yFlag; // 6-flags
- boolean bCFlag;
- boolean bBFlag;
- byte bType;
-
- metricObjHeader = PcepObjectHeader.read(cb);
-
- if (metricObjHeader.getObjClass() != METRIC_OBJ_CLASS) {
- throw new PcepParseException("This object is not a Metric Object. Object Class: "
- + metricObjHeader.getObjClass());
- }
-
- //take only metric buffer.
- ChannelBuffer tempCb = cb.readBytes(metricObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
-
- tempCb.readShort();
- yFlag = tempCb.readByte();
- bType = tempCb.readByte();
- bCFlag = (yFlag & CFLAG_CHECK) == CFLAG_CHECK;
- bBFlag = (yFlag & BFLAG_SET) == BFLAG_SET;
- iMetricVal = tempCb.readInt();
-
- return new PcepMetricObjectVer1(metricObjHeader, iMetricVal, yFlag, bCFlag, bBFlag, bType);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
- //write Object header
- int objStartIndex = cb.writerIndex();
-
- int objLenIndex = metricObjHeader.write(cb);
-
- if (objLenIndex <= 0) {
- throw new PcepParseException("Error: ObjectLength is " + objLenIndex);
- }
-
- int iFlag = (bCFlag) ? CFLAG_SET : CFLAG_RESET;
- int iTemp = iFlag << IFLAG_SHIFT_VALUE;
- iFlag = (bBFlag) ? BFLAG_SET : BFLAG_RESET;
- iTemp = iTemp | (iFlag << BTYPE_SHIFT_VALUE);
- iTemp = iTemp | bType;
- cb.writeInt(iTemp);
- cb.writeInt(iMetricVal);
-
- short hLength = (short) (cb.writerIndex() - objStartIndex);
- cb.setShort(objLenIndex, hLength);
- //will be helpful during print().
- metricObjHeader.setObjLen(hLength);
- return hLength;
- }
-
- /**
- * Builder class for PCEP metric object.
- */
- public static class Builder implements PcepMetricObject.Builder {
-
- private boolean bIsHeaderSet = false;
- private PcepObjectHeader metricObjHeader;
- private int iMetricVal;
- private boolean bIsMetricValSet = false;
- private byte yFlag; // 6-flags
- private boolean bCFlag;
- private boolean bBFlag;
- private byte bType;
- private boolean bIsbTypeSet = false;
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepMetricObject build() throws PcepParseException {
-
- PcepObjectHeader metricObjHeader = this.bIsHeaderSet ? this.metricObjHeader : DEFAULT_METRIC_OBJECT_HEADER;
-
- if (!this.bIsMetricValSet) {
- throw new PcepParseException(" Metric Value NOT Set while building PcepMetricObject.");
- }
- if (!this.bIsbTypeSet) {
- throw new PcepParseException(" Type NOT Set while building PcepMetricObject.");
- }
-
- if (bIsPFlagSet) {
- metricObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- metricObjHeader.setIFlag(bIFlag);
- }
-
- return new PcepMetricObjectVer1(metricObjHeader, iMetricVal, yFlag, bCFlag, bBFlag, bType);
- }
-
- @Override
- public PcepObjectHeader getMetricObjHeader() {
- return this.metricObjHeader;
- }
-
- @Override
- public Builder setMetricObjHeader(PcepObjectHeader obj) {
- this.metricObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public int getMetricVal() {
- return this.iMetricVal;
- }
-
- @Override
- public Builder setMetricVal(int value) {
- this.iMetricVal = value;
- this.bIsMetricValSet = true;
- return this;
- }
-
- @Override
- public byte getYFlag() {
- return this.yFlag;
- }
-
- @Override
- public Builder setYFlag(byte value) {
- this.yFlag = value;
- return this;
- }
-
- @Override
- public boolean getCFlag() {
- return this.bCFlag;
- }
-
- @Override
- public Builder setCFlag(boolean value) {
- this.bCFlag = value;
- return this;
- }
-
- @Override
- public boolean getBFlag() {
- return this.bBFlag;
- }
-
- @Override
- public Builder setBFlag(boolean value) {
- this.bBFlag = value;
- return this;
- }
-
- @Override
- public byte getBType() {
- return this.bType;
- }
-
- @Override
- public Builder setBType(byte value) {
- this.bType = value;
- this.bIsbTypeSet = true;
- return this;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
-
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("MetricValue", iMetricVal)
- .add("BFlag", bBFlag)
- .add("CFlag", bCFlag)
- .add("BType", bType)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMsgPathVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMsgPathVer1.java
deleted file mode 100644
index 9b2f5aa..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMsgPathVer1.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepAttribute;
-import org.onosproject.pcepio.protocol.PcepEroObject;
-import org.onosproject.pcepio.protocol.PcepMsgPath;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP Message PAth for update message.
- * Reference :PCE extensions for stateful draft-ietf-pce-stateful-pce-10.
- */
-public class PcepMsgPathVer1 implements PcepMsgPath {
-
- /*
- * <path> ::= <ERO><attribute-list>
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepMsgPathVer1.class);
- //PcepEroObject
- private PcepEroObject eroObj;
- private boolean isEroObjectSet;
- // PcepAttribute
- private PcepAttribute attrList;
- private boolean isAttributeListSet;
-
- /**
- * constructor to initialize objects.
- */
- public PcepMsgPathVer1() {
- eroObj = null;
- attrList = null;
- isEroObjectSet = false;
- isAttributeListSet = false;
- }
-
- @Override
- public PcepEroObject getEroObject() {
- return eroObj;
- }
-
- @Override
- public PcepAttribute getPcepAttribute() {
- return attrList;
- }
-
- @Override
- public void setEroObject(PcepEroObject eroObj) {
- this.eroObj = eroObj;
- }
-
- @Override
- public void setPcepAttribute(PcepAttribute attrList) {
- this.attrList = attrList;
- }
-
- /**
- * constructor to initialize member variables.
- *
- * @param eroObj pcep ero object
- * @param attrList pcep attribute
- */
- public PcepMsgPathVer1(PcepEroObject eroObj, PcepAttribute attrList) {
- this.eroObj = eroObj;
- isEroObjectSet = true;
- this.attrList = attrList;
- if (attrList == null) {
- isAttributeListSet = false;
- } else {
- isAttributeListSet = true;
- }
- }
-
- @Override
- public PcepMsgPath read(ChannelBuffer cb) throws PcepParseException {
- PcepEroObject eroObj;
- PcepAttribute attrList;
-
- eroObj = PcepEroObjectVer1.read(cb);
- attrList = PcepAttributeVer1.read(cb);
-
- return new PcepMsgPathVer1(eroObj, attrList);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
- int iLenStartIndex = cb.writerIndex();
-
- //write Object header
- if (this.isEroObjectSet) {
- this.eroObj.write(cb);
- }
- if (this.isAttributeListSet) {
- attrList.write(cb);
- }
-
- return cb.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Builder class for PCEP Message path.
- */
- public static class Builder implements PcepMsgPath.Builder {
-
- private boolean bIsEroObjectSet = false;
- private boolean bIsPcepAttributeSet = false;
-
- //PCEP ERO Object
- private PcepEroObject eroObject;
- //PCEP Attribute list
- private PcepAttribute pcepAttribute;
-
- @Override
- public PcepMsgPath build() throws PcepParseException {
-
- //PCEP ERO Object
- PcepEroObject eroObject = null;
- //PCEP Attribute list
- PcepAttribute pcepAttribute = null;
-
- if (!this.bIsEroObjectSet) {
- throw new PcepParseException("ERO Object NOT Set while building PcepMsgPath.");
- } else {
- eroObject = this.eroObject;
- }
- if (!this.bIsPcepAttributeSet) {
- throw new PcepParseException("Pcep Attributes NOT Set while building PcepMsgPath.");
- } else {
- pcepAttribute = this.pcepAttribute;
- }
-
- return new PcepMsgPathVer1(eroObject, pcepAttribute);
- }
-
- @Override
- public PcepEroObject getEroObject() {
- return this.eroObject;
- }
-
- @Override
- public PcepAttribute getPcepAttribute() {
- return this.pcepAttribute;
- }
-
- @Override
- public Builder setEroObject(PcepEroObject eroObject) {
- this.eroObject = eroObject;
- this.bIsEroObjectSet = true;
- return this;
- }
-
- @Override
- public Builder setPcepAttribute(PcepAttribute pcepAttribute) {
- this.pcepAttribute = pcepAttribute;
- this.bIsPcepAttributeSet = true;
- return this;
- }
-
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("EroObject", eroObj)
- .add("AttributeList", attrList)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenMsgVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenMsgVer1.java
deleted file mode 100644
index 0d5dc11..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenMsgVer1.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepMessageWriter;
-import org.onosproject.pcepio.protocol.PcepOpenMsg;
-import org.onosproject.pcepio.protocol.PcepOpenObject;
-import org.onosproject.pcepio.protocol.PcepType;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.onosproject.pcepio.types.PcepErrorDetailInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP open message.
- */
-public class PcepOpenMsgVer1 implements PcepOpenMsg {
-
- /*
- * <Open Message>::= <Common Header> <OPEN>
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Ver | Flags | Message-Type | Message-Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Object-Class | OT |Res|P|I| Object Length (bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Ver | Flags | Keepalive | DeadTimer | SID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Optional TLVs //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepOpenMsgVer1.class);
-
- public static final byte PACKET_VERSION = 1;
- public static final int PACKET_MINIMUM_LENGTH = 12;
- public static final PcepType MSG_TYPE = PcepType.OPEN;
- private PcepOpenObject pcepOpenObj;
-
- public static final PcepOpenMsgVer1.Reader READER = new Reader();
-
- /**
- * Constructor to initialize PcepOpenObject.
- *
- * @param pcepOpenObj PCEP-OPEN-OBJECT
- */
- public PcepOpenMsgVer1(PcepOpenObject pcepOpenObj) {
- this.pcepOpenObj = pcepOpenObj;
- }
-
- @Override
- public PcepOpenObject getPcepOpenObject() {
- return this.pcepOpenObj;
- }
-
- @Override
- public void setPcepOpenObject(PcepOpenObject pcepOpenObj) {
- this.pcepOpenObj = pcepOpenObj;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return MSG_TYPE;
- }
-
- /**
- * Reader class for reading PCEP open message from channel buffer.
- */
- public static class Reader implements PcepMessageReader<PcepOpenMsg> {
-
- @Override
- public PcepOpenMsg readFrom(ChannelBuffer cb) throws PcepParseException {
-
- if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Packet size is less than the minimum length.");
- }
-
- byte version = cb.readByte();
- version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
- if (version != PACKET_VERSION) {
- log.error("[readFrom] Invalid version: " + version);
- throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_1);
- }
- // fixed value property type == 1
- byte type = cb.readByte();
-
- if (type != MSG_TYPE.getType()) {
- log.error("[readFrom] Unexpected type: " + type);
- throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_1);
- }
- int length = cb.readShort();
- if (length < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException(
- "Wrong length: Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: " + length);
- }
- return new PcepOpenMsgVer1(PcepOpenObjectVer1.read(cb));
- }
- }
-
- /**
- * Builder class for PCEP open message.
- */
- static class Builder implements PcepOpenMsg.Builder {
-
- private PcepOpenObject pcepOpenObj;
-
- @Override
- public PcepOpenMsg build() throws PcepParseException {
- if (!(pcepOpenObj instanceof PcepOpenObjectVer1)) {
- throw new NullPointerException("PcepOpenObject is null.");
- }
- return new PcepOpenMsgVer1(pcepOpenObj);
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return PcepType.OPEN;
- }
-
- @Override
- public PcepOpenObject getPcepOpenObj() {
- return this.pcepOpenObj;
- }
-
- @Override
- public Builder setPcepOpenObj(PcepOpenObject obj) {
- this.pcepOpenObj = obj;
- return this;
- }
- }
-
- @Override
- public void writeTo(ChannelBuffer cb) throws PcepParseException {
- WRITER.write(cb, this);
- }
-
- public static final Writer WRITER = new Writer();
-
- /**
- * Writer class for writing PCEP opne message to channel buffer.
- */
- public static class Writer implements PcepMessageWriter<PcepOpenMsgVer1> {
-
- @Override
- public void write(ChannelBuffer cb, PcepOpenMsgVer1 message) throws PcepParseException {
- int startIndex = cb.writerIndex();
- // first 3 bits set to version
- cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
- // message type
- cb.writeByte(MSG_TYPE.getType());
- // length is length of variable message, will be updated at the end
- // Store the position of message
- // length in buffer
-
- int msgLenIndex = cb.writerIndex();
- cb.writeShort(0);
-
- message.getPcepOpenObject().write(cb);
-
- // update message length field
- int iLength = cb.writerIndex() - startIndex;
- cb.setShort(msgLenIndex, (short) iLength);
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("OpenObject", pcepOpenObj)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenObjectVer1.java
deleted file mode 100644
index 51a8eaf..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenObjectVer1.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepOpenObject;
-import org.onosproject.pcepio.protocol.PcepType;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.onosproject.pcepio.types.GmplsCapabilityTlv;
-import org.onosproject.pcepio.types.NodeAttributesTlv;
-import org.onosproject.pcepio.types.PceccCapabilityTlv;
-import org.onosproject.pcepio.types.PcepLabelDbVerTlv;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.onosproject.pcepio.types.SrPceCapabilityTlv;
-import org.onosproject.pcepio.types.StatefulLspDbVerTlv;
-import org.onosproject.pcepio.types.StatefulPceCapabilityTlv;
-import org.onosproject.pcepio.types.LsCapabilityTlv;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP open object.
- */
-public class PcepOpenObjectVer1 implements PcepOpenObject {
-
- /*
- message format.
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Object-Class | OT |Res|P|I| Object Length (bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Ver | Flags | Keepalive | DeadTimer | SID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Optional TLVs //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- The OPEN Object format
- */
- private static final Logger log = LoggerFactory.getLogger(PcepOpenObjectVer1.class);
-
- public static final PcepType MSG_TYPE = PcepType.OPEN;
- public static final byte OPEN_OBJECT_VERSION = 1;
- public static final byte OPEN_OBJ_TYPE = 1;
- public static final byte OPEN_OBJ_CLASS = 1;
- public static final byte DEFAULT_KEEPALIVE_TIME = 30;
- public static final byte DEFAULT_DEAD_TIME = 120;
- public static final short OPEN_OBJ_MINIMUM_LENGTH = 8;
- public static final int DEFAULT_GMPLS_CAPABILITY_TLV_IVALUE = 0X0;
- public static final int DEFAULT_STATEFUL_PCE_CAPABILITY_TLV_IVALUE = 0xf;
- public static final int DEFAULT_PCECC_CAPABILITY_TLV_IVALUE = 0x7;
- public static final int DEFAULT_PCEP_LABEL_DB_VER_TLV_IVALUE = 0X0;
-
- public static final PcepObjectHeader DEFAULT_OPEN_HEADER = new PcepObjectHeader(OPEN_OBJ_CLASS, OPEN_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, OPEN_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader openObjHeader;
- private byte keepAliveTime;
- private byte deadTime;
- private byte sessionId;
- private LinkedList<PcepValueType> llOptionalTlv;
-
- /**
- * Default constructor.
- */
- public PcepOpenObjectVer1() {
- this.openObjHeader = null;
- this.keepAliveTime = 0;
- this.deadTime = 0;
- this.sessionId = 0;
- this.llOptionalTlv = null;
- }
-
- /**
- * Constructor to initialize all member variables.
- *
- * @param openObjHeader Open Object Header
- * @param keepAliveTime Keepalive timer value
- * @param deadTime Dead timer value
- * @param sessionID session id
- * @param llOptionalTlv Optional TLV
- */
- public PcepOpenObjectVer1(PcepObjectHeader openObjHeader, byte keepAliveTime, byte deadTime, byte sessionID,
- LinkedList<PcepValueType> llOptionalTlv) {
- this.openObjHeader = openObjHeader;
- this.keepAliveTime = keepAliveTime;
- this.deadTime = deadTime;
- this.sessionId = sessionID;
- this.llOptionalTlv = llOptionalTlv;
- }
-
- @Override
- public PcepObjectHeader getOpenObjHeader() {
- return this.openObjHeader;
- }
-
- @Override
- public void setOpenObjHeader(PcepObjectHeader obj) {
- this.openObjHeader = obj;
- }
-
- @Override
- public byte getKeepAliveTime() {
- return this.keepAliveTime;
- }
-
- @Override
- public void setKeepAliveTime(byte value) {
- this.keepAliveTime = value;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public byte getDeadTime() {
- return this.deadTime;
- }
-
- @Override
- public void setDeadTime(byte value) {
- this.deadTime = value;
- }
-
- @Override
- public byte getSessionId() {
- return this.sessionId;
- }
-
- @Override
- public void setSessionId(byte value) {
- this.sessionId = value;
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.llOptionalTlv;
- }
-
- @Override
- public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
- this.llOptionalTlv = llOptionalTlv;
- }
-
- /**
- * Reads from channel buffer and returns object of PcepOpenObject.
- *
- * @param cb of type channel buffer
- * @return object of PcepOpenObject
- * @throws PcepParseException if mandatory fields are missing
- */
- public static PcepOpenObject read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader openObjHeader;
- byte version;
- byte keepAliveTime;
- byte deadTime;
- byte sessionID;
- LinkedList<PcepValueType> llOptionalTlv;
-
- openObjHeader = PcepObjectHeader.read(cb);
- version = cb.readByte();
- version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
- if (version != OPEN_OBJECT_VERSION) {
- throw new PcepParseException("Wrong version: Expected=PcepVersion.PCEP_1(1), got=" + version);
- }
- /* Keepalive */
- keepAliveTime = cb.readByte();
-
- /* DeadTimer */
- deadTime = cb.readByte();
-
- /* SID */
- sessionID = cb.readByte();
-
- // Optional TLV
- llOptionalTlv = parseOptionalTlv(cb);
-
- return new PcepOpenObjectVer1(openObjHeader, keepAliveTime, deadTime, sessionID, llOptionalTlv);
- }
-
- /**
- * Returns linkedlist of optional tlvs.
- *
- * @param cb of type channel buffer
- * @return llOptionalTlv Optional TLV
- * @throws PcepParseException if mandatory fields are missing
- */
- protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
-
- LinkedList<PcepValueType> llOptionalTlv;
-
- llOptionalTlv = new LinkedList<>();
-
- while (4 <= cb.readableBytes()) {
- PcepValueType tlv;
- short hType = cb.readShort();
- short hLength = cb.readShort();
-
- switch (hType) {
- case GmplsCapabilityTlv.TYPE:
- log.debug("GmplsCapabilityTlv");
- if (GmplsCapabilityTlv.LENGTH != hLength) {
- throw new PcepParseException("Invalid length received for Gmpls_Capability_Tlv.");
- }
- int iValue = cb.readInt();
- tlv = new GmplsCapabilityTlv(iValue);
- break;
- case StatefulPceCapabilityTlv.TYPE:
- log.debug("StatefulPceCapabilityTlv");
- if (StatefulPceCapabilityTlv.LENGTH != hLength) {
- throw new PcepParseException("Invalid length received for StatefulPceCapabilityTlv.");
- }
- tlv = StatefulPceCapabilityTlv.read(cb);
- break;
- case PceccCapabilityTlv.TYPE:
- log.debug("PceccCapabilityTlv");
- if (PceccCapabilityTlv.LENGTH != hLength) {
- throw new PcepParseException("Invalid length for PceccCapabilityTlv.");
- }
- iValue = cb.readInt();
- tlv = new PceccCapabilityTlv(iValue);
- break;
- case StatefulLspDbVerTlv.TYPE:
- log.debug("StatefulLspDbVerTlv");
- if (StatefulLspDbVerTlv.LENGTH != hLength) {
- throw new PcepParseException("Invalid length received for StatefulLspDbVerTlv.");
- }
- long lValue = cb.readLong();
- tlv = new StatefulLspDbVerTlv(lValue);
- break;
- case LsCapabilityTlv.TYPE:
- log.debug("LsCapabilityTlv");
- if (LsCapabilityTlv.LENGTH != hLength) {
- throw new PcepParseException("Invalid length received for LsCapabilityTlv.");
- }
- iValue = cb.readInt();
- tlv = new LsCapabilityTlv(iValue);
- break;
- case PcepLabelDbVerTlv.TYPE:
- log.debug("PcepLabelDbVerTlv");
- if (PcepLabelDbVerTlv.LENGTH != hLength) {
- throw new PcepParseException("Invalid length received for PcepLabelDbVerTlv.");
- }
- lValue = cb.readLong();
- tlv = new PcepLabelDbVerTlv(lValue);
- break;
- case NodeAttributesTlv.TYPE:
- log.debug("NodeAttributesTlv");
- if (cb.readableBytes() < hLength) {
- throw new PcepParseException("Invalid length for NodeAttributesTlv.");
- }
- tlv = NodeAttributesTlv.read(cb.readBytes(hLength), hLength);
- break;
- case SrPceCapabilityTlv.TYPE:
- log.debug("SrPceCapabilityTlv");
- if (SrPceCapabilityTlv.LENGTH != hLength) {
- throw new PcepParseException("Invalid length received for SrPceCapabilityTlv.");
- }
- tlv = SrPceCapabilityTlv.read(cb);
- break;
- default:
- log.debug("Unsupported TLV: " + hType);
- cb.skipBytes(hLength);
- tlv = null;
- }
-
- // Check for the padding
- int pad = hLength % 4;
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= cb.readableBytes()) {
- cb.skipBytes(pad);
- }
- }
-
- if (tlv != null) {
- llOptionalTlv.add(tlv);
- }
- }
-
- if (0 < cb.readableBytes()) {
- throw new PcepParseException("Optional Tlv parsing error. Extra bytes received.");
- }
-
- return llOptionalTlv;
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- int objStartIndex = cb.writerIndex();
-
- //write common header
- int objLenIndex = openObjHeader.write(cb);
-
- if (objLenIndex <= 0) {
- throw new PcepParseException("Unable to write Open object header.");
- }
-
- cb.writeByte((byte) (OPEN_OBJECT_VERSION << PcepMessageVer1.SHIFT_FLAG));
- cb.writeByte(this.keepAliveTime);
- cb.writeByte(this.deadTime);
- cb.writeByte(this.sessionId);
-
- //Pack optional TLV
- packOptionalTlv(cb);
-
- //now write OPEN Object Length
- int length = cb.writerIndex() - objStartIndex;
- cb.setShort(objLenIndex, (short) length);
- //will be helpful during print().
- this.openObjHeader.setObjLen((short) length);
-
- return length;
- }
-
- /**
- * Returns writer index.
- *
- * @param cb of type channel buffer.
- * @return writer index
- */
- protected int packOptionalTlv(ChannelBuffer cb) {
- int startIndex = cb.writerIndex();
-
- LinkedList<PcepValueType> llOptionalTlv = this.llOptionalTlv;
- ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
- if (tlv == null) {
- log.debug("TLV is null from OptionalTlv list");
- continue;
- }
-
- tlv.write(cb);
-
- // need to take care of padding
- int pad = tlv.getLength() % 4;
-
- if (0 != pad) {
- pad = 4 - pad;
- for (int i = 0; i < pad; ++i) {
- cb.writeByte((byte) 0);
- }
- }
- }
- return cb.writerIndex() - startIndex;
- }
-
- /**
- * Builder class for PCPE open object.
- */
- public static class Builder implements PcepOpenObject.Builder {
- // Pcep open message fields
- private boolean bIsHeaderSet = false;
- private PcepObjectHeader openObjHeader;
- private boolean bIsKeepAliveTimeSet = false;
- private byte keepAliveTime;
- private boolean bIsDeadTimeSet = false;
- private byte deadTime;
- private boolean bIsSessionIDSet = false;
- private byte sessionID;
- private boolean bIsOptionalTlvSet = false;
- private LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepOpenObject build() throws PcepParseException {
- PcepObjectHeader openObjHeader = this.bIsHeaderSet ? this.openObjHeader : DEFAULT_OPEN_HEADER;
- byte keepAliveTime = this.bIsKeepAliveTimeSet ? this.keepAliveTime : DEFAULT_KEEPALIVE_TIME;
- byte deadTime = this.bIsDeadTimeSet ? this.deadTime : DEFAULT_DEAD_TIME;
-
- if (!this.bIsSessionIDSet) {
- throw new PcepParseException("SessionID is not set (mandatory)");
- }
- if (!this.bIsOptionalTlvSet) {
- //Add tlv to list
- //Add GmplsCapabilityTlv
- PcepValueType tlv;
- int iValue = DEFAULT_GMPLS_CAPABILITY_TLV_IVALUE;
- tlv = new GmplsCapabilityTlv(iValue);
- this.llOptionalTlv.add(tlv);
-
- //Add StatefulPceCapabilityTlv
- iValue = DEFAULT_STATEFUL_PCE_CAPABILITY_TLV_IVALUE;
- tlv = new StatefulPceCapabilityTlv(iValue);
- this.llOptionalTlv.add(tlv);
-
- }
-
- if (bIsPFlagSet) {
- openObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- openObjHeader.setIFlag(bIFlag);
- }
-
- return new PcepOpenObjectVer1(openObjHeader, keepAliveTime, deadTime, this.sessionID, this.llOptionalTlv);
- }
-
- @Override
- public PcepObjectHeader getOpenObjHeader() {
- return this.openObjHeader;
- }
-
- @Override
- public Builder setOpenObjHeader(PcepObjectHeader obj) {
- this.openObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public byte getKeepAliveTime() {
- return this.keepAliveTime;
- }
-
- @Override
- public Builder setKeepAliveTime(byte value) {
- this.keepAliveTime = value;
- this.bIsKeepAliveTimeSet = true;
- return this;
- }
-
- @Override
- public byte getDeadTime() {
- return this.deadTime;
- }
-
- @Override
- public Builder setDeadTime(byte value) {
- this.deadTime = value;
- this.bIsDeadTimeSet = true;
- return this;
- }
-
- @Override
- public byte getSessionId() {
- return this.sessionID;
- }
-
- @Override
- public Builder setSessionId(byte value) {
- this.sessionID = value;
- this.bIsSessionIDSet = true;
- return this;
- }
-
- @Override
- public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
- this.llOptionalTlv = llOptionalTlv;
- this.bIsOptionalTlvSet = true;
- return this;
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.llOptionalTlv;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("ObjectHeader", openObjHeader)
- .add("Keepalive", keepAliveTime)
- .add("DeadTimer", deadTime)
- .add("SessionId", sessionId)
- .add("OptionalTlv", llOptionalTlv)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRPObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRPObjectVer1.java
deleted file mode 100644
index 0106299..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRPObjectVer1.java
+++ /dev/null
@@ -1,445 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepRPObject;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP RP object.
- */
-public class PcepRPObjectVer1 implements PcepRPObject {
-
- /*
- * RP Object.
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Flags |O|B|R| Pri |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Request-ID-number |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Optional TLVs //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepRPObjectVer1.class);
-
- public static final byte RP_OBJ_TYPE = 1;
- public static final byte RP_OBJ_CLASS = 2;
- public static final byte RP_OBJECT_VERSION = 1;
- public static final short RP_OBJ_MINIMUM_LENGTH = 12;
-
- public static final int DEFAULT_REQUEST_ID_NUM = 0;
- //Signalled , all default values to be checked.
- public static final boolean DEFAULT_OFLAG = false;
- public static final boolean DEFAULT_BFLAG = false;
- public static final boolean DEFAULT_RFLAG = false;
- public static final byte DEFAULT_PRIFLAG = 0;
- public static final int OBJECT_HEADER_LENGTH = 4;
- public static final int OFLAG_SHIFT_VALUE = 5;
- public static final int BFLAG_SHIFT_VALUE = 4;
- public static final int RFLAG_SHIFT_VALUE = 3;
- public static final int OFLAG_TEMP_SHIFT_VALUE = 0x20;
- public static final int BFLAG_TEMP_SHIFT_VALUE = 0x10;
- public static final int RFLAG_TEMP_SHIFT_VALUE = 0x08;
- public static final int PRIFLAG_TEMP_SHIFT_VALUE = 0x07;
- public static final int BIT_SET = 1;
- public static final int BIT_RESET = 0;
- public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
-
- public static final PcepObjectHeader DEFAULT_RP_OBJECT_HEADER = new PcepObjectHeader(RP_OBJ_CLASS, RP_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, RP_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader rpObjHeader;
- private int iRequestIdNum;
- private boolean bOFlag;
- private boolean bBFlag;
- private boolean bRFlag;
- private byte yPriFlag; // 3bytes
- private LinkedList<PcepValueType> llOptionalTlv;
-
- /**
- * Constructor to initialize variables.
- *
- * @param rpObjHeader RP-OBJECT header
- * @param iRequestIdNum Request-ID-number
- * @param bOFlag O-flag
- * @param bBFlag B-flag
- * @param bRFlag R-flag
- * @param yPriFlag Pri-flag
- * @param llOptionalTlv linked list of Optional TLV
- */
- public PcepRPObjectVer1(PcepObjectHeader rpObjHeader, int iRequestIdNum, boolean bOFlag, boolean bBFlag,
- boolean bRFlag, byte yPriFlag, LinkedList<PcepValueType> llOptionalTlv) {
- this.rpObjHeader = rpObjHeader;
- this.iRequestIdNum = iRequestIdNum;
- this.bOFlag = bOFlag;
- this.bBFlag = bBFlag;
- this.bRFlag = bRFlag;
- this.yPriFlag = yPriFlag;
- this.llOptionalTlv = llOptionalTlv;
- }
-
- /**
- * Sets RP Object header.
- *
- * @param obj RP Object header
- */
- public void setRPObjHeader(PcepObjectHeader obj) {
- this.rpObjHeader = obj;
- }
-
- @Override
- public void setRequestIdNum(int iRequestIdNum) {
- this.iRequestIdNum = iRequestIdNum;
- }
-
- @Override
- public void setOFlag(boolean bOFlag) {
- this.bOFlag = bOFlag;
- }
-
- @Override
- public void setBFlag(boolean bBFlag) {
- this.bBFlag = bBFlag;
- }
-
- @Override
- public void setRFlag(boolean bRFlag) {
- this.bRFlag = bRFlag;
- }
-
- @Override
- public void setPriFlag(byte yPriFlag) {
- this.yPriFlag = yPriFlag;
- }
-
- /**
- * Returns RP Object header.
- *
- * @return rpObjHeader
- */
- public PcepObjectHeader getRPObjHeader() {
- return this.rpObjHeader;
- }
-
- @Override
- public int getRequestIdNum() {
- return this.iRequestIdNum;
- }
-
- @Override
- public boolean getOFlag() {
- return this.bOFlag;
- }
-
- @Override
- public boolean getBFlag() {
- return this.bBFlag;
- }
-
- @Override
- public boolean getRFlag() {
- return this.bRFlag;
- }
-
- @Override
- public byte getPriFlag() {
- return this.yPriFlag;
- }
-
- /**
- * Reads the channel buffer and returns the object of PcepRPObject.
- *
- * @param cb of type channel buffer
- * @return the object of PcepRPObject
- * @throws PcepParseException if mandatory fields are missing
- */
- public static PcepRPObject read(ChannelBuffer cb) throws PcepParseException {
- log.debug("read");
- PcepObjectHeader rpObjHeader;
- int iRequestIdNum;
- boolean bOFlag;
- boolean bBFlag;
- boolean bRFlag;
- byte yPriFlag; // 3bytes
- LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
-
- rpObjHeader = PcepObjectHeader.read(cb);
-
- //take only LspObject buffer.
- ChannelBuffer tempCb = cb.readBytes(rpObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
-
- int iTemp = tempCb.readInt();
- yPriFlag = (byte) (iTemp & PRIFLAG_TEMP_SHIFT_VALUE);
- bOFlag = (iTemp & OFLAG_TEMP_SHIFT_VALUE) == OFLAG_TEMP_SHIFT_VALUE;
- bBFlag = (iTemp & BFLAG_TEMP_SHIFT_VALUE) == BFLAG_TEMP_SHIFT_VALUE;
- bRFlag = (iTemp & RFLAG_TEMP_SHIFT_VALUE) == RFLAG_TEMP_SHIFT_VALUE;
-
- iRequestIdNum = tempCb.readInt();
-
- // parse optional TLV
- llOptionalTlv = parseOptionalTlv(tempCb);
-
- return new PcepRPObjectVer1(rpObjHeader, iRequestIdNum, bOFlag, bBFlag, bRFlag, yPriFlag, llOptionalTlv);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- //write Object header
- int objStartIndex = cb.writerIndex();
-
- int objLenIndex = rpObjHeader.write(cb);
-
- if (objLenIndex <= 0) {
- throw new PcepParseException("ObjectLength Index is " + objLenIndex);
- }
- int iTemp;
- iTemp = (yPriFlag);
-
- iTemp = (bOFlag) ? (iTemp | OFLAG_SHIFT_VALUE) : iTemp;
- iTemp = (bBFlag) ? (iTemp | BFLAG_SHIFT_VALUE) : iTemp;
- iTemp = (bRFlag) ? (iTemp | RFLAG_SHIFT_VALUE) : iTemp;
-
- cb.writeInt(iTemp);
- cb.writeInt(iRequestIdNum);
-
- // Add optional TLV
- packOptionalTlv(cb);
-
- //Update object length now
- int length = cb.writerIndex() - objStartIndex;
-
- //will be helpful during print().
- rpObjHeader.setObjLen((short) length);
-
- cb.setShort(objLenIndex, (short) length);
- return cb.writerIndex();
- }
-
- /**
- * Returns list of optional tlvs.
- *
- * @param cb of type channel buffer.
- * @return llOutOptionalTlv linked list of Optional TLV
- * @throws PcepParseException if mandatory fields are missing
- */
- protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
-
- LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<>();
- //Currently no optional TLvs, will be added based on requirements.
- return llOutOptionalTlv;
- }
-
- /**
- * Returns optional tlvs.
- *
- * @param cb of type channel buffer
- * @return llOptionalTlv linked list of Optional TLV
- */
- protected int packOptionalTlv(ChannelBuffer cb) {
-
- ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
- while (listIterator.hasNext()) {
- listIterator.next().write(cb);
- }
-
- return cb.writerIndex();
- }
-
- /**
- * Builder class for PCEP rp object.
- */
- public static class Builder implements PcepRPObject.Builder {
-
- private boolean bIsHeaderSet = false;
- private boolean bIsRequestIdNumSet = false;
- private boolean bIsOFlagSet = false;
- private boolean bIsRFlagset = false;
- private boolean bIsBFlagSet = false;
- private boolean bIsPriFlagSet = false;
-
- private PcepObjectHeader rpObjHeader;
- private int requestIdNum;
- private boolean bOFlag;
- private boolean bBFlag;
- private boolean bRFlag;
- private byte yPriFlag;
- private LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepRPObject build() {
- PcepObjectHeader lspObjHeader = this.bIsHeaderSet ? this.rpObjHeader : DEFAULT_RP_OBJECT_HEADER;
-
- int requestIdNum = this.bIsRequestIdNumSet ? this.requestIdNum : DEFAULT_REQUEST_ID_NUM;
- boolean bOFlag = this.bIsOFlagSet ? this.bOFlag : DEFAULT_OFLAG;
- boolean bBFlag = this.bIsBFlagSet ? this.bBFlag : DEFAULT_BFLAG;
- boolean bRFlag = this.bIsRFlagset ? this.bRFlag : DEFAULT_RFLAG;
- byte yPriFlag = this.bIsPriFlagSet ? this.yPriFlag : DEFAULT_PRIFLAG;
-
- if (bIsPFlagSet) {
- lspObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- lspObjHeader.setIFlag(bIFlag);
- }
-
- return new PcepRPObjectVer1(lspObjHeader, requestIdNum, bOFlag, bBFlag, bRFlag, yPriFlag, llOptionalTlv);
- }
-
- @Override
- public PcepObjectHeader getRPObjHeader() {
- return this.rpObjHeader;
- }
-
- @Override
- public Builder setRPObjHeader(PcepObjectHeader obj) {
- this.rpObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public int getRequestIdNum() {
- return this.requestIdNum;
- }
-
- @Override
- public Builder setRequestIdNum(int value) {
- this.requestIdNum = value;
- this.bIsRequestIdNumSet = true;
- return this;
- }
-
- @Override
- public Builder setOFlag(boolean value) {
- this.bOFlag = value;
- this.bIsOFlagSet = true;
- return this;
- }
-
- @Override
- public boolean getBFlag() {
- return this.bBFlag;
- }
-
- @Override
- public Builder setBFlag(boolean value) {
- this.bBFlag = value;
- this.bIsBFlagSet = true;
- return this;
- }
-
- @Override
- public boolean getRFlag() {
- return this.bRFlag;
- }
-
- @Override
- public Builder setRFlag(boolean value) {
- this.bRFlag = value;
- this.bIsRFlagset = true;
- return this;
- }
-
- @Override
- public byte getPriFlag() {
- return this.yPriFlag;
- }
-
- @Override
- public Builder setPriFlag(byte value) {
- this.yPriFlag = value;
- this.bIsPriFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
- this.llOptionalTlv = llOptionalTlv;
- return this;
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.llOptionalTlv;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
-
- @Override
- public boolean getOFlag() {
- return this.bOFlag;
- }
-
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.llOptionalTlv;
- }
-
- @Override
- public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
- this.llOptionalTlv = llOptionalTlv;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("ObjectHeader", rpObjHeader)
- .add("OFlag", (bOFlag) ? 1 : 0)
- .add("BFlag", (bBFlag) ? 1 : 0)
- .add("RFlag", (bRFlag) ? 1 : 0)
- .add("PriFlag", yPriFlag)
- .add("RequestIdNumber", iRequestIdNum)
- .add("OptionalTlv", llOptionalTlv)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepReportMsgVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepReportMsgVer1.java
deleted file mode 100644
index ad2cc47..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepReportMsgVer1.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepLspObject;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepMessageWriter;
-import org.onosproject.pcepio.protocol.PcepReportMsg;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.onosproject.pcepio.protocol.PcepStateReport;
-import org.onosproject.pcepio.protocol.PcepType;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP report message.
- */
-class PcepReportMsgVer1 implements PcepReportMsg {
-
- // Pcep version: 1
-
- /*
- * The format of the PCRpt message is as follows:
- * <PCRpt Message> ::= <Common Header>
- * <state-report-list>
- *Where:
- * <state-report-list> ::= <state-report>[<state-report-list>]
- * <state-report> ::= [<SRP>]
- * <LSP>
- * <path>
- * Where:
- * <path> ::= <ERO><attribute-list>[<RRO>]
- * Where:
- * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
- * where:
- * <attribute-list> ::=[<LSPA>]
- * [<BANDWIDTH>]
- * [<metric-list>]
- * [<IRO>]
- * <metric-list> ::=<METRIC>[<metric-list>]
- */
- private static final Logger log = LoggerFactory.getLogger(PcepReportMsgVer1.class);
-
- public static final byte PACKET_VERSION = 1;
- //PACKET_MINIMUM_LENGTH = CommonHeaderLen(4)+LspObjMinLen(8)
- public static final int PACKET_MINIMUM_LENGTH = 12;
- public static final PcepType MSG_TYPE = PcepType.REPORT;
- public static final byte REPORT_OBJ_TYPE = 1;
- //Optional TLV
- private LinkedList<PcepStateReport> llStateReportList;
-
- public static final PcepReportMsgVer1.Reader READER = new Reader();
-
- /**
- * Reader class for reading PCEP report message from channel buffer.
- */
- static class Reader implements PcepMessageReader<PcepReportMsg> {
-
- LinkedList<PcepStateReport> llStateReportList;
-
- @Override
- public PcepReportMsg readFrom(ChannelBuffer cb) throws PcepParseException {
-
- if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Received packet size " + cb.readableBytes()
- + " is less than the expected size: " + PACKET_MINIMUM_LENGTH);
- }
- llStateReportList = new LinkedList<>();
- byte version = cb.readByte();
- version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
-
- if (version != PACKET_VERSION) {
- throw new PcepParseException(" Invalid version: " + version);
- }
-
- byte type = cb.readByte();
-
- if (type != MSG_TYPE.getType()) {
- throw new PcepParseException("Unexpected type: " + type);
- }
-
- short length = cb.readShort();
-
- if (length < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Wrong length. Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: "
- + length);
- }
- // parse state report list
- parseStateReportList(cb);
- return new PcepReportMsgVer1(llStateReportList);
- }
-
- // Parse State Report list
- public void parseStateReportList(ChannelBuffer cb) throws PcepParseException {
-
- /*
- <state-report-list>
- Where:
- <state-report-list> ::= <state-report>[<state-report-list>]
- <state-report> ::= [<SRP>]
- <LSP>
- <path>
- Where:
- <path> ::= <ERO><attribute-list>[<RRO>]
- Where:
- <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
-
- */
-
- while (0 < cb.readableBytes()) {
-
- PcepStateReport pcestateReq = new PcepStateReportVer1();
-
- /*
- * SRP is optional
- * Check whether SRP Object is available, if yes store it.
- * First read common object header and check the Object Class whether it is SRP or LSP
- * If it is LSP then store only LSP. So, SRP is optional. then read path and store.
- * If it is SRP then store SRP and then read LSP, path and store them.
- */
-
- //mark the reader index to reset
- cb.markReaderIndex();
- PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
-
- byte yObjectClass = tempObjHeader.getObjClass();
- byte yObjectType = tempObjHeader.getObjType();
-
- //reset reader index
- cb.resetReaderIndex();
- //If SRP present then store it.
- if ((PcepSrpObjectVer1.SRP_OBJ_CLASS == yObjectClass)
- && (PcepSrpObjectVer1.SRP_OBJ_TYPE == yObjectType)) {
- PcepSrpObject srpObj;
- srpObj = PcepSrpObjectVer1.read(cb);
- pcestateReq.setSrpObject(srpObj);
- }
-
- //store LSP object
- PcepLspObject lspObj;
- lspObj = PcepLspObjectVer1.read(cb);
- pcestateReq.setLspObject(lspObj);
-
- if (cb.readableBytes() > 0) {
-
- //mark the reader index to reset
- cb.markReaderIndex();
- tempObjHeader = PcepObjectHeader.read(cb);
-
- yObjectClass = tempObjHeader.getObjClass();
- yObjectType = tempObjHeader.getObjType();
-
- //reset reader index
- cb.resetReaderIndex();
-
- if ((PcepEroObjectVer1.ERO_OBJ_CLASS == yObjectClass)
- && (PcepEroObjectVer1.ERO_OBJ_TYPE == yObjectType)) {
- // store path
- PcepStateReport.PcepMsgPath msgPath = new PcepStateReportVer1().new PcepMsgPath().read(cb);
- pcestateReq.setMsgPath(msgPath);
- }
- }
-
- llStateReportList.add(pcestateReq);
- }
- }
- }
-
- /**
- * Constructor to initialize State Report List.
- *
- * @param llStateReportList list of type Pcep state report
- */
- PcepReportMsgVer1(LinkedList<PcepStateReport> llStateReportList) {
- this.llStateReportList = llStateReportList;
- }
-
- /**
- * Builder class for PCEP Report message.
- */
- static class Builder implements PcepReportMsg.Builder {
- // Pcep report message fields
- LinkedList<PcepStateReport> llStateReportList;
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return PcepType.REPORT;
- }
-
- @Override
- public PcepReportMsg build() {
- return new PcepReportMsgVer1(this.llStateReportList);
- }
-
- @Override
- public LinkedList<PcepStateReport> getStateReportList() {
- return this.llStateReportList;
- }
-
- @Override
- public Builder setStateReportList(LinkedList<PcepStateReport> ll) {
- this.llStateReportList = ll;
- return this;
- }
- }
-
- @Override
- public void writeTo(ChannelBuffer cb) throws PcepParseException {
- WRITER.write(cb, this);
- }
-
- static final Writer WRITER = new Writer();
-
- /**
- * Writer class for writing PCEP report message to channel buffer.
- */
- static class Writer implements PcepMessageWriter<PcepReportMsgVer1> {
-
- @Override
- public void write(ChannelBuffer cb, PcepReportMsgVer1 message) throws PcepParseException {
-
- int startIndex = cb.writerIndex();
-
- // first 3 bits set to version
- cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
-
- // message type
- cb.writeByte(MSG_TYPE.getType());
-
- // length is length of variable message, will be updated at the end
- // Store the position of message
- // length in buffer
- int msgLenIndex = cb.writerIndex();
-
- cb.writeShort((short) 0);
- ListIterator<PcepStateReport> listIterator = message.llStateReportList.listIterator();
-
- while (listIterator.hasNext()) {
-
- PcepStateReport stateRpt = listIterator.next();
- PcepSrpObject srpObj = stateRpt.getSrpObject();
-
- //SRP object is optional
- if (srpObj != null) {
- srpObj.write(cb);
- }
-
- //LSP object is mandatory
- PcepLspObject lspObj = stateRpt.getLspObject();
- if (lspObj == null) {
- throw new PcepParseException("LSP Object is mandatory object for PcRpt message.");
- } else {
- lspObj.write(cb);
- }
-
- //path is mandatory
- PcepStateReport.PcepMsgPath msgPath = stateRpt.getMsgPath();
- if (msgPath == null) {
- throw new PcepParseException("Message path is mandatory object for PcRpt message.");
- } else {
- msgPath.write(cb);
- }
- }
-
- // update message length field
- int length = cb.writerIndex() - startIndex;
- cb.setShort(msgLenIndex, (short) length);
- }
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return MSG_TYPE;
- }
-
- @Override
- public LinkedList<PcepStateReport> getStateReportList() {
- return this.llStateReportList;
- }
-
- @Override
- public void setStateReportList(LinkedList<PcepStateReport> ll) {
- this.llStateReportList = ll;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("StateReportList", llStateReportList)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRroObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRroObjectVer1.java
deleted file mode 100644
index ae8ec34..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRroObjectVer1.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepRroObject;
-import org.onosproject.pcepio.types.IPv4SubObject;
-import org.onosproject.pcepio.types.IPv6SubObject;
-import org.onosproject.pcepio.types.LabelSubObject;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP RRO object.
- */
-public class PcepRroObjectVer1 implements PcepRroObject {
-
- /*
- * rfc3209
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Object-Class | OT |Res|P|I| Object Length (bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // (Subobjects) //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Each subobject has its own Length
- field. The length contains the total length of the subobject in
- bytes, including the Type and Length fields. The length MUST always
- be a multiple of 4, and at least 4.
-
- An empty RRO with no subobjects is considered illegal.
- Three kinds of subobjects are currently defined.
-
- Subobject 1: IPv4 address
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type | Length | IPv4 address (4 bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv4 address (continued) | Prefix Length | Flags |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Subobject 2: IPv6 address
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type | Length | IPv6 address (16 bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv6 address (continued) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv6 address (continued) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv6 address (continued) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv6 address (continued) | Prefix Length | Flags |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Subobject 3, Label
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type | Length | Flags | C-Type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Contents of Label Object |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- */
- private static final Logger log = LoggerFactory.getLogger(PcepRroObjectVer1.class);
-
- public static final byte RRO_OBJ_TYPE = 1;
- public static final byte RRO_OBJ_CLASS = 8;
- public static final byte RRO_OBJECT_VERSION = 1;
- public static final short RRO_OBJ_MINIMUM_LENGTH = 12;
- public static final int OBJECT_HEADER_LENGTH = 4;
- public static final int YTYPE_SHIFT_VALUE = 0x7F;
-
- static final PcepObjectHeader DEFAULT_RRO_OBJECT_HEADER = new PcepObjectHeader(RRO_OBJ_CLASS, RRO_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, RRO_OBJ_MINIMUM_LENGTH);
-
- private short rroObjType = 0;
- private byte length;
- private byte prefixLength;
- private byte resvd;
- PcepObjectHeader rroObjHeader;
- private LinkedList<PcepValueType> llSubObjects = new LinkedList<>();
-
- /**
- * Reset variables.
- */
- public PcepRroObjectVer1() {
- this.rroObjHeader = null;
- this.rroObjType = 0;
- this.length = 0;
- }
-
- /**
- * constructor to initialize parameters for RRO object.
- *
- * @param rroObjHeader RRO object header
- * @param llSubObjects list of sub objects
- */
- public PcepRroObjectVer1(PcepObjectHeader rroObjHeader, LinkedList<PcepValueType> llSubObjects) {
- this.rroObjHeader = rroObjHeader;
- this.llSubObjects = llSubObjects;
- }
-
- /**
- * Returns PCEP RRO Object Header.
- *
- * @return rroObjHeader RRO Object header
- */
- public PcepObjectHeader getRroObjHeader() {
- return this.rroObjHeader;
- }
-
- /**
- * Sets PCEP RRO Object Header.
- *
- * @param obj Object header
- */
- public void setRroObjHeader(PcepObjectHeader obj) {
- this.rroObjHeader = obj;
- }
-
- @Override
- public LinkedList<PcepValueType> getSubObjects() {
- return this.llSubObjects;
- }
-
- @Override
- public void setSubObjects(LinkedList<PcepValueType> llSubObjects) {
- this.llSubObjects = llSubObjects;
- }
-
- /**
- * Reads the channel buffer and returns object of PcepRroObject.
- *
- * @param cb of type channel buffer
- * @return object of PcepRroObject
- * @throws PcepParseException when fails to read from channel buffer
- */
- public static PcepRroObject read(ChannelBuffer cb) throws PcepParseException {
-
- PcepObjectHeader rroObjHeader;
- LinkedList<PcepValueType> llSubObjects;
- rroObjHeader = PcepObjectHeader.read(cb);
-
- //take only RroObject buffer.
- ChannelBuffer tempCb = cb.readBytes(rroObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
- llSubObjects = parseSubObjects(tempCb);
-
- return new PcepRroObjectVer1(rroObjHeader, llSubObjects);
- }
-
- /**
- * Returns list of sub objects.
- *
- * @param cb of type channel buffer
- * @return list of sub objects
- * @throws PcepParseException when fails to parse list of sub objects
- */
- protected static LinkedList<PcepValueType> parseSubObjects(ChannelBuffer cb) throws PcepParseException {
-
- LinkedList<PcepValueType> llSubObjects = new LinkedList<>();
-
- while (0 < cb.readableBytes()) {
-
- //check the Type of the Sub objects
- byte yType = cb.readByte();
- yType = (byte) (yType & (YTYPE_SHIFT_VALUE));
- byte hLength = cb.readByte();
-
- PcepValueType subObj;
-
- switch (yType) {
-
- case IPv4SubObject.TYPE:
- subObj = IPv4SubObject.read(cb);
- break;
- case IPv6SubObject.TYPE:
- byte[] ipv6Value = new byte[IPv6SubObject.VALUE_LENGTH];
- cb.readBytes(ipv6Value, 0, IPv6SubObject.VALUE_LENGTH);
- subObj = new IPv6SubObject(ipv6Value);
- break;
- case LabelSubObject.TYPE:
- subObj = LabelSubObject.read(cb);
- break;
- default:
- throw new PcepParseException(" Unexpected sub object. Type: " + (int) yType);
- }
- // Check for the padding
- int pad = hLength % 4;
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= cb.readableBytes()) {
- cb.skipBytes(pad);
- }
- }
- llSubObjects.add(subObj);
- }
-
- return llSubObjects;
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
- //write Object header
- int objStartIndex = cb.writerIndex();
-
- int objLenIndex = rroObjHeader.write(cb);
-
- if (objLenIndex <= 0) {
- throw new PcepParseException(" object Length Index" + objLenIndex);
- }
-
- ListIterator<PcepValueType> listIterator = llSubObjects.listIterator();
-
- while (listIterator.hasNext()) {
- listIterator.next().write(cb);
- }
-
- //Update object length now
- int length = cb.writerIndex() - objStartIndex;
- cb.setShort(objLenIndex, (short) length);
- //will be helpful during print().
- rroObjHeader.setObjLen((short) length);
-
- //As per RFC the length of object should be multiples of 4
- int pad = length % 4;
-
- if (0 != pad) {
- pad = 4 - pad;
- for (int i = 0; i < pad; i++) {
- cb.writeByte((byte) 0);
- }
- }
- objLenIndex = cb.writerIndex();
- return objLenIndex;
- }
-
- /**
- * Builder class for PCEP RRO object.
- */
- public static class Builder implements PcepRroObject.Builder {
- private boolean bIsHeaderSet = false;
-
- private PcepObjectHeader rroObjHeader;
- LinkedList<PcepValueType> llSubObjects = new LinkedList<>();
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepRroObject build() {
-
- PcepObjectHeader rroObjHeader = this.bIsHeaderSet ? this.rroObjHeader : DEFAULT_RRO_OBJECT_HEADER;
-
- if (bIsPFlagSet) {
- rroObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- rroObjHeader.setIFlag(bIFlag);
- }
- return new PcepRroObjectVer1(rroObjHeader, this.llSubObjects);
- }
-
- @Override
- public PcepObjectHeader getRroObjHeader() {
- return this.rroObjHeader;
- }
-
- @Override
- public Builder setRroObjHeader(PcepObjectHeader obj) {
- this.rroObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public LinkedList<PcepValueType> getSubObjects() {
- return this.llSubObjects;
- }
-
- @Override
- public Builder setSubObjects(LinkedList<PcepValueType> llSubObjects) {
- this.llSubObjects = llSubObjects;
- return this;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("SubObjects", llSubObjects)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepSrpObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepSrpObjectVer1.java
deleted file mode 100644
index ca0a317..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepSrpObjectVer1.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.onosproject.pcepio.types.PathSetupTypeTlv;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.onosproject.pcepio.types.SymbolicPathNameTlv;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP SRP obejct.
- */
-public class PcepSrpObjectVer1 implements PcepSrpObject {
-
- /*
- * ref : draft-ietf-pce-stateful-pce-10, section : 7.2
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Object-Class | OT |Res|P|I| Object Length (bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Flags |S|R|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | SRP-ID-number |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Optional TLVs //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- */
- private static final Logger log = LoggerFactory.getLogger(PcepSrpObjectVer1.class);
-
- public static final byte SRP_OBJ_TYPE = 1;
- public static final byte SRP_OBJ_CLASS = 33;
- public static final byte SRP_OBJECT_VERSION = 1;
- public static final short SRP_OBJ_MINIMUM_LENGTH = 12;
- public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
- public static final boolean FLAG_DEFAULT_VALUE = false;
-
- static final PcepObjectHeader DEFAULT_SRP_OBJECT_HEADER = new PcepObjectHeader(SRP_OBJ_CLASS, SRP_OBJ_TYPE,
- PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, SRP_OBJ_MINIMUM_LENGTH);
-
- private PcepObjectHeader srpObjHeader;
- private static int flags;
- private boolean bRFlag;
- private boolean bSFlag;
- private int srpId;
-
- //Optional TLV
- private LinkedList<PcepValueType> llOptionalTlv;
- public static final byte BBIT_SET = 1;
- public static final byte BBIT_RESET = 0;
-
- /**
- * Constructor to initialize member variables.
- *
- * @param srpObjHeader srp object header
- * @param bRFlag R flag
- * @param bSFlag S (sync) flag
- * @param srpID srp Id
- * @param llOptionalTlv list of optional tlv
- */
- public PcepSrpObjectVer1(PcepObjectHeader srpObjHeader, boolean bRFlag, boolean bSFlag, int srpID,
- LinkedList<PcepValueType> llOptionalTlv) {
-
- this.srpObjHeader = srpObjHeader;
- this.bRFlag = bRFlag;
- this.bSFlag = bSFlag;
- this.srpId = srpID;
- this.llOptionalTlv = llOptionalTlv;
- }
-
- /**
- * sets the SRP object header.
- *
- * @param obj srp object header
- */
- public void setSrpObjHeader(PcepObjectHeader obj) {
- this.srpObjHeader = obj;
- }
-
- @Override
- public void setSrpID(int srpID) {
- this.srpId = srpID;
- }
-
- @Override
- public void setRFlag(boolean bRFlag) {
- this.bRFlag = bRFlag;
- }
-
- @Override
- public void setSFlag(boolean bSFlag) {
- this.bSFlag = bSFlag;
- }
-
- /**
- * Returns SRP object header.
- *
- * @return srpObjHeader
- */
- public PcepObjectHeader getSrpObjHeader() {
- return this.srpObjHeader;
- }
-
- @Override
- public int getSrpID() {
- return this.srpId;
- }
-
- @Override
- public boolean getRFlag() {
- return this.bRFlag;
- }
-
- @Override
- public boolean getSFlag() {
- return this.bSFlag;
- }
-
- @Override
- public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
- this.llOptionalTlv = llOptionalTlv;
-
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.llOptionalTlv;
- }
-
- /**
- * Reads from channel buffer and returns instance of PCEP SRP object.
- *
- * @param cb of channel buffer.
- * @return PCEP SRP object
- * @throws PcepParseException when srp object is not received in channel buffer
- */
- public static PcepSrpObject read(ChannelBuffer cb) throws PcepParseException {
-
- log.debug("SrpObject::read");
- PcepObjectHeader srpObjHeader;
- boolean bRFlag;
- boolean bSFlag;
-
- int srpID;
- int flags;
- LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
-
- srpObjHeader = PcepObjectHeader.read(cb);
-
- if (srpObjHeader.getObjClass() != SRP_OBJ_CLASS) {
- throw new PcepParseException("SRP object expected. But received " + srpObjHeader.getObjClass());
- }
-
- //take only SrpObject buffer.
- ChannelBuffer tempCb = cb.readBytes(srpObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH);
- flags = tempCb.readInt();
- bRFlag = 0 < (flags & 0x1);
- bSFlag = 0 < ((flags >> 1) & 0x1);
- srpID = tempCb.readInt();
-
- llOptionalTlv = parseOptionalTlv(tempCb);
-
- return new PcepSrpObjectVer1(srpObjHeader, bRFlag, bSFlag, srpID, llOptionalTlv);
- }
-
- @Override
- public int write(ChannelBuffer cb) throws PcepParseException {
-
- int objStartIndex = cb.writerIndex();
-
- //write common header
- int objLenIndex = srpObjHeader.write(cb);
-
- //write Flags
- byte bFlag;
-
- bFlag = (bRFlag) ? BBIT_SET : BBIT_RESET;
- bFlag |= (((bSFlag) ? BBIT_SET : BBIT_RESET) << 1);
-
- cb.writeInt(bFlag);
-
- //write SrpId
- cb.writeInt(srpId);
-
- // Add optional TLV
- if (!packOptionalTlv(cb)) {
- throw new PcepParseException("Failed to write srp tlv to channel buffer.");
- }
-
- //now write SRP Object Length
- cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
-
- return cb.writerIndex();
- }
-
- /**
- * Parse Optional TLvs from the channel buffer.
- *
- * @param cb of type channel buffer
- * @return list of optional tlvs
- * @throws PcepParseException when unsupported tlv is received in srp object
- */
- public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
-
- LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<>();
-
- while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) {
-
- PcepValueType tlv;
- short hType = cb.readShort();
- short hLength = cb.readShort();
-
- switch (hType) {
- case SymbolicPathNameTlv.TYPE:
- if (cb.readableBytes() < hLength) {
- throw new PcepParseException("Length is not valid in SymbolicPathNameTlv");
- }
- tlv = SymbolicPathNameTlv.read(cb, hLength);
- break;
- case PathSetupTypeTlv.TYPE:
- if (cb.readableBytes() != PathSetupTypeTlv.LENGTH) {
- throw new PcepParseException("Length is not valid in PathSetupTypeTlv");
- }
- tlv = PathSetupTypeTlv.of(cb.readInt());
- break;
- default:
- // Skip the unknown TLV.
- cb.skipBytes(hLength);
- tlv = null;
- log.info("Received unsupported TLV type :" + hType + " in SRP object.");
- }
-
- // Check for the padding
- int pad = hLength % 4;
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= cb.readableBytes()) {
- cb.skipBytes(pad);
- }
- }
-
- if (tlv != null) {
- llOutOptionalTlv.add(tlv);
- }
- }
-
- return llOutOptionalTlv;
- }
-
- /**
- * Writes optional tlvs to channel buffer.
- *
- * @param cb of type channel buffer
- * @return true if writing optional tlv to channel buffer is success.
- */
- protected boolean packOptionalTlv(ChannelBuffer cb) {
-
- ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
-
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
-
- if (tlv == null) {
- log.debug("tlv is null from OptionalTlv list");
- continue;
- }
- tlv.write(cb);
-
- // need to take care of padding
- int pad = tlv.getLength() % 4;
-
- if (0 != pad) {
- pad = 4 - pad;
- for (int i = 0; i < pad; ++i) {
- cb.writeByte((byte) 0);
- }
- }
- }
-
- return true;
- }
-
- /**
- * Builder class for PCEP srp Object.
- */
- public static class Builder implements PcepSrpObject.Builder {
- private boolean bIsHeaderSet = false;
- private boolean bIsSrpIdset = false;
- private boolean bIsRFlagSet = false;
- private boolean bIsSFlagSet = false;
-
- private PcepObjectHeader srpObjHeader;
- private int srpId;
- private boolean bRFlag;
- private boolean bSFlag;
- LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
-
- private boolean bIsPFlagSet = false;
- private boolean bPFlag;
-
- private boolean bIsIFlagSet = false;
- private boolean bIFlag;
-
- @Override
- public PcepSrpObject build() throws PcepParseException {
- PcepObjectHeader srpObjHeader = this.bIsHeaderSet ? this.srpObjHeader : DEFAULT_SRP_OBJECT_HEADER;
-
- boolean bRFlag = this.bIsRFlagSet ? this.bRFlag : FLAG_DEFAULT_VALUE;
- boolean bSFlag = this.bIsSFlagSet ? this.bSFlag : FLAG_DEFAULT_VALUE;
-
- if (!this.bIsSrpIdset) {
- throw new PcepParseException("SrpID not set while building SRP Object.");
- }
-
- if (bIsPFlagSet) {
- srpObjHeader.setPFlag(bPFlag);
- }
-
- if (bIsIFlagSet) {
- srpObjHeader.setIFlag(bIFlag);
- }
-
- return new PcepSrpObjectVer1(srpObjHeader, bRFlag, bSFlag, this.srpId, this.llOptionalTlv);
- }
-
- @Override
- public PcepObjectHeader getSrpObjHeader() {
- return this.srpObjHeader;
- }
-
- @Override
- public Builder setSrpObjHeader(PcepObjectHeader obj) {
- this.srpObjHeader = obj;
- this.bIsHeaderSet = true;
- return this;
- }
-
- @Override
- public int getSrpID() {
- return this.srpId;
- }
-
- @Override
- public Builder setSrpID(int srpID) {
- this.srpId = srpID;
- this.bIsSrpIdset = true;
- return this;
- }
-
- @Override
- public boolean getRFlag() {
- return this.bRFlag;
- }
-
- @Override
- public Builder setRFlag(boolean bRFlag) {
- this.bRFlag = bRFlag;
- this.bIsRFlagSet = true;
- return this;
- }
-
- @Override
- public boolean getSFlag() {
- return this.bSFlag;
- }
-
- @Override
- public Builder setSFlag(boolean bSFlag) {
- this.bSFlag = bSFlag;
- this.bIsSFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
- this.llOptionalTlv = llOptionalTlv;
- return this;
- }
-
- @Override
- public LinkedList<PcepValueType> getOptionalTlv() {
- return this.llOptionalTlv;
- }
-
- @Override
- public Builder setPFlag(boolean value) {
- this.bPFlag = value;
- this.bIsPFlagSet = true;
- return this;
- }
-
- @Override
- public Builder setIFlag(boolean value) {
- this.bIFlag = value;
- this.bIsIFlagSet = true;
- return this;
- }
-
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("RFlag", bRFlag)
- .add("SFlag", bSFlag)
- .add("SRPID", srpId)
- .add("OptionalTlvList", llOptionalTlv)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepStateReportVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepStateReportVer1.java
deleted file mode 100644
index 4ebe8a8..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepStateReportVer1.java
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepAttribute;
-import org.onosproject.pcepio.protocol.PcepBandwidthObject;
-import org.onosproject.pcepio.protocol.PcepEroObject;
-import org.onosproject.pcepio.protocol.PcepLspObject;
-import org.onosproject.pcepio.protocol.PcepRroObject;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.onosproject.pcepio.protocol.PcepStateReport;
-import org.onosproject.pcepio.types.PcepObjectHeader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-
-/**
- * Provide the State Report for the Pcep Report Message.
- * Reference :PCE extensions for stateful draft-ietf-pce-stateful-pce-10.
- */
-public class PcepStateReportVer1 implements PcepStateReport {
- /*
- * <state-report> ::= [<SRP>]
- <LSP>
- <path>
- Where:
- <path> ::= <ERO><attribute-list>[<RRO>]
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepStateReport.class);
-
- public static final int OBJECT_HEADER_LENGTH = 4;
-
- /**
- * Provides PCEP Message path for report message.
- */
- public class PcepMsgPath implements PcepStateReport.PcepMsgPath {
-
- /*
- * <path> ::= <ERO><attribute-list>[<RRO>]
- */
-
- //PcepEroObject
- private PcepEroObject eroObj;
- private boolean isEroObjectSet;
- //PcepAttribute List
- private PcepAttribute attrList;
- private boolean isAttributeListSet;
- //PcepRroObject
- private PcepRroObject rroObj;
- private boolean isRroObjectSet;
- private PcepBandwidthObject bandwidth;
- private boolean isBandwidthObjectSet;
-
- /**
- * Constructor to reset the parameters.
- */
- public PcepMsgPath() {
- eroObj = null;
- attrList = null;
- rroObj = null;
- this.isEroObjectSet = false;
- this.isAttributeListSet = false;
- this.isRroObjectSet = false;
- this.isBandwidthObjectSet = false;
- }
-
- /**
- * Constructor to initialize the parameters from PCEP Message path.
- *
- * @param eroObj PCEP ERO Object
- * @param attrList PCEP Attribute
- * @param rroObj PCEP Rro Object
- * @param bandwidth PCEP bandwidth object
- */
- public PcepMsgPath(PcepEroObject eroObj, PcepAttribute attrList, PcepRroObject rroObj,
- PcepBandwidthObject bandwidth) {
-
- this.eroObj = eroObj;
- this.attrList = attrList;
- this.rroObj = rroObj;
- this.bandwidth = bandwidth;
- if (rroObj == null) {
- this.isRroObjectSet = false;
- } else {
- this.isRroObjectSet = true;
- }
- if (eroObj == null) {
- this.isEroObjectSet = false;
- } else {
- this.isEroObjectSet = true;
- }
- if (attrList == null) {
- this.isAttributeListSet = false;
- } else {
- this.isAttributeListSet = true;
- }
- if (bandwidth == null) {
- this.isBandwidthObjectSet = false;
- } else {
- this.isBandwidthObjectSet = true;
- }
- }
-
- /**
- * Returns PcepEroObject.
- *
- * @return eroObj PCEP ERO Object
- */
- @Override
- public PcepEroObject getEroObject() {
- return this.eroObj;
- }
-
- /**
- * Returns PCEP Attribute.
- *
- * @return attrList Attribute list
- */
- @Override
- public PcepAttribute getPcepAttribute() {
- return this.attrList;
- }
-
- /**
- * Returns PcepRroObject.
- *
- * @return rroObj PCEP RRO Object
- */
- @Override
- public PcepRroObject getRroObject() {
- return this.rroObj;
- }
-
- @Override
- public PcepBandwidthObject getBandwidthObject() {
- return this.bandwidth;
- }
-
- @Override
- public void setEroObject(PcepEroObject eroObj) {
- this.eroObj = eroObj;
- }
-
- @Override
- public void setPcepAttribute(PcepAttribute attrList) {
- this.attrList = attrList;
- }
-
- @Override
- public void setRroObject(PcepRroObject rroObj) {
- this.rroObj = rroObj;
- }
-
- @Override
- public void setBandwidthObject(PcepBandwidthObject bandwidth) {
- this.bandwidth = bandwidth;
- }
-
- /**
- * Reads all the Objects for PCEP Message Path.
- *
- * @param bb of type channel buffer
- * @return PCEP Message path
- * @throws PcepParseException when fails to read pcep message path
- */
- @Override
- public PcepMsgPath read(ChannelBuffer bb) throws PcepParseException {
-
- PcepEroObject eroObj;
- PcepAttribute attrList;
- PcepRroObject rroObj = null;
- PcepBandwidthObject bandwidth = null;
-
- eroObj = PcepEroObjectVer1.read(bb);
- attrList = PcepAttributeVer1.read(bb);
-
- boolean bBreakWhile = false;
- while (0 < bb.readableBytes()) {
-
- if (bb.readableBytes() < OBJECT_HEADER_LENGTH) {
- break;
- }
- bb.markReaderIndex();
- PcepObjectHeader tempObjHeader = PcepObjectHeader.read(bb);
- bb.resetReaderIndex();
- byte yObjClass = tempObjHeader.getObjClass();
-
- switch (yObjClass) {
- case PcepRroObjectVer1.RRO_OBJ_CLASS:
- rroObj = PcepRroObjectVer1.read(bb);
- break;
- case PcepInterLayerObjectVer1.INTER_LAYER_OBJ_CLASS:
- bb.skipBytes(tempObjHeader.getObjLen());
- break;
- case PcepBandwidthObjectVer1.BANDWIDTH_OBJ_CLASS:
- bandwidth = PcepBandwidthObjectVer1.read(bb);
- break;
- default:
- //Otherthan above objects handle those objects in caller.
- bBreakWhile = true;
- break;
- }
- if (bBreakWhile) {
- break;
- }
- }
- return new PcepMsgPath(eroObj, attrList, rroObj, bandwidth);
- }
-
- /**
- * Writes all the objects for PCEP message path.
- *
- * @param bb of type channel buffer.
- * @return object length index
- * @throws PcepParseException when fails to write to channel buffer
- */
- @Override
- public int write(ChannelBuffer bb) throws PcepParseException {
- int iLenStartIndex = bb.writerIndex();
-
- //write Object header
- if (this.isEroObjectSet) {
- this.eroObj.write(bb);
- } else {
- throw new PcepParseException("Ero object is not set in path");
- }
-
- if (this.isAttributeListSet) {
- this.attrList.write(bb);
- }
-
- // RRO is optional check and read
- if (this.isRroObjectSet) {
- this.rroObj.write(bb);
- // bandwidth should come along with RRO.
- if (this.isBandwidthObjectSet) {
- this.bandwidth.write(bb);
- }
- }
- return bb.writerIndex() - iLenStartIndex;
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- if (attrList != null) {
- toStrHelper.add("AttributeList", attrList);
- }
- if (rroObj instanceof PcepRroObjectVer1) {
- toStrHelper.add("RroObject", rroObj);
- }
- if (bandwidth instanceof PcepBandwidthObjectVer1) {
- toStrHelper.add("bandwidthObject", bandwidth);
- }
- return toStrHelper.toString();
- }
- }
-
- //SRP Object
- private PcepSrpObject srpObject;
- //LSP Object
- private PcepLspObject lspObject;
- //PcepMsgPath
- private PcepStateReport.PcepMsgPath msgPath;
-
- /**
- * Constructor to reset objects.
- */
- public PcepStateReportVer1() {
- this.srpObject = null;
- this.lspObject = null;
- this.msgPath = null;
- }
-
- public PcepStateReportVer1(PcepSrpObject srpObject, PcepLspObject lspObject, PcepStateReport.PcepMsgPath msgPath) {
- this.srpObject = srpObject;
- this.lspObject = lspObject;
- this.msgPath = msgPath;
- }
-
- @Override
- public PcepSrpObject getSrpObject() {
- return srpObject;
- }
-
- @Override
- public PcepLspObject getLspObject() {
- return lspObject;
- }
-
- @Override
- public PcepStateReport.PcepMsgPath getMsgPath() {
- return msgPath;
- }
-
- @Override
- public void setSrpObject(PcepSrpObject srpObj) {
- this.srpObject = srpObj;
- }
-
- @Override
- public void setLspObject(PcepLspObject lspObject) {
- this.lspObject = lspObject;
- }
-
- @Override
- public void setMsgPath(PcepStateReport.PcepMsgPath msgPath) {
- this.msgPath = msgPath;
- }
-
- /**
- * Builder class for PCEP state report.
- */
- public static class Builder implements PcepStateReport.Builder {
-
- private boolean bIsSrpObjectSet = false;
- private boolean bIsLspObjectSet = false;
- private boolean bIsPcepMsgPathSet = false;
-
- //PCEP SRP Object
- private PcepSrpObject srpObject;
- //PCEP LSP Object
- private PcepLspObject lspObject;
- //PCEP Attribute list
- private PcepStateReport.PcepMsgPath msgPath;
-
- @Override
- public PcepStateReport build() throws PcepParseException {
-
- //PCEP SRP Object
- PcepSrpObject srpObject = null;
- //PCEP LSP Object
- PcepLspObject lspObject = null;
- //PCEP Attribute list
- PcepStateReport.PcepMsgPath msgPath = null;
-
- if (this.bIsSrpObjectSet) {
- srpObject = this.srpObject;
- }
-
- if (!this.bIsLspObjectSet) {
- throw new PcepParseException(" LSP Object NOT Set while building PcepStateReport.");
- } else {
- lspObject = this.lspObject;
- }
- if (!this.bIsPcepMsgPathSet) {
- throw new PcepParseException(" Message Path NOT Set while building PcepStateReport.");
- } else {
- msgPath = this.msgPath;
- }
-
- return new PcepStateReportVer1(srpObject, lspObject, msgPath);
- }
-
- @Override
- public PcepSrpObject getSrpObject() {
- return this.srpObject;
- }
-
- @Override
- public PcepLspObject getLspObject() {
- return this.lspObject;
- }
-
- @Override
- public PcepStateReport.PcepMsgPath getMsgPath() {
- return this.msgPath;
- }
-
- @Override
- public Builder setSrpObject(PcepSrpObject srpobj) {
- this.srpObject = srpobj;
- this.bIsSrpObjectSet = true;
- return this;
- }
-
- @Override
- public Builder setLspObject(PcepLspObject lspObject) {
- this.lspObject = lspObject;
- this.bIsLspObjectSet = true;
- return this;
- }
-
- @Override
- public Builder setMsgPath(PcepStateReport.PcepMsgPath msgPath) {
- this.msgPath = msgPath;
- this.bIsPcepMsgPathSet = true;
- return this;
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("SrpObject", srpObject)
- .add("LspObject", lspObject)
- .add("MsgPath", msgPath)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateMsgVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateMsgVer1.java
deleted file mode 100644
index fdc6e1f..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateMsgVer1.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepLspObject;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepMessageWriter;
-import org.onosproject.pcepio.protocol.PcepMsgPath;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.onosproject.pcepio.protocol.PcepType;
-import org.onosproject.pcepio.protocol.PcepUpdateMsg;
-import org.onosproject.pcepio.protocol.PcepUpdateRequest;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP update message.
- */
-
-class PcepUpdateMsgVer1 implements PcepUpdateMsg {
-
- // Pcep version: 1
-
- /* The format of the PCUpd message is as follows:
- * <PCUpd Message> ::= <Common Header>
- * <update-request-list>
- * Where:
- * <update-request-list> ::= <update-request>[<update-request-list>]
- * <update-request> ::= <SRP>
- * <LSP>
- * <path>
- * Where:
- * <path> ::= <ERO><attribute-list>
- * Where:
- * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
- * where:
- * <attribute-list> ::=[<LSPA>]
- * [<BANDWIDTH>]
- * [<metric-list>]
- * [<IRO>]
- * <metric-list> ::=<METRIC>[<metric-list>]
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Ver | Flags | Message-Type | Message-Length |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * // UPDATE REQUEST LIST //
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- * Reference:Internet-Draft-PCEP Extensions-for-Stateful-PCE-10
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepUpdateMsgVer1.class);
-
- public static final byte PACKET_VERSION = 1;
- // UpdateMsgMinLength = SrpObjMinLentgh(12)+LspObjMinLength(8)+EroObjMinLength(12)+ CommonHeaderLength(4)
- public static final short PACKET_MINIMUM_LENGTH = 36;
- public static final PcepType MSG_TYPE = PcepType.UPDATE;
- //Update Request List
- private LinkedList<PcepUpdateRequest> llUpdateRequestList;
-
- public static final PcepUpdateMsgVer1.Reader READER = new Reader();
-
- /**
- * Reader reads UpdateMessage from the channel.
- */
- static class Reader implements PcepMessageReader<PcepUpdateMsg> {
-
- LinkedList<PcepUpdateRequest> llUpdateRequestList;
-
- @Override
- public PcepUpdateMsg readFrom(ChannelBuffer cb) throws PcepParseException {
-
- if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Readable bytes is less than update message minimum length");
- }
-
- llUpdateRequestList = new LinkedList<>();
-
- // fixed value property version == 1
- byte version = cb.readByte();
- version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
- if (version != PACKET_VERSION) {
- throw new PcepParseException("Wrong version. Expected=PcepVersion.PCEP_1(1), got=" + version);
- }
- // fixed value property type == 11
- byte type = cb.readByte();
- if (type != MSG_TYPE.getType()) {
- throw new PcepParseException("Wrong type. Expected=PcepType.UPDATE(11), got=" + type);
- }
- short length = cb.readShort();
- if (length < PACKET_MINIMUM_LENGTH) {
- throw new PcepParseException("Wrong length. Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: "
- + length);
- }
-
- log.debug("reading update message of length " + length);
-
- // parse Update Request list
- if (!parseUpdateRequestList(cb)) {
- throw new PcepParseException("parsing Update Request List Failed.");
- }
-
- return new PcepUpdateMsgVer1(llUpdateRequestList);
- }
-
- /**
- * Parse update request list.
- *
- * @param cb of type channel buffer
- * @return true after parsing Update Request List
- * @throws PcepParseException while parsing update request list from channel buffer
- */
- public boolean parseUpdateRequestList(ChannelBuffer cb) throws PcepParseException {
-
- /* <update-request-list>
- * Where:
- * <update-request-list> ::= <update-request>[<update-request-list>]
- * <update-request> ::= <SRP>
- * <LSP>
- * <path>
- * Where:
- * <path> ::= <ERO><attribute-list>
- * Where:
- * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
- */
-
- while (0 < cb.readableBytes()) {
-
- PcepUpdateRequest pceUpdateReq = new PcepUpdateRequestVer1();
-
- //Read SRP Object and Store it.
- PcepSrpObject srpObj;
- srpObj = PcepSrpObjectVer1.read(cb);
- pceUpdateReq.setSrpObject(srpObj);
-
- //Read LSP object and Store it.
- PcepLspObject lspObj;
- lspObj = PcepLspObjectVer1.read(cb);
- pceUpdateReq.setLspObject(lspObj);
-
- // Read Msg Path and store it.
- PcepMsgPath msgPath = new PcepMsgPathVer1().read(cb);
- pceUpdateReq.setMsgPath(msgPath);
-
- llUpdateRequestList.add(pceUpdateReq);
- }
- return true;
- }
- }
-
- /**
- * Constructor to initialize llUpdateRequestList.
- *
- * @param llUpdateRequestList list of PcepUpdateRequest.
- */
- PcepUpdateMsgVer1(LinkedList<PcepUpdateRequest> llUpdateRequestList) {
- this.llUpdateRequestList = llUpdateRequestList;
- }
-
- /**
- * Builder class for PCPE update message.
- */
- static class Builder implements PcepUpdateMsg.Builder {
-
- // PCEP report message fields
- LinkedList<PcepUpdateRequest> llUpdateRequestList;
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return PcepType.UPDATE;
- }
-
- @Override
- public PcepUpdateMsg build() {
- return new PcepUpdateMsgVer1(this.llUpdateRequestList);
- }
-
- @Override
- public LinkedList<PcepUpdateRequest> getUpdateRequestList() {
- return this.llUpdateRequestList;
- }
-
- @Override
- public Builder setUpdateRequestList(LinkedList<PcepUpdateRequest> llUpdateRequestList) {
- this.llUpdateRequestList = llUpdateRequestList;
- return this;
- }
-
- }
-
- @Override
- public void writeTo(ChannelBuffer cb) throws PcepParseException {
- WRITER.write(cb, this);
- }
-
- static final Writer WRITER = new Writer();
-
- /**
- * Writer writes UpdateMessage to the channel buffer.
- */
- static class Writer implements PcepMessageWriter<PcepUpdateMsgVer1> {
-
- @Override
- public void write(ChannelBuffer cb, PcepUpdateMsgVer1 message) throws PcepParseException {
-
- int startIndex = cb.writerIndex();
- // first 3 bits set to version
- cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
- // message type
- cb.writeByte(MSG_TYPE.getType());
- /* length is length of variable message, will be updated at the end
- * Store the position of message
- * length in buffer
- */
- int msgLenIndex = cb.writerIndex();
-
- cb.writeShort((short) 0);
- ListIterator<PcepUpdateRequest> listIterator = message.llUpdateRequestList.listIterator();
-
- while (listIterator.hasNext()) {
-
- PcepUpdateRequest updateReq = listIterator.next();
-
- //SRP object is mandatory
- PcepSrpObject srpObj = updateReq.getSrpObject();
- srpObj.write(cb);
-
- //LSP object is mandatory
- PcepLspObject lspObj = updateReq.getLspObject();
- lspObj.write(cb);
-
- //PATH object is mandatory
- PcepMsgPath msgPath = updateReq.getMsgPath();
- msgPath.write(cb);
- }
-
- // update message length field
- int length = cb.writerIndex() - startIndex;
- cb.setShort(msgLenIndex, (short) length);
- }
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public PcepType getType() {
- return MSG_TYPE;
- }
-
- @Override
- public LinkedList<PcepUpdateRequest> getUpdateRequestList() {
- return this.llUpdateRequestList;
- }
-
- @Override
- public void setUpdateRequestList(LinkedList<PcepUpdateRequest> llUpdateRequestList) {
- this.llUpdateRequestList = llUpdateRequestList;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("UpdateRequestList", llUpdateRequestList)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateRequestVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateRequestVer1.java
deleted file mode 100644
index 836b47d..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateRequestVer1.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.protocol.ver1;
-
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepLspObject;
-import org.onosproject.pcepio.protocol.PcepMsgPath;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.onosproject.pcepio.protocol.PcepUpdateRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP Update Request List.
- */
-public class PcepUpdateRequestVer1 implements PcepUpdateRequest {
-
- /* <update-request-list>
- * Where:
- * <update-request-list> ::= <update-request>[<update-request-list>]
- * <update-request> ::= <SRP>
- * <LSP>
- * <path>
- * Where:
- * <path> ::= <ERO><attribute-list>
- * Where:
- * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepUpdateRequestVer1.class);
-
- //PCEP SRP Object
- private PcepSrpObject srpObject;
- //PCEP LSP Object
- private PcepLspObject lspObject;
- //PCEP Message path
- private PcepMsgPath msgPath;
-
- /**
- * Default constructor.
- */
- public PcepUpdateRequestVer1() {
- srpObject = null;
- lspObject = null;
- msgPath = null;
- }
-
- /**
- * Constructor to initialize all member variables.
- *
- * @param srpObject srp object
- * @param lspObject lsp object
- * @param msgPath message path object
- */
- public PcepUpdateRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject, PcepMsgPath msgPath) {
- this.srpObject = srpObject;
- this.lspObject = lspObject;
- this.msgPath = msgPath;
- }
-
- @Override
- public PcepSrpObject getSrpObject() {
- return srpObject;
- }
-
- @Override
- public PcepLspObject getLspObject() {
- return lspObject;
- }
-
- @Override
- public PcepMsgPath getMsgPath() {
- return msgPath;
- }
-
- @Override
- public void setSrpObject(PcepSrpObject srpObject) {
- this.srpObject = srpObject;
-
- }
-
- @Override
- public void setLspObject(PcepLspObject lspObject) {
- this.lspObject = lspObject;
- }
-
- @Override
- public void setMsgPath(PcepMsgPath msgPath) {
- this.msgPath = msgPath;
- }
-
- /**
- * Builder class for PCEP update request.
- */
- public static class Builder implements PcepUpdateRequest.Builder {
-
- private boolean bIsSrpObjectSet = false;
- private boolean bIsLspObjectSet = false;
- private boolean bIsPcepMsgPathSet = false;
-
- //PCEP SRP Object
- private PcepSrpObject srpObject;
- //PCEP LSP Object
- private PcepLspObject lspObject;
- //PCEP Attribute list
- private PcepMsgPath msgPath;
-
- @Override
- public PcepUpdateRequest build() throws PcepParseException {
-
- //PCEP SRP Object
- PcepSrpObject srpObject = null;
- //PCEP LSP Object
- PcepLspObject lspObject = null;
- //PCEP Attribute list
- PcepMsgPath msgPath = null;
-
- if (!this.bIsSrpObjectSet) {
- throw new PcepParseException(" SRP Object NOT Set while building PcepUpdateRequest.");
- } else {
- srpObject = this.srpObject;
- }
- if (!this.bIsLspObjectSet) {
- throw new PcepParseException(" LSP Object NOT Set while building PcepUpdateRequest.");
- } else {
- lspObject = this.lspObject;
- }
- if (!this.bIsPcepMsgPathSet) {
- throw new PcepParseException(" Msg Path NOT Set while building PcepUpdateRequest.");
- } else {
- msgPath = this.msgPath;
- }
-
- return new PcepUpdateRequestVer1(srpObject, lspObject, msgPath);
- }
-
- @Override
- public PcepSrpObject getSrpObject() {
- return this.srpObject;
- }
-
- @Override
- public PcepLspObject getLspObject() {
- return this.lspObject;
- }
-
- @Override
- public PcepMsgPath getMsgPath() {
- return this.msgPath;
- }
-
- @Override
- public Builder setSrpObject(PcepSrpObject srpobj) {
- this.srpObject = srpobj;
- this.bIsSrpObjectSet = true;
- return this;
-
- }
-
- @Override
- public Builder setLspObject(PcepLspObject lspObject) {
- this.lspObject = lspObject;
- this.bIsLspObjectSet = true;
- return this;
- }
-
- @Override
- public Builder setMsgPath(PcepMsgPath msgPath) {
- this.msgPath = msgPath;
- this.bIsPcepMsgPathSet = true;
- return this;
- }
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("SrpObject", srpObject)
- .add("LspObject", lspObject)
- .add("MsgPath", msgPath)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/package-info.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/package-info.java
deleted file mode 100644
index b5bea04..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of PCEP messages.
- */
-package org.onosproject.pcepio.protocol.ver1;
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupSubTlv.java
deleted file mode 100644
index 373e5db..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupSubTlv.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Administrative Group Tlv which contains value (32 Bit ).
- */
-public class AdministrativeGroupSubTlv implements PcepValueType {
-
- /* REFERENCE :[RFC5305]/3.1
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TDB33] | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | value (32 Bit ) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(AdministrativeGroupSubTlv.class);
-
- public static final short TYPE = 22;
- public static final short LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue of Administrative-Group-Tlv.
- */
- public AdministrativeGroupSubTlv(int rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created AdministrativeGroupTlv object.
- *
- * @param raw value.
- * @return object of Administrative-Group-Tlv
- */
- public static AdministrativeGroupSubTlv of(final int raw) {
- return new AdministrativeGroupSubTlv(raw);
- }
-
- /**
- * Returns raw value.
- *
- * @return rawValue raw value
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof AdministrativeGroupSubTlv) {
- AdministrativeGroupSubTlv other = (AdministrativeGroupSubTlv) obj;
- return Objects.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of Administrative-Group-Tlv.
- *
- * @param c input channel buffer
- * @return object of Administrative-Group-Tlv
- */
- public static AdministrativeGroupSubTlv read(ChannelBuffer c) {
- return AdministrativeGroupSubTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemNumberSubObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemNumberSubObject.java
deleted file mode 100644
index 9bf392d..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemNumberSubObject.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author b00295750
- *
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Autonomous system number sub object.
- */
-public class AutonomousSystemNumberSubObject implements PcepValueType {
-
- /*Reference : RFC 3209 : 4.3.3.4
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |L| Type | Length | AS number (2-octet) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
- private static final Logger log = LoggerFactory.getLogger(AutonomousSystemNumberSubObject.class);
-
- public static final byte TYPE = (byte) 0x32;
- public static final byte LENGTH = 4;
- public static final byte VALUE_LENGTH = 2;
- public static final byte OBJ_LENGTH = 4;
- public static final byte LBIT = 0;
- public static final int SHIFT_LBIT_POSITION = 7;
- private short asNumber;
-
- /**
- * Constructor to initialize AS number.
- *
- * @param asNumber AS number
- */
- public AutonomousSystemNumberSubObject(short asNumber) {
- this.asNumber = asNumber;
- }
-
- /**
- * Returns a new instance of AutonomousSystemNumberSubObject.
- *
- * @param asNumber AS number
- * @return object of AutonomousSystemNumberSubObject
- */
- public static AutonomousSystemNumberSubObject of(short asNumber) {
- return new AutonomousSystemNumberSubObject(asNumber);
- }
-
- /**
- * Returns value of AS number.
- *
- * @return value of AS number
- */
- public short getAsNumber() {
- return asNumber;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(asNumber);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof AutonomousSystemNumberSubObject) {
- AutonomousSystemNumberSubObject other = (AutonomousSystemNumberSubObject) obj;
- return Objects.equals(this.asNumber, other.asNumber);
- }
- return false;
- }
-
- /**
- * Reads the channel buffer and returns object of AutonomousSystemNumberSubObject.
- *
- * @param c type of channel buffer
- * @return object of AutonomousSystemNumberSubObject
- */
- public static PcepValueType read(ChannelBuffer c) {
- short asNumber = c.readShort();
- return new AutonomousSystemNumberSubObject(asNumber);
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- byte bValue = LBIT;
- bValue = (byte) (bValue << SHIFT_LBIT_POSITION);
- bValue = (byte) (bValue | TYPE);
- c.writeByte(bValue);
- c.writeByte(OBJ_LENGTH);
- c.writeShort(asNumber);
-
- return c.writerIndex() - iLenStartIndex;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("AsNumber", asNumber)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemSubTlv.java
deleted file mode 100644
index 7d50842..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemSubTlv.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Autonomous-System-Tlv which contains opaque value (32 Bit AS Number).
- */
-public class AutonomousSystemSubTlv implements PcepValueType {
-
- /* Reference :RFC3209
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD10] | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | opaque value (32 Bit AS Number) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(AutonomousSystemSubTlv.class);
-
- public static final short TYPE = 1;
- public static final short LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue Autonomous-System-Tlv
- */
- public AutonomousSystemSubTlv(int rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created AutonomousSystemTlv object.
- *
- * @param raw value of opaque.
- * @return object of Autonomous-System-Tlv
- */
- public static AutonomousSystemSubTlv of(final int raw) {
- return new AutonomousSystemSubTlv(raw);
- }
-
- /**
- * Returns opaque value.
- *
- * @return rawValue opaque value.
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof AutonomousSystemSubTlv) {
- AutonomousSystemSubTlv other = (AutonomousSystemSubTlv) obj;
- return Objects.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of AutonomousSystemTlv.
- *
- * @param c input channel buffer
- * @return object of Autonomous-System-Tlv
- */
- public static AutonomousSystemSubTlv read(ChannelBuffer c) {
- return AutonomousSystemSubTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("TYPE", TYPE)
- .add("Length", LENGTH)
- .add("value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BgpLsIdentifierSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BgpLsIdentifierSubTlv.java
deleted file mode 100644
index a36e846..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BgpLsIdentifierSubTlv.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides BGP LS identifier which contains opaque value (32 Bit ID).
- */
-public class BgpLsIdentifierSubTlv implements PcepValueType {
-
- /* Reference :draft-ietf-idr-ls-distribution-10
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD11] | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | opaque value (32 Bit ID). |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(BgpLsIdentifierSubTlv.class);
-
- public static final short TYPE = 2;
- public static final short LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * constructor to initialize rawValue.
- *
- * @param rawValue BGP LS identifier Tlv
- */
- public BgpLsIdentifierSubTlv(int rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created BGPLSidentifierTlv object.
- *
- * @param raw value
- * @return object of BGPLSidentifierTlv
- */
- public static BgpLsIdentifierSubTlv of(final int raw) {
- return new BgpLsIdentifierSubTlv(raw);
- }
-
- /**
- * Returns opaque value.
- *
- * @return rawValue opaque value
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof BgpLsIdentifierSubTlv) {
- BgpLsIdentifierSubTlv other = (BgpLsIdentifierSubTlv) obj;
- return Objects.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of BGPLSidentifierTlv.
- *
- * @param c input channel buffer
- * @return object of BGP LS identifier Tlv
- */
- public static BgpLsIdentifierSubTlv read(ChannelBuffer c) {
- return BgpLsIdentifierSubTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java
deleted file mode 100644
index 1876215..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepErrorObject;
-import org.onosproject.pcepio.protocol.PcepOpenObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provide the error object list with open object.
- */
-public class ErrorObjListWithOpen {
- //errorObjList is mandatory
- private List<PcepErrorObject> llerrorObjList;
- // openObject is optional
- private PcepOpenObject openObject;
- // flag to check if open object is set or not
- private boolean isOpenObjectSet;
- private static final Logger log = LoggerFactory.getLogger(ErrorObjListWithOpen.class);
-
- /**
- * Constructor to initialize Error and OPEN object.
- *
- * @param errObj ERROR object list
- * @param openObj OPEN object
- */
- public ErrorObjListWithOpen(List<PcepErrorObject> errObj, PcepOpenObject openObj) {
- this.llerrorObjList = errObj;
- this.openObject = openObj;
- if (openObj != null) {
- isOpenObjectSet = true;
- } else {
- isOpenObjectSet = false;
- }
- }
-
- /**
- * Constructor to initialize ERROR Object.
- *
- * @param errObj ERROR Object list
- */
- public ErrorObjListWithOpen(List<PcepErrorObject> errObj) {
- this.llerrorObjList = errObj;
- this.openObject = null;
- isOpenObjectSet = false;
- }
-
- /**
- * Return list of Error Types.
- *
- * @return error types list
- */
- public List<Integer> getErrorType() {
- List<Integer> errorType = new LinkedList<>();
- if (llerrorObjList != null) {
- ListIterator<PcepErrorObject> errObjListIterator = llerrorObjList.listIterator();
- int error;
- PcepErrorObject errorObj;
- while (errObjListIterator.hasNext()) {
- errorObj = errObjListIterator.next();
- error = errorObj.getErrorType();
- errorType.add(error);
- }
- }
- return errorType;
- }
-
- /**
- * Return list of Error Values.
- *
- * @return error values list
- */
- public List<Integer> getErrorValue() {
- List<Integer> errorValue = new LinkedList<>();
- if (llerrorObjList != null) {
- ListIterator<PcepErrorObject> errObjListIterator = llerrorObjList.listIterator();
- int error;
- PcepErrorObject errorObj;
- while (errObjListIterator.hasNext()) {
- errorObj = errObjListIterator.next();
- error = errorObj.getErrorValue();
- errorValue.add(error);
- }
- }
- return errorValue;
- }
-
- /**
- * Checks whether ERROR Object list is empty or not.
- *
- * @return true if ERROR Object list is empty otherwise false
- */
- public boolean isErrorObjListWithOpenPresent() {
- // ( <error-obj-list> [<Open>]
- // At least in this case <error-obj-list> should be present.
- return !this.llerrorObjList.isEmpty();
- }
-
- /**
- * Write Error Object List and Open Object to channel buffer.
- *
- * @param cb output channel buffer
- * @return length of written Error object list with open
- * @throws PcepParseException when mandatory fields are not set
- */
- public int write(ChannelBuffer cb) throws PcepParseException {
- int iLenStartIndex = cb.writerIndex();
- boolean bIsErrObjListFound = false;
-
- //<error-obj-list> is mandatory , if not present throw exception.
- if (llerrorObjList != null) {
- ListIterator<PcepErrorObject> errObjListIterator = llerrorObjList.listIterator();
- while (errObjListIterator.hasNext()) {
- errObjListIterator.next().write(cb);
- bIsErrObjListFound = true;
- }
- }
-
- if (!bIsErrObjListFound) {
- throw new PcepParseException("<error-obj-list> is mandatory.");
- }
-
- //Open Object is optional , if present write.
- if (openObject != null) {
- openObject.write(cb);
- }
-
- return cb.writerIndex() - iLenStartIndex;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("ErrorObjList", llerrorObjList)
- .add("Open", openObject)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java
deleted file mode 100644
index 2125185..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides GMPLS Capability Tlv.
- */
-public class GmplsCapabilityTlv implements PcepValueType {
-
- /*
- * GMPLS-CAPABILITY TLV format
- * reference :draft-ietf-pce-gmpls-pcep-extensions -2.1.1
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=14 | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Flags |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
- private static final Logger log = LoggerFactory.getLogger(GmplsCapabilityTlv.class);
-
- public static final short TYPE = 14;
- public static final short LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * Constructor to initialize raw value.
- *
- * @param rawValue of Gmpls-Capability-Tlv
- */
- public GmplsCapabilityTlv(int rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created GmplsCapabilityTlv object.
- *
- * @param raw Flags value
- * @return object of Gmpls-Capability-Tlv
- */
- public static GmplsCapabilityTlv of(final int raw) {
- return new GmplsCapabilityTlv(raw);
- }
-
- /**
- * Returns value of Flags.
- *
- * @return rawValue Flags
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof GmplsCapabilityTlv) {
- GmplsCapabilityTlv other = (GmplsCapabilityTlv) obj;
- return Objects.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of Gmpls-Capability-Tlv.
- *
- * @param c input channel buffer
- * @return object of Gmpls-Capability-Tlv
- */
- public static GmplsCapabilityTlv read(ChannelBuffer c) {
- return GmplsCapabilityTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressSubTlv.java
deleted file mode 100644
index 3821daa..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressSubTlv.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides IPv4 Interface Address .
- */
-public class IPv4InterfaceAddressSubTlv implements PcepValueType {
-
- /*
- * reference :[RFC5305]/3.2
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=6 | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv4 Interface Address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(IPv4InterfaceAddressSubTlv.class);
-
- public static final short TYPE = 7;
- public static final short LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue of IPv4-Interface-Address.
- */
- public IPv4InterfaceAddressSubTlv(int rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created IPv4InterfaceAddressTlv object.
- *
- * @param raw value of IPv4-Interface-Address
- * @return object of IPv4-Interface-Address-Tlv
- */
- public static IPv4InterfaceAddressSubTlv of(final int raw) {
- return new IPv4InterfaceAddressSubTlv(raw);
- }
-
- /**
- * Returns value of IPv4 Interface Address.
- *
- * @return rawValue IPv4 Interface Address
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IPv4InterfaceAddressSubTlv) {
- IPv4InterfaceAddressSubTlv other = (IPv4InterfaceAddressSubTlv) obj;
- return Objects.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IPv4InterfaceAddressTlv.
- *
- * @param c input channel buffer
- * @return object of IPv4-Interface-Address-Tlv
- */
- public static IPv4InterfaceAddressSubTlv read(ChannelBuffer c) {
- return IPv4InterfaceAddressSubTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressSubTlv.java
deleted file mode 100644
index 1142209..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressSubTlv.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides IPv4 Neighbor Address .
- */
-public class IPv4NeighborAddressSubTlv implements PcepValueType {
-
- /* Reference :[RFC5305]/3.3
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=8 | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv4 Neighbor Address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(IPv4NeighborAddressSubTlv.class);
-
- public static final short TYPE = 8;
- public static final short LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue IPv4-Neighbor-Address-Tlv
- */
- public IPv4NeighborAddressSubTlv(int rawValue) {
- log.debug("IPv4NeighborAddressTlv");
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created IPv4NeighborAddressTlv object.
- *
- * @param raw value of IPv4-Neighbor-Address
- * @return object of IPv4NeighborAddressTlv
- */
- public static IPv4NeighborAddressSubTlv of(final int raw) {
- return new IPv4NeighborAddressSubTlv(raw);
- }
-
- /**
- * Returns value of IPv4 Neighbor Address.
- *
- * @return rawValue IPv4 Neighbor Address
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IPv4NeighborAddressSubTlv) {
- IPv4NeighborAddressSubTlv other = (IPv4NeighborAddressSubTlv) obj;
- return Objects.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IPv4-Neighbor-Address-Tlv.
- *
- * @param c input channel buffer
- * @return object of IPv4-Neighbor-Address-Tlv
- */
- public static IPv4NeighborAddressSubTlv read(ChannelBuffer c) {
- return IPv4NeighborAddressSubTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4RouterIdOfLocalNodeSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4RouterIdOfLocalNodeSubTlv.java
deleted file mode 100644
index 81b48d0..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4RouterIdOfLocalNodeSubTlv.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides IPv4 Router Id Of Local Node.
- */
-public class IPv4RouterIdOfLocalNodeSubTlv implements PcepValueType {
-
- /* Reference:[RFC5305]/4.3
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TDB25] | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv4 Router Id Of Local Node |
- +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
- */
-
- private static final Logger log = LoggerFactory.getLogger(IPv4RouterIdOfLocalNodeSubTlv.class);
-
- public static final short TYPE = 17;
- public static final short LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue IPv4-RouterId-Of-Local-Node-Tlv
- */
- public IPv4RouterIdOfLocalNodeSubTlv(int rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created IPv4RouterIdOfLocalNodeTlv object.
- *
- * @param raw value of IPv4-RouterId-Of-Local-Node
- * @return object of IPv4RouterIdOfLocalNodeTlv
- */
- public static IPv4RouterIdOfLocalNodeSubTlv of(final int raw) {
- return new IPv4RouterIdOfLocalNodeSubTlv(raw);
- }
-
- /**
- * Returns value of IPv4 Router Id Of Local Node.
- *
- * @return rawValue IPv4 Router Id Of Local Node
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IPv4RouterIdOfLocalNodeSubTlv) {
- IPv4RouterIdOfLocalNodeSubTlv other = (IPv4RouterIdOfLocalNodeSubTlv) obj;
- return Objects.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IPv4RouterIdOfLocalNodeTlv.
- *
- * @param c input channel buffer
- * @return object of IPv4RouterIdOfLocalNodeTlv
- */
- public static IPv4RouterIdOfLocalNodeSubTlv read(ChannelBuffer c) {
- return IPv4RouterIdOfLocalNodeSubTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4RouterIdOfRemoteNodeSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4RouterIdOfRemoteNodeSubTlv.java
deleted file mode 100644
index f5b6daa..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4RouterIdOfRemoteNodeSubTlv.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides IPv4 Router Id Of Remote Node.
- */
-public class IPv4RouterIdOfRemoteNodeSubTlv implements PcepValueType {
-
- /* Reference :[RFC5305]/4.3
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TDB28] | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv4 Router Id Of Remote Node |
- +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
- */
-
- private static final Logger log = LoggerFactory.getLogger(IPv4RouterIdOfRemoteNodeSubTlv.class);
-
- public static final short TYPE = 19;
- public static final short LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue IPv4 RouterId Of Remote Node Tlv
- */
- public IPv4RouterIdOfRemoteNodeSubTlv(int rawValue) {
- log.debug("IPv4RouterIdOfRemoteNodeTlv");
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created IPv4RouterIdOfRemoteNodeTlv object.
- *
- * @param raw IPv4 RouterId Of Remote Node
- * @return object of IPv4RouterIdOfRemoteNodeTlv
- */
- public static IPv4RouterIdOfRemoteNodeSubTlv of(final int raw) {
- return new IPv4RouterIdOfRemoteNodeSubTlv(raw);
- }
-
- /**
- * Returns value of IPv4 Router Id Of Remote Node.
- *
- * @return rawValue IPv4 Router Id Of Remote Node
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IPv4RouterIdOfRemoteNodeSubTlv) {
- IPv4RouterIdOfRemoteNodeSubTlv other = (IPv4RouterIdOfRemoteNodeSubTlv) obj;
- return Objects.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IPv4RouterIdOfRemoteNodeTlv.
- *
- * @param c input channel buffer
- * @return object of IPv4RouterIdOfRemoteNodeTlv
- */
- public static IPv4RouterIdOfRemoteNodeSubTlv read(ChannelBuffer c) {
- return IPv4RouterIdOfRemoteNodeSubTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4SubObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4SubObject.java
deleted file mode 100644
index 45fa2b3..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4SubObject.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author b00295750
- *
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides IPv4 Sub Object.
- */
-public class IPv4SubObject implements PcepValueType {
-
- /*Reference : RFC 4874:3.1.1
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |L| Type | Length | IPv4 address (4 bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv4 address (continued) | Prefix Length | Resvd |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
- private static final Logger log = LoggerFactory.getLogger(IPv4SubObject.class);
-
- public static final byte TYPE = 0x01;
- public static final byte LENGTH = 8;
- public static final byte VALUE_LENGTH = 6;
- public static final byte OBJ_LENGTH = 8;
- public static final byte LBIT = 0;
- public static final int SHIFT_LBIT_POSITION = 7;
- private int ipAddress;
- private byte prefixLen;
- private byte resvd;
-
- /**
- * Constructor to initialize ipv4 address.
- *
- * @param ipAddr ipv4 address
- */
- public IPv4SubObject(int ipAddr) {
- this.ipAddress = ipAddr;
- }
-
- /**
- * constructor to initialize ipAddress, prefixLen and resvd.
- *
- * @param ipAddress ipv4 address
- * @param prefixLen prefix length
- * @param resvd reserved flags value
- */
- public IPv4SubObject(int ipAddress, byte prefixLen, byte resvd) {
- this.ipAddress = ipAddress;
- this.prefixLen = prefixLen;
- this.resvd = resvd;
- }
-
- /**
- * Returns a new instance of IPv4SubObject.
- *
- * @param ipAddress ipv4 address
- * @param prefixLen prefix length
- * @param resvd reserved flags value
- * @return object of IPv4SubObject
- */
- public static IPv4SubObject of(int ipAddress, byte prefixLen, byte resvd) {
- return new IPv4SubObject(ipAddress, prefixLen, resvd);
- }
-
- /**
- * Returns prefixLen of IPv4 IP address.
- *
- * @return byte value of rawValue
- */
- public byte getPrefixLen() {
- return prefixLen;
- }
-
- /**
- * Returns value of IPv4 IP address.
- *
- * @return int value of ipv4 address
- */
- public int getIpAddress() {
- return ipAddress;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(ipAddress, prefixLen, resvd);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IPv4SubObject) {
- IPv4SubObject other = (IPv4SubObject) obj;
- return Objects.equals(this.ipAddress, other.ipAddress) && Objects.equals(this.prefixLen, other.prefixLen)
- && Objects.equals(this.resvd, other.resvd);
- }
- return false;
- }
-
- /**
- * Reads the channel buffer and returns object of IPv4SubObject.
- *
- * @param c type of channel buffer
- * @return object of IPv4SubObject
- */
- public static PcepValueType read(ChannelBuffer c) {
- int ipAddess = c.readInt();
- byte prefixLen = c.readByte();
- byte resvd = c.readByte();
- return new IPv4SubObject(ipAddess, prefixLen, resvd);
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- byte bValue = LBIT;
- bValue = (byte) (bValue << SHIFT_LBIT_POSITION);
- bValue = (byte) (bValue | TYPE);
- c.writeByte(bValue);
- c.writeByte(OBJ_LENGTH);
- c.writeInt(ipAddress);
- c.writeByte(prefixLen);
- c.writeByte(resvd);
-
- return c.writerIndex() - iLenStartIndex;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("IPv4Address", ipAddress)
- .add("PrefixLength", prefixLen)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6InterfaceAddressSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6InterfaceAddressSubTlv.java
deleted file mode 100644
index d318ca3..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6InterfaceAddressSubTlv.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-
-/**
- * Provides IPv6 Interface Address. REFERENCE :[RFC6119]/4.2.
- */
-public class IPv6InterfaceAddressSubTlv implements PcepValueType {
-
- private static final Logger log = LoggerFactory.getLogger(IPv6InterfaceAddressSubTlv.class);
-
- public static final short TYPE = 9;
- public static final short LENGTH = 20;
- public static final byte VALUE_LENGTH = 18;
-
- private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- public static final IPv6InterfaceAddressSubTlv NONE = new IPv6InterfaceAddressSubTlv(NONE_VAL);
-
- private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
- public static final IPv6InterfaceAddressSubTlv NO_MASK = new IPv6InterfaceAddressSubTlv(NO_MASK_VAL);
- public static final IPv6InterfaceAddressSubTlv FULL_MASK = NONE;
-
- private final byte[] rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue IPv6 Interface Address Tlv
- */
- public IPv6InterfaceAddressSubTlv(byte[] rawValue) {
- log.debug("IPv6InterfaceAddressTlv");
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created IPv6InterfaceAddressTlv object.
- *
- * @param raw IPv6 Interface Address
- * @return object of IPv6InterfaceAddressTlv
- */
- public static IPv6InterfaceAddressSubTlv of(final byte[] raw) {
- //check NONE_VAL
- boolean bFoundNone = true;
- //value starts from 3rd byte.
- for (int i = 2; i < 20; ++i) {
- if (NONE_VAL[i] != raw[i]) {
- bFoundNone = false;
- }
- }
-
- if (bFoundNone) {
- return NONE;
- }
-
- //check NO_MASK_VAL
- boolean bFoundNoMask = true;
- //value starts from 3rd byte.
- for (int i = 2; i < 20; ++i) {
- if ((byte) 0xFF != raw[i]) {
- bFoundNoMask = false;
- }
- }
- if (bFoundNoMask) {
- return NO_MASK;
- }
-
- return new IPv6InterfaceAddressSubTlv(raw);
- }
-
- /**
- * Returns value of IPv6 Interface Address.
- *
- * @return rawValue raw value
- */
- public byte[] getBytes() {
- return rawValue;
- }
-
- /**
- * Returns value of IPv6 Interface Address.
- *
- * @return rawValue raw value
- */
- public byte[] getValue() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IPv6InterfaceAddressSubTlv) {
- IPv6InterfaceAddressSubTlv other = (IPv6InterfaceAddressSubTlv) obj;
- return Arrays.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeBytes(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IPv6InterfaceAddressTlv.
- *
- * @param c input channel buffer
- * @return object of IPv6InterfaceAddressTlv
- */
- public static IPv6InterfaceAddressSubTlv read20Bytes(ChannelBuffer c) {
- byte[] yTemp = new byte[20];
- c.readBytes(yTemp, 0, 20);
- return IPv6InterfaceAddressSubTlv.of(yTemp);
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- toStrHelper.add("Type", TYPE);
- toStrHelper.add("Length", LENGTH);
-
- StringBuffer result = new StringBuffer();
- for (byte b : rawValue) {
- result.append(String.format("%02X ", b));
- }
- toStrHelper.add("Value", result);
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6NeighborAddressSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6NeighborAddressSubTlv.java
deleted file mode 100644
index 7b2f5e5..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6NeighborAddressSubTlv.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-
-/**
- * Provides IPv6 Neighbor Address. Reference :[RFC6119]/4.3.
- */
-public class IPv6NeighborAddressSubTlv implements PcepValueType {
- private static final Logger log = LoggerFactory.getLogger(IPv6NeighborAddressSubTlv.class);
-
- public static final short TYPE = 10;
- public static final short LENGTH = 20;
- public static final byte VALUE_LENGTH = 18;
-
- private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- public static final IPv6NeighborAddressSubTlv NONE = new IPv6NeighborAddressSubTlv(NONE_VAL);
-
- private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
- public static final IPv6NeighborAddressSubTlv NO_MASK = new IPv6NeighborAddressSubTlv(NO_MASK_VAL);
- public static final IPv6NeighborAddressSubTlv FULL_MASK = NONE;
-
- private final byte[] rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue IPv6 Neighbor Address Tlv
- */
- public IPv6NeighborAddressSubTlv(byte[] rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created IPv6NeighborAddressTlv object.
- *
- * @param raw IPv6 Neighbor Address
- * @return object of IPv6 Neighbor Address Tlv
- */
- public static IPv6NeighborAddressSubTlv of(final byte[] raw) {
- //check NONE_VAL
- boolean bFoundNone = true;
- //value starts from 3rd byte.
- for (int i = 2; i < 20; ++i) {
- if (NONE_VAL[i] != raw[i]) {
- bFoundNone = false;
- }
- }
-
- if (bFoundNone) {
- return NONE;
- }
-
- //check NO_MASK_VAL
- boolean bFoundNoMask = true;
- //value starts from 3rd byte.
- for (int i = 2; i < 20; ++i) {
- if ((byte) 0xFF != raw[i]) {
- bFoundNoMask = false;
- }
- }
- if (bFoundNoMask) {
- return NO_MASK;
- }
-
- return new IPv6NeighborAddressSubTlv(raw);
- }
-
- /**
- * Returns value of IPv6 Neighbor Address.
- *
- * @return rawValue raw value
- */
- public byte[] getBytes() {
- return rawValue;
- }
-
- /**
- * Returns value of IPv6 Neighbor Address.
- *
- * @return rawValue raw value
- */
- public byte[] getValue() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IPv6NeighborAddressSubTlv) {
- IPv6NeighborAddressSubTlv other = (IPv6NeighborAddressSubTlv) obj;
- return Arrays.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeBytes(rawValue);
- return c.writerIndex() - iStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IPv6NeighborAddressTlv.
- *
- * @param c input channel buffer
- * @return object of IPv6NeighborAddressTlv
- */
- public static IPv6NeighborAddressSubTlv read20Bytes(ChannelBuffer c) {
- byte[] yTemp = new byte[20];
- c.readBytes(yTemp, 0, 20);
- return IPv6NeighborAddressSubTlv.of(yTemp);
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- toStrHelper.add("Type", TYPE);
- toStrHelper.add("Length", LENGTH);
-
- StringBuffer result = new StringBuffer();
- for (byte b : rawValue) {
- result.append(String.format("%02X ", b));
- }
- toStrHelper.add("Value", result);
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6RouterIdofLocalNodeSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6RouterIdofLocalNodeSubTlv.java
deleted file mode 100644
index 186f56d..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6RouterIdofLocalNodeSubTlv.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-
-/**
- * Provides IPv6 TE Router Id of Local Node. Reference :[RFC6119]/4.1.
- */
-public class IPv6RouterIdofLocalNodeSubTlv implements PcepValueType {
- private static final Logger log = LoggerFactory.getLogger(IPv6RouterIdofLocalNodeSubTlv.class);
-
- public static final short TYPE = 18;
- public static final short LENGTH = 20;
- public static final byte VALUE_LENGTH = 18;
-
- private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- public static final IPv6RouterIdofLocalNodeSubTlv NONE = new IPv6RouterIdofLocalNodeSubTlv(NONE_VAL);
-
- private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
- public static final IPv6RouterIdofLocalNodeSubTlv NO_MASK = new IPv6RouterIdofLocalNodeSubTlv(NO_MASK_VAL);
- public static final IPv6RouterIdofLocalNodeSubTlv FULL_MASK = NONE;
-
- private final byte[] rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue IPv6RouterIdofLocalNodeTlv
- */
- public IPv6RouterIdofLocalNodeSubTlv(byte[] rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created IPv6RouterIdofLocalNodeTlv object.
- *
- * @param raw IPv6 TE Router Id of Local Node
- * @return object of IPv6RouterIdofLocalNodeTlv
- */
- public static IPv6RouterIdofLocalNodeSubTlv of(final byte[] raw) {
- //check NONE_VAL
- boolean bFoundNone = true;
- //value starts from 3rd byte.
- for (int i = 2; i < 20; ++i) {
- if (NONE_VAL[i] != raw[i]) {
- bFoundNone = false;
- }
- }
-
- if (bFoundNone) {
- return NONE;
- }
-
- //check NO_MASK_VAL
- boolean bFoundNoMask = true;
- //value starts from 3rd byte.
- for (int i = 2; i < 20; ++i) {
- if ((byte) 0xFF != raw[i]) {
- bFoundNoMask = false;
- }
- }
- if (bFoundNoMask) {
- return NO_MASK;
- }
-
- return new IPv6RouterIdofLocalNodeSubTlv(raw);
- }
-
- /**
- * Returns value of IPv6 TE Router Id of Local Node.
- *
- * @return byte array value of rawValue
- */
- public byte[] getBytes() {
- return rawValue;
- }
-
- /**
- * Returns value of IPv6 TE Router Id of Local Node.
- *
- * @return byte array value of rawValue
- */
- public byte[] getValue() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IPv6RouterIdofLocalNodeSubTlv) {
- IPv6RouterIdofLocalNodeSubTlv other = (IPv6RouterIdofLocalNodeSubTlv) obj;
- return Arrays.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeBytes(rawValue);
- return c.writerIndex() - iStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IPv6RouterIdofLocalNodeTlv.
- *
- * @param c input channel buffer
- * @return object of IPv6RouterIdofLocalNodeTlv
- */
- public static IPv6RouterIdofLocalNodeSubTlv read20Bytes(ChannelBuffer c) {
- byte[] yTemp = new byte[20];
- c.readBytes(yTemp, 0, 20);
- return IPv6RouterIdofLocalNodeSubTlv.of(yTemp);
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- toStrHelper.add("Type", TYPE);
- toStrHelper.add("Length", LENGTH);
-
- StringBuffer result = new StringBuffer();
- for (byte b : rawValue) {
- result.append(String.format("%02X ", b));
- }
- toStrHelper.add("Value", result);
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6RouterIdofRemoteNodeSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6RouterIdofRemoteNodeSubTlv.java
deleted file mode 100644
index 021da71..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6RouterIdofRemoteNodeSubTlv.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-
-/**
- * Provides IPv6 TE Router Id of Remote Node. Reference :[RFC6119]/4.1.
- */
-public class IPv6RouterIdofRemoteNodeSubTlv implements PcepValueType {
- private static final Logger log = LoggerFactory.getLogger(IPv6RouterIdofRemoteNodeSubTlv.class);
-
- public static final short TYPE = 20;
- public static final short LENGTH = 20;
- public static final byte VALUE_LENGTH = 18;
-
- private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- public static final IPv6RouterIdofRemoteNodeSubTlv NONE = new IPv6RouterIdofRemoteNodeSubTlv(NONE_VAL);
-
- private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
- public static final IPv6RouterIdofRemoteNodeSubTlv NO_MASK = new IPv6RouterIdofRemoteNodeSubTlv(NO_MASK_VAL);
- public static final IPv6RouterIdofRemoteNodeSubTlv FULL_MASK = NONE;
-
- private final byte[] rawValue;
-
- /**
- * constructor to initialize rawValue.
- *
- * @param rawValue IPv6RouterIdofRemoteNodeTlv
- */
- public IPv6RouterIdofRemoteNodeSubTlv(byte[] rawValue) {
- log.debug("IPv6RouterIdofRemoteNodeTlv");
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created IPv6RouterIdofRemoteNodeTlv object.
- *
- * @param raw IPv6 TE Router Id of RemoteNode
- * @return object of IPv6RouterIdofRemoteNodeTlv
- */
- public static IPv6RouterIdofRemoteNodeSubTlv of(final byte[] raw) {
- //check NONE_VAL
- boolean bFoundNone = true;
- //value starts from 3rd byte.
- for (int i = 2; i < 20; ++i) {
- if (NONE_VAL[i] != raw[i]) {
- bFoundNone = false;
- }
- }
-
- if (bFoundNone) {
- return NONE;
- }
-
- //check NO_MASK_VAL
- boolean bFoundNoMask = true;
- //value starts from 3rd byte.
- for (int i = 2; i < 20; ++i) {
- if ((byte) 0xFF != raw[i]) {
- bFoundNoMask = false;
- }
- }
- if (bFoundNoMask) {
- return NO_MASK;
- }
-
- return new IPv6RouterIdofRemoteNodeSubTlv(raw);
- }
-
- /**
- * Returns value of IPv6 TE Router Id of Remote Node.
- *
- * @return byte array value of rawValue
- */
- public byte[] getBytes() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IPv6RouterIdofRemoteNodeSubTlv) {
- IPv6RouterIdofRemoteNodeSubTlv other = (IPv6RouterIdofRemoteNodeSubTlv) obj;
- return Arrays.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeBytes(rawValue);
- return c.writerIndex() - iStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IPv6RouterIdofRemoteNodeTlv.
- *
- * @param c input channel buffer
- * @return object of IPv6RouterIdofRemoteNodeTlv
- */
- public static IPv6RouterIdofRemoteNodeSubTlv read20Bytes(ChannelBuffer c) {
- byte[] yTemp = new byte[20];
- c.readBytes(yTemp, 0, 20);
- return IPv6RouterIdofRemoteNodeSubTlv.of(yTemp);
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- toStrHelper.add("Type", TYPE);
- toStrHelper.add("Length", LENGTH);
-
- StringBuffer result = new StringBuffer();
- for (byte b : rawValue) {
- result.append(String.format("%02X ", b));
- }
- toStrHelper.add("Value", result);
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6SubObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6SubObject.java
deleted file mode 100644
index 808b1e8..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6SubObject.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-
-/**
- * Provides IPv6 Sub Object.
- */
-public class IPv6SubObject implements PcepValueType {
-
- /* reference :RFC 4874.
- Subobject : IPv6 address
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type | Length | IPv6 address (16 bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv6 address (continued) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv6 address (continued) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv6 address (continued) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv6 address (continued) | Prefix Length | Flags |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Type
-
- 0x02 IPv6 address
-
- Length
-
- The Length contains the total length of the subobject in bytes,
- including the Type and Length fields. The Length is always 20.
-
- IPv6 address
-
- A 128-bit unicast host address.
-
- Prefix length
-
- 128
-
- Flags
-
- 0x01 Local protection available
-
- Indicates that the link downstream of this node is
- protected via a local repair mechanism. This flag can
- only be set if the Local protection flag was set in the
- SESSION_ATTRIBUTE object of the corresponding Path
- message.
-
- 0x02 Local protection in use
-
- Indicates that a local repair mechanism is in use to
- maintain this tunnel (usually in the face of an outage
- of the link it was previously routed over).
- */
- private static final Logger log = LoggerFactory.getLogger(IPv6SubObject.class);
-
- public static final short TYPE = 0x02;
- public static final short LENGTH = 20;
- public static final byte VALUE_LENGTH = 18;
-
- private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- public static final IPv6SubObject NONE = new IPv6SubObject(NONE_VAL);
-
- private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
- public static final IPv6SubObject NO_MASK = new IPv6SubObject(NO_MASK_VAL);
- public static final IPv6SubObject FULL_MASK = NONE;
-
- private final byte[] rawValue;
-
- /**
- * constructor to initialize rawValue with ipv6 address.
- *
- * @param rawValue ipv6 address
- */
- public IPv6SubObject(byte[] rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * To create instance of IPv6SubObject.
- *
- * @param raw byte array of ipv6 address
- * @return object of IPv6SubObject
- */
- public static IPv6SubObject of(final byte[] raw) {
- //check NONE_VAL
- boolean bFoundNone = true;
- //value starts from 3rd byte.
- for (int i = 2; i < 20; ++i) {
- if (NONE_VAL[i] != raw[i]) {
- bFoundNone = false;
- }
- }
-
- if (bFoundNone) {
- return NONE;
- }
-
- //check NO_MASK_VAL
- boolean bFoundNoMask = true;
- //value starts from 3rd byte.
- for (int i = 2; i < 20; ++i) {
- if ((byte) 0xFF != raw[i]) {
- bFoundNoMask = false;
- }
- }
- if (bFoundNoMask) {
- return NO_MASK;
- }
-
- return new IPv6SubObject(raw);
- }
-
- /**
- * Returns value of IPv6 Sub Object.
- *
- * @return byte array of ipv6 address
- */
- public byte[] getValue() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IPv6SubObject) {
- IPv6SubObject other = (IPv6SubObject) obj;
- return Arrays.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeBytes(rawValue);
- return c.writerIndex() - iStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IPv6SubObject.
- *
- * @param c type of channel buffer
- * @return object of IPv6SubObject
- */
- public static IPv6SubObject read20Bytes(ChannelBuffer c) {
- byte[] yTemp = new byte[20];
- c.readBytes(yTemp, 0, 20);
- return IPv6SubObject.of(yTemp);
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- toStrHelper.add("Type", TYPE);
- toStrHelper.add("Length", LENGTH);
-
- StringBuffer result = new StringBuffer();
- for (byte b : rawValue) {
- result.append(String.format("%02X ", b));
- }
- toStrHelper.add("Value", result);
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IgpMetricSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IgpMetricSubTlv.java
deleted file mode 100644
index 93199c5..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IgpMetricSubTlv.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-
-/**
- * Provides IGP Link Metric .
- */
-public class IgpMetricSubTlv implements PcepValueType {
-
- /* Reference :[I-D.ietf-idr-ls-distribution] /3.3.2.4
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=TDB40 | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // IGP Link Metric (variable length) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(IgpMetricSubTlv.class);
-
- public static final short TYPE = 29;
- private short hLength;
-
- private final byte[] rawValue;
-
- /**
- * Constructor to initialize raw value.
- *
- * @param rawValue IGP Link Metric
- * @param hLength length
- */
- public IgpMetricSubTlv(byte[] rawValue, short hLength) {
- this.rawValue = rawValue;
- this.hLength = hLength;
- }
-
- /**
- * Returns newly created IGPMetricTlv object.
- *
- * @param raw value of IGP Link Metric
- * @param hLength length
- * @return object of IGPMetricTlv
- */
- public static IgpMetricSubTlv of(final byte[] raw, short hLength) {
- return new IgpMetricSubTlv(raw, hLength);
- }
-
- /**
- * Returns value of IGP Link Metric.
- *
- * @return rawValue of IGP Link Metric
- */
- public byte[] getValue() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IgpMetricSubTlv) {
- IgpMetricSubTlv other = (IgpMetricSubTlv) obj;
- return Arrays.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(hLength);
- c.writeBytes(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of IGPMetricTlv.
- *
- * @param c input channel buffer
- * @param hLength length
- * @return object of IGPMetricTlv
- */
- public static PcepValueType read(ChannelBuffer c, short hLength) {
- byte[] iIgpMetric = new byte[hLength];
- c.readBytes(iIgpMetric, 0, hLength);
- return new IgpMetricSubTlv(iIgpMetric, hLength);
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- toStrHelper.add("Type", TYPE);
- toStrHelper.add("Length", hLength);
-
- StringBuffer result = new StringBuffer();
- for (byte b : rawValue) {
- result.append(String.format("%02X ", b));
- }
- toStrHelper.add("Value", result);
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IgpRouterIdSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IgpRouterIdSubTlv.java
deleted file mode 100644
index f57dafb..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IgpRouterIdSubTlv.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-
-/**
- * Provides router id.
- */
-public class IgpRouterIdSubTlv implements PcepValueType {
-
- /* reference :I-D.ietf-idr-ls-distribution.
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD13] | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | opaque value |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(IgpRouterIdSubTlv.class);
-
- public static final short TYPE = 4;
- private final short hLength;
-
- private final byte[] rawValue;
-
- /**
- * constructor to initialize rawValue.
- *
- * @param rawValue raw value
- * @param hLength length
- */
- public IgpRouterIdSubTlv(byte[] rawValue, short hLength) {
- this.rawValue = rawValue;
- if (0 == hLength) {
- this.hLength = (short) rawValue.length;
- } else {
- this.hLength = hLength;
- }
- }
-
- /**
- * Returns object of Router ID Sub Tlv.
- *
- * @param raw value
- * @param hLength length
- * @return object of Router ID Sub Tlv
- */
- public static IgpRouterIdSubTlv of(final byte[] raw, short hLength) {
- return new IgpRouterIdSubTlv(raw, hLength);
- }
-
- /**
- * Returns raw value.
- *
- * @return rawValue value
- */
- public byte[] getValue() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IgpRouterIdSubTlv) {
- IgpRouterIdSubTlv other = (IgpRouterIdSubTlv) obj;
- return Arrays.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(hLength);
- c.writeBytes(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads channel buffer and returns object of IgpRouterIDTlv.
- *
- * @param c input channel buffer
- * @param hLength length
- * @return object of IgpRouterIDTlv
- */
- public static PcepValueType read(ChannelBuffer c, short hLength) {
- byte[] iOpaqueValue = new byte[hLength];
- c.readBytes(iOpaqueValue, 0, hLength);
- return new IgpRouterIdSubTlv(iOpaqueValue, hLength);
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- toStrHelper.add("Type", TYPE);
- toStrHelper.add("Length", hLength);
-
- StringBuffer result = new StringBuffer();
- for (byte b : rawValue) {
- result.append(String.format("%02X ", b));
- }
- toStrHelper.add("Value", result);
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IsisAreaIdentifierSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IsisAreaIdentifierSubTlv.java
deleted file mode 100644
index b9256cc..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IsisAreaIdentifierSubTlv.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-import java.util.Objects;
-
-/**
- * Provides ISIS Area Identifier.
- */
-public class IsisAreaIdentifierSubTlv implements PcepValueType {
-
- /* Reference :[I-D.ietf-idr- ls-distribution]/3.3.1.2
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD24] | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // Area Identifier (variable) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(IsisAreaIdentifierSubTlv.class);
-
- public static final short TYPE = 16;
- private short hLength;
-
- private final byte[] rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue ISIS-Area-Identifier
- * @param hLength length
- */
- public IsisAreaIdentifierSubTlv(byte[] rawValue, short hLength) {
- log.debug("ISISAreaIdentifierTlv");
- this.rawValue = rawValue;
- if (0 == hLength) {
- this.hLength = (short) rawValue.length;
- } else {
- this.hLength = hLength;
- }
- }
-
- /**
- * Returns newly created ISISAreaIdentifierTlv object.
- *
- * @param raw ISIS-Area-Identifier
- * @param hLength length
- * @return object of ISISAreaIdentifierTlv
- */
- public static IsisAreaIdentifierSubTlv of(final byte[] raw, short hLength) {
- return new IsisAreaIdentifierSubTlv(raw, hLength);
- }
-
- /**
- * Returns value of ISIS-Area-Identifier.
- *
- * @return byte array of rawValue
- */
- public byte[] getValue() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(Arrays.hashCode(rawValue), rawValue.length);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof IsisAreaIdentifierSubTlv) {
- IsisAreaIdentifierSubTlv other = (IsisAreaIdentifierSubTlv) obj;
- return Objects.equals(hLength, other.hLength) && Arrays.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(hLength);
- c.writeBytes(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of ISISAreaIdentifierTlv.
- *
- * @param c input channel buffer
- * @param hLength length
- * @return object of ISISAreaIdentifierTlv
- */
- public static PcepValueType read(ChannelBuffer c, short hLength) {
- byte[] iIsisAreaIdentifier = new byte[hLength];
- c.readBytes(iIsisAreaIdentifier, 0, hLength);
- return new IsisAreaIdentifierSubTlv(iIsisAreaIdentifier, hLength);
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- toStrHelper.add("Type", TYPE);
- toStrHelper.add("Length", hLength);
-
- StringBuffer result = new StringBuffer();
- for (byte b : rawValue) {
- result.append(String.format("%02X ", b));
- }
- toStrHelper.add("Value", result);
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LabelSubObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LabelSubObject.java
deleted file mode 100644
index aadb4be..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LabelSubObject.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * LabelSubObject: Provides a LabelSubObject.
- */
-public class LabelSubObject implements PcepValueType {
-
- /* Reference : RFC 3209
- * LABEL Sub Object
- *
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type | Length | Flags | C-Type |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Contents of Label Object |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
- private static final Logger log = LoggerFactory.getLogger(LabelSubObject.class);
-
- public static final short TYPE = 0x03;
- public static final short LENGTH = 8;
- private final byte flags;
- private final byte cType;
- private final int contents;
-
- /**
- * constructor to initialize parameters for LabelSubObject.
- *
- * @param flags flags
- * @param cType C-Type
- * @param contents Contents of label object
- */
- public LabelSubObject(byte flags, byte cType, int contents) {
- this.flags = flags;
- this.cType = cType;
- this.contents = contents;
- }
-
- /**
- * Return an object of LabelSubObject.
- *
- * @param flags flags
- * @param cType C-type
- * @param contents contents of label objects
- * @return object of LabelSubObject
- */
- public static LabelSubObject of(byte flags, byte cType, int contents) {
- return new LabelSubObject(flags, cType, contents);
- }
-
- /**
- * Returns Flags.
- *
- * @return flags
- */
- public byte getFlags() {
- return flags;
- }
-
- /**
- * Returns cType.
- *
- * @return cType
- */
- public byte getCtype() {
- return cType;
- }
-
- /**
- * Returns contents.
- *
- * @return contents
- */
- public int getContents() {
- return contents;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(flags, cType, contents);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof LabelSubObject) {
- LabelSubObject other = (LabelSubObject) obj;
- return Objects.equals(this.flags, other.flags) && Objects.equals(this.cType, other.cType)
- && Objects.equals(this.contents, other.contents);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeByte(flags);
- c.writeByte(cType);
- c.writeByte(contents);
- return c.writerIndex() - iStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of LabelSubObject.
- *
- * @param c type of channel buffer
- * @return object of LabelSubObject
- */
- public static PcepValueType read(ChannelBuffer c) {
- byte flags = c.readByte();
- byte cType = c.readByte();
- int contents = c.readInt();
- return new LabelSubObject(flags, cType, contents);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("type", TYPE)
- .add("Length", LENGTH)
- .add("flags", flags)
- .add("C-type", cType)
- .add("contents", contents)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkAttributesTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkAttributesTlv.java
deleted file mode 100644
index 2c172f9..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkAttributesTlv.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides LinkAttributesTlv.
- */
-public class LinkAttributesTlv implements PcepValueType {
-
- /*
- * Reference :draft-dhodylee-pce-pcep-ls-01, section 9.2.8.2.
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD27] | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Link Attributes Sub-TLVs (variable) //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(LinkAttributesTlv.class);
-
- public static final short TYPE = (short) 65286;
- short hLength;
-
- public static final int TLV_HEADER_LENGTH = 4;
-
- // LinkDescriptors Sub-TLVs (variable)
- private List<PcepValueType> llLinkAttributesSubTLVs;
-
- /**
- * Constructor to initialize Link Attributes Sub TLVs.
- *
- * @param llLinkAttributesSubTLVs linked list of PcepValueType
- */
- public LinkAttributesTlv(List<PcepValueType> llLinkAttributesSubTLVs) {
- this.llLinkAttributesSubTLVs = llLinkAttributesSubTLVs;
- }
-
- /**
- * Returns object of TE Link Attributes TLV.
- *
- * @param llLinkAttributesSubTLVs linked list of Link Attribute of Sub TLV
- * @return object of LinkAttributesTlv
- */
- public static LinkAttributesTlv of(final List<PcepValueType> llLinkAttributesSubTLVs) {
- return new LinkAttributesTlv(llLinkAttributesSubTLVs);
- }
-
- /**
- * Returns linked list of Link Attribute of Sub TLV.
- *
- * @return llLinkAttributesSubTLVs linked list of Link Attribute of Sub TLV
- */
- public List<PcepValueType> getllLinkAttributesSubTLVs() {
- return llLinkAttributesSubTLVs;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(llLinkAttributesSubTLVs.hashCode());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- /*
- * Here we have a list of Tlv so to compare each sub tlv between the object
- * we have to take a list iterator so one by one we can get each sub tlv object
- * and can compare them.
- * it may be possible that the size of 2 lists is not equal so we have to first check
- * the size, if both are same then we should check for the subtlv objects otherwise
- * we should return false.
- */
- if (obj instanceof LinkAttributesTlv) {
- int countObjSubTlv = 0;
- int countOtherSubTlv = 0;
- boolean isCommonSubTlv = true;
- LinkAttributesTlv other = (LinkAttributesTlv) obj;
- Iterator<PcepValueType> objListIterator = ((LinkAttributesTlv) obj).llLinkAttributesSubTLVs.iterator();
- countObjSubTlv = ((LinkAttributesTlv) obj).llLinkAttributesSubTLVs.size();
- countOtherSubTlv = other.llLinkAttributesSubTLVs.size();
- if (countObjSubTlv != countOtherSubTlv) {
- return false;
- } else {
- while (objListIterator.hasNext() && isCommonSubTlv) {
- PcepValueType subTlv = objListIterator.next();
- isCommonSubTlv = Objects.equals(llLinkAttributesSubTLVs.contains(subTlv),
- other.llLinkAttributesSubTLVs.contains(subTlv));
- }
- return isCommonSubTlv;
- }
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int tlvStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- int tlvLenIndex = c.writerIndex();
- hLength = 0;
- c.writeShort(hLength);
-
- ListIterator<PcepValueType> listIterator = llLinkAttributesSubTLVs.listIterator();
-
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
-
- if (tlv == null) {
- log.debug("TLV is null from subTlv list");
- continue;
- }
- tlv.write(c);
-
- // need to take care of padding
- int pad = tlv.getLength() % 4;
-
- if (0 != pad) {
- pad = 4 - pad;
- for (int i = 0; i < pad; ++i) {
- c.writeByte((byte) 0);
- }
- }
- }
-
- hLength = (short) (c.writerIndex() - tlvStartIndex);
- c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
-
- return c.writerIndex() - tlvStartIndex;
- }
-
- /**
- * Reads channel buffer and returns object of TE Link Attributes TLV.
- *
- * @param c input channel buffer
- * @param hLength length
- * @return object of LinkAttributesTlv
- * @throws PcepParseException if mandatory fields are missing
- */
- public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException {
-
- // Node Descriptor Sub-TLVs (variable)
- List<PcepValueType> llLinkAttributesSubTLVs = new LinkedList<>();
-
- ChannelBuffer tempCb = c.readBytes(hLength);
-
- while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
-
- PcepValueType tlv;
- short hType = tempCb.readShort();
- int iValue = 0;
- short length = tempCb.readShort();
- switch (hType) {
-
- case IPv4RouterIdOfLocalNodeSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new IPv4RouterIdOfLocalNodeSubTlv(iValue);
- break;
- case IPv6RouterIdofLocalNodeSubTlv.TYPE:
- byte[] ipv6LValue = new byte[IPv6RouterIdofLocalNodeSubTlv.VALUE_LENGTH];
- tempCb.readBytes(ipv6LValue, 0, IPv6RouterIdofLocalNodeSubTlv.VALUE_LENGTH);
- tlv = new IPv6RouterIdofLocalNodeSubTlv(ipv6LValue);
- break;
- case IPv4RouterIdOfRemoteNodeSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new IPv4RouterIdOfRemoteNodeSubTlv(iValue);
- break;
- case IPv6RouterIdofRemoteNodeSubTlv.TYPE:
- byte[] ipv6RValue = new byte[IPv6RouterIdofRemoteNodeSubTlv.VALUE_LENGTH];
- tempCb.readBytes(ipv6RValue, 0, IPv6RouterIdofRemoteNodeSubTlv.VALUE_LENGTH);
- tlv = new IPv6RouterIdofRemoteNodeSubTlv(ipv6RValue);
- break;
- case LinkLocalRemoteIdentifiersSubTlv.TYPE:
- tlv = LinkLocalRemoteIdentifiersSubTlv.read(tempCb);
- break;
- case AdministrativeGroupSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new AdministrativeGroupSubTlv(iValue);
- break;
- case MaximumLinkBandwidthSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new MaximumLinkBandwidthSubTlv(iValue);
- break;
- case MaximumReservableLinkBandwidthSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new MaximumReservableLinkBandwidthSubTlv(iValue);
- break;
- case UnreservedBandwidthSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new UnreservedBandwidthSubTlv(iValue);
- break;
- case TEDefaultMetricSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new TEDefaultMetricSubTlv(iValue);
- break;
- case LinkProtectionTypeSubTlv.TYPE:
- tlv = LinkProtectionTypeSubTlv.read(tempCb);
- break;
- case MplsProtocolMaskSubTlv.TYPE:
- byte cValue = tempCb.readByte();
- tlv = new MplsProtocolMaskSubTlv(cValue);
- break;
- case IgpMetricSubTlv.TYPE:
- tlv = IgpMetricSubTlv.read(tempCb, length);
- break;
- case SharedRiskLinkGroupSubTlv.TYPE:
- tlv = SharedRiskLinkGroupSubTlv.read(tempCb, length);
- break;
- case OpaqueLinkAttributeSubTlv.TYPE:
- tlv = OpaqueLinkAttributeSubTlv.read(tempCb, length);
- break;
- case LinkNameAttributeSubTlv.TYPE:
- tlv = LinkNameAttributeSubTlv.read(tempCb, length);
- break;
- default:
- throw new PcepParseException("Unsupported Sub TLV type :" + hType);
- }
-
- // Check for the padding
- int pad = length % 4;
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= tempCb.readableBytes()) {
- tempCb.skipBytes(pad);
- }
- }
- llLinkAttributesSubTLVs.add(tlv);
- }
-
- if (0 < tempCb.readableBytes()) {
-
- throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
- }
-
- return new LinkAttributesTlv(llLinkAttributesSubTLVs);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", hLength)
- .add("LinkAttributesSubTLVs", llLinkAttributesSubTLVs)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkDescriptorsTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkDescriptorsTlv.java
deleted file mode 100644
index 1505a42..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkDescriptorsTlv.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides TE Link Descriptors TLV.
- */
-public class LinkDescriptorsTlv implements PcepValueType {
-
- /*
- * Reference: draft-dhodylee-pce-pcep-ls-01, section 9.2.6.
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD14] | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Link Descriptor Sub-TLVs (variable) //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- */
-
- private static final Logger log = LoggerFactory.getLogger(LinkDescriptorsTlv.class);
-
- public static final short TYPE = (short) 65284;
- public short hLength;
-
- public static final int TLV_HEADER_LENGTH = 4;
-
- // LinkDescriptors Sub-TLVs (variable)
- private List<PcepValueType> llLinkDescriptorsSubTLVs;
-
- /**
- * Constructor to initialize llLinkDescriptorsSubTLVs.
- *
- * @param llLinkDescriptorsSubTLVs of PcepValueType
- */
- public LinkDescriptorsTlv(List<PcepValueType> llLinkDescriptorsSubTLVs) {
- this.llLinkDescriptorsSubTLVs = llLinkDescriptorsSubTLVs;
- }
-
- /**
- * Returns object of LinkDescriptorsTlv.
- *
- * @param llLinkDescriptorsSubTLVs of PcepValueType
- * @return object of LinkDescriptorsTlv
- */
- public static LinkDescriptorsTlv of(final List<PcepValueType> llLinkDescriptorsSubTLVs) {
- return new LinkDescriptorsTlv(llLinkDescriptorsSubTLVs);
- }
-
- /**
- * Returns linked list of Link Attribute of Sub TLV.
- *
- * @return llLinkDescriptorsSubTLVs linked list of Link Attribute of Sub TLV
- */
- public List<PcepValueType> getllLinkDescriptorsSubTLVs() {
- return llLinkDescriptorsSubTLVs;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(llLinkDescriptorsSubTLVs.hashCode());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- /*
- * Here we have a list of Tlv so to compare each sub tlv between the object
- * we have to take a list iterator so one by one we can get each sub tlv object
- * and can compare them.
- * it may be possible that the size of 2 lists is not equal so we have to first check
- * the size, if both are same then we should check for the subtlv objects otherwise
- * we should return false.
- */
- if (obj instanceof LinkDescriptorsTlv) {
- int countObjSubTlv = 0;
- int countOtherSubTlv = 0;
- boolean isCommonSubTlv = true;
- LinkDescriptorsTlv other = (LinkDescriptorsTlv) obj;
- Iterator<PcepValueType> objListIterator = ((LinkDescriptorsTlv) obj).llLinkDescriptorsSubTLVs.iterator();
- countObjSubTlv = ((LinkDescriptorsTlv) obj).llLinkDescriptorsSubTLVs.size();
- countOtherSubTlv = other.llLinkDescriptorsSubTLVs.size();
- if (countObjSubTlv != countOtherSubTlv) {
- return false;
- } else {
- while (objListIterator.hasNext() && isCommonSubTlv) {
- PcepValueType subTlv = objListIterator.next();
- isCommonSubTlv = Objects.equals(llLinkDescriptorsSubTLVs.contains(subTlv),
- other.llLinkDescriptorsSubTLVs.contains(subTlv));
- }
- return isCommonSubTlv;
- }
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int tlvStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- int tlvLenIndex = c.writerIndex();
- hLength = 0;
- c.writeShort(hLength);
-
- ListIterator<PcepValueType> listIterator = llLinkDescriptorsSubTLVs.listIterator();
-
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
-
- tlv.write(c);
-
- // need to take care of padding
- int pad = tlv.getLength() % 4;
-
- if (0 != pad) {
- pad = 4 - pad;
- for (int i = 0; i < pad; ++i) {
- c.writeByte((byte) 0);
- }
- }
- }
-
- hLength = (short) (c.writerIndex() - tlvStartIndex);
- c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
-
- return c.writerIndex() - tlvStartIndex;
- }
-
- /**
- * Reads channel buffer and returns object of LinkDescriptorsTlv.
- *
- * @param c input channel buffer
- * @param length length
- * @return object of LinkDescriptorsTlv
- * @throws PcepParseException if mandatory fields are missing
- */
- public static PcepValueType read(ChannelBuffer c, short length) throws PcepParseException {
-
- // Node Descriptor Sub-TLVs (variable)
- List<PcepValueType> llLinkDescriptorsSubTLVs = new LinkedList<>();
-
- ChannelBuffer tempCb = c.readBytes(length);
-
- while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
-
- PcepValueType tlv;
- short hType = tempCb.readShort();
- int iValue = 0;
- short hLength = tempCb.readShort();
- log.debug("sub Tlv Length" + hLength);
- switch (hType) {
-
- case LinkLocalRemoteIdentifiersSubTlv.TYPE:
- tlv = LinkLocalRemoteIdentifiersSubTlv.read(tempCb);
- break;
- case IPv4InterfaceAddressSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new IPv4InterfaceAddressSubTlv(iValue);
- break;
- case IPv4NeighborAddressSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new IPv4NeighborAddressSubTlv(iValue);
- break;
- case IPv6InterfaceAddressSubTlv.TYPE:
- byte[] ipv6Value = new byte[IPv6InterfaceAddressSubTlv.VALUE_LENGTH];
- tempCb.readBytes(ipv6Value, 0, IPv6InterfaceAddressSubTlv.VALUE_LENGTH);
- tlv = new IPv6InterfaceAddressSubTlv(ipv6Value);
- break;
- case IPv6NeighborAddressSubTlv.TYPE:
- byte[] ipv6NeighborAdd = new byte[IPv6NeighborAddressSubTlv.VALUE_LENGTH];
- tempCb.readBytes(ipv6NeighborAdd, 0, IPv6NeighborAddressSubTlv.VALUE_LENGTH);
- tlv = new IPv6NeighborAddressSubTlv(ipv6NeighborAdd);
- break;
- default:
- throw new PcepParseException("Unsupported Sub TLV type:" + hType);
- }
-
- // Check for the padding
- int pad = hLength % 4;
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= tempCb.readableBytes()) {
- tempCb.skipBytes(pad);
- }
- }
- llLinkDescriptorsSubTLVs.add(tlv);
-
- }
-
- if (0 < tempCb.readableBytes()) {
-
- throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
- }
- return new LinkDescriptorsTlv(llLinkDescriptorsSubTLVs);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", hLength)
- .add("LinkDescriptorsSubTLVs", llLinkDescriptorsSubTLVs)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersSubTlv.java
deleted file mode 100644
index bf55f44..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersSubTlv.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Local and remote Link Identifiers.
- */
-public class LinkLocalRemoteIdentifiersSubTlv implements PcepValueType {
-
- /* Reference :RFC5307
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=4 | Length=8 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Link Local Identifier |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Link Remote Identifier |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- */
- private static final Logger log = LoggerFactory.getLogger(LinkLocalRemoteIdentifiersSubTlv.class);
-
- public static final short TYPE = 6;
- public static final short LENGTH = 8;
- private final int iLinkLocalIdentifier;
- private final int iLinkRemoteIdentifier;
-
- /**
- * Constructor to initialize iLinkLocalIdentifier , iLinkRemoteIdentifier.
- *
- * @param iLinkLocalIdentifier Link Local identifier
- * @param iLinkRemoteIdentifier Link Remote identifier
- */
- public LinkLocalRemoteIdentifiersSubTlv(int iLinkLocalIdentifier, int iLinkRemoteIdentifier) {
- this.iLinkLocalIdentifier = iLinkLocalIdentifier;
- this.iLinkRemoteIdentifier = iLinkRemoteIdentifier;
- }
-
- /**
- * Retruns an object of Link Local Remote Identifiers Tlv.
- *
- * @param iLinkLocalIdentifier Link Local identifier
- * @param iLinkRemoteIdentifier Link Remote identifier
- * @return object of LinkLocalRemoteIdentifiersTlv
- */
- public static LinkLocalRemoteIdentifiersSubTlv of(int iLinkLocalIdentifier, int iLinkRemoteIdentifier) {
- return new LinkLocalRemoteIdentifiersSubTlv(iLinkLocalIdentifier, iLinkRemoteIdentifier);
- }
-
- /**
- * Returns Link-Local-Identifier.
- *
- * @return iLinkLocalIdentifier Link Local Identifier
- */
- public int getLinkLocalIdentifier() {
- return iLinkLocalIdentifier;
- }
-
- /**
- * Returns Link-Remote-Identifier.
- *
- * @return iLinkRemoteIdentifier Link Remote Identifier.
- */
- public int getLinkRemoteIdentifier() {
- return iLinkRemoteIdentifier;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(iLinkLocalIdentifier, iLinkRemoteIdentifier);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof LinkLocalRemoteIdentifiersSubTlv) {
- LinkLocalRemoteIdentifiersSubTlv other = (LinkLocalRemoteIdentifiersSubTlv) obj;
- return Objects.equals(iLinkLocalIdentifier, other.iLinkLocalIdentifier)
- && Objects.equals(iLinkRemoteIdentifier, other.iLinkRemoteIdentifier);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(iLinkLocalIdentifier);
- c.writeInt(iLinkRemoteIdentifier);
- return c.writerIndex() - iStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of LinkLocalRemoteIdentifiersTlv.
- *
- * @param c input channel buffer
- * @return object of LinkLocalRemoteIdentifiersTlv
- */
- public static PcepValueType read(ChannelBuffer c) {
- int iLinkLocalIdentifier = c.readInt();
- int iLinkRemoteIdentifier = c.readInt();
- return new LinkLocalRemoteIdentifiersSubTlv(iLinkLocalIdentifier, iLinkRemoteIdentifier);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("LinkLocalIdentifier", iLinkLocalIdentifier)
- .add("LinkRemoteIdentifier", iLinkRemoteIdentifier)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkNameAttributeSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkNameAttributeSubTlv.java
deleted file mode 100644
index ce3902f..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkNameAttributeSubTlv.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Arrays;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-
-/**
- * Provides the Link Name.
- */
-public class LinkNameAttributeSubTlv implements PcepValueType {
-
- /* Reference :[I-D.ietf-idr- ls-distribution] /3.3.2.7
- * Link name tlv format.
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=TDB43 | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // Link Name (variable) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(LinkNameAttributeSubTlv.class);
-
- public static final short TYPE = 32;
- private short hLength;
-
- private final byte[] rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue Link-Name
- * @param hLength length
- */
- public LinkNameAttributeSubTlv(byte[] rawValue, short hLength) {
- this.rawValue = rawValue;
- if (0 == hLength) {
- this.hLength = (short) rawValue.length;
- } else {
- this.hLength = hLength;
- }
- }
-
- /**
- * Returns newly created LinkNameTlv object.
- *
- * @param raw Link-Name
- * @param hLength length
- * @return object of LinkNameTlv
- */
- public static LinkNameAttributeSubTlv of(final byte[] raw, short hLength) {
- return new LinkNameAttributeSubTlv(raw, hLength);
- }
-
- /**
- * Returns value of Link-Name.
- *
- * @return raw value
- */
- public byte[] getValue() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof LinkNameAttributeSubTlv) {
- LinkNameAttributeSubTlv other = (LinkNameAttributeSubTlv) obj;
- return Arrays.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(hLength);
- c.writeBytes(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of LinkNameTlv.
- *
- * @param c input channel buffer
- * @param hLength length
- * @return object of LinkNameTlv
- */
- public static PcepValueType read(ChannelBuffer c, short hLength) {
- byte[] linkName = new byte[hLength];
- c.readBytes(linkName, 0, hLength);
- return new LinkNameAttributeSubTlv(linkName, hLength);
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- toStrHelper.add("Type", TYPE);
- toStrHelper.add("Length", hLength);
-
- StringBuffer result = new StringBuffer();
- for (byte b : rawValue) {
- result.append(String.format("%02X ", b));
- }
- toStrHelper.add("Value", result);
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeSubTlv.java
deleted file mode 100644
index 3f992c4..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeSubTlv.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provide Link Protection Type.
- */
-
-public class LinkProtectionTypeSubTlv implements PcepValueType {
-
- /* Reference :[RFC5307]/1.2
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TDB38] | Length=2 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |Protection Cap | Reserved |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
- private static final Logger log = LoggerFactory.getLogger(LinkProtectionTypeSubTlv.class);
-
- public static final short TYPE = 27;
- public static final short LENGTH = 2;
- private final byte protectionCap;
- private final byte reserved;
-
- /**
- * Constructor to initialize protectionCap.
- *
- * @param protectionCap Protection Cap
- */
- public LinkProtectionTypeSubTlv(byte protectionCap) {
- this.protectionCap = protectionCap;
- this.reserved = 0;
- }
-
- /**
- * Constructor to initialize protectionCap, reserved.
- *
- * @param protectionCap Protection Cap
- * @param reserved Reserved value
- */
- public LinkProtectionTypeSubTlv(byte protectionCap, byte reserved) {
- this.protectionCap = protectionCap;
- this.reserved = reserved;
- }
-
- /**
- * Returns Protection Cap.
- *
- * @return protectionCap Protection Cap
- */
- public byte getProtectionCap() {
- return protectionCap;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(protectionCap, reserved);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof LinkProtectionTypeSubTlv) {
- LinkProtectionTypeSubTlv other = (LinkProtectionTypeSubTlv) obj;
- return Objects.equals(protectionCap, other.protectionCap) && Objects.equals(reserved, other.reserved);
- }
-
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeByte(protectionCap);
- c.writeByte(reserved);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of LinkProtectionTypeTlv.
- *
- * @param c input channel buffer
- * @return object of LinkProtectionTypeTlv
- */
- public static PcepValueType read(ChannelBuffer c) {
- byte protectionCap = c.readByte();
- byte reserved = c.readByte();
- return new LinkProtectionTypeSubTlv(protectionCap, reserved);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("ProtectionCap", protectionCap)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalNodeDescriptorsTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalNodeDescriptorsTlv.java
deleted file mode 100644
index ea7f277..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalNodeDescriptorsTlv.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Local TE Node Descriptors TLV which contains Node Descriptor Sub-TLVs.
- */
-public class LocalNodeDescriptorsTlv implements PcepValueType {
-
- /* REFERENCE :draft-dhodylee-pce-pcep-ls-01, section 9.2.2
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD8] | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Node Descriptor Sub-TLVs (variable) //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Note: Length is including header here. Refer Routing Universe TLV.
- */
-
- private static final Logger log = LoggerFactory.getLogger(LocalNodeDescriptorsTlv.class);
-
- public static final short TYPE = (short) 65282;
- short hLength;
-
- public static final int TLV_HEADER_LENGTH = 4;
- // Node Descriptor Sub-TLVs (variable)
- private List<PcepValueType> llNodeDescriptorSubTLVs;
-
- /**
- * Constructor to initialize llNodeDescriptorSubTLVs.
- *
- * @param llNodeDescriptorSubTLVs List of PcepValueType
- */
- public LocalNodeDescriptorsTlv(List<PcepValueType> llNodeDescriptorSubTLVs) {
- this.llNodeDescriptorSubTLVs = llNodeDescriptorSubTLVs;
- }
-
- /**
- * Returns a new object of LocalNodeDescriptorsTLV.
- *
- * @param llNodeDescriptorSubTLVs linked list of Node Descriptor Sub TLVs
- * @return object of LocalNodeDescriptorsTLV
- */
- public static LocalNodeDescriptorsTlv of(final List<PcepValueType> llNodeDescriptorSubTLVs) {
- return new LocalNodeDescriptorsTlv(llNodeDescriptorSubTLVs);
- }
-
- /**
- * Returns Linked List of tlvs.
- *
- * @return llNodeDescriptorSubTLVs linked list of Node Descriptor Sub TLV
- */
- public List<PcepValueType> getllNodeDescriptorSubTLVs() {
- return llNodeDescriptorSubTLVs;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(llNodeDescriptorSubTLVs.hashCode());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- /*
- * Here we have a list of Tlv so to compare each sub tlv between the object
- * we have to take a list iterator so one by one we can get each sub tlv object
- * and can compare them.
- * it may be possible that the size of 2 lists is not equal so we have to first check
- * the size, if both are same then we should check for the subtlv objects otherwise
- * we should return false.
- */
- if (obj instanceof LocalNodeDescriptorsTlv) {
- int countObjSubTlv = 0;
- int countOtherSubTlv = 0;
- boolean isCommonSubTlv = true;
- LocalNodeDescriptorsTlv other = (LocalNodeDescriptorsTlv) obj;
- Iterator<PcepValueType> objListIterator = ((LocalNodeDescriptorsTlv) obj).llNodeDescriptorSubTLVs
- .iterator();
- countObjSubTlv = ((LocalNodeDescriptorsTlv) obj).llNodeDescriptorSubTLVs.size();
- countOtherSubTlv = other.llNodeDescriptorSubTLVs.size();
- if (countObjSubTlv != countOtherSubTlv) {
- return false;
- } else {
- while (objListIterator.hasNext() && isCommonSubTlv) {
- PcepValueType subTlv = objListIterator.next();
- isCommonSubTlv = Objects.equals(llNodeDescriptorSubTLVs.contains(subTlv),
- other.llNodeDescriptorSubTLVs.contains(subTlv));
- }
- return isCommonSubTlv;
- }
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int tlvStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- int tlvLenIndex = c.writerIndex();
- hLength = 0;
- c.writeShort(0);
-
- ListIterator<PcepValueType> listIterator = llNodeDescriptorSubTLVs.listIterator();
-
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
- if (tlv == null) {
- log.debug("TLV is null from subTlv list");
- continue;
- }
- tlv.write(c);
-
- // need to take care of padding
- int pad = tlv.getLength() % 4;
-
- if (0 != pad) {
- pad = 4 - pad;
- for (int i = 0; i < pad; ++i) {
- c.writeByte((byte) 0);
- }
- }
- }
- hLength = (short) (c.writerIndex() - tlvStartIndex);
- c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
- return c.writerIndex() - tlvStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of AutonomousSystemTlv.
- *
- * @param c input channel buffer
- * @param hLength length of subtlvs.
- * @return object of AutonomousSystemTlv
- * @throws PcepParseException if mandatory fields are missing
- */
- public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException {
-
- // Node Descriptor Sub-TLVs (variable)
- List<PcepValueType> llNodeDescriptorSubTLVs = new LinkedList<>();
-
- ChannelBuffer tempCb = c.readBytes(hLength);
-
- while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
-
- PcepValueType tlv;
- short hType = tempCb.readShort();
- int iValue = 0;
- short length = tempCb.readShort();
-
- switch (hType) {
-
- case AutonomousSystemSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new AutonomousSystemSubTlv(iValue);
- break;
- case BgpLsIdentifierSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new BgpLsIdentifierSubTlv(iValue);
- break;
- case OspfAreaIdSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new OspfAreaIdSubTlv(iValue);
- break;
- case IgpRouterIdSubTlv.TYPE:
- tlv = IgpRouterIdSubTlv.read(tempCb, length);
- break;
-
- default:
- throw new PcepParseException("Unsupported Sub TLV type :" + hType);
- }
-
- // Check for the padding
- int pad = length % 4;
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= tempCb.readableBytes()) {
- tempCb.skipBytes(pad);
- }
- }
-
- llNodeDescriptorSubTLVs.add(tlv);
- }
-
- if (0 < tempCb.readableBytes()) {
- throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
- }
- return new LocalNodeDescriptorsTlv(llNodeDescriptorSubTLVs);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", hLength)
- .add("NodeDescriptorSubTLVs", llNodeDescriptorSubTLVs)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LsCapabilityTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LsCapabilityTlv.java
deleted file mode 100644
index 566717d..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LsCapabilityTlv.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides TED Capability Tlv.
- */
-public class LsCapabilityTlv implements PcepValueType {
-
- /*
- * Reference :draft-dhodylee-pce-pcep-ls-01, section 9.1.1.
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD5] | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Flags |R|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(LsCapabilityTlv.class);
-
- public static final short TYPE = (short) 65280;
- public static final short LENGTH = 4;
- public static final int SET = 1;
- public static final byte RFLAG_CHECK = 0x01;
-
- private final boolean rFlag;
- private final int rawValue;
- private final boolean isRawValueSet;
-
- /**
- * Constructor to initialize raw Value.
- *
- * @param rawValue Flags
- */
- public LsCapabilityTlv(final int rawValue) {
- this.rawValue = rawValue;
- this.isRawValueSet = true;
- int temp = rawValue;
- temp = temp & RFLAG_CHECK;
- if (temp == SET) {
- this.rFlag = true;
- } else {
- this.rFlag = false;
- }
-
- }
-
- /**
- * Constructor to initialize rFlag.
- *
- * @param rFlag R-flag
- */
- public LsCapabilityTlv(boolean rFlag) {
- this.rFlag = rFlag;
- this.rawValue = 0;
- this.isRawValueSet = false;
- }
-
- /**
- * Returns R-flag.
- *
- * @return rFlag
- */
- public boolean getrFlag() {
- return rFlag;
- }
-
- /**
- * Returns an object of LsCapabilityTlv.
- *
- * @param raw value Flags
- * @return object of LsCapabilityTlv
- */
- public static LsCapabilityTlv of(final int raw) {
- return new LsCapabilityTlv(raw);
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- if (isRawValueSet) {
- return Objects.hash(rawValue);
- } else {
- return Objects.hash(rFlag);
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof LsCapabilityTlv) {
- LsCapabilityTlv other = (LsCapabilityTlv) obj;
- if (isRawValueSet) {
- return Objects.equals(this.rawValue, other.rawValue);
- } else {
- return Objects.equals(this.rFlag, other.rFlag);
- }
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iStartIndex = c.writerIndex();
- int temp = 0;
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- if (isRawValueSet) {
- c.writeInt(rawValue);
- } else {
- if (rFlag) {
- temp = temp | RFLAG_CHECK;
- }
- c.writeInt(temp);
- }
- return c.writerIndex() - iStartIndex;
- }
-
- /**
- * Reads channel buffer and returns object of LsCapabilityTlv.
- *
- * @param c input channel buffer
- * @return object of LsCapabilityTlv
- */
- public static LsCapabilityTlv read(ChannelBuffer c) {
- return LsCapabilityTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthSubTlv.java
deleted file mode 100644
index 288ab4d..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthSubTlv.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provide the Maximum Link Bandwidth.
- */
-public class MaximumLinkBandwidthSubTlv implements PcepValueType {
-
- /* Reference :[RFC5305]/3.3.
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TDB34] | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Maximum Link Bandwidth |
- +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
- */
-
- private static final Logger log = LoggerFactory.getLogger(MaximumLinkBandwidthSubTlv.class);
-
- public static final short TYPE = 23;
- public static final short LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue Maximum-Link-Bandwidth
- */
-
- public MaximumLinkBandwidthSubTlv(int rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created MaximumLinkBandwidthTlv object.
- *
- * @param raw value of Maximum-Link-Bandwidth
- * @return object of MaximumLinkBandwidthTlv
- */
- public static MaximumLinkBandwidthSubTlv of(final int raw) {
- return new MaximumLinkBandwidthSubTlv(raw);
- }
-
- /**
- * Returns value of Maximum Link Bandwidth.
- *
- * @return rawValue Maximum Link Bandwidth
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof MaximumLinkBandwidthSubTlv) {
- MaximumLinkBandwidthSubTlv other = (MaximumLinkBandwidthSubTlv) obj;
- return Objects.equals(rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of MaximumLinkBandwidthTlv.
- *
- * @param c input channel buffer
- * @return object of MaximumLinkBandwidthTlv
- */
- public static MaximumLinkBandwidthSubTlv read(ChannelBuffer c) {
- return MaximumLinkBandwidthSubTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthSubTlv.java
deleted file mode 100644
index 1a74340..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthSubTlv.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provide the Maximum Reservable Link Bandwidth.
- */
-public class MaximumReservableLinkBandwidthSubTlv implements PcepValueType {
-
- /* Reference :[RFC5305]/3.5.
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TDB35] | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Maximum Reservable Link Bandwidth |
- +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
- */
-
- private static final Logger log = LoggerFactory.getLogger(MaximumReservableLinkBandwidthSubTlv.class);
-
- public static final short TYPE = 24;
- public static final short LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * constructor to initialize rawValue.
- *
- * @param rawValue MaximumReservableLinkBandwidth
- */
- public MaximumReservableLinkBandwidthSubTlv(int rawValue) {
- log.debug("MaximumReservableLinkBandwidthTlv");
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created MaximumReservableLinkBandwidth object.
- *
- * @param raw MaximumReservableLinkBandwidth
- * @return object of MaximumReservableLinkBandwidthTlv
- */
- public static MaximumReservableLinkBandwidthSubTlv of(final int raw) {
- return new MaximumReservableLinkBandwidthSubTlv(raw);
- }
-
- /**
- * Returns value of Maximum Reservable Link Bandwidth.
- * @return rawValue Maximum Reservable Link Bandwidth
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof MaximumReservableLinkBandwidthSubTlv) {
- MaximumReservableLinkBandwidthSubTlv other = (MaximumReservableLinkBandwidthSubTlv) obj;
- return Objects.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of MaximumReservableLinkBandwidthTlv.
- *
- * @param c input channel buffer
- * @return object of MaximumReservableLinkBandwidthTlv
- */
- public static MaximumReservableLinkBandwidthSubTlv read(ChannelBuffer c) {
- return MaximumReservableLinkBandwidthSubTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MplsProtocolMaskSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MplsProtocolMaskSubTlv.java
deleted file mode 100644
index 0ca4fed..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MplsProtocolMaskSubTlv.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides MPLS Protocol Mask.
- */
-public class MplsProtocolMaskSubTlv implements PcepValueType {
-
- /* Reference :[I-D.ietf-idr-ls-distribution]/3.3.2.2
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=TDB39 | Length =1 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |L|R| Reserved |
- +-+-+-+-+-+-+-+-+
- */
- private static final Logger log = LoggerFactory.getLogger(MplsProtocolMaskSubTlv.class);
-
- public static final short TYPE = 28;
- public static final short LENGTH = 1;
- public static final byte LFLAG_SET = (byte) 0x80;
- public static final byte RFLAG_SET = 0x40;
-
- private final byte rawValue;
- private final boolean bLFlag;
- private final boolean bRFlag;
- private final boolean isRawValueSet;
-
- /**
- * constructor to initialize rawValue.
- *
- * @param rawValue MPLS Protocol Mask Flag Bits
- */
- public MplsProtocolMaskSubTlv(byte rawValue) {
- this.rawValue = rawValue;
- this.isRawValueSet = true;
- this.bLFlag = (rawValue & LFLAG_SET) == LFLAG_SET;
- this.bRFlag = (rawValue & RFLAG_SET) == RFLAG_SET;
- }
-
- /**
- * constructor to initialize different Flags.
- *
- * @param bLFlag L-flag
- * @param bRFlag R-flag
- */
- public MplsProtocolMaskSubTlv(boolean bLFlag, boolean bRFlag) {
- this.bLFlag = bLFlag;
- this.bRFlag = bRFlag;
- this.rawValue = 0;
- isRawValueSet = false;
- }
-
- /**
- * Returns newly created MPLSProtocolMaskTlv object.
- *
- * @param raw MPLS Protocol Mask Tlv
- * @return new object of MPLS Protocol Mask Tlv
- */
- public static MplsProtocolMaskSubTlv of(final byte raw) {
- return new MplsProtocolMaskSubTlv(raw);
- }
-
- /**
- * Returns L-flag.
- *
- * @return bLFlag L-flag
- */
- public boolean getbLFlag() {
- return bLFlag;
- }
-
- /**
- * Returns R-flag.
- *
- * @return bRFlag R-flag
- */
- public boolean getbRFlag() {
- return bRFlag;
- }
-
- /**
- * Returns raw value.
- *
- * @return rawValue raw value
- */
- public byte getByte() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- if (isRawValueSet) {
- return Objects.hash(rawValue);
- } else {
- return Objects.hash(bLFlag, bRFlag);
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof MplsProtocolMaskSubTlv) {
- MplsProtocolMaskSubTlv other = (MplsProtocolMaskSubTlv) obj;
- if (isRawValueSet) {
- return Objects.equals(this.rawValue, other.rawValue);
- } else {
- return Objects.equals(this.bLFlag, other.bLFlag) && Objects.equals(this.bRFlag, other.bRFlag);
- }
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- if (isRawValueSet) {
- c.writeByte(rawValue);
- } else {
- byte temp = 0;
- if (bLFlag) {
- temp = (byte) (temp | LFLAG_SET);
- }
- if (bRFlag) {
- temp = (byte) (temp | RFLAG_SET);
- }
- c.writeByte(temp);
- }
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of MPLS Protocol Mask Tlv.
- *
- * @param c input channel buffer
- * @return object of MPLS Protocol Mask Tlv
- */
- public static PcepValueType read(ChannelBuffer c) {
- byte temp = c.readByte();
- boolean bLFlag;
- boolean bRFlag;
-
- bLFlag = (temp & LFLAG_SET) == LFLAG_SET;
- bRFlag = (temp & RFLAG_SET) == RFLAG_SET;
-
- return new MplsProtocolMaskSubTlv(bLFlag, bRFlag);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv4addressTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv4addressTlv.java
deleted file mode 100644
index 1848bf5..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv4addressTlv.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * NexthopIPv6addressTlv provides Ipv4 address of next hop.
- */
-public class NexthopIPv4addressTlv implements PcepValueType {
-
- /*
- Reference :draft-zhao-pce-pcep-extension-for-pce-controller-01
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=TBD | Length = 4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | nexthop IPv4 address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- NEXTHOP-IPV4-ADDRESS TLV
-
- */
- private static final Logger log = LoggerFactory.getLogger(NexthopIPv4addressTlv.class);
-
- public static final short TYPE = (short) 65289; //to be defined
- //Length is header + value
- public static final short LENGTH = 8;
- public static final short VALUE_LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * Constructor to initialize next hop IPv4 address.
- *
- * @param rawValue next hop IPv4 address
- */
- public NexthopIPv4addressTlv(int rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Return next hop IPv4 address tlv.
- *
- * @param raw of next hop IPv4 address
- * @return object of NexthopIPv4addressTlv
- */
- public static NexthopIPv4addressTlv of(final int raw) {
- return new NexthopIPv4addressTlv(raw);
- }
-
- /**
- * Returns next hop IPv4 address.
- *
- * @return next hop IPv4 address
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return VALUE_LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof NexthopIPv4addressTlv) {
- NexthopIPv4addressTlv other = (NexthopIPv4addressTlv) obj;
- return Objects.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(VALUE_LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of NexthopIPv4addressTlv.
- *
- * @param c type of channel buffer
- * @return object of NexthopIPv4addressTlv
- */
- public static NexthopIPv4addressTlv read(ChannelBuffer c) {
- return NexthopIPv4addressTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", VALUE_LENGTH)
- .add("Ipv4Address ", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv6addressTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv6addressTlv.java
deleted file mode 100644
index 2c031ab..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv6addressTlv.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-
-/**
- * NexthopIPv6addressTlv provides Ipv6 address of next hop.
- */
-public class NexthopIPv6addressTlv implements PcepValueType {
-
- /*
- Reference: draft-zhao-pce-pcep-extension-for-pce-controller-01.
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=TBD | Length = 20 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // nexthop IPv6 address (16 bytes) //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- NEXTHOP-IPV6-ADDRESS TLV:
-
- */
- private static final Logger log = LoggerFactory.getLogger(NexthopIPv6addressTlv.class);
-
- public static final short TYPE = 100; //to be defined
- //Length is header + value
- public static final short LENGTH = 20;
- public static final short VALUE_LENGTH = 16;
-
- private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- public static final NexthopIPv6addressTlv NONE = new NexthopIPv6addressTlv(NONE_VAL);
-
- private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
- public static final NexthopIPv6addressTlv NO_MASK = new NexthopIPv6addressTlv(NO_MASK_VAL);
- public static final NexthopIPv6addressTlv FULL_MASK = NONE;
-
- private final byte[] rawValue;
-
- /**
- * Constructor to initialize IP address for next hop IPv6 address tlv.
- *
- * @param rawValue value of Next hop ipAddress
- */
- public NexthopIPv6addressTlv(byte[] rawValue) {
- log.debug("NexthopIPv6addressTlv");
- this.rawValue = rawValue;
- }
-
- /**
- * Creates next hop IPv6 address tlv.
- *
- * @param raw value of Next hop ipAddress
- * @return object of NexthopIPv6addressTlv
- */
- //logic to be checked
- public static NexthopIPv6addressTlv of(final byte[] raw) {
- //check NONE_VAL
- boolean bFoundNone = true;
- //value starts from 3rd byte.
- for (int i = 5; i < 20; ++i) {
- if (NONE_VAL[i] != raw[i]) {
- bFoundNone = false;
- }
- }
-
- if (bFoundNone) {
- return NONE;
- }
-
- //check NO_MASK_VAL
- boolean bFoundNoMask = true;
- //value starts from 3rd byte.
- for (int i = 5; i < 20; ++i) {
- if ((byte) 0xFF != raw[i]) {
- bFoundNoMask = false;
- }
- }
- if (bFoundNoMask) {
- return NO_MASK;
- }
- return new NexthopIPv6addressTlv(raw);
- }
-
- /**
- * Returns next hop IPv6 address.
- *
- * @return next hop IPv6 address
- */
- public byte[] getBytes() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof NexthopIPv6addressTlv) {
- NexthopIPv6addressTlv other = (NexthopIPv6addressTlv) obj;
- return Arrays.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeBytes(rawValue);
- return c.writerIndex() - iStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of NexthopIPv6addressTlv.
- *
- * @param c type of channel buffer
- * @return object of NexthopIPv6addressTlv
- */
- public static NexthopIPv6addressTlv read(ChannelBuffer c) {
- byte[] yTemp = new byte[20];
- c.readBytes(yTemp, 0, 20);
- return NexthopIPv6addressTlv.of(yTemp);
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- toStrHelper.add("Type", TYPE);
- toStrHelper.add("Length", LENGTH);
-
- StringBuffer result = new StringBuffer();
- for (byte b : rawValue) {
- result.append(String.format("%02X ", b));
- }
- toStrHelper.add("IpAddress", result);
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlv.java
deleted file mode 100644
index 8f03277..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlv.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * NexthopUnnumberedIPv4IDTlv provides the next node's ID and Interface ID.
- */
-public class NexthopUnnumberedIPv4IDTlv implements PcepValueType {
-
- /*
- Reference : draft-zhao-pce-pcep-extension-for-pce-controller-01.
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=TBD | Length = 12 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Node-ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Interface ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- NEXTHOP-UNNUMBERED-IPV4-ID TLV
-
- */
- private static final Logger log = LoggerFactory.getLogger(NexthopUnnumberedIPv4IDTlv.class);
-
- public static final short TYPE = 1; //to be defined
- //Length is header + value
- public static final short LENGTH = 12;
-
- private final int nodeID;
- private final int interfaceID;
-
- /**
- * constructor to initialize nodeID and interfaceID.
- *
- * @param nodeID node ID
- * @param interfaceID interface ID
- */
- public NexthopUnnumberedIPv4IDTlv(int nodeID, int interfaceID) {
- this.nodeID = nodeID;
- this.interfaceID = interfaceID;
- }
-
- /**
- * Returns new object of NexthopUnnumberedIPv4IDTlv.
- *
- * @param nodeID node ID
- * @param interfaceID interface ID
- * @return NexthopUnnumberedIPv4IDTlv
- */
- public static NexthopUnnumberedIPv4IDTlv of(int nodeID, int interfaceID) {
- return new NexthopUnnumberedIPv4IDTlv(nodeID, interfaceID);
- }
-
- /**
- * Returns Node Id.
- *
- * @return node ID
- */
- public int getNodeID() {
- return nodeID;
- }
-
- /**
- * Returns Interface Id.
- *
- * @return interface ID
- */
- public int getInterfaceID() {
- return interfaceID;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(nodeID, interfaceID);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof NexthopUnnumberedIPv4IDTlv) {
- NexthopUnnumberedIPv4IDTlv other = (NexthopUnnumberedIPv4IDTlv) obj;
- return Objects.equals(this.nodeID, other.nodeID) && Objects.equals(this.interfaceID, other.interfaceID);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
-
- c.writeInt(nodeID);
- c.writeInt(interfaceID);
-
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of NexthopUnnumberedIPv4IDTlv.
- *
- * @param cb type of channel buffer
- * @return object of NexthopUnnumberedIPv4IDTlv
- */
- public static NexthopUnnumberedIPv4IDTlv read(ChannelBuffer cb) {
- int nodeID = cb.readInt();
- int interfaceID = cb.readInt();
- return new NexthopUnnumberedIPv4IDTlv(nodeID, interfaceID);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("NodeId", nodeID)
- .add("InterfaceId", interfaceID)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeAttributesTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeAttributesTlv.java
deleted file mode 100644
index 633c46d..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeAttributesTlv.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides TE Node Attributes Tlv.
- */
-public class NodeAttributesTlv implements PcepValueType {
- /*
- * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02
- *
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD20] | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Node Attributes Sub-TLVs (variable) //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
-
- */
-
- private static final Logger log = LoggerFactory.getLogger(NodeAttributesTlv.class);
-
- public static final short TYPE = (short) 65285;
- short hLength;
-
- public static final int TLV_HEADER_LENGTH = 4;
- // LinkDescriptors Sub-TLVs (variable)
- private List<PcepValueType> llNodeAttributesSubTLVs;
-
- /**
- * Constructor to initialize llNodeAttributesSubTLVs.
- *
- * @param llNodeAttributesSubTLVs linked list of Node Attributes Sub-TLVs
- */
- public NodeAttributesTlv(List<PcepValueType> llNodeAttributesSubTLVs) {
- this.llNodeAttributesSubTLVs = llNodeAttributesSubTLVs;
- }
-
- /**
- * Returns object of NodeAttributesTlv.
- *
- * @param llNodeAttributesSubTLVs List of PcepValueType
- * @return object of NodeAttributesTlv
- */
- public static NodeAttributesTlv of(List<PcepValueType> llNodeAttributesSubTLVs) {
- return new NodeAttributesTlv(llNodeAttributesSubTLVs);
- }
-
- /**
- * Returns Node Attributes Sub-TLVs.
- *
- * @return llNodeAttributesSubTLVs linked list of Node Attributes Sub-TLVs
- */
- public List<PcepValueType> getllNodeAttributesSubTLVs() {
- return llNodeAttributesSubTLVs;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(llNodeAttributesSubTLVs.hashCode());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- /*
- * Here we have a list of Tlv so to compare each sub tlv between the object
- * we have to take a list iterator so one by one we can get each sub tlv object
- * and can compare them.
- * it may be possible that the size of 2 lists is not equal so we have to first check
- * the size, if both are same then we should check for the subtlv objects otherwise
- * we should return false.
- */
- if (obj instanceof NodeAttributesTlv) {
- int countObjSubTlv = 0;
- int countOtherSubTlv = 0;
- boolean isCommonSubTlv = true;
- NodeAttributesTlv other = (NodeAttributesTlv) obj;
- Iterator<PcepValueType> objListIterator = ((NodeAttributesTlv) obj).llNodeAttributesSubTLVs.iterator();
- countObjSubTlv = ((NodeAttributesTlv) obj).llNodeAttributesSubTLVs.size();
- countOtherSubTlv = other.llNodeAttributesSubTLVs.size();
- if (countObjSubTlv != countOtherSubTlv) {
- return false;
- } else {
- while (objListIterator.hasNext() && isCommonSubTlv) {
- PcepValueType subTlv = objListIterator.next();
- isCommonSubTlv = Objects.equals(llNodeAttributesSubTLVs.contains(subTlv),
- other.llNodeAttributesSubTLVs.contains(subTlv));
- }
- return isCommonSubTlv;
- }
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int tlvStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- int tlvLenIndex = c.writerIndex();
- hLength = 0;
- c.writeShort(hLength);
-
- ListIterator<PcepValueType> listIterator = llNodeAttributesSubTLVs.listIterator();
-
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
-
- tlv.write(c);
-
- // need to take care of padding
- int pad = tlv.getLength() % 4;
-
- if (0 != pad) {
- pad = 4 - pad;
- for (int i = 0; i < pad; ++i) {
- c.writeByte((byte) 0);
- }
- }
- }
-
- hLength = (short) (c.writerIndex() - tlvStartIndex);
- c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
-
- return c.writerIndex() - tlvStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of NodeAttributesTlv.
- *
- * @param c input channel buffer
- * @param hLength length
- * @return object of NodeAttributesTlv
- * @throws PcepParseException if mandatory fields are missing
- */
- public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException {
-
- // Node Descriptor Sub-TLVs (variable)
- List<PcepValueType> llNodeAttributesSubTLVs = new LinkedList<>();
-
- ChannelBuffer tempCb = c.readBytes(hLength);
-
- while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
- PcepValueType tlv;
- short hType = tempCb.readShort();
- int iValue = 0;
- short length = tempCb.readShort();
- switch (hType) {
-
- case NodeFlagBitsSubTlv.TYPE:
- byte cValue = tempCb.readByte();
- tlv = new NodeFlagBitsSubTlv(cValue);
- break;
- case OpaqueNodePropertiesSubTlv.TYPE:
- tlv = OpaqueNodePropertiesSubTlv.read(tempCb, length);
- break;
- case NodeNameSubTlv.TYPE:
- tlv = NodeNameSubTlv.read(tempCb, length);
- break;
- case IsisAreaIdentifierSubTlv.TYPE:
- tlv = IsisAreaIdentifierSubTlv.read(tempCb, length);
- break;
- case IPv4RouterIdOfLocalNodeSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new IPv4RouterIdOfLocalNodeSubTlv(iValue);
- break;
- case IPv6RouterIdofLocalNodeSubTlv.TYPE:
- byte[] ipv6Value = new byte[IPv6RouterIdofLocalNodeSubTlv.VALUE_LENGTH];
- tempCb.readBytes(ipv6Value, 0, IPv6RouterIdofLocalNodeSubTlv.VALUE_LENGTH);
- tlv = new IPv6RouterIdofLocalNodeSubTlv(ipv6Value);
- break;
- default:
- throw new PcepParseException("Unsupported Sub TLV type :" + hType);
- }
-
- // Check for the padding
- int pad = length % 4;
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= tempCb.readableBytes()) {
- tempCb.skipBytes(pad);
- }
- }
-
- llNodeAttributesSubTLVs.add(tlv);
- }
-
- if (0 < tempCb.readableBytes()) {
-
- throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
- }
- return new NodeAttributesTlv(llNodeAttributesSubTLVs);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", hLength)
- .add("NodeAttributesSubTLVs", llNodeAttributesSubTLVs)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsSubTlv.java
deleted file mode 100644
index 5b0cc78..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsSubTlv.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provide node Flags bits.
- */
-public class NodeFlagBitsSubTlv implements PcepValueType {
-
- /* Reference :[I-D.ietf-idr- ls-distribution] /3.3.1.1
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD21] | Length=1 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |O|T|E|B| Reserved|
- +-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(NodeFlagBitsSubTlv.class);
-
- public static final short TYPE = 13;
- public static final short LENGTH = 1;
- public static final int SET = 1;
- public static final byte OFLAG_SET = (byte) 0x80;
- public static final byte TFLAG_SET = 0x40;
- public static final byte EFLAG_SET = 0x20;
- public static final byte BFLAG_SET = 0x10;
-
- private final byte rawValue;
- private final boolean bOFlag;
- private final boolean bTFlag;
- private final boolean bEFlag;
- private final boolean bBFlag;
- private final boolean isRawValueSet;
-
- /**
- * constructor to initialize rawValue.
- *
- * @param rawValue of Node Flag Bits TLV
- */
- public NodeFlagBitsSubTlv(byte rawValue) {
- this.rawValue = rawValue;
- isRawValueSet = true;
- this.bOFlag = (rawValue & OFLAG_SET) == OFLAG_SET;
- this.bTFlag = (rawValue & TFLAG_SET) == TFLAG_SET;
- this.bEFlag = (rawValue & EFLAG_SET) == EFLAG_SET;
- this.bBFlag = (rawValue & BFLAG_SET) == BFLAG_SET;
- }
-
- /**
- * constructor to initialize different Flags.
- *
- * @param bOFlag O-flag
- * @param bTFlag T-flag
- * @param bEFlag E-flag
- * @param bBFlag B-flag
- */
- public NodeFlagBitsSubTlv(boolean bOFlag, boolean bTFlag, boolean bEFlag, boolean bBFlag) {
- this.bOFlag = bOFlag;
- this.bTFlag = bTFlag;
- this.bEFlag = bEFlag;
- this.bBFlag = bBFlag;
- this.rawValue = 0;
- this.isRawValueSet = false;
- }
-
- /**
- * Returns newly created NodeFlagBitsTlv object.
- *
- * @param raw of Node Flag Bits TLV
- * @return new object of NodeFlagBitsTlv
- */
- public static NodeFlagBitsSubTlv of(final byte raw) {
- return new NodeFlagBitsSubTlv(raw);
- }
-
- /**
- * Returns raw value of NodeFlagBitsTlv.
- *
- * @return rawValue raw value
- */
- public byte getbyte() {
- return rawValue;
- }
-
- /**
- * Returns O-flag.
- *
- * @return bOFlag O-flag
- */
- public boolean getOFlag() {
- return bOFlag;
- }
-
- /**
- * Returns T-flag.
- *
- * @return bTFlag T-flag
- */
- public boolean getTFlag() {
- return bTFlag;
- }
-
- /**
- * Returns E-flag.
- *
- * @return bEFlag E-flag
- */
- public boolean getEFlag() {
- return bEFlag;
- }
-
- /**
- * Returns B-flag.
- *
- * @return bBFlag B-flag
- */
- public boolean getBFlag() {
- return bBFlag;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- if (isRawValueSet) {
- return Objects.hash(rawValue);
- } else {
- return Objects.hash(bOFlag, bTFlag, bEFlag, bBFlag);
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof NodeFlagBitsSubTlv) {
- NodeFlagBitsSubTlv other = (NodeFlagBitsSubTlv) obj;
- if (isRawValueSet) {
- return Objects.equals(this.rawValue, other.rawValue);
- } else {
- return Objects.equals(this.bOFlag, other.bOFlag) && Objects.equals(this.bTFlag, other.bTFlag)
- && Objects.equals(this.bEFlag, other.bEFlag) && Objects.equals(this.bBFlag, other.bBFlag);
- }
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- if (isRawValueSet) {
- c.writeByte(rawValue);
- } else {
- byte temp = 0;
- if (bOFlag) {
- temp = (byte) (temp | OFLAG_SET);
- }
- if (bTFlag) {
- temp = (byte) (temp | TFLAG_SET);
- }
- if (bEFlag) {
- temp = (byte) (temp | EFLAG_SET);
- }
- if (bBFlag) {
- temp = (byte) (temp | BFLAG_SET);
- }
- c.writeByte(temp);
- }
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of NodeFlagBitsTlv.
- *
- * @param c input channel buffer
- * @return object of NodeFlagBitsTlv
- */
- public static PcepValueType read(ChannelBuffer c) {
-
- return NodeFlagBitsSubTlv.of(c.readByte());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("OFlag", (bOFlag) ? 1 : 0)
- .add("TFlag", (bTFlag) ? 1 : 0)
- .add("EFlag", (bEFlag) ? 1 : 0)
- .add("BFlag", (bBFlag) ? 1 : 0)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeNameSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeNameSubTlv.java
deleted file mode 100644
index fc7648c..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeNameSubTlv.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Arrays;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-
-/**
- * Provide the name for the node.
- */
-public class NodeNameSubTlv implements PcepValueType {
-
- /* reference :[I-D.ietf-idr-ls-distribution]/3.3.1.3
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD23] | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // Node Name (variable) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(NodeNameSubTlv.class);
-
- public static final short TYPE = 15;
- public final short hLength;
-
- private final byte[] rawValue;
-
- /**
- * constructor to initialize rawValue.
- *
- * @param rawValue of Node Name
- * @param hLength length
- */
- public NodeNameSubTlv(byte[] rawValue, short hLength) {
- log.debug("NodeNameTlv");
- this.rawValue = rawValue;
- if (0 == hLength) {
- this.hLength = (short) rawValue.length;
- } else {
- this.hLength = hLength;
- }
- }
-
- /**
- * Returns newly created NodeNameTlv object.
- *
- * @param raw of NodeName
- * @param hLength length
- * @return new object of Node Name Tlv
- */
- public static NodeNameSubTlv of(final byte[] raw, short hLength) {
- return new NodeNameSubTlv(raw, hLength);
- }
-
- /**
- * Returns RawValue for NodeName.
- *
- * @return rawValue raw value
- */
- public byte[] getValue() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof NodeNameSubTlv) {
- NodeNameSubTlv other = (NodeNameSubTlv) obj;
- return Arrays.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(hLength);
- c.writeBytes(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of NodeNameTlv.
- *
- * @param c input channel buffer
- * @param hLength length
- * @return object of Node Name TLV
- */
- public static PcepValueType read(ChannelBuffer c, short hLength) {
- byte[] iNodeName = new byte[hLength];
- c.readBytes(iNodeName, 0, hLength);
- return new NodeNameSubTlv(iNodeName, hLength);
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- toStrHelper.add("Type", TYPE);
- toStrHelper.add("Length", hLength);
-
- StringBuffer result = new StringBuffer();
- for (byte b : rawValue) {
- result.append(String.format("%02X ", b));
- }
- toStrHelper.add("Value", result);
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueLinkAttributeSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueLinkAttributeSubTlv.java
deleted file mode 100644
index cec7292..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueLinkAttributeSubTlv.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Arrays;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-
-/**
- * Provides Opaque Link Attribute.
- */
-public class OpaqueLinkAttributeSubTlv implements PcepValueType {
-
- /*
- * TLV format.
- * Reference :[I-D.ietf-idr-attributesls-distribution] /3.3.2.6
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=TBD42 | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // Opaque link attributes (variable) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(OpaqueLinkAttributeSubTlv.class);
-
- public static final short TYPE = 31;
- private final short hLength;
-
- private final byte[] rawValue;
-
- /**
- * constructor to initialize rawValue.
- *
- * @param rawValue of Opaque Link Attribute
- * @param hLength length
- */
- public OpaqueLinkAttributeSubTlv(byte[] rawValue, short hLength) {
- log.debug("OpaqueLinkAttributeTlv");
- this.rawValue = rawValue;
- if (0 == hLength) {
- this.hLength = (short) rawValue.length;
- } else {
- this.hLength = hLength;
- }
- }
-
- /**
- * Returns newly created OpaqueLinkAttributeTlv object.
- *
- * @param raw of Opaque Link Attribute
- * @param hLength length
- * @return new object of OpaqueLinkAttributeTlv
- */
- public static OpaqueLinkAttributeSubTlv of(final byte[] raw, short hLength) {
- return new OpaqueLinkAttributeSubTlv(raw, hLength);
- }
-
- /**
- * Returns raw value of Opaque Link Attribute Tlv.
- * @return rawValue raw value
- */
- public byte[] getValue() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof OpaqueLinkAttributeSubTlv) {
- OpaqueLinkAttributeSubTlv other = (OpaqueLinkAttributeSubTlv) obj;
- return Arrays.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(hLength);
- c.writeBytes(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of OpaqueLinkAttributeTlv.
- *
- * @param c input channel buffer
- * @param hLength length
- * @return object of Opaque Link Attribute Tlv
- */
- public static PcepValueType read(ChannelBuffer c, short hLength) {
- byte[] iOpaqueValue = new byte[hLength];
- c.readBytes(iOpaqueValue, 0, hLength);
- return new OpaqueLinkAttributeSubTlv(iOpaqueValue, hLength);
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- toStrHelper.add("Type", TYPE);
- toStrHelper.add("Length", hLength);
-
- StringBuffer result = new StringBuffer();
- for (byte b : rawValue) {
- result.append(String.format("%02X ", b));
- }
- toStrHelper.add("Value", result);
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueNodePropertiesSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueNodePropertiesSubTlv.java
deleted file mode 100644
index a03e3de..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueNodePropertiesSubTlv.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Arrays;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-
-/**
- * Provides Opaque node attributes.
- */
-public class OpaqueNodePropertiesSubTlv implements PcepValueType {
- /*
- * Reference [I-D.ietf-idr-Properties ls-distribution] /3.3.1.5
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD22] | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // Opaque node attributes (variable) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(OpaqueNodePropertiesSubTlv.class);
-
- public static final short TYPE = 14;
- private final short hLength;
-
- private final byte[] rawValue;
-
- /**
- * constructor to initialize rawValue.
- *
- * @param rawValue Opaque Node Attribute
- * @param hLength length
- */
- public OpaqueNodePropertiesSubTlv(byte[] rawValue, short hLength) {
-
- this.rawValue = rawValue;
- if (0 == hLength) {
- this.hLength = (short) rawValue.length;
- } else {
- this.hLength = hLength;
- }
- }
-
- /**
- * Returns newly created OpaqueNodeAttributeTlv object.
- *
- * @param raw value of Opaque Node Attribute
- * @param hLength length
- * @return new object of Opaque Node Attribute Tlv
- */
- public static OpaqueNodePropertiesSubTlv of(final byte[] raw, short hLength) {
- return new OpaqueNodePropertiesSubTlv(raw, hLength);
- }
-
- /**
- * Returns raw value of Opaque Node Attribute Tlv.
- *
- * @return rawValue of Opaque Node Attribute
- */
- public byte[] getValue() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof OpaqueNodePropertiesSubTlv) {
- OpaqueNodePropertiesSubTlv other = (OpaqueNodePropertiesSubTlv) obj;
- return Arrays.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(hLength);
- c.writeBytes(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of Opaque Node Attribute Tlv.
- *
- * @param c input channel buffer
- * @param hLength length
- * @return object of OpaqueNodeAttributeTlv
- */
- public static PcepValueType read(ChannelBuffer c, short hLength) {
- byte[] iOpaqueValue = new byte[hLength];
- c.readBytes(iOpaqueValue, 0, hLength);
- return new OpaqueNodePropertiesSubTlv(iOpaqueValue, hLength);
- }
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- toStrHelper.add("Type", TYPE);
- toStrHelper.add("Length", hLength);
-
- StringBuffer result = new StringBuffer();
- for (byte b : rawValue) {
- result.append(String.format("%02X ", b));
- }
- toStrHelper.add("Value", result);
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OspfAreaIdSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OspfAreaIdSubTlv.java
deleted file mode 100644
index 5e77e2f..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OspfAreaIdSubTlv.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.base.MoreObjects;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Objects;
-
-/**
- * Provides area ID for OSPF area.
- */
-public class OspfAreaIdSubTlv implements PcepValueType {
-
- /* Reference :draft-ietf-idr-ls-distribution-10.
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD12] | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | opaque value (32 Bit AS Number) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(OspfAreaIdSubTlv.class);
-
- public static final short TYPE = 3;
- public static final short LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * constructor to initialize rawValue.
- *
- * @param rawValue area ID for OSPF area.
- */
- public OspfAreaIdSubTlv(int rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created OSPFareaIDsubTlv object.
- *
- * @param raw opaque value of AreaID
- * @return new object of OSPF area ID sub TLV
- */
- public static OspfAreaIdSubTlv of(final int raw) {
- return new OspfAreaIdSubTlv(raw);
- }
-
- /**
- * Returns RawValue opaque value of AreaID.
- *
- * @return rawValue Area ID
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof OspfAreaIdSubTlv) {
- OspfAreaIdSubTlv other = (OspfAreaIdSubTlv) obj;
- return Objects.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of OSPFAreaIdSubTlv.
- *
- * @param c input channel buffer
- * @return object of OSPFAreaIdSubTlv
- */
- public static OspfAreaIdSubTlv read(ChannelBuffer c) {
- return OspfAreaIdSubTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathKeySubObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathKeySubObject.java
deleted file mode 100644
index dd177b4..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathKeySubObject.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Path Key SubObject: When a PCC needs to expand a path-key in order to expand a CPS, it
- * issues a Path Computation Request (PCReq) to the PCE identified in
- * the PKS in the RSVP-TE ERO that it is processing. The PCC supplies
- * the PKS to be expanded in a PATH-KEY SubObject in the PCReq message.
- */
-public class PathKeySubObject implements PcepValueType {
-
- /*
- Pathkey subobject(RFC 5520):
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |L| Type | Length | Path-Key |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | PCE ID (4 bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(PathKeySubObject.class);
-
- public static final byte TYPE = 0x40;
- public static final byte LENGTH = 8;
- private final short pathKey;
- private final int pceID;
-
- /**
- * Constructor for Path Key sub Object which initializes pathKey and pceId.
- *
- * @param pathKey path key provided by PCC
- * @param pceID ID for the PCE
- */
- public PathKeySubObject(short pathKey, int pceID) {
- this.pathKey = pathKey;
- this.pceID = pceID;
- }
-
- /**
- * Creates Path Key sub Object which initializes pathKey and pceId.
- *
- * @param pathKey path key provided by PCC
- * @param pceID PCE id
- * @return new object of type path key sub object
- */
- public static PathKeySubObject of(short pathKey, int pceID) {
- return new PathKeySubObject(pathKey, pceID);
- }
-
- /**
- * Returns Path Key.
- *
- * @return pathKey
- */
- public short getPathKey() {
- return pathKey;
- }
-
- /**
- * Returns pceID.
- *
- * @return pceID
- */
- public int getPceId() {
- return pceID;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(pathKey, pceID);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof PathKeySubObject) {
- PathKeySubObject other = (PathKeySubObject) obj;
- return Objects.equals(this.pathKey, other.pathKey) && Objects.equals(this.pceID, other.pceID);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
-
- c.writeShort(pathKey);
- c.writeInt(pceID);
-
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns new path key sub objects.
- *
- * @param c of type channel buffer
- * @return object of type path key sub object
- */
- public static PcepValueType read(ChannelBuffer c) {
- Short pathKey = c.readShort();
- int pceID = c.readInt();
- return new PathKeySubObject(pathKey, pceID);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("PathKey", pathKey)
- .add("PceID", pceID)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java
deleted file mode 100644
index 1f993de..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PcepSetup type tlv.
- */
-public class PathSetupTypeTlv implements PcepValueType {
-
- /*
- Reference : draft-sivabalan-pce-lsp-setup-type-02.
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Reserved | PST |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Figure 1: PATH-SETUP-TYPE TLV
-
- */
- private static final Logger log = LoggerFactory.getLogger(PathSetupTypeTlv.class);
-
- public static final short TYPE = 28;
- public static final short LENGTH = 4;
-
- private final byte pst;
- private final int rawValue;
- private final boolean isRawValueSet;
-
- /**
- * Constructor to initialize parameters for path setup type tlv.
- *
- * @param rawValue parameter for path setup type tlv
- */
- public PathSetupTypeTlv(final int rawValue) {
- this.rawValue = rawValue;
- this.isRawValueSet = true;
- this.pst = (byte) rawValue;
- }
-
- /**
- * Constructor to initialize pst.
- *
- * @param pst PST
- */
- public PathSetupTypeTlv(byte pst) {
- this.pst = pst;
- this.rawValue = 0;
- this.isRawValueSet = false;
- }
-
- /**
- * Returns Object of path setup type tlv.
- *
- * @param raw parameter for path setup type tlv
- * @return object of PathSetupTypeTlv
- */
- public static PathSetupTypeTlv of(final int raw) {
- return new PathSetupTypeTlv(raw);
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- /**
- * Returns parameters for path setup type tlv.
- *
- * @return parameters for path setup type tlv
- */
- public int getInt() {
- return rawValue;
- }
-
- /**
- * Returns the pst value.
- *
- * @return pst value
- */
- public byte getPst() {
- return pst;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(pst);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof PathSetupTypeTlv) {
- PathSetupTypeTlv other = (PathSetupTypeTlv) obj;
- return Objects.equals(this.pst, other.pst);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(pst);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Returns the object of type PathSetupTypeTlv.
- *
- * @param c is type Channel buffer
- * @return object of PathSetupTypeTlv
- */
- public static PathSetupTypeTlv read(ChannelBuffer c) {
- return PathSetupTypeTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("PST", pst)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java
deleted file mode 100644
index 0f29c53..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PceccCapabilityTlv.
- */
-public class PceccCapabilityTlv implements PcepValueType {
-
- /* PCECC CAPABILITY TLV
- * Reference : draft-zhao-pce-pcep-extension-for-pce-controller-03, section-7.1.1
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD] | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Flags |S|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- */
- private static final Logger log = LoggerFactory.getLogger(PceccCapabilityTlv.class);
-
- public static final short TYPE = (short) 65287;
- public static final short LENGTH = 4;
- public static final int SET = 1;
- public static final byte SBIT_CHECK = 0x01;
-
- private final boolean sBit;
-
- private final int rawValue;
- private final boolean isRawValueSet;
-
- /**
- * Constructor to initialize raw Value.
- *
- * @param rawValue raw value
- */
- public PceccCapabilityTlv(final int rawValue) {
- this.rawValue = rawValue;
- this.isRawValueSet = true;
-
- sBit = (rawValue & SBIT_CHECK) == SBIT_CHECK;
- }
-
- /**
- * Constructor to initialize G-flag L-flag.
- *
- * @param sBit pcecc sr capbaility bit
- */
- public PceccCapabilityTlv(boolean sBit) {
- this.sBit = sBit;
- this.rawValue = 0;
- this.isRawValueSet = false;
- }
-
- /**
- * Returns newly created PceccCapabilityTlv object.
- *
- * @param raw value
- * @return object of Pcecc Capability Tlv
- */
- public static PceccCapabilityTlv of(final int raw) {
- return new PceccCapabilityTlv(raw);
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- /**
- * Returns sBit.
- *
- * @return sBit S bit
- */
- public boolean sBit() {
- return sBit;
- }
-
- /**
- * Returns the raw value.
- *
- * @return rawValue Flags
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- if (isRawValueSet) {
- return Objects.hash(rawValue);
- } else {
- return Objects.hash(sBit);
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof PceccCapabilityTlv) {
- PceccCapabilityTlv other = (PceccCapabilityTlv) obj;
- if (isRawValueSet) {
- return Objects.equals(this.rawValue, other.rawValue);
- } else {
- return Objects.equals(this.sBit, other.sBit);
- }
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- int temp = 0;
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- if (isRawValueSet) {
- c.writeInt(rawValue);
- } else {
- if (sBit) {
- temp = temp | SBIT_CHECK;
- }
- c.writeInt(temp);
- }
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads channel buffer and returns object of PceccCapabilityTlv.
- *
- * @param c input channel buffer
- * @return object of PceccCapabilityTlv
- */
- public static PceccCapabilityTlv read(ChannelBuffer c) {
- return PceccCapabilityTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("rawValue", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepErrorDetailInfo.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepErrorDetailInfo.java
deleted file mode 100644
index f1382a6..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepErrorDetailInfo.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-/**
- * Provide the PCEP Error Info Details.
- */
-public final class PcepErrorDetailInfo {
-
- private PcepErrorDetailInfo() {
- }
-
- // Error Types
- /**
- Error- Meaning Reference:RFC 5440
- Type
- 1 PCEP session establishment failure
- Error-value=1: reception of an invalid Open message or a non Open message.
- Error-value=2: no Open message received before the expiration of the OpenWait timer
- Error-value=3: unacceptable and non-negotiable session characteristics
- Error-value=4: unacceptable but negotiable session characteristics
- Error-value=5: reception of a second Open message with still unacceptable session characteristics
- Error-value=6: reception of a PCErr message proposing unacceptable session characteristics
- Error-value=7: No Keepalive or PCErr message received before the expiration of the KeepWait timer
- Error-value=8: PCEP version not supported
- 2 Capability not supported
- 3 Unknown Object
- Error-value=1: Unrecognized object class
- Error-value=2: Unrecognized object Type
- 4 Not supported object
- Error-value=1: Not supported object class
- Error-value=2: Not supported object Type
- 5 Policy violation
- Error-value=1: C bit of the METRIC object set (request rejected)
- Error-value=2: O bit of the RP object cleared (request rejected)
- 6 Mandatory Object missing
- Error-value=1: RP object missing
- Error-value=2: RRO missing for a re-optimization request (R bit of the RP object set)
- Error-value=3: END-POINTS object missing
- 7 Synchronized path computation request missing
- 8 Unknown request reference
- 9 Attempt to establish a second PCEP session
- 10 Reception of an invalid object
- Error-value=1: reception of an object with P flag not set although the P flag must be
- set according to this specification.
-
- Reference draft-ietf-pce-stateful-pce-11, section : 8.4
- 19 Invalid Operation
- Error-value=1: Attempted LSP Update Request for a non-
- delegated LSP. The PCEP-ERROR Object
- is followed by the LSP Object that
- identifies the LSP.
- Error-value=2: Attempted LSP Update Request if the
- stateful PCE capability was not
- advertised.
- Error-value=3: Attempted LSP Update Request for an LSP
- identified by an unknown PLSP-ID.
- Error-value=4: A PCE indicates to a PCC that it has
- exceeded the resource limit allocated
- for its state, and thus it cannot
- accept and process its LSP State Report
- message.
- Error-value=5: Attempted LSP State Report if active
- stateful PCE capability was not
- advertised.
- */
- public static final byte ERROR_TYPE_1 = 1;
- public static final byte ERROR_TYPE_2 = 2;
- public static final byte ERROR_TYPE_3 = 3;
- public static final byte ERROR_TYPE_4 = 4;
- public static final byte ERROR_TYPE_5 = 5;
- public static final byte ERROR_TYPE_6 = 6;
- public static final byte ERROR_TYPE_7 = 7;
- public static final byte ERROR_TYPE_8 = 8;
- public static final byte ERROR_TYPE_9 = 9;
- public static final byte ERROR_TYPE_10 = 10;
- public static final byte ERROR_TYPE_19 = 19;
-
- // Error Values
- public static final byte ERROR_VALUE_1 = 1;
- public static final byte ERROR_VALUE_2 = 2;
- public static final byte ERROR_VALUE_3 = 3;
- public static final byte ERROR_VALUE_4 = 4;
- public static final byte ERROR_VALUE_5 = 5;
- public static final byte ERROR_VALUE_6 = 6;
- public static final byte ERROR_VALUE_7 = 7;
- public static final byte ERROR_VALUE_8 = 8;
- public static final byte ERROR_VALUE_9 = 9;
- public static final byte ERROR_VALUE_10 = 10;
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java
deleted file mode 100644
index b3ace4b..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides CEP LABEL DB VERSION TLV which contains LSP State DB Version (32 Bit ).
- */
-public class PcepLabelDbVerTlv implements PcepValueType {
-
- /* PCEP LABEL DB VERSION TLV format
-
- Reference : draft-ietf-pce-stateful-sync-optimizations-02, section 3.3.1
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=23 | Length=8 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LSP State DB Version |
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- */
- private static final Logger log = LoggerFactory.getLogger(PcepLabelDbVerTlv.class);
-
- public static final short TYPE = 34;
- public static final short LENGTH = 8;
- private final long rawValue;
-
- /**
- * constructor to initialize rawValue.
- *
- * @param rawValue of Pcep Label Db Version Tlv
- */
- public PcepLabelDbVerTlv(final long rawValue) {
- log.debug("PcepLabelDbVerTlv");
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created PcepLabelDbVerTlv object.
- *
- * @param raw LSP State DB Version
- * @return object of PcepLabelDbVerTlv
- */
- public static PcepLabelDbVerTlv of(final long raw) {
- return new PcepLabelDbVerTlv(raw);
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- /**
- * Returns LSP State DB Version.
- * @return raw value
- */
- public long getLong() {
- return rawValue;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof PcepLabelDbVerTlv) {
- PcepLabelDbVerTlv other = (PcepLabelDbVerTlv) obj;
- return Objects.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeLong(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of PcepLabelDbVerTlv.
- *
- * @param c input channel buffer
- * @return object of PcepLabelDbVerTlv
- */
- public static PcepLabelDbVerTlv read(ChannelBuffer c) {
- return PcepLabelDbVerTlv.of(c.readLong());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java
deleted file mode 100644
index 90c665b..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.LinkedList;
-
-import org.onosproject.pcepio.protocol.PcepLabelObject;
-import org.onosproject.pcepio.protocol.PcepLspObject;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Pcep Label.
- * REference :draft-zhao-pce-pcep-extension-for-pce-controller-01.
- */
-public class PcepLabelDownload {
-
- private static final Logger log = LoggerFactory.getLogger(PcepLabelDownload.class);
-
- //PCEP SPR Object
- private PcepSrpObject srpObject;
- //PCEP LSP Object
- private PcepLspObject lspObject;
- //LinkList of Labels
- private LinkedList<PcepLabelObject> llLabelList;
-
- /**
- * Returns SRP Object.
- *
- * @return PCEP SRP Object
- */
- public PcepSrpObject getSrpObject() {
- return srpObject;
- }
-
- /**
- * Sets the Pcep SRP Object.
- *
- * @param srpobj PCEP SRP Object
- */
- public void setSrpObject(PcepSrpObject srpobj) {
- this.srpObject = srpobj;
- }
-
- /**
- * Returns LSP Object.
- *
- * @return PCEP LSP Object
- */
- public PcepLspObject getLspObject() {
- return lspObject;
- }
-
- /**
- * Sets the Pcep LSP Object.
- *
- * @param lspObject PCEP LSP Object
- */
- public void setLspObject(PcepLspObject lspObject) {
- this.lspObject = lspObject;
- }
-
- /**
- * Returns a list of labels.
- *
- * @return llLabelList list of pcep label objects
- */
- public LinkedList<PcepLabelObject> getLabelList() {
- return llLabelList;
- }
-
- /**
- * set the llLabelList list of type PcepLableObject.
- *
- * @param llLabelList list of pcep label objects
- */
- public void setLabelList(LinkedList<PcepLabelObject> llLabelList) {
- this.llLabelList = llLabelList;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("SrpObject", srpObject)
- .add("LspObject", lspObject)
- .add("LabelObjectList", llLabelList)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelMap.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelMap.java
deleted file mode 100644
index 00fec74..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelMap.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import org.onosproject.pcepio.protocol.PcepFecObject;
-import org.onosproject.pcepio.protocol.PcepLabelObject;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provide PCEP Label Map.
- * Reference :draft-zhao-pce-pcep-extension-for-pce-controller-01.
- */
-public class PcepLabelMap {
-
- private static final Logger log = LoggerFactory.getLogger(PcepLabelMap.class);
- //PCEP SRP Object
- private PcepSrpObject srpObject;
- //PCEP Label Object
- private PcepLabelObject labelObject;
- //PCEP FEC Object
- private PcepFecObject fecObject;
-
- /**
- * Sets Fec Object.
- *
- * @param fecObject PCEP fec object
- */
- public void setFecObject(PcepFecObject fecObject) {
- this.fecObject = fecObject;
- }
-
- /**
- * Returns the PcepFecObject.
- *
- * @return PCEP fec object
- */
- public PcepFecObject getFecObject() {
- return this.fecObject;
- }
-
- /**
- * Returns SRP Object.
- *
- * @return PCEP SRP Object
- */
- public PcepSrpObject getSrpObject() {
- return srpObject;
- }
-
- /**
- * Sets the PCEP Srp Object.
- *
- * @param srpObject PCEP SRP Object
- */
- public void setSrpObject(PcepSrpObject srpObject) {
- this.srpObject = srpObject;
- }
-
- /**
- * Returns labelObject.
- *
- * @return PCEP label object
- */
- public PcepLabelObject getLabelObject() {
- return labelObject;
- }
-
- /**
- * Sets the Pcep labelObject.
- *
- * @param labelObject PCEP label object
- */
- public void setLabelObject(PcepLabelObject labelObject) {
- this.labelObject = labelObject;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("SrpObject", srpObject)
- .add("LabelObject", labelObject)
- .add("FecObject", fecObject)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
deleted file mode 100644
index 3cf186d..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepNai;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Pcep Nai Ipv4 Adjacency.
- */
-public class PcepNaiIpv4Adjacency implements PcepNai {
-
- public static final byte ST_TYPE = 0x03;
- private final int localIpv4Addr;
- private final int remoteIpv4Addr;
-
- /**
- * Constructor to initialize variables.
- *
- * @param localIpv4 local ipv4 address
- * @param remoteIpv4 remote ipv4 address
- */
- public PcepNaiIpv4Adjacency(int localIpv4, int remoteIpv4) {
- this.localIpv4Addr = localIpv4;
- this.remoteIpv4Addr = remoteIpv4;
- }
-
- /**
- * Returns Object of Pcep nai Ipv4 Adjacency.
- *
- * @param localIpv4Addr local ipv4 address
- * @param remoteIpv4Addr remote ipv4 address
- * @return Object of Pcep nai Ipv4 Adjacency
- */
- public static PcepNaiIpv4Adjacency of(int localIpv4Addr, int remoteIpv4Addr) {
- return new PcepNaiIpv4Adjacency(localIpv4Addr, remoteIpv4Addr);
- }
-
- @Override
- public byte getType() {
- return ST_TYPE;
- }
-
- public int getLocalIpv4Addr() {
- return localIpv4Addr;
- }
-
- public int getRemoteIpv4Addr() {
- return remoteIpv4Addr;
- }
-
- @Override
- public int write(ChannelBuffer bb) {
- int iLenStartIndex = bb.writerIndex();
- bb.writeInt(localIpv4Addr);
- bb.writeInt(remoteIpv4Addr);
- return bb.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of PcepNAIIpv4AdjacencyVer1.
- *
- * @param cb of channel buffer
- * @return object of PcepNAIIpv4Adjacency
- */
- public static PcepNaiIpv4Adjacency read(ChannelBuffer cb) {
- int localIpv4 = cb.readInt();
- int remoteIpv4 = cb.readInt();
- return new PcepNaiIpv4Adjacency(localIpv4, remoteIpv4);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(localIpv4Addr, remoteIpv4Addr);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof PcepNaiIpv4Adjacency) {
- PcepNaiIpv4Adjacency other = (PcepNaiIpv4Adjacency) obj;
- return Objects.equals(this.localIpv4Addr, other.localIpv4Addr)
- && Objects.equals(this.remoteIpv4Addr, other.remoteIpv4Addr);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("localIPv4Address", localIpv4Addr)
- .add("remoteIPv4Address", remoteIpv4Addr)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeId.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeId.java
deleted file mode 100644
index 0847be0..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeId.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onlab.util.Identifier;
-import org.onosproject.pcepio.protocol.PcepNai;
-
-/**
- * Provides Pcep Nai Ipv4 Node Id.
- */
-public class PcepNaiIpv4NodeId extends Identifier<Integer> implements PcepNai {
-
- public static final byte ST_TYPE = 0x01;
-
- /**
- * Constructor to initialize ipv4NodeId.
- *
- * @param value ipv4 node id
- */
- public PcepNaiIpv4NodeId(int value) {
- super(value);
- }
-
- /**
- * Returns an object of PcepNaiIpv4NodeId.
- *
- * @param value ipv4 node id
- * @return object of PcepNaiIpv4NodeId
- */
- public static PcepNaiIpv4NodeId of(int value) {
- return new PcepNaiIpv4NodeId(value);
- }
-
- @Override
- public byte getType() {
- return ST_TYPE;
- }
-
- @Override
- public int write(ChannelBuffer bb) {
- int iLenStartIndex = bb.writerIndex();
- bb.writeInt(identifier);
- return bb.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads from the channel buffer and returns object of PcepNAIIpv4NodeIdVer1.
- *
- * @param bb of channel buffer.
- * @return object of PcepNAIIpv4NodeIdVer1
- */
- public static PcepNaiIpv4NodeId read(ChannelBuffer bb) {
- return new PcepNaiIpv4NodeId(bb.readInt());
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6Adjacency.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6Adjacency.java
deleted file mode 100644
index 1a162e2..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6Adjacency.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Arrays;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepNai;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Pcep Nai Ipv6 Adjacency.
- */
-public class PcepNaiIpv6Adjacency implements PcepNai {
-
- public static final byte ST_TYPE = 0x04;
- public static final byte IPV6_LEN = 0x10;
-
- private final byte[] localIpv6Addr;
- private final byte[] remoteIpv6Addr;
-
- /**
- * Constructor to initialize local ipv6 and remote ipv6.
- *
- * @param localIpv6 local ipv6 address
- * @param remoteIpv6 remote ipv6 address
- */
- public PcepNaiIpv6Adjacency(byte[] localIpv6, byte[] remoteIpv6) {
- this.localIpv6Addr = localIpv6;
- this.remoteIpv6Addr = remoteIpv6;
- }
-
- @Override
- public byte getType() {
- return ST_TYPE;
- }
-
- @Override
- public int write(ChannelBuffer bb) {
- int iLenStartIndex = bb.writerIndex();
- bb.writeBytes(localIpv6Addr);
- bb.writeBytes(remoteIpv6Addr);
- return bb.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads from channel buffer and returns object of PcepNAIIpv6AdjacencyVer1.
- *
- * @param bb of type channel buffer
- * @return object of PcepNAIIpv6AdjacencyVer1
- */
- public static PcepNaiIpv6Adjacency read(ChannelBuffer bb) {
- byte[] localIpv6 = new byte[IPV6_LEN];
- bb.readBytes(localIpv6, 0, IPV6_LEN);
- byte[] remoteIpv6 = new byte[IPV6_LEN];
- bb.readBytes(remoteIpv6, 0, IPV6_LEN);
- return new PcepNaiIpv6Adjacency(localIpv6, remoteIpv6);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(Arrays.hashCode(localIpv6Addr), Arrays.hashCode(remoteIpv6Addr));
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof PcepNaiIpv6Adjacency) {
- PcepNaiIpv6Adjacency other = (PcepNaiIpv6Adjacency) obj;
- return Arrays.equals(this.localIpv6Addr, other.localIpv6Addr)
- && Arrays.equals(this.remoteIpv6Addr, other.remoteIpv6Addr);
- }
- return false;
- }
-
- /**
- * Creates object of PcepNaiIpv6Adjacency with local ipv6 address and remote ipv6 address.
- *
- * @param localIpv6Addr local ipv6 address
- * @param remoteIpv6Addr remote ipv6 address
- * @return object of PcepNaiIpv6Adjacency
- */
-
- public static PcepNaiIpv6Adjacency of(final byte[] localIpv6Addr, final byte[] remoteIpv6Addr) {
- return new PcepNaiIpv6Adjacency(localIpv6Addr, remoteIpv6Addr);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("localIPV6Address", localIpv6Addr)
- .add("remoteIPV6Address", remoteIpv6Addr)
- .toString();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java
deleted file mode 100644
index 1daf071..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepNai;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Pcep Nai Ipv6 Node Id.
- */
-public class PcepNaiIpv6NodeId implements PcepNai {
-
- public static final byte ST_TYPE = 0x02;
- public static final byte IPV6_LEN = 0x10;
-
- private final byte[] ipv6NodeId;
-
- /**
- * Constructor to initialize ipv6NodeId.
- *
- * @param value ipv6 node id
- */
- public PcepNaiIpv6NodeId(byte[] value) {
- this.ipv6NodeId = value;
- }
-
- /**
- * Return object of Pcep Nai Ipv6 Node ID.
- *
- * @param ipv6NodeId Ipv6 node ID.
- * @return object of Pcep Nai Ipv6 Node ID.
- */
- public static PcepNaiIpv6NodeId of(byte[] ipv6NodeId) {
- return new PcepNaiIpv6NodeId(ipv6NodeId);
- }
-
- @Override
- public byte getType() {
- return ST_TYPE;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- int iLenStartIndex = cb.writerIndex();
- cb.writeBytes(ipv6NodeId);
- return cb.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads from the channel buffer and returns object of PcepNAIIpv6NodeId.
- *
- * @param cb of type channel buffer.
- * @return object of PcepNAIIpv6NodeId
- */
- public static PcepNaiIpv6NodeId read(ChannelBuffer cb) {
- byte[] ipv6NodeId = new byte[IPV6_LEN];
- cb.readBytes(ipv6NodeId, 0, IPV6_LEN);
- return new PcepNaiIpv6NodeId(ipv6NodeId);
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(ipv6NodeId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof PcepNaiIpv6NodeId) {
- PcepNaiIpv6NodeId other = (PcepNaiIpv6NodeId) obj;
- return Arrays.equals(this.ipv6NodeId, other.ipv6NodeId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("IPV6NodeID", ipv6NodeId)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java
deleted file mode 100644
index d615e18..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepNai;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Pcep Nai Unnumbered Adjacency Ipv4.
- */
-public class PcepNaiUnnumberedAdjacencyIpv4 implements PcepNai {
- /**
- * draft-ietf-pce-segment-routing-03 section 5.3.2.
- */
- public static final byte ST_TYPE = 0x05;
-
- private final int localNodeId;
- private final int localInterfaceId;
- private final int remoteNodeId;
- private final int remoteInterfaceId;
-
- /**
- * Constructor to initialize all the member variables.
- *
- * @param localNodeId local node id
- * @param localInterfaceId local interface id
- * @param remoteNodeId remote node id
- * @param remoteInterfaceId remote interface id
- */
- public PcepNaiUnnumberedAdjacencyIpv4(int localNodeId, int localInterfaceId, int remoteNodeId,
- int remoteInterfaceId) {
- this.localNodeId = localNodeId;
- this.localInterfaceId = localInterfaceId;
- this.remoteNodeId = remoteNodeId;
- this.remoteInterfaceId = remoteInterfaceId;
- }
-
- /**
- * Returns PCEP Nai Unnumbered Adjacency Ipv4 object.
- *
- * @param localNodeId local node id
- * @param localInterfaceId local interface if
- * @param remoteNodeId remote node id
- * @param remoteInterfaceId remote interface id
- * @return PCEP Nai Unnumbered Adjacency Ipv4 object
- */
- public static PcepNaiUnnumberedAdjacencyIpv4 of(int localNodeId, int localInterfaceId, int remoteNodeId,
- int remoteInterfaceId) {
- return new PcepNaiUnnumberedAdjacencyIpv4(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
- }
-
- @Override
- public byte getType() {
- return ST_TYPE;
- }
-
- @Override
- public int write(ChannelBuffer bb) {
- int iLenStartIndex = bb.writerIndex();
- bb.writeInt(localNodeId);
- bb.writeInt(localInterfaceId);
- bb.writeInt(remoteNodeId);
- bb.writeInt(remoteInterfaceId);
- return bb.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads from channel buffer and return object of PcepNAIUnnumberedAdjacencyIpv4.
- *
- * @param bb of type channel buffer
- * @return object of PcepNAIUnnumberedAdjacencyIpv4
- */
- public static PcepNaiUnnumberedAdjacencyIpv4 read(ChannelBuffer bb) {
- int localNodeId;
- int localInterfaceId;
- int remoteNodeId;
- int remoteInterfaceId;
- localNodeId = bb.readInt();
- localInterfaceId = bb.readInt();
- remoteNodeId = bb.readInt();
- remoteInterfaceId = bb.readInt();
- return new PcepNaiUnnumberedAdjacencyIpv4(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof PcepNaiUnnumberedAdjacencyIpv4) {
- PcepNaiUnnumberedAdjacencyIpv4 other = (PcepNaiUnnumberedAdjacencyIpv4) obj;
- return Objects.equals(this.localNodeId, other.localNodeId)
- && Objects.equals(this.localInterfaceId, other.localInterfaceId)
- && Objects.equals(this.remoteNodeId, other.remoteNodeId)
- && Objects.equals(this.remoteInterfaceId, other.remoteInterfaceId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("localNodeId", localNodeId)
- .add("localInterfaceId", localInterfaceId)
- .add("remoteNodeId", remoteNodeId)
- .add("remoteInterfaceId", remoteInterfaceId)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepObjectHeader.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepObjectHeader.java
deleted file mode 100644
index ad4615c..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepObjectHeader.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PCEP Object Header which is common for all the objects.
- * Reference : RFC 5440.
- */
-
-public class PcepObjectHeader {
-
- /*
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Object-Class | OT |Res|P|I| Object Length (bytes) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // (Object body) //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- PCEP Common Object Header
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepObjectHeader.class);
-
- public static final boolean REQ_OBJ_MUST_PROCESS = true;
- public static final boolean REQ_OBJ_OPTIONAL_PROCESS = false;
- public static final boolean RSP_OBJ_IGNORED = true;
- public static final boolean RSP_OBJ_PROCESSED = false;
- public static final int OBJECT_TYPE_SHIFT_VALUE = 4;
- public static final byte PFLAG_SET = 0x02;
- public static final byte IFLAG_SET = 0x01;
- public static final int SET = 1;
- private byte objClass;
- private byte objType;
- private boolean bPFlag;
- private boolean bIFlag;
- private short objLen;
-
- /**
- * Constructor to initialize all the variables in object header.
- *
- * @param objClass PCEP Object class
- * @param objType PCEP Object type
- * @param bPFlag P flag
- * @param bIFlag I flag
- * @param objLen PCEP object length
- */
-
- public PcepObjectHeader(byte objClass, byte objType, boolean bPFlag, boolean bIFlag, short objLen) {
- this.objClass = objClass;
- this.objType = objType;
- this.bPFlag = bPFlag;
- this.bIFlag = bIFlag;
- this.objLen = objLen;
- }
-
- /**
- * Sets the Object class.
- *
- * @param value object class
- */
- public void setObjClass(byte value) {
- this.objClass = value;
- }
-
- /**
- * Sets the Object TYPE.
- *
- * @param value object type
- */
- public void setObjType(byte value) {
- this.objType = value;
- }
-
- /**
- * Sets the Object P flag.
- *
- * @param value p flag
- */
- public void setPFlag(boolean value) {
- this.bPFlag = value;
- }
-
- /**
- * Sets the Object I flag.
- *
- * @param value I flag
- */
- public void setIFlag(boolean value) {
- this.bIFlag = value;
- }
-
- /**
- * Sets the Object Length.
- *
- * @param value object length
- */
- public void setObjLen(short value) {
- this.objLen = value;
- }
-
- /**
- * Returns Object's P flag.
- *
- * @return bPFlag P flag
- */
- public boolean getPFlag() {
- return this.bPFlag;
- }
-
- /**
- * Returns Object's i flag.
- *
- * @return bIFlag I flag
- */
- public boolean getIFlag() {
- return this.bIFlag;
- }
-
- /**
- * Returns Object Length.
- *
- * @return objLen object length
- */
- public short getObjLen() {
- return this.objLen;
- }
-
- /**
- * Returns Object class.
- *
- * @return objClass object class
- */
- public byte getObjClass() {
- return this.objClass;
- }
-
- /**
- * Returns Object Type.
- *
- * @return objType object type
- */
- public byte getObjType() {
- return this.objType;
- }
-
- /**
- * Writes Byte stream of PCEP object header to channel buffer.
- *
- * @param cb output channel buffer
- * @return objLenIndex object length index in channel buffer
- */
- public int write(ChannelBuffer cb) {
-
- cb.writeByte(this.objClass);
- byte temp = (byte) (this.objType << OBJECT_TYPE_SHIFT_VALUE);
- if (this.bPFlag) {
- temp = (byte) (temp | PFLAG_SET);
- }
- if (this.bIFlag) {
- temp = (byte) (temp | IFLAG_SET);
- }
- cb.writeByte(temp);
- int objLenIndex = cb.writerIndex();
- cb.writeShort((short) 0);
- return objLenIndex;
- }
-
- /**
- * Read from channel buffer and Returns PCEP Objects header.
- *
- * @param cb of type channel buffer
- * @return PCEP Object header
- */
- public static PcepObjectHeader read(ChannelBuffer cb) {
-
- byte objClass;
- byte objType;
- boolean bPFlag;
- boolean bIFlag;
- short objLen;
- objClass = cb.readByte();
- byte temp = cb.readByte();
- bIFlag = (temp & IFLAG_SET) == IFLAG_SET;
- bPFlag = (temp & PFLAG_SET) == PFLAG_SET;
- objType = (byte) (temp >> OBJECT_TYPE_SHIFT_VALUE);
- objLen = cb.readShort();
- return new PcepObjectHeader(objClass, objType, bPFlag, bIFlag, objLen);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(objClass, objType, bPFlag, bIFlag, objLen);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof PcepObjectHeader) {
- PcepObjectHeader other = (PcepObjectHeader) obj;
- return Objects.equals(objClass, other.objClass)
- && Objects.equals(objType, other.objType)
- && Objects.equals(bPFlag, other.bPFlag)
- && Objects.equals(bIFlag, other.bIFlag)
- && Objects.equals(objLen, other.objLen);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("ObjectClass", objClass)
- .add("ObjectType", objType)
- .add("ObjectLength", objLen)
- .add("PFlag", (bPFlag) ? 1 : 0)
- .add("IFlag", (bIFlag) ? 1 : 0)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpErrorSpec.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpErrorSpec.java
deleted file mode 100644
index 326cc91..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpErrorSpec.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-
-/**
- * Abstraction of an entity which provides PCPE RSVP error spec.
- */
-public interface PcepRsvpErrorSpec extends PcepValueType {
-
- /**
- * To write the object information to channelBuffer.
- *
- * @param cb of type channel buffer
- */
- @Override
- int write(ChannelBuffer cb);
-
- /**
- * Returns class number.
- *
- * @return class number
- */
- byte getClassNum();
-
- /**
- * Returns class type.
- *
- * @return class type
- */
- byte getClassType();
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv4ErrorSpec.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv4ErrorSpec.java
deleted file mode 100644
index d165d59..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv4ErrorSpec.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Pcep Rsvp Ipv4 Error Spec.
- */
-public class PcepRsvpIpv4ErrorSpec implements PcepRsvpErrorSpec {
-
- /*
- RSVP error spec object header.
- 0 1 2 3
- +-------------+-------------+-------------+-------------+
- | Length (bytes) | Class-Num | C-Type |
- +-------------+-------------+-------------+-------------+
- | |
- // (Object contents) //
- | |
- +-------------+-------------+-------------+-------------+
-
- Ref : ERROR_SPEC @ RFC2205
-
- IPv4 ERROR_SPEC object: Class = 6, C-Type = 1
- +-------------+-------------+-------------+-------------+
- | IPv4 Error Node Address (4 bytes) |
- +-------------+-------------+-------------+-------------+
- | Flags | Error Code | Error Value |
- +-------------+-------------+-------------+-------------+
-
- */
-
- PcepRsvpSpecObjHeader objHeader;
- public static final byte CLASS_NUM = 0x06;
- public static final byte CLASS_TYPE = 0x01;
- public static final byte CLASS_LENGTH = 0x0c;
- private int ipv4Addr;
- private byte flags;
- private byte errCode;
- private short errValue;
-
- /**
- * Constructor to initialize obj header, ipv4 addr, flags, err code and err value.
- *
- * @param objHeader rsvp ipv4 error spec object header
- * @param ipv4Addr ipv4 address
- * @param flags flags value
- * @param errCode error code value
- * @param errValue error value
- */
- public PcepRsvpIpv4ErrorSpec(PcepRsvpSpecObjHeader objHeader, int ipv4Addr, byte flags, byte errCode,
- short errValue) {
- this.objHeader = objHeader;
- this.ipv4Addr = ipv4Addr;
- this.flags = flags;
- this.errCode = errCode;
- this.errValue = errValue;
- }
-
- /**
- * Constructor to initialize ipv4 address, flags, err code and err value.
- *
- * @param ipv4Addr ipv4 address
- * @param flags flags value
- * @param errCode error code
- * @param errValue error value
- */
- public PcepRsvpIpv4ErrorSpec(int ipv4Addr, byte flags, byte errCode, short errValue) {
- this.objHeader = new PcepRsvpSpecObjHeader(CLASS_LENGTH, CLASS_NUM, CLASS_TYPE);
- this.ipv4Addr = ipv4Addr;
- this.flags = flags;
- this.errCode = errCode;
- this.errValue = errValue;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- int objLenIndex = objHeader.write(cb);
- cb.writeInt(ipv4Addr);
- cb.writeByte(flags);
- cb.writeByte(errCode);
- cb.writeShort(errValue);
- short objLen = (short) (cb.writerIndex() - objLenIndex);
- cb.setShort(objLenIndex, objLen);
- return objLen;
- }
-
- /**
- * Reads PCPE RSVP error spec from channel buffer and returns PCEP rsvp IPv4 error spec object.
- *
- * @param cb channel buffer
- * @return PCEP rsvp IPv4 error spec object
- */
- public static PcepRsvpErrorSpec read(ChannelBuffer cb) {
- PcepRsvpSpecObjHeader objHeader;
- int ipv4Addr;
- byte flags;
- byte errCode;
- short errValue;
-
- objHeader = PcepRsvpSpecObjHeader.read(cb);
- ipv4Addr = cb.readInt();
- flags = cb.readByte();
- errCode = cb.readByte();
- errValue = cb.readShort();
- return new PcepRsvpIpv4ErrorSpec(objHeader, ipv4Addr, flags, errCode, errValue);
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return StatefulRsvpErrorSpecTlv.TYPE;
- }
-
- @Override
- public short getLength() {
- return CLASS_LENGTH;
- }
-
- @Override
- public byte getClassNum() {
- return CLASS_NUM;
- }
-
- @Override
- public byte getClassType() {
- return CLASS_TYPE;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("IPv4Address", ipv4Addr)
- .add("flags", flags)
- .add("errorCode", errCode)
- .add("errorValue", errValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java
deleted file mode 100644
index 1897f9d..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Pcep Rsvp Ipv6 Error Spec.
- */
-public class PcepRsvpIpv6ErrorSpec implements PcepRsvpErrorSpec {
-
- /*
- 0 1 2 3
- +-------------+-------------+-------------+-------------+
- | Length (bytes) | Class-Num | C-Type |
- +-------------+-------------+-------------+-------------+
- | |
- // (Object contents) //
- | |
- +-------------+-------------+-------------+-------------+
-
- Ref : ERROR_SPEC @ RFC2205
-
- IPv6 ERROR_SPEC object: Class = 6, C-Type = 2
- +-------------+-------------+-------------+-------------+
- | |
- + +
- | |
- + IPv6 Error Node Address (16 bytes) +
- | |
- + +
- | |
- +-------------+-------------+-------------+-------------+
- | Flags | Error Code | Error Value |
- +-------------+-------------+-------------+-------------+ */
-
- PcepRsvpSpecObjHeader objHeader;
- public static final byte CLASS_NUM = 0x06;
- public static final byte CLASS_TYPE = 0x02;
- public static final byte CLASS_LENGTH = 0x18;
- public static final byte IPV6_LEN = 0x10;
-
- private byte[] ipv6Addr;
- private byte flags;
- private byte errCode;
- private short errValue;
-
- /**
- * Constructor to initialize obj header, ipv6 addr, flags, err code and err value.
- *
- * @param objHeader rsvp ipv6 error spec object header
- * @param ipv6Addr ipv6 address
- * @param flags flags value
- * @param errCode error code
- * @param errValue error value
- */
- public PcepRsvpIpv6ErrorSpec(PcepRsvpSpecObjHeader objHeader, byte[] ipv6Addr, byte flags, byte errCode,
- short errValue) {
- this.objHeader = objHeader;
- this.ipv6Addr = ipv6Addr;
- this.flags = flags;
- this.errCode = errCode;
- this.errValue = errValue;
- }
-
- /**
- * Constructor to initialize ipv6 addr, flags, err code and err value.
- *
- * @param ipv6Addr ipv6 address
- * @param flags flags value
- * @param errCode error code
- * @param errValue error value
- */
- public PcepRsvpIpv6ErrorSpec(byte[] ipv6Addr, byte flags, byte errCode, short errValue) {
- this.objHeader = new PcepRsvpSpecObjHeader(CLASS_LENGTH, CLASS_NUM, CLASS_TYPE);
- this.ipv6Addr = ipv6Addr;
- this.flags = flags;
- this.errCode = errCode;
- this.errValue = errValue;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- int objLenIndex = objHeader.write(cb);
- cb.writeBytes(ipv6Addr);
- cb.writeByte(flags);
- cb.writeByte(errCode);
- cb.writeShort(errValue);
- short objLen = (short) (cb.writerIndex() - objLenIndex);
- cb.setShort(objLenIndex, objLen);
- return objLen;
- }
-
- /**
- * Returns PCEP rsvp IPv6 error spce object.
- *
- * @param cb channel buffer
- * @return PCEP rsvp IPv6 error spce object
- */
- public static PcepRsvpErrorSpec read(ChannelBuffer cb) {
- PcepRsvpSpecObjHeader objHeader;
- byte[] ipv6Addr = new byte[IPV6_LEN];
- byte flags;
- byte errCode;
- short errValue;
-
- objHeader = PcepRsvpSpecObjHeader.read(cb);
- cb.readBytes(ipv6Addr, 0, IPV6_LEN);
- flags = cb.readByte();
- errCode = cb.readByte();
- errValue = cb.readShort();
- return new PcepRsvpIpv6ErrorSpec(objHeader, ipv6Addr, flags, errCode, errValue);
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return StatefulRsvpErrorSpecTlv.TYPE;
- }
-
- @Override
- public short getLength() {
- return CLASS_LENGTH;
- }
-
- @Override
- public byte getClassNum() {
- return CLASS_NUM;
- }
-
- @Override
- public byte getClassType() {
- return CLASS_TYPE;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("IPv6Address", ipv6Addr)
- .add("flags", flags)
- .add("errorCode", errCode)
- .add("errorValue", errValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpObjectHeader.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpObjectHeader.java
deleted file mode 100644
index 1a47c3c..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpObjectHeader.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PcepRsvpObjectHeader.
- */
-public class PcepRsvpObjectHeader {
-
- /*
- 0 1 2 3
- +-------------+-------------+-------------+-------------+
- | Length (bytes) | Class-Num | C-Type |
- +-------------+-------------+-------------+-------------+
- | |
- // (Object contents) //
- | |
- +-------------+-------------+-------------+-------------+
-
- ERROR_SPEC object Header
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepRsvpObjectHeader.class);
-
- public static final boolean REQ_OBJ_MUST_PROCESS = true;
- public static final boolean REQ_OBJ_OPTIONAL_PROCESS = false;
- public static final boolean RSP_OBJ_IGNORED = true;
- public static final boolean RSP_OBJ_PROCESSED = false;
- public static final int OBJECT_TYPE_SHIFT_VALUE = 4;
- private byte objClassNum;
- private byte objClassType;
- private short objLen;
-
- /**
- * Constructor to initialize class num, length and type.
- *
- * @param objClassNum object class number
- * @param objClassType object class type
- * @param objLen object length
- */
- public PcepRsvpObjectHeader(byte objClassNum, byte objClassType, short objLen) {
- this.objClassNum = objClassNum;
- this.objClassType = objClassType;
- this.objLen = objLen;
- }
-
- /**
- * Sets the Class-Num.
- *
- * @param value object class number
- */
- public void setObjClassNum(byte value) {
- this.objClassNum = value;
- }
-
- /**
- * Sets the Class type.
- *
- * @param value object class type
- */
- public void setObjClassType(byte value) {
- this.objClassType = value;
- }
-
- /**
- * Sets the Class Length.
- *
- * @param value object length
- */
- public void setObjLen(short value) {
- this.objLen = value;
- }
-
- /**
- * Returns Object Length.
- *
- * @return objLen
- */
- public short getObjLen() {
- return this.objLen;
- }
-
- /**
- * Returns Object num.
- *
- * @return objClassNum
- */
- public byte getObjClassNum() {
- return this.objClassNum;
- }
-
- /**
- * Returns Object type.
- *
- * @return objClassType
- */
- public byte getObjClassType() {
- return this.objClassType;
- }
-
- /**
- * Writes the byte stream of PcepRsvpObjectHeader to channel buffer.
- *
- * @param cb of type channel buffer
- * @return object length index in channel buffer
- */
- public int write(ChannelBuffer cb) {
- int iLenStartIndex = cb.writerIndex();
- cb.writeShort((short) 0);
- cb.writeByte(this.objClassNum);
- cb.writeByte(this.objClassType);
- return cb.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the PcepRsvpObjectHeader.
- *
- * @param cb input channel buffer
- * @return PcepRsvpObjectHeader
- */
- public static PcepRsvpObjectHeader read(ChannelBuffer cb) {
- log.debug("read ");
- byte objClassNum;
- byte objClassType;
- short objLen;
- objLen = cb.readShort();
- objClassNum = cb.readByte();
- objClassType = cb.readByte();
-
- return new PcepRsvpObjectHeader(objClassNum, objClassType, objLen);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("ObjectClassNum", objClassNum)
- .add("ObjectCType", objClassType)
- .add("ObjectLength", objLen)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpSpecObjHeader.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpSpecObjHeader.java
deleted file mode 100644
index 50c4699..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpSpecObjHeader.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides PcepRsvpObjectHeader.
- */
-public class PcepRsvpSpecObjHeader {
-
- /*
- 0 1 2 3
- +-------------+-------------+-------------+-------------+
- | Length (bytes) | Class-Num | C-Type |
- +-------------+-------------+-------------+-------------+
- | |
- // (Object contents) //
- | |
- +-------------+-------------+-------------+-------------+
-
- ERROR_SPEC object Header
- */
-
- private static final Logger log = LoggerFactory.getLogger(PcepRsvpSpecObjHeader.class);
-
- private short objLen;
- private byte objClassNum;
- private byte objClassType;
-
- /**
- * Constructor to initialize length, class num and type.
- *
- * @param objLen object length
- * @param objClassNum pcep rsvp error spec object class num
- * @param objClassType pcep rsvp error spec object class type
- */
- public PcepRsvpSpecObjHeader(short objLen, byte objClassNum, byte objClassType) {
- this.objLen = objLen;
- this.objClassNum = objClassNum;
- this.objClassType = objClassType;
- }
-
- /**
- * Sets the Class num.
- *
- * @param value pcep rsvp error spec object class num
- */
- public void setObjClassNum(byte value) {
- this.objClassNum = value;
- }
-
- /**
- * Sets the Class type.
- *
- * @param value pcep rsvp error spec object class type
- */
- public void setObjClassType(byte value) {
- this.objClassType = value;
- }
-
- /**
- * Sets the Class Length.
- *
- * @param value pcep rsvp error spec object length
- */
- public void setObjLen(short value) {
- this.objLen = value;
- }
-
- /**
- * Returns Object Length.
- *
- * @return objLen pcep rsvp error spec object length
- */
- public short getObjLen() {
- return this.objLen;
- }
-
- /**
- * Returns Object num.
- *
- * @return objClassNum pcep rsvp error spec object class num
- */
- public byte getObjClassNum() {
- return this.objClassNum;
- }
-
- /**
- * Returns Object type.
- *
- * @return objClassType pcep rsvp error spec object class type
- */
- public byte getObjClassType() {
- return this.objClassType;
- }
-
- /**
- * Writes the byte stream of PcepRsvpObjectHeader to channel buffer.
- *
- * @param cb of type channel buffer
- * @return object length index
- */
- public int write(ChannelBuffer cb) {
- int objLenIndex = cb.writerIndex();
- objLen = 0;
- cb.writeShort(objLen);
- cb.writeByte(objClassNum);
- cb.writeByte(objClassType);
- return objLenIndex;
- }
-
- /**
- * Reads the PcepRsvpObjectHeader.
- *
- * @param cb of type channel buffer
- * @return PcepRsvpObjectHeader
- */
- public static PcepRsvpSpecObjHeader read(ChannelBuffer cb) {
- byte objClassNum;
- byte objClassType;
- short objLen;
- objLen = cb.readShort();
- objClassNum = cb.readByte();
- objClassType = cb.readByte();
-
- return new PcepRsvpSpecObjHeader(objLen, objClassNum, objClassType);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("ObjectClassNum: ", objClassNum)
- .add("ObjectCType: ", objClassType)
- .add("ObjectLength: ", objLen)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpUserErrorSpec.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpUserErrorSpec.java
deleted file mode 100644
index 91a2d51..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpUserErrorSpec.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepVersion;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Pcep Rsvp User Error Spec.
- */
-public class PcepRsvpUserErrorSpec implements PcepRsvpErrorSpec {
-
- /*
- RSVP error spec object header.
- 0 1 2 3
- +-------------+-------------+-------------+-------------+
- | Length (bytes) | Class-Num | C-Type |
- +-------------+-------------+-------------+-------------+
- | |
- // (Object contents) //
- | |
- +-------------+-------------+-------------+-------------+
-
- Ref : USER_ERROR_SPEC @ RFC5284.
- USER_ERROR_SPEC object: Class = 194, C-Type = 1
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +---------------+---------------+---------------+---------------+
- | Enterprise Number |
- +---------------+---------------+---------------+---------------+
- | Sub Org | Err Desc Len | User Error Value |
- +---------------+---------------+---------------+---------------+
- | |
- ~ Error Description ~
- | |
- +---------------+---------------+---------------+---------------+
- | |
- ~ User-Defined Subobjects ~
- | |
- +---------------+---------------+---------------+---------------+
- */
-
- public static final byte CLASS_NUM = (byte) 0xc2;
- public static final byte CLASS_TYPE = 0x01;
-
- private PcepRsvpSpecObjHeader objHeader;
- private int enterpriseNum;
- private byte subOrg;
- private byte errDescLen;
- private short userErrorValue;
- private byte[] errDesc;
- private LinkedList<PcepValueType> llRsvpUserSpecSubObj;
-
- /**
- * Default constructor.
- *
- * @param objHeader pcep rsvp spec object header
- * @param enterpriseNum enterprise number
- * @param subOrg organization identifier value
- * @param errDescLen error description length
- * @param userErrorValue user error value
- * @param errDesc error description
- * @param llRsvpUserSpecSubObj list of subobjects
- */
- public PcepRsvpUserErrorSpec(PcepRsvpSpecObjHeader objHeader, int enterpriseNum, byte subOrg, byte errDescLen,
- short userErrorValue, byte[] errDesc, LinkedList<PcepValueType> llRsvpUserSpecSubObj) {
- this.objHeader = objHeader;
- this.enterpriseNum = enterpriseNum;
- this.subOrg = subOrg;
- this.errDescLen = errDescLen;
- this.userErrorValue = userErrorValue;
- this.errDesc = errDesc;
- this.llRsvpUserSpecSubObj = llRsvpUserSpecSubObj;
- }
-
- @Override
- public int write(ChannelBuffer cb) {
- int objLenIndex = objHeader.write(cb);
- cb.writeInt(enterpriseNum);
- cb.writeByte(subOrg);
- cb.writeByte(errDescLen);
- cb.writeShort(userErrorValue);
- cb.writeBytes(errDesc);
-
- if (llRsvpUserSpecSubObj != null) {
-
- ListIterator<PcepValueType> listIterator = llRsvpUserSpecSubObj.listIterator();
-
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
- if (tlv == null) {
- continue;
- }
- tlv.write(cb);
- // need to take care of padding
- int pad = tlv.getLength() % 4;
- if (0 != pad) {
- pad = 4 - pad;
- for (int i = 0; i < pad; ++i) {
- cb.writeByte((byte) 0);
- }
- }
- }
- }
- short objLen = (short) (cb.writerIndex() - objLenIndex);
- cb.setShort(objLenIndex, objLen);
- return objLen;
- }
-
- /**
- * Reads the channel buffer and returns object of PcepRsvpErrorSpec.
- *
- * @param cb of type channel buffer
- * @return object of PcepRsvpErrorSpec
- * @throws PcepParseException when expected object is not received
- */
- public static PcepRsvpErrorSpec read(ChannelBuffer cb) throws PcepParseException {
- PcepRsvpSpecObjHeader objHeader;
- int enterpriseNum;
- byte subOrg;
- byte errDescLen;
- short userErrorValue;
- byte[] errDesc;
- LinkedList<PcepValueType> llRsvpUserSpecSubObj = null;
-
- objHeader = PcepRsvpSpecObjHeader.read(cb);
-
- if (objHeader.getObjClassNum() != CLASS_NUM || objHeader.getObjClassType() != CLASS_TYPE) {
- throw new PcepParseException("Expected PcepRsvpUserErrorSpec object.");
- }
- enterpriseNum = cb.readInt();
- subOrg = cb.readByte();
- errDescLen = cb.readByte();
- userErrorValue = cb.readShort();
- errDesc = new byte[errDescLen];
- cb.readBytes(errDesc, 0, errDescLen);
-
- llRsvpUserSpecSubObj = parseErrSpecSubObj(cb);
-
- return new PcepRsvpUserErrorSpec(objHeader, enterpriseNum, subOrg, errDescLen, userErrorValue, errDesc,
- llRsvpUserSpecSubObj);
- }
-
- private static LinkedList<PcepValueType> parseErrSpecSubObj(ChannelBuffer cb) throws PcepParseException {
- LinkedList<PcepValueType> llRsvpUserSpecSubObj = new LinkedList<>();
- while (0 < cb.readableBytes()) {
- PcepValueType tlv = null;
- short hType = cb.readShort();
- int iValue = 0;
- //short hLength = cb.readShort();
- switch (hType) {
- case AutonomousSystemSubTlv.TYPE:
- iValue = cb.readInt();
- tlv = new AutonomousSystemSubTlv(iValue);
- break;
- default:
- throw new PcepParseException("Unsupported Sub TLV type :" + hType);
- }
- llRsvpUserSpecSubObj.add(tlv);
- }
- return llRsvpUserSpecSubObj;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return StatefulRsvpErrorSpecTlv.TYPE;
- }
-
- @Override
- public short getLength() {
- return objHeader.getObjLen();
- }
-
- @Override
- public byte getClassNum() {
- return CLASS_NUM;
- }
-
- @Override
- public byte getClassType() {
- return CLASS_TYPE;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("enterpriseNumber", enterpriseNum)
- .add("subOrganization", subOrg)
- .add("errDescLength", errDescLen)
- .add("userErrorValue", userErrorValue)
- .add("errDesc", errDesc)
- .add("RsvpUserSpecSubObject", llRsvpUserSpecSubObj)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepValueType.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepValueType.java
deleted file mode 100644
index d130b91..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepValueType.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-
-/**
- * Abstraction which Provides the PCEP Values of Type, Length ,Version.
- */
-public interface PcepValueType {
-
- /**
- * Returns the Version Of PCEP Message.
- *
- * @return Version of PcepVersion Type.
- */
- PcepVersion getVersion();
-
- /**
- * Returns the Type of PCEP Message.
- *
- * @return value of type
- */
- short getType();
-
- /**
- * Returns the Length of PCEP Message.
- *
- * @return value of Length
- */
- short getLength();
-
- /**
- * Writes the byte Stream of PCEP Message to channel buffer.
- *
- * @param bb of type channel buffer
- * @return length of bytes written to channel buffer
- */
- int write(ChannelBuffer bb);
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteNodeDescriptorsTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteNodeDescriptorsTlv.java
deleted file mode 100644
index 5c9751d..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteNodeDescriptorsTlv.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Remote TE Node Descriptors TLV.
- */
-public class RemoteNodeDescriptorsTlv implements PcepValueType {
-
- /* Reference : draft-dhodylee-pce-pcep-ls-01, section 9.2.3.
- *
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD9] | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Node Descriptor Sub-TLVs (variable) //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(RemoteNodeDescriptorsTlv.class);
-
- public static final short TYPE = (short) 65283;
- short hLength;
-
- public static final int TLV_HEADER_LENGTH = 4;
- // Node Descriptor Sub-TLVs (variable)
- private List<PcepValueType> llRemoteTENodeDescriptorSubTLVs;
-
- /**
- * Constructor to initialize llRemoteTENodeDescriptorSubTLVs.
- *
- * @param llRemoteTENodeDescriptorSubTLVs List of PcepValueType
- */
- public RemoteNodeDescriptorsTlv(List<PcepValueType> llRemoteTENodeDescriptorSubTLVs) {
- this.llRemoteTENodeDescriptorSubTLVs = llRemoteTENodeDescriptorSubTLVs;
- }
-
- /**
- * Returns object of Remote TE Node Descriptors TLV.
- *
- * @param llRemoteTENodeDescriptorSubTLVs List of PcepValueType
- * @return object of RemoteNodeDescriptorsTlv
- */
- public static RemoteNodeDescriptorsTlv of(final List<PcepValueType> llRemoteTENodeDescriptorSubTLVs) {
- return new RemoteNodeDescriptorsTlv(llRemoteTENodeDescriptorSubTLVs);
- }
-
- /**
- * Returns Remote TE Node Descriptor Sub TLVs.
- *
- * @return llRemoteTENodeDescriptorSubTLVs
- */
- public List<PcepValueType> getllRemoteTENodeDescriptorSubTLVs() {
- return llRemoteTENodeDescriptorSubTLVs;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(llRemoteTENodeDescriptorSubTLVs.hashCode());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- /*
- * Here we have a list of Tlv so to compare each sub tlv between the object
- * we have to take a list iterator so one by one we can get each sub tlv object
- * and can compare them.
- * it may be possible that the size of 2 lists is not equal so we have to first check
- * the size, if both are same then we should check for the subtlv objects otherwise
- * we should return false.
- */
- if (obj instanceof RemoteNodeDescriptorsTlv) {
- int countObjSubTlv = 0;
- int countOtherSubTlv = 0;
- boolean isCommonSubTlv = true;
- RemoteNodeDescriptorsTlv other = (RemoteNodeDescriptorsTlv) obj;
- Iterator<PcepValueType> objListIterator = ((RemoteNodeDescriptorsTlv) obj).llRemoteTENodeDescriptorSubTLVs
- .iterator();
- countObjSubTlv = ((RemoteNodeDescriptorsTlv) obj).llRemoteTENodeDescriptorSubTLVs.size();
- countOtherSubTlv = other.llRemoteTENodeDescriptorSubTLVs.size();
- if (countObjSubTlv != countOtherSubTlv) {
- return false;
- } else {
- while (objListIterator.hasNext() && isCommonSubTlv) {
- PcepValueType subTlv = objListIterator.next();
- isCommonSubTlv = Objects.equals(llRemoteTENodeDescriptorSubTLVs.contains(subTlv),
- other.llRemoteTENodeDescriptorSubTLVs.contains(subTlv));
- }
- return isCommonSubTlv;
- }
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
-
- int tlvStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- int tlvLenIndex = c.writerIndex();
- hLength = 0;
- c.writeShort(hLength);
-
- ListIterator<PcepValueType> listIterator = llRemoteTENodeDescriptorSubTLVs.listIterator();
-
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
-
- if (tlv == null) {
- log.debug("TLV is null from subTlv list");
- continue;
- }
- tlv.write(c);
-
- // need to take care of padding
- int pad = tlv.getLength() % 4;
-
- if (0 != pad) {
- pad = 4 - pad;
- for (int i = 0; i < pad; ++i) {
- c.writeByte((byte) 0);
- }
- }
- }
-
- hLength = (short) (c.writerIndex() - tlvStartIndex);
- c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
-
- return c.writerIndex() - tlvStartIndex;
- }
-
- /**
- * Reads channel buffer and returns object of Remote TE Node Descriptors TLV.
- *
- * @param c input channel buffer
- * @param length length of buffer
- * @return object of RemoteNodeDescriptorsTlv
- * @throws PcepParseException if mandatory fields are missing
- */
- public static PcepValueType read(ChannelBuffer c, short length) throws PcepParseException {
-
- // Node Descriptor Sub-TLVs (variable)
- List<PcepValueType> llRemoteTENodeDescriptorSubTLVs = new LinkedList<>();
-
- ChannelBuffer tempCb = c.readBytes(length);
-
- while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
-
- PcepValueType tlv;
- short hType = tempCb.readShort();
- int iValue = 0;
- short hLength = tempCb.readShort();
- switch (hType) {
-
- case AutonomousSystemSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new AutonomousSystemSubTlv(iValue);
- break;
- case BgpLsIdentifierSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new BgpLsIdentifierSubTlv(iValue);
- break;
- case OspfAreaIdSubTlv.TYPE:
- iValue = tempCb.readInt();
- tlv = new OspfAreaIdSubTlv(iValue);
- break;
- case IgpRouterIdSubTlv.TYPE:
- tlv = IgpRouterIdSubTlv.read(tempCb, hLength);
- break;
-
- default:
- throw new PcepParseException("Unsupported Sub TLV type :" + hType);
- }
-
- // Check for the padding
- int pad = hLength % 4;
- if (0 < pad) {
- pad = 4 - pad;
- if (pad <= tempCb.readableBytes()) {
- tempCb.skipBytes(pad);
- }
- }
-
- llRemoteTENodeDescriptorSubTLVs.add(tlv);
- }
-
- if (0 < tempCb.readableBytes()) {
-
- throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
- }
- return new RemoteNodeDescriptorsTlv(llRemoteTENodeDescriptorSubTLVs);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", hLength)
- .add("RemoteTeNodeDescriptorSubTLVs", llRemoteTENodeDescriptorSubTLVs)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTlv.java
deleted file mode 100644
index c555da1..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTlv.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides RoutingUniverseTLV identifiers.
- */
-public class RoutingUniverseTlv implements PcepValueType {
-
- /*
- * Reference : draft-dhodylee-pce-pcep-te-data-extn-02, section 9.2.1.
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TBD7] | Length=8 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Identifier |
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- *
- *
- * +------------+---------------------+
- | Identifier | Routing Universe |
- +------------+---------------------+
- | 0 | L3 packet topology |
- | 1 | L1 optical topology |
- +------------+---------------------+
- */
-
- private static final Logger log = LoggerFactory.getLogger(RoutingUniverseTlv.class);
-
- public static final short TYPE = (short) 65281;
- public static final short LENGTH = 8;
-
- private final long rawValue;
-
- /**
- * Constructor to initialize raw value.
- *
- * @param rawValue raw value
- */
- public RoutingUniverseTlv(long rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Returns object of RoutingUniverseTLV.
- *
- * @param raw value
- * @return object of RoutingUniverseTLV
- */
- public static RoutingUniverseTlv of(final long raw) {
- return new RoutingUniverseTlv(raw);
- }
-
- /**
- * Returns raw value as Identifier.
- *
- * @return rawValue Identifier
- */
- public long getLong() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof RoutingUniverseTlv) {
- RoutingUniverseTlv other = (RoutingUniverseTlv) obj;
- return Objects.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeLong(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads from channel buffer and returns object of RoutingUniverseTLV.
- *
- * @param c input channel buffer
- * @return object of RoutingUniverseTLV
- */
- public static RoutingUniverseTlv read(ChannelBuffer c) {
- return RoutingUniverseTlv.of(c.readLong());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SharedRiskLinkGroupSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SharedRiskLinkGroupSubTlv.java
deleted file mode 100644
index 6ff5639..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SharedRiskLinkGroupSubTlv.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-
-/**
- * Provides SharedRiskLinkGroupTlv.
- */
-public class SharedRiskLinkGroupSubTlv implements PcepValueType {
-
- /*
- * Reference :[I-D.ietf-idr- Group ls-distribution] /3.3.2.5
- *
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type =TDB41 | Length |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Shared Risk Link Group Value |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // ............ //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Shared Risk Link Group Value |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(SharedRiskLinkGroupSubTlv.class);
-
- public static final short TYPE = 30;
-
- private final short hLength;
-
- private final int[] srlgValue;
-
- /**
- * Constructor to initialize SRLG value.
- *
- * @param srlgValue Shared Risk Link Group Value
- * @param hLength length
- */
- public SharedRiskLinkGroupSubTlv(int[] srlgValue, short hLength) {
- this.srlgValue = srlgValue;
- if (0 == hLength) {
- this.hLength = (short) ((srlgValue.length) * 4);
- } else {
- this.hLength = hLength;
- }
- }
-
- /**
- * Returns object of SharedRiskLinkGroupTlv.
- *
- * @param raw value
- * @param hLength length
- * @return object of SharedRiskLinkGroupTlv
- */
- public static SharedRiskLinkGroupSubTlv of(final int[] raw, short hLength) {
- return new SharedRiskLinkGroupSubTlv(raw, hLength);
- }
-
- /**
- * Returns SRLG Value.
- *
- * @return srlgValue
- */
- public int[] getValue() {
- return srlgValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(srlgValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof SharedRiskLinkGroupSubTlv) {
- SharedRiskLinkGroupSubTlv other = (SharedRiskLinkGroupSubTlv) obj;
- return Arrays.equals(this.srlgValue, other.srlgValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(hLength);
- for (int b : srlgValue) {
- c.writeInt(b);
- }
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads from channel buffer and returns object of SharedRiskLinkGroupTlv.
- *
- * @param c input channel buffer
- * @param hLength length
- * @return object of SharedRiskLinkGroupTlv
- */
- public static PcepValueType read(ChannelBuffer c, short hLength) {
- int iLength = hLength / 4;
- int[] iSharedRiskLinkGroup = new int[iLength];
- for (int i = 0; i < iLength; i++) {
- iSharedRiskLinkGroup[i] = c.readInt();
- }
- return new SharedRiskLinkGroupSubTlv(iSharedRiskLinkGroup, hLength);
- }
-
-
- @Override
- public String toString() {
- ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
-
- toStrHelper.add("Type", TYPE);
- toStrHelper.add("Length", hLength);
-
- StringBuffer result = new StringBuffer();
- for (int b : srlgValue) {
- result.append(String.format("%02X ", b));
- }
- toStrHelper.add("Value", result);
-
- return toStrHelper.toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java
deleted file mode 100644
index 77c803d..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import com.google.common.base.MoreObjects;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepNai;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Objects;
-
-/**
- * Provides SrEroSubObject.
- */
-public class SrEroSubObject implements PcepValueType {
- /*
- SR-ERO subobject: (draft-ietf-pce-segment-routing-06)
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |L| Type | Length | ST | Flags |F|S|C|M|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | SID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // NAI (variable) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- When M bit is reset, SID is 32 bit Index.
- When M bit is set, SID is 20 bit Label.
-
-
- NAI
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Local IPv4 address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Remote IPv4 address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- NAI for IPv4 Adjacency
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // Local IPv6 address (16 bytes) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- // Remote IPv6 address (16 bytes) //
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- NAI for IPv6 adjacency
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Local Node-ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Local Interface ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Remote Node-ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Remote Interface ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- NAI for Unnumbered adjacency with IPv4 Node IDs
-
- */
- private static final Logger log = LoggerFactory.getLogger(SrEroSubObject.class);
-
- public static final short TYPE = 0x24; //TODO : type to be defined
- public static final short LENGTH = 12;
- public static final short VALUE_LENGTH = 10;
- public static final int SET = 1;
- public static final byte MFLAG_SET = 0x01;
- public static final byte CFLAG_SET = 0x02;
- public static final byte SFLAG_SET = 0x04;
- public static final byte FFLAG_SET = 0x08;
- public static final byte SHIFT_ST = 12;
-
- private final boolean bFFlag;
- private final boolean bSFlag;
- private final boolean bCFlag;
- private final boolean bMFlag;
- private final byte st;
-
- //If m bit is set SID will store label else store 32 bit value
- private final int sid;
- private final PcepNai nai;
-
- /**
- * Constructor to initialize member variables.
- *
- * @param st SID type
- * @param bFFlag F flag
- * @param bSFlag S flag
- * @param bCFlag C flag
- * @param bMFlag M flag
- * @param sid segment identifier value
- * @param nai NAI associated with SID
- */
- public SrEroSubObject(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sid,
- PcepNai nai) {
- this.st = st;
- this.bFFlag = bFFlag;
- this.bSFlag = bSFlag;
- this.bCFlag = bCFlag;
- this.bMFlag = bMFlag;
- this.sid = sid;
- this.nai = nai;
- }
-
- /**
- * Creates object of SrEroSubObject.
- *
- * @param st SID type
- * @param bFFlag F flag
- * @param bSFlag S flag
- * @param bCFlag C flag
- * @param bMFlag M flag
- * @param sid segment identifier value
- * @param nai NAI associated with SID
- * @return object of SrEroSubObject
- */
- public static SrEroSubObject of(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sid,
- PcepNai nai) {
- return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sid, nai);
- }
-
- /**
- * Returns SID type.
- *
- * @return st SID type
- */
- public byte getSt() {
- return st;
- }
-
- /**
- * Returns bFFlag.
- *
- * @return bFFlag
- */
- public boolean getFFlag() {
- return bFFlag;
- }
-
- /**
- * Returns bSFlag.
- *
- * @return bSFlag
- */
- public boolean getSFlag() {
- return bSFlag;
- }
-
- /**
- * Returns bCFlag.
- *
- * @return bCFlag
- */
- public boolean getCFlag() {
- return bCFlag;
- }
-
- /**
- * Returns bMFlag.
- *
- * @return bMFlag
- */
- public boolean getMFlag() {
- return bMFlag;
- }
-
- /**
- * Returns sID.
- *
- * @return sid
- */
- public int getSid() {
- return sid;
- }
-
- /**
- * Returns nai.
- * @return nai
- */
- public PcepNai getNai() {
- return nai;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(st, bFFlag, bSFlag, bCFlag, bMFlag, sid, nai);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof SrEroSubObject) {
- SrEroSubObject other = (SrEroSubObject) obj;
- return Objects.equals(this.st, other.st) && Objects.equals(this.bFFlag, other.bFFlag)
- && Objects.equals(this.bSFlag, other.bSFlag) && Objects.equals(this.bCFlag, other.bCFlag)
- && Objects.equals(this.bMFlag, other.bMFlag) && Objects.equals(this.sid, other.sid)
- && Objects.equals(this.nai, other.nai);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeByte(TYPE);
- // Store the position of object length
- int objectLenIndex = c.writerIndex();
- c.writeByte(0);
-
- short temp = 0;
- if (bMFlag) {
- temp = (short) (temp | MFLAG_SET);
- }
- if (bCFlag) {
- temp = (short) (temp | CFLAG_SET);
- }
- if (bSFlag) {
- temp = (short) (temp | SFLAG_SET);
- }
- if (bFFlag) {
- temp = (short) (temp | FFLAG_SET);
- }
- short tempST = (short) (st << SHIFT_ST);
- temp = (short) (temp | tempST);
- c.writeShort(temp);
- if (bMFlag) {
- int tempSid = sid << 12;
- c.writeInt(tempSid);
- } else {
- c.writeInt(sid);
- }
- nai.write(c);
-
- c.setByte(objectLenIndex, (c.writerIndex() - iLenStartIndex));
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of SrEroSubObject.
- * @param c of type channel buffer
- * @return object of SrEroSubObject
- */
- public static PcepValueType read(ChannelBuffer c) {
- short temp = c.readShort();
- boolean bMFlag;
- boolean bCFlag;
- boolean bSFlag;
- boolean bFFlag;
- byte st;
- PcepNai nai = null;
-
- bMFlag = (temp & MFLAG_SET) == MFLAG_SET;
- bCFlag = (temp & CFLAG_SET) == CFLAG_SET;
- bSFlag = (temp & SFLAG_SET) == SFLAG_SET;
- bFFlag = (temp & FFLAG_SET) == FFLAG_SET;
-
- st = (byte) (temp >> SHIFT_ST);
-
- int sid = c.readInt();
- if (bMFlag) {
- sid = sid >> 12;
- }
- switch (st) {
- case PcepNaiIpv4NodeId.ST_TYPE:
- nai = PcepNaiIpv4NodeId.read(c);
- break;
- case PcepNaiIpv6NodeId.ST_TYPE:
- nai = PcepNaiIpv6NodeId.read(c);
- break;
- case PcepNaiIpv4Adjacency.ST_TYPE:
- nai = PcepNaiIpv4Adjacency.read(c);
- break;
- case PcepNaiIpv6Adjacency.ST_TYPE:
- nai = PcepNaiIpv6Adjacency.read(c);
- break;
- case PcepNaiUnnumberedAdjacencyIpv4.ST_TYPE:
- nai = PcepNaiUnnumberedAdjacencyIpv4.read(c);
- break;
- default:
- nai = null;
- break;
- }
-
- return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sid, nai);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("st", st)
- .add("bFflag", bFFlag)
- .add("bSFlag", bSFlag)
- .add("bCFlag", bCFlag)
- .add("bMFlag", bMFlag)
- .add("sid", sid)
- .add("nAI", nai)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrPceCapabilityTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrPceCapabilityTlv.java
deleted file mode 100644
index 7208785..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrPceCapabilityTlv.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides SR PCE Capability Tlv.
- */
-public class SrPceCapabilityTlv implements PcepValueType {
-
- /*
- *
- reference : draft-ietf-pce-segment-routing-06, section 5.1.1
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=TBD | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Reserved | Flags | MSD |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- fig: SR-PCE-CAPABILITY TLV format
- */
- private static final Logger log = LoggerFactory.getLogger(SrPceCapabilityTlv.class);
-
- public static final short TYPE = 26;
- public static final short LENGTH = 4;
-
- private final byte msd;
-
- /**
- * Constructor to initialize its parameter.
- *
- * @param msd maximum SID depth
- */
- public SrPceCapabilityTlv(byte msd) {
- this.msd = msd;
- }
-
- /**
- * Obtains newly created SrPceCapabilityTlv object.
- *
- * @param msd maximum SID depth
- * @return object of SrPceCapabilityTlv
- */
- public static SrPceCapabilityTlv of(final byte msd) {
- return new SrPceCapabilityTlv(msd);
- }
-
- /**
- * Obtains msd.
- *
- * @return msd
- */
- public byte msd() {
- return msd;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(msd);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof SrPceCapabilityTlv) {
- SrPceCapabilityTlv other = (SrPceCapabilityTlv) obj;
- return Objects.equals(msd, other.msd);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(msd);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of SrPceCapabilityTlv.
- *
- * @param cb channel buffer
- * @return object of Gmpls-Capability-Tlv
- */
- public static SrPceCapabilityTlv read(ChannelBuffer cb) {
- //read reserved bits
- cb.readShort();
- //read flags
- cb.readByte();
- return SrPceCapabilityTlv.of(cb.readByte());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("msd", msd)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentifiersTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentifiersTlv.java
deleted file mode 100644
index a05b4e5..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentifiersTlv.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides StatefulIPv4LspIdentidiersTlv.
- */
-public class StatefulIPv4LspIdentifiersTlv implements PcepValueType {
-
- /* IPV4-LSP-IDENTIFIERS TLV format
- *
- * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
- *
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=18 | Length=16 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv4 Tunnel Sender Address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LSP ID | Tunnel ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Extended Tunnel ID |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | IPv4 Tunnel Endpoint Address |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- */
- private static final Logger log = LoggerFactory.getLogger(StatefulIPv4LspIdentifiersTlv.class);
-
- public static final short TYPE = 18;
- public static final short LENGTH = 16;
- public static final int VALUE_LENGTH = 16;
- private final int ipv4IngressAddress;
- private final short lspId;
- private final short tunnelId;
- private final int extendedTunnelId;
- private final int ipv4EgressAddress;
-
- /**
- * Constructor to initialize member variables.
- *
- * @param ipv4IngressAddress ingress ipv4 address
- * @param lspId lsp id
- * @param tunnelId tunnel id
- * @param extendedTunnelId extended tunnel id
- * @param ipv4EgressAddress egress ipv4 address
- */
- public StatefulIPv4LspIdentifiersTlv(int ipv4IngressAddress, short lspId, short tunnelId, int extendedTunnelId,
- int ipv4EgressAddress) {
-
- this.ipv4IngressAddress = ipv4IngressAddress;
- this.lspId = lspId;
- this.tunnelId = tunnelId;
- this.extendedTunnelId = extendedTunnelId;
- this.ipv4EgressAddress = ipv4EgressAddress;
- }
-
- /**
- * Creates object of StatefulIPv4LspIdentidiersTlv.
- *
- * @param ipv4IngressAddress ingress ipv4 address
- * @param lspId lsp id
- * @param tunnelId tunnel id
- * @param extendedTunnelId extended tunnel id
- * @param ipv4EgressAddress egress ipv4 address
- * @return object of StatefulIPv4LspIdentidiersTlv
- */
- public static StatefulIPv4LspIdentifiersTlv of(int ipv4IngressAddress, short lspId, short tunnelId,
- int extendedTunnelId, int ipv4EgressAddress) {
- return new StatefulIPv4LspIdentifiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
- ipv4EgressAddress);
- }
-
- /**
- * Returns tunnel id.
- *
- * @return tunnelId
- */
- public short getTunnelId() {
- return this.tunnelId;
- }
-
- /**
- * Returns LSP id.
- *
- * @return lspId
- */
- public short getLspId() {
- return this.lspId;
- }
-
- /**
- * Returns extendedTunnelId.
- *
- * @return extendedTunnelId
- */
- public int getextendedTunnelId() {
- return this.extendedTunnelId;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- /**
- * Returns ipv4IngressAddress.
- *
- * @return ipv4IngressAddress
- */
- public int getIpv4IngressAddress() {
- return ipv4IngressAddress;
- }
-
- /**
- * Returns ipv4EgressAddress.
- *
- * @return ipv4EgressAddress
- */
- public int getIpv4EgressAddress() {
- return ipv4EgressAddress;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId, ipv4EgressAddress);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof StatefulIPv4LspIdentifiersTlv) {
- StatefulIPv4LspIdentifiersTlv other = (StatefulIPv4LspIdentifiersTlv) obj;
- return Objects.equals(this.ipv4IngressAddress, other.ipv4IngressAddress)
- && Objects.equals(this.lspId, other.lspId) && Objects.equals(this.tunnelId, other.tunnelId)
- && Objects.equals(this.extendedTunnelId, other.extendedTunnelId)
- && Objects.equals(this.ipv4EgressAddress, other.ipv4EgressAddress);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(ipv4IngressAddress);
- c.writeShort(lspId);
- c.writeShort(tunnelId);
- c.writeInt(extendedTunnelId);
- c.writeInt(ipv4EgressAddress);
-
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of StatefulIPv4LspIdentidiersTlv.
- *
- * @param c of type channel buffer
- * @return object of StatefulIPv4LspIdentidiersTlv
- */
- public static PcepValueType read(ChannelBuffer c) {
- int ipv4IngressAddress = c.readInt();
- short lspId = c.readShort();
- short tunnelId = c.readShort();
- int extendedTunnelId = c.readInt();
- int ipv4EgressAddress = c.readInt();
- return new StatefulIPv4LspIdentifiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
- ipv4EgressAddress);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type:", TYPE)
- .add("Length:", LENGTH)
- .add("Ipv4IngressAddress:", ipv4IngressAddress)
- .add("LspId:", lspId).add("TunnelId:", tunnelId)
- .add("ExtendedTunnelId:", extendedTunnelId)
- .add("Ipv4EgressAddress:", ipv4EgressAddress).toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java
deleted file mode 100644
index b5dfeea..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides StatefulLspDbVerTlv.
- */
-public class StatefulLspDbVerTlv implements PcepValueType {
-
- /* LSP-DB-VERSION TLV format
- *
- * Reference : Optimizations of Label Switched Path State Synchronization Procedures
- for a Stateful PCE draft-ietf-pce-stateful-sync-optimizations-02
- *
- *
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=23 | Length=8 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LSP State DB Version |
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- */
- private static final Logger log = LoggerFactory.getLogger(StatefulLspDbVerTlv.class);
-
- public static final short TYPE = 23;
- public static final short LENGTH = 8;
- private final long rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue value
- */
- public StatefulLspDbVerTlv(final long rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Returns object of StatefulLspDbVerTlv.
- *
- * @param raw is LSP State DB Version
- * @return object of StatefulLspDbVerTlv
- */
- public static StatefulLspDbVerTlv of(final long raw) {
- return new StatefulLspDbVerTlv(raw);
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- /**
- * Returns LSP State DB Version.
- *
- * @return rawValue value
- */
- public long getLong() {
- return rawValue;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof StatefulLspDbVerTlv) {
- StatefulLspDbVerTlv other = (StatefulLspDbVerTlv) obj;
- return Objects.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeLong(rawValue);
- return c.writerIndex();
- }
-
- /**
- * Reads the channel buffer and returns object of StatefulLspDbVerTlv.
- *
- * @param c input channel buffer
- * @return object of StatefulLspDbVerTlv
- */
- public static StatefulLspDbVerTlv read(ChannelBuffer c) {
- return StatefulLspDbVerTlv.of(c.readLong());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlv.java
deleted file mode 100644
index 3899d73..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlv.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides StatefulLspErrorCodeTlv.
- */
-public class StatefulLspErrorCodeTlv implements PcepValueType {
-
- /* LSP-ERROR-CODE TLV format
- *
- * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
- *
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=20 | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | LSP Error Code |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- */
-
- private static final Logger log = LoggerFactory.getLogger(StatefulLspErrorCodeTlv.class);
-
- public static final short TYPE = 20;
- public static final short LENGTH = 4;
- private final int rawValue;
-
- /**
- * Constructor to initialize raw Value.
- *
- * @param rawValue lsp error code value
- */
- public StatefulLspErrorCodeTlv(int rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Creates object of StatefulLspErrorCodeTlv.
- *
- * @param raw lsp error code value
- * @return object of StatefulLspErrorCodeTlv
- */
- public static StatefulLspErrorCodeTlv of(int raw) {
- return new StatefulLspErrorCodeTlv(raw);
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- /**
- * Returns lsp error code value.
- *
- * @return lsp error code value
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof StatefulLspErrorCodeTlv) {
- StatefulLspErrorCodeTlv other = (StatefulLspErrorCodeTlv) obj;
- return Objects.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads the channel buffer and returns object of StatefulLspErrorCodeTlv.
- *
- * @param c of type channel buffer
- * @return object of StatefulLspErrorCodeTlv
- */
- public static StatefulLspErrorCodeTlv read(ChannelBuffer c) {
- return StatefulLspErrorCodeTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java
deleted file mode 100644
index d184142..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides StatefulPceCapabilityTlv.
- */
-public class StatefulPceCapabilityTlv implements PcepValueType {
-
- /* STATEFUL-PCE-CAPABILITY TLV format
- *
- * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=16 | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Flags |D|T|I|S|U|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- */
- private static final Logger log = LoggerFactory.getLogger(StatefulPceCapabilityTlv.class);
-
- public static final short TYPE = 16;
- public static final short LENGTH = 4;
- public static final byte UFLAG_SET = 0x01;
- public static final byte SFLAG_SET = 0x02;
- public static final byte IFLAG_SET = 0x04;
- public static final byte TFLAG_SET = 0x08;
- public static final byte DFLAG_SET = 0x10;
- public static final int SET = 1;
-
- private final int rawValue;
- private final boolean bDFlag;
- private final boolean bTFlag;
- private final boolean bIFlag;
- private final boolean bSFlag;
- private final boolean bUFlag;
- private final boolean isRawValueSet;
-
- /**
- * Constructor to initialize variables.
- *
- * @param rawValue Flags
- */
- public StatefulPceCapabilityTlv(int rawValue) {
- this.rawValue = rawValue;
- isRawValueSet = true;
- this.bUFlag = (rawValue & UFLAG_SET) == UFLAG_SET;
- this.bSFlag = (rawValue & SFLAG_SET) == SFLAG_SET;
- this.bIFlag = (rawValue & IFLAG_SET) == IFLAG_SET;
- this.bTFlag = (rawValue & TFLAG_SET) == TFLAG_SET;
- this.bDFlag = (rawValue & DFLAG_SET) == DFLAG_SET;
- }
-
- /**
- * Constructor to initialize variables.
- *
- * @param bDFlag D-flag
- * @param bTFlag T-flag
- * @param bIFlag I-flag
- * @param bSFlag S-flag
- * @param bUFlag U-flag
- */
- public StatefulPceCapabilityTlv(boolean bDFlag, boolean bTFlag, boolean bIFlag, boolean bSFlag, boolean bUFlag) {
- this.bDFlag = bDFlag;
- this.bTFlag = bTFlag;
- this.bIFlag = bIFlag;
- this.bSFlag = bSFlag;
- this.bUFlag = bUFlag;
- this.rawValue = 0;
- isRawValueSet = false;
- }
-
- /**
- * Returns object of StatefulPceCapabilityTlv.
- *
- * @param raw value Flags
- * @return object of StatefulPceCapabilityTlv
- */
- public static StatefulPceCapabilityTlv of(final int raw) {
- return new StatefulPceCapabilityTlv(raw);
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- /**
- * Returns D-flag.
- *
- * @return bDFlag D-flag
- */
- public boolean getDFlag() {
- return bDFlag;
- }
-
- /**
- * Returns T-flag.
- *
- * @return bTFlag T-flag
- */
- public boolean getTFlag() {
- return bTFlag;
- }
-
- /**
- * Returns I-flag.
- *
- * @return bIFlag I-flag
- */
- public boolean getIFlag() {
- return bIFlag;
- }
-
- /**
- * Returns S-flag.
- *
- * @return bSFlag S-flag
- */
- public boolean getSFlag() {
- return bSFlag;
- }
-
- /**
- * Returns U-flag.
- *
- * @return bUFlag U-flag
- */
- public boolean getUFlag() {
- return bUFlag;
- }
-
- /**
- * Returns raw value Flags.
- *
- * @return rawValue Flags
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- if (isRawValueSet) {
- return Objects.hash(rawValue);
- } else {
- return Objects.hash(bDFlag, bTFlag, bIFlag, bSFlag, bUFlag);
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof StatefulPceCapabilityTlv) {
- StatefulPceCapabilityTlv other = (StatefulPceCapabilityTlv) obj;
- if (isRawValueSet) {
- return Objects.equals(this.rawValue, other.rawValue);
- } else {
- return Objects.equals(this.bDFlag, other.bDFlag) && Objects.equals(this.bTFlag, other.bTFlag)
- && Objects.equals(this.bIFlag, other.bIFlag) && Objects.equals(this.bSFlag, other.bSFlag)
- && Objects.equals(this.bUFlag, other.bUFlag);
- }
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- if (isRawValueSet) {
- c.writeInt(rawValue);
- } else {
- int temp = 0;
- if (bUFlag) {
- temp = temp | UFLAG_SET;
- }
- if (bSFlag) {
- temp = temp | SFLAG_SET;
- }
- if (bIFlag) {
- temp = temp | IFLAG_SET;
- }
- if (bTFlag) {
- temp = temp | TFLAG_SET;
- }
- if (bDFlag) {
- temp = temp | DFLAG_SET;
- }
- c.writeInt(temp);
- }
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads from channel buffer and returns object of StatefulPceCapabilityTlv.
- *
- * @param c input channel buffer
- * @return object of StatefulPceCapabilityTlv
- */
- public static PcepValueType read(ChannelBuffer c) {
- int temp = c.readInt();
- boolean bDFlag;
- boolean bTFlag;
- boolean bIFlag;
- boolean bSFlag;
- boolean bUFlag;
-
- bUFlag = (temp & UFLAG_SET) == UFLAG_SET;
- bSFlag = (temp & SFLAG_SET) == SFLAG_SET;
- bIFlag = (temp & IFLAG_SET) == IFLAG_SET;
- bTFlag = (temp & TFLAG_SET) == TFLAG_SET;
- bDFlag = (temp & DFLAG_SET) == DFLAG_SET;
-
- return new StatefulPceCapabilityTlv(bDFlag, bTFlag, bIFlag, bSFlag, bUFlag);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("type", TYPE)
- .add("Length", LENGTH)
- .add("DFlag", bDFlag)
- .add("TFlag", bTFlag)
- .add("IFlag", bIFlag)
- .add("SFlag", bSFlag)
- .add("UFlag", bUFlag)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulRsvpErrorSpecTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulRsvpErrorSpecTlv.java
deleted file mode 100644
index ce2ed6c..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulRsvpErrorSpecTlv.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides StatefulRsvpErrorSpecTlv.
- */
-public class StatefulRsvpErrorSpecTlv implements PcepValueType {
-
- private static final Logger log = LoggerFactory.getLogger(StatefulRsvpErrorSpecTlv.class);
-
- /* RSVP-ERROR-SPEC TLV format
- * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
- *
- *
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=21 | Length (variable) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- + RSVP ERROR_SPEC or USER_ERROR_SPEC Object +
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- 0 1 2 3
- +-------------+-------------+-------------+-------------+
- | Length (bytes) | Class-Num | C-Type |
- +-------------+-------------+-------------+-------------+
- | |
- // (Object contents) //
- | |
- +-------------+-------------+-------------+-------------+
-
- Ref : ERROR_SPEC @ RFC2205
-
- IPv4 ERROR_SPEC object: Class = 6, C-Type = 1
- +-------------+-------------+-------------+-------------+
- | IPv4 Error Node Address (4 bytes) |
- +-------------+-------------+-------------+-------------+
- | Flags | Error Code | Error Value |
- +-------------+-------------+-------------+-------------+
-
-
- IPv6 ERROR_SPEC object: Class = 6, C-Type = 2
- +-------------+-------------+-------------+-------------+
- | |
- + +
- | |
- + IPv6 Error Node Address (16 bytes) +
- | |
- + +
- | |
- +-------------+-------------+-------------+-------------+
- | Flags | Error Code | Error Value |
- +-------------+-------------+-------------+-------------+
-
-
- Ref : USER_ERROR_SPEC @ RFC5284
- USER_ERROR_SPEC object: Class = 194, C-Type = 1
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +---------------+---------------+---------------+---------------+
- | Enterprise Number |
- +---------------+---------------+---------------+---------------+
- | Sub Org | Err Desc Len | User Error Value |
- +---------------+---------------+---------------+---------------+
- | |
- ~ Error Description ~
- | |
- +---------------+---------------+---------------+---------------+
- | |
- ~ User-Defined Subobjects ~
- | |
- +---------------+---------------+---------------+---------------+
-
- */
-
- public static final short TYPE = 21;
- public static final int OBJECT_HEADER_LENGTH = 4;
- private short hLength;
-
- private final PcepRsvpErrorSpec rsvpErrSpecObj;
- private final boolean isErrSpceObjSet;
-
- /**
- * Constructor to initialize errSpecObj.
- *
- * @param rsvpErrSpecObj Rsvp error spec object
- */
- public StatefulRsvpErrorSpecTlv(PcepRsvpErrorSpec rsvpErrSpecObj) {
- this.rsvpErrSpecObj = rsvpErrSpecObj;
- this.isErrSpceObjSet = true;
- }
-
- /**
- * Returns PcepRsvpErrorSpecObject.
- *
- * @return rsvpErrSpecObj
- */
- public PcepRsvpErrorSpec getPcepRsvpErrorSpec() {
- return this.rsvpErrSpecObj;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- /**
- * Reads channel buffer and returns object of StatefulRsvpErrorSpecTlv.
- *
- * @param cb of type channel buffer
- * @return object of StatefulRsvpErrorSpecTlv
- * @throws PcepParseException while parsing this tlv from channel buffer
- */
- public static PcepValueType read(ChannelBuffer cb) throws PcepParseException {
-
- PcepRsvpErrorSpec rsvpErrSpecObj = null;
- PcepRsvpSpecObjHeader rsvpErrSpecObjHeader;
-
- cb.markReaderIndex();
- rsvpErrSpecObjHeader = PcepRsvpSpecObjHeader.read(cb);
- cb.resetReaderIndex();
-
- if (PcepRsvpIpv4ErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
- && PcepRsvpIpv4ErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
- rsvpErrSpecObj = PcepRsvpIpv4ErrorSpec.read(cb);
- } else if (PcepRsvpIpv6ErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
- && PcepRsvpIpv6ErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
- rsvpErrSpecObj = PcepRsvpIpv6ErrorSpec.read(cb);
- } else if (PcepRsvpUserErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
- && PcepRsvpUserErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
- rsvpErrSpecObj = PcepRsvpUserErrorSpec.read(cb);
- }
- return new StatefulRsvpErrorSpecTlv(rsvpErrSpecObj);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rsvpErrSpecObj.hashCode());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof StatefulRsvpErrorSpecTlv) {
- StatefulRsvpErrorSpecTlv other = (StatefulRsvpErrorSpecTlv) obj;
- return Objects.equals(this.rsvpErrSpecObj, other.rsvpErrSpecObj);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- int tlvLenIndex = c.writerIndex();
- hLength = 0;
- c.writeShort(hLength);
- if (isErrSpceObjSet) {
- rsvpErrSpecObj.write(c);
- }
- hLength = (short) (c.writerIndex() - iStartIndex);
- c.setShort(tlvLenIndex, (hLength - OBJECT_HEADER_LENGTH));
-
- return c.writerIndex() - iStartIndex;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("Type", TYPE)
- .add("Length", hLength)
- .add("RSVPErrorSpecObject", rsvpErrSpecObj)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SymbolicPathNameTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SymbolicPathNameTlv.java
deleted file mode 100644
index faad33a..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SymbolicPathNameTlv.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import java.util.Arrays;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides SymbolicPathNameTlv.
- */
-public class SymbolicPathNameTlv implements PcepValueType {
-
- /*
- * SYMBOLIC-PATH-NAME TLV format
- * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
- *
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=17 | Length (variable) |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Symbolic Path Name //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
- private static final Logger log = LoggerFactory.getLogger(SymbolicPathNameTlv.class);
-
- public static final short TYPE = 17;
- private short hLength;
-
- private final byte[] rawValue;
-
- /**
- * Constructor to initialize raw Value.
- *
- * @param rawValue Symbolic path name
- */
- public SymbolicPathNameTlv(byte[] rawValue) {
- this.rawValue = rawValue;
- this.hLength = (short) rawValue.length;
- }
-
- /**
- * Constructor to initialize raw Value.
- *
- * @param rawValue Symbolic path name
- * @param hLength length of Symbolic path name
- */
- public SymbolicPathNameTlv(byte[] rawValue, short hLength) {
- this.rawValue = rawValue;
- if (0 == hLength) {
- this.hLength = (short) rawValue.length;
- } else {
- this.hLength = hLength;
- }
- }
-
- /**
- * Creates an object of SymbolicPathNameTlv.
- *
- * @param raw Symbolic path name
- * @param hLength length of Symbolic path name
- * @return object of SymbolicPathNameTlv
- */
- public static SymbolicPathNameTlv of(final byte[] raw, short hLength) {
- return new SymbolicPathNameTlv(raw, hLength);
- }
-
- /**
- * Returns Symbolic path name.
- *
- * @return Symbolic path name byte array
- */
- public byte[] getValue() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return hLength;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof SymbolicPathNameTlv) {
- SymbolicPathNameTlv other = (SymbolicPathNameTlv) obj;
- return Arrays.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(hLength);
- c.writeBytes(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads channel buffer and returns object of SymbolicPathNameTlv.
- *
- * @param c of type channel buffer
- * @param hLength length of bytes to read
- * @return object of SymbolicPathNameTlv
- */
- public static SymbolicPathNameTlv read(ChannelBuffer c, short hLength) {
- byte[] symbolicPathName = new byte[hLength];
- c.readBytes(symbolicPathName, 0, hLength);
- return new SymbolicPathNameTlv(symbolicPathName, hLength);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("SymbolicPathName ", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricSubTlv.java
deleted file mode 100644
index ab6f814..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricSubTlv.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides TEDefaultMetricTlv.
- */
-public class TEDefaultMetricSubTlv implements PcepValueType {
-
- /*
- * Reference :| [I-D.ietf-idr- ls-distribution] /3.3.2.3
- * 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=TDB37 | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | TE Default Link Metric |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- */
- private static final Logger log = LoggerFactory.getLogger(TEDefaultMetricSubTlv.class);
-
- public static final short TYPE = 26;
- public static final short LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue TE Default Link Metric
- */
- public TEDefaultMetricSubTlv(int rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created TEDefaultMetricTlv object.
- *
- * @param raw raw value
- * @return object of TEDefaultMetricTlv.
- */
- public static TEDefaultMetricSubTlv of(final int raw) {
- return new TEDefaultMetricSubTlv(raw);
- }
-
- /**
- * Returns raw value.
- *
- * @return rawValue TE Default Link Metric
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof TEDefaultMetricSubTlv) {
- TEDefaultMetricSubTlv other = (TEDefaultMetricSubTlv) obj;
- return Objects.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads channel buffer and returns object of TEDefaultMetricTlv.
- *
- * @param c input channel buffer
- * @return object of TEDefaultMetricTlv
- */
- public static TEDefaultMetricSubTlv read(ChannelBuffer c) {
- return TEDefaultMetricSubTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthSubTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthSubTlv.java
deleted file mode 100644
index 6f3b065..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthSubTlv.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import java.util.Objects;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Provides Unreserved Bandwidth Tlv.
- */
-public class UnreservedBandwidthSubTlv implements PcepValueType {
-
- /* Reference :[RFC5305]/3.6
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=[TDB36] | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Unreserved Bandwidth |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
- private static final Logger log = LoggerFactory.getLogger(UnreservedBandwidthSubTlv.class);
-
- public static final short TYPE = 25;
- public static final short LENGTH = 4;
-
- private final int rawValue;
-
- /**
- * Constructor to initialize rawValue.
- *
- * @param rawValue Unreserved Bandwidth
- */
- public UnreservedBandwidthSubTlv(int rawValue) {
- this.rawValue = rawValue;
- }
-
- /**
- * Returns newly created UnreservedBandwidthTlv object.
- *
- * @param raw as Unreserved Bandwidth
- * @return object of UnreservedBandwidthTlv
- */
- public static UnreservedBandwidthSubTlv of(final int raw) {
- return new UnreservedBandwidthSubTlv(raw);
- }
-
- /**
- * Returns Unreserved Bandwidth.
- *
- * @return rawValue Unreserved Bandwidth
- */
- public int getInt() {
- return rawValue;
- }
-
- @Override
- public PcepVersion getVersion() {
- return PcepVersion.PCEP_1;
- }
-
- @Override
- public short getType() {
- return TYPE;
- }
-
- @Override
- public short getLength() {
- return LENGTH;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(rawValue);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof UnreservedBandwidthSubTlv) {
- UnreservedBandwidthSubTlv other = (UnreservedBandwidthSubTlv) obj;
- return Objects.equals(this.rawValue, other.rawValue);
- }
- return false;
- }
-
- @Override
- public int write(ChannelBuffer c) {
- int iLenStartIndex = c.writerIndex();
- c.writeShort(TYPE);
- c.writeShort(LENGTH);
- c.writeInt(rawValue);
- return c.writerIndex() - iLenStartIndex;
- }
-
- /**
- * Reads byte stream from channel buffer and returns object of UnreservedBandwidthTlv.
- *
- * @param c input channel buffer
- * @return object of UnreservedBandwidthTlv
- */
- public static UnreservedBandwidthSubTlv read(ChannelBuffer c) {
- return UnreservedBandwidthSubTlv.of(c.readInt());
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("Type", TYPE)
- .add("Length", LENGTH)
- .add("Value", rawValue)
- .toString();
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/package-info.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/package-info.java
deleted file mode 100644
index 73d86002..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of Tlvs and Pcep common objects.
- */
-package org.onosproject.pcepio.types;
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/HexDump.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/HexDump.java
deleted file mode 100644
index 79f3815..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/HexDump.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.util;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Provides Hex Dump for debugging.
- */
-public final class HexDump {
- private static final Logger log = LoggerFactory.getLogger(HexDump.class);
-
- private HexDump() {
- }
-
- public static void pcepHexDump(ChannelBuffer buff) {
-
- log.debug("==================== HEX DUMP ======================");
- try {
- byte[] yTemp;
- yTemp = buff.array();
-
- int iStartIndex = buff.readerIndex();
- int iEndIndex = buff.writerIndex();
- do {
- StringBuilder sb = new StringBuilder();
- for (int k = 0; (k < 16) && (iStartIndex < iEndIndex); ++k) {
- if (0 == k % 4) {
- sb.append(" "); //blank after 4 bytes
- }
- sb.append(String.format("%02X ", yTemp[iStartIndex++]));
- }
- log.debug(sb.toString());
- } while (iStartIndex < iEndIndex);
- } catch (Exception e) {
- log.error("[HexDump] Invalid buffer: " + e.toString());
- }
-
- log.debug("===================================================");
- }
-}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/package-info.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/package-info.java
deleted file mode 100644
index 6fa35a2..0000000
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides utility functionality for PCEP messages.
- */
-package org.onosproject.pcepio.util;
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepCloseMsgTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepCloseMsgTest.java
deleted file mode 100644
index fb59ee9..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepCloseMsgTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-
-public class PcepCloseMsgTest {
-
- /**
- * Common header, reason to close.
- */
- @Test
- public void closeMessageTest1() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] closeMsg = new byte[] {0x20, 0x07, 0x00, 0x0C, 0x0f, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02 };
-
- byte[] testCloseMsg = {0 };
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(closeMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message;
-
- message = reader.readFrom(buffer);
- assertThat(message, instanceOf(PcepCloseMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testCloseMsg = buf.array();
-
- int readLen = buf.writerIndex();
- testCloseMsg = new byte[readLen];
- buf.readBytes(testCloseMsg, 0, readLen);
- assertThat(testCloseMsg, is(closeMsg));
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java
deleted file mode 100644
index 4a4956f..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java
+++ /dev/null
@@ -1,756 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-
-/**
- * Test cases for PCEP ERROR Message.
- */
-public class PcepErrorMsgTest {
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
- * PCECC-CAPABILITY-TLV, LS Capability TLV)
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest1() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x34, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x28, // OPEN object header
- 0x20, 0x05, 0x1E, 0x01, // OPEN object
- 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
- 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x07, 0x00, 0x04, // PCECC-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x03, (byte) 0xFF, (byte) 0x00, 0x00, 0x04, // LS Capability TLV
- 0x00, 0x00, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
- * PCECC-CAPABILITY-TLV, LS Capability TLV)
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest2() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x28, // OPEN object header
- 0x20, 0x05, 0x1E, 0x01, // OPEN object
- 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
- 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x07, 0x00, 0x04, // PCECC-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x03, (byte) 0xFF, (byte) 0x00, 0x00, 0x04, // LS Capability TLV
- 0x00, 0x00, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
- * PCECC-CAPABILITY-TLV)
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest3() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x34, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x20, // OPEN object header
- 0x20, 0x05, 0x1E, 0x01, // OPEN object
- 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
- 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x07, 0x00, 0x04, // PCECC-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x03};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV)
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest4() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2c, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x18, // OPEN object header
- 0x20, 0x05, 0x1E, 0x01, // OPEN object
- 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
- 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY)
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest5() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x10, // OPEN object header
- 0x20, 0x05, 0x1E, 0x01, // OPEN object
- 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
- 0x00, 0x00, 0x00, 0x05};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest6() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x1C, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x08, // OPEN object header
- 0x20, 0x05, 0x1E, 0x01 // OPEN object
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, OPEN Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest7() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x08, // OPEN object header
- 0x20, 0x05, 0x1E, 0x01 // OPEN object
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, RP Object, PCEP-ERROR Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest8() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x20, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x03};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, PCEP-ERROR Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest9() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x01};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, PCEP-ERROR Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest10() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x01};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * LS Object, PCEP-ERROR Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest11() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x1C, // common header
- (byte) 0xE0, 0x13, 0x00, 0x10, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, // LS-ID
- 0x00, 0x00, 0x00, 0x10,
- 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x01};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * RP Object, PCEP-ERROR Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest12() throws PcepParseException, PcepOutOfBoundMessageException {
-
- //RP Object, PCEP-ERROR Object
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x18, // common header
- 0x02, 0x10, 0x00, 0x0C, // RP Object Header
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x01};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * RP Object, RP Object, PCEP-ERROR Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest13() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header
- 0x02, 0x10, 0x00, 0x0C, // RP Object Header
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x01};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * LS Object, LS Object, PCEP-ERROR Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest14() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2C, // common header
- (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, // LS-ID
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10,
- (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, // LS-ID
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x11,
- 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x01};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, LS Object, PCEP-ERROR Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest15() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x01,
- (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, // LS-ID
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10,
- 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x03};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest16() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2C, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x03};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, LS Object, LS Object, PCEP-ERROR Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest17() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x34, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x01,
- (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, // LS-ID
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10,
- (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, // LS-ID
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x11,
- 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x03};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object, PCEP-ERROR Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest18() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x06};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, PCEP-ERROR Object, LS Object, LS Object, PCEP-ERROR Object, PCEP-ERROR Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest19() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x44, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x01,
- 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x03,
- (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, // LS-ID
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10,
- (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, // LS-ID
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x11,
- 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x04, // PCERR Object Header
- 0x0D, 0x10, 0x00, 0x08,
- 0x00, 0x00, 0x01, 0x06};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-
- /**
- * This test case checks for
- * PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object, PCEP-ERROR Object,
- * LS Object, PCEP-ERROR Object
- * in PcepErrorMsg message.
- */
- @Test
- public void errorMessageTest20() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x4C, // common header
- 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
- 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x06, (byte) 0xE0, 0x10, 0x00, 0x10, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
- 0x00, 0x00, 0x01, 0x06};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(errorMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testErrorMsg = {0};
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- assertThat(message, instanceOf(PcepErrorMsg.class));
-
- message.writeTo(buf);
- int iReadLen = buf.writerIndex();
- testErrorMsg = new byte[iReadLen];
- buf.readBytes(testErrorMsg, 0, iReadLen);
-
- assertThat(testErrorMsg, is(errorMsg));
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgExtTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgExtTest.java
deleted file mode 100644
index ed39516..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgExtTest.java
+++ /dev/null
@@ -1,1684 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-
-public class PcepInitiateMsgExtTest {
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv),
- * END-POINTS, ERO, LSPA, BANDWIDTH, METRIC-LIST objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest1() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
- // StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC-LIST.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA4,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03,
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, //Metric object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv,
- * StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest2() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
- // StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA8,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x48, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
- 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS,
- * ERO, LSPA, BANDWIDTH objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest3() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
- // StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x8c,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
- //0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv),
- * END-POINTS, ERO, LSPA objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest4() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
- // StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
- // 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest5() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
- // StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA,
- * BANDWIDTH OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest6() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
- // StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x8c,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO,
- * LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest7() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
- // StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x98,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest8() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
- // END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x90,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest9() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
- // END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest10() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
- // END-POINTS, ERO, LSPA OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x70,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA OBJECT
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest11() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
- // END-POINTS, ERO, LSPA OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x7C,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03,
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest12() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
- // END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x78,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest13() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
- // END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
- * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest14() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
- // END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x7c,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
- * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest15() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
- // END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x70,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
- * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest16() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
- // END-POINTS, ERO, LSPA OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x68,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest17() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
- * BANDWIDTH OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest18() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x68,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03,
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
- * BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest19() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x74,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
- * BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest20() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
- * BANDWIDTH OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest21() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO,
- * LSPA OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest22() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
- * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest23() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
- * END-POINTS, ERO, LSPA BANDWIDTH OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest25() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA BANDWIDTH OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS,
- * ERO, LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest26() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS,
- // ERO, LSPA, BANDWIDTH, METRIC OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x6C,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA,
- * BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest27() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO,
- * LSPA, BANDWIDTH OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest28() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv),
- * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest29() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x4C,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv),
- * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest30() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5C,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest31() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP (SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
- * ERO, LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest32() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
- // ERO, LSPA, BANDWIDTH, METRIC OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
- * ERO, LSPA, BANDWIDTH OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest33() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
- // ERO, LSPA, BANDWIDTH OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
- * ERO, LSPA OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest34() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
- // ERO, LSPA OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
- * ERO, LSPA OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest35() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
- // ERO, LSPA OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
- * ERO, LSPA OBJECT objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest36() throws PcepParseException, PcepOutOfBoundMessageException {
-
- // SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
- // ERO, LSPA OBJECT.
- //
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
- 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-}
-
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgTest.java
deleted file mode 100644
index bce601b..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgTest.java
+++ /dev/null
@@ -1,1332 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-
-public class PcepInitiateMsgTest {
-
- /**
- * This test case checks for srp, lsp, end-point, ERO objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest1() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* srp, lsp, end-point, ERO.
- */
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, 0x54,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x00, 0x08, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for srp and lsp objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest2() throws PcepParseException, PcepOutOfBoundMessageException {
- /* srp, lsp.
- */
- byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x34,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x20, 0x10, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- 0x01, 0x01, 0x01, 0x01, 0x00, 0x43, (byte) 0x83, 0x01,
- 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33}; //SymbolicPathTlv
-
- byte[] testInitiateDeletionMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateDeletionMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testInitiateDeletionMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateDeletionMsg = new byte[iReadLen];
- buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
-
- assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO objects
- * in PcInitiate message.
- */
- @Test
- public void initiateMessageTest3() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO.
- */
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv), END-POINT, ERO objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest4() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv), END-POINT, ERO.
- */
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
- * END-POINT, ERO objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest5() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
- * END-POINT, ERO.
- */
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5c,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
- * END-POINT, ERO objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest6() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
- * END-POINT, ERO.
- */
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5c,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
- * END-POINT, ERO objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest7() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
- * END-POINT, ERO.
- */
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
- * END-POINT, ERO objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest8() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* SRP, LSP (StatefulIPv4LspIdentidiersTlv),
- * END-POINT, ERO.
- */
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x4c,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
- * END-POINT, ERO objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest9() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* SRP, LSP (StatefulIPv4LspIdentidiersTlv),
- * END-POINT, ERO.
- */
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x3c,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, StatefulRsvpErrorSpecTlv)
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest10() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, StatefulRsvpErrorSpecTlv).
- */
- byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x44,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f,
- (byte) 0xb6, 0x02, 0x4e, 0x20, 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08 //StatefulLspErrorCodeTlv
- };
-
- byte[] testInitiateDeletionMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateDeletionMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateDeletionMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateDeletionMsg = new byte[iReadLen];
- buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
-
- assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv) objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest11() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- StatefulLspErrorCodeTlv).*/
- byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x44,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08}; //StatefulLspErrorCodeTlv
-
- byte[] testInitiateDeletionMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateDeletionMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateDeletionMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateDeletionMsg = new byte[iReadLen];
- buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
-
- assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest12() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv).
- */
- byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x3c,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00 //SymbolicPathNameTlv
- };
-
- byte[] testInitiateDeletionMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateDeletionMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateDeletionMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateDeletionMsg = new byte[iReadLen];
- buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
-
- assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest13() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv).
- */
- byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x3c,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00}; //SymbolicPathNameTlv
-
- byte[] testInitiateDeletionMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateDeletionMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateDeletionMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateDeletionMsg = new byte[iReadLen];
- buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
-
- assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv)
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest14() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv).
- */
- byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x34,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20};
-
- byte[] testInitiateDeletionMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateDeletionMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateDeletionMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateDeletionMsg = new byte[iReadLen];
- buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
-
- assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv)
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest15() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* SRP, LSP (StatefulIPv4LspIdentidiersTlv).
- */
- byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x2c,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20};
-
- byte[] testInitiateDeletionMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateDeletionMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateDeletionMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateDeletionMsg = new byte[iReadLen];
- buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
-
- assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
- }
-
- /**
- * This test case checks for srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest16() throws PcepParseException, PcepOutOfBoundMessageException {
-
- //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest17() throws PcepParseException, PcepOutOfBoundMessageException {
-
- //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest18() throws PcepParseException, PcepOutOfBoundMessageException {
- //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for srp,lsp(all tlvs),end-point,ero,lspa,bandwidth,metric-list
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest19() throws PcepParseException, PcepOutOfBoundMessageException {
- //srp,lsp(all tlvs),end-point,ero,lspa,bandwidth,metric-list
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x74,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x04, //ERO object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for srp,lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, srp,
- * lsp(SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv) objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest20() throws PcepParseException, PcepOutOfBoundMessageException {
- /* srp,lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, srp,
- * lsp(SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv).
- */
- byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x64,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20};
-
- byte[] testInitiateDeletionMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateDeletionMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateDeletionMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateDeletionMsg = new byte[iReadLen];
- buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
-
- assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
- }
-
- /**
- * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest21() throws PcepParseException, PcepOutOfBoundMessageException {
- /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,
- * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero
- */
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x94,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest22() throws PcepParseException, PcepOutOfBoundMessageException {
- /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,
- * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa
- */
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA8,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest23() throws PcepParseException, PcepOutOfBoundMessageException {
- /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,
- * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth
- */
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xB0,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest24() throws PcepParseException, PcepOutOfBoundMessageException {
- /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,
- * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth*/
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xBC,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,
- * srp,lsp(StatefulIPv4LspIdentidiersTlv), end-point,ero,lspa,bandwidth,metric-list
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest25() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,
- * srp,lsp(StatefulIPv4LspIdentidiersTlv),
- * end-point,ero,lspa,bandwidth,metric-list */
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xC4,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,metric-list,
- * srp,lsp(StatefulIPv4LspIdentidiersTlv), end-point,ero,lspa,bandwidth,metric-list
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest26() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,metric-list,
- * srp,lsp(StatefulIPv4LspIdentidiersTlv),
- * end-point,ero,lspa,bandwidth,metric-list */
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xD0,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-
- /**
- * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list,
- * srp,lsp(StatefulIPv4LspIdentidiersTlv), end-point,ero,lspa,bandwidth,metric-list
- * objects in PcInitiate message.
- */
- @Test
- public void initiateMessageTest27() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list,
- * srp,lsp(StatefulIPv4LspIdentidiersTlv),
- * end-point,ero,lspa,bandwidth,metric-list */
- byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xE4,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
- 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
-
- byte[] testInitiateCreationMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(initiateCreationMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepInitiateMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testInitiateCreationMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testInitiateCreationMsg = new byte[iReadLen];
- buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
-
- assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsgTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsgTest.java
deleted file mode 100644
index b9bfa6f..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsgTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Assert;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-
-public class PcepKeepaliveMsgTest {
-
- /**
- * Common header for keep alive message.
- */
- @Test
- public void keepaliveMessageTest1() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] keepaliveMsg = new byte[] {0x20, 0x02, 0x00, 0x04 };
-
- byte[] testKeepaliveMsg = {0 };
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(keepaliveMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
- assertThat(message, instanceOf(PcepKeepaliveMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- message.writeTo(buf);
-
- testKeepaliveMsg = buf.array();
-
- int iReadLen = buf.writerIndex();
- testKeepaliveMsg = new byte[iReadLen];
- buf.readBytes(testKeepaliveMsg, 0, iReadLen);
-
- Assert.assertThat(testKeepaliveMsg, is(keepaliveMsg));
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLSReportMsgTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLSReportMsgTest.java
deleted file mode 100644
index 63ba2e9..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLSReportMsgTest.java
+++ /dev/null
@@ -1,1585 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-
-public class PcepLSReportMsgTest {
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV, Local Node Descriptors TLV(AutonomousSystemSubTlv)).
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest1() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, 0x2C, // common header
- (byte) 0xE0, 0x10, 0x00, 0x28, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x08, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystem Tlv
- 0x00, 0x00, 0x00, 0x11};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
-
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV, Local Node Descriptors TLV(AutonomousSystemSubTlv)) with different LS-ID.
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest2() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, 0x2C, // common header
- (byte) 0xE0, 0x10, 0x00, 0x28, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x08, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for LS Object (Routing Universe TLV)
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest3() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, 0x20, // common header
- (byte) 0xE0, 0x10, 0x00, 0x1C, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv.
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv)).
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest4() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, 0x48, // common header
- (byte) 0xE0, 0x10, 0x00, 0x44, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OspfAreaIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv))
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest5() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, 0x40, // common header
- (byte) 0xE0, 0x10, 0x00, 0x3C, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x1C, // Local Node Descriptors TLV
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for LS Object (Routing Universe TLV,Local Node Descriptors TLV(OSPFareaIDsubTlv,
- * IgpRouterIdSubTlv))
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest6() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, 0x38, // common header
- (byte) 0xE0, 0x10, 0x00, 0x34, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x14, // Local Node Descriptors TLV
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for LS Object (Routing Universe TLV,Local Node Descriptors TLV(IgpRouterIdSubTlv)).
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest7() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, 0x30, // common header
- (byte) 0xE0, 0x10, 0x00, 0x2C, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x0C, // Local Node Descriptors TLV
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for LS Object (Routing Universe TLV,Local Node Descriptors TLV)
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest8() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, 0x24, // common header
- (byte) 0xE0, 0x10, 0x00, 0x20, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x00 // Local Node Descriptors TLV
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv.
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv.
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv)).
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest9() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, 0x70, // common header
- (byte) 0xE0, 0x10, 0x00, 0x6C, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv))
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest10() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, 0x68, // common header
- (byte) 0xE0, 0x10, 0x00, 0x64, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x1C, //RemoteNodeDescriptorsTLV
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(OSPFareaIDsubTlv, IgpRouterIdSubTlv))
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest11() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, 0x60, // common header
- (byte) 0xE0, 0x10, 0x00, 0x5C, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x14, //RemoteNodeDescriptorsTLV
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(IgpRouterIdSubTlv))
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest12() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, 0x58, // common header
- (byte) 0xE0, 0x10, 0x00, 0x54, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x0c, //RemoteNodeDescriptorsTLV
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV)
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest13() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, 0x4C, // common header
- (byte) 0xE0, 0x10, 0x00, 0x48, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x00 //RemoteNodeDescriptorsTLV
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), LinkDescriptorsTLV(LinkLocalRemoteIdentifiersSubTlv
- * IPv4InterfaceAddressSubTlv, IPv4NeighborAddressSubTlv))
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest14() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, (byte) 0x90, // common header
- (byte) 0xE0, 0x10, 0x00, (byte) 0x8C, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x04, 0x00, 0x1C, //LinkDescriptorsTLV
- 0x00, 0x06, 0x00, 0x08, //LinkLocalRemoteIdentifiersSubTlv
- 0x01, 0x11, 0x00, 0x09,
- 0x01, 0x21, 0x00, 0x09,
- 0x00, 0x07, 0x00, 0x04, //IPv4InterfaceAddressSubTlv
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressSubTlv
- 0x01, 0x011, 0x01, 0x10
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), LinkDescriptorsTLV(
- * IPv4InterfaceAddressSubTlv, IPv4NeighborAddressSubTlv))
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest15() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, (byte) 0x84, // common header
- (byte) 0xE0, 0x10, 0x00, (byte) 0x80, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x04, 0x00, 0x10, //LinkDescriptorsTLV
- 0x00, 0x07, 0x00, 0x04, //IPv4InterfaceAddressSubTlv
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressSubTlv
- 0x01, 0x011, 0x01, 0x10
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), LinkDescriptorsTLV(IPv4NeighborAddressSubTlv))
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest16() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, (byte) 0x7C, // common header
- (byte) 0xE0, 0x10, 0x00, (byte) 0x78, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x04, 0x00, 0x08, //LinkDescriptorsTLV
- 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressSubTlv
- 0x01, 0x011, 0x01, 0x10
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), LinkDescriptorsTLV)
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest17() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, (byte) 0x74, // common header
- (byte) 0xE0, 0x10, 0x00, (byte) 0x70, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x04, 0x00, 0x00, //LinkDescriptorsTLV
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), LinkDescriptorsTLV(LinkLocalRemoteIdentifiersSubTlv
- * IPv4InterfaceAddressSubTlv, IPv4NeighborAddressSubTlv))
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest18() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, (byte) 0xC4, // common header
- (byte) 0xE0, 0x10, 0x00, (byte) 0xC0, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x04, 0x00, 0x1C, //LinkDescriptorsTLV
- 0x00, 0x06, 0x00, 0x08, //LinkLocalRemoteIdentifiersSubTlv
- 0x01, 0x11, 0x00, 0x09,
- 0x01, 0x21, 0x00, 0x09,
- 0x00, 0x07, 0x00, 0x04, //IPv4InterfaceAddressSubTlv
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressSubTlv
- 0x01, 0x011, 0x01, 0x10,
- (byte) 0xFF, 0x05, 0x00, 0x30, //NodeAttributesTlv
- 0x00, 0x0D, 0x00, 0x01, //NodeFlagBitsSubTlv
- (byte) 0x90, 0x00, 0x00, 0x00,
- 0x00, 0x0E, 0x00, 0x04, //OpaqueNodePropertiesSubTlv
- 0x01, 0x011, 0x01, 0x10,
- 0x00, 0x0F, 0x00, 0x08, //NodeNameSubTlv
- 0x08, 0x00, 0x01, 0x09,
- 0x08, 0x00, 0x01, 0x09,
- 0x00, 0x10, 0x00, 0x08, //ISISAreaIdentifierSubTlv
- 0x20, 0x01, 0x22, 0x01,
- 0x20, 0x01, 0x22, 0x01,
- 0x00, 0x11, 0x00, 0x04, //IPv4RouterIdOfLocalNodeSubTlv
- 0x00, 0x01, 0x01, 0x02
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), LinkDescriptorsTLV(LinkLocalRemoteIdentifiersSubTlv
- * IPv4InterfaceAddressSubTlv, IPv4NeighborAddressSubTlv), NodeAttributesTlv(NodeFlagBitsSubTlv
- * OpaqueNodePropertiesSubTlv, NodeNameSubTlv, ISISAreaIdentifierSubTlv, IPv4RouterIdOfLocalNodeSubTlv))
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest19() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, (byte) 0xC4, // common header
- (byte) 0xE0, 0x10, 0x00, (byte) 0xC0, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x04, 0x00, 0x1C, //LinkDescriptorsTLV
- 0x00, 0x06, 0x00, 0x08, //LinkLocalRemoteIdentifiersSubTlv
- 0x01, 0x11, 0x00, 0x09,
- 0x01, 0x21, 0x00, 0x09,
- 0x00, 0x07, 0x00, 0x04, //IPv4InterfaceAddressSubTlv
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressSubTlv
- 0x01, 0x011, 0x01, 0x10,
- (byte) 0xFF, 0x05, 0x00, 0x30, //NodeAttributesTlv
- 0x00, 0x0D, 0x00, 0x01, //NodeFlagBitsSubTlv
- (byte) 0x90, 0x00, 0x00, 0x00,
- 0x00, 0x0E, 0x00, 0x04, //OpaqueNodePropertiesSubTlv
- 0x01, 0x011, 0x01, 0x10,
- 0x00, 0x0F, 0x00, 0x08, //NodeNameSubTlv
- 0x08, 0x00, 0x01, 0x09,
- 0x08, 0x00, 0x01, 0x09,
- 0x00, 0x10, 0x00, 0x08, //ISISAreaIdentifierSubTlv
- 0x20, 0x01, 0x22, 0x01,
- 0x20, 0x01, 0x22, 0x01,
- 0x00, 0x11, 0x00, 0x04, //IPv4RouterIdOfLocalNodeSubTlv
- 0x00, 0x01, 0x01, 0x02
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), LinkDescriptorsTLV(LinkLocalRemoteIdentifiersSubTlv
- * IPv4InterfaceAddressSubTlv, IPv4NeighborAddressSubTlv), NodeAttributesTlv(OpaqueNodePropertiesSubTlv
- * NodeNameSubTlv, ISISAreaIdentifierSubTlv, IPv4RouterIdOfLocalNodeSubTlv))
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest20() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, (byte) 0xBC, // common header
- (byte) 0xE0, 0x10, 0x00, (byte) 0xB8, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x04, 0x00, 0x1C, //LinkDescriptorsTLV
- 0x00, 0x06, 0x00, 0x08, //LinkLocalRemoteIdentifiersSubTlv
- 0x01, 0x11, 0x00, 0x09,
- 0x01, 0x21, 0x00, 0x09,
- 0x00, 0x07, 0x00, 0x04, //IPv4InterfaceAddressSubTlv
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressSubTlv
- 0x01, 0x011, 0x01, 0x10,
- (byte) 0xFF, 0x05, 0x00, 0x28, //NodeAttributesTlv
- 0x00, 0x0E, 0x00, 0x04, //OpaqueNodePropertiesSubTlv
- 0x01, 0x011, 0x01, 0x10,
- 0x00, 0x0F, 0x00, 0x08, //NodeNameSubTlv
- 0x08, 0x00, 0x01, 0x09,
- 0x08, 0x00, 0x01, 0x09,
- 0x00, 0x10, 0x00, 0x08, //ISISAreaIdentifierSubTlv
- 0x20, 0x01, 0x22, 0x01,
- 0x20, 0x01, 0x22, 0x01,
- 0x00, 0x11, 0x00, 0x04, //IPv4RouterIdOfLocalNodeSubTlv
- 0x00, 0x01, 0x01, 0x02
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), LinkDescriptorsTLV(LinkLocalRemoteIdentifiersSubTlv.
- * IPv4InterfaceAddressSubTlv, IPv4NeighborAddressSubTlv), NodeAttributesTlv(OpaqueNodePropertiesSubTlv
- * ISISAreaIdentifierSubTlv, IPv4RouterIdOfLocalNodeSubTlv))
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest21() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, (byte) 0xB0, // common header
- (byte) 0xE0, 0x10, 0x00, (byte) 0xAC, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x04, 0x00, 0x1C, //LinkDescriptorsTLV
- 0x00, 0x06, 0x00, 0x08, //LinkLocalRemoteIdentifiersSubTlv
- 0x01, 0x11, 0x00, 0x09,
- 0x01, 0x21, 0x00, 0x09,
- 0x00, 0x07, 0x00, 0x04, //IPv4InterfaceAddressSubTlv
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressSubTlv
- 0x01, 0x011, 0x01, 0x10,
- (byte) 0xFF, 0x05, 0x00, 0x1C, //NodeAttributesTlv
- 0x00, 0x0E, 0x00, 0x04, //OpaqueNodePropertiesSubTlv
- 0x01, 0x011, 0x01, 0x10,
- 0x00, 0x10, 0x00, 0x08, //ISISAreaIdentifierSubTlv
- 0x20, 0x01, 0x22, 0x01,
- 0x20, 0x01, 0x22, 0x01,
- 0x00, 0x11, 0x00, 0x04, //IPv4RouterIdOfLocalNodeSubTlv
- 0x00, 0x01, 0x01, 0x02
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv,
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv,
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), LinkDescriptorsTLV(LinkLocalRemoteIdentifiersSubTlv,
- * IPv4InterfaceAddressSubTlv, IPv4NeighborAddressSubTlv), NodeAttributesTlv(NodeFlagBitsSubTlv,
- * OpaqueNodePropertiesSubTlv, NodeNameSubTlv, ISISAreaIdentifierSubTlv, IPv4RouterIdOfLocalNodeSubTlv),
- * LinkAttributesTlv(IPv4RouterIdOfRemoteNodeSubTlv, IPv6LSRouterIdofRemoteNodeTlv, AdministrativeGroupSubTlv,
- * TEDefaultMetricSubTlv, MaximumLinkBandwidthSubTlv, MaximumReservableLinkBandwidthSubTlv,
- * UnreservedBandwidthSubTlv, LinkProtectionTypeSubTlv, MPLSProtocolMaskSubTlv, IgpMetricSubTlv,
- * SharedRiskLinkGroupSubTlv, OpaqueLinkAttributeSubTlv, LinkNameAttributeSubTlv)).
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest22() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x01, 0x18, // common header
- (byte) 0xE0, 0x10, 0x01, 0x14, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x04, 0x00, 0x1C, //LinkDescriptorsTLV
- 0x00, 0x06, 0x00, 0x08, //LinkLocalRemoteIdentifiersSubTlv
- 0x01, 0x11, 0x00, 0x09,
- 0x01, 0x21, 0x00, 0x09,
- 0x00, 0x07, 0x00, 0x04, //IPv4InterfaceAddressSubTlv
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressSubTlv
- 0x01, 0x011, 0x01, 0x10,
- (byte) 0xFF, 0x05, 0x00, 0x1C, //NodeAttributesTlv
- 0x00, 0x0E, 0x00, 0x04, //OpaqueNodePropertiesSubTlv
- 0x01, 0x011, 0x01, 0x10,
- 0x00, 0x10, 0x00, 0x08, //ISISAreaIdentifierSubTlv
- 0x20, 0x01, 0x22, 0x01,
- 0x20, 0x01, 0x22, 0x01,
- 0x00, 0x11, 0x00, 0x04, //IPv4RouterIdOfLocalNodeSubTlv
- 0x00, 0x01, 0x01, 0x02,
- (byte) 0xFF, 0x06, 0x00, 0x64, //LinkAttributesTlv
- 0x00, 0x13, 0x00, 0x04, //IPv4RouterIdOfRemoteNodeSubTlv
- 0x00, 0x07, 0x08, 0x00,
- 0x00, 0x16, 0x00, 0x04, //AdministrativeGroupSubTlv
- 0x00, 0x09, 0x08, 0x00,
- 0x00, 0x17, 0x00, 0x04, //MaximumLinkBandwidthSubTlv
- 0x00, 0x09, 0x00, 0x00,
- 0x00, 0x18, 0x00, 0x04, //MaximumReservableLinkBandwidthSubTlv
- 0x00, 0x10, 0x00, 0x00,
- 0x00, 0x19, 0x00, 0x04, //UnreservedBandwidthSubTlv
- 0x00, 0x00, (byte) 0x90, 0x00,
- 0x00, 0x1A, 0x00, 0x04, //TEDefaultMetricSubTlv
- 0x00, (byte) 0x99, 0x09, 0x00,
- 0x00, 0x1B, 0x00, 0x02, //LinkProtectionTypeSubTlv
- 0x09, 0x00, 0x00, 0x00,
- 0x00, 0x1C, 0x00, 0x01, //MPLSProtocolMaskSubTlv
- (byte) 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x1D, 0x00, 0x04, //IgpMetricSubTlv
- 0x09, (byte) 0x89, 0x07, 0x00,
- 0x00, 0x1E, 0x00, 0x04, //SharedRiskLinkGroupSubTlv
- 0x04, 0x47, 0x00, 0x03,
- 0x00, 0x1F, 0x00, 0x08, //OpaqueLinkAttributeSubTlv
- 0x04, 0x49, 0x00, 0x04,
- 0x04, 0x47, 0x00, 0x03,
- 0x00, 0x20, 0x00, 0x04, //LinkNameAttributeSubTlv
- 0x04, 0x47, 0x00, 0x03
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv,
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv,
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), LinkDescriptorsTLV(LinkLocalRemoteIdentifiersSubTlv,
- * IPv4InterfaceAddressSubTlv, IPv4NeighborAddressSubTlv), NodeAttributesTlv(NodeFlagBitsSubTlv,
- * OpaqueNodePropertiesSubTlv, NodeNameSubTlv, ISISAreaIdentifierSubTlv, IPv4RouterIdOfLocalNodeSubTlv),
- * LinkAttributesTlv(IPv4RouterIdOfRemoteNodeSubTlv, IPv6LSRouterIdofRemoteNodeTlv, AdministrativeGroupSubTlv,
- * MaximumLinkBandwidthSubTlv, MaximumReservableLinkBandwidthSubTlv, UnreservedBandwidthSubTlv,
- * TEDefaultMetricSubTlv, LinkProtectionTypeSubTlv, MPLSProtocolMaskSubTlv, IgpMetricSubTlv,
- * SharedRiskLinkGroupSubTlv, OpaqueLinkAttributeSubTlv))
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest23() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x01, 0x10, // common header
- (byte) 0xE0, 0x10, 0x01, 0x0C, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x04, 0x00, 0x1C, //LinkDescriptorsTLV
- 0x00, 0x06, 0x00, 0x08, //LinkLocalRemoteIdentifiersSubTlv
- 0x01, 0x11, 0x00, 0x09,
- 0x01, 0x21, 0x00, 0x09,
- 0x00, 0x07, 0x00, 0x04, //IPv4InterfaceAddressSubTlv
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressSubTlv
- 0x01, 0x011, 0x01, 0x10,
- (byte) 0xFF, 0x05, 0x00, 0x1C, //NodeAttributesTlv
- 0x00, 0x0E, 0x00, 0x04, //OpaqueNodePropertiesSubTlv
- 0x01, 0x011, 0x01, 0x10,
- 0x00, 0x10, 0x00, 0x08, //ISISAreaIdentifierSubTlv
- 0x20, 0x01, 0x22, 0x01,
- 0x20, 0x01, 0x22, 0x01,
- 0x00, 0x11, 0x00, 0x04, //IPv4RouterIdOfLocalNodeSubTlv
- 0x00, 0x01, 0x01, 0x02,
- (byte) 0xFF, 0x06, 0x00, 0x5C, //LinkAttributesTlv
- 0x00, 0x13, 0x00, 0x04, //IPv4RouterIdOfRemoteNodeSubTlv
- 0x00, 0x07, 0x08, 0x00,
- 0x00, 0x16, 0x00, 0x04, //AdministrativeGroupSubTlv
- 0x00, 0x09, 0x08, 0x00,
- 0x00, 0x17, 0x00, 0x04, //MaximumLinkBandwidthSubTlv
- 0x00, 0x09, 0x00, 0x00,
- 0x00, 0x18, 0x00, 0x04, //MaximumReservableLinkBandwidthSubTlv
- 0x00, 0x10, 0x00, 0x00,
- 0x00, 0x19, 0x00, 0x04, //UnreservedBandwidthSubTlv
- 0x00, 0x00, (byte) 0x90, 0x00,
- 0x00, 0x1A, 0x00, 0x04, //TEDefaultMetricSubTlv
- 0x00, (byte) 0x99, 0x09, 0x00,
- 0x00, 0x1B, 0x00, 0x02, //LinkProtectionTypeSubTlv
- 0x09, 0x00, 0x00, 0x00,
- 0x00, 0x1C, 0x00, 0x01, //MPLSProtocolMaskSubTlv
- (byte) 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x1D, 0x00, 0x04, //IgpMetricSubTlv
- 0x09, (byte) 0x89, 0x07, 0x00,
- 0x00, 0x1E, 0x00, 0x04, //SharedRiskLinkGroupSubTlv
- 0x04, 0x47, 0x00, 0x03,
- 0x00, 0x1F, 0x00, 0x08, //OpaqueLinkAttributeSubTlv
- 0x04, 0x49, 0x00, 0x04,
- 0x04, 0x47, 0x00, 0x03
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv,
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv,
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), LinkDescriptorsTLV(LinkLocalRemoteIdentifiersSubTlv,
- * IPv4InterfaceAddressSubTlv, IPv4NeighborAddressSubTlv), NodeAttributesTlv(NodeFlagBitsSubTlv,
- * OpaqueNodePropertiesSubTlv, NodeNameSubTlv, ISISAreaIdentifierSubTlv, IPv4RouterIdOfLocalNodeSubTlv),
- * LinkAttributesTlv(IPv4RouterIdOfRemoteNodeSubTlv, IPv6LSRouterIdofRemoteNodeTlv, AdministrativeGroupSubTlv,
- * MaximumLinkBandwidthSubTlv, MaximumReservableLinkBandwidthSubTlv, UnreservedBandwidthSubTlv,
- * TEDefaultMetricSubTlv, LinkProtectionTypeSubTlv, MPLSProtocolMaskSubTlv, IgpMetricSubTlv,
- * SharedRiskLinkGroupSubTlv)) in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest24() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x01, 0x08, // common header
- (byte) 0xE0, 0x10, 0x01, 0x04, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x04, 0x00, 0x1C, //LinkDescriptorsTLV
- 0x00, 0x06, 0x00, 0x08, //LinkLocalRemoteIdentifiersSubTlv
- 0x01, 0x11, 0x00, 0x09,
- 0x01, 0x21, 0x00, 0x09,
- 0x00, 0x07, 0x00, 0x04, //IPv4InterfaceAddressSubTlv
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressSubTlv
- 0x01, 0x011, 0x01, 0x10,
- (byte) 0xFF, 0x05, 0x00, 0x1C, //NodeAttributesTlv
- 0x00, 0x0E, 0x00, 0x04, //OpaqueNodePropertiesSubTlv
- 0x01, 0x011, 0x01, 0x10,
- 0x00, 0x10, 0x00, 0x08, //ISISAreaIdentifierSubTlv
- 0x20, 0x01, 0x22, 0x01,
- 0x20, 0x01, 0x22, 0x01,
- 0x00, 0x11, 0x00, 0x04, //IPv4RouterIdOfLocalNodeSubTlv
- 0x00, 0x01, 0x01, 0x02,
- (byte) 0xFF, 0x06, 0x00, 0x54, //LinkAttributesTlv
- 0x00, 0x13, 0x00, 0x04, //IPv4RouterIdOfRemoteNodeSubTlv
- 0x00, 0x07, 0x08, 0x00,
- 0x00, 0x16, 0x00, 0x04, //AdministrativeGroupSubTlv
- 0x00, 0x09, 0x08, 0x00,
- 0x00, 0x17, 0x00, 0x04, //MaximumLinkBandwidthSubTlv
- 0x00, 0x09, 0x00, 0x00,
- 0x00, 0x18, 0x00, 0x04, //MaximumReservableLinkBandwidthSubTlv
- 0x00, 0x10, 0x00, 0x00,
- 0x00, 0x19, 0x00, 0x04, //UnreservedBandwidthSubTlv
- 0x00, 0x00, (byte) 0x90, 0x00,
- 0x00, 0x1A, 0x00, 0x04, //TEDefaultMetricSubTlv
- 0x00, (byte) 0x99, 0x09, 0x00,
- 0x00, 0x1B, 0x00, 0x02, //LinkProtectionTypeSubTlv
- 0x09, 0x00, 0x00, 0x00,
- 0x00, 0x1C, 0x00, 0x01, //MPLSProtocolMaskSubTlv
- (byte) 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x1D, 0x00, 0x04, //IgpMetricSubTlv
- 0x09, (byte) 0x89, 0x07, 0x00,
- 0x00, 0x1E, 0x00, 0x08, //SharedRiskLinkGroupSubTlv
- 0x04, 0x47, 0x00, 0x03,
- 0x04, 0x47, 0x00, 0x03
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-
- /**
- * This test case checks for
- * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv,
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv,
- * OSPFareaIDsubTlv, IgpRouterIdSubTlv), LinkDescriptorsTLV(LinkLocalRemoteIdentifiersSubTlv,
- * IPv4InterfaceAddressSubTlv, IPv4NeighborAddressSubTlv), NodeAttributesTlv(NodeFlagBitsSubTlv,
- * OpaqueNodePropertiesSubTlv, NodeNameSubTlv, ISISAreaIdentifierSubTlv, IPv4RouterIdOfLocalNodeSubTlv),
- * LinkAttributesTlv(IPv4RouterIdOfRemoteNodeSubTlv, IPv6LSRouterIdofRemoteNodeTlv, AdministrativeGroupSubTlv,
- * MaximumLinkBandwidthSubTlv, MaximumReservableLinkBandwidthSubTlv, UnreservedBandwidthSubTlv,
- * TEDefaultMetricSubTlv, LinkProtectionTypeSubTlv, MPLSProtocolMaskSubTlv, IgpMetricSubTlv))
- * in PcLSRpt message.
- */
- @Test
- public void lsReportMessageTest25() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, (byte) 0xFC, // common header
- (byte) 0xE0, 0x10, 0x00, (byte) 0xF8, // LS Object Header
- 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
- (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
- 0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
- 0x00, 0x00, 0x00, 0x11,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xFF, 0x04, 0x00, 0x1C, //LinkDescriptorsTLV
- 0x00, 0x06, 0x00, 0x08, //LinkLocalRemoteIdentifiersSubTlv
- 0x01, 0x11, 0x00, 0x09,
- 0x01, 0x21, 0x00, 0x09,
- 0x00, 0x07, 0x00, 0x04, //IPv4InterfaceAddressSubTlv
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressSubTlv
- 0x01, 0x011, 0x01, 0x10,
- (byte) 0xFF, 0x05, 0x00, 0x1C, //NodeAttributesTlv
- 0x00, 0x0E, 0x00, 0x04, //OpaqueNodePropertiesSubTlv
- 0x01, 0x011, 0x01, 0x10,
- 0x00, 0x10, 0x00, 0x08, //ISISAreaIdentifierSubTlv
- 0x20, 0x01, 0x22, 0x01,
- 0x20, 0x01, 0x22, 0x01,
- 0x00, 0x11, 0x00, 0x04, //IPv4RouterIdOfLocalNodeSubTlv
- 0x00, 0x01, 0x01, 0x02,
- (byte) 0xFF, 0x06, 0x00, 0x48, //LinkAttributesTlv
- 0x00, 0x13, 0x00, 0x04, //IPv4RouterIdOfRemoteNodeSubTlv
- 0x00, 0x07, 0x08, 0x00,
- 0x00, 0x16, 0x00, 0x04, //AdministrativeGroupSubTlv
- 0x00, 0x09, 0x08, 0x00,
- 0x00, 0x17, 0x00, 0x04, //MaximumLinkBandwidthSubTlv
- 0x00, 0x09, 0x00, 0x00,
- 0x00, 0x18, 0x00, 0x04, //MaximumReservableLinkBandwidthSubTlv
- 0x00, 0x10, 0x00, 0x00,
- 0x00, 0x19, 0x00, 0x04, //UnreservedBandwidthSubTlv
- 0x00, 0x00, (byte) 0x90, 0x00,
- 0x00, 0x1A, 0x00, 0x04, //TEDefaultMetricSubTlv
- 0x00, (byte) 0x99, 0x09, 0x00,
- 0x00, 0x1B, 0x00, 0x02, //LinkProtectionTypeSubTlv
- 0x09, 0x00, 0x00, 0x00,
- 0x00, 0x1C, 0x00, 0x01, //MPLSProtocolMaskSubTlv
- (byte) 0x80, 0x00, 0x00, 0x00,
- 0x00, 0x1D, 0x00, 0x04, //IgpMetricSubTlv
- 0x09, (byte) 0x89, 0x07, 0x00
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(lsReportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testReportMsg = {0};
-
- assertThat(message, instanceOf(PcepLSReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(lsReportMsg));
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java
deleted file mode 100644
index 6d5a7b3..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.Matchers.is;
-
-public class PcepLabelUpdateMsgTest {
-
- /**
- * This test case checks for
- * <pce-label-download> SRP, LSP, LABEL Object.
- * in PcepLabelUpdate message.
- */
- @Test
- public void labelUpdateMessageTest1() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x24, // common header
- 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10,
- 0x20, 0x10, 0x00, 0x08, // LSP Object Header
- 0x00, 0x01, 0x00, 0x00,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x10, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(labelUpdate);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testLabelUpdateMsg = {0};
- assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
-
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testLabelUpdateMsg = new byte[readLen];
- buf.readBytes(testLabelUpdateMsg, 0, readLen);
-
- assertThat(testLabelUpdateMsg, is(labelUpdate));
- }
-
- /**
- * This test case checks for
- * <pce-label-download> SRP, LSP, LABEL Object, LABEL Object.
- * in PcepLabelUpdate message.
- */
- @Test
- public void labelUpdateMessageTest2() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x30, // common header
- 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10,
- 0x20, 0x10, 0x00, 0x08, // LSP Object Header
- 0x00, 0x01, 0x00, 0x00,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x44, 0x00, 0x00,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x79, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(labelUpdate);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testLabelUpdateMsg = {0};
- assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testLabelUpdateMsg = new byte[readLen];
- buf.readBytes(testLabelUpdateMsg, 0, readLen);
-
- assertThat(testLabelUpdateMsg, is(labelUpdate));
- }
-
- /**
- * This test case checks for
- * <pce-label-map> SRP, LABEL, FEC Object.
- * in PcepLabelUpdate message.
- */
- @Test
- public void labelUpdateMessageTest3() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x24, // common header
- 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x79, 0x00, 0x00,
- (byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header
- 0x0A, 0x0A, 0x0B, 0x0B};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(labelUpdate);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testLabelUpdateMsg = {0};
- assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testLabelUpdateMsg = new byte[readLen];
- buf.readBytes(testLabelUpdateMsg, 0, readLen);
-
- assertThat(testLabelUpdateMsg, is(labelUpdate));
- }
-
- /**
- * This test case checks for
- * <pce-label-download> SRP, LSP, LABEL, LABEL, <pce-label-download> SRP, LSP, LABEL
- * in PcepLabelUpdate message.
- */
- @Test
- public void labelUpdateMessageTest4() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x50, // common header
- 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10,
- 0x20, 0x10, 0x00, 0x08, // LSP Object Header
- 0x00, 0x01, 0x00, 0x00,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x66, 0x00, 0x00,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x68, 0x00, 0x00,
- 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x11,
- 0x20, 0x10, 0x00, 0x08, // LSP Object Header
- 0x00, 0x02, 0x00, 0x00,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x44, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(labelUpdate);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testLabelUpdateMsg = {0};
- assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testLabelUpdateMsg = new byte[readLen];
- buf.readBytes(testLabelUpdateMsg, 0, readLen);
-
- assertThat(testLabelUpdateMsg, is(labelUpdate));
- }
-
- /**
- * This test case checks for
- * <pce-label-map> SRP, LABEL, FEC, <pce-label-map> SRP, LABEL, FEC.
- * in PcepLabelUpdate message.
- */
- @Test
- public void labelUpdateMessageTest5() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x44, // common header
- 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x44, 0x00, 0x00,
- (byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header
- 0x0A, 0x0A, 0x0B, 0x0B,
- 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x11,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x44, 0x00, 0x00,
- (byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header
- 0x0A, 0x0A, 0x0C, 0x0C};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(labelUpdate);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testLabelUpdateMsg = {0};
- assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testLabelUpdateMsg = new byte[readLen];
- buf.readBytes(testLabelUpdateMsg, 0, readLen);
-
- assertThat(testLabelUpdateMsg, is(labelUpdate));
- }
-
- /**
- * This test case checks for
- * <pce-label-download> SRP, LSP, LABEL, LABEL, <pce-label-download> SRP, LABEL, FEC.
- * in PcepLabelUpdate message.
- */
- @Test
- public void labelUpdateMessageTest6() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x50, // common header
- 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10,
- 0x20, 0x10, 0x00, 0x08, // LSP Object Header
- 0x00, 0x01, 0x00, 0x00,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x44, 0x00, 0x00,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x44, 0x00, 0x00,
- 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x12,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x44, 0x00, 0x00,
- (byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header
- 0x0A, 0x0A, 0x0D, 0x0D};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(labelUpdate);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testLabelUpdateMsg = {0};
- assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testLabelUpdateMsg = new byte[readLen];
- buf.readBytes(testLabelUpdateMsg, 0, readLen);
-
- assertThat(testLabelUpdateMsg, is(labelUpdate));
- }
-
- /**
- * This test case checks for
- * <pce-label-download> SRP, LABEL, FEC, <pce-label-download> SRP, LSP, LABEL, LABEL.
- * in PcepLabelUpdate message.
- */
- @Test
- public void labelUpdateMessageTest7() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x50, // common header
- 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x12,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x44, 0x00, 0x00,
- (byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header
- 0x0A, 0x0A, 0x0D, 0x0D,
- 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10,
- 0x20, 0x10, 0x00, 0x08, // LSP Object Header
- 0x00, 0x01, 0x00, 0x00,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x44, 0x00, 0x00,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x44, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(labelUpdate);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testLabelUpdateMsg = {0};
- assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testLabelUpdateMsg = new byte[readLen];
- buf.readBytes(testLabelUpdateMsg, 0, readLen);
-
- assertThat(testLabelUpdateMsg, is(labelUpdate));
- }
-
- /**
- * This test case checks for
- * <pce-label-download> SRP, LABEL, FEC, <pce-label-download> SRP, LSP, LABEL, LABEL.
- * <pce-label-download> SRP, LSP, LABEL, LABEL.
- * in PcepLabelUpdate message.
- */
- @Test
- public void labelUpdateMessageTest8() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] labelUpdate = new byte[]{0x20, (byte) 0xE2, 0x00, 0x7C, // common header
- 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x12,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x44, 0x00, 0x00,
- (byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header
- 0x0A, 0x0A, 0x0D, 0x0D,
- 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10,
- 0x20, 0x10, 0x00, 0x08, // LSP Object Header
- 0x00, 0x01, 0x00, 0x00,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x44, 0x00, 0x00,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x44, 0x00, 0x00,
- 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10,
- 0x20, 0x10, 0x00, 0x08, // LSP Object Header
- 0x00, 0x01, 0x00, 0x00,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x44, 0x00, 0x00,
- (byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x44, 0x00, 0x00};
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(labelUpdate);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- byte[] testLabelUpdateMsg = {0};
-
- assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testLabelUpdateMsg = new byte[readLen];
- buf.readBytes(testLabelUpdateMsg, 0, readLen);
-
- assertThat(testLabelUpdateMsg, is(labelUpdate));
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java
deleted file mode 100644
index 4d370f5..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java
+++ /dev/null
@@ -1,594 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-/**
- * Test cases for PCEP OPEN Message.
- */
-public class PcepOpenMsgTest {
-
- /**
- * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
- * PCECC-CAPABILITY-TLV in Pcep Open message.
- */
- @Test
- public void openMessageTest1() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x10, 0x00, 0x20, 0x20, 0x1e, 0x78, (byte) 0xbd,
- 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY
- 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
- (byte) 0xff, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
- };
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
-
- }
-
- /**
- * This test case checks open object with STATEFUL-PCE-CAPABILITY-TLV in Pcep Open message.
- */
- @Test
- public void openMessageTest2() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header
- 0x01, 0x10, 0x00, 0x10, // common object header
- 0x20, 0x1E, 0x78, 0x01, // OPEN object
- 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f}; // STATEFUL-PCE-CAPABILITY
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
-
- }
-
- /**
- * This test case checks open object with GmplsCapability tlv in Pcep Open message.
- */
- @Test
- public void openMessageTest3() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header
- 0x01, 0x10, 0x00, 0x10, // common object header
- 0x20, 0x1E, 0x78, 0x01, // OPEN object
- 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}; //GMPLS-CAPABILITY-TLV
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
-
- assertThat(testOpenMsg, is(openMsg));
-
- }
-
- /**
- * This test case checks open object with StatefulLspDbVer Tlv in Pcep Open message.
- */
- @Test
- public void openMessageTest4() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x18,
- 0x01, 0x10, 0x00, 0x14, 0x20, 0x1e, 0x78, 0x20,
- 0x00, 0x17, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; //StatefulLspDbVerTlv
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
-
- }
-
- /**
- * This test case checks open object with no tlv's in Pcep Open message.
- */
- @Test
- public void openMessageTest5() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x0C,
- 0x01, 0x10, 0x00, 0x08, 0x20, 0x1e, 0x78, (byte) 0xbd }; // no Tlvs in open messsage
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
-
- }
-
- /**
- * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV
- * with I bit set in Pcep Open message.
- */
- @Test
- public void openMessageTest6() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x11, 0x00, 0x20, //p bit not set & i bit set
- 0x20, 0x1e, 0x78, (byte) 0xbd,
- 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, // STATEFUL-PCE-CAPABILITY
- 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
- (byte) 0xff, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
- };
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
-
- }
-
- /**
- * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV
- * with P bit set in Pcep Open message.
- */
- @Test
- public void openMessageTest7() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x12, 0x00, 0x20, //p bit set & i bit not set
- 0x20, 0x1e, 0x78, (byte) 0xbd,
- 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY
- 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
- (byte) 0xff, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
- };
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
-
- }
-
- /**
- * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV
- * with P & I bits set in Pcep Open message.
- */
- @Test
- public void openMessageTest8() throws PcepParseException, PcepOutOfBoundMessageException {
-
- /* OPEN OBJECT (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV)
- with p bit set & i bit set.
- */
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x13, 0x00, 0x20, //p bit set & i bit set
- 0x20, 0x1e, 0x78, (byte) 0xbd,
- 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY
- 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
- (byte) 0xff, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
- };
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
-
- }
-
- /**
- * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV
- * with P & I bits set and invalid session id in Pcep Open message.
- */
- @Test
- public void openMessageTest9() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x13, 0x00, 0x20, //p bit set & i bit set
- 0x20, 0x1e, 0x78, 0x00, //invalid sessionID
- 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY
- 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
- (byte) 0xff, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
- };
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
-
- assertThat(testOpenMsg, is(openMsg));
-
- }
-
- /**
- * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV
- * in Pcep Open message.
- */
- @Test
- public void openMessageTest10() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x1C, // common header
- 0x01, 0x10, 0x00, 0x18, // common object header
- 0x20, 0x05, 0x1E, 0x01, // OPEN object
- 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
- 0x00, 0x00, 0x00, 0x05,
- 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x00};
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
-
- }
-
- /**
- * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
- * PCECC-CAPABILITY-TLV, TED Capability TLV in Pcep Open message.
- */
- @Test
- public void openMessageTest11() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x2C, // common header
- 0x01, 0x10, 0x00, 0x28, // common object header
- 0x20, 0x05, 0x1E, 0x01, // OPEN object
- 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
- 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x07, 0x00, 0x04, // PCECC-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x03, (byte) 0xFF, (byte) 0x00, 0x00, 0x04, // LS Capability TLV
- 0x00, 0x00, 0x00, 0x00 };
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
- }
-
- /**
- * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
- * PCECC-CAPABILITY-TLV in Pcep Open message.
- */
- @Test
- public void openMessageTest12() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, // common header
- 0x01, 0x10, 0x00, 0x20, // common object header
- 0x20, 0x05, 0x1E, 0x01, // OPEN object
- 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
- 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x07, 0x00, 0x04, // PCECC-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x03};
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
-
- }
-
- /**
- * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV
- * in Pcep Open message.
- */
- @Test
- public void openMessageTest13() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x1c, // common header
- 0x01, 0x10, 0x00, 0x18, // common object header
- 0x20, 0x05, 0x1E, 0x01, // OPEN object
- 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
- 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x00};
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
-
- assertThat(testOpenMsg, is(openMsg));
-
- }
-
- /**
- * This test case checks open object with STATEFUL-PCE-CAPABILITY in Pcep Open message.
- */
- @Test
- public void openMessageTest14() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header
- 0x01, 0x10, 0x00, 0x10, // common object header
- 0x20, 0x05, 0x1E, 0x01, // OPEN object
- 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
- 0x00, 0x00, 0x00, 0x05};
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
-
- assertThat(testOpenMsg, is(openMsg));
-
- }
-
- /**
- * This test case checks open object with no tlv Pcep Open message.
- */
- @Test
- public void openMessageTest15() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x0c, // common header
- 0x01, 0x10, 0x00, 0x08, // common object header
- 0x20, 0x05, 0x1E, 0x01 // OPEN object
- };
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
- assertThat(testOpenMsg, is(openMsg));
-
- }
-
- /**
- * This test case checks open object with LSR id encoded.
- */
- @Test
- public void openMessageTest16() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x18, // common header
- 0x01, 0x10, 0x00, 0x14, // common object header
- 0x20, 0x05, 0x1E, 0x01, // OPEN object
- (byte) 0xFF, 0x05, 0x00, 0x08, // Node attribute TLV
- 0x00, 0x11, 0x00, 0x04, // PCEP-LS-IPv4-ROUTER-ID sub tlv
- 0x02, 0x02, 0x02, 0x02
- };
-
- byte[] testOpenMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(openMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepOpenMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testOpenMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testOpenMsg = new byte[readLen];
- buf.readBytes(testOpenMsg, 0, readLen);
- assertThat(testOpenMsg, is(openMsg));
-
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java
deleted file mode 100644
index 4a30700..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-
-public class PcepReportMsgExtTest {
-
- /**
- * This test case checks forSRP Object,LSP Object(symbolic path tlv),ERO Object
- * SRP Object,LSP Object(symbolic path tlv,ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest39() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x98,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object
- * SRP Object,LSP Object(symbolic path tlv),ERO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest40() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x64,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object
- * SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest41() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x8c,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object,
- * Metric-list SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object,Metric-list,
- * RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest42() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0xE8,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, //RRO IPv4 subobjects
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * Tests PCRpt msg with Path-Setup-Type TLV as SR.
- *
- * @throws PcepParseException
- * @throws PcepOutOfBoundMessageException
- */
- @Test
- public void reportMessageTest43() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x3C,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
- 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
- 0x00, 0x00, 0x00, 0x01,
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- };
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * Tests PCRpt msg with Path-Setup-Type TLV as "without SR and without signalling".
- *
- * @throws PcepParseException
- * @throws PcepOutOfBoundMessageException
- */
- @Test
- public void reportMessageTest44() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x3C,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
- 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
- 0x00, 0x00, 0x00, 0x02,
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- };
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgTest.java
deleted file mode 100644
index bee2b06..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgTest.java
+++ /dev/null
@@ -1,1598 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-
-public class PcepReportMsgTest {
-
- /**
- * This test case checks for SRP object, LSP object(Symbolic path name tlv), ERO object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest1() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, 0x24,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x04}; //ERO Object
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object, LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv
- * StatefulLspErrorCodeTlv) ERO Object, LSPA Object, Metric-list, IRO object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest2() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x7c,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object // LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, // IPv4SubObjects
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, //Metric Object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- };
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv,StatefulLspErrorCodeTlv)
- * ERO Object, LSPA Object, Metric-list, IRO object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest3() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x70,
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //Ipv4SubObjects
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, //Metric Objects
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- };
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv,StatefulLspErrorCodeTlv)
- * ERO Object, LSPA Object, Metric-list
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest4() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x64,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object, LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv
- * StatefulLspErrorCodeTlv) ERO Object, IRO object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest5() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x50,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object, LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv
- * StatefulLspErrorCodeTlv) ERO Object, LSPA Object, Metric-list.
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest6() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x6c,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x04, //ERO Object
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, //Metric object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- };
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for LSP Object, ERO Object, LSPA Object, Metric-list, IRO object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest7() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x58,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, // Metric objects
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP object, LSP object( StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv) ERO object, LSPA object, Metric object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest8() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x70,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric Object
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,
- * StatefulLspErrorCodeTlv ),ERO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest9() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x44,
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(StatefulIPv4LspIdentidiersTlv)ERO Object,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest10() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x74,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(SymbolicPathNameTlv)ERO Object,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest11() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x68,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object, ERO Object,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest12() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x60,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(StatefulLspErrorCodeTlv)ERO Object,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest13() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x68,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(StatefulRsvpErrorSpecTlv),ERO Object,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest14() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x60,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(symbolic path tlv),LSPA Object,ERO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest15() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x7C,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(symbolic path tlv),BandWidth Object,ERO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest16() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x70,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object,ERO Object,LSPA Object,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest17() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x74,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object,ERO Object,BandWidth Object,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest18() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x68,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object,ERO Object,Metric-list,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest19() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x6C,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object,ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest20() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x88,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,
- * StatefulLspErrorCodeTlv ) ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest21() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xac,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv )
- * ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest22() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xA0,
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv )
- * ERO Object,BandWidth Object,Metric-list,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest23() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x8c,
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv )
- * ERO Object,Metric-list,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest24() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x84,
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv )
- * ERO Object,LSPA Object,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest25() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x8c,
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv )
- * ERO Object,LSPA Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest26() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x58,
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv)
- * ERO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest27() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x44,
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv )
- * LSPA Object,BandWidth Object,Metric-list,ERO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest28() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x6c,
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,Metric-list,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest29() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x74,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,Metric-list,RRO Object
- * SRP Object,LSP Object(symbolic path tlv),ERO Object,Metric-list,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest30() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xE4,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object
- * BandWidth Object,Metric-list,RRO Object,SRP Object,LSP Object(symbolic path tlv)
- * ERO Object,Metric-list,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest31() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x01, 0x00,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object
- * BandWidth Object,Metric-list,RRO Object,SRP Object,LSP Object(symbolic path tlv)
- * ERO Object,LSPA Object,Metric-list,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest32() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x01, (byte) 0x14,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object
- * BandWidth Object,Metric-list,RRO Object,SRP Object,LSP Object(symbolic path tlv)
- * ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest33() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x01, (byte) 0x1c,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
- 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object(symbolic path Tlv),ERO Object,LSPA Object
- * BandWidth Object,Metric-list,SRP Object,LSP Object(symbolic path tlv)
- * ERO Object,LSPA Object,BandWidth Object,Metric-list
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest34() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xB4,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x04, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric Object
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-
- /**
- * This test case checks for SRP Object,LSP Object)Symbolic path tlv),ERO Object,SRP Object
- * LSP Object(symbolic path tlv) ERO Object,LSPA Object, BandWidth Object,Metric-list
- * in PcRpt message.
- */
- @Test
- public void reportMessageTest35() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x8C,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, //ERO Object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, //LSPA Object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric Object
-
- byte[] testReportMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepReportMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
-
- int readLen = buf.writerIndex();
- testReportMsg = new byte[readLen];
- buf.readBytes(testReportMsg, 0, readLen);
-
- assertThat(testReportMsg, is(reportMsg));
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgExtTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgExtTest.java
deleted file mode 100644
index a8003ca..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgExtTest.java
+++ /dev/null
@@ -1,1270 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-
-/**
- * Test cases for PCEP update message.
- */
-public class PcepUpdateMsgExtTest {
-
- /**
- * This test case is for SRP object(symbolic path tlv), LSP object(StatefulLspDbVerTlv), ERO object,
- * Metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest1() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x8c,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
- * LSPA, Bandwidth object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest2() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSP object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object, ERO object, LSPA, bandwidth object
- * Metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest3() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,bandwidth object
- * Metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest4() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,bandwidth object
- * Metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest5() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object, LSPA, bandwidth object
- * Metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest6() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
- * bandwidth object Metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest7() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,LSPA
- * bandwidth object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest8() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulRsvpErrorSpecTlv), ERO object,LSPA
- * bandwidth object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest9() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x18, 0x00, 0x00, 0x10, 0x03,
- 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
- 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulRsvpErrorSpecTlv), ERO object,LSPA
- * bandwidth object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest10() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPa object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,LSPA
- * bandwidth object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest11() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,LSPA
- * bandwidth object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest12() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,LSPA
- * bandwidth object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest13() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,LSPA
- * metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest14() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object, ERO object,LSPA
- * metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest15() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //lspa object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,LSPA
- * metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest16() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,LSPA
- * metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest17() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,LSPA
- * metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest18() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
- * metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest19() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
- * Bandwidth , metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest20() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object, ERO object,
- * Bandwidth , metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest21() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,
- * Bandwidth , metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest22() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,
- * Bandwidth , metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest23() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,
- * Bandwidth , metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest24() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
- * Bandwidth , metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest25() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
- * LSPA object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest26() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object, ERO object,
- * bandwidth object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest27() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x34,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,
- * metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest28() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
- * lspa object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest29() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
- * bandwidth object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest30() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
- * metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest31() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case is for SRP object(symbolic path tlv), LSP object(StatefulLspDbVerTlv), ERO object,
- * Metric object in PcepUpdate message.
- */
- @Test
- public void pcepUpdateMsgTest32() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-}
-
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgTest.java
deleted file mode 100644
index 46f6fa0..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgTest.java
+++ /dev/null
@@ -1,1424 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.protocol;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.hamcrest.core.Is.is;
-
-public class PcepUpdateMsgTest {
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), ERO in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest1() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x30,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv
- 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x04 }; //ERO object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP(SymbolicPathNameTlv), LSP (StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv, StatefulLspErrorCodeTlv), ERO, LSPA, Metric-list in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest2() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x94,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object // lsp object
- 0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv
- 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x24, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
- 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
- * ERO objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest3() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x38,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x04 }; //ERO object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv), ERO objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest4() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x04 }; //ERO object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv), ERO objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest5() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x04 }; //ERO object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv), ERO objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest6() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x04 };
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
-
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv), ERO objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest7() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x04}; //ERO object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv), ERO (IPv4SubObject) objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest8() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x0c, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00 };
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject) objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest9() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00 };
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject), LSPA objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest10() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x6c,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest11() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest12() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest13() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
- * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric Object objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest14() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
- * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest15() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
- * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest16() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
- * ERO (IPv4SubObject, IPv4SubObject),LSPA objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest17() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x05, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
- * ERO (IPv4SubObject, IPv4SubObject),Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest18() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
- * ERO (IPv4SubObject, IPv4SubObject),Metric-list objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest19() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv),ERO (IPv4SubObject, IPv4SubObject),LSPA, Bandwidth, Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest20() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
- * ERO (IPv4SubObject, IPv4SubObject), Bandwidth objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest21() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
- * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest22() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5C,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
- * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest23() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
- * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest24() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
- * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest25() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv) ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth,
- * Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest26() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
- * StatefulLspErrorCodeTlv) ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth,
- * Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest27() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
- * SymbolicPathNameTlv, StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),
- * LSPA, Bandwidth, Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest28() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
- * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest29() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
- (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
- (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP,
- * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest30() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (StatefulLspErrorCodeTlv),
- * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest31() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP,
- * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest32() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x8, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv),
- * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest33() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
- 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-
- /**
- * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv),
- * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
- */
- @Test
- public void pcepUpdateMsgTest34() throws PcepParseException, PcepOutOfBoundMessageException {
-
- byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
- 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
- 0x01, 0x01, 0x04, 0x00,
- 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
- 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
- 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
-
- byte[] testupdateMsg = {0};
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(updateMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = null;
-
- message = reader.readFrom(buffer);
-
- assertThat(message, instanceOf(PcepUpdateMsg.class));
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
- message.writeTo(buf);
- testupdateMsg = buf.array();
-
- int readLen = buf.writerIndex() - 0;
- testupdateMsg = new byte[readLen];
- buf.readBytes(testupdateMsg, 0, readLen);
-
- assertThat(testupdateMsg, is(updateMsg));
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AdministrativeGroupSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AdministrativeGroupSubTlvTest.java
deleted file mode 100644
index ab30bd4..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AdministrativeGroupSubTlvTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the AdministrativeGroupSubTlv.
- */
-public class AdministrativeGroupSubTlvTest {
- private final AdministrativeGroupSubTlv tlv1 = AdministrativeGroupSubTlv.of(1);
- private final AdministrativeGroupSubTlv sameAsTlv1 = AdministrativeGroupSubTlv.of(1);
- private final AdministrativeGroupSubTlv tlv2 = AdministrativeGroupSubTlv.of(2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemNumberSubObjectTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemNumberSubObjectTest.java
deleted file mode 100644
index d14ffcf..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemNumberSubObjectTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the AutonomousSystemNumberSubObject.
- */
-public class AutonomousSystemNumberSubObjectTest {
-
- private final AutonomousSystemNumberSubObject subObj1 = AutonomousSystemNumberSubObject.of((short) 2);
- private final AutonomousSystemNumberSubObject sameAsSubObj1 = AutonomousSystemNumberSubObject.of((short) 2);
- private final AutonomousSystemNumberSubObject subObj2 = AutonomousSystemNumberSubObject.of((short) 3);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(subObj1, sameAsSubObj1)
- .addEqualityGroup(subObj2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemSubTlvTest.java
deleted file mode 100644
index 26ac3fc..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemSubTlvTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the AutonomousSystemSubTlv.
- */
-public class AutonomousSystemSubTlvTest {
- private final AutonomousSystemSubTlv tlv1 = AutonomousSystemSubTlv.of(1);
- private final AutonomousSystemSubTlv sameAsTlv1 = AutonomousSystemSubTlv.of(1);
- private final AutonomousSystemSubTlv tlv2 = AutonomousSystemSubTlv.of(2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/BgpLsIdentifierSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/BgpLsIdentifierSubTlvTest.java
deleted file mode 100644
index 24f9dda..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/BgpLsIdentifierSubTlvTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the BgpLsIdentifierSubTlv.
- */
-public class BgpLsIdentifierSubTlvTest {
- private final BgpLsIdentifierSubTlv tlv1 = BgpLsIdentifierSubTlv.of(1);
- private final BgpLsIdentifierSubTlv sameAsTlv1 = BgpLsIdentifierSubTlv.of(1);
- private final BgpLsIdentifierSubTlv tlv2 = BgpLsIdentifierSubTlv.of(2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/GmplsCapabilityTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/GmplsCapabilityTlvTest.java
deleted file mode 100644
index 5db8436..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/GmplsCapabilityTlvTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the GmplsCapabilityTlv.
- */
-public class GmplsCapabilityTlvTest {
- private final GmplsCapabilityTlv tlv1 = GmplsCapabilityTlv.of(1);
- private final GmplsCapabilityTlv sameAsTlv1 = GmplsCapabilityTlv.of(1);
- private final GmplsCapabilityTlv tlv2 = GmplsCapabilityTlv.of(2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4InterfaceAddressSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4InterfaceAddressSubTlvTest.java
deleted file mode 100644
index fa3faf3..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4InterfaceAddressSubTlvTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the IPv4InterfaceAddressSubTlv.
- */
-public class IPv4InterfaceAddressSubTlvTest {
-
- private final IPv4InterfaceAddressSubTlv tlv1 = IPv4InterfaceAddressSubTlv.of(2);
- private final IPv4InterfaceAddressSubTlv sameAsTlv1 = IPv4InterfaceAddressSubTlv.of(2);
- private final IPv4InterfaceAddressSubTlv tlv2 = IPv4InterfaceAddressSubTlv.of(3);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4NeighborAddressSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4NeighborAddressSubTlvTest.java
deleted file mode 100644
index 70a5851..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4NeighborAddressSubTlvTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the IPv4NeighborAddressSubTlv.
- */
-public class IPv4NeighborAddressSubTlvTest {
-
- private final IPv4NeighborAddressSubTlv tlv1 = IPv4NeighborAddressSubTlv.of(2);
- private final IPv4NeighborAddressSubTlv sameAsTlv1 = IPv4NeighborAddressSubTlv.of(2);
- private final IPv4NeighborAddressSubTlv tlv2 = IPv4NeighborAddressSubTlv.of(3);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4RouterIdOfLocalNodeSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4RouterIdOfLocalNodeSubTlvTest.java
deleted file mode 100644
index ab926d4..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4RouterIdOfLocalNodeSubTlvTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the IPv4RouterIdOfLocalNodeSubTlv.
- */
-public class IPv4RouterIdOfLocalNodeSubTlvTest {
-
- private final IPv4RouterIdOfLocalNodeSubTlv tlv1 = IPv4RouterIdOfLocalNodeSubTlv.of(2);
- private final IPv4RouterIdOfLocalNodeSubTlv sameAsTlv1 = IPv4RouterIdOfLocalNodeSubTlv.of(2);
- private final IPv4RouterIdOfLocalNodeSubTlv tlv2 = IPv4RouterIdOfLocalNodeSubTlv.of(3);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4RouterIdOfRemoteNodeSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4RouterIdOfRemoteNodeSubTlvTest.java
deleted file mode 100644
index 8d65470..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4RouterIdOfRemoteNodeSubTlvTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the IPv4RouterIdOfRemoteNodeSubTlv.
- */
-public class IPv4RouterIdOfRemoteNodeSubTlvTest {
-
- private final IPv4RouterIdOfRemoteNodeSubTlv tlv1 = IPv4RouterIdOfRemoteNodeSubTlv.of(2);
- private final IPv4RouterIdOfRemoteNodeSubTlv sameAsTlv1 = IPv4RouterIdOfRemoteNodeSubTlv.of(2);
- private final IPv4RouterIdOfRemoteNodeSubTlv tlv2 = IPv4RouterIdOfRemoteNodeSubTlv.of(3);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4SubObjectTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4SubObjectTest.java
deleted file mode 100644
index 8dce2fe..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4SubObjectTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the IPv4SubObject.
- */
-public class IPv4SubObjectTest {
-
- private final IPv4SubObject subObj1 = IPv4SubObject.of(2, (byte) 16, (byte) 0);
- private final IPv4SubObject sameAsSubObj1 = IPv4SubObject.of(2, (byte) 16, (byte) 0);
- private final IPv4SubObject subObj2 = IPv4SubObject.of(3, (byte) 16, (byte) 0);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(subObj1, sameAsSubObj1)
- .addEqualityGroup(subObj2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6InterfaceAddressSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6InterfaceAddressSubTlvTest.java
deleted file mode 100644
index f8929a1..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6InterfaceAddressSubTlvTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the IPv6InterfaceAddressSubTlv.
- */
-public class IPv6InterfaceAddressSubTlvTest {
-
- private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
- private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x01};
-
- private final IPv6InterfaceAddressSubTlv tlv1 = IPv6InterfaceAddressSubTlv.of(b1);
- private final IPv6InterfaceAddressSubTlv sameAsTlv1 = IPv6InterfaceAddressSubTlv.of(b1);
- private final IPv6InterfaceAddressSubTlv tlv2 = IPv6InterfaceAddressSubTlv.of(b2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6NeighborAddressSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6NeighborAddressSubTlvTest.java
deleted file mode 100644
index fd7f5c3..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6NeighborAddressSubTlvTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the IPv6NeighborAddressSubTlv.
- */
-public class IPv6NeighborAddressSubTlvTest {
-
- private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
- private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x01};
-
- private final IPv6NeighborAddressSubTlv tlv1 = IPv6NeighborAddressSubTlv.of(b1);
- private final IPv6NeighborAddressSubTlv sameAsTlv1 = IPv6NeighborAddressSubTlv.of(b1);
- private final IPv6NeighborAddressSubTlv tlv2 = IPv6NeighborAddressSubTlv.of(b2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6RouterIdofLocalNodeSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6RouterIdofLocalNodeSubTlvTest.java
deleted file mode 100644
index be75537..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6RouterIdofLocalNodeSubTlvTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the IPv6RouterIdofLocalNodeSubTlv.
- */
-public class IPv6RouterIdofLocalNodeSubTlvTest {
-
- private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
- private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
-
- private final IPv6RouterIdofLocalNodeSubTlv tlv1 = IPv6RouterIdofLocalNodeSubTlv.of(b1);
- private final IPv6RouterIdofLocalNodeSubTlv sameAsTlv1 = IPv6RouterIdofLocalNodeSubTlv.of(b1);
- private final IPv6RouterIdofLocalNodeSubTlv tlv2 = IPv6RouterIdofLocalNodeSubTlv.of(b2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6RouterIdofRemoteNodeSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6RouterIdofRemoteNodeSubTlvTest.java
deleted file mode 100644
index 9b4c916..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6RouterIdofRemoteNodeSubTlvTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the IPv6RouterIdofRemoteNodeSubTlv.
- */
-public class IPv6RouterIdofRemoteNodeSubTlvTest {
-
- private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
- private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
-
- private final IPv6RouterIdofRemoteNodeSubTlv tlv1 = IPv6RouterIdofRemoteNodeSubTlv.of(b1);
- private final IPv6RouterIdofRemoteNodeSubTlv sameAsTlv1 = IPv6RouterIdofRemoteNodeSubTlv.of(b1);
- private final IPv6RouterIdofRemoteNodeSubTlv tlv2 = IPv6RouterIdofRemoteNodeSubTlv.of(b2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6SubObjectTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6SubObjectTest.java
deleted file mode 100644
index 1b6cf87..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6SubObjectTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the IPv6SubObject.
- */
-public class IPv6SubObjectTest {
-
- private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
- private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
-
- private final IPv6SubObject subObj1 = IPv6SubObject.of(b1);
- private final IPv6SubObject sameAsSubObj1 = IPv6SubObject.of(b1);
- private final IPv6SubObject subObj2 = IPv6SubObject.of(b2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(subObj1, sameAsSubObj1).addEqualityGroup(subObj2).testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IgpMetricSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IgpMetricSubTlvTest.java
deleted file mode 100644
index dd373c6..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IgpMetricSubTlvTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the IgpMetricSubTlv.
- */
-public class IgpMetricSubTlvTest {
- private final byte[] b1 = new byte[] {0x01, 0x02};
- private final byte[] b2 = new byte[] {0x01, 0x03};
- private final IgpMetricSubTlv tlv1 = IgpMetricSubTlv.of(b1, (short) 2);
- private final IgpMetricSubTlv sameAsTlv1 = IgpMetricSubTlv.of(b1, (short) 2);
- private final IgpMetricSubTlv tlv2 = IgpMetricSubTlv.of(b2, (short) 2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IgpRouterIdSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IgpRouterIdSubTlvTest.java
deleted file mode 100644
index ceaf66f..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IgpRouterIdSubTlvTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test case for IgpRouterIdSubTlv.
- */
-public class IgpRouterIdSubTlvTest {
-
- private final byte[] value1 = {1, 2 };
- private final Short length1 = 2;
- private final IgpRouterIdSubTlv tlv1 = IgpRouterIdSubTlv.of(value1, length1);
-
- private final Short length2 = 2;
- private final IgpRouterIdSubTlv tlv2 = IgpRouterIdSubTlv.of(value1, length2);
-
- private final byte[] value3 = {1, 2, 3 };
- private final Short length3 = 3;
- private final IgpRouterIdSubTlv tlv3 = IgpRouterIdSubTlv.of(value3, length3);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IsisAreaIdentifierSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IsisAreaIdentifierSubTlvTest.java
deleted file mode 100644
index 586dbf7..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IsisAreaIdentifierSubTlvTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the IsisAreaIdentifierSubTlv.
- */
-public class IsisAreaIdentifierSubTlvTest {
-
- private final byte[] b1 = new byte[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
- private final byte[] b2 = new byte[] {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
-
- private final IsisAreaIdentifierSubTlv tlv1 = IsisAreaIdentifierSubTlv.of(b1, (short) 20);
- private final IsisAreaIdentifierSubTlv sameAsTlv1 = IsisAreaIdentifierSubTlv.of(b1, (short) 20);
- private final IsisAreaIdentifierSubTlv tlv2 = IsisAreaIdentifierSubTlv.of(b2, (short) 20);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LabelSubObjectTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LabelSubObjectTest.java
deleted file mode 100644
index 940f7b0..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LabelSubObjectTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the LabelSubObject.
- */
-public class LabelSubObjectTest {
-
- private final LabelSubObject subObj1 = LabelSubObject.of((byte) 0, (byte) 1, 20);
- private final LabelSubObject sameAsSubObj1 = LabelSubObject.of((byte) 0, (byte) 1, 20);
- private final LabelSubObject subObj2 = LabelSubObject.of((byte) 0, (byte) 1, 30);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(subObj1, sameAsSubObj1)
- .addEqualityGroup(subObj2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkAttributesTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkAttributesTlvTest.java
deleted file mode 100644
index 78011c8..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkAttributesTlvTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Test case for TE Link Attribute Tlv.
- */
-public class LinkAttributesTlvTest {
-
- private final AdministrativeGroupSubTlv administrativeGroupTlv1 = new AdministrativeGroupSubTlv(10);
- private final MaximumReservableLinkBandwidthSubTlv maximumReservableLinkBandwidthTlv1 =
- new MaximumReservableLinkBandwidthSubTlv(20);
-
- private final AdministrativeGroupSubTlv administrativeGroupTlv2 = new AdministrativeGroupSubTlv(20);
- private final MaximumReservableLinkBandwidthSubTlv maximumReservableLinkBandwidthTlv2 =
- new MaximumReservableLinkBandwidthSubTlv(30);
-
- private final List<PcepValueType> llLinkAttributesSubTLV1 = new LinkedList<>();
- private final boolean a = llLinkAttributesSubTLV1.add(administrativeGroupTlv1);
- private final boolean b = llLinkAttributesSubTLV1.add(maximumReservableLinkBandwidthTlv1);
-
- private final List<PcepValueType> llLinkAttributesSubTLV2 = new LinkedList<>();
-
- private final boolean c = llLinkAttributesSubTLV2.add(administrativeGroupTlv2);
- private final boolean d = llLinkAttributesSubTLV2.add(maximumReservableLinkBandwidthTlv2);
-
- private final LinkAttributesTlv tlv1 = LinkAttributesTlv.of(llLinkAttributesSubTLV1);
- private final LinkAttributesTlv sameAsTlv1 = LinkAttributesTlv.of(llLinkAttributesSubTLV1);
- private final LinkAttributesTlv tlv2 = LinkAttributesTlv.of(llLinkAttributesSubTLV2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkDescriptorsTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkDescriptorsTlvTest.java
deleted file mode 100644
index 11e5393..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkDescriptorsTlvTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Test case for TE link descriptors Tlv.
- */
-public class LinkDescriptorsTlvTest {
- private final LinkLocalRemoteIdentifiersSubTlv linkLocalRemoteIdentifiersTlv1 = new
- LinkLocalRemoteIdentifiersSubTlv(10, 10);
- private final IPv4InterfaceAddressSubTlv iPv4InterfaceAddressTlv1 = new IPv4InterfaceAddressSubTlv(0x01010101);
-
- private final LinkLocalRemoteIdentifiersSubTlv linkLocalRemoteIdentifiersTlv2 = new
- LinkLocalRemoteIdentifiersSubTlv(20, 20);
- private final IPv4InterfaceAddressSubTlv iPv4InterfaceAddressTlv2 = new IPv4InterfaceAddressSubTlv(0x02020202);
-
- private final List<PcepValueType> llLinkDescriptorsSubTLVs1 = new LinkedList<>();
- private final boolean a = llLinkDescriptorsSubTLVs1.add(linkLocalRemoteIdentifiersTlv1);
- private final boolean b = llLinkDescriptorsSubTLVs1.add(iPv4InterfaceAddressTlv1);
-
- private final List<PcepValueType> llLinkDescriptorsSubTLVs2 = new LinkedList<>();
- private final boolean c = llLinkDescriptorsSubTLVs2.add(linkLocalRemoteIdentifiersTlv2);
- private final boolean d = llLinkDescriptorsSubTLVs2.add(iPv4InterfaceAddressTlv2);
-
- private final LinkDescriptorsTlv tlv1 = LinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs1);
- private final LinkDescriptorsTlv sameAstlv1 = LinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs1);
- private final LinkDescriptorsTlv tlv2 = LinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, sameAstlv1).addEqualityGroup(tlv2).testEquals();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersSubTlvTest.java
deleted file mode 100644
index febdf30..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersSubTlvTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the LinkLocalRemoteIdentifiersSubTlv.
- */
-public class LinkLocalRemoteIdentifiersSubTlvTest {
-
- private final LinkLocalRemoteIdentifiersSubTlv tlv1 = LinkLocalRemoteIdentifiersSubTlv.of(10, 20);
- private final LinkLocalRemoteIdentifiersSubTlv sameAsTlv1 = LinkLocalRemoteIdentifiersSubTlv.of(10, 20);
- private final LinkLocalRemoteIdentifiersSubTlv tlv2 = LinkLocalRemoteIdentifiersSubTlv.of(20, 30);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkNameAttributeSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkNameAttributeSubTlvTest.java
deleted file mode 100644
index ffca22d..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkNameAttributeSubTlvTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Equality test for LinkNameAttributeSubTlv.
- */
-public class LinkNameAttributeSubTlvTest {
- private final byte[] rawValue1 = new byte[] {0x01, 0x00};
- private final byte[] rawValue2 = new byte[] {0x02, 0x00};
-
- private final LinkNameAttributeSubTlv tlv1 = new LinkNameAttributeSubTlv(rawValue1, (short) rawValue1.length);
- private final LinkNameAttributeSubTlv sameAsTlv1 = LinkNameAttributeSubTlv.of(tlv1.getValue(), tlv1.getLength());
- private final LinkNameAttributeSubTlv tlv2 = new LinkNameAttributeSubTlv(rawValue2, (short) 0);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkProtectionTypeSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkProtectionTypeSubTlvTest.java
deleted file mode 100644
index d079e34..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkProtectionTypeSubTlvTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the LinkProtectionTypeSubTlv.
- */
-public class LinkProtectionTypeSubTlvTest {
- private final byte rawValue1 = 0x0A;
- private final byte rawValue2 = 0x0B;
-
- private final LinkProtectionTypeSubTlv tlv1 = new LinkProtectionTypeSubTlv(rawValue1);
- private final LinkProtectionTypeSubTlv sameAsTlv1 = new LinkProtectionTypeSubTlv(rawValue1);
- private final LinkProtectionTypeSubTlv tlv2 = new LinkProtectionTypeSubTlv(rawValue2, (byte) 0);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LocalNodeDescriptorsTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LocalNodeDescriptorsTlvTest.java
deleted file mode 100644
index 35d6c7f..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LocalNodeDescriptorsTlvTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Test of the LocalNodeDescriptorsTlv.
- */
-public class LocalNodeDescriptorsTlvTest {
-
- private final AutonomousSystemSubTlv baAutoSysTlvRawValue1 = new AutonomousSystemSubTlv(1);
- private final BgpLsIdentifierSubTlv baBgplsIdRawValue1 = new BgpLsIdentifierSubTlv(1);
-
- private final AutonomousSystemSubTlv baAutoSysTlvRawValue2 = new AutonomousSystemSubTlv(2);
- private final BgpLsIdentifierSubTlv baBgplsIdRawValue2 = new BgpLsIdentifierSubTlv(2);
-
- private final List<PcepValueType> llNodeDescriptorSubTLVs1 = new LinkedList<PcepValueType>();
- private final boolean a = llNodeDescriptorSubTLVs1.add(baAutoSysTlvRawValue1);
- private final boolean b = llNodeDescriptorSubTLVs1.add(baBgplsIdRawValue1);
-
- private final List<PcepValueType> llNodeDescriptorSubTLVs2 = new LinkedList<PcepValueType>();
- private final boolean c = llNodeDescriptorSubTLVs2.add(baAutoSysTlvRawValue2);
- private final boolean d = llNodeDescriptorSubTLVs2.add(baBgplsIdRawValue2);
-
- private final LocalNodeDescriptorsTlv tlv1 = LocalNodeDescriptorsTlv.of(llNodeDescriptorSubTLVs1);
- private final LocalNodeDescriptorsTlv sameAstlv1 = LocalNodeDescriptorsTlv.of(llNodeDescriptorSubTLVs1);
- private final LocalNodeDescriptorsTlv tlv2 = LocalNodeDescriptorsTlv.of(llNodeDescriptorSubTLVs2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, sameAstlv1).addEqualityGroup(tlv2).testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LsCapabilityTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LsCapabilityTlvTest.java
deleted file mode 100644
index 3ef1932..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LsCapabilityTlvTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test case for TED Capability tlv.
- */
-public class LsCapabilityTlvTest {
-
- private final LsCapabilityTlv tlv1 = LsCapabilityTlv.of(1);
- private final LsCapabilityTlv tlv2 = LsCapabilityTlv.of(1);
- private final LsCapabilityTlv tlv3 = LsCapabilityTlv.of(2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumLinkBandwidthSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumLinkBandwidthSubTlvTest.java
deleted file mode 100644
index 3db22dd..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumLinkBandwidthSubTlvTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the MaximumLinkBandwidthSubTlv.
- */
-public class MaximumLinkBandwidthSubTlvTest {
- private final int rawValue1 = 0x0A;
- private final int rawValue2 = 0x0B;
-
- private final MaximumLinkBandwidthSubTlv tlv1 = new MaximumLinkBandwidthSubTlv(rawValue1);
- private final MaximumLinkBandwidthSubTlv sameAsTlv1 = new MaximumLinkBandwidthSubTlv(rawValue1);
- private final MaximumLinkBandwidthSubTlv tlv2 = MaximumLinkBandwidthSubTlv.of(rawValue2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthSubTlvTest.java
deleted file mode 100644
index af37ac9..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthSubTlvTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the MaximumReservableLinkBandwidthSubTlv.
- */
-public class MaximumReservableLinkBandwidthSubTlvTest {
- private final int rawValue1 = 0x0A;
- private final int rawValue2 = 0x0B;
-
- private final MaximumReservableLinkBandwidthSubTlv tlv1 = new MaximumReservableLinkBandwidthSubTlv(rawValue1);
- private final MaximumReservableLinkBandwidthSubTlv sameAsTlv1 = new MaximumReservableLinkBandwidthSubTlv(rawValue1);
- private final MaximumReservableLinkBandwidthSubTlv tlv2 = MaximumReservableLinkBandwidthSubTlv.of(rawValue2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MplsProtocolMaskSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MplsProtocolMaskSubTlvTest.java
deleted file mode 100644
index 0def410..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MplsProtocolMaskSubTlvTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the MplsProtocolMaskSubTlv.
- */
-public class MplsProtocolMaskSubTlvTest {
- private final byte rawValue1 = 0x0A;
- private final byte rawValue2 = 0x0B;
-
- private final MplsProtocolMaskSubTlv tlv1 = new MplsProtocolMaskSubTlv(rawValue1);
- private final MplsProtocolMaskSubTlv sameAsTlv1 = new MplsProtocolMaskSubTlv(rawValue1);
- private final MplsProtocolMaskSubTlv tlv2 = MplsProtocolMaskSubTlv.of(rawValue2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv4addressTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv4addressTlvTest.java
deleted file mode 100644
index 3b95d77..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv4addressTlvTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Equality test for NexthopIPv4addressTlv.
- */
-public class NexthopIPv4addressTlvTest {
-
- private final NexthopIPv4addressTlv tlv1 = new NexthopIPv4addressTlv(0x0A);
- private final NexthopIPv4addressTlv sameAsTlv1 = new NexthopIPv4addressTlv(0x0A);
- private final NexthopIPv4addressTlv tlv2 = NexthopIPv4addressTlv.of(0x0B);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv6addressTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv6addressTlvTest.java
deleted file mode 100644
index 35e4b00..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv6addressTlvTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Equality test for NexthopIPv6addressTlv.
- */
-public class NexthopIPv6addressTlvTest {
-
- private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00 };
- private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
-
- private final NexthopIPv6addressTlv tlv1 = NexthopIPv6addressTlv.of(b1);
- private final NexthopIPv6addressTlv sameAsTlv1 = NexthopIPv6addressTlv.of(b1);
- private final NexthopIPv6addressTlv tlv2 = NexthopIPv6addressTlv.of(b2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlvTest.java
deleted file mode 100644
index 2fc5fba..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlvTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Equality test for NexthopUnnumberedIPv4IDTlv.
- */
-public class NexthopUnnumberedIPv4IDTlvTest {
-
- private final NexthopUnnumberedIPv4IDTlv tlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A);
- private final NexthopUnnumberedIPv4IDTlv sameAsTlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A);
- private final NexthopUnnumberedIPv4IDTlv tlv2 = NexthopUnnumberedIPv4IDTlv.of(0x0B, 0x0B);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeAttributesTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeAttributesTlvTest.java
deleted file mode 100644
index 5a6fddd..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeAttributesTlvTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Test case for TE Node Attribute tlv.
- */
-public class NodeAttributesTlvTest {
-
- private final NodeFlagBitsSubTlv nodeFlagBitsTlv1 = new NodeFlagBitsSubTlv((byte) 10);
- private final IPv4RouterIdOfLocalNodeSubTlv iPv4TERouterIdOfLocalNodeTlv1 = new
- IPv4RouterIdOfLocalNodeSubTlv(0x01010101);
-
- private final NodeFlagBitsSubTlv nodeFlagBitsTlv2 = new NodeFlagBitsSubTlv((byte) 20);
- private final IPv4RouterIdOfLocalNodeSubTlv iPv4TERouterIdOfLocalNodeTlv2 = new
- IPv4RouterIdOfLocalNodeSubTlv(0x02020202);
-
- private final List<PcepValueType> llNodeAttributesSubTLV1 = new LinkedList<>();
- private final boolean a = llNodeAttributesSubTLV1.add(nodeFlagBitsTlv1);
- private final boolean b = llNodeAttributesSubTLV1.add(iPv4TERouterIdOfLocalNodeTlv1);
-
- private final List<PcepValueType> llNodeAttributesSubTLV2 = new LinkedList<>();
-
- private final boolean c = llNodeAttributesSubTLV2.add(nodeFlagBitsTlv2);
- private final boolean d = llNodeAttributesSubTLV2.add(iPv4TERouterIdOfLocalNodeTlv2);
-
- private final NodeAttributesTlv tlv1 = NodeAttributesTlv.of(llNodeAttributesSubTLV1);
- private final NodeAttributesTlv sameAsTlv1 = NodeAttributesTlv.of(llNodeAttributesSubTLV1);
- private final NodeAttributesTlv tlv2 = NodeAttributesTlv.of(llNodeAttributesSubTLV2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeFlagBitsSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeFlagBitsSubTlvTest.java
deleted file mode 100644
index 7c186eb..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeFlagBitsSubTlvTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the NodeFlagBitsSubTlv.
- */
-public class NodeFlagBitsSubTlvTest {
- private final byte rawValue1 = 0x0A;
- private final byte rawValue2 = 0x0B;
-
- private final NodeFlagBitsSubTlv tlv1 = new NodeFlagBitsSubTlv(rawValue1);
- private final NodeFlagBitsSubTlv sameAsTlv1 = new NodeFlagBitsSubTlv(rawValue1);
- private final NodeFlagBitsSubTlv tlv2 = NodeFlagBitsSubTlv.of(rawValue2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeNameSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeNameSubTlvTest.java
deleted file mode 100644
index e4e468c..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeNameSubTlvTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the NodeNameSubTlv.
- */
-public class NodeNameSubTlvTest {
- private final byte[] rawValue1 = new byte[] {0x01, 0x02};
- private final byte[] rawValue2 = new byte[] {0x14, 0x15};
-
- private final NodeNameSubTlv tlv1 = new NodeNameSubTlv(rawValue1, (short) rawValue1.length);
- private final NodeNameSubTlv sameAsTlv1 = NodeNameSubTlv.of(tlv1.getValue(), tlv1.getLength());
- private final NodeNameSubTlv tlv2 = new NodeNameSubTlv(rawValue2, (short) 0);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OpaqueLinkAttributeSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OpaqueLinkAttributeSubTlvTest.java
deleted file mode 100644
index b2036a9..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OpaqueLinkAttributeSubTlvTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the OpaqueLinkAttributeSubTlv.
- */
-public class OpaqueLinkAttributeSubTlvTest {
- private final byte[] rawValue1 = new byte[] {0x01, 0x02};
- private final byte[] rawValue2 = new byte[] {0x14, 0x15};
-
- private final OpaqueLinkAttributeSubTlv tlv1 =
- new OpaqueLinkAttributeSubTlv(rawValue1, (short) rawValue1.length);
- private final OpaqueLinkAttributeSubTlv sameAsTlv1 =
- OpaqueLinkAttributeSubTlv.of(tlv1.getValue(), tlv1.getLength());
- private final OpaqueLinkAttributeSubTlv tlv2 = new OpaqueLinkAttributeSubTlv(rawValue2, (short) 0);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OspfAreaIdSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OspfAreaIdSubTlvTest.java
deleted file mode 100644
index 609b337..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OspfAreaIdSubTlvTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the OspfAreaIdSubTlv.
- */
-public class OspfAreaIdSubTlvTest {
- private final int rawValue1 = 0x0A;
-
- private final OspfAreaIdSubTlv tlv1 = new OspfAreaIdSubTlv(rawValue1);
- private final OspfAreaIdSubTlv tlv2 = OspfAreaIdSubTlv.of(tlv1.getInt());
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathKeySubObjectTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathKeySubObjectTest.java
deleted file mode 100644
index 22a2ffb..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathKeySubObjectTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the PathKeySubObject.
- */
-public class PathKeySubObjectTest {
-
- private final PathKeySubObject tlv1 = new PathKeySubObject((short) 0x0A, 0x0A);
- private final PathKeySubObject sameAsTlv1 = PathKeySubObject.of((short) 0x0A, 0x0A);
- private final PathKeySubObject tlv2 = new PathKeySubObject((short) 0x0B, 0x0B);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathSetupTypeTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathSetupTypeTlvTest.java
deleted file mode 100644
index 452a1c6..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathSetupTypeTlvTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the PathSetupTypeTlv.
- */
-public class PathSetupTypeTlvTest {
-
- private final PathSetupTypeTlv tlv1 = PathSetupTypeTlv.of(0x0A);
- private final PathSetupTypeTlv sameAsTlv1 = PathSetupTypeTlv.of(0x0A);
- private final PathSetupTypeTlv tlv2 = PathSetupTypeTlv.of(0x0B);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PceccCapabilityTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PceccCapabilityTlvTest.java
deleted file mode 100644
index 9a61e7c..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PceccCapabilityTlvTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test of the PceccCapabilityTlv.
- */
-public class PceccCapabilityTlvTest {
- private final int rawValue1 = 0x0A;
- private final int rawValue2 = 0x0B;
-
- private final PceccCapabilityTlv tlv1 = new PceccCapabilityTlv(rawValue1);
- private final PceccCapabilityTlv sameAsTlv1 = new PceccCapabilityTlv(rawValue1);
- private final PceccCapabilityTlv tlv2 = PceccCapabilityTlv.of(rawValue2);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, sameAsTlv1)
- .addEqualityGroup(tlv2)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4AdjacencyTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4AdjacencyTest.java
deleted file mode 100644
index b89805e..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4AdjacencyTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Equality test for PcepNaiIpv4Adjacency.
- */
-public class PcepNaiIpv4AdjacencyTest {
-
- private final PcepNaiIpv4Adjacency obj1 = PcepNaiIpv4Adjacency.of(2, 16);
- private final PcepNaiIpv4Adjacency sameAsObj1 = PcepNaiIpv4Adjacency.of(2, 16);
- private final PcepNaiIpv4Adjacency obj2 = PcepNaiIpv4Adjacency.of(3, 16);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(obj1, sameAsObj1).addEqualityGroup(obj2).testEquals();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeIdTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeIdTest.java
deleted file mode 100644
index 93f61d4..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeIdTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-public class PcepNaiIpv4NodeIdTest {
-
- private final PcepNaiIpv4NodeId tlv1 = PcepNaiIpv4NodeId.of(1);
- private final PcepNaiIpv4NodeId tlv2 = PcepNaiIpv4NodeId.of(1);
- private final PcepNaiIpv4NodeId tlv3 = PcepNaiIpv4NodeId.of(3);
-
- @Test
- public void basics() {
- new EqualsTester()
- .addEqualityGroup(tlv1, tlv2)
- .addEqualityGroup(tlv3)
- .testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6AdjacencyTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6AdjacencyTest.java
deleted file mode 100644
index 7c1fbb5..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6AdjacencyTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-public class PcepNaiIpv6AdjacencyTest {
- private final byte[] localIpv6Addr1 = {(byte) 0x01010101 };
- private final byte[] remoteIpv6Addr1 = {(byte) 0x02020202 };
- private final byte[] localIpv6Addr2 = {(byte) 0x01010101 };
- private final byte[] remoteIpv6Addr2 = {(byte) 0x02020202 };
- private final byte[] localIpv6Addr3 = {(byte) 0x05050505 };
- private final byte[] remoteIpv6Addr3 = {(byte) 0x06060606 };
-
- private final PcepNaiIpv6Adjacency tlv1 = PcepNaiIpv6Adjacency.of(localIpv6Addr1, remoteIpv6Addr1);
- private final PcepNaiIpv6Adjacency tlv2 = PcepNaiIpv6Adjacency.of(localIpv6Addr1, remoteIpv6Addr1);
- private final PcepNaiIpv6Adjacency tlv3 = PcepNaiIpv6Adjacency.of(localIpv6Addr3, remoteIpv6Addr3);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeIdTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeIdTest.java
deleted file mode 100644
index ed10201..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeIdTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Equality test for PcepNaiIpv6NodeId.
- */
-public class PcepNaiIpv6NodeIdTest {
-
- private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02,
- 0x00, 0x00 };
- private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
- (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02,
- 0x00, 0x00 };
-
- private final PcepNaiIpv6NodeId tlv1 = PcepNaiIpv6NodeId.of(b1);
- private final PcepNaiIpv6NodeId sameAsTlv1 = PcepNaiIpv6NodeId.of(b1);
- private final PcepNaiIpv6NodeId tlv2 = PcepNaiIpv6NodeId.of(b2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4Test.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4Test.java
deleted file mode 100644
index d2d0532..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4Test.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-public class PcepNaiUnnumberedAdjacencyIpv4Test {
-
- private final int localNodeId1 = 1;
- private final int localInterfaceId1 = 1;
- private final int remoteNodeId1 = 1;
- private final int remoteInterfaceId1 = 1;
- private final PcepNaiUnnumberedAdjacencyIpv4 tlv1 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId1,
- localInterfaceId1, remoteNodeId1, remoteInterfaceId1);
-
- private final int localNodeId2 = 1;
- private final int localInterfaceId2 = 1;
- private final int remoteNodeId2 = 1;
- private final int remoteInterfaceId2 = 1;
- private final PcepNaiUnnumberedAdjacencyIpv4 tlv2 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId2,
- localInterfaceId2, remoteNodeId2, remoteInterfaceId2);
-
- private final int localNodeId3 = 2;
- private final int localInterfaceId3 = 2;
- private final int remoteNodeId3 = 2;
- private final int remoteInterfaceId3 = 2;
-
- private final PcepNaiUnnumberedAdjacencyIpv4 tlv3 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId3,
- localInterfaceId3, remoteNodeId3, remoteInterfaceId3);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RemoteNodeDescriptorsTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RemoteNodeDescriptorsTlvTest.java
deleted file mode 100644
index def98e7..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RemoteNodeDescriptorsTlvTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Test case for Remote TE Node Descriptors tlv.
- */
-public class RemoteNodeDescriptorsTlvTest {
-
- private final AutonomousSystemSubTlv autonomousSystemTlv1 = new AutonomousSystemSubTlv(10);
- private final BgpLsIdentifierSubTlv bGPLSidentifierTlv1 = new BgpLsIdentifierSubTlv(20);
-
- private final AutonomousSystemSubTlv autonomousSystemTlv2 = new AutonomousSystemSubTlv(20);
- private final BgpLsIdentifierSubTlv bGPLSidentifierTlv2 = new BgpLsIdentifierSubTlv(30);
-
- private final List<PcepValueType> llRemoteTENodeDescriptorSubTLV1 = new LinkedList<>();
- private final boolean a = llRemoteTENodeDescriptorSubTLV1.add(autonomousSystemTlv1);
- private final boolean b = llRemoteTENodeDescriptorSubTLV1.add(bGPLSidentifierTlv1);
-
- private final List<PcepValueType> llRemoteTENodeDescriptorSubTLV2 = new LinkedList<>();
- private final boolean c = llRemoteTENodeDescriptorSubTLV2.add(autonomousSystemTlv2);
- private final boolean d = llRemoteTENodeDescriptorSubTLV2.add(bGPLSidentifierTlv2);
-
- private final RemoteNodeDescriptorsTlv tlv1 = RemoteNodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV1);
- private final RemoteNodeDescriptorsTlv sameAsTlv1 =
- RemoteNodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV1);
- private final RemoteNodeDescriptorsTlv tlv2 = RemoteNodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RoutingUniverseTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RoutingUniverseTlvTest.java
deleted file mode 100644
index d488c4f..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RoutingUniverseTlvTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Equality test for RoutingUniverseTlv.
- */
-public class RoutingUniverseTlvTest {
-
- private final RoutingUniverseTlv tlv1 = RoutingUniverseTlv.of(2);
- private final RoutingUniverseTlv tlv2 = RoutingUniverseTlv.of(2);
- private final RoutingUniverseTlv tlv3 = RoutingUniverseTlv.of(3);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SharedRiskLinkGroupSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SharedRiskLinkGroupSubTlvTest.java
deleted file mode 100644
index 480e49f..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SharedRiskLinkGroupSubTlvTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test case for SharedRiskLinkGroupSubTlv.
- */
-public class SharedRiskLinkGroupSubTlvTest {
-
- private final int[] raw = {1 };
- private final Short hLength = 2;
- private final SharedRiskLinkGroupSubTlv tlv1 = SharedRiskLinkGroupSubTlv.of(raw, hLength);
-
- private final SharedRiskLinkGroupSubTlv sameAsTlv1 = SharedRiskLinkGroupSubTlv.of(raw, hLength);
-
- private final int[] raw2 = {2 };
- private final Short hLength2 = 3;
- private final SharedRiskLinkGroupSubTlv tlv2 = SharedRiskLinkGroupSubTlv.of(raw2, hLength2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SrEroSubObjectTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SrEroSubObjectTest.java
deleted file mode 100644
index 7dac675..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SrEroSubObjectTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-import org.onosproject.pcepio.protocol.PcepNai;
-
-public class SrEroSubObjectTest {
-
- private final boolean bFFlag = false;
- private final boolean bSFlag = false;
- private final boolean bCFlag = false;
- private final boolean bMFlag = false;
- private final byte st = 1;
- private final int sID = 1;
- private final PcepNai nai = null;
-
- private final SrEroSubObject tlv1 = SrEroSubObject.of(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
-
- private final boolean bFFlag1 = false;
- private final boolean bSFlag1 = false;
- private final boolean bCFlag1 = false;
- private final boolean bMFlag1 = false;
- private final byte st1 = 1;
- private final int sID1 = 1;
- private final PcepNai nai1 = null;
-
- private final SrEroSubObject tlv2 = SrEroSubObject.of(st1, bFFlag1, bSFlag1, bCFlag1, bMFlag1, sID1, nai1);
-
- private final boolean bFFlag2 = true;
- private final boolean bSFlag2 = true;
- private final boolean bCFlag2 = true;
- private final boolean bMFlag2 = true;
- private final byte st2 = 2;
- private final int sID2 = 2;
- private final PcepNai nai2 = null;
-
- private final SrEroSubObject tlv3 = SrEroSubObject.of(st2, bFFlag2, bSFlag2, bCFlag2, bMFlag2, sID2, nai2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentifiersTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentifiersTlvTest.java
deleted file mode 100644
index a8d527f..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentifiersTlvTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Tests class StatefulIPv4LspIdentifiersTlv.
- */
-public class StatefulIPv4LspIdentifiersTlvTest {
-
- private final int ipv4IngressAddress = 1;
- private final short lspId = 1;
- private final short tunnelId = 1;
- private final int extendedTunnelId = 1;
- private final int ipv4EgressAddress = 1;
-
- private final StatefulIPv4LspIdentifiersTlv tlv1 = StatefulIPv4LspIdentifiersTlv.of(ipv4IngressAddress, lspId,
- tunnelId, extendedTunnelId, ipv4EgressAddress);
-
- private final int ipv4IngressAddress1 = 1;
- private final short lspId1 = 1;
- private final short tunnelId1 = 1;
- private final int extendedTunnelId1 = 1;
- private final int ipv4EgressAddress1 = 1;
-
- private final StatefulIPv4LspIdentifiersTlv tlv2 = StatefulIPv4LspIdentifiersTlv.of(ipv4IngressAddress1, lspId1,
- tunnelId1, extendedTunnelId1, ipv4EgressAddress1);
-
- private final int ipv4IngressAddress2 = 2;
- private final short lspId2 = 2;
- private final short tunnelId2 = 2;
- private final int extendedTunnelId2 = 2;
- private final int ipv4EgressAddress2 = 2;
-
- private final StatefulIPv4LspIdentifiersTlv tlv3 = StatefulIPv4LspIdentifiersTlv.of(ipv4IngressAddress2, lspId2,
- tunnelId2, extendedTunnelId2, ipv4EgressAddress2);
-
- /**
- * Tests equality of objects of class StatefulIPv4LspIdentifiersTlv.
- */
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
-
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspDbVerTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspDbVerTlvTest.java
deleted file mode 100644
index 5d3d0d6..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspDbVerTlvTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test case for Stateful Lsp Db Ver tlv.
- */
-public class StatefulLspDbVerTlvTest {
-
- private final StatefulLspDbVerTlv tlv1 = StatefulLspDbVerTlv.of(1);
- private final StatefulLspDbVerTlv tlv2 = StatefulLspDbVerTlv.of(1);
- private final StatefulLspDbVerTlv tlv3 = StatefulLspDbVerTlv.of(2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlvTest.java
deleted file mode 100644
index 54408de..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlvTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-public class StatefulLspErrorCodeTlvTest {
-
- private final StatefulLspErrorCodeTlv tlv1 = StatefulLspErrorCodeTlv.of(1);
- private final StatefulLspErrorCodeTlv tlv2 = StatefulLspErrorCodeTlv.of(1);
- private final StatefulLspErrorCodeTlv tlv3 = StatefulLspErrorCodeTlv.of(2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlvTest.java
deleted file mode 100644
index 69b31e7..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlvTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test case for Stateful Pce Capability tlv.
- */
-public class StatefulPceCapabilityTlvTest {
-
- private final StatefulPceCapabilityTlv tlv1 = StatefulPceCapabilityTlv.of(1);
- private final StatefulPceCapabilityTlv tlv2 = StatefulPceCapabilityTlv.of(1);
- private final StatefulPceCapabilityTlv tlv3 = StatefulPceCapabilityTlv.of(2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SymbolicPathNameTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SymbolicPathNameTlvTest.java
deleted file mode 100644
index 33e1a8c..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SymbolicPathNameTlvTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test case for Symbolic path tlv.
- */
-public class SymbolicPathNameTlvTest {
-
- private final byte[] value1 = {0x41 };
- private final Short length1 = 2;
- private final SymbolicPathNameTlv tlv1 = SymbolicPathNameTlv.of(value1, length1);
-
- private final byte[] value2 = {0x41 };
- private final Short length2 = 2;
- private final SymbolicPathNameTlv tlv2 = SymbolicPathNameTlv.of(value1, length2);
-
- private final byte[] value3 = {0x41, 0x43 };
- private final Short length3 = 3;
- private final SymbolicPathNameTlv tlv3 = SymbolicPathNameTlv.of(value3, length3);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
- }
-
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TEDefaultMetricSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TEDefaultMetricSubTlvTest.java
deleted file mode 100644
index 5c5256b..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TEDefaultMetricSubTlvTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Test case for TEDefaultMetricSubTlv.
- */
-public class TEDefaultMetricSubTlvTest {
-
- private final TEDefaultMetricSubTlv tlv1 = TEDefaultMetricSubTlv.of(1);
- private final TEDefaultMetricSubTlv tlv2 = TEDefaultMetricSubTlv.of(1);
- private final TEDefaultMetricSubTlv tlv3 = TEDefaultMetricSubTlv.of(2);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
- }
-}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/UnreservedBandwidthSubTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/UnreservedBandwidthSubTlvTest.java
deleted file mode 100644
index 9543001..0000000
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/UnreservedBandwidthSubTlvTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcepio.types;
-
-import com.google.common.testing.EqualsTester;
-import org.junit.Test;
-
-/**
- * Unit Test case for UnreservedBandwidthSubTlv.
- */
-public class UnreservedBandwidthSubTlvTest {
-
- // Objects of unreserved bandwidth tlv
- private final UnreservedBandwidthSubTlv tlv1 = UnreservedBandwidthSubTlv.of(100);
- private final UnreservedBandwidthSubTlv tlv2 = UnreservedBandwidthSubTlv.of(100);
- private final UnreservedBandwidthSubTlv tlv3 = UnreservedBandwidthSubTlv.of(200);
-
- @Test
- public void basics() {
- new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
- }
-
-}
diff --git a/protocols/pcep/server/BUILD b/protocols/pcep/server/BUILD
deleted file mode 100644
index c8b744d..0000000
--- a/protocols/pcep/server/BUILD
+++ /dev/null
@@ -1,11 +0,0 @@
-BUNDLES = [
- "//protocols/pcep/server/api:onos-protocols-pcep-server-api",
- "//protocols/pcep/server/ctl:onos-protocols-pcep-server-ctl",
-]
-
-onos_app(
- category = "Utility",
- included_bundles = BUNDLES,
- title = "PCEP Server Module",
- url = "http://onosproject.org",
-)
diff --git a/protocols/pcep/server/api/BUILD b/protocols/pcep/server/api/BUILD
deleted file mode 100644
index 0826d45..0000000
--- a/protocols/pcep/server/api/BUILD
+++ /dev/null
@@ -1,10 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + [
- "@io_netty_netty//jar",
- "//apps/tunnel/api:onos-apps-tunnel-api",
- "//protocols/pcep/pcepio:onos-protocols-pcep-pcepio",
- "//apps/pcep-api:onos-apps-pcep-api",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/ClientCapability.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/ClientCapability.java
deleted file mode 100644
index 2a6c71a..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/ClientCapability.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-import java.util.Objects;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Representation of capabilities supported by client.
- */
-public class ClientCapability {
- private boolean pceccCapability;
- private boolean statefulPceCapability;
- private boolean pcInstantiationCapability;
- private boolean labelStackCapability;
- private boolean srCapability;
-
- /**
- * Creates new instance of client capability.
- *
- * @param pceccCapability represents PCECC capability
- * @param statefulPceCapability represents stateful PCE capability
- * @param pcInstantiationCapability represents PC initiation capability
- * @param labelStackCapability represents S bit is set in PCECC capability
- * @param srCapability represents SR capability
- */
- public ClientCapability(boolean pceccCapability, boolean statefulPceCapability, boolean pcInstantiationCapability,
- boolean labelStackCapability, boolean srCapability) {
- this.pceccCapability = pceccCapability;
- this.statefulPceCapability = statefulPceCapability;
- this.pcInstantiationCapability = pcInstantiationCapability;
- this.labelStackCapability = labelStackCapability;
- this.srCapability = srCapability;
- }
-
- /**
- * Obtains label stack capability.
- *
- * @return true if client supports PCECC capability with S bit set otherwise false
- */
- public boolean labelStackCapability() {
- return labelStackCapability;
- }
-
- /**
- * Obtains segment routing capability.
- *
- * @return true if client supports SR capability otherwise false
- */
- public boolean srCapability() {
- return srCapability;
- }
-
- /**
- * Obtains PCECC capability.
- *
- * @return true if client supports PCECC capability otherwise false
- */
- public boolean pceccCapability() {
- return pceccCapability;
- }
-
- /**
- * Obtains stateful PCE capability.
- *
- * @return true if client supports stateful PCE capability otherwise false
- */
- public boolean statefulPceCapability() {
- return statefulPceCapability;
- }
-
- /**
- * Obtains PC initiation capability.
- *
- * @return true if client supports PC initiation capability otherwise false
- */
- public boolean pcInstantiationCapability() {
- return pcInstantiationCapability;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(pceccCapability, statefulPceCapability, pcInstantiationCapability, labelStackCapability,
- srCapability);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof ClientCapability) {
- ClientCapability other = (ClientCapability) obj;
- return Objects.equals(pceccCapability, other.pceccCapability)
- && Objects.equals(statefulPceCapability, other.statefulPceCapability)
- && Objects.equals(pcInstantiationCapability, other.pcInstantiationCapability)
- && Objects.equals(labelStackCapability, other.labelStackCapability)
- && Objects.equals(srCapability, other.srCapability);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("pceccCapability", pceccCapability)
- .add("statefulPceCapability", statefulPceCapability)
- .add("pcInstantiationCapability", pcInstantiationCapability)
- .add("labelStackCapability", labelStackCapability)
- .add("srCapability", srCapability)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/LspKey.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/LspKey.java
deleted file mode 100644
index 2cba240..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/LspKey.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-import java.util.Objects;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Representation of LSP info, it will be unique for each LSP.
- */
-public class LspKey {
- private int plspId;
- private short localLspId;
-
- /**
- * Creates new instance of LspInfo.
- *
- * @param plspId LSP id assigned per tunnel per session
- * @param localLspId LSP id assigned per tunnel
- */
- public LspKey(int plspId, short localLspId) {
- this.plspId = plspId;
- this.localLspId = localLspId;
- }
-
- /**
- * Obtains PLSP id.
- *
- * @return LSP id assigned per tunnel per session
- */
- public int plspId() {
- return plspId;
- }
-
- /**
- * Obtains local LSP id.
- *
- * @return LSP id assigned per tunnel
- */
- public short localLspId() {
- return localLspId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(plspId, localLspId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof LspKey) {
- LspKey other = (LspKey) obj;
- return Objects.equals(plspId, other.plspId)
- && Objects.equals(localLspId, other.localLspId);
- }
-
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("plspId", plspId)
- .add("localLspId", localLspId)
- .toString();
- }
-}
\ No newline at end of file
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/LspType.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/LspType.java
deleted file mode 100644
index 6cfcd37..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/LspType.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcep.server;
-
-/**
- * Representation of LSP type.
- */
-public enum LspType {
- /**
- * Signifies that path is created via signaling mode.
- */
- WITH_SIGNALLING(0),
-
- /**
- * Signifies that path is created via SR mode.
- */
- SR_WITHOUT_SIGNALLING(1),
-
- /**
- * Signifies that path is created via without signaling and without SR mode.
- */
- WITHOUT_SIGNALLING_AND_WITHOUT_SR(2);
-
- int value;
-
- /**
- * Assign val with the value as the LSP type.
- *
- * @param val LSP type
- */
- LspType(int val) {
- value = val;
- }
-
- /**
- * Returns value of LSP type.
- *
- * @return LSP type
- */
- public byte type() {
- return (byte) value;
- }
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PccId.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PccId.java
deleted file mode 100644
index 9fdd605..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PccId.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.util.Identifier;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-/**
- * The class representing a network client pc ip.
- * This class is immutable.
- */
-public final class PccId extends Identifier<IpAddress> {
-
- private static final String SCHEME = "l3";
- private static final long UNKNOWN = 0;
-
- /**
- * Private constructor.
- */
- private PccId(IpAddress ipAddress) {
- super(ipAddress);
- }
-
- /**
- * Create a PccId from ip address.
- *
- * @param ipAddress IP address
- * @return ipAddress
- */
- public static PccId pccId(IpAddress ipAddress) {
- return new PccId(ipAddress);
- }
-
- /**
- * Returns the ip address.
- *
- * @return ipAddress
- */
- public IpAddress ipAddress() {
- return identifier;
- }
-
- /**
- * Returns PccId created from the given client URI.
- *
- * @param uri device URI
- * @return pccid
- */
- public static PccId pccid(URI uri) {
- checkArgument(uri.getScheme().equals(SCHEME), "Unsupported URI scheme");
- return new PccId(IpAddress.valueOf(uri.getSchemeSpecificPart()));
- }
-
- /**
- * Produces client URI from the given DPID.
- *
- * @param pccid client pccid
- * @return client URI
- */
- public static URI uri(PccId pccid) {
- return uri(pccid.ipAddress());
- }
-
- /**
- * Produces client URI from the given ip address.
- *
- * @param ipAddress ip of client
- * @return client URI
- */
- public static URI uri(IpAddress ipAddress) {
- try {
- return new URI(SCHEME, ipAddress.toString(), null);
- } catch (URISyntaxException e) {
- return null;
- }
- }
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepAnnotationKeys.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepAnnotationKeys.java
deleted file mode 100644
index bdcd35a..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepAnnotationKeys.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-/**
- * Collection of keys for annotation for PCEP tunnels.
- */
-public final class PcepAnnotationKeys {
-
- /**
- * Prohibits instantiation.
- */
- private PcepAnnotationKeys() {
- }
-
- /**
- * Annotation key for bandwidth.
- * The value for this key is interpreted as Mbps.
- */
- public static final String BANDWIDTH = "bandwidth";
-
- /**
- * Annotation key for the LSP signaling type.
- */
- public static final String LSP_SIG_TYPE = "lspSigType";
-
- /**
- * Annotation key for the PCC tunnel id.
- */
- public static final String PCC_TUNNEL_ID = "PccTunnelId";
-
- /**
- * Annotation key for the LSP id assigned per tunnel per session.
- */
- public static final String PLSP_ID = "PLspId";
-
- /**
- * Annotation key for the LSP id assigned per tunnel.
- */
- public static final String LOCAL_LSP_ID = "localLspId";
-
- /**
- * Annotation key for the identification of initiated LSP.
- */
- public static final String PCE_INIT = "pceInit";
-
- /**
- * Annotation key for the cost type.
- */
- public static final String COST_TYPE = "costType";
-
- /**
- * Annotation key for the Delegation.
- * Whether LSPs are delegated or not
- */
- public static final String DELEGATE = "delegate";
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepCfg.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepCfg.java
deleted file mode 100644
index af5debf..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepCfg.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcep.server;
-
-/**
- * PCEP peer state information.
- */
-
-public interface PcepCfg {
-
- State getState();
-
- void setState(State state);
-
- enum State {
- /**
- * Signifies that its just created.
- */
- INIT,
-
- /**
- * Signifies that only IP Address is configured.
- */
- OPENWAIT,
-
- /**
- * Signifies that only Autonomous System is configured.
- */
- KEEPWAIT,
-
- /**
- * Signifies that both IP and Autonomous System is configured.
- */
- ESTABLISHED,
-
- /**
- * Signifies that both IP and Autonomous System is down.
- */
- DOWN
- }
-
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClient.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClient.java
deleted file mode 100644
index cace76a..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClient.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-import java.util.List;
-
-import org.onosproject.pcepio.protocol.PcepFactory;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepStateReport;
-
-/**
- * Represents to provider facing side of a path computation client(pcc).
- */
-public interface PcepClient {
-
- /**
- * Writes the message to the driver.
- *
- * @param msg the message to write
- */
- void sendMessage(PcepMessage msg);
-
- /**
- * Writes the PcepMessage list to the driver.
- *
- * @param msgs the messages to be written
- */
- void sendMessage(List<PcepMessage> msgs);
-
- /**
- * Handle a message from the pcc.
- *
- * @param fromClient the message to handle
- */
- void handleMessage(PcepMessage fromClient);
-
- /**
- * Provides the factory for this PCEP version.
- *
- * @return PCEP version specific factory.
- */
- PcepFactory factory();
-
- /**
- * Gets a string version of the ID for this pcc.
- *
- * @return string version of the ID
- */
- String getStringId();
-
- /**
- * Gets the ipAddress of the client.
- *
- * @return the client pccId in IPAddress format
- */
- PccId getPccId();
-
- /**
- * Checks if the pcc is still connected.
- *
- * @return true if client is connected, false otherwise
- */
- boolean isConnected();
-
- /**
- * Disconnects the pcc by closing the TCP connection. Results in a call
- * to the channel handler's channelDisconnected method for cleanup.
- */
- void disconnectClient();
-
- /**
- * Indicates if this pcc is optical.
- *
- * @return true if optical
- */
- boolean isOptical();
-
- /**
- * Identifies the channel used to communicate with the pcc.
- *
- * @return string representation of the connection to the client
- */
- String channelId();
-
- /**
- * Sets the status of LSP state synchronization.
- *
- * @param syncStatus LSP synchronization status to be set
- */
- void setLspDbSyncStatus(PcepSyncStatus syncStatus);
-
- /**
- * Indicates the LSP state synchronization status of this pcc.
- *
- * @return LSP state synchronization status.
- */
- PcepSyncStatus lspDbSyncStatus();
-
- /**
- * Sets the status of label DB synchronization.
- *
- * @param syncStatus label DB synchronization status to be set
- */
- void setLabelDbSyncStatus(PcepSyncStatus syncStatus);
-
- /**
- * Indicates the label DB synchronization status of this pcc.
- *
- * @return label DB synchronization status.
- */
- PcepSyncStatus labelDbSyncStatus();
-
- /**
- * Sets capability negotiated during open message exchange.
- *
- * @param capability supported by client
- */
- void setCapability(ClientCapability capability);
-
- /**
- * Obtains capability supported by client.
- *
- * @return capability supported by client
- */
- ClientCapability capability();
-
- /**
- * Adds PCEP device when session is successfully established.
- *
- * @param pc PCEP client details
- */
- void addNode(PcepClient pc);
-
- /**
- * Removes PCEP device when session is disconnected.
- *
- * @param pccId PCEP client ID
- */
- void deleteNode(PccId pccId);
-
- /**
- * Sets D flag for the given LSP and its LSP info.
- *
- * @param lspKey contains LSP info
- * @param dFlag delegation flag in LSP object
- */
- void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag);
-
- /**
- * Returns delegation flag for the given LSP info.
- *
- * @param lspKey contains LSP info
- * @return delegation flag
- */
- Boolean delegationInfo(LspKey lspKey);
-
- /**
- * Creates a temporary cache to hold report messages received during LSPDB sync.
- *
- * @param pccId PCC id which is the key to store report messages
- */
- void initializeSyncMsgList(PccId pccId);
-
- /**
- * Returns the list of report messages received during LSPDB sync.
- *
- * @param pccId PCC id which is the key for all the report messages
- * @return list of report messages received during LSPDB sync
- */
- List<PcepStateReport> getSyncMsgList(PccId pccId);
-
- /**
- * Removes the list of report messages received during LSPDB sync.
- *
- * @param pccId PCC id which is the key for all the report messages
- */
- void removeSyncMsgList(PccId pccId);
-
- /**
- * Adds report message received during LSPDB sync into temporary cache.
- *
- * @param pccId PCC id which is the key to store report messages
- * @param rptMsg the report message to be stored
- */
- void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg);
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClientController.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClientController.java
deleted file mode 100644
index 226944e..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClientController.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
-import org.onosproject.incubator.net.tunnel.LabelStack;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.net.Path;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.types.PcepValueType;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Abstraction of an Pcep client controller. Serves as a one stop
- * shop for obtaining Pcep devices and (un)register listeners
- * on pcep events
- */
-public interface PcepClientController {
-
- /**
- * Returns list of pcc clients connected to this Pcep controller.
- *
- * @return list of PcepClient elements
- */
- Collection<PcepClient> getClients();
-
- /**
- * Returns the actual pcc client for the given ip address.
- *
- * @param pccId the id of the pcc client to fetch
- * @return the interface to this pcc client
- */
- PcepClient getClient(PccId pccId);
-
- /**
- * Register a listener for meta events that occur to pcep
- * devices.
- *
- * @param listener the listener to notify
- */
- void addListener(PcepClientListener listener);
-
- /**
- * Unregister a listener.
- *
- * @param listener the listener to unregister
- */
- void removeListener(PcepClientListener listener);
-
- /**
- * Register a listener for PCEP msg events.
- *
- * @param listener the listener to notify
- */
- void addEventListener(PcepEventListener listener);
-
- /**
- * Unregister a listener.
- *
- * @param listener the listener to unregister
- */
- void removeEventListener(PcepEventListener listener);
-
- /**
- * Register a listener for PCEP msg events[carrying node descriptor details].
- *
- * @param listener the listener to notify
- */
- void addNodeListener(PcepNodeListener listener);
-
- /**
- * Unregister a listener.
- *
- * @param listener the listener to be unregistered
- */
- void removeNodeListener(PcepNodeListener listener);
-
- /**
- * Send a message to a particular pcc client.
- *
- * @param pccId the id of the client to send message.
- * @param msg the message to send
- */
- void writeMessage(PccId pccId, PcepMessage msg);
-
- /**
- * Process a message and notify the appropriate listeners.
- *
- * @param pccId id of the client the message arrived on
- * @param msg the message to process.
- */
- void processClientMessage(PccId pccId, PcepMessage msg);
-
- /**
- * Close all connected PCC clients.
- */
- void closeConnectedClients();
-
- /**
- * Create label stack from the given path.
- *
- * @param path from which label stack is to be computed
- * @return the label stack
- */
- public LabelStack computeLabelStack(Path path);
-
- /**
- * Allocates and downloads local labels for the given LSP.
- *
- * @param tunnel for which local labels have to be assigned and downloaded
- * @return success or failure
- */
- public boolean allocateLocalLabel(Tunnel tunnel);
-
- /**
- * Creates label stack for ERO object from network resource.
- *
- * @param labelStack label stack
- * @param path (hop list)
- * @return list of ERO sub-objects
- */
- public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path);
-
- /**
- * Returns list of PCEP exceptions.
- *
- * @return PcepExceptions
- */
- public Map<String, List<String>> getPcepExceptions();
-
- /**
- * Returns all the pcep error messages received .
- *
- * @return PcepErrorMsg
- */
- public Map<Integer, Integer> getPcepErrorMsg();
-
- /**
- * Returns the pcep session details.
- *
- * @return PcepSession
- */
- public Map<String, String> getPcepSessionMap();
-
- /**
- * Returns the pcep sessionid information.
- *
- * @return PcepSessionId
- */
- public Map<String, Byte> getPcepSessionIdMap();
-
- /**
- * Creates detailed information about pcep error value and type per peer.
- *
- * @param peerId id of the peer which sent the error message
- * @param errorType the error type of the error message received
- * @param errValue the error value of the error message received
- */
- void peerErrorMsg(String peerId, Integer errorType, Integer errValue);
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClientListener.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClientListener.java
deleted file mode 100644
index 5a0d5bc..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepClientListener.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-/**
- * Allows for providers interested in PCC client events to be notified.
- */
-public interface PcepClientListener {
-
- /**
- * Notify that the PCC was connected.
- *
- * @param pccId the id of the client that connected
- */
- void clientConnected(PccId pccId);
-
- /**
- * Notify that the PCC was disconnected.
- *
- * @param pccId the id of the client that disconnected.
- */
- void clientDisconnected(PccId pccId);
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepErrorDetail.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepErrorDetail.java
deleted file mode 100644
index 37ea6d0..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepErrorDetail.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * PCEP error message details.
- */
-public class PcepErrorDetail {
-
- private Map<Integer, String> sessionEstablishmentFailureMap = new TreeMap<>();
- private Map<Integer, String> unknownObjectMap = new TreeMap<>();
- private Map<Integer, String> notSupportedObjectMap = new TreeMap<>();
- private Map<Integer, String> policyViolationMap = new TreeMap<>();
- private Map<Integer, String> mandatoryObjectMissingMap = new TreeMap<>();
- private Map<Integer, String> receptionOfInvalidObjectMap = new TreeMap<>();
- private Map<Integer, String> invalidOperationMap = new TreeMap<>();
-
-
- public Map sessionEstablishmentFailure() {
- sessionEstablishmentFailureMap.put(1, "Reception of an invalid Open message or a non Open message.");
- sessionEstablishmentFailureMap.put(2, "no Open message received before the expiration of the OpenWait timer");
- sessionEstablishmentFailureMap.put(3, "unacceptable and non-negotiable session characteristics");
- sessionEstablishmentFailureMap.put(4, "unacceptable but negotiable session characteristics");
- sessionEstablishmentFailureMap.put(5, "reception of a second Open message with still " +
- "unacceptable session characteristics");
- sessionEstablishmentFailureMap.put(6, "reception of a PCErr message proposing unacceptable " +
- "session characteristics");
- sessionEstablishmentFailureMap.put(7, "No Keepalive or PCErr message received before the " +
- "expiration of the KeepWait timer");
- sessionEstablishmentFailureMap.put(8, "PCEP version not supported");
- return sessionEstablishmentFailureMap;
- }
-
-
- public Map unknownObject() {
- unknownObjectMap.put(1, "Unrecognized object class");
- unknownObjectMap.put(2, "Unrecognized object type");
- return unknownObjectMap;
- }
-
- public Map notSupportedObject() {
- notSupportedObjectMap.put(1, "Not Supported object class");
- notSupportedObjectMap.put(2, "Not Supported object type");
- return notSupportedObjectMap;
- }
-
-
- public Map policyViolation() {
- policyViolationMap.put(1, "C bit of the METRIC object set (request rejected)");
- policyViolationMap.put(2, "O bit of the RP object cleared (request rejected)");
- return policyViolationMap;
- }
-
-
-
- public Map mandatoryObjectMissing() {
- mandatoryObjectMissingMap.put(1, "RP object missing");
- mandatoryObjectMissingMap.put(2, "RRO missing for a re-optimization request (R bit of the RP object set)");
- mandatoryObjectMissingMap.put(2, "END-POINTS object missing");
- return mandatoryObjectMissingMap;
-
- }
-
-
- public Map receptionOfInvalidObject() {
- receptionOfInvalidObjectMap.put(1, "reception of an object with P flag not set although the P flag must be" +
- "set according to this specification.");
- return receptionOfInvalidObjectMap;
- }
-
- public Map invalidOperation() {
- invalidOperationMap.put(1, "Attempted LSP Update Request for a non-delegated LSP. The PCEP-ERROR Object" +
- " is followed by the LSP Object that identifies the LSP.");
- invalidOperationMap.put(2, "Attempted LSP Update Request if the" +
- " stateful PCE capability was not" +
- " advertised.");
- invalidOperationMap.put(3, "Attempted LSP Update Request for an LSP" +
- "identified by an unknown PLSP-ID.");
- invalidOperationMap.put(4, "A PCE indicates to a PCC that it has" +
- " exceeded the resource limit allocated" +
- " for its state, and thus it cannot" +
- " accept and process its LSP State Report" +
- " message.");
- invalidOperationMap.put(5, "Attempted LSP State Report if active" +
- " stateful PCE capability was not" +
- " advertised.");
- return invalidOperationMap;
- }
-
-
-
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepErrorType.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepErrorType.java
deleted file mode 100644
index 8d51999..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepErrorType.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-/**
- * PCEP error message type information.
- */
-public enum PcepErrorType {
- SESSIONESTABLISHMENTFAILURE(1),
- CAPABALITYNOTSUPPORTED(2),
- UNKNOWNOBJECT(3),
- NOTSUPPORTEDOBJECT(4),
- POLICYVIOLATION(5),
- MANDATORYOBJECTMISSING(6),
- SYNCHRONIZEDPATHCOMPUTATIONREQUESTMISSING(7),
- UNKNOWNREQUESTREFERENCE(8),
- ESTABLISHINGSECONDPCEPSESSION(9),
- RECEPTIONOFINVALIDOBJECT(10),
- INVALIDOPERATION(19),
- VIRTUALNETWORKTLVMISSING(255);
-
- int value;
-
- /**
- * Creates an instance of Pcep Error Type.
- *
- * @param value represents Error type
- */
- PcepErrorType(int value) {
- this.value = value;
- }
-
- /**
- * Gets the value representing Pcep Error Type.
- *
- * @return value represents Error Type
- */
- public int value() {
- return value;
- }
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepEventListener.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepEventListener.java
deleted file mode 100644
index 06d49ed..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepEventListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.pcepio.protocol.PcepMessage;
-/**
- * Notifies providers about PCEP message events.
- */
-public interface PcepEventListener {
-
- /**
- * Handles the message event.
- *
- * @param pccId id of the pcc
- * @param msg the message
- */
- void handleMessage(PccId pccId, PcepMessage msg);
-
- /**
- * Handles end of LSPDB sync actions.
- *
- * @param tunnel the tunnel on which action needs to be taken
- * @param endOfSyncAction the action that needs to be taken for the tunnel
- */
- void handleEndOfSyncAction(Tunnel tunnel, PcepLspSyncAction endOfSyncAction);
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepLspStatus.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepLspStatus.java
deleted file mode 100644
index 9ced00a..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepLspStatus.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-import org.onosproject.incubator.net.tunnel.Tunnel.State;
-
-/**
- * Representation of the PCEP LSP state.
- */
-public enum PcepLspStatus {
-
- /**
- * Signifies that the LSP is not active.
- */
- DOWN,
-
- /**
- * Signifies that the LSP is signalled.
- */
- UP,
-
- /**
- * Signifies that the LSP is up and carrying traffic.
- */
- ACTIVE,
-
- /**
- * Signifies that the LSP is being torn down, resources are being released.
- */
- GOING_DOWN,
-
- /**
- * Signifies that the LSP is being signalled.
- */
- GOING_UP;
-
- /**
- * Returns the applicable PCEP LSP status corresponding to ONOS tunnel state.
- *
- * @param tunnelState ONOS tunnel state
- * @return LSP status as per protocol
- */
- public static PcepLspStatus getLspStatusFromTunnelStatus(State tunnelState) {
-
- switch (tunnelState) {
-
- case INIT:
- return PcepLspStatus.DOWN;
-
- case ESTABLISHED:
- return PcepLspStatus.GOING_UP;
-
- case ACTIVE:
- return PcepLspStatus.UP;
-
- case FAILED: // fall through
- case INACTIVE: // LSP is administratively down.
- default:
- return PcepLspStatus.DOWN;
- }
- }
-
- /**
- * Returns the applicable ONOS tunnel state corresponding to PCEP LSP status.
- *
- * @param lspState PCEP LSP status
- * @return tunnel state
- */
- public static State getTunnelStatusFromLspStatus(PcepLspStatus lspState) {
-
- switch (lspState) {
-
- case DOWN:
- return State.FAILED;
-
- case UP: // fall through
- case ACTIVE:
- return State.ACTIVE;
-
- case GOING_DOWN:
- return State.FAILED;
-
- case GOING_UP:
- return State.ESTABLISHED;
-
- default:
- return State.FAILED;
- }
- }
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepLspSyncAction.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepLspSyncAction.java
deleted file mode 100644
index c120df3..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepLspSyncAction.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-/**
- * Representation of actions to be taken for LSPs on end of LSP-DB sync.
- */
-public enum PcepLspSyncAction {
-
- /**
- * Specifies that delete message for PCE intiiated tunnel should be sent.
- */
- SEND_DELETE(0),
-
- /**
- * Specifies that update message should be sent.
- */
- SEND_UPDATE(1),
-
- /**
- * Specifies that the tunnel should be removed from PCE.
- */
- REMOVE(2),
-
- /**
- * Specifies that the status of the tunnel should be set as unstable.
- */
- UNSTABLE(3);
-
- int value;
-
- /**
- * Assigns val with the value for actions to be taken for LSPs on end of LSP-DB sync.
- *
- * @param val sync status
- */
- PcepLspSyncAction(int val) {
- value = val;
- }
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepNodeListener.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepNodeListener.java
deleted file mode 100644
index 1bb0b95..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepNodeListener.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-/**
- * Notifies providers about PCEP node events.
- */
-public interface PcepNodeListener {
-
- /**
- * Notifies that the node was added.
- *
- * @param pc PCEP client details
- */
- void addDevicePcepConfig(PcepClient pc);
-
- /**
- * Notifies that the node was removed.
- *
- * @param pccId PCEP client ID
- */
- void deleteDevicePcepConfig(PccId pccId);
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepPacketStats.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepPacketStats.java
deleted file mode 100644
index 5802cc5..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepPacketStats.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-/**
- * The representation for PCEP packet statistics.
- */
-public interface PcepPacketStats {
-
- /**
- * Returns the count for no of packets sent out.
- *
- * @return int value of no of packets sent
- */
- int outPacketCount();
-
- /**
- * Returns the count for no of packets received.
- *
- * @return int value of no of packets sent
- */
- int inPacketCount();
-
- /**
- * Returns the count for no of wrong packets received.
- *
- * @return int value of no of wrong packets received
- */
- int wrongPacketCount();
-
- /**
- * Returns the time value.
- *
- * @return long value of time
- */
- long getTime();
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepSyncStatus.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepSyncStatus.java
deleted file mode 100644
index e487b95..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/PcepSyncStatus.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-/**
- * Representation of PCEP database sync status on session establishment.
- */
-public enum PcepSyncStatus {
-
- /**
- * Specifies that the DB state is not synchronized.
- */
- NOT_SYNCED(0),
-
- /**
- * Specifies that the DB state is currently undergoing synchronization.
- */
- IN_SYNC(1),
-
- /**
- * Specifies that the DB state synchronization is completed.
- */
- SYNCED(2);
-
- int value;
-
- /**
- * Assign val with the value as the sync status.
- *
- * @param val sync status
- */
- PcepSyncStatus(int val) {
- value = val;
- }
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/SrpIdGenerators.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/SrpIdGenerators.java
deleted file mode 100644
index 8d73287..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/SrpIdGenerators.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.slf4j.Logger;
-
-/**
- * Unique Srp Id generator for pcep messages.
- */
-public final class SrpIdGenerators {
-
- private static final Logger log = getLogger(SrpIdGenerators.class);
- private static final AtomicInteger SRP_ID_GEN = new AtomicInteger();
- private static final int MAX_SRP_ID = 0x7FFFFFFF;
- private static int srpId;
-
- /**
- * Default constructor.
- */
- private SrpIdGenerators() {
- }
-
- /**
- * Get the next srp id.
- *
- * @return srp id
- */
- public static int create() {
- do {
- if (srpId >= MAX_SRP_ID) {
- if (SRP_ID_GEN.get() >= MAX_SRP_ID) {
- SRP_ID_GEN.set(0);
- }
- }
- srpId = SRP_ID_GEN.incrementAndGet();
- } while (srpId > MAX_SRP_ID);
- return srpId;
- }
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepAgent.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepAgent.java
deleted file mode 100644
index 42f25cc..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepAgent.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server.driver;
-
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepClient;
-import org.onosproject.pcepio.protocol.PcepMessage;
-
-/**
- * Responsible for keeping track of the current set Pcep clients
- * connected to the system.
- *
- */
-public interface PcepAgent {
-
- /**
- * Add a pcc client that has just connected to the system.
- *
- * @param pccId the id of pcc client to add
- * @param pc the actual pce client object.
- * @return true if added, false otherwise.
- */
- boolean addConnectedClient(PccId pccId, PcepClient pc);
-
- /**
- * Checks if the activation for this pcc client is valid.
- *
- * @param pccId the id of pcc client to check
- * @return true if valid, false otherwise
- */
- boolean validActivation(PccId pccId);
-
- /**
- * Clear all state in controller client maps for a pcc client that has
- * disconnected from the local controller. Also release control for
- * that pccIds client from the global repository. Notify client listeners.
- *
- * @param pccIds the id of pcc client to remove.
- */
- void removeConnectedClient(PccId pccIds);
-
- /**
- * Process a message coming from a pcc client.
- *
- * @param pccId the id of pcc client the message was received.
- * @param m the message to process
- */
- void processPcepMessage(PccId pccId, PcepMessage m);
-
- /**
- * Adds PCEP device when session is successfully established.
- *
- * @param pc PCEP client details
- */
- void addNode(PcepClient pc);
-
- /**
- * Removes PCEP device when session is disconnected.
- *
- * @param pccId PCEP client ID
- */
- void deleteNode(PccId pccId);
-
- /**
- * Analyzes report messages received during LSP DB sync again tunnel store and takes necessary actions.
- *
- * @param pccId the id of pcc client
- * @return success or failure
- */
- boolean analyzeSyncMsgList(PccId pccId);
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepClientDriver.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepClientDriver.java
deleted file mode 100644
index 58fc33f..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepClientDriver.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server.driver;
-
-import org.jboss.netty.channel.Channel;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepClient;
-import org.onosproject.pcep.server.PcepPacketStats;
-import org.onosproject.pcepio.protocol.PcepVersion;
-
-
-/**
- * Represents the driver side of an Path computation client(pcc).
- *
- */
-public interface PcepClientDriver extends PcepClient {
-
- /**
- * Sets the Pcep agent to be used. This method
- * can only be called once.
- *
- * @param agent the agent to set.
- */
- void setAgent(PcepAgent agent);
-
- /**
- * Announce to the Pcep agent that this pcc client has connected.
- *
- * @return true if successful, false if duplicate switch.
- */
- boolean connectClient();
-
- /**
- * Remove this pcc client from the Pcep agent.
- */
- void removeConnectedClient();
-
- /**
- * Sets the PCEP version for this pcc.
- *
- * @param pcepVersion the version to set.
- */
- void setPcVersion(PcepVersion pcepVersion);
-
- /**
- * Sets the associated Netty channel for this pcc.
- *
- * @param channel the Netty channel
- */
- void setChannel(Channel channel);
-
-
- /**
- * Sets the keep alive time for this pcc.
- *
- * @param keepAliveTime the keep alive time to set.
- */
- void setPcKeepAliveTime(byte keepAliveTime);
-
- /**
- * Sets the dead time for this pcc.
- *
- * @param deadTime the dead timer value to set.
- */
- void setPcDeadTime(byte deadTime);
-
- /**
- * Sets the session id for this pcc.
- *
- * @param sessionId the session id value to set.
- */
- void setPcSessionId(byte sessionId);
-
- /**
- * Sets whether the pcc is connected.
- *
- * @param connected whether the pcc is connected
- */
- void setConnected(boolean connected);
-
- /**
- * Initializes the behavior.
- *
- * @param pccId id of pcc
- * @param pcepVersion Pcep version
- * @param pktStats Pcep Packet Stats
- */
- void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats);
-
- /**
- * Checks whether the handshake is complete.
- *
- * @return true is finished, false if not.
- */
- boolean isHandshakeComplete();
-
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepClientDriverFactory.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepClientDriverFactory.java
deleted file mode 100644
index 46e04ff..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/PcepClientDriverFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server.driver;
-
-import org.onlab.packet.IpAddress;
-import org.onosproject.pcepio.protocol.PcepVersion;
-
-/**
- * Pcc Client factory which returns concrete pcc client objects for the
- * physical pcc client in use.
- *
- */
-public interface PcepClientDriverFactory {
-
-
- /**
- * Constructs the real Pcep Client representation.
- *
- * @param pccIpAddress the ip address for this pcc client.
- * @param pcepVersion the Pcep version in use
- * @return the Pcep client representation.
- */
- PcepClientDriver getPcepClientImpl(IpAddress pccIpAddress,
- PcepVersion pcepVersion);
-}
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/package-info.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/package-info.java
deleted file mode 100644
index 6e542e7..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/driver/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCEP client controller driver API.
- */
-package org.onosproject.pcep.server.driver;
diff --git a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/package-info.java b/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/package-info.java
deleted file mode 100644
index 8ed1233..0000000
--- a/protocols/pcep/server/api/src/main/java/org/onosproject/pcep/server/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCEP client controller API.
- */
-package org.onosproject.pcep.server;
diff --git a/protocols/pcep/server/api/src/test/java/org/onosproject/pcep/server/PcepClientAdapter.java b/protocols/pcep/server/api/src/test/java/org/onosproject/pcep/server/PcepClientAdapter.java
deleted file mode 100644
index 6e503ef..0000000
--- a/protocols/pcep/server/api/src/test/java/org/onosproject/pcep/server/PcepClientAdapter.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-import org.jboss.netty.channel.Channel;
-import org.onosproject.pcepio.protocol.PcepFactories;
-import org.onosproject.pcepio.protocol.PcepFactory;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepStateReport;
-import org.onosproject.pcepio.protocol.PcepVersion;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.RejectedExecutionException;
-
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Representation of PCEP client adapter.
- */
-public class PcepClientAdapter implements PcepClient {
-
- private Channel channel;
- protected String channelId;
-
- private boolean connected;
- private PccId pccId;
- private ClientCapability capability;
-
- private PcepVersion pcepVersion;
- private PcepSyncStatus lspDbSyncStatus;
- private PcepSyncStatus labelDbSyncStatus;
- private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>();
-
- /**
- * Initialize instance with specified parameters.
- *
- * @param pccId PCC id
- * @param pcepVersion PCEP message version
- */
- public void init(PccId pccId, PcepVersion pcepVersion) {
- this.pccId = pccId;
- this.pcepVersion = pcepVersion;
- }
-
- @Override
- public final void disconnectClient() {
- this.channel.close();
- }
-
- @Override
- public final void sendMessage(PcepMessage m) {
- }
-
- @Override
- public final void sendMessage(List<PcepMessage> msgs) {
- try {
- PcepMessage pcepMsg = msgs.get(0);
- assertNotNull("PCEP MSG should be created.", pcepMsg);
- } catch (RejectedExecutionException e) {
- throw e;
- }
- }
-
- @Override
- public final boolean isConnected() {
- return this.connected;
- }
-
- @Override
- public String channelId() {
- return channelId;
- }
-
- @Override
- public final PccId getPccId() {
- return this.pccId;
- }
-
- @Override
- public final String getStringId() {
- return this.pccId.toString();
- }
-
- @Override
- public final void handleMessage(PcepMessage m) {
- }
-
- @Override
- public boolean isOptical() {
- return false;
- }
-
- @Override
- public PcepFactory factory() {
- return PcepFactories.getFactory(pcepVersion);
- }
-
- @Override
- public void setLspDbSyncStatus(PcepSyncStatus syncStatus) {
- this.lspDbSyncStatus = syncStatus;
- }
-
- @Override
- public PcepSyncStatus lspDbSyncStatus() {
- return lspDbSyncStatus;
- }
-
- @Override
- public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) {
- this.labelDbSyncStatus = syncStatus;
- }
-
- @Override
- public PcepSyncStatus labelDbSyncStatus() {
- return labelDbSyncStatus;
- }
-
- @Override
- public void setCapability(ClientCapability capability) {
- this.capability = capability;
- }
-
- @Override
- public ClientCapability capability() {
- return capability;
- }
-
- @Override
- public void addNode(PcepClient pc) {
- }
-
- @Override
- public void deleteNode(PccId pccId) {
- }
-
- @Override
- public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) {
- lspDelegationInfo.put(lspKey, dFlag);
- }
-
- @Override
- public Boolean delegationInfo(LspKey lspKey) {
- return lspDelegationInfo.get(lspKey);
- }
-
- @Override
- public void initializeSyncMsgList(PccId pccId) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public List<PcepStateReport> getSyncMsgList(PccId pccId) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void removeSyncMsgList(PccId pccId) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/protocols/pcep/server/api/src/test/java/org/onosproject/pcep/server/PcepClientControllerAdapter.java b/protocols/pcep/server/api/src/test/java/org/onosproject/pcep/server/PcepClientControllerAdapter.java
deleted file mode 100644
index b5e448e..0000000
--- a/protocols/pcep/server/api/src/test/java/org/onosproject/pcep/server/PcepClientControllerAdapter.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server;
-
-
-import com.google.common.collect.Sets;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Deactivate;
-import org.onlab.packet.IpAddress;
-import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
-import org.onosproject.incubator.net.tunnel.LabelStack;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.net.Path;
-import org.onosproject.pcep.server.driver.PcepAgent;
-import org.onosproject.pcepio.protocol.PcepError;
-import org.onosproject.pcepio.protocol.PcepErrorInfo;
-import org.onosproject.pcepio.protocol.PcepErrorMsg;
-import org.onosproject.pcepio.protocol.PcepErrorObject;
-import org.onosproject.pcepio.protocol.PcepFactory;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.onosproject.pcepio.types.PcepValueType;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_TYPE_19;
-import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_VALUE_5;
-
-/**
- * Representation of PCEP client controller adapter.
- */
-public class PcepClientControllerAdapter implements PcepClientController {
-
- protected ConcurrentHashMap<PccId, PcepClient> connectedClients =
- new ConcurrentHashMap<PccId, PcepClient>();
-
- protected PcepClientAgent agent = new PcepClientAgent();
- protected Set<PcepClientListener> pcepClientListener = new HashSet<>();
-
- protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet();
- public Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet();
-
- @Activate
- public void activate() {
- }
-
- @Deactivate
- public void deactivate() {
- }
-
- @Override
- public Collection<PcepClient> getClients() {
- return connectedClients.values();
- }
-
- @Override
- public PcepClient getClient(PccId pccId) {
- if (null != connectedClients.get(pccId)) {
- return connectedClients.get(pccId);
- }
- PcepClientAdapter pc = new PcepClientAdapter();
- if (pccId.ipAddress().equals(IpAddress.valueOf(0xC010103))
- || pccId.ipAddress().equals(IpAddress.valueOf(0xB6024E22))) {
- pc.setCapability(new ClientCapability(true, false, false, false, false));
- } else {
- pc.setCapability(new ClientCapability(true, true, true, false, false));
- }
- pc.init(PccId.pccId(pccId.ipAddress()), PcepVersion.PCEP_1);
- connectedClients.put(pccId, pc);
- return pc;
- }
-
- @Override
- public void addListener(PcepClientListener listener) {
- if (!pcepClientListener.contains(listener)) {
- this.pcepClientListener.add(listener);
- }
- }
-
- @Override
- public void addNodeListener(PcepNodeListener listener) {
- pcepNodeListener.add(listener);
- }
-
- @Override
- public void removeNodeListener(PcepNodeListener listener) {
- pcepNodeListener.remove(listener);
- }
-
- @Override
- public void removeListener(PcepClientListener listener) {
- this.pcepClientListener.remove(listener);
- }
-
- @Override
- public void addEventListener(PcepEventListener listener) {
- pcepEventListener.add(listener);
- }
-
- @Override
- public void removeEventListener(PcepEventListener listener) {
- pcepEventListener.remove(listener);
- }
-
- @Override
- public void writeMessage(PccId pccId, PcepMessage msg) {
- this.getClient(pccId).sendMessage(msg);
- }
-
- @Override
- public void processClientMessage(PccId pccId, PcepMessage msg) {
-
- PcepClient pc = getClient(pccId);
-
- switch (msg.getType()) {
- case NONE:
- break;
- case OPEN:
- break;
- case KEEP_ALIVE:
- //log.debug("Sending Keep Alive Message to {" + pccIpAddress.toString() + "}");
- pc.sendMessage(Collections.singletonList(pc.factory().buildKeepaliveMsg().build()));
- break;
- case PATH_COMPUTATION_REQUEST:
- break;
- case PATH_COMPUTATION_REPLY:
- break;
- case NOTIFICATION:
- break;
- case ERROR:
- break;
- case CLOSE:
- //log.debug("Sending Close Message to { }", pccIpAddress.toString());
- pc.sendMessage(Collections.singletonList(pc.factory().buildCloseMsg().build()));
- break;
- case INITIATE:
- if (!pc.capability().pcInstantiationCapability()) {
- pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(),
- ERROR_TYPE_19, ERROR_VALUE_5)));
- }
- break;
- case REPORT:
- //Only update the listener if respective capability is supported else send PCEP-ERR msg
- if (pc.capability().statefulPceCapability()) {
- for (PcepEventListener l : pcepEventListener) {
- l.handleMessage(pccId, msg);
- }
- } else {
- // Send PCEP-ERROR message.
- pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(),
- ERROR_TYPE_19, ERROR_VALUE_5)));
- }
- break;
- case UPDATE:
- if (!pc.capability().statefulPceCapability()) {
- pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(),
- ERROR_TYPE_19, ERROR_VALUE_5)));
- }
- break;
- case LABEL_UPDATE:
- if (!pc.capability().pceccCapability()) {
- pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(),
- ERROR_TYPE_19, ERROR_VALUE_5)));
- }
- break;
- case MAX:
- break;
- case END:
- break;
- default:
- break;
- }
- }
-
- @Override
- public void closeConnectedClients() {
- PcepClient pc;
- for (PccId id : connectedClients.keySet()) {
- pc = getClient(id);
- pc.disconnectClient();
- }
- }
-
- private PcepErrorMsg getErrMsg(PcepFactory factory, byte errorType, byte errorValue) {
- LinkedList<PcepError> llPcepErr = new LinkedList<>();
-
- LinkedList<PcepErrorObject> llerrObj = new LinkedList<>();
- PcepErrorMsg errMsg;
-
- PcepErrorObject errObj = factory.buildPcepErrorObject().setErrorValue(errorValue).setErrorType(errorType)
- .build();
-
- llerrObj.add(errObj);
- PcepError pcepErr = factory.buildPcepError().setErrorObjList(llerrObj).build();
-
- llPcepErr.add(pcepErr);
-
- PcepErrorInfo errInfo = factory.buildPcepErrorInfo().setPcepErrorList(llPcepErr).build();
-
- errMsg = factory.buildPcepErrorMsg().setPcepErrorInfo(errInfo).build();
- return errMsg;
- }
-
- /**
- * Implementation of an Pcep Agent which is responsible for
- * keeping track of connected clients and the state in which
- * they are.
- */
- public class PcepClientAgent implements PcepAgent {
-
- @Override
- public boolean addConnectedClient(PccId pccId, PcepClient pc) {
-
- if (connectedClients.get(pccId) != null) {
- return false;
- } else {
- connectedClients.put(pccId, pc);
- for (PcepClientListener l : pcepClientListener) {
- l.clientConnected(pccId);
- }
- return true;
- }
- }
-
- @Override
- public boolean validActivation(PccId pccId) {
- if (connectedClients.get(pccId) == null) {
- //log.error("Trying to activate client but is not in "
- // + "connected switches: pccIp {}. Aborting ..", pccIpAddress.toString());
- return false;
- }
-
- return true;
- }
-
- @Override
- public void removeConnectedClient(PccId pccId) {
- connectedClients.remove(pccId);
- for (PcepClientListener l : pcepClientListener) {
- //log.warn("removal for {}", pccIpAddress.toString());
- l.clientDisconnected(pccId);
- }
- }
-
- @Override
- public void processPcepMessage(PccId pccId, PcepMessage m) {
- processClientMessage(pccId, m);
- }
-
- @Override
- public void addNode(PcepClient pc) {
- for (PcepNodeListener l : pcepNodeListener) {
- l.addDevicePcepConfig(pc);
- }
- }
-
- @Override
- public void deleteNode(PccId pccId) {
- for (PcepNodeListener l : pcepNodeListener) {
- l.deleteDevicePcepConfig(pccId);
- }
- }
-
- @Override
- public boolean analyzeSyncMsgList(PccId pccId) {
- // TODO Auto-generated method stub
- return false;
- }
- }
-
- @Override
- public LabelStack computeLabelStack(Path path) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Map<String, List<String>> getPcepExceptions() {
- return null;
- }
-
- @Override
- public Map<Integer, Integer> getPcepErrorMsg() {
- return null;
- }
-
- @Override
- public Map<String, String> getPcepSessionMap() {
- return null;
- }
-
- @Override
- public Map<String, Byte> getPcepSessionIdMap() {
- return null;
- }
-
- @Override
- public void peerErrorMsg(String peerId, Integer errorType, Integer errValue) {
- return;
- }
-
-
- @Override
- public boolean allocateLocalLabel(Tunnel tunnel) {
- // TODO Auto-generated method stub
- return false;
- }
-}
-
diff --git a/protocols/pcep/server/ctl/BUILD b/protocols/pcep/server/ctl/BUILD
deleted file mode 100644
index f470e41..0000000
--- a/protocols/pcep/server/ctl/BUILD
+++ /dev/null
@@ -1,18 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + KRYO + [
- "@io_netty_netty//jar",
- "//apps/tunnel/api:onos-apps-tunnel-api",
- "//protocols/pcep/pcepio:onos-protocols-pcep-pcepio",
- "//protocols/pcep/server/api:onos-protocols-pcep-server-api",
- "//core/store/serializers:onos-core-serializers",
- "//apps/pcep-api:onos-apps-pcep-api",
-]
-
-TEST_DEPS = TEST_ADAPTERS + [
- "//protocols/pcep/server/api:onos-protocols-pcep-server-api-tests",
- "//apps/tunnel/api:onos-apps-tunnel-api-tests",
-]
-
-osgi_jar_with_tests(
- test_deps = TEST_DEPS,
- deps = COMPILE_DEPS,
-)
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/DefaultLspLocalLabelInfo.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/DefaultLspLocalLabelInfo.java
deleted file mode 100644
index be262f0..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/DefaultLspLocalLabelInfo.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore;
-
-import com.google.common.base.MoreObjects;
-
-import java.util.Objects;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.pcelabelstore.api.LspLocalLabelInfo;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-
-/**
- * Local node details including IN and OUT labels as well as IN and OUT port details.
- */
-public final class DefaultLspLocalLabelInfo implements LspLocalLabelInfo {
-
- private final DeviceId deviceId;
- private final LabelResourceId inLabelId;
- private final LabelResourceId outLabelId;
- private final PortNumber inPort;
- private final PortNumber outPort;
-
- /**
- * Initialization of member variables.
- *
- * @param deviceId device id
- * @param inLabelId in label id of a node
- * @param outLabelId out label id of a node
- * @param inPort input port
- * @param outPort remote port
- */
- private DefaultLspLocalLabelInfo(DeviceId deviceId,
- LabelResourceId inLabelId,
- LabelResourceId outLabelId,
- PortNumber inPort,
- PortNumber outPort) {
- this.deviceId = deviceId;
- this.inLabelId = inLabelId;
- this.outLabelId = outLabelId;
- this.inPort = inPort;
- this.outPort = outPort;
- }
-
- /**
- * Initialization of member variables for serialization.
- */
- private DefaultLspLocalLabelInfo() {
- this.deviceId = null;
- this.inLabelId = null;
- this.outLabelId = null;
- this.inPort = null;
- this.outPort = null;
- }
-
- @Override
- public DeviceId deviceId() {
- return deviceId;
- }
-
- @Override
- public LabelResourceId inLabelId() {
- return inLabelId;
- }
-
- @Override
- public LabelResourceId outLabelId() {
- return outLabelId;
- }
-
- @Override
- public PortNumber inPort() {
- return inPort;
- }
-
- @Override
- public PortNumber outPort() {
- return outPort;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(deviceId, inLabelId, outLabelId, inPort, outPort);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof LspLocalLabelInfo) {
- final DefaultLspLocalLabelInfo other = (DefaultLspLocalLabelInfo) obj;
- return Objects.equals(this.deviceId, other.deviceId) &&
- Objects.equals(this.inLabelId, other.inLabelId) &&
- Objects.equals(this.outLabelId, other.outLabelId) &&
- Objects.equals(this.inPort, other.inPort) &&
- Objects.equals(this.outPort, other.outPort);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .omitNullValues()
- .add("DeviceId", deviceId)
- .add("InLabelId", inLabelId)
- .add("OutLabelId", outLabelId)
- .add("InPort", inPort)
- .add("OutPort", outPort)
- .toString();
- }
-
- /**
- * Creates and returns a new builder instance that clones an existing object.
- *
- * @param deviceLabelInfo device label information
- * @return new builder
- */
- public static Builder builder(LspLocalLabelInfo deviceLabelInfo) {
- return new Builder(deviceLabelInfo);
- }
-
- /**
- * Creates and returns a new builder instance.
- *
- * @return new builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder.
- */
- public static final class Builder implements LspLocalLabelInfo.Builder {
- private DeviceId deviceId;
- private LabelResourceId inLabelId;
- private LabelResourceId outLabelId;
- private PortNumber inPort;
- private PortNumber outPort;
-
- /**
- * Constructs default builder.
- */
- private Builder() {
- }
-
- /**
- * Initializes member variables with existing object.
- */
- private Builder(LspLocalLabelInfo deviceLabelInfo) {
- this.deviceId = deviceLabelInfo.deviceId();
- this.inLabelId = deviceLabelInfo.inLabelId();
- this.outLabelId = deviceLabelInfo.outLabelId();
- this.inPort = deviceLabelInfo.inPort();
- this.outPort = deviceLabelInfo.outPort();
- }
-
- @Override
- public Builder deviceId(DeviceId id) {
- this.deviceId = id;
- return this;
- }
-
- @Override
- public Builder inLabelId(LabelResourceId id) {
- this.inLabelId = id;
- return this;
- }
-
- @Override
- public Builder outLabelId(LabelResourceId id) {
- this.outLabelId = id;
- return this;
- }
-
- @Override
- public Builder inPort(PortNumber port) {
- this.inPort = port;
- return this;
- }
-
- @Override
- public Builder outPort(PortNumber port) {
- this.outPort = port;
- return this;
- }
-
- @Override
- public LspLocalLabelInfo build() {
- return new DefaultLspLocalLabelInfo(deviceId, inLabelId, outLabelId, inPort, outPort);
- }
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/DistributedPceLabelStore.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/DistributedPceLabelStore.java
deleted file mode 100644
index 6288134..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/DistributedPceLabelStore.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore;
-
-import org.onlab.util.KryoNamespace;
-import org.onosproject.incubator.net.resource.label.LabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.pcelabelstore.api.LspLocalLabelInfo;
-import org.onosproject.pcelabelstore.api.PceLabelStore;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Manages the pool of available labels to devices, links and tunnels.
- */
-@Component(immediate = true, service = PceLabelStore.class)
-public class DistributedPceLabelStore implements PceLabelStore {
-
- private static final String DEVICE_ID_NULL = "Device ID cannot be null";
- private static final String LABEL_RESOURCE_ID_NULL = "Label Resource Id cannot be null";
- private static final String LINK_NULL = "LINK cannot be null";
- private static final String PCECC_TUNNEL_INFO_NULL = "PCECC Tunnel Info cannot be null";
- private static final String TUNNEL_ID_NULL = "Tunnel Id cannot be null";
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected StorageService storageService;
-
- // Mapping device with global node label
- private ConsistentMap<DeviceId, LabelResourceId> globalNodeLabelMap;
-
- // Mapping link with adjacency label
- private ConsistentMap<Link, LabelResourceId> adjLabelMap;
-
- // Mapping tunnel id with local labels.
- private ConsistentMap<TunnelId, List<LspLocalLabelInfo>> tunnelLabelInfoMap;
-
- // Locally maintain LSRID to device id mapping for better performance.
- private Map<String, DeviceId> lsrIdDeviceIdMap = new HashMap<>();
-
- // List of PCC LSR ids whose BGP device information was not available to perform
- // label db sync.
- private HashSet<DeviceId> pendinglabelDbSyncPccMap = new HashSet<>();
-
- @Activate
- protected void activate() {
- globalNodeLabelMap = storageService.<DeviceId, LabelResourceId>consistentMapBuilder()
- .withName("onos-pce-globalnodelabelmap")
- .withSerializer(Serializer.using(
- new KryoNamespace.Builder()
- .register(KryoNamespaces.API)
- .register(LabelResourceId.class)
- .build()))
- .build();
-
- adjLabelMap = storageService.<Link, LabelResourceId>consistentMapBuilder()
- .withName("onos-pce-adjlabelmap")
- .withSerializer(Serializer.using(
- new KryoNamespace.Builder()
- .register(KryoNamespaces.API)
- .register(Link.class,
- LabelResource.class,
- LabelResourceId.class)
- .build()))
- .build();
-
- tunnelLabelInfoMap = storageService.<TunnelId, List<LspLocalLabelInfo>>consistentMapBuilder()
- .withName("onos-pce-tunnellabelinfomap")
- .withSerializer(Serializer.using(
- new KryoNamespace.Builder()
- .register(KryoNamespaces.API)
- .register(TunnelId.class,
- DefaultLspLocalLabelInfo.class,
- LabelResourceId.class,
- DeviceId.class)
- .build()))
- .build();
-
- log.info("Started");
- }
-
- @Deactivate
- protected void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public boolean existsGlobalNodeLabel(DeviceId id) {
- checkNotNull(id, DEVICE_ID_NULL);
- return globalNodeLabelMap.containsKey(id);
- }
-
- @Override
- public boolean existsAdjLabel(Link link) {
- checkNotNull(link, LINK_NULL);
- return adjLabelMap.containsKey(link);
- }
-
- @Override
- public boolean existsTunnelInfo(TunnelId tunnelId) {
- checkNotNull(tunnelId, TUNNEL_ID_NULL);
- return tunnelLabelInfoMap.containsKey(tunnelId);
- }
-
- @Override
- public int getGlobalNodeLabelCount() {
- return globalNodeLabelMap.size();
- }
-
- @Override
- public int getAdjLabelCount() {
- return adjLabelMap.size();
- }
-
- @Override
- public int getTunnelInfoCount() {
- return tunnelLabelInfoMap.size();
- }
-
- @Override
- public Map<DeviceId, LabelResourceId> getGlobalNodeLabels() {
- return globalNodeLabelMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().value()));
- }
-
- @Override
- public Map<Link, LabelResourceId> getAdjLabels() {
- return adjLabelMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().value()));
- }
-
- @Override
- public Map<TunnelId, List<LspLocalLabelInfo>> getTunnelInfos() {
- return tunnelLabelInfoMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().value()));
- }
-
- @Override
- public LabelResourceId getGlobalNodeLabel(DeviceId id) {
- checkNotNull(id, DEVICE_ID_NULL);
- return globalNodeLabelMap.get(id) == null ? null : globalNodeLabelMap.get(id).value();
- }
-
- @Override
- public LabelResourceId getAdjLabel(Link link) {
- checkNotNull(link, LINK_NULL);
- return adjLabelMap.get(link) == null ? null : adjLabelMap.get(link).value();
- }
-
- @Override
- public List<LspLocalLabelInfo> getTunnelInfo(TunnelId tunnelId) {
- checkNotNull(tunnelId, TUNNEL_ID_NULL);
- return tunnelLabelInfoMap.get(tunnelId) == null ? null : tunnelLabelInfoMap.get(tunnelId).value();
- }
-
- @Override
- public void addGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId) {
- checkNotNull(deviceId, DEVICE_ID_NULL);
- checkNotNull(labelId, LABEL_RESOURCE_ID_NULL);
-
- globalNodeLabelMap.put(deviceId, labelId);
- }
-
- @Override
- public void addAdjLabel(Link link, LabelResourceId labelId) {
- checkNotNull(link, LINK_NULL);
- checkNotNull(labelId, LABEL_RESOURCE_ID_NULL);
-
- adjLabelMap.put(link, labelId);
- }
-
- @Override
- public void addTunnelInfo(TunnelId tunnelId, List<LspLocalLabelInfo> lspLocalLabelInfoList) {
- checkNotNull(tunnelId, TUNNEL_ID_NULL);
- checkNotNull(lspLocalLabelInfoList, PCECC_TUNNEL_INFO_NULL);
-
- tunnelLabelInfoMap.put(tunnelId, lspLocalLabelInfoList);
- }
-
- @Override
- public boolean removeGlobalNodeLabel(DeviceId id) {
- checkNotNull(id, DEVICE_ID_NULL);
-
- if (globalNodeLabelMap.remove(id) == null) {
- log.error("SR-TE node label deletion for device {} has failed.", id.toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removeAdjLabel(Link link) {
- checkNotNull(link, LINK_NULL);
-
- if (adjLabelMap.remove(link) == null) {
- log.error("Adjacency label deletion for link {} hash failed.", link.toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removeTunnelInfo(TunnelId tunnelId) {
- checkNotNull(tunnelId, TUNNEL_ID_NULL);
-
- if (tunnelLabelInfoMap.remove(tunnelId) == null) {
- log.error("Tunnel info deletion for tunnel id {} has failed.", tunnelId.toString());
- return false;
- }
- return true;
- }
-
- @Override
- public boolean addLsrIdDevice(String lsrId, DeviceId deviceId) {
- checkNotNull(lsrId);
- checkNotNull(deviceId);
-
- lsrIdDeviceIdMap.put(lsrId, deviceId);
- return true;
- }
-
- @Override
- public boolean removeLsrIdDevice(String lsrId) {
- checkNotNull(lsrId);
-
- lsrIdDeviceIdMap.remove(lsrId);
- return true;
- }
-
- @Override
- public DeviceId getLsrIdDevice(String lsrId) {
- checkNotNull(lsrId);
-
- return lsrIdDeviceIdMap.get(lsrId);
-
- }
-
- @Override
- public boolean addPccLsr(DeviceId lsrId) {
- checkNotNull(lsrId);
- pendinglabelDbSyncPccMap.add(lsrId);
- return true;
- }
-
- @Override
- public boolean removePccLsr(DeviceId lsrId) {
- checkNotNull(lsrId);
- pendinglabelDbSyncPccMap.remove(lsrId);
- return true;
- }
-
- @Override
- public boolean hasPccLsr(DeviceId lsrId) {
- checkNotNull(lsrId);
- return pendinglabelDbSyncPccMap.contains(lsrId);
-
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/PcepLabelOp.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/PcepLabelOp.java
deleted file mode 100644
index d879a86..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/PcepLabelOp.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore;
-
-/**
- * Representation of label operation over PCEP.
- */
-public enum PcepLabelOp {
- /**
- * Signifies that the label operation is addition.
- */
- ADD,
-
- /**
- * Signifies that the label operation is modification. This is reserved for future.
- */
- MODIFY,
-
- /**
- * Signifies that the label operation is deletion.
- */
- REMOVE
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/api/LspLocalLabelInfo.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/api/LspLocalLabelInfo.java
deleted file mode 100644
index 666449a..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/api/LspLocalLabelInfo.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore.api;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-
-/**
- * Abstraction of an entity providing LSP local label information.
- */
-public interface LspLocalLabelInfo {
-
- /**
- * Returns device id.
- *
- * @return device id
- */
- DeviceId deviceId();
-
- /**
- * Returns in label id of a device.
- *
- * @return in label resource id
- */
- LabelResourceId inLabelId();
-
- /**
- * Returns out label id of a device.
- *
- * @return node out label resource id
- */
- LabelResourceId outLabelId();
-
- /**
- * Returns in port of an incoming label.
- *
- * @return in port
- */
- PortNumber inPort();
-
- /**
- * Returns next hop of an outgoing label.
- *
- * @return out port
- */
- PortNumber outPort();
-
- /**
- * LspLocalLabelInfo Builder.
- */
- interface Builder {
-
- /**
- * Returns builder object of a device id.
- *
- * @param id device id
- * @return builder object of device id
- */
- Builder deviceId(DeviceId id);
-
- /**
- * Returns builder object of in label.
- *
- * @param id in label id
- * @return builder object of in label id
- */
- Builder inLabelId(LabelResourceId id);
-
- /**
- * Returns builder object of out label.
- *
- * @param id out label id
- * @return builder object of out label id
- */
- Builder outLabelId(LabelResourceId id);
-
- /**
- * Returns builder object of in port of an incoming label.
- *
- * @param port in port
- * @return builder object of in port
- */
- Builder inPort(PortNumber port);
-
- /**
- * Returns builder object of next hop of an outgoing label.
- *
- * @param port out port
- * @return builder object of out port
- */
- Builder outPort(PortNumber port);
-
- /**
- * Builds object of device local label info.
- *
- * @return object of device local label info.
- */
- LspLocalLabelInfo build();
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/api/PceLabelStore.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/api/PceLabelStore.java
deleted file mode 100644
index c732f25..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/api/PceLabelStore.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore.api;
-
-import java.util.List;
-
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import java.util.Map;
-
-/**
- * Abstraction of an entity providing pool of available labels to devices, links and tunnels.
- */
-public interface PceLabelStore {
- /**
- * Checks whether device id is present in global node label store.
- *
- * @param id device id
- * @return success of failure
- */
- boolean existsGlobalNodeLabel(DeviceId id);
-
- /**
- * Checks whether link is present in adjacency label store.
- *
- * @param link link between devices
- * @return success of failure
- */
- boolean existsAdjLabel(Link link);
-
- /**
- * Checks whether tunnel id is present in tunnel info store.
- *
- * @param tunnelId tunnel id
- * @return success of failure
- */
- boolean existsTunnelInfo(TunnelId tunnelId);
-
- /**
- * Retrieves the node label count.
- *
- * @return node label count
- */
- int getGlobalNodeLabelCount();
-
- /**
- * Retrieves the adjacency label count.
- *
- * @return adjacency label count
- */
- int getAdjLabelCount();
-
- /**
- * Retrieves the tunnel info count.
- *
- * @return tunnel info count
- */
- int getTunnelInfoCount();
-
- /**
- * Retrieves device id and label pairs collection from global node label store.
- *
- * @return collection of device id and label pairs
- */
- Map<DeviceId, LabelResourceId> getGlobalNodeLabels();
-
- /**
- * Retrieves link and label pairs collection from adjacency label store.
- *
- * @return collection of link and label pairs
- */
- Map<Link, LabelResourceId> getAdjLabels();
-
- /**
- * Retrieves tunnel id and pcecc tunnel info pairs collection from tunnel info store.
- *
- * @return collection of tunnel id and pcecc tunnel info pairs
- */
- Map<TunnelId, List<LspLocalLabelInfo>> getTunnelInfos();
-
- /**
- * Retrieves node label for specified device id.
- *
- * @param id device id
- * @return node label
- */
- LabelResourceId getGlobalNodeLabel(DeviceId id);
-
- /**
- * Retrieves adjacency label for specified link.
- *
- * @param link between devices
- * @return adjacency label
- */
- LabelResourceId getAdjLabel(Link link);
-
- /**
- * Retrieves local label info with tunnel consumer id from tunnel info store.
- *
- * @param tunnelId tunnel id
- * @return pcecc tunnel info
- */
- List<LspLocalLabelInfo> getTunnelInfo(TunnelId tunnelId);
-
- /**
- * Stores node label into global node label store.
- *
- * @param deviceId device id
- * @param labelId node label id
- */
- void addGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId);
-
- /**
- * Stores adjacency label into adjacency label store.
- *
- * @param link link between nodes
- * @param labelId link label id
- */
- void addAdjLabel(Link link, LabelResourceId labelId);
-
- /**
- * Stores local label info with tunnel consumer id into tunnel info store for specified tunnel id.
- *
- * @param tunnelId tunnel id
- * @param lspLocalLabelInfoList local label info
- */
- void addTunnelInfo(TunnelId tunnelId, List<LspLocalLabelInfo> lspLocalLabelInfoList);
-
- /**
- * Removes device label from global node label store for specified device id.
- *
- * @param id device id
- * @return success or failure
- */
- boolean removeGlobalNodeLabel(DeviceId id);
-
- /**
- * Removes adjacency label from adjacency label store for specified link information.
- *
- * @param link between nodes
- * @return success or failure
- */
- boolean removeAdjLabel(Link link);
-
- /**
- * Removes local label info with tunnel consumer id from tunnel info store for specified tunnel id.
- *
- * @param tunnelId tunnel id
- * @return success or failure
- */
- boolean removeTunnelInfo(TunnelId tunnelId);
-
- /**
- * Adds lsrid to device id mapping.
- *
- * @param lsrId lsrId of the device
- * @param deviceId device id
- * @return success or failure
- */
- boolean addLsrIdDevice(String lsrId, DeviceId deviceId);
-
- /**
- * Removes lsrid to device id mapping.
- *
- * @param lsrId lsrId of the device
- * @return success or failure
- */
- boolean removeLsrIdDevice(String lsrId);
-
- /**
- * Gets lsrid to device id mapping.
- *
- * @param lsrId lsrId of the device
- * @return device id of the lsrId
- */
- DeviceId getLsrIdDevice(String lsrId);
-
- /**
- * Adds lsrId of the PCC in form of device id for the PCC for which sync is pending due to non-availability of BGP.
- * device.
- *
- * @param lsrId LSR id of the PCC in form of device id
- * @return success or failure
- */
- public boolean addPccLsr(DeviceId lsrId);
-
- /**
- * Removes lsrId of the PCC in form of device id for the PCC for which pending sync is done.
- *
- * @param lsrId LSR id of the PCC in form of device id
- * @return success or failure
- */
- public boolean removePccLsr(DeviceId lsrId);
-
- /**
- * Gets lsrId of the PCC in form of device id.
- *
- * @param lsrId LSR id of the PCC in form of device id
- * @return success or failure
- */
- public boolean hasPccLsr(DeviceId lsrId);
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/api/package-info.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/api/package-info.java
deleted file mode 100644
index 9147dba..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/api/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCE store service API.
- */
-package org.onosproject.pcelabelstore.api;
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/package-info.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/package-info.java
deleted file mode 100644
index 0b4e482..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcelabelstore/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCE store application.
- */
-package org.onosproject.pcelabelstore;
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/BasicPceccHandler.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/BasicPceccHandler.java
deleted file mode 100644
index 7376c14..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/BasicPceccHandler.java
+++ /dev/null
@@ -1,579 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.LinkedList;
-
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpAddress;
-import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.pcelabelstore.DefaultLspLocalLabelInfo;
-import org.onosproject.pcelabelstore.PcepLabelOp;
-import org.onosproject.pcelabelstore.api.LspLocalLabelInfo;
-import org.onosproject.pcelabelstore.api.PceLabelStore;
-import org.onosproject.pcep.server.LspType;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepAnnotationKeys;
-import org.onosproject.pcep.server.PcepClient;
-import org.onosproject.pcep.server.PcepClientController;
-import org.onosproject.pcep.server.SrpIdGenerators;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepAttribute;
-import org.onosproject.pcepio.protocol.PcepBandwidthObject;
-import org.onosproject.pcepio.protocol.PcepEroObject;
-import org.onosproject.pcepio.protocol.PcepLabelObject;
-import org.onosproject.pcepio.protocol.PcepLabelUpdate;
-import org.onosproject.pcepio.protocol.PcepLabelUpdateMsg;
-import org.onosproject.pcepio.protocol.PcepLspObject;
-import org.onosproject.pcepio.protocol.PcepMsgPath;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.onosproject.pcepio.protocol.PcepUpdateMsg;
-import org.onosproject.pcepio.protocol.PcepUpdateRequest;
-import org.onosproject.pcepio.types.IPv4SubObject;
-import org.onosproject.pcepio.types.NexthopIPv4addressTlv;
-import org.onosproject.pcepio.types.PathSetupTypeTlv;
-import org.onosproject.pcepio.types.PcepLabelDownload;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
-import org.onosproject.pcepio.types.SymbolicPathNameTlv;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
-
-import static org.onosproject.pcep.server.PcepAnnotationKeys.BANDWIDTH;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.LSP_SIG_TYPE;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.PCE_INIT;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.DELEGATE;
-
-/**
- * Basic PCECC handler.
- * In Basic PCECC, after path computation will configure IN and OUT label to nodes.
- * [X]OUT---link----IN[Y]OUT---link-----IN[Z] where X, Y and Z are nodes.
- * For generating labels, will go thorough links in the path from Egress to Ingress.
- * In each link, will take label from destination node local pool as IN label,
- * and assign this label as OUT label to source node.
- */
-public final class BasicPceccHandler {
- private static final Logger log = LoggerFactory.getLogger(BasicPceccHandler.class);
- public static final int OUT_LABEL_TYPE = 0;
- public static final int IN_LABEL_TYPE = 1;
- public static final long IDENTIFIER_SET = 0x100000000L;
- public static final long SET = 0xFFFFFFFFL;
- private static final String LSRID = "lsrId";
- private static final String LABEL_RESOURCE_SERVICE_NULL = "Label Resource Service cannot be null";
- private static final String PCE_STORE_NULL = "PCE Store cannot be null";
- private static BasicPceccHandler crHandlerInstance = null;
- private LabelResourceService labelRsrcService;
- private DeviceService deviceService;
- private PceLabelStore pceStore;
- private PcepClientController clientController;
- private PcepLabelObject labelObj;
-
- /**
- * Initializes default values.
- */
- private BasicPceccHandler() {
- }
-
- /**
- * Returns single instance of this class.
- *
- * @return this class single instance
- */
- public static synchronized BasicPceccHandler getInstance() {
- if (crHandlerInstance == null) {
- crHandlerInstance = new BasicPceccHandler();
- }
- return crHandlerInstance;
- }
-
- /**
- * Initialization of label manager and pce store.
- *
- * @param labelRsrcService label resource service
- * @param deviceService device service
- * @param pceStore pce label store
- * @param clientController client controller
- */
- public void initialize(LabelResourceService labelRsrcService,
- DeviceService deviceService,
- PceLabelStore pceStore,
- PcepClientController clientController) {
- this.labelRsrcService = labelRsrcService;
- this.deviceService = deviceService;
- this.pceStore = pceStore;
- this.clientController = clientController;
- }
-
- /**
- * Allocates labels from local resource pool and configure these (IN and OUT) labels into devices.
- *
- * @param tunnel tunnel between ingress to egress
- * @return success or failure
- */
- public boolean allocateLabel(Tunnel tunnel) {
- long applyNum = 1;
- boolean isLastLabelToPush = false;
- Collection<LabelResource> labelRscList;
-
- checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
- checkNotNull(pceStore, PCE_STORE_NULL);
-
- List<Link> linkList = tunnel.path().links();
- if ((linkList != null) && (!linkList.isEmpty())) {
- // Sequence through reverse order to push local labels into devices
- // Generation of labels from egress to ingress
- for (ListIterator<Link> iterator = linkList.listIterator(linkList.size()); iterator.hasPrevious();) {
- Link link = iterator.previous();
- DeviceId dstDeviceId = link.dst().deviceId();
- DeviceId srcDeviceId = link.src().deviceId();
- labelRscList = labelRsrcService.applyFromDevicePool(dstDeviceId, applyNum);
- if ((labelRscList != null) && (!labelRscList.isEmpty())) {
- // Link label value is taken from destination device local pool.
- // [X]OUT---link----IN[Y]OUT---link-----IN[Z] where X, Y and Z are nodes.
- // Link label value is used as OUT and IN for both ends
- // (source and destination devices) of the link.
- // Currently only one label is allocated to a device (destination device).
- // So, no need to iterate through list
- Iterator<LabelResource> labelIterator = labelRscList.iterator();
- DefaultLabelResource defaultLabelResource = (DefaultLabelResource) labelIterator.next();
- LabelResourceId labelId = defaultLabelResource.labelResourceId();
- log.debug("Allocated local label: " + labelId.toString()
- + "to device: " + defaultLabelResource.deviceId().toString());
- PortNumber dstPort = link.dst().port();
-
- // Check whether this is last link label to push
- if (!iterator.hasPrevious()) {
- isLastLabelToPush = true;
- }
-
- try {
- // Push into destination device
- // Destination device IN port is link.dst().port()
- pushLocalLabels(dstDeviceId, labelId, dstPort, tunnel, false,
- Long.valueOf(LabelType.IN_LABEL.value), PcepLabelOp.ADD);
-
- // Push into source device
- // Source device OUT port will be link.dst().port(). Means its remote port used to send packet.
- pushLocalLabels(srcDeviceId, labelId, dstPort, tunnel, isLastLabelToPush,
- Long.valueOf(LabelType.OUT_LABEL.value), PcepLabelOp.ADD);
- } catch (PcepParseException e) {
- log.error("Failed to push local label for device {} or {} for tunnel {}.",
- dstDeviceId.toString(), srcDeviceId.toString(), tunnel.tunnelName().toString());
- }
-
- // Add or update pcecc tunnel info in pce store.
- updatePceccTunnelInfoInStore(srcDeviceId, dstDeviceId, labelId, dstPort,
- tunnel);
- } else {
- log.error("Unable to allocate label to device id {}.", dstDeviceId.toString());
- releaseLabel(tunnel);
- return false;
- }
- }
- } else {
- log.error("Tunnel {} is having empty links.", tunnel.toString());
- return false;
- }
- return true;
- }
-
- /**
- * Updates list of local labels of PCECC tunnel info in pce store.
- *
- * @param srcDeviceId source device in a link
- * @param dstDeviceId destination device in a link
- * @param labelId label id of a link
- * @param dstPort destination device port number of a link
- * @param tunnel tunnel
- */
- public void updatePceccTunnelInfoInStore(DeviceId srcDeviceId, DeviceId dstDeviceId, LabelResourceId labelId,
- PortNumber dstPort, Tunnel tunnel) {
- // First try to retrieve device from store and update its label id if it is exists,
- // otherwise add it
- boolean dstDeviceUpdated = false;
- boolean srcDeviceUpdated = false;
-
- List<LspLocalLabelInfo> lspLabelInfoList = pceStore.getTunnelInfo(tunnel.tunnelId());
- if ((lspLabelInfoList != null) && (!lspLabelInfoList.isEmpty())) {
- for (int i = 0; i < lspLabelInfoList.size(); ++i) {
- LspLocalLabelInfo lspLocalLabelInfo =
- lspLabelInfoList.get(i);
- LspLocalLabelInfo.Builder lspLocalLabelInfoBuilder = null;
- if (dstDeviceId.equals(lspLocalLabelInfo.deviceId())) {
- lspLocalLabelInfoBuilder = DefaultLspLocalLabelInfo.builder(lspLocalLabelInfo);
- lspLocalLabelInfoBuilder.inLabelId(labelId);
- // Destination device IN port will be link destination port
- lspLocalLabelInfoBuilder.inPort(dstPort);
- dstDeviceUpdated = true;
- } else if (srcDeviceId.equals(lspLocalLabelInfo.deviceId())) {
- lspLocalLabelInfoBuilder = DefaultLspLocalLabelInfo.builder(lspLocalLabelInfo);
- lspLocalLabelInfoBuilder.outLabelId(labelId);
- // Source device OUT port will be link destination (remote) port
- lspLocalLabelInfoBuilder.outPort(dstPort);
- srcDeviceUpdated = true;
- }
-
- // Update
- if ((lspLocalLabelInfoBuilder != null) && (dstDeviceUpdated || srcDeviceUpdated)) {
- lspLabelInfoList.set(i, lspLocalLabelInfoBuilder.build());
- }
- }
- }
-
- // If it is not found in store then add it to store
- if (!dstDeviceUpdated || !srcDeviceUpdated) {
- // If tunnel info itself not available then create new one, otherwise add node to list.
- if (lspLabelInfoList == null) {
- lspLabelInfoList = new LinkedList<>();
- }
-
- if (!dstDeviceUpdated) {
- LspLocalLabelInfo lspLocalLabelInfo = DefaultLspLocalLabelInfo.builder()
- .deviceId(dstDeviceId)
- .inLabelId(labelId)
- .outLabelId(null)
- .inPort(dstPort) // Destination device IN port will be link destination port
- .outPort(null)
- .build();
- lspLabelInfoList.add(lspLocalLabelInfo);
- }
-
- if (!srcDeviceUpdated) {
- LspLocalLabelInfo lspLocalLabelInfo = DefaultLspLocalLabelInfo.builder()
- .deviceId(srcDeviceId)
- .inLabelId(null)
- .outLabelId(labelId)
- .inPort(null)
- .outPort(dstPort) // Source device OUT port will be link destination (remote) port
- .build();
- lspLabelInfoList.add(lspLocalLabelInfo);
- }
-
- pceStore.addTunnelInfo(tunnel.tunnelId(), lspLabelInfoList);
- }
- }
-
- /**
- * Deallocates unused labels to device pools.
- *
- * @param tunnel tunnel between ingress to egress
- */
- public void releaseLabel(Tunnel tunnel) {
-
- checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
- checkNotNull(pceStore, PCE_STORE_NULL);
-
- Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create();
- List<LspLocalLabelInfo> lspLocalLabelInfoList = pceStore.getTunnelInfo(tunnel.tunnelId());
- if ((lspLocalLabelInfoList != null) && (!lspLocalLabelInfoList.isEmpty())) {
- for (Iterator<LspLocalLabelInfo> iterator = lspLocalLabelInfoList.iterator(); iterator.hasNext();) {
- LspLocalLabelInfo lspLocalLabelInfo = iterator.next();
- DeviceId deviceId = lspLocalLabelInfo.deviceId();
- LabelResourceId inLabelId = lspLocalLabelInfo.inLabelId();
- LabelResourceId outLabelId = lspLocalLabelInfo.outLabelId();
- PortNumber inPort = lspLocalLabelInfo.inPort();
- PortNumber outPort = lspLocalLabelInfo.outPort();
-
- try {
- // Push into device
- if ((outLabelId != null) && (outPort != null)) {
- pushLocalLabels(deviceId, outLabelId, outPort, tunnel, false,
- Long.valueOf(LabelType.OUT_LABEL.value), PcepLabelOp.REMOVE);
- }
-
- if ((inLabelId != null) && (inPort != null)) {
- pushLocalLabels(deviceId, inLabelId, inPort, tunnel, false,
- Long.valueOf(LabelType.IN_LABEL.value), PcepLabelOp.REMOVE);
- }
- } catch (PcepParseException e) {
- log.error("Failed to push local label for device {}for tunnel {}.", deviceId.toString(),
- tunnel.tunnelName().toString());
- }
-
- // List is stored from egress to ingress. So, using IN label id to release.
- // Only one local label is assigned to device (destination node)
- // and that is used as OUT label for source node.
- // No need to release label for last node in the list from pool because label was not allocated to
- // ingress node (source node).
- if ((iterator.hasNext()) && (inLabelId != null)) {
- LabelResource labelRsc = new DefaultLabelResource(deviceId, inLabelId);
- release.put(deviceId, labelRsc);
- }
- }
- }
-
- // Release from label pool
- if (!release.isEmpty()) {
- labelRsrcService.releaseToDevicePool(release);
- }
-
- pceStore.removeTunnelInfo(tunnel.tunnelId());
- }
-
- //Pushes local labels to the device which is specific to path [CR-case].
- private void pushLocalLabels(DeviceId deviceId, LabelResourceId labelId,
- PortNumber portNum, Tunnel tunnel,
- Boolean isBos, Long labelType, PcepLabelOp type) throws PcepParseException {
-
- checkNotNull(deviceId);
- checkNotNull(labelId);
- checkNotNull(portNum);
- checkNotNull(tunnel);
- checkNotNull(labelType);
- checkNotNull(type);
-
- PcepClient pc = getPcepClient(deviceId);
- if (pc == null) {
- log.error("PCEP client not found");
- return;
- }
-
- PcepLspObject lspObj;
- LinkedList<PcepLabelUpdate> labelUpdateList = new LinkedList<>();
- LinkedList<PcepLabelObject> labelObjects = new LinkedList<>();
- PcepSrpObject srpObj;
- PcepLabelDownload labelDownload = new PcepLabelDownload();
- LinkedList<PcepValueType> optionalTlv = new LinkedList<>();
-
- long portNo = portNum.toLong();
- portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo;
-
- optionalTlv.add(NexthopIPv4addressTlv.of((int) portNo));
-
- PcepLabelObject labelObj = pc.factory().buildLabelObject()
- .setOFlag(labelType == OUT_LABEL_TYPE ? true : false)
- .setOptionalTlv(optionalTlv)
- .setLabel((int) labelId.labelId())
- .build();
-
- /**
- * Check whether transit node or not. For transit node, label update message should include IN and OUT labels.
- * Hence store IN label object and next when out label comes add IN and OUT label objects and encode label
- * update message and send to specified client.
- */
- if (!deviceId.equals(tunnel.path().src().deviceId()) && !deviceId.equals(tunnel.path().dst().deviceId())) {
- //Device is transit node
- if (labelType == OUT_LABEL_TYPE) {
- //Store label object having IN label value
- this.labelObj = labelObj;
- return;
- }
- //Add IN label object
- labelObjects.add(this.labelObj);
- }
-
- //Add OUT label object in case of transit node
- labelObjects.add(labelObj);
-
- srpObj = getSrpObject(pc, type, false);
-
- String lspId = tunnel.annotations().value(PcepAnnotationKeys.LOCAL_LSP_ID);
- String plspId = tunnel.annotations().value(PcepAnnotationKeys.PLSP_ID);
- String tunnelIdentifier = tunnel.annotations().value(PcepAnnotationKeys.PCC_TUNNEL_ID);
-
- LinkedList<PcepValueType> tlvs = new LinkedList<>();
- StatefulIPv4LspIdentifiersTlv lspIdTlv = new StatefulIPv4LspIdentifiersTlv(((IpTunnelEndPoint) tunnel.src())
- .ip().getIp4Address().toInt(), Short.valueOf(lspId), Short.valueOf(tunnelIdentifier),
- ((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt(),
- ((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt());
- tlvs.add(lspIdTlv);
-
- if (tunnel.tunnelName().value() != null) {
- SymbolicPathNameTlv pathNameTlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes());
- tlvs.add(pathNameTlv);
- }
-
- boolean delegated = (tunnel.annotations().value(DELEGATE) == null) ? false
- : Boolean.valueOf(tunnel.annotations()
- .value(DELEGATE));
- boolean initiated = (tunnel.annotations().value(PCE_INIT) == null) ? false
- : Boolean.valueOf(tunnel.annotations()
- .value(PCE_INIT));
-
- lspObj = pc.factory().buildLspObject()
- .setRFlag(false)
- .setAFlag(true)
- .setDFlag(delegated)
- .setCFlag(initiated)
- .setPlspId(Integer.valueOf(plspId))
- .setOptionalTlv(tlvs)
- .build();
-
- labelDownload.setLabelList(labelObjects);
- labelDownload.setLspObject(lspObj);
- labelDownload.setSrpObject(srpObj);
-
- labelUpdateList.add(pc.factory().buildPcepLabelUpdateObject()
- .setLabelDownload(labelDownload)
- .build());
-
- PcepLabelUpdateMsg labelMsg = pc.factory().buildPcepLabelUpdateMsg()
- .setPcLabelUpdateList(labelUpdateList)
- .build();
-
- pc.sendMessage(labelMsg);
-
- //If isBos is true, label download is done along the LSP, send PCEP update message.
- if (isBos) {
- sendPcepUpdateMsg(pc, lspObj, tunnel);
- }
- }
-
- //Sends PCEP update message.
- private void sendPcepUpdateMsg(PcepClient pc, PcepLspObject lspObj, Tunnel tunnel) throws PcepParseException {
- LinkedList<PcepUpdateRequest> updateRequestList = new LinkedList<>();
- LinkedList<PcepValueType> subObjects = createEroSubObj(tunnel.path());
-
- if (subObjects == null) {
- log.error("ERO subjects not present");
- return;
- }
-
- // set PathSetupTypeTlv of SRP object
- LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
- LspType lspSigType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE));
- llOptionalTlv.add(new PathSetupTypeTlv(lspSigType.type()));
-
- PcepSrpObject srpObj = pc.factory().buildSrpObject()
- .setRFlag(false)
- .setSrpID(SrpIdGenerators.create())
- .setOptionalTlv(llOptionalTlv)
- .build();
-
- PcepEroObject eroObj = pc.factory().buildEroObject()
- .setSubObjects(subObjects)
- .build();
-
- float iBandwidth = 0;
- if (tunnel.annotations().value(BANDWIDTH) != null) {
- //iBandwidth = Float.floatToIntBits(Float.parseFloat(tunnel.annotations().value(BANDWIDTH)));
- iBandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH));
- }
- // build bandwidth object
- PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject()
- .setBandwidth(iBandwidth)
- .build();
- // build pcep attribute
- PcepAttribute pcepAttribute = pc.factory().buildPcepAttribute()
- .setBandwidthObject(bandwidthObject)
- .build();
-
- PcepMsgPath msgPath = pc.factory().buildPcepMsgPath()
- .setEroObject(eroObj)
- .setPcepAttribute(pcepAttribute)
- .build();
-
- PcepUpdateRequest updateReq = pc.factory().buildPcepUpdateRequest()
- .setSrpObject(srpObj)
- .setMsgPath(msgPath)
- .setLspObject(lspObj)
- .build();
-
- updateRequestList.add(updateReq);
-
- //TODO: P = 1 is it P flag in PCEP obj header
- PcepUpdateMsg updateMsg = pc.factory().buildUpdateMsg()
- .setUpdateRequestList(updateRequestList)
- .build();
-
- pc.sendMessage(updateMsg);
- }
-
- private LinkedList<PcepValueType> createEroSubObj(Path path) {
- LinkedList<PcepValueType> subObjects = new LinkedList<>();
- List<Link> links = path.links();
- ConnectPoint source = null;
- ConnectPoint destination = null;
- IpAddress ipDstAddress = null;
- IpAddress ipSrcAddress = null;
- PcepValueType subObj = null;
- long portNo;
-
- for (Link link : links) {
- source = link.src();
- if (!(source.equals(destination))) {
- //set IPv4SubObject for ERO object
- portNo = source.port().toLong();
- portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo;
- ipSrcAddress = Ip4Address.valueOf((int) portNo);
- subObj = new IPv4SubObject(ipSrcAddress.getIp4Address().toInt());
- subObjects.add(subObj);
- }
-
- destination = link.dst();
- portNo = destination.port().toLong();
- portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo;
- ipDstAddress = Ip4Address.valueOf((int) portNo);
- subObj = new IPv4SubObject(ipDstAddress.getIp4Address().toInt());
- subObjects.add(subObj);
- }
- return subObjects;
- }
-
- private PcepSrpObject getSrpObject(PcepClient pc, PcepLabelOp type, boolean bSFlag)
- throws PcepParseException {
- PcepSrpObject srpObj;
- boolean bRFlag = false;
-
- if (!type.equals(PcepLabelOp.ADD)) {
- // To cleanup labels, R bit is set
- bRFlag = true;
- }
-
- srpObj = pc.factory().buildSrpObject()
- .setRFlag(bRFlag)
- .setSFlag(bSFlag)
- .setSrpID(SrpIdGenerators.create())
- .build();
-
- return srpObj;
- }
-
- /**
- * Returns PCEP client.
- *
- * @return PCEP client
- */
- private PcepClient getPcepClient(DeviceId deviceId) {
- Device device = deviceService.getDevice(deviceId);
-
- // In future projections instead of annotations will be used to fetch LSR ID.
- String lsrId = device.annotations().value(LSRID);
- PcepClient pcc = clientController.getClient(PccId.pccId(IpAddress.valueOf(lsrId)));
- return pcc;
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/Controller.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/Controller.java
deleted file mode 100644
index f7f596c..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/Controller.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server.impl;
-
-import static org.onlab.util.Tools.groupedThreads;
-
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
-import java.net.InetSocketAddress;
-import java.util.Map;
-import java.util.LinkedList;
-import java.util.TreeMap;
-import java.util.List;
-import java.util.HashMap;
-import java.util.concurrent.Executors;
-
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.group.ChannelGroup;
-import org.jboss.netty.channel.group.DefaultChannelGroup;
-import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepCfg;
-import org.onosproject.pcep.server.PcepPacketStats;
-import org.onosproject.pcep.server.driver.PcepAgent;
-import org.onosproject.pcep.server.driver.PcepClientDriver;
-import org.onosproject.pcepio.protocol.PcepFactories;
-import org.onosproject.pcepio.protocol.PcepFactory;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The main controller class. Handles all setup and network listeners -
- * Distributed ownership control of pcc through IControllerRegistryService
- */
-public class Controller {
-
- private static final Logger log = LoggerFactory.getLogger(Controller.class);
-
- private static final PcepFactory FACTORY1 = PcepFactories.getFactory(PcepVersion.PCEP_1);
- private PcepCfg pcepConfig = new PcepConfig();
- private ChannelGroup cg;
-
- // Configuration options
- private int pcepPort = 4189;
- private int workerThreads = 10;
-
- // Start time of the controller
- private long systemStartTime;
-
- private PcepAgent agent;
-
- private Map<String, String> peerMap = new TreeMap<>();
- private Map<String, List<String>> pcepExceptionMap = new TreeMap<>();
- private Map<Integer, Integer> pcepErrorMsg = new TreeMap<>();
- private Map<String, Byte> sessionMap = new TreeMap<>();
- private LinkedList<String> pcepExceptionList = new LinkedList<String>();
-
- private NioServerSocketChannelFactory execFactory;
-
- // Perf. related configuration
- private static final int SEND_BUFFER_SIZE = 4 * 1024 * 1024;
-
- /**
- * pcep session information.
- *
- * @param peerId id of the peer with which the session is being formed
- * @param status pcep session status
- * @param sessionId pcep session id
- */
- public void peerStatus(String peerId, String status, byte sessionId) {
- if (peerId != null) {
- peerMap.put(peerId, status);
- sessionMap.put(peerId, sessionId);
- } else {
- log.debug("Peer Id is null");
- }
- }
-
- /**
- * Pcep session exceptions information.
- *
- * @param peerId id of the peer which has generated the exception
- * @param exception pcep session exception
- */
- public void peerExceptions(String peerId, String exception) {
- if (peerId != null) {
- pcepExceptionList.add(exception);
- pcepExceptionMap.put(peerId, pcepExceptionList);
- } else {
- log.debug("Peer Id is null");
- }
- if (pcepExceptionList.size() > 10) {
- pcepExceptionList.clear();
- pcepExceptionList.add(exception);
- pcepExceptionMap.put(peerId, pcepExceptionList);
- }
- }
-
- /**
- * Create a map of pcep error messages received.
- *
- * @param peerId id of the peer which has sent the error message
- * @param errorType error type of pcep error messgae
- * @param errValue error value of pcep error messgae
- */
- public void peerErrorMsg(String peerId, Integer errorType, Integer errValue) {
- if (peerId == null) {
- pcepErrorMsg.put(errorType, errValue);
- } else {
- if (pcepErrorMsg.size() > 10) {
- pcepErrorMsg.clear();
- }
- pcepErrorMsg.put(errorType, errValue);
- }
- }
-
- /**
- * Returns the pcep session details.
- *
- * @return pcep session details
- */
- public Map<String, Byte> mapSession() {
- return this.sessionMap;
- }
-
-
-
- /**
- * Returns factory version for processing pcep messages.
- *
- * @return instance of factory version
- */
- public PcepFactory getPcepMessageFactory1() {
- return FACTORY1;
- }
-
- /**
- * To get system start time.
- *
- * @return system start time in milliseconds
- */
- public long getSystemStartTime() {
- return (this.systemStartTime);
- }
-
- /**
- * Returns the list of pcep peers with session information.
- *
- * @return pcep peer information
- */
- public Map<String, String> mapPeer() {
- return this.peerMap;
- }
-
- /**
- * Returns the list of pcep exceptions per peer.
- *
- * @return pcep exceptions
- */
- public Map<String, List<String>> exceptionsMap() {
- return this.pcepExceptionMap;
- }
-
- /**
- * Returns the type and value of pcep error messages.
- *
- * @return pcep error message
- */
- public Map<Integer, Integer> mapErrorMsg() {
- return this.pcepErrorMsg;
- }
-
- /**
- * Tell controller that we're ready to accept pcc connections.
- */
- public void run() {
- try {
- final ServerBootstrap bootstrap = createServerBootStrap();
-
- bootstrap.setOption("reuseAddr", true);
- bootstrap.setOption("child.keepAlive", true);
- bootstrap.setOption("child.tcpNoDelay", true);
- bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE);
-
- ChannelPipelineFactory pfact = new PcepPipelineFactory(this);
-
- bootstrap.setPipelineFactory(pfact);
- InetSocketAddress sa = new InetSocketAddress(pcepPort);
- cg = new DefaultChannelGroup();
- cg.add(bootstrap.bind(sa));
- log.debug("Listening for PCC connection on {}", sa);
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
- }
-
- /**
- * Creates server boot strap.
- *
- * @return ServerBootStrap
- */
- private ServerBootstrap createServerBootStrap() {
- if (workerThreads == 0) {
- execFactory = new NioServerSocketChannelFactory(
- Executors.newCachedThreadPool(groupedThreads("onos/pcep", "boss-%d")),
- Executors.newCachedThreadPool(groupedThreads("onos/pcep", "worker-%d")));
- return new ServerBootstrap(execFactory);
- } else {
- execFactory = new NioServerSocketChannelFactory(
- Executors.newCachedThreadPool(groupedThreads("onos/pcep", "boss-%d")),
- Executors.newCachedThreadPool(groupedThreads("onos/pcep", "worker-%d")), workerThreads);
- return new ServerBootstrap(execFactory);
- }
- }
-
- /**
- * Initialize internal data structures.
- */
- public void init() {
- // These data structures are initialized here because other
- // module's startUp() might be called before ours
- this.systemStartTime = System.currentTimeMillis();
- }
-
- public Map<String, Long> getMemory() {
- Map<String, Long> m = new HashMap<>();
- Runtime runtime = Runtime.getRuntime();
- m.put("total", runtime.totalMemory());
- m.put("free", runtime.freeMemory());
- return m;
- }
-
- public Long getUptime() {
- RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
- return rb.getUptime();
- }
-
- /**
- * Creates instance of Pcep client.
- *
- * @param pccId pcc identifier
- * @param sessionID session id
- * @param pv pcep version
- * @param pktStats pcep packet statistics
- * @return instance of PcepClient
- */
- protected PcepClientDriver getPcepClientInstance(PccId pccId, int sessionID, PcepVersion pv,
- PcepPacketStats pktStats) {
- PcepClientDriver pcepClientDriver = new PcepClientImpl();
- pcepClientDriver.init(pccId, pv, pktStats);
- pcepClientDriver.setAgent(agent);
- return pcepClientDriver;
- }
-
- /**
- * Starts the pcep controller.
- *
- * @param ag Pcep agent
- */
- public void start(PcepAgent ag) {
- log.info("Started");
- this.agent = ag;
- this.init();
- this.run();
- }
-
- /**
- * Stops the pcep controller.
- */
- public void stop() {
- log.info("Stopped");
- execFactory.shutdown();
- cg.close();
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/LabelType.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/LabelType.java
deleted file mode 100644
index ca7cc7c..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/LabelType.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcep.server.impl;
-
-/**
- * Describes about Label type.
- */
-public enum LabelType {
- /**
- * Signifies in label id of a device.
- */
- OUT_LABEL(0),
-
- /**
- * Signifies out label id of a device.
- */
- IN_LABEL(1);
-
- int value;
-
- /**
- * Assign val with the value as the Label type.
- *
- * @param val Label type
- */
- LabelType(int val) {
- value = val;
- }
-
- /**
- * Returns value of Label type.
- *
- * @return label type
- */
- public byte type() {
- return (byte) value;
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PceccSrTeBeHandler.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PceccSrTeBeHandler.java
deleted file mode 100644
index 682f242..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PceccSrTeBeHandler.java
+++ /dev/null
@@ -1,585 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.pcep.server.PcepSyncStatus.IN_SYNC;
-import static org.onosproject.pcep.server.PcepSyncStatus.SYNCED;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.HashSet;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-
-import org.onlab.packet.IpAddress;
-import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
-import org.onosproject.incubator.net.tunnel.LabelStack;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.pcelabelstore.PcepLabelOp;
-import org.onosproject.pcelabelstore.api.PceLabelStore;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepClient;
-import org.onosproject.pcep.server.PcepClientController;
-import org.onosproject.pcep.server.SrpIdGenerators;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepFecObjectIPv4;
-import org.onosproject.pcepio.protocol.PcepFecObjectIPv4Adjacency;
-import org.onosproject.pcepio.protocol.PcepLabelObject;
-import org.onosproject.pcepio.protocol.PcepLabelUpdate;
-import org.onosproject.pcepio.protocol.PcepLabelUpdateMsg;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.onosproject.pcepio.types.PcepLabelMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
-
-/**
- * PCE SR-BE and SR-TE functionality.
- * SR-BE: Each node (PCC) is allocated a node-SID (label) by the PCECC. The PCECC sends PCLabelUpd to
- * update the label map of each node to all the nodes in the domain.
- * SR-TE: apart from node-SID, Adj-SID is used where each adjacency is allocated an Adj-SID (label) by the PCECC.
- * The PCECC sends PCLabelUpd to update the label map of each Adj to the corresponding nodes in the domain.
- */
-public final class PceccSrTeBeHandler {
- private static final Logger log = LoggerFactory.getLogger(PceccSrTeBeHandler.class);
-
- private static final String LABEL_RESOURCE_ADMIN_SERVICE_NULL = "Label Resource Admin Service cannot be null";
- private static final String LABEL_RESOURCE_SERVICE_NULL = "Label Resource Service cannot be null";
- private static final String PCE_STORE_NULL = "PCE Store cannot be null";
- private static final String DEVICE_ID_NULL = "Device-Id cannot be null";
- private static final String LSR_ID_NULL = "LSR-Id cannot be null";
- private static final String LINK_NULL = "Link cannot be null";
- private static final String PATH_NULL = "Path cannot be null";
- private static final String LSR_ID = "lsrId";
- private static PceccSrTeBeHandler srTeHandlerInstance = null;
- private LabelResourceAdminService labelRsrcAdminService;
- private LabelResourceService labelRsrcService;
- private DeviceService deviceService;
- private PcepClientController clientController;
- private PceLabelStore pceStore;
-
- /**
- * Initializes default values.
- */
- private PceccSrTeBeHandler() {
- }
-
- /**
- * Returns single instance of this class.
- *
- * @return this class single instance
- */
- public static synchronized PceccSrTeBeHandler getInstance() {
- if (srTeHandlerInstance == null) {
- srTeHandlerInstance = new PceccSrTeBeHandler();
- }
- return srTeHandlerInstance;
- }
-
- /**
- * Initialization of label manager interfaces and pce store.
- *
- * @param labelRsrcAdminService label resource admin service
- * @param labelRsrcService label resource service
- * @param clientController client controller
- * @param pceStore PCE label store
- * @param deviceService device service
- */
- public void initialize(LabelResourceAdminService labelRsrcAdminService,
- LabelResourceService labelRsrcService,
- PcepClientController clientController,
- PceLabelStore pceStore,
- DeviceService deviceService) {
- this.labelRsrcAdminService = labelRsrcAdminService;
- this.labelRsrcService = labelRsrcService;
- this.clientController = clientController;
- this.pceStore = pceStore;
- this.deviceService = deviceService;
- }
-
- /**
- * Reserves the global label pool.
- *
- * @param beginLabel minimum value of global label space
- * @param endLabel maximum value of global label space
- * @return success or failure
- */
- public boolean reserveGlobalPool(long beginLabel, long endLabel) {
- checkNotNull(labelRsrcAdminService, LABEL_RESOURCE_ADMIN_SERVICE_NULL);
- return labelRsrcAdminService.createGlobalPool(LabelResourceId.labelResourceId(beginLabel),
- LabelResourceId.labelResourceId(endLabel));
- }
-
- /**
- * Retrieve lsr-id from device annotation.
- *
- * @param deviceId specific device id from which lsr-id needs to be retrieved
- * @return lsr-id of a device
- */
- public String getLsrId(DeviceId deviceId) {
- checkNotNull(deviceId, DEVICE_ID_NULL);
- Device device = deviceService.getDevice(deviceId);
- if (device == null) {
- log.debug("Device is not available for device id {} in device service.", deviceId.toString());
- return null;
- }
-
- // Retrieve lsr-id from device
- if (device.annotations() == null) {
- log.debug("Device {} does not have annotation.", device.toString());
- return null;
- }
-
- String lsrId = device.annotations().value(LSR_ID);
- if (lsrId == null) {
- log.debug("The lsr-id of device {} is null.", device.toString());
- return null;
- }
- return lsrId;
- }
-
- /**
- * Allocates node label from global node label pool to specific device.
- * Configure this device with labels and lsrid mapping of all other devices and vice versa.
- *
- * @param specificDeviceId node label needs to be allocated to specific device
- * @param specificLsrId lsrid of specific device
- * @return success or failure
- */
- public boolean allocateNodeLabel(DeviceId specificDeviceId, String specificLsrId) {
- long applyNum = 1; // For each node only one node label
- LabelResourceId specificLabelId = null;
-
- checkNotNull(specificDeviceId, DEVICE_ID_NULL);
- checkNotNull(specificLsrId, LSR_ID_NULL);
- checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
- checkNotNull(pceStore, PCE_STORE_NULL);
-
- // Check whether node-label was already configured for this specific device.
- if (pceStore.getGlobalNodeLabel(specificDeviceId) != null) {
- log.debug("Node label was already configured for device {}.", specificDeviceId.toString());
- return false;
- }
-
- // The specificDeviceId is the new device and is not there in the pce store.
- // So, first generate its label and configure label and its lsr-id to it.
- Collection<LabelResource> result = labelRsrcService.applyFromGlobalPool(applyNum);
- if (!result.isEmpty()) {
- // Only one element (label-id) to retrieve
- Iterator<LabelResource> iterator = result.iterator();
- DefaultLabelResource defaultLabelResource = (DefaultLabelResource) iterator.next();
- specificLabelId = defaultLabelResource.labelResourceId();
- if (specificLabelId == null) {
- log.error("Unable to retrieve global node label for a device id {}.", specificDeviceId.toString());
- return false;
- }
- } else {
- log.error("Unable to allocate global node label for a device id {}.", specificDeviceId.toString());
- return false;
- }
-
- // store it
- pceStore.addGlobalNodeLabel(specificDeviceId, specificLabelId);
-
- // Push its label information into specificDeviceId
- PcepClient pcc = getPcepClient(specificDeviceId);
- try {
- pushGlobalNodeLabel(pcc,
- specificLabelId,
- IpAddress.valueOf(specificLsrId).getIp4Address().toInt(),
- PcepLabelOp.ADD,
- false);
- } catch (PcepParseException e) {
- log.error("Failed to push global node label for LSR {}.", specificLsrId.toString());
- }
-
- // Configure (node-label, lsr-id) mapping of each devices into specific device and vice versa.
- for (Map.Entry<DeviceId, LabelResourceId> element : pceStore.getGlobalNodeLabels().entrySet()) {
- DeviceId otherDevId = element.getKey();
-
- // Get lsr-id of a device
- String otherLsrId = getLsrId(otherDevId);
- if (otherLsrId == null) {
- log.error("The lsr-id of device id {} is null.", otherDevId.toString());
- releaseNodeLabel(specificDeviceId, specificLsrId);
- return false;
- }
-
- // Push to device
- // Push label information of specificDeviceId to otherDevId in list and vice versa.
- if (!otherDevId.equals(specificDeviceId)) {
- try {
- pushGlobalNodeLabel(getPcepClient(otherDevId),
- specificLabelId,
- IpAddress.valueOf(specificLsrId).getIp4Address().toInt(),
- PcepLabelOp.ADD,
- false);
-
- pushGlobalNodeLabel(pcc, element.getValue(),
- IpAddress.valueOf(otherLsrId).getIp4Address().toInt(),
- PcepLabelOp.ADD,
- false);
- } catch (PcepParseException e) {
- log.error("Failed to push global node label for LSR {} or LSR {}.", specificLsrId.toString(),
- otherLsrId.toString());
- }
- }
- }
- return true;
- }
-
- /**
- * Releases assigned node label of specific device from global node label pool and pce store.
- * and remove configured this node label from all other devices.
- *
- * @param specificDeviceId node label needs to be released for specific device
- * @param specificLsrId lsrid of specific device
- * @return success or failure
- */
- public boolean releaseNodeLabel(DeviceId specificDeviceId, String specificLsrId) {
- checkNotNull(specificDeviceId, DEVICE_ID_NULL);
- checkNotNull(specificLsrId, LSR_ID_NULL);
- checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
- checkNotNull(pceStore, PCE_STORE_NULL);
- boolean retValue = true;
-
- // Release node label entry of this specific device from all other devices
- // Retrieve node label of this specific device from store
- LabelResourceId labelId = pceStore.getGlobalNodeLabel(specificDeviceId);
- if (labelId == null) {
- log.error("Unable to retrieve label of a device id {} from store.", specificDeviceId.toString());
- return false;
- }
-
- // Go through all devices in the pce store and remove label entry from device
- for (Map.Entry<DeviceId, LabelResourceId> element : pceStore.getGlobalNodeLabels().entrySet()) {
- DeviceId otherDevId = element.getKey();
-
- // Remove this specific device label information from all other nodes except
- // this specific node where connection already lost.
- if (!specificDeviceId.equals(otherDevId)) {
- try {
- pushGlobalNodeLabel(getPcepClient(otherDevId),
- labelId,
- IpAddress.valueOf(specificLsrId).getIp4Address().toInt(),
- PcepLabelOp.REMOVE,
- false);
- } catch (PcepParseException e) {
- log.error("Failed to push global node label for LSR {}.", specificLsrId.toString());
- }
- }
- }
-
- // Release from label manager
- Set<LabelResourceId> release = new HashSet<>();
- release.add(labelId);
- if (!labelRsrcService.releaseToGlobalPool(release)) {
- log.error("Unable to release label id {} from label manager.", labelId.toString());
- retValue = false;
- }
-
- // Remove from store
- if (!pceStore.removeGlobalNodeLabel(specificDeviceId)) {
- log.error("Unable to remove global node label id {} from store.", labelId.toString());
- retValue = false;
- }
- return retValue;
- }
-
- /**
- * Allocates adjacency label to a link from local resource pool by a specific device id.
- *
- * @param link between devices
- * @return success or failure
- */
- public boolean allocateAdjacencyLabel(Link link) {
- long applyNum = 1; // Single label to each link.
- DeviceId srcDeviceId = link.src().deviceId();
- Collection<LabelResource> labelList;
-
- checkNotNull(link, LINK_NULL);
- checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
- checkNotNull(pceStore, PCE_STORE_NULL);
-
- // Checks whether adjacency label was already allocated
- LabelResourceId labelId = pceStore.getAdjLabel(link);
- if (labelId != null) {
- log.debug("Adjacency label {} was already allocated for a link {}.", labelId.toString(), link.toString());
- return false;
- }
-
- // Allocate adjacency label to a link from label manager.
- // Take label from source device pool to allocate.
- labelList = labelRsrcService.applyFromDevicePool(srcDeviceId, applyNum);
- if (labelList.isEmpty()) {
- log.error("Unable to allocate label to a device id {}.", srcDeviceId.toString());
- return false;
- }
-
- // Currently only one label to a device. So, no need to iterate through list
- Iterator<LabelResource> iterator = labelList.iterator();
- DefaultLabelResource defaultLabelResource = (DefaultLabelResource) iterator.next();
- labelId = defaultLabelResource.labelResourceId();
- if (labelId == null) {
- log.error("Unable to allocate label to a device id {}.", srcDeviceId.toString());
- return false;
- }
- log.debug("Allocated adjacency label {} to a link {}.", labelId.toString(), link.toString());
-
- // Push adjacency label to device
- try {
- pushAdjacencyLabel(getPcepClient(srcDeviceId), labelId, (int) link.src().port().toLong(),
- (int) link.dst().port().toLong(), PcepLabelOp.ADD);
- } catch (PcepParseException e) {
- log.error("Failed to push adjacency label for link {}-{}.", (int) link.src().port().toLong(),
- (int) link.dst().port().toLong());
- }
-
- // Save in store
- pceStore.addAdjLabel(link, labelId);
- return true;
- }
-
- /**
- * Releases unused adjacency labels from device pools.
- *
- * @param link between devices
- * @return success or failure
- */
- public boolean releaseAdjacencyLabel(Link link) {
- checkNotNull(link, LINK_NULL);
- checkNotNull(labelRsrcService, LABEL_RESOURCE_SERVICE_NULL);
- checkNotNull(pceStore, PCE_STORE_NULL);
- boolean retValue = true;
-
- // Retrieve link label from store
- LabelResourceId labelId = pceStore.getAdjLabel(link);
- if (labelId == null) {
- log.error("Unabel to retrieve label for a link {} from store.", link.toString());
- return false;
- }
-
- // Device
- DeviceId srcDeviceId = link.src().deviceId();
-
- // Release adjacency label from device
- try {
- pushAdjacencyLabel(getPcepClient(srcDeviceId), labelId, (int) link.src().port().toLong(),
- (int) link.dst().port().toLong(), PcepLabelOp.REMOVE);
- } catch (PcepParseException e) {
- log.error("Failed to push adjacency label for link {}-{}.", (int) link.src().port().toLong(),
- (int) link.dst().port().toLong());
- }
-
-
- // Release link label from label manager
- Multimap<DeviceId, LabelResource> release = ArrayListMultimap.create();
- DefaultLabelResource defaultLabelResource = new DefaultLabelResource(srcDeviceId, labelId);
- release.put(srcDeviceId, defaultLabelResource);
- if (!labelRsrcService.releaseToDevicePool(release)) {
- log.error("Unable to release label id {} from label manager.", labelId.toString());
- retValue = false;
- }
-
- // Remove adjacency label from store
- if (!pceStore.removeAdjLabel(link)) {
- log.error("Unable to remove adjacency label id {} from store.", labelId.toString());
- retValue = false;
- }
- return retValue;
- }
-
- /**
- * Computes label stack for a path.
- *
- * @param path lsp path
- * @return label stack
- */
- public LabelStack computeLabelStack(Path path) {
- checkNotNull(path, PATH_NULL);
- // Label stack is linked list to make labels in order.
- List<LabelResourceId> labelStack = new LinkedList<>();
- List<Link> linkList = path.links();
- if ((linkList != null) && (!linkList.isEmpty())) {
- // Path: [x] ---- [y] ---- [z]
- // For other than last link, add only source[x] device label.
- // For the last link, add both source[y] and destination[z] device labels.
- // For all links add adjacency label
- Link link = null;
- LabelResourceId nodeLabelId = null;
- LabelResourceId adjLabelId = null;
- DeviceId deviceId = null;
- for (Iterator<Link> iterator = linkList.iterator(); iterator.hasNext();) {
- link = iterator.next();
- // Add adjacency label for this link
- adjLabelId = pceStore.getAdjLabel(link);
- if (adjLabelId == null) {
- log.error("Adjacency label id is null for a link {}.", link.toString());
- return null;
- }
- labelStack.add(adjLabelId);
-
- deviceId = link.dst().deviceId();
- nodeLabelId = pceStore.getGlobalNodeLabel(deviceId);
- if (nodeLabelId == null) {
- log.error("Unable to find node label for a device id {} in store.", deviceId.toString());
- return null;
- }
- labelStack.add(nodeLabelId);
- }
- } else {
- log.debug("Empty link in path.");
- return null;
- }
- return new DefaultLabelStack(labelStack);
- }
-
- //Pushes node labels to the specified device.
- void pushGlobalNodeLabel(PcepClient pc, LabelResourceId labelId,
- int labelForNode, PcepLabelOp type, boolean isBos) throws PcepParseException {
-
- checkNotNull(pc);
- checkNotNull(labelId);
- checkNotNull(type);
-
- LinkedList<PcepLabelUpdate> labelUpdateList = new LinkedList<>();
- PcepFecObjectIPv4 fecObject = pc.factory().buildFecObjectIpv4()
- .setNodeID(labelForNode)
- .build();
-
- boolean bSFlag = false;
- if (pc.labelDbSyncStatus() == IN_SYNC && !isBos) {
- // Need to set sync flag in all messages till sync completes.
- bSFlag = true;
- }
-
- PcepSrpObject srpObj = getSrpObject(pc, type, bSFlag);
-
- //Global NODE-SID as label object
- PcepLabelObject labelObject = pc.factory().buildLabelObject()
- .setLabel((int) labelId.labelId())
- .build();
-
- PcepLabelMap labelMap = new PcepLabelMap();
- labelMap.setFecObject(fecObject);
- labelMap.setLabelObject(labelObject);
- labelMap.setSrpObject(srpObj);
-
- labelUpdateList.add(pc.factory().buildPcepLabelUpdateObject()
- .setLabelMap(labelMap)
- .build());
-
- PcepLabelUpdateMsg labelMsg = pc.factory().buildPcepLabelUpdateMsg()
- .setPcLabelUpdateList(labelUpdateList)
- .build();
- pc.sendMessage(labelMsg);
-
- if (isBos) {
- // Sync is completed.
- pc.setLabelDbSyncStatus(SYNCED);
- }
- }
-
- //Pushes adjacency labels to the specified device.
- void pushAdjacencyLabel(PcepClient pc, LabelResourceId labelId, int srcPortNo,
- int dstPortNo, PcepLabelOp type)
- throws PcepParseException {
-
- checkNotNull(pc);
- checkNotNull(labelId);
- checkNotNull(type);
-
- LinkedList<PcepLabelUpdate> labelUpdateList = new LinkedList<>();
- PcepFecObjectIPv4Adjacency fecAdjObject = pc.factory().buildFecIpv4Adjacency()
- .seRemoteIPv4Address(dstPortNo)
- .seLocalIPv4Address(srcPortNo)
- .build();
-
- boolean bSFlag = false;
- if (pc.labelDbSyncStatus() == IN_SYNC) {
- // Need to set sync flag in all messages till sync completes.
- bSFlag = true;
- }
-
- PcepSrpObject srpObj = getSrpObject(pc, type, bSFlag);
-
- //Adjacency label object
- PcepLabelObject labelObject = pc.factory().buildLabelObject()
- .setLabel((int) labelId.labelId())
- .build();
-
- PcepLabelMap labelMap = new PcepLabelMap();
- labelMap.setFecObject(fecAdjObject);
- labelMap.setLabelObject(labelObject);
- labelMap.setSrpObject(srpObj);
-
- labelUpdateList.add(pc.factory().buildPcepLabelUpdateObject()
- .setLabelMap(labelMap)
- .build());
-
- PcepLabelUpdateMsg labelMsg = pc.factory().buildPcepLabelUpdateMsg()
- .setPcLabelUpdateList(labelUpdateList)
- .build();
- pc.sendMessage(labelMsg);
- }
-
- private PcepSrpObject getSrpObject(PcepClient pc, PcepLabelOp type, boolean bSFlag)
- throws PcepParseException {
- PcepSrpObject srpObj;
- boolean bRFlag = false;
-
- if (!type.equals(PcepLabelOp.ADD)) {
- // To cleanup labels, R bit is set
- bRFlag = true;
- }
-
- srpObj = pc.factory().buildSrpObject()
- .setRFlag(bRFlag)
- .setSFlag(bSFlag)
- .setSrpID(SrpIdGenerators.create())
- .build();
-
- return srpObj;
- }
-
- /**
- * Returns PCEP client.
- *
- * @return PCEP client
- */
- private PcepClient getPcepClient(DeviceId deviceId) {
- Device device = deviceService.getDevice(deviceId);
-
- // In future projections instead of annotations will be used to fetch LSR ID.
- String lsrId = device.annotations().value(LSR_ID);
- PcepClient pcc = clientController.getClient(PccId.pccId(IpAddress.valueOf(lsrId)));
- return pcc;
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepChannelHandler.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepChannelHandler.java
deleted file mode 100644
index ce8b04b..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepChannelHandler.java
+++ /dev/null
@@ -1,724 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcep.server.impl;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.nio.channels.ClosedChannelException;
-import java.util.Collections;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.concurrent.RejectedExecutionException;
-
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelStateEvent;
-import org.jboss.netty.channel.ExceptionEvent;
-import org.jboss.netty.channel.MessageEvent;
-import org.jboss.netty.handler.timeout.IdleState;
-import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler;
-import org.jboss.netty.handler.timeout.IdleStateEvent;
-import org.jboss.netty.handler.timeout.IdleStateHandler;
-import org.jboss.netty.handler.timeout.ReadTimeoutException;
-import org.onlab.packet.IpAddress;
-import org.onosproject.pcep.server.ClientCapability;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepCfg;
-import org.onosproject.pcep.server.driver.PcepClientDriver;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepError;
-import org.onosproject.pcepio.protocol.PcepErrorInfo;
-import org.onosproject.pcepio.protocol.PcepErrorMsg;
-import org.onosproject.pcepio.protocol.PcepErrorObject;
-import org.onosproject.pcepio.protocol.PcepFactory;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepOpenMsg;
-import org.onosproject.pcepio.protocol.PcepOpenObject;
-import org.onosproject.pcepio.protocol.PcepType;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.onosproject.pcepio.types.IPv4RouterIdOfLocalNodeSubTlv;
-import org.onosproject.pcepio.types.NodeAttributesTlv;
-import org.onosproject.pcepio.types.PceccCapabilityTlv;
-import org.onosproject.pcepio.types.SrPceCapabilityTlv;
-import org.onosproject.pcepio.types.StatefulPceCapabilityTlv;
-import org.onosproject.pcepio.types.PcepErrorDetailInfo;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.onosproject.pcep.server.PcepSyncStatus.NOT_SYNCED;
-
-/**
- * Channel handler deals with the pcc client connection and dispatches
- * messages from client to the appropriate locations.
- */
-class PcepChannelHandler extends IdleStateAwareChannelHandler {
- static final byte DEADTIMER_MAXIMUM_VALUE = (byte) 0xFF;
- static final byte KEEPALIVE_MULTIPLE_FOR_DEADTIMER = 4;
- private static final Logger log = LoggerFactory.getLogger(PcepChannelHandler.class);
- private final Controller controller;
- private PcepClientDriver pc;
- private PccId thispccId;
- private Channel channel;
- private byte sessionId = 0;
- private byte keepAliveTime;
- private byte deadTime;
- private ClientCapability capability;
- private PcepPacketStatsImpl pcepPacketStats;
- static final int MAX_WRONG_COUNT_PACKET = 5;
- static final int BYTE_MASK = 0xFF;
-
- // State needs to be volatile because the HandshakeTimeoutHandler
- // needs to check if the handshake is complete
- private volatile ChannelState state;
- private String peerAddr;
- private SocketAddress address;
- private InetSocketAddress inetAddress;
- // When a pcc client with a ip addresss is found (i.e we already have a
- // connected client with the same ip), the new client is immediately
- // disconnected. At that point netty callsback channelDisconnected() which
- // proceeds to cleaup client state - we need to ensure that it does not cleanup
- // client state for the older (still connected) client
- private volatile Boolean duplicatePccIdFound;
-
- //Indicates the pcep version used by this pcc client
- protected PcepVersion pcepVersion;
- protected PcepFactory factory1;
-
- /**
- * Create a new unconnected PcepChannelHandler.
- * @param controller parent controller
- */
- PcepChannelHandler(Controller controller) {
- this.controller = controller;
- this.state = ChannelState.INIT;
- factory1 = controller.getPcepMessageFactory1();
- duplicatePccIdFound = Boolean.FALSE;
- pcepPacketStats = new PcepPacketStatsImpl();
- }
-
- /**
- * To disconnect a PCC.
- */
- public void disconnectClient() {
- pc.disconnectClient();
- }
-
- //*************************
- // Channel State Machine
- //*************************
-
- @Override
- public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
- channel = e.getChannel();
- log.info("PCC connected from {}", channel.getRemoteAddress());
-
- address = channel.getRemoteAddress();
- if (!(address instanceof InetSocketAddress)) {
- throw new IOException("Invalid peer connection.");
- }
-
- inetAddress = (InetSocketAddress) address;
- peerAddr = IpAddress.valueOf(inetAddress.getAddress()).toString();
-
- // Wait for open message from pcc client
- setState(ChannelState.OPENWAIT);
- controller.peerStatus(peerAddr, PcepCfg.State.OPENWAIT.toString(), sessionId);
- }
-
- @Override
- public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
- log.info("Pcc disconnected callback for pc:{}. Cleaning up ...", getClientInfoString());
- controller.peerStatus(peerAddr, PcepCfg.State.DOWN.toString(), sessionId);
-
- channel = e.getChannel();
- address = channel.getRemoteAddress();
- if (!(address instanceof InetSocketAddress)) {
- throw new IOException("Invalid peer connection.");
- }
-
- inetAddress = (InetSocketAddress) address;
- peerAddr = IpAddress.valueOf(inetAddress.getAddress()).toString();
-
- if (thispccId != null) {
- if (!duplicatePccIdFound) {
- // if the disconnected client (on this ChannelHandler)
- // was not one with a duplicate-dpid, it is safe to remove all
- // state for it at the controller. Notice that if the disconnected
- // client was a duplicate-ip, calling the method below would clear
- // all state for the original client (with the same ip),
- // which we obviously don't want.
- log.debug("{}:removal called", getClientInfoString());
- if (pc != null) {
- pc.removeConnectedClient();
- }
- } else {
- // A duplicate was disconnected on this ChannelHandler,
- // this is the same client reconnecting, but the original state was
- // not cleaned up - XXX check liveness of original ChannelHandler
- log.debug("{}:duplicate found", getClientInfoString());
- duplicatePccIdFound = Boolean.FALSE;
- }
- } else {
- log.warn("no pccip in channelHandler registered for " + "disconnected client {}", getClientInfoString());
- }
- }
-
- @Override
- public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
- PcepErrorMsg errMsg;
- log.info("exceptionCaught: " + e.toString());
-
- if (e.getCause() instanceof ReadTimeoutException) {
- if (ChannelState.OPENWAIT == state) {
- // When ReadTimeout timer is expired in OPENWAIT state, it is considered
- // OpenWait timer.
- errMsg = getErrorMsg(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_2);
- log.debug("Sending PCEP-ERROR message to PCC.");
- controller.peerExceptions(peerAddr, e.getCause().toString());
- channel.write(Collections.singletonList(errMsg));
- channel.close();
- state = ChannelState.INIT;
- return;
- } else if (ChannelState.KEEPWAIT == state) {
- // When ReadTimeout timer is expired in KEEPWAIT state, is is considered
- // KeepWait timer.
- errMsg = getErrorMsg(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_7);
- log.debug("Sending PCEP-ERROR message to PCC.");
- controller.peerExceptions(peerAddr, e.getCause().toString());
- channel.write(Collections.singletonList(errMsg));
- channel.close();
- state = ChannelState.INIT;
- return;
- }
- } else if (e.getCause() instanceof ClosedChannelException) {
- controller.peerExceptions(peerAddr, e.getCause().toString());
- log.debug("Channel for pc {} already closed", getClientInfoString());
- } else if (e.getCause() instanceof IOException) {
- controller.peerExceptions(peerAddr, e.getCause().toString());
- log.error("Disconnecting client {} due to IO Error: {}", getClientInfoString(), e.getCause().getMessage());
- if (log.isDebugEnabled()) {
- // still print stack trace if debug is enabled
- log.debug("StackTrace for previous Exception: ", e.getCause());
- }
- channel.close();
- } else if (e.getCause() instanceof PcepParseException) {
- controller.peerExceptions(peerAddr, e.getCause().toString());
- PcepParseException errMsgParse = (PcepParseException) e.getCause();
- byte errorType = errMsgParse.getErrorType();
- byte errorValue = errMsgParse.getErrorValue();
-
- if ((errorType == (byte) 0x0) && (errorValue == (byte) 0x0)) {
- processUnknownMsg();
- } else {
- errMsg = getErrorMsg(errorType, errorValue);
- log.debug("Sending PCEP-ERROR message to PCC.");
- channel.write(Collections.singletonList(errMsg));
- }
- } else if (e.getCause() instanceof RejectedExecutionException) {
- log.warn("Could not process message: queue full");
- controller.peerExceptions(peerAddr, e.getCause().toString());
- } else {
- log.error("Error while processing message from client " + getClientInfoString() + "state " + this.state);
- controller.peerExceptions(peerAddr, e.getCause().toString());
- channel.close();
- }
- }
-
- @Override
- public String toString() {
- return getClientInfoString();
- }
-
- @Override
- public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception {
- if (!isHandshakeComplete()) {
- return;
- }
-
- if (e.getState() == IdleState.READER_IDLE) {
- // When no message is received on channel for read timeout, then close
- // the channel
- log.info("Disconnecting client {} due to read timeout", getClientInfoString());
- ctx.getChannel().close();
- } else if (e.getState() == IdleState.WRITER_IDLE) {
- // Send keep alive message
- log.debug("Sending keep alive message due to IdleState timeout " + pc.toString());
- pc.sendMessage(Collections.singletonList(pc.factory().buildKeepaliveMsg().build()));
- }
- }
-
- @Override
- public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
- if (e.getMessage() instanceof List) {
- @SuppressWarnings("unchecked")
- List<PcepMessage> msglist = (List<PcepMessage>) e.getMessage();
- for (PcepMessage pm : msglist) {
- // Do the actual packet processing
- state.processPcepMessage(this, pm);
- }
- } else {
- state.processPcepMessage(this, (PcepMessage) e.getMessage());
- }
- }
-
- /**
- * Is this a state in which the handshake has completed.
- *
- * @return true if the handshake is complete
- */
- public boolean isHandshakeComplete() {
- return this.state.isHandshakeComplete();
- }
-
- /**
- * To set the handshake status.
- *
- * @param handshakeComplete value is handshake status
- */
- public void setHandshakeComplete(boolean handshakeComplete) {
- this.state.setHandshakeComplete(handshakeComplete);
- }
-
- /**
- * To handle the pcep message.
- *
- * @param m pcep message
- */
- private void dispatchMessage(PcepMessage m) {
- pc.handleMessage(m);
- }
-
- /**
- * Adds PCEP device configuration with capabilities once session is established.
- */
- private void addNode() {
- pc.addNode(pc);
- }
-
- /**
- * Deletes PCEP device configuration when session is disconnected.
- */
- private void deleteNode() {
- pc.deleteNode(pc.getPccId());
- }
-
- /**
- * Return a string describing this client based on the already available
- * information (ip address and/or remote socket).
- *
- * @return display string
- */
- private String getClientInfoString() {
- if (pc != null) {
- return pc.toString();
- }
- String channelString;
- if (channel == null || channel.getRemoteAddress() == null) {
- channelString = "?";
- } else {
- channelString = channel.getRemoteAddress().toString();
- }
- String pccIpString;
- // TODO : implement functionality to get pcc id string
- pccIpString = "?";
- return String.format("[%s PCCIP[%s]]", channelString, pccIpString);
- }
-
- /**
- * Update the channels state. Only called from the state machine.
- *
- * @param state
- */
- private void setState(ChannelState state) {
- this.state = state;
- }
-
- /**
- * Send handshake open message.
- *
- * @throws IOException,PcepParseException
- */
- private void sendHandshakeOpenMessage() throws IOException, PcepParseException {
- PcepOpenObject pcepOpenobj = factory1.buildOpenObject()
- .setSessionId(sessionId)
- .setKeepAliveTime(keepAliveTime)
- .setDeadTime(deadTime)
- .build();
- PcepMessage msg = factory1.buildOpenMsg()
- .setPcepOpenObj(pcepOpenobj)
- .build();
- log.debug("Sending OPEN message to {}", channel.getRemoteAddress());
- channel.write(Collections.singletonList(msg));
- }
-
- //Capability negotiation
- private void capabilityNegotiation(PcepOpenMsg pOpenmsg) {
- LinkedList<PcepValueType> tlvList = pOpenmsg.getPcepOpenObject().getOptionalTlv();
- boolean pceccCapability = false;
- boolean statefulPceCapability = false;
- boolean pcInstantiationCapability = false;
- boolean labelStackCapability = false;
- boolean srCapability = false;
-
- ListIterator<PcepValueType> listIterator = tlvList.listIterator();
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
-
- switch (tlv.getType()) {
- case PceccCapabilityTlv.TYPE:
- pceccCapability = true;
- if (((PceccCapabilityTlv) tlv).sBit()) {
- labelStackCapability = true;
- }
- break;
- case StatefulPceCapabilityTlv.TYPE:
- statefulPceCapability = true;
- StatefulPceCapabilityTlv stetefulPcCapTlv = (StatefulPceCapabilityTlv) tlv;
- if (stetefulPcCapTlv.getIFlag()) {
- pcInstantiationCapability = true;
- }
- break;
- case SrPceCapabilityTlv.TYPE:
- srCapability = true;
- break;
- default:
- continue;
- }
- }
- this.capability = new ClientCapability(pceccCapability, statefulPceCapability, pcInstantiationCapability,
- labelStackCapability, srCapability);
- }
-
- /**
- * Send keep alive message.
- *
- * @throws IOException when channel is disconnected
- * @throws PcepParseException while building keep alive message
- */
- private void sendKeepAliveMessage() throws IOException, PcepParseException {
- PcepMessage msg = factory1.buildKeepaliveMsg().build();
- log.debug("Sending KEEPALIVE message to {}", channel.getRemoteAddress());
- channel.write(Collections.singletonList(msg));
- }
-
- /**
- * Send error message and close channel with pcc.
- */
- private void sendErrMsgAndCloseChannel() {
- // TODO send error message
- //Remove PCEP device from topology
- deleteNode();
- channel.close();
- }
-
- /**
- * Send error message when an invalid message is received.
- *
- * @throws PcepParseException while building error message
- */
- private void sendErrMsgForInvalidMsg() throws PcepParseException {
- byte errorType = 0x02;
- byte errorValue = 0x00;
- PcepErrorMsg errMsg = getErrorMsg(errorType, errorValue);
- channel.write(Collections.singletonList(errMsg));
- }
-
- /**
- * Builds pcep error message based on error value and error type.
- *
- * @param errorType pcep error type
- * @param errorValue pcep error value
- * @return pcep error message
- * @throws PcepParseException while bulding error message
- */
- public PcepErrorMsg getErrorMsg(byte errorType, byte errorValue) throws PcepParseException {
- LinkedList<PcepErrorObject> llerrObj = new LinkedList<>();
- PcepErrorMsg errMsg;
-
- PcepErrorObject errObj = factory1.buildPcepErrorObject()
- .setErrorValue(errorValue)
- .setErrorType(errorType)
- .build();
-
- llerrObj.add(errObj);
-
- //If Error caught in other than Openmessage
- LinkedList<PcepError> llPcepErr = new LinkedList<>();
-
- PcepError pcepErr = factory1.buildPcepError()
- .setErrorObjList(llerrObj)
- .build();
-
- llPcepErr.add(pcepErr);
-
- PcepErrorInfo errInfo = factory1.buildPcepErrorInfo()
- .setPcepErrorList(llPcepErr)
- .build();
-
- errMsg = factory1.buildPcepErrorMsg()
- .setPcepErrorInfo(errInfo)
- .build();
- return errMsg;
- }
-
- /**
- * Process unknown pcep message received.
- *
- * @throws PcepParseException while building pcep error message
- */
- public void processUnknownMsg() throws PcepParseException {
- Date now = new Date();
- if (pcepPacketStats.wrongPacketCount() == 0) {
- pcepPacketStats.setTime(now.getTime());
- pcepPacketStats.addWrongPacket();
- sendErrMsgForInvalidMsg();
- }
-
- if (pcepPacketStats.wrongPacketCount() > 1) {
- Date lastest = new Date();
- pcepPacketStats.addWrongPacket();
- //converting to seconds
- if (((lastest.getTime() - pcepPacketStats.getTime()) / 1000) > 60) {
- now = lastest;
- pcepPacketStats.setTime(now.getTime());
- pcepPacketStats.resetWrongPacket();
- pcepPacketStats.addWrongPacket();
- } else if (((int) (lastest.getTime() - now.getTime()) / 1000) < 60) {
- if (MAX_WRONG_COUNT_PACKET <= pcepPacketStats.wrongPacketCount()) {
- //reset once wrong packet count reaches MAX_WRONG_COUNT_PACKET
- pcepPacketStats.resetWrongPacket();
- // max wrong packets received send error message and close the session
- sendErrMsgAndCloseChannel();
- }
- }
- }
- }
-
- /**
- * The state machine for handling the client/channel state. All state
- * transitions should happen from within the state machine (and not from other
- * parts of the code)
- */
- enum ChannelState {
- /**
- * Initial state before channel is connected.
- */
- INIT(false) {
-
- },
- /**
- * Once the session is established, wait for open message.
- */
- OPENWAIT(false) {
- @Override
- void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
-
- log.info("Message received in OPEN WAIT State");
-
- //check for open message
- if (m.getType() != PcepType.OPEN) {
- // When the message type is not open message increment the wrong packet statistics
- h.processUnknownMsg();
- log.debug("Message is not OPEN message");
- } else {
-
- h.pcepPacketStats.addInPacket();
- PcepOpenMsg pOpenmsg = (PcepOpenMsg) m;
- //Do Capability negotiation.
- h.capabilityNegotiation(pOpenmsg);
- log.debug("Sending handshake OPEN message");
- h.sessionId = pOpenmsg.getPcepOpenObject().getSessionId();
- h.pcepVersion = pOpenmsg.getPcepOpenObject().getVersion();
-
- //setting keepalive and deadTimer
- byte yKeepalive = pOpenmsg.getPcepOpenObject().getKeepAliveTime();
- byte yDeadTimer = pOpenmsg.getPcepOpenObject().getDeadTime();
- h.keepAliveTime = yKeepalive;
- if (yKeepalive < yDeadTimer) {
- h.deadTime = yDeadTimer;
- } else {
- if (DEADTIMER_MAXIMUM_VALUE > (yKeepalive * KEEPALIVE_MULTIPLE_FOR_DEADTIMER)) {
- h.deadTime = (byte) (yKeepalive * KEEPALIVE_MULTIPLE_FOR_DEADTIMER);
- } else {
- h.deadTime = DEADTIMER_MAXIMUM_VALUE;
- }
- }
-
- /*
- * If MPLS LSR id and PCEP session socket IP addresses are not same,
- * the MPLS LSR id will be encoded in separate TLV.
- * We always maintain session information based on LSR ids.
- * The socket IP is stored in channel.
- */
- LinkedList<PcepValueType> optionalTlvs = pOpenmsg.getPcepOpenObject().getOptionalTlv();
- if (optionalTlvs != null) {
- for (PcepValueType optionalTlv : optionalTlvs) {
- if (optionalTlv instanceof NodeAttributesTlv) {
- List<PcepValueType> subTlvs = ((NodeAttributesTlv) optionalTlv)
- .getllNodeAttributesSubTLVs();
- if (subTlvs == null) {
- break;
- }
- for (PcepValueType subTlv : subTlvs) {
- if (subTlv instanceof IPv4RouterIdOfLocalNodeSubTlv) {
- h.thispccId = PccId.pccId(IpAddress
- .valueOf(((IPv4RouterIdOfLocalNodeSubTlv) subTlv).getInt()));
- break;
- }
- }
- break;
- }
- }
- }
-
- if (h.thispccId == null) {
- final SocketAddress address = h.channel.getRemoteAddress();
- if (!(address instanceof InetSocketAddress)) {
- throw new IOException("Invalid client connection. Pcc is indentifed based on IP");
- }
-
- final InetSocketAddress inetAddress = (InetSocketAddress) address;
- h.thispccId = PccId.pccId(IpAddress.valueOf(inetAddress.getAddress()));
- }
-
- h.sendHandshakeOpenMessage();
- h.pcepPacketStats.addOutPacket();
- h.setState(KEEPWAIT);
- h.controller.peerStatus(h.peerAddr.toString(), PcepCfg.State.KEEPWAIT.toString(), h.sessionId);
- }
- }
- },
- /**
- * Once the open messages are exchanged, wait for keep alive message.
- */
- KEEPWAIT(false) {
- @Override
- void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
- log.info("Message received in KEEPWAIT state");
- //check for keep alive message
- if (m.getType() != PcepType.KEEP_ALIVE) {
- // When the message type is not keep alive message increment the wrong packet statistics
- h.processUnknownMsg();
- log.error("Message is not KEEPALIVE message");
- } else {
- // Set the client connected status
- h.pcepPacketStats.addInPacket();
- log.debug("sending keep alive message in KEEPWAIT state");
- h.pc = h.controller.getPcepClientInstance(h.thispccId, h.sessionId, h.pcepVersion,
- h.pcepPacketStats);
- //Get pc instance and set capabilities
- h.pc.setCapability(h.capability);
-
- // Initilialize DB sync status.
- h.pc.setLspDbSyncStatus(NOT_SYNCED);
- h.pc.setLabelDbSyncStatus(NOT_SYNCED);
-
- // set the status of pcc as connected
- h.pc.setConnected(true);
- h.pc.setChannel(h.channel);
-
- // set any other specific parameters to the pcc
- h.pc.setPcVersion(h.pcepVersion);
- h.pc.setPcSessionId(h.sessionId);
- h.pc.setPcKeepAliveTime(h.keepAliveTime);
- h.pc.setPcDeadTime(h.deadTime);
- int keepAliveTimer = h.keepAliveTime & BYTE_MASK;
- int deadTimer = h.deadTime & BYTE_MASK;
- if (0 == h.keepAliveTime) {
- h.deadTime = 0;
- }
- // handle keep alive and dead time
- if (keepAliveTimer != PcepPipelineFactory.DEFAULT_KEEP_ALIVE_TIME
- || deadTimer != PcepPipelineFactory.DEFAULT_DEAD_TIME) {
-
- h.channel.getPipeline().replace("idle", "idle",
- new IdleStateHandler(PcepPipelineFactory.TIMER, deadTimer, keepAliveTimer, 0));
- }
- log.debug("Dead timer : " + deadTimer);
- log.debug("Keep alive time : " + keepAliveTimer);
-
- //set the state handshake completion.
-
- h.sendKeepAliveMessage();
- h.pcepPacketStats.addOutPacket();
- h.setHandshakeComplete(true);
-
- if (!h.pc.connectClient()) {
- disconnectDuplicate(h);
- } else {
- h.setState(ESTABLISHED);
- h.controller.peerStatus(h.peerAddr.toString(), PcepCfg.State.ESTABLISHED.toString(), h.sessionId);
- //Session is established, add a network configuration with LSR id and device capabilities.
- h.addNode();
- }
- }
- }
- },
- /**
- * Once the keep alive messages are exchanged, the state is established.
- */
- ESTABLISHED(true) {
- @Override
- void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
-
- //h.channel.getPipeline().remove("waittimeout");
- log.debug("Message received in established state " + m.getType());
- //dispatch the message
- h.dispatchMessage(m);
- }
- };
- private boolean handshakeComplete;
-
- ChannelState(boolean handshakeComplete) {
- this.handshakeComplete = handshakeComplete;
- }
-
- void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
- // do nothing
- }
-
- /**
- * Is this a state in which the handshake has completed.
- *
- * @return true if the handshake is complete
- */
- public boolean isHandshakeComplete() {
- return this.handshakeComplete;
- }
-
- /**
- * Sets handshake complete status.
- *
- * @param handshakeComplete status of handshake
- */
- private void setHandshakeComplete(boolean handshakeComplete) {
- this.handshakeComplete = handshakeComplete;
- }
-
- protected void disconnectDuplicate(PcepChannelHandler h) {
- log.error("Duplicated Pcc IP or incompleted cleanup - " + "disconnecting channel {}",
- h.getClientInfoString());
- h.duplicatePccIdFound = Boolean.TRUE;
- h.channel.disconnect();
- }
-
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepClientControllerImpl.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepClientControllerImpl.java
deleted file mode 100644
index 2624804..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepClientControllerImpl.java
+++ /dev/null
@@ -1,1232 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server.impl;
-
-import com.google.common.collect.Sets;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpAddress;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
-import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.LabelStack;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.Tunnel.State;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultAnnotations.Builder;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.Path;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.link.LinkEvent;
-import org.onosproject.net.link.LinkListener;
-import org.onosproject.net.link.LinkService;
-import org.onosproject.pcelabelstore.PcepLabelOp;
-import org.onosproject.pcelabelstore.api.PceLabelStore;
-import org.onosproject.pcep.api.DeviceCapability;
-import org.onosproject.pcep.server.LspKey;
-import org.onosproject.pcep.server.LspType;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepClient;
-import org.onosproject.pcep.server.PcepClientController;
-import org.onosproject.pcep.server.PcepClientListener;
-import org.onosproject.pcep.server.PcepEventListener;
-import org.onosproject.pcep.server.PcepLspStatus;
-import org.onosproject.pcep.server.PcepNodeListener;
-import org.onosproject.pcep.server.SrpIdGenerators;
-import org.onosproject.pcep.server.driver.PcepAgent;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
-import org.onosproject.pcepio.protocol.PcepError;
-import org.onosproject.pcepio.protocol.PcepErrorInfo;
-import org.onosproject.pcepio.protocol.PcepErrorMsg;
-import org.onosproject.pcepio.protocol.PcepErrorObject;
-import org.onosproject.pcepio.protocol.PcepFactory;
-import org.onosproject.pcepio.protocol.PcepInitiateMsg;
-import org.onosproject.pcepio.protocol.PcepLspObject;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepNai;
-import org.onosproject.pcepio.protocol.PcepReportMsg;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.onosproject.pcepio.protocol.PcepStateReport;
-import org.onosproject.pcepio.types.PathSetupTypeTlv;
-import org.onosproject.pcepio.types.PcepNaiIpv4Adjacency;
-import org.onosproject.pcepio.types.PcepNaiIpv4NodeId;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.onosproject.pcepio.types.SrEroSubObject;
-import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
-import org.onosproject.pcepio.types.SymbolicPathNameTlv;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.concurrent.ConcurrentHashMap;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.pcep.server.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
-import static org.onosproject.pcep.server.LspType.WITH_SIGNALLING;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.BANDWIDTH;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.COST_TYPE;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.DELEGATE;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.LOCAL_LSP_ID;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.LSP_SIG_TYPE;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.PCC_TUNNEL_ID;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.PCE_INIT;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.PLSP_ID;
-import static org.onosproject.pcep.server.PcepLspSyncAction.REMOVE;
-import static org.onosproject.pcep.server.PcepLspSyncAction.SEND_UPDATE;
-import static org.onosproject.pcep.server.PcepLspSyncAction.UNSTABLE;
-import static org.onosproject.pcep.server.PcepSyncStatus.IN_SYNC;
-import static org.onosproject.pcep.server.PcepSyncStatus.NOT_SYNCED;
-import static org.onosproject.pcep.server.PcepSyncStatus.SYNCED;
-import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_TYPE_19;
-import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_VALUE_5;
-
-/**
- * Implementation of PCEP client controller.
- */
-@Component(immediate = true, service = PcepClientController.class)
-public class PcepClientControllerImpl implements PcepClientController {
-
- private static final Logger log = LoggerFactory.getLogger(PcepClientControllerImpl.class);
- private static final long IDENTIFIER_SET = 0x100000000L;
- private static final long SET = 0xFFFFFFFFL;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceService deviceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LinkService linkService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TunnelService tunnelService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigService netCfgService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected MastershipService mastershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LabelResourceAdminService labelRsrcAdminService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LabelResourceService labelRsrcService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PceLabelStore pceStore;
-
- protected ConcurrentHashMap<PccId, PcepClient> connectedClients =
- new ConcurrentHashMap<>();
-
- protected PcepClientAgent agent = new PcepClientAgent();
- protected Set<PcepClientListener> pcepClientListener = new HashSet<>();
-
- protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet();
- protected Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet();
-
- // LSR-id and device-id mapping for checking capability if L3 device is not
- // having its capability
- private Map<String, DeviceId> lsrIdDeviceIdMap = new HashMap<>();
-
- private final Controller ctrl = new Controller();
- public static final long GLOBAL_LABEL_SPACE_MIN = 4097;
- public static final long GLOBAL_LABEL_SPACE_MAX = 5121;
- private static final String LSRID = "lsrId";
- private static final String DEVICE_NULL = "Device-cannot be null";
- private static final String LINK_NULL = "Link-cannot be null";
-
- private BasicPceccHandler crHandler;
- private PceccSrTeBeHandler srTeHandler;
-
- private DeviceListener deviceListener = new InternalDeviceListener();
- private LinkListener linkListener = new InternalLinkListener();
- private InternalConfigListener cfgListener = new InternalConfigListener();
- private Map<Integer, Integer> pcepErrorMsg = new TreeMap<>();
-
- @Activate
- public void activate() {
- ctrl.start(agent);
- crHandler = BasicPceccHandler.getInstance();
- crHandler.initialize(labelRsrcService, deviceService, pceStore, this);
-
- srTeHandler = PceccSrTeBeHandler.getInstance();
- srTeHandler.initialize(labelRsrcAdminService, labelRsrcService, this, pceStore,
- deviceService);
-
- deviceService.addListener(deviceListener);
- linkService.addListener(linkListener);
- netCfgService.addListener(cfgListener);
-
- // Reserve global node pool
- if (!srTeHandler.reserveGlobalPool(GLOBAL_LABEL_SPACE_MIN, GLOBAL_LABEL_SPACE_MAX)) {
- log.debug("Global node pool was already reserved.");
- }
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- // Close all connected clients
- closeConnectedClients();
- deviceService.removeListener(deviceListener);
- linkService.removeListener(linkListener);
- netCfgService.removeListener(cfgListener);
- ctrl.stop();
- log.info("Stopped");
- }
-
- @Override
- public void peerErrorMsg(String peerId, Integer errorType, Integer errValue) {
- if (peerId == null) {
- pcepErrorMsg.put(errorType, errValue);
- } else {
- if (pcepErrorMsg.size() > 10) {
- pcepErrorMsg.clear();
- }
- pcepErrorMsg.put(errorType, errValue);
- }
- }
-
- @Override
- public Map<String, List<String>> getPcepExceptions() {
- return this.ctrl.exceptionsMap();
- }
-
- @Override
- public Map<Integer, Integer> getPcepErrorMsg() {
- return pcepErrorMsg;
- }
-
-
- @Override
- public Map<String, String> getPcepSessionMap() {
- return this.ctrl.mapPeer();
- }
-
- @Override
- public Map<String, Byte> getPcepSessionIdMap() {
- return this.ctrl.mapSession();
- }
-
- @Override
- public Collection<PcepClient> getClients() {
- return connectedClients.values();
- }
-
- @Override
- public PcepClient getClient(PccId pccId) {
- return connectedClients.get(pccId);
- }
-
- @Override
- public void addListener(PcepClientListener listener) {
- if (!pcepClientListener.contains(listener)) {
- this.pcepClientListener.add(listener);
- }
- }
-
- @Override
- public void removeListener(PcepClientListener listener) {
- this.pcepClientListener.remove(listener);
- }
-
- @Override
- public void addEventListener(PcepEventListener listener) {
- pcepEventListener.add(listener);
- }
-
- @Override
- public void removeEventListener(PcepEventListener listener) {
- pcepEventListener.remove(listener);
- }
-
- @Override
- public void writeMessage(PccId pccId, PcepMessage msg) {
- this.getClient(pccId).sendMessage(msg);
- }
-
- @Override
- public void addNodeListener(PcepNodeListener listener) {
- pcepNodeListener.add(listener);
- }
-
- @Override
- public void removeNodeListener(PcepNodeListener listener) {
- pcepNodeListener.remove(listener);
- }
-
- @Override
- public void processClientMessage(PccId pccId, PcepMessage msg) {
- PcepClient pc = getClient(pccId);
-
- switch (msg.getType()) {
- case NONE:
- break;
- case OPEN:
- break;
- case KEEP_ALIVE:
- break;
- case PATH_COMPUTATION_REQUEST:
- break;
- case PATH_COMPUTATION_REPLY:
- break;
- case NOTIFICATION:
- break;
- case ERROR:
- break;
- case INITIATE:
- if (!pc.capability().pcInstantiationCapability()) {
- pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), ERROR_TYPE_19,
- ERROR_VALUE_5)));
- }
- break;
- case UPDATE:
- if (!pc.capability().statefulPceCapability()) {
- pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), ERROR_TYPE_19,
- ERROR_VALUE_5)));
- }
- break;
- case LABEL_UPDATE:
- if (!pc.capability().pceccCapability()) {
- pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), ERROR_TYPE_19,
- ERROR_VALUE_5)));
- }
- break;
- case CLOSE:
- log.info("Sending Close Message to {" + pccId.toString() + "}");
- pc.sendMessage(Collections.singletonList(pc.factory().buildCloseMsg().build()));
- //now disconnect client
- pc.disconnectClient();
- break;
- case REPORT:
- //Only update the listener if respective capability is supported else send PCEP-ERR msg
- if (pc.capability().statefulPceCapability()) {
-
- ListIterator<PcepStateReport> listIterator = ((PcepReportMsg) msg).getStateReportList().listIterator();
- while (listIterator.hasNext()) {
- PcepStateReport stateRpt = listIterator.next();
- PcepLspObject lspObj = stateRpt.getLspObject();
- if (lspObj.getSFlag()) {
- if (pc.lspDbSyncStatus() != IN_SYNC) {
- log.debug("LSP DB sync started for PCC {}", pc.getPccId().id().toString());
- // Initialize LSP DB sync and temporary cache.
- pc.setLspDbSyncStatus(IN_SYNC);
- pc.initializeSyncMsgList(pccId);
- }
- // Store stateRpt in temporary cache.
- pc.addSyncMsgToList(pccId, stateRpt);
-
- // Don't send to provider as of now.
- continue;
- } else if (lspObj.getPlspId() == 0) {
- if (pc.lspDbSyncStatus() == IN_SYNC
- || pc.lspDbSyncStatus() == NOT_SYNCED) {
- // Set end of LSPDB sync.
- log.debug("LSP DB sync completed for PCC {}", pc.getPccId().id().toString());
- pc.setLspDbSyncStatus(SYNCED);
-
- // Call packet provider to initiate label DB sync (only if PCECC capable).
- if (pc.capability().pceccCapability()) {
- log.debug("Trigger label DB sync for PCC {}", pc.getPccId().id().toString());
- pc.setLabelDbSyncStatus(IN_SYNC);
- // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID.
- String lsrId = String.valueOf(pccId.ipAddress());
- DeviceId pccDeviceId = DeviceId.deviceId(lsrId);
- try {
- syncLabelDb(pccDeviceId);
- pc.setLabelDbSyncStatus(SYNCED);
- } catch (PcepParseException e) {
- log.error("Exception caught in sending label masg to PCC while in sync.");
- }
- } else {
- // If label db sync is not to be done, handle end of LSPDB sync actions.
- agent.analyzeSyncMsgList(pccId);
- }
- continue;
- }
- }
-
- PcepLspStatus pcepLspStatus = PcepLspStatus.values()[lspObj.getOFlag()];
- LspType lspType = getLspType(stateRpt.getSrpObject());
-
- // Download (or remove) labels for basic PCECC LSPs.
- if (lspType.equals(WITHOUT_SIGNALLING_AND_WITHOUT_SR)) {
- boolean isRemove = lspObj.getRFlag();
- Tunnel tunnel = null;
-
- if (isRemove || pcepLspStatus.equals(PcepLspStatus.GOING_UP)) {
- tunnel = getTunnel(lspObj);
- }
-
- if (tunnel != null) {
- if (isRemove) {
- crHandler.releaseLabel(tunnel);
- } else {
- crHandler.allocateLabel(tunnel);
- }
- }
- }
-
- // It's a usual report message while sync is not undergoing. So process it immediately.
- LinkedList<PcepStateReport> llPcRptList = new LinkedList<>();
- llPcRptList.add(stateRpt);
- PcepMessage pcReportMsg = pc.factory().buildReportMsg().setStateReportList((llPcRptList))
- .build();
- for (PcepEventListener l : pcepEventListener) {
- l.handleMessage(pccId, pcReportMsg);
- }
- }
- } else {
- // Send PCEP-ERROR message.
- pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(),
- ERROR_TYPE_19, ERROR_VALUE_5)));
- }
- break;
- case LABEL_RANGE_RESERV:
- break;
- case LS_REPORT: //TODO: need to handle LS report to add or remove node
- break;
- case MAX:
- break;
- case END:
- break;
- default:
- break;
- }
- }
-
- private LspType getLspType(PcepSrpObject srpObj) {
- LspType lspType = WITH_SIGNALLING;
-
- if (null != srpObj) {
- LinkedList<PcepValueType> llOptionalTlv = srpObj.getOptionalTlv();
- ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
-
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
- switch (tlv.getType()) {
- case PathSetupTypeTlv.TYPE:
- lspType = LspType.values()[Integer.valueOf(((PathSetupTypeTlv) tlv).getPst())];
- break;
- default:
- break;
- }
- }
- }
- return lspType;
- }
-
- private Tunnel getTunnel(PcepLspObject lspObj) {
- ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator();
- StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv = null;
- SymbolicPathNameTlv pathNameTlv = null;
- Tunnel tunnel = null;
- while (listTlvIterator.hasNext()) {
- PcepValueType tlv = listTlvIterator.next();
- switch (tlv.getType()) {
- case StatefulIPv4LspIdentifiersTlv.TYPE:
- ipv4LspIdenTlv = (StatefulIPv4LspIdentifiersTlv) tlv;
- break;
- case SymbolicPathNameTlv.TYPE:
- pathNameTlv = (SymbolicPathNameTlv) tlv;
- break;
- default:
- break;
- }
- }
- /*
- * Draft says: The LSP-IDENTIFIERS TLV MUST be included in the LSP object in PCRpt messages for
- * RSVP-signaled LSPs. For ONOS PCECC implementation, it is mandatory.
- */
- if (ipv4LspIdenTlv == null) {
- log.error("Stateful IPv4 identifier TLV is null in PCRpt msg.");
- return null;
- }
- IpTunnelEndPoint tunnelEndPointSrc = IpTunnelEndPoint
- .ipTunnelPoint(IpAddress.valueOf(ipv4LspIdenTlv.getIpv4IngressAddress()));
- IpTunnelEndPoint tunnelEndPointDst = IpTunnelEndPoint
- .ipTunnelPoint(IpAddress.valueOf(ipv4LspIdenTlv.getIpv4EgressAddress()));
- Collection<Tunnel> tunnelQueryResult = tunnelService.queryTunnel(tunnelEndPointSrc, tunnelEndPointDst);
-
- for (Tunnel tunnelObj : tunnelQueryResult) {
- if (tunnelObj.annotations().value(PLSP_ID) == null) {
- /*
- * PLSP_ID is null while Tunnel is created at PCE and PCInit msg carries it as 0. It is allocated by
- * PCC and in that case it becomes the first PCRpt msg from PCC for this LSP, and hence symbolic
- * path name must be carried in the PCRpt msg. Draft says: The SYMBOLIC-PATH-NAME TLV "MUST" be
- * included in the LSP object in the LSP State Report (PCRpt) message when during a given PCEP
- * session an LSP is "first" reported to a PCE.
- */
- if ((pathNameTlv != null)
- && Arrays.equals(tunnelObj.tunnelName().value().getBytes(), pathNameTlv.getValue())) {
- tunnel = tunnelObj;
- break;
- }
- continue;
- }
- if ((Integer.valueOf(tunnelObj.annotations().value(PLSP_ID)) == lspObj.getPlspId())) {
- if ((Integer
- .valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) == ipv4LspIdenTlv.getLspId())) {
- tunnel = tunnelObj;
- break;
- }
- }
- }
-
- if (tunnel == null || tunnel.annotations().value(PLSP_ID) != null) {
- return tunnel;
- }
-
- // The returned tunnel is used just for filling values in Label message. So manipulate locally
- // and return so that to allocate label, we don't need to wait for the tunnel in the "core"
- // to be updated, as that depends on listener mechanism and there may be timing/multi-threading issues.
- Builder annotationBuilder = DefaultAnnotations.builder();
- annotationBuilder.set(BANDWIDTH, tunnel.annotations().value(BANDWIDTH));
- annotationBuilder.set(COST_TYPE, tunnel.annotations().value(COST_TYPE));
- annotationBuilder.set(LSP_SIG_TYPE, tunnel.annotations().value(LSP_SIG_TYPE));
- annotationBuilder.set(PCE_INIT, tunnel.annotations().value(PCE_INIT));
- annotationBuilder.set(DELEGATE, tunnel.annotations().value(DELEGATE));
- annotationBuilder.set(PLSP_ID, String.valueOf(lspObj.getPlspId()));
- annotationBuilder.set(PCC_TUNNEL_ID, String.valueOf(ipv4LspIdenTlv.getTunnelId()));
- annotationBuilder.set(LOCAL_LSP_ID, tunnel.annotations().value(LOCAL_LSP_ID));
-
- Tunnel updatedTunnel = new DefaultTunnel(tunnel.providerId(), tunnel.src(),
- tunnel.dst(), tunnel.type(),
- tunnel.state(), tunnel.groupId(),
- tunnel.tunnelId(),
- tunnel.tunnelName(),
- tunnel.path(),
- tunnel.resource(),
- annotationBuilder.build());
-
- return updatedTunnel;
- }
-
- @Override
- public void closeConnectedClients() {
- PcepClient pc;
- for (PccId id : connectedClients.keySet()) {
- pc = getClient(id);
- pc.disconnectClient();
- }
- }
-
- /**
- * Returns pcep error message with specific error type and value.
- *
- * @param factory represents pcep factory
- * @param errorType pcep error type
- * @param errorValue pcep error value
- * @return pcep error message
- */
- public PcepErrorMsg getErrMsg(PcepFactory factory, byte errorType, byte errorValue) {
- LinkedList<PcepError> llPcepErr = new LinkedList<>();
-
- LinkedList<PcepErrorObject> llerrObj = new LinkedList<>();
- PcepErrorMsg errMsg;
-
- PcepErrorObject errObj = factory.buildPcepErrorObject().setErrorValue(errorValue).setErrorType(errorType)
- .build();
-
- llerrObj.add(errObj);
- PcepError pcepErr = factory.buildPcepError().setErrorObjList(llerrObj).build();
-
- llPcepErr.add(pcepErr);
-
- PcepErrorInfo errInfo = factory.buildPcepErrorInfo().setPcepErrorList(llPcepErr).build();
-
- errMsg = factory.buildPcepErrorMsg().setPcepErrorInfo(errInfo).build();
- return errMsg;
- }
-
- private boolean syncLabelDb(DeviceId deviceId) throws PcepParseException {
- checkNotNull(deviceId);
-
- DeviceId actualDevcieId = pceStore.getLsrIdDevice(deviceId.toString());
- if (actualDevcieId == null) {
- log.error("Device not available {}.", deviceId.toString());
- pceStore.addPccLsr(deviceId);
- return false;
- }
- PcepClient pc = connectedClients.get(PccId.pccId(IpAddress.valueOf(deviceId.toString())));
-
- Device specificDevice = deviceService.getDevice(actualDevcieId);
- if (specificDevice == null) {
- log.error("Unable to find device for specific device id {}.", actualDevcieId.toString());
- return false;
- }
-
- if (pceStore.getGlobalNodeLabel(actualDevcieId) != null) {
- Map<DeviceId, LabelResourceId> globalNodeLabelMap = pceStore.getGlobalNodeLabels();
-
- for (Entry<DeviceId, LabelResourceId> entry : globalNodeLabelMap.entrySet()) {
-
- // Convert from DeviceId to TunnelEndPoint
- Device srcDevice = deviceService.getDevice(entry.getKey());
-
- /*
- * If there is a slight difference in timing such that if device subsystem has removed the device but
- * PCE store still has it, just ignore such devices.
- */
- if (srcDevice == null) {
- continue;
- }
-
- String srcLsrId = srcDevice.annotations().value(LSRID);
- if (srcLsrId == null) {
- continue;
- }
-
- srTeHandler.pushGlobalNodeLabel(pc, entry.getValue(),
- IpAddress.valueOf(srcLsrId).getIp4Address().toInt(),
- PcepLabelOp.ADD, false);
- }
-
- Map<Link, LabelResourceId> adjLabelMap = pceStore.getAdjLabels();
- for (Entry<Link, LabelResourceId> entry : adjLabelMap.entrySet()) {
- if (entry.getKey().src().deviceId().equals(actualDevcieId)) {
- srTeHandler.pushAdjacencyLabel(pc,
- entry.getValue(),
- (int) entry.getKey().src().port().toLong(),
- (int) entry.getKey().dst().port().toLong(),
- PcepLabelOp.ADD
- );
- }
- }
- }
-
- srTeHandler.pushGlobalNodeLabel(pc, LabelResourceId.labelResourceId(0),
- 0, PcepLabelOp.ADD, true);
-
- log.debug("End of label DB sync for device {}", actualDevcieId);
-
- if (mastershipService.getLocalRole(specificDevice.id()) == MastershipRole.MASTER) {
- // Allocate node-label to this specific device.
- allocateNodeLabel(specificDevice);
-
- // Allocate adjacency label
- Set<Link> links = linkService.getDeviceEgressLinks(specificDevice.id());
- if (links != null) {
- for (Link link : links) {
- allocateAdjacencyLabel(link);
- }
- }
- }
- return true;
- }
-
- /**
- * Allocates node label to specific device.
- *
- * @param specificDevice device to which node label needs to be allocated
- */
- public void allocateNodeLabel(Device specificDevice) {
- checkNotNull(specificDevice, DEVICE_NULL);
-
- DeviceId deviceId = specificDevice.id();
-
- // Retrieve lsrId of a specific device
- if (specificDevice.annotations() == null) {
- log.debug("Device {} does not have annotations.", specificDevice.toString());
- return;
- }
-
- String lsrId = specificDevice.annotations().value(LSRID);
- if (lsrId == null) {
- log.debug("Unable to retrieve lsr-id of a device {}.", specificDevice.toString());
- return;
- }
-
- // Get capability config from netconfig
- DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(lsrId), DeviceCapability.class);
- if (cfg == null) {
- log.error("Unable to find corresponding capability for a lsrd {} from NetConfig.", lsrId);
- // Save info. When PCEP session is comes up then allocate node-label
- lsrIdDeviceIdMap.put(lsrId, specificDevice.id());
- return;
- }
-
- // Check whether device has SR-TE Capability
- if (cfg.labelStackCap()) {
- srTeHandler.allocateNodeLabel(deviceId, lsrId);
- }
- }
-
- /**
- * Releases node label of a specific device.
- *
- * @param specificDevice this device label and lsr-id information will be
- * released in other existing devices
- */
- public void releaseNodeLabel(Device specificDevice) {
- checkNotNull(specificDevice, DEVICE_NULL);
-
- DeviceId deviceId = specificDevice.id();
-
- // Retrieve lsrId of a specific device
- if (specificDevice.annotations() == null) {
- log.debug("Device {} does not have annotations.", specificDevice.toString());
- return;
- }
-
- String lsrId = specificDevice.annotations().value(LSRID);
- if (lsrId == null) {
- log.debug("Unable to retrieve lsr-id of a device {}.", specificDevice.toString());
- return;
- }
-
- // Get capability config from netconfig
- DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(lsrId), DeviceCapability.class);
- if (cfg == null) {
- log.error("Unable to find corresponding capabilty for a lsrd {} from NetConfig.", lsrId);
- return;
- }
-
- // Check whether device has SR-TE Capability
- if (cfg.labelStackCap()) {
- if (!srTeHandler.releaseNodeLabel(deviceId, lsrId)) {
- log.error("Unable to release node label for a device id {}.", deviceId.toString());
- }
- }
- }
-
- /**
- * Allocates adjacency label for a link.
- *
- * @param link link
- */
- public void allocateAdjacencyLabel(Link link) {
- checkNotNull(link, LINK_NULL);
-
- Device specificDevice = deviceService.getDevice(link.src().deviceId());
-
- // Retrieve lsrId of a specific device
- if (specificDevice.annotations() == null) {
- log.debug("Device {} does not have annotations.", specificDevice.toString());
- return;
- }
-
- String lsrId = specificDevice.annotations().value(LSRID);
- if (lsrId == null) {
- log.debug("Unable to retrieve lsr-id of a device {}.", specificDevice.toString());
- return;
- }
-
- // Get capability config from netconfig
- DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(lsrId), DeviceCapability.class);
- if (cfg == null) {
- log.error("Unable to find corresponding capabilty for a lsrd {} from NetConfig.", lsrId);
- // Save info. When PCEP session comes up then allocate adjacency
- // label
- if (lsrIdDeviceIdMap.get(lsrId) != null) {
- lsrIdDeviceIdMap.put(lsrId, specificDevice.id());
- }
- return;
- }
-
- // Check whether device has SR-TE Capability
- if (cfg.labelStackCap()) {
- srTeHandler.allocateAdjacencyLabel(link);
- }
- }
-
- /**
- * Releases allocated adjacency label of a link.
- *
- * @param link link
- */
- public void releaseAdjacencyLabel(Link link) {
- checkNotNull(link, LINK_NULL);
-
- Device specificDevice = deviceService.getDevice(link.src().deviceId());
-
- // Retrieve lsrId of a specific device
- if (specificDevice.annotations() == null) {
- log.debug("Device {} does not have annotations.", specificDevice.toString());
- return;
- }
-
- String lsrId = specificDevice.annotations().value(LSRID);
- if (lsrId == null) {
- log.debug("Unable to retrieve lsr-id of a device {}.", specificDevice.toString());
- return;
- }
-
- // Get capability config from netconfig
- DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(lsrId), DeviceCapability.class);
- if (cfg == null) {
- log.error("Unable to find corresponding capabilty for a lsrd {} from NetConfig.", lsrId);
- return;
- }
-
- // Check whether device has SR-TE Capability
- if (cfg.labelStackCap()) {
- if (!srTeHandler.releaseAdjacencyLabel(link)) {
- log.error("Unable to release adjacency labels for a link {}.", link.toString());
- }
- }
- }
-
- @Override
- public LabelStack computeLabelStack(Path path) {
- return srTeHandler.computeLabelStack(path);
- }
-
- @Override
- public boolean allocateLocalLabel(Tunnel tunnel) {
- return crHandler.allocateLabel(tunnel);
- }
-
- /**
- * Creates label stack for ERO object from network resource.
- *
- * @param labelStack label stack
- * @param path (hop list)
- * @return list of ERO subobjects
- */
- @Override
- public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) {
- checkNotNull(labelStack);
-
- LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
- Iterator<Link> links = path.links().iterator();
- LabelResourceId label = null;
- Link link = null;
- PcepValueType subObj = null;
- PcepNai nai = null;
- Device dstNode = null;
- long srcPortNo, dstPortNo;
-
- ListIterator<LabelResourceId> labelListIterator = labelStack.labelResources().listIterator();
- while (labelListIterator.hasNext()) {
- label = labelListIterator.next();
- link = links.next();
-
- srcPortNo = link.src().port().toLong();
- srcPortNo = ((srcPortNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? srcPortNo & SET : srcPortNo;
-
- dstPortNo = link.dst().port().toLong();
- dstPortNo = ((dstPortNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? dstPortNo & SET : dstPortNo;
-
- nai = new PcepNaiIpv4Adjacency((int) srcPortNo, (int) dstPortNo);
- subObj = new SrEroSubObject(PcepNaiIpv4Adjacency.ST_TYPE, false, false, false, true, (int) label.labelId(),
- nai);
- llSubObjects.add(subObj);
-
- dstNode = deviceService.getDevice(link.dst().deviceId());
- nai = new PcepNaiIpv4NodeId(Ip4Address.valueOf(dstNode.annotations().value(LSRID)).toInt());
-
- if (!labelListIterator.hasNext()) {
- log.error("Malformed label stack.");
- }
- label = labelListIterator.next();
- subObj = new SrEroSubObject(PcepNaiIpv4NodeId.ST_TYPE, false, false, false, true, (int) label.labelId(),
- nai);
- llSubObjects.add(subObj);
- }
- return llSubObjects;
- }
-
- /**
- * Implementation of an Pcep Agent which is responsible for
- * keeping track of connected clients and the state in which
- * they are.
- */
- public class PcepClientAgent implements PcepAgent {
-
- private final Logger log = LoggerFactory.getLogger(PcepClientAgent.class);
-
- @Override
- public boolean addConnectedClient(PccId pccId, PcepClient pc) {
-
- if (connectedClients.get(pccId) != null) {
- log.error("Trying to add connectedClient but found a previous "
- + "value for pcc ip: {}", pccId.toString());
- return false;
- } else {
- log.debug("Added Client {}", pccId.toString());
- connectedClients.put(pccId, pc);
- for (PcepClientListener l : pcepClientListener) {
- l.clientConnected(pccId);
- }
- return true;
- }
- }
-
- @Override
- public boolean validActivation(PccId pccId) {
- if (connectedClients.get(pccId) == null) {
- log.error("Trying to activate client but is not in "
- + "connected client: pccIp {}. Aborting ..", pccId.toString());
- return false;
- }
- return true;
- }
-
- @Override
- public void removeConnectedClient(PccId pccId) {
-
- connectedClients.remove(pccId);
- for (PcepClientListener l : pcepClientListener) {
- log.warn("Removal for {}", pccId.toString());
- l.clientDisconnected(pccId);
- }
- }
-
- @Override
- public void processPcepMessage(PccId pccId, PcepMessage m) {
- processClientMessage(pccId, m);
- }
-
- @Override
- public void addNode(PcepClient pc) {
- for (PcepNodeListener l : pcepNodeListener) {
- l.addDevicePcepConfig(pc);
- }
- }
-
- @Override
- public void deleteNode(PccId pccId) {
- for (PcepNodeListener l : pcepNodeListener) {
- l.deleteDevicePcepConfig(pccId);
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- public boolean analyzeSyncMsgList(PccId pccId) {
- PcepClient pc = getClient(pccId);
- /*
- * PLSP_ID is null while tunnel is created at PCE and PCInit msg carries it as 0. It is allocated by PCC and
- * in that case it becomes the first PCRpt msg from PCC for this LSP, and hence symbolic path name must be
- * carried in the PCRpt msg. Draft says: The SYMBOLIC-PATH-NAME TLV "MUST" be included in the LSP object in
- * the LSP State Report (PCRpt) message when during a given PCEP session an LSP is "first" reported to a
- * PCE. So two separate lists with separate keys are maintained.
- */
- Map<LspKey, Tunnel> preSyncLspDbByKey = new HashMap<>();
- Map<String, Tunnel> preSyncLspDbByName = new HashMap<>();
-
- // Query tunnel service and fetch all the tunnels with this PCC as ingress.
- // Organize into two maps, with LSP key if known otherwise with symbolic path name, for quick search.
- Collection<Tunnel> queriedTunnels = tunnelService.queryTunnel(Tunnel.Type.MPLS);
- for (Tunnel tunnel : queriedTunnels) {
- if (((IpTunnelEndPoint) tunnel.src()).ip().equals(pccId.ipAddress())) {
- String pLspId = tunnel.annotations().value(PLSP_ID);
- if (pLspId != null) {
- String localLspId = tunnel.annotations().value(LOCAL_LSP_ID);
- checkNotNull(localLspId);
- LspKey lspKey = new LspKey(Integer.valueOf(pLspId), Short.valueOf(localLspId));
- preSyncLspDbByKey.put(lspKey, tunnel);
- } else {
- preSyncLspDbByName.put(tunnel.tunnelName().value(), tunnel);
- }
- }
- }
-
- List<PcepStateReport> syncStateRptList = pc.getSyncMsgList(pccId);
- if (syncStateRptList == null) {
- // When there are no LSPs to sync, directly end-of-sync PCRpt will come and the
- // list will be null.
- syncStateRptList = Collections.EMPTY_LIST;
- log.debug("No LSPs reported from PCC during sync.");
- }
-
- Iterator<PcepStateReport> stateRptListIterator = syncStateRptList.iterator();
-
- // For every report, fetch PLSP id, local LSP id and symbolic path name from the message.
- while (stateRptListIterator.hasNext()) {
- PcepStateReport stateRpt = stateRptListIterator.next();
- Tunnel tunnel = null;
-
- PcepLspObject lspObj = stateRpt.getLspObject();
- ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator();
- StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv = null;
- SymbolicPathNameTlv pathNameTlv = null;
-
- while (listTlvIterator.hasNext()) {
- PcepValueType tlv = listTlvIterator.next();
- switch (tlv.getType()) {
- case StatefulIPv4LspIdentifiersTlv.TYPE:
- ipv4LspIdenTlv = (StatefulIPv4LspIdentifiersTlv) tlv;
- break;
-
- case SymbolicPathNameTlv.TYPE:
- pathNameTlv = (SymbolicPathNameTlv) tlv;
- break;
-
- default:
- break;
- }
- }
-
- if (ipv4LspIdenTlv == null) {
- return false;
- }
-
- LspKey lspKeyOfRpt = new LspKey(lspObj.getPlspId(), ipv4LspIdenTlv.getLspId());
- tunnel = preSyncLspDbByKey.get(lspKeyOfRpt);
- // PCE tunnel is matched with PCRpt LSP. Now delete it from the preSyncLspDb list as the residual
- // non-matching list will be processed at the end.
- if (tunnel != null) {
- preSyncLspDbByKey.remove(lspKeyOfRpt);
- } else if (pathNameTlv != null) {
- tunnel = preSyncLspDbByName.get(Arrays.toString(pathNameTlv.getValue()));
- if (tunnel != null) {
- preSyncLspDbByName.remove(tunnel.tunnelName().value());
- }
- }
-
- if (tunnel == null) {
- // If remove flag is set, and tunnel is not known to PCE, ignore it.
- if (lspObj.getCFlag() && !lspObj.getRFlag()) {
- // For initiated LSP, need to send PCInit delete msg.
- try {
- PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(SrpIdGenerators.create())
- .setRFlag(true).build();
- PcInitiatedLspRequest releaseLspRequest = pc.factory().buildPcInitiatedLspRequest()
- .setLspObject(lspObj).setSrpObject(srpobj).build();
- LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList
- = new LinkedList<PcInitiatedLspRequest>();
- llPcInitiatedLspRequestList.add(releaseLspRequest);
-
- PcepInitiateMsg pcInitiateMsg = pc.factory().buildPcepInitiateMsg()
- .setPcInitiatedLspRequestList(llPcInitiatedLspRequestList).build();
-
- pc.sendMessage(Collections.singletonList(pcInitiateMsg));
- } catch (PcepParseException e) {
- log.error("Exception occured while sending initiate delete message {}", e.getMessage());
- }
- continue;
- }
- }
-
- if (!lspObj.getCFlag()) {
- // For learned LSP process both add/update PCRpt.
- LinkedList<PcepStateReport> llPcRptList = new LinkedList<>();
- llPcRptList.add(stateRpt);
- PcepMessage pcReportMsg = pc.factory().buildReportMsg().setStateReportList((llPcRptList))
- .build();
-
- for (PcepEventListener l : pcepEventListener) {
- l.handleMessage(pccId, pcReportMsg);
- }
- continue;
- }
-
- // Implied that tunnel != null and lspObj.getCFlag() is set
- // State different for PCC sent LSP and PCE known LSP, send PCUpd msg.
- State tunnelState = PcepLspStatus
- .getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]);
-
- if (tunnel != null && tunnelState != tunnel.state()) {
- for (PcepEventListener l : pcepEventListener) {
- l.handleEndOfSyncAction(tunnel, SEND_UPDATE);
- }
- }
- }
-
- // Check which tunnels are extra at PCE that were not reported by PCC.
- Map<Object, Tunnel> preSyncLspDb = (Map) preSyncLspDbByKey;
- handleResidualTunnels(preSyncLspDb);
- preSyncLspDbByKey = null;
-
- preSyncLspDb = (Map) preSyncLspDbByName;
- handleResidualTunnels(preSyncLspDb);
- preSyncLspDbByName = null;
- preSyncLspDb = null;
-
- pc.removeSyncMsgList(pccId);
- return true;
- }
-
- /*
- * Go through the tunnels which are known by PCE but were not reported by PCC during LSP DB sync and take
- * appropriate actions.
- */
- private void handleResidualTunnels(Map<Object, Tunnel> preSyncLspDb) {
- for (Tunnel pceExtraTunnel : preSyncLspDb.values()) {
- if (pceExtraTunnel.annotations().value(PCE_INIT) == null
- || "false".equalsIgnoreCase(pceExtraTunnel.annotations().value(PCE_INIT))) {
- // PCC initiated tunnels should be removed from tunnel store.
- for (PcepEventListener l : pcepEventListener) {
- l.handleEndOfSyncAction(pceExtraTunnel, REMOVE);
- }
- } else {
- // PCE initiated tunnels should be initiated again.
- for (PcepEventListener l : pcepEventListener) {
- l.handleEndOfSyncAction(pceExtraTunnel, UNSTABLE);
- }
- }
- }
- }
- }
-
- /*
- * Handle device events.
- */
- private class InternalDeviceListener implements DeviceListener {
- @Override
- public void event(DeviceEvent event) {
- Device specificDevice = event.subject();
- if (specificDevice == null) {
- log.error("Unable to find device from device event.");
- return;
- }
-
- switch (event.type()) {
-
- case DEVICE_ADDED:
- // Node-label allocation is being done during Label DB Sync.
- // So, when device is detected, no need to do node-label
- // allocation.
- String lsrId = specificDevice.annotations().value(LSRID);
- if (lsrId != null) {
- pceStore.addLsrIdDevice(lsrId, specificDevice.id());
-
- // Search in failed DB sync store. If found, trigger label DB sync.
- DeviceId pccDeviceId = DeviceId.deviceId(lsrId);
- if (pceStore.hasPccLsr(pccDeviceId)) {
- log.debug("Continue to perform label DB sync for device {}.", pccDeviceId.toString());
- try {
- syncLabelDb(pccDeviceId);
- } catch (PcepParseException e) {
- log.error("Exception caught in sending label masg to PCC while in sync.");
- }
- pceStore.removePccLsr(pccDeviceId);
- }
- }
- break;
-
- case DEVICE_REMOVED:
- // Release node-label
- if (mastershipService.getLocalRole(specificDevice.id()) == MastershipRole.MASTER) {
- releaseNodeLabel(specificDevice);
- }
-
- if (specificDevice.annotations().value(LSRID) != null) {
- pceStore.removeLsrIdDevice(specificDevice.annotations().value(LSRID));
- }
- break;
-
- default:
- break;
- }
- }
- }
-
- /*
- * Handle link events.
- */
- private class InternalLinkListener implements LinkListener {
- @Override
- public void event(LinkEvent event) {
- Link link = event.subject();
-
- switch (event.type()) {
-
- case LINK_ADDED:
- // Allocate adjacency label
- if (mastershipService.getLocalRole(link.src().deviceId()) == MastershipRole.MASTER) {
- allocateAdjacencyLabel(link);
- }
- break;
-
- case LINK_REMOVED:
- // Release adjacency label
- if (mastershipService.getLocalRole(link.src().deviceId()) == MastershipRole.MASTER) {
- releaseAdjacencyLabel(link);
- }
- break;
-
- default:
- break;
- }
- }
- }
-
- private class InternalConfigListener implements NetworkConfigListener {
-
- @Override
- public void event(NetworkConfigEvent event) {
-
- if ((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED)
- && event.configClass().equals(DeviceCapability.class)) {
-
- DeviceId deviceIdLsrId = (DeviceId) event.subject();
- String lsrId = deviceIdLsrId.toString();
- DeviceId deviceId = lsrIdDeviceIdMap.get(lsrId);
- if (deviceId == null) {
- log.debug("Unable to find device id for a lsr-id {} from lsr-id and device-id map.", lsrId);
- return;
- }
-
- DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(lsrId), DeviceCapability.class);
- if (cfg == null) {
- log.error("Unable to find corresponding capabilty for a lsrd {}.", lsrId);
- return;
- }
-
- if (cfg.labelStackCap()) {
- if (mastershipService.getLocalRole(deviceId) == MastershipRole.MASTER) {
- // Allocate node-label
- srTeHandler.allocateNodeLabel(deviceId, lsrId);
-
- // Allocate adjacency label to links which are
- // originated from this specific device id
- Set<Link> links = linkService.getDeviceEgressLinks(deviceId);
- for (Link link : links) {
- if (!srTeHandler.allocateAdjacencyLabel(link)) {
- return;
- }
- }
- }
- }
- // Remove lsrId info from map
- lsrIdDeviceIdMap.remove(lsrId);
- }
- }
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepClientImpl.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepClientImpl.java
deleted file mode 100644
index 7e52c19..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepClientImpl.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcep.server.impl;
-
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.RejectedExecutionException;
-
-import org.jboss.netty.channel.Channel;
-import org.onlab.packet.IpAddress;
-import org.onosproject.pcep.server.ClientCapability;
-import org.onosproject.pcep.server.LspKey;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepClient;
-import org.onosproject.pcep.server.PcepPacketStats;
-import org.onosproject.pcep.server.PcepSyncStatus;
-import org.onosproject.pcep.server.driver.PcepAgent;
-import org.onosproject.pcep.server.driver.PcepClientDriver;
-import org.onosproject.pcepio.protocol.PcepFactories;
-import org.onosproject.pcepio.protocol.PcepFactory;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepStateReport;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * An abstract representation of an OpenFlow switch. Can be extended by others
- * to serve as a base for their vendor specific representation of a switch.
- */
-public class PcepClientImpl implements PcepClientDriver {
-
- protected final Logger log = LoggerFactory.getLogger(PcepClientImpl.class);
-
- private static final String SHUTDOWN_MSG = "Worker has already been shutdown";
-
- private Channel channel;
- protected String channelId;
-
- private boolean connected;
- protected boolean startDriverHandshakeCalled;
- protected boolean isHandShakeComplete;
- private PcepSyncStatus lspDbSyncStatus;
- private PcepSyncStatus labelDbSyncStatus;
- private PccId pccId;
- private PcepAgent agent;
-
- private ClientCapability capability;
- private PcepVersion pcepVersion;
- private byte keepAliveTime;
- private byte deadTime;
- private byte sessionId;
- private PcepPacketStatsImpl pktStats;
- private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>();
- private Map<PccId, List<PcepStateReport>> syncRptCache = new HashMap<>();
-
- @Override
- public void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats) {
- this.pccId = pccId;
- this.pcepVersion = pcepVersion;
- this.pktStats = (PcepPacketStatsImpl) pktStats;
- }
-
- @Override
- public final void disconnectClient() {
- this.channel.close();
- }
-
- @Override
- public void setCapability(ClientCapability capability) {
- this.capability = capability;
- }
-
- @Override
- public ClientCapability capability() {
- return capability;
- }
-
- @Override
- public final void sendMessage(PcepMessage m) {
- log.debug("Sending message to {}", channel.getRemoteAddress());
- try {
- channel.write(Collections.singletonList(m));
- this.pktStats.addOutPacket();
- } catch (RejectedExecutionException e) {
- log.warn(e.getMessage());
- if (!e.getMessage().contains(SHUTDOWN_MSG)) {
- throw e;
- }
- }
- }
-
- @Override
- public final void sendMessage(List<PcepMessage> msgs) {
- try {
- channel.write(msgs);
- this.pktStats.addOutPacket(msgs.size());
- } catch (RejectedExecutionException e) {
- log.warn(e.getMessage());
- if (!e.getMessage().contains(SHUTDOWN_MSG)) {
- throw e;
- }
- }
- }
-
- @Override
- public final boolean isConnected() {
- return this.connected;
- }
-
- @Override
- public final void setConnected(boolean connected) {
- this.connected = connected;
- };
-
- @Override
- public final void setChannel(Channel channel) {
- this.channel = channel;
- final SocketAddress address = channel.getRemoteAddress();
- if (address instanceof InetSocketAddress) {
- final InetSocketAddress inetAddress = (InetSocketAddress) address;
- final IpAddress ipAddress = IpAddress.valueOf(inetAddress.getAddress());
- if (ipAddress.isIp4()) {
- channelId = ipAddress.toString() + ':' + inetAddress.getPort();
- } else {
- channelId = '[' + ipAddress.toString() + "]:" + inetAddress.getPort();
- }
- }
- };
-
- @Override
- public String channelId() {
- return channelId;
- }
-
- @Override
- public final PccId getPccId() {
- return this.pccId;
- }
-
- @Override
- public final String getStringId() {
- return this.pccId.toString();
- }
-
- @Override
- public final void setPcVersion(PcepVersion pcepVersion) {
- this.pcepVersion = pcepVersion;
- }
-
- @Override
- public void setPcKeepAliveTime(byte keepAliveTime) {
- this.keepAliveTime = keepAliveTime;
- }
-
- @Override
- public void setPcDeadTime(byte deadTime) {
- this.deadTime = deadTime;
- }
-
- @Override
- public void setPcSessionId(byte sessionId) {
- this.sessionId = sessionId;
- }
-
- @Override
- public void setLspDbSyncStatus(PcepSyncStatus syncStatus) {
- log.debug("LSP DB sync status set from {} to {}", this.lspDbSyncStatus, syncStatus);
- this.lspDbSyncStatus = syncStatus;
- }
-
- @Override
- public PcepSyncStatus lspDbSyncStatus() {
- return lspDbSyncStatus;
- }
-
- @Override
- public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) {
-
- PcepSyncStatus syncOldStatus = labelDbSyncStatus();
- this.labelDbSyncStatus = syncStatus;
- log.debug("Label DB sync status set from {} to {}", syncOldStatus, syncStatus);
- if ((syncOldStatus == PcepSyncStatus.IN_SYNC) && (syncStatus == PcepSyncStatus.SYNCED)) {
- // Perform end of LSP DB sync actions.
- this.agent.analyzeSyncMsgList(pccId);
- }
- }
-
- @Override
- public PcepSyncStatus labelDbSyncStatus() {
- return labelDbSyncStatus;
- }
-
- @Override
- public final void handleMessage(PcepMessage m) {
- this.pktStats.addInPacket();
- this.agent.processPcepMessage(pccId, m);
- }
-
- @Override
- public void addNode(PcepClient pc) {
- this.agent.addNode(pc);
- }
-
- @Override
- public void deleteNode(PccId pccId) {
- this.agent.deleteNode(pccId);
- }
-
- @Override
- public final boolean connectClient() {
- return this.agent.addConnectedClient(pccId, this);
- }
-
- @Override
- public final void removeConnectedClient() {
- this.agent.removeConnectedClient(pccId);
- }
-
- @Override
- public PcepFactory factory() {
- return PcepFactories.getFactory(pcepVersion);
- }
-
- @Override
- public boolean isHandshakeComplete() {
- return isHandShakeComplete;
- }
-
- @Override
- public final void setAgent(PcepAgent ag) {
- if (this.agent == null) {
- this.agent = ag;
- }
- }
-
- @Override
- public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) {
- lspDelegationInfo.put(lspKey, dFlag);
- }
-
- @Override
- public Boolean delegationInfo(LspKey lspKey) {
- return lspDelegationInfo.get(lspKey);
- }
-
- @Override
- public void initializeSyncMsgList(PccId pccId) {
- List<PcepStateReport> rptMsgList = new LinkedList<>();
- syncRptCache.put(pccId, rptMsgList);
- }
-
- @Override
- public List<PcepStateReport> getSyncMsgList(PccId pccId) {
- return syncRptCache.get(pccId);
- }
-
- @Override
- public void removeSyncMsgList(PccId pccId) {
- syncRptCache.remove(pccId);
- }
-
- @Override
- public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) {
- List<PcepStateReport> rptMsgList = syncRptCache.get(pccId);
- rptMsgList.add(rptMsg);
- syncRptCache.put(pccId, rptMsgList);
- }
-
- @Override
- public boolean isOptical() {
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass())
- .add("channel", channelId())
- .add("pccId", getPccId())
- .toString();
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepConfig.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepConfig.java
deleted file mode 100644
index b5b93e4..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepConfig.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server.impl;
-
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepCfg;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.TreeMap;
-
-
-public class PcepConfig implements PcepCfg {
-
- private static final Logger log = LoggerFactory.getLogger(PcepConfig.class);
-
- private State state = State.INIT;
- private PccId pccId;
- private TreeMap<String, PcepCfg> bgpPeerTree = new TreeMap<>();
-
- @Override
- public State getState() {
- return state;
- }
-
- @Override
- public void setState(State state) {
- this.state = state;
- }
-
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepControllerImpl.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepControllerImpl.java
deleted file mode 100644
index 2d1477a..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepControllerImpl.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server.impl;
-
-import com.google.common.collect.Sets;
-import org.onosproject.net.DeviceId;
-import org.onosproject.pcep.api.PcepController;
-import org.onosproject.pcep.api.PcepDpid;
-import org.onosproject.pcep.api.PcepLinkListener;
-import org.onosproject.pcep.api.PcepSwitch;
-import org.onosproject.pcep.api.PcepSwitchListener;
-import org.onosproject.pcep.api.PcepTunnel;
-import org.onosproject.pcep.api.PcepTunnelListener;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Set;
-
-/**
- * Implementation of PCEP controller [protocol].
- */
-@Component(immediate = true, service = PcepController.class)
-public class PcepControllerImpl implements PcepController {
-
- private static final Logger log = LoggerFactory.getLogger(PcepControllerImpl.class);
-
- protected Set<PcepTunnelListener> pcepTunnelListener = Sets.newHashSet();
- protected Set<PcepLinkListener> pcepLinkListener = Sets.newHashSet();
- protected Set<PcepSwitchListener> pcepSwitchListener = Sets.newHashSet();
-
- private final Controller ctrl = new Controller();
-
- @Activate
- public void activate() {
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public Iterable<PcepSwitch> getSwitches() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public PcepSwitch getSwitch(PcepDpid did) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void addListener(PcepSwitchListener listener) {
- this.pcepSwitchListener.add(listener);
- }
-
- @Override
- public void removeListener(PcepSwitchListener listener) {
- this.pcepSwitchListener.remove(listener);
- }
-
- @Override
- public void addLinkListener(PcepLinkListener listener) {
- this.pcepLinkListener.add(listener);
- }
-
- @Override
- public void removeLinkListener(PcepLinkListener listener) {
- this.pcepLinkListener.remove(listener);
- }
-
- @Override
- public void addTunnelListener(PcepTunnelListener listener) {
- this.pcepTunnelListener.add(listener);
- }
-
- @Override
- public void removeTunnelListener(PcepTunnelListener listener) {
- this.pcepTunnelListener.remove(listener);
- }
-
- @Override
- public PcepTunnel applyTunnel(DeviceId srcDid, DeviceId dstDid, long srcPort, long dstPort, long bandwidth,
- String name) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Boolean deleteTunnel(String id) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public Boolean updateTunnelBandwidth(String id, long bandwidth) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public void getTunnelStatistics(String pcepTunnelId) {
- // TODO Auto-generated method stub
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepMessageDecoder.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepMessageDecoder.java
deleted file mode 100644
index bd831a8..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepMessageDecoder.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server.impl;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.protocol.PcepFactories;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.util.HexDump;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Decode an pcep message from a Channel, for use in a netty pipeline.
- */
-public class PcepMessageDecoder extends FrameDecoder {
-
- private static final Logger log = LoggerFactory.getLogger(PcepMessageDecoder.class);
-
- @Override
- protected Object decode(ChannelHandlerContext ctx, Channel channel,
- ChannelBuffer buffer) throws Exception {
- log.debug("Message received.");
- if (!channel.isConnected()) {
- log.info("Channel is not connected.");
- // In testing, I see decode being called AFTER decode last.
- // This check avoids that from reading corrupted frames
- return null;
- }
-
- HexDump.pcepHexDump(buffer);
-
- // Buffer can contain multiple messages, also may contain out of bound message.
- // Read the message one by one from buffer and parse it. If it encountered out of bound message,
- // then mark the reader index and again take the next chunk of messages from the channel
- // and parse again from the marked reader index.
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- List<PcepMessage> msgList = (List<PcepMessage>) ctx.getAttachment();
-
- if (msgList == null) {
- msgList = new LinkedList<>();
- }
-
- try {
- while (buffer.readableBytes() > 0) {
- buffer.markReaderIndex();
- PcepMessage message = reader.readFrom(buffer);
- msgList.add(message);
- }
- ctx.setAttachment(null);
- return msgList;
- } catch (PcepOutOfBoundMessageException e) {
- log.debug("PCEP message decode error");
- buffer.resetReaderIndex();
- buffer.discardReadBytes();
- ctx.setAttachment(msgList);
- }
- return null;
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepMessageEncoder.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepMessageEncoder.java
deleted file mode 100644
index 7c5b14b..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepMessageEncoder.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server.impl;
-
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.util.HexDump;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Encode an pcep message for output into a ChannelBuffer, for use in a
- * netty pipeline.
- */
-public class PcepMessageEncoder extends OneToOneEncoder {
- private static final Logger log = LoggerFactory.getLogger(PcepMessageEncoder.class);
-
- @Override
- protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
- log.debug("Sending message");
- if (!(msg instanceof List)) {
- log.debug("Invalid msg.");
- return msg;
- }
-
- @SuppressWarnings("unchecked")
- List<PcepMessage> msglist = (List<PcepMessage>) msg;
-
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
-
- for (PcepMessage pm : msglist) {
- pm.writeTo(buf);
- }
-
- HexDump.pcepHexDump(buf);
-
- return buf;
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepPacketStatsImpl.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepPacketStatsImpl.java
deleted file mode 100644
index 1659247..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepPacketStatsImpl.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.server.impl;
-
-import org.onosproject.pcep.server.PcepPacketStats;
-
-/**
- * The implementation for PCEP packet statistics.
- */
-public class PcepPacketStatsImpl implements PcepPacketStats {
-
- private int inPacketCount;
- private int outPacketCount;
- private int wrongPacketCount;
- private long time;
-
- /**
- * Default constructor.
- */
- public PcepPacketStatsImpl() {
- this.inPacketCount = 0;
- this.outPacketCount = 0;
- this.wrongPacketCount = 0;
- this.time = 0;
- }
-
- @Override
- public int outPacketCount() {
- return outPacketCount;
- }
-
- @Override
- public int inPacketCount() {
- return inPacketCount;
- }
-
- @Override
- public int wrongPacketCount() {
- return wrongPacketCount;
- }
-
- /**
- * Increments the received packet counter.
- */
- public void addInPacket() {
- this.inPacketCount++;
- }
-
- /**
- * Increments the sent packet counter.
- */
- public void addOutPacket() {
- this.outPacketCount++;
- }
-
- /**
- * Increments the sent packet counter by specified value.
- *
- * @param value of no of packets sent
- */
- public void addOutPacket(int value) {
- this.outPacketCount = this.outPacketCount + value;
- }
-
- /**
- * Increments the wrong packet counter.
- */
- public void addWrongPacket() {
- this.wrongPacketCount++;
- }
-
- /**
- * Resets wrong packet count.
- */
- public void resetWrongPacket() {
- this.wrongPacketCount = 0;
- }
-
- @Override
- public long getTime() {
- return this.time;
- }
-
- /**
- * Sets the time value.
- *
- * @param time long value of time
- */
- public void setTime(long time) {
- this.time = time;
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepPipelineFactory.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepPipelineFactory.java
deleted file mode 100644
index f1932e9..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/PcepPipelineFactory.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcep.server.impl;
-
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.Channels;
-import org.jboss.netty.handler.timeout.IdleStateHandler;
-import org.jboss.netty.handler.timeout.ReadTimeoutHandler;
-import org.jboss.netty.util.ExternalResourceReleasable;
-import org.jboss.netty.util.HashedWheelTimer;
-import org.jboss.netty.util.Timer;
-
-/**
- * Creates a ChannelPipeline for a server-side pcep channel.
- */
-public class PcepPipelineFactory
- implements ChannelPipelineFactory, ExternalResourceReleasable {
-
- protected Controller controller;
- static final Timer TIMER = new HashedWheelTimer();
- protected IdleStateHandler idleHandler;
- protected ReadTimeoutHandler readTimeoutHandler;
- static final int DEFAULT_KEEP_ALIVE_TIME = 30;
- static final int DEFAULT_DEAD_TIME = 120;
- static final int DEFAULT_WAIT_TIME = 60;
-
- public PcepPipelineFactory(Controller controller) {
- super();
- this.controller = controller;
- this.idleHandler = new IdleStateHandler(TIMER, DEFAULT_DEAD_TIME, DEFAULT_KEEP_ALIVE_TIME, 0);
- this.readTimeoutHandler = new ReadTimeoutHandler(TIMER, DEFAULT_WAIT_TIME);
- }
-
- @Override
- public ChannelPipeline getPipeline() throws Exception {
- PcepChannelHandler handler = new PcepChannelHandler(controller);
-
- ChannelPipeline pipeline = Channels.pipeline();
- pipeline.addLast("pcepmessagedecoder", new PcepMessageDecoder());
- pipeline.addLast("pcepmessageencoder", new PcepMessageEncoder());
- pipeline.addLast("idle", idleHandler);
- pipeline.addLast("waittimeout", readTimeoutHandler);
- pipeline.addLast("handler", handler);
- return pipeline;
- }
-
- @Override
- public void releaseExternalResources() {
- TIMER.stop();
- }
-}
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/package-info.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/package-info.java
deleted file mode 100644
index 4fd2660..0000000
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the PCEP client controller subsystem.
- */
-package org.onosproject.pcep.server.impl;
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/DefaultLspLocalLabelInfoTest.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/DefaultLspLocalLabelInfoTest.java
deleted file mode 100644
index 4b99e2c..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/DefaultLspLocalLabelInfoTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-
-import com.google.common.testing.EqualsTester;
-
-import org.junit.Test;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.pcelabelstore.api.LspLocalLabelInfo;
-
-/**
- * Unit tests for DefaultLspLocalLabelInfo class.
- */
-public class DefaultLspLocalLabelInfoTest {
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- // create same two objects.
- DeviceId deviceId1 = DeviceId.deviceId("foo");
- LabelResourceId inLabelId1 = LabelResourceId.labelResourceId(1);
- LabelResourceId outLabelId1 = LabelResourceId.labelResourceId(2);
- PortNumber inPort1 = PortNumber.portNumber(5122);
- PortNumber outPort1 = PortNumber.portNumber(5123);
-
- LspLocalLabelInfo lspLocalLabel1 = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId1)
- .inLabelId(inLabelId1)
- .outLabelId(outLabelId1)
- .inPort(inPort1)
- .outPort(outPort1)
- .build();
-
- // create same object as above object
- LspLocalLabelInfo sameLocalLabel1 = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId1)
- .inLabelId(inLabelId1)
- .outLabelId(outLabelId1)
- .inPort(inPort1)
- .outPort(outPort1)
- .build();
-
- // Create different object.
- DeviceId deviceId2 = DeviceId.deviceId("goo");
- LabelResourceId inLabelId2 = LabelResourceId.labelResourceId(3);
- LabelResourceId outLabelId2 = LabelResourceId.labelResourceId(4);
- PortNumber inPort2 = PortNumber.portNumber(5124);
- PortNumber outPort2 = PortNumber.portNumber(5125);
-
- LspLocalLabelInfo lspLocalLabel2 = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId2)
- .inLabelId(inLabelId2)
- .outLabelId(outLabelId2)
- .inPort(inPort2)
- .outPort(outPort2)
- .build();
-
- new EqualsTester().addEqualityGroup(lspLocalLabel1, sameLocalLabel1)
- .addEqualityGroup(lspLocalLabel2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a DefaultLspLocalLabelInfo object.
- */
- @Test
- public void testConstruction() {
- DeviceId deviceId = DeviceId.deviceId("foo");
- LabelResourceId inLabelId = LabelResourceId.labelResourceId(1);
- LabelResourceId outLabelId = LabelResourceId.labelResourceId(2);
- PortNumber inPort = PortNumber.portNumber(5122);
- PortNumber outPort = PortNumber.portNumber(5123);
-
- LspLocalLabelInfo lspLocalLabel = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId)
- .inLabelId(inLabelId)
- .outLabelId(outLabelId)
- .inPort(inPort)
- .outPort(outPort)
- .build();
-
- assertThat(deviceId, is(lspLocalLabel.deviceId()));
- assertThat(inLabelId, is(lspLocalLabel.inLabelId()));
- assertThat(outLabelId, is(lspLocalLabel.outLabelId()));
- assertThat(inPort, is(lspLocalLabel.inPort()));
- assertThat(outPort, is(lspLocalLabel.outPort()));
- }
-}
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/DistributedPceLabelStoreTest.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/DistributedPceLabelStoreTest.java
deleted file mode 100644
index 185ffd1..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/DistributedPceLabelStoreTest.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pcelabelstore.api.LspLocalLabelInfo;
-import org.onosproject.pcelabelstore.util.TestStorageService;
-
-/**
- * Unit tests for DistributedPceStore class.
- */
-public class DistributedPceLabelStoreTest {
-
- private DistributedPceLabelStore distrPceStore;
- private DeviceId deviceId1 = DeviceId.deviceId("foo");
- private DeviceId deviceId2 = DeviceId.deviceId("goo");
- private DeviceId deviceId3 = DeviceId.deviceId("yaa");
- private DeviceId deviceId4 = DeviceId.deviceId("zoo");
- private LabelResourceId labelId1 = LabelResourceId.labelResourceId(1);
- private LabelResourceId labelId2 = LabelResourceId.labelResourceId(2);
- private LabelResourceId labelId3 = LabelResourceId.labelResourceId(3);
- private LabelResourceId labelId4 = LabelResourceId.labelResourceId(4);
- private PortNumber portNumber1 = PortNumber.portNumber(1);
- private PortNumber portNumber2 = PortNumber.portNumber(2);
- private PortNumber portNumber3 = PortNumber.portNumber(3);
- private PortNumber portNumber4 = PortNumber.portNumber(4);
- private ConnectPoint srcConnectionPoint1 = new ConnectPoint(deviceId1, portNumber1);
- private ConnectPoint dstConnectionPoint2 = new ConnectPoint(deviceId2, portNumber2);
- private ConnectPoint srcConnectionPoint3 = new ConnectPoint(deviceId3, portNumber3);
- private ConnectPoint dstConnectionPoint4 = new ConnectPoint(deviceId4, portNumber4);
- private LabelResource labelResource1 = new DefaultLabelResource(deviceId1, labelId1);
- private LabelResource labelResource2 = new DefaultLabelResource(deviceId2, labelId2);
- private LabelResource labelResource3 = new DefaultLabelResource(deviceId3, labelId3);
- private LabelResource labelResource4 = new DefaultLabelResource(deviceId4, labelId4);
- private Link link1;
- private Link link2;
- private List<LabelResource> labelList1 = new LinkedList<>();
- private List<LabelResource> labelList2 = new LinkedList<>();
- private TunnelId tunnelId1 = TunnelId.valueOf("1");
- private TunnelId tunnelId2 = TunnelId.valueOf("2");
- private TunnelId tunnelId3 = TunnelId.valueOf("3");
- private TunnelId tunnelId4 = TunnelId.valueOf("4");
-
- List<LspLocalLabelInfo> lspLocalLabelInfoList1 = new LinkedList<>();
- List<LspLocalLabelInfo> lspLocalLabelInfoList2 = new LinkedList<>();
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- distrPceStore = new DistributedPceLabelStore();
- // initialization
- distrPceStore.storageService = new TestStorageService();
- distrPceStore.activate();
-
- // Initialization of member variables
- link1 = DefaultLink.builder()
- .providerId(new ProviderId("eth", "1"))
- .annotations(DefaultAnnotations.builder().set("key1", "yahoo").build())
- .src(srcConnectionPoint1)
- .dst(dstConnectionPoint2)
- .type(Link.Type.DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- link2 = DefaultLink.builder()
- .providerId(new ProviderId("mac", "2"))
- .annotations(DefaultAnnotations.builder().set("key2", "google").build())
- .src(srcConnectionPoint3)
- .dst(dstConnectionPoint4)
- .type(Link.Type.DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- labelList1.add(labelResource1);
- labelList1.add(labelResource2);
- labelList2.add(labelResource3);
- labelList2.add(labelResource4);
-
- // Create pceccTunnelInfo1
- DeviceId deviceId1 = DeviceId.deviceId("foo");
- LabelResourceId inLabelId1 = LabelResourceId.labelResourceId(1);
- LabelResourceId outLabelId1 = LabelResourceId.labelResourceId(2);
-
- LspLocalLabelInfo lspLocalLabel1 = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId1)
- .inLabelId(inLabelId1)
- .outLabelId(outLabelId1)
- .build();
- lspLocalLabelInfoList1.add(lspLocalLabel1);
- distrPceStore.addTunnelInfo(tunnelId1, lspLocalLabelInfoList1);
-
- // Create pceccTunnelInfo2
- DeviceId deviceId2 = DeviceId.deviceId("foo");
- LabelResourceId inLabelId2 = LabelResourceId.labelResourceId(3);
- LabelResourceId outLabelId2 = LabelResourceId.labelResourceId(4);
-
- LspLocalLabelInfo lspLocalLabel2 = DefaultLspLocalLabelInfo.builder()
- .deviceId(deviceId2)
- .inLabelId(inLabelId2)
- .outLabelId(outLabelId2)
- .build();
- lspLocalLabelInfoList2.add(lspLocalLabel2);
- distrPceStore.addTunnelInfo(tunnelId2, lspLocalLabelInfoList2);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- /**
- * Checks the operation of addGlobalNodeLabel() method.
- */
- @Test
- public void testAddGlobalNodeLabel() {
- // add device with label
- distrPceStore.addGlobalNodeLabel(deviceId1, labelId1);
- assertThat(distrPceStore.existsGlobalNodeLabel(deviceId1), is(true));
- assertThat(distrPceStore.getGlobalNodeLabel(deviceId1), is(labelId1));
- distrPceStore.addGlobalNodeLabel(deviceId2, labelId2);
- assertThat(distrPceStore.existsGlobalNodeLabel(deviceId2), is(true));
- assertThat(distrPceStore.getGlobalNodeLabel(deviceId2), is(labelId2));
- }
-
- /**
- * Checks the operation of addAdjLabel() method.
- */
- @Test
- public void testAddAdjLabel() {
- // link with list of labels
- distrPceStore.addAdjLabel(link1, labelId1);
- assertThat(distrPceStore.existsAdjLabel(link1), is(true));
- assertThat(distrPceStore.getAdjLabel(link1), is(labelId1));
- distrPceStore.addAdjLabel(link2, labelId2);
- assertThat(distrPceStore.existsAdjLabel(link2), is(true));
- assertThat(distrPceStore.getAdjLabel(link2), is(labelId2));
- }
-
- /**
- * Checks the operation of addTunnelInfo() method.
- */
- @Test
- public void testAddTunnelInfo() {
- // TunnelId with device label store information
- distrPceStore.addTunnelInfo(tunnelId1, lspLocalLabelInfoList1);
- assertThat(distrPceStore.existsTunnelInfo(tunnelId1), is(true));
- assertThat(distrPceStore.getTunnelInfo(tunnelId1), is(lspLocalLabelInfoList1));
- distrPceStore.addTunnelInfo(tunnelId2, lspLocalLabelInfoList2);
- assertThat(distrPceStore.existsTunnelInfo(tunnelId2), is(true));
- assertThat(distrPceStore.getTunnelInfo(tunnelId2), is(lspLocalLabelInfoList2));
- }
-
- /**
- * Checks the operation of existsGlobalNodeLabel() method.
- */
- @Test
- public void testExistsGlobalNodeLabel() {
- testAddGlobalNodeLabel();
-
- assertThat(distrPceStore.existsGlobalNodeLabel(deviceId1), is(true));
- assertThat(distrPceStore.existsGlobalNodeLabel(deviceId2), is(true));
- assertThat(distrPceStore.existsGlobalNodeLabel(deviceId3), is(false));
- assertThat(distrPceStore.existsGlobalNodeLabel(deviceId4), is(false));
- }
-
- /**
- * Checks the operation of existsAdjLabel() method.
- */
- @Test
- public void testExistsAdjLabel() {
- testAddAdjLabel();
-
- assertThat(distrPceStore.existsAdjLabel(link1), is(true));
- assertThat(distrPceStore.existsAdjLabel(link2), is(true));
- }
-
- /**
- * Checks the operation of existsTunnelInfo() method.
- */
- @Test
- public void testExistsTunnelInfo() {
- testAddTunnelInfo();
-
- assertThat(distrPceStore.existsTunnelInfo(tunnelId1), is(true));
- assertThat(distrPceStore.existsTunnelInfo(tunnelId2), is(true));
- assertThat(distrPceStore.existsTunnelInfo(tunnelId3), is(false));
- assertThat(distrPceStore.existsTunnelInfo(tunnelId4), is(false));
- }
-
- /**
- * Checks the operation of getGlobalNodeLabelCount() method.
- */
- @Test
- public void testGetGlobalNodeLabelCount() {
- testAddGlobalNodeLabel();
-
- assertThat(distrPceStore.getGlobalNodeLabelCount(), is(2));
- }
-
- /**
- * Checks the operation of getAdjLabelCount() method.
- */
- @Test
- public void testGetAdjLabelCount() {
- testAddAdjLabel();
-
- assertThat(distrPceStore.getAdjLabelCount(), is(2));
- }
-
- /**
- * Checks the operation of getTunnelInfoCount() method.
- */
- @Test
- public void testGetTunnelInfoCount() {
- testAddTunnelInfo();
-
- assertThat(distrPceStore.getTunnelInfoCount(), is(2));
- }
-
- /**
- * Checks the operation of getGlobalNodeLabels() method.
- */
- @Test
- public void testGetGlobalNodeLabels() {
- testAddGlobalNodeLabel();
-
- Map<DeviceId, LabelResourceId> nodeLabelMap = distrPceStore.getGlobalNodeLabels();
- assertThat(nodeLabelMap, is(notNullValue()));
- assertThat(nodeLabelMap.isEmpty(), is(false));
- assertThat(nodeLabelMap.size(), is(2));
- }
-
- /**
- * Checks the operation of getAdjLabels() method.
- */
- @Test
- public void testGetAdjLabels() {
- testAddAdjLabel();
-
- Map<Link, LabelResourceId> adjLabelMap = distrPceStore.getAdjLabels();
- assertThat(adjLabelMap, is(notNullValue()));
- assertThat(adjLabelMap.isEmpty(), is(false));
- assertThat(adjLabelMap.size(), is(2));
- }
-
- /**
- * Checks the operation of getTunnelInfos() method.
- */
- @Test
- public void testGetTunnelInfos() {
- testAddTunnelInfo();
-
- Map<TunnelId, List<LspLocalLabelInfo>> tunnelInfoMap = distrPceStore.getTunnelInfos();
- assertThat(tunnelInfoMap, is(notNullValue()));
- assertThat(tunnelInfoMap.isEmpty(), is(false));
- assertThat(tunnelInfoMap.size(), is(2));
- }
-
- /**
- * Checks the operation of getGlobalNodeLabel() method.
- */
- @Test
- public void testGetGlobalNodeLabel() {
- testAddGlobalNodeLabel();
-
- // deviceId1 with labelId1
- assertThat(deviceId1, is(notNullValue()));
- assertThat(distrPceStore.getGlobalNodeLabel(deviceId1), is(labelId1));
-
- // deviceId2 with labelId2
- assertThat(deviceId2, is(notNullValue()));
- assertThat(distrPceStore.getGlobalNodeLabel(deviceId2), is(labelId2));
- }
-
- /**
- * Checks the operation of getAdjLabel() method.
- */
- @Test
- public void testGetAdjLabel() {
- testAddAdjLabel();
-
- // link1 with labels
- assertThat(link1, is(notNullValue()));
- assertThat(distrPceStore.getAdjLabel(link1), is(labelId1));
-
- // link2 with labels
- assertThat(link2, is(notNullValue()));
- assertThat(distrPceStore.getAdjLabel(link2), is(labelId2));
- }
-
- /**
- * Checks the operation of getTunnelInfo() method.
- */
- @Test
- public void testGetTunnelInfo() {
- testAddTunnelInfo();
-
- // tunnelId1 with device label store info
- assertThat(tunnelId1, is(notNullValue()));
- assertThat(distrPceStore.getTunnelInfo(tunnelId1), is(lspLocalLabelInfoList1));
-
- // tunnelId2 with device label store info
- assertThat(tunnelId2, is(notNullValue()));
- assertThat(distrPceStore.getTunnelInfo(tunnelId2), is(lspLocalLabelInfoList2));
- }
-
- /**
- * Checks the operation of removeGlobalNodeLabel() method.
- */
- @Test
- public void testRemoveGlobalNodeLabel() {
- testAddGlobalNodeLabel();
-
- assertThat(distrPceStore.removeGlobalNodeLabel(deviceId1), is(true));
- assertThat(distrPceStore.removeGlobalNodeLabel(deviceId2), is(true));
- }
-
- /**
- * Checks the operation of removeAdjLabel() method.
- */
- @Test
- public void testRemoveAdjLabel() {
- testAddAdjLabel();
-
- assertThat(distrPceStore.removeAdjLabel(link1), is(true));
- assertThat(distrPceStore.removeAdjLabel(link2), is(true));
- }
-
- /**
- * Checks the operation of removeTunnelInfo() method.
- */
- @Test
- public void testRemoveTunnelInfo() {
- testAddTunnelInfo();
-
- assertThat(distrPceStore.removeTunnelInfo(tunnelId1), is(true));
- assertThat(distrPceStore.removeTunnelInfo(tunnelId2), is(true));
- }
-}
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/api/PceLabelStoreAdapter.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/api/PceLabelStoreAdapter.java
deleted file mode 100644
index 598fb78..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/api/PceLabelStoreAdapter.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcelabelstore.api;
-
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.stream.Collectors;
-
-/**
- * Provides test implementation of PceStore.
- */
-public class PceLabelStoreAdapter implements PceLabelStore {
-
- // Mapping device with global node label
- private ConcurrentMap<DeviceId, LabelResourceId> globalNodeLabelMap = new ConcurrentHashMap<>();
-
- // Mapping link with adjacency label
- private ConcurrentMap<Link, LabelResourceId> adjLabelMap = new ConcurrentHashMap<>();
-
- // Mapping tunnel with device local info with tunnel consumer id
- private ConcurrentMap<TunnelId, List<LspLocalLabelInfo>> tunnelInfoMap = new ConcurrentHashMap<>();
-
-
- // Locally maintain LSRID to device id mapping for better performance.
- private Map<String, DeviceId> lsrIdDeviceIdMap = new HashMap<>();
-
- @Override
- public boolean existsGlobalNodeLabel(DeviceId id) {
- return globalNodeLabelMap.containsKey(id);
- }
-
- @Override
- public boolean existsAdjLabel(Link link) {
- return adjLabelMap.containsKey(link);
- }
-
- @Override
- public boolean existsTunnelInfo(TunnelId tunnelId) {
- return tunnelInfoMap.containsKey(tunnelId);
- }
-
- @Override
- public int getGlobalNodeLabelCount() {
- return globalNodeLabelMap.size();
- }
-
- @Override
- public int getAdjLabelCount() {
- return adjLabelMap.size();
- }
-
- @Override
- public int getTunnelInfoCount() {
- return tunnelInfoMap.size();
- }
-
- @Override
- public boolean removeTunnelInfo(TunnelId tunnelId) {
- tunnelInfoMap.remove(tunnelId);
- if (tunnelInfoMap.containsKey(tunnelId)) {
- return false;
- }
- return true;
- }
-
- @Override
- public Map<DeviceId, LabelResourceId> getGlobalNodeLabels() {
- return globalNodeLabelMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()));
- }
-
- @Override
- public Map<Link, LabelResourceId> getAdjLabels() {
- return adjLabelMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()));
- }
-
- @Override
- public LabelResourceId getGlobalNodeLabel(DeviceId id) {
- return globalNodeLabelMap.get(id);
- }
-
- @Override
- public LabelResourceId getAdjLabel(Link link) {
- return adjLabelMap.get(link);
- }
-
- @Override
- public List<LspLocalLabelInfo> getTunnelInfo(TunnelId tunnelId) {
- return tunnelInfoMap.get(tunnelId);
- }
-
- @Override
- public void addGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId) {
- globalNodeLabelMap.put(deviceId, labelId);
- }
-
- @Override
- public void addAdjLabel(Link link, LabelResourceId labelId) {
- adjLabelMap.put(link, labelId);
- }
-
- @Override
- public void addTunnelInfo(TunnelId tunnelId, List<LspLocalLabelInfo> lspLocalLabelInfoList) {
- tunnelInfoMap.put(tunnelId, lspLocalLabelInfoList);
- }
-
- @Override
- public boolean removeGlobalNodeLabel(DeviceId id) {
- globalNodeLabelMap.remove(id);
- if (globalNodeLabelMap.containsKey(id)) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean removeAdjLabel(Link link) {
- adjLabelMap.remove(link);
- if (adjLabelMap.containsKey(link)) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean addLsrIdDevice(String lsrId, DeviceId deviceId) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean removeLsrIdDevice(String lsrId) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public DeviceId getLsrIdDevice(String lsrId) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean addPccLsr(DeviceId lsrId) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean removePccLsr(DeviceId lsrId) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean hasPccLsr(DeviceId lsrId) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public Map<TunnelId, List<LspLocalLabelInfo>> getTunnelInfos() {
- return tunnelInfoMap.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()));
- }
-}
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/label/BasicPceccHandlerTest.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/label/BasicPceccHandlerTest.java
deleted file mode 100644
index 856c1fd..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/label/BasicPceccHandlerTest.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore.label;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.graph.ScalarWeight;
-import org.onlab.packet.IpAddress;
-import org.onosproject.core.GroupId;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdapter;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultDevice;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.DefaultPath;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pcelabelstore.api.LspLocalLabelInfo;
-import org.onosproject.pcelabelstore.api.PceLabelStore;
-import org.onosproject.pcelabelstore.api.PceLabelStoreAdapter;
-import org.onosproject.pcelabelstore.util.MockDeviceService;
-import org.onosproject.pcep.server.impl.BasicPceccHandler;
-import org.onosproject.pcep.server.impl.PcepClientControllerImpl;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-import static org.onosproject.net.Link.Type.DIRECT;
-
-/**
- * Unit tests for BasicPceccHandler class.
- */
-public class BasicPceccHandlerTest {
-
- public static final long LOCAL_LABEL_SPACE_MIN = 5122;
- public static final long LOCAL_LABEL_SPACE_MAX = 9217;
- private static final String L3 = "L3";
- private static final String LSRID = "lsrId";
-
- private BasicPceccHandler pceccHandler;
- protected LabelResourceService labelRsrcService;
- protected MockDeviceService deviceService;
- protected PceLabelStore pceStore;
- private TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423));
- private TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421));
- private GroupId groupId = new GroupId(92034);
- private TunnelName tunnelName = TunnelName.tunnelName("TunnelName");
- private TunnelId tunnelId = TunnelId.valueOf("41654654");
- private ProviderId producerName = new ProviderId("producer1", "13");
- private Path path;
- private Tunnel tunnel;
- List<LspLocalLabelInfo> lspLocalLabelInfoList;
- private Device deviceD1, deviceD2, deviceD3, deviceD4, deviceD5;
- private DeviceId deviceId1;
- private DeviceId deviceId2;
- private DeviceId deviceId3;
- private DeviceId deviceId4;
- private DeviceId deviceId5;
- private PortNumber port1;
- private PortNumber port2;
- private PortNumber port3;
- private PortNumber port4;
- private PortNumber port5;
-
- @Before
- public void setUp() throws Exception {
- pceccHandler = BasicPceccHandler.getInstance();
- labelRsrcService = new LabelResourceAdapter();
- pceStore = new PceLabelStoreAdapter();
- deviceService = new MockDeviceService();
- pceccHandler.initialize(labelRsrcService,
- deviceService,
- pceStore,
- new PcepClientControllerImpl());
-
- // Create tunnel test
- // Link
- ProviderId providerId = new ProviderId("of", "foo");
- deviceId1 = DeviceId.deviceId("of:A");
- deviceId2 = DeviceId.deviceId("of:B");
- deviceId3 = DeviceId.deviceId("of:C");
- deviceId4 = DeviceId.deviceId("of:D");
- deviceId5 = DeviceId.deviceId("of:E");
- port1 = PortNumber.portNumber(1);
- port2 = PortNumber.portNumber(2);
- port3 = PortNumber.portNumber(3);
- port4 = PortNumber.portNumber(4);
- port5 = PortNumber.portNumber(5);
- List<Link> linkList = new LinkedList<>();
-
- // Making L3 devices
- DefaultAnnotations.Builder builderDev1 = DefaultAnnotations.builder();
- builderDev1.set(AnnotationKeys.TYPE, L3);
- builderDev1.set(LSRID, "1.1.1.1");
- deviceD1 = new MockDevice(deviceId1, builderDev1.build());
- deviceService.addDevice(deviceD1);
-
- // Making L3 devices
- DefaultAnnotations.Builder builderDev2 = DefaultAnnotations.builder();
- builderDev2.set(AnnotationKeys.TYPE, L3);
- builderDev2.set(LSRID, "2.2.2.2");
- deviceD2 = new MockDevice(deviceId2, builderDev2.build());
- deviceService.addDevice(deviceD2);
-
- // Making L3 devices
- DefaultAnnotations.Builder builderDev3 = DefaultAnnotations.builder();
- builderDev3.set(AnnotationKeys.TYPE, L3);
- builderDev3.set(LSRID, "3.3.3.3");
- deviceD3 = new MockDevice(deviceId3, builderDev3.build());
- deviceService.addDevice(deviceD3);
-
- // Making L3 devices
- DefaultAnnotations.Builder builderDev4 = DefaultAnnotations.builder();
- builderDev4.set(AnnotationKeys.TYPE, L3);
- builderDev4.set(LSRID, "4.4.4.4");
- deviceD4 = new MockDevice(deviceId4, builderDev4.build());
- deviceService.addDevice(deviceD4);
-
- // Making L3 devices
- DefaultAnnotations.Builder builderDev5 = DefaultAnnotations.builder();
- builderDev5.set(AnnotationKeys.TYPE, L3);
- builderDev5.set(LSRID, "5.5.5.5");
- deviceD5 = new MockDevice(deviceId5, builderDev5.build());
- deviceService.addDevice(deviceD5);
-
- Link l1 = DefaultLink.builder()
- .providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key1", "yahoo").build())
- .src(new ConnectPoint(deviceId1, port1))
- .dst(new ConnectPoint(deviceId2, port2))
- .type(DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- linkList.add(l1);
- Link l2 = DefaultLink.builder()
- .providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key2", "yahoo").build())
- .src(new ConnectPoint(deviceId2, port2))
- .dst(new ConnectPoint(deviceId3, port3))
- .type(DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- linkList.add(l2);
- Link l3 = DefaultLink.builder()
- .providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key3", "yahoo").build())
- .src(new ConnectPoint(deviceId3, port3))
- .dst(new ConnectPoint(deviceId4, port4))
- .type(DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- linkList.add(l3);
- Link l4 = DefaultLink.builder()
- .providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key4", "yahoo").build())
- .src(new ConnectPoint(deviceId4, port4))
- .dst(new ConnectPoint(deviceId5, port5))
- .type(DIRECT)
- .state(Link.State.ACTIVE)
- .build();
- linkList.add(l4);
-
- // Path
- path = new DefaultPath(providerId, linkList, ScalarWeight.toWeight(10));
-
- // Tunnel
- tunnel = new DefaultTunnel(producerName, src, dst, Tunnel.Type.VXLAN,
- Tunnel.State.ACTIVE, groupId, tunnelId,
- tunnelName, path);
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- /**
- * Checks the operation of getInstance() method.
- */
- @Test
- public void testGetInstance() {
- assertThat(pceccHandler, is(notNullValue()));
- }
-
- /**
- * Checks the operation of allocateLabel() method.
- */
- @Test
- public void testAllocateLabel() {
- Iterator<LspLocalLabelInfo> iterator;
- LspLocalLabelInfo lspLocalLabelInfo;
- DeviceId deviceId;
- LabelResourceId inLabelId;
- LabelResourceId outLabelId;
- PortNumber inPort;
- PortNumber outPort;
-
- // check allocation result
- assertThat(pceccHandler.allocateLabel(tunnel), is(true));
-
- // Check list of devices with IN and OUT labels whether stored properly in store
- lspLocalLabelInfoList = pceStore.getTunnelInfo(tunnel.tunnelId());
- iterator = lspLocalLabelInfoList.iterator();
-
- // Retrieve values and check device5
- lspLocalLabelInfo = iterator.next();
- deviceId = lspLocalLabelInfo.deviceId();
- inLabelId = lspLocalLabelInfo.inLabelId();
- outLabelId = lspLocalLabelInfo.outLabelId();
- inPort = lspLocalLabelInfo.inPort();
- outPort = lspLocalLabelInfo.outPort();
-
- assertThat(deviceId, is(deviceId5));
- assertThat(inLabelId, is(notNullValue()));
- assertThat(outLabelId, is(nullValue()));
- assertThat(inPort, is(port5));
- assertThat(outPort, is(nullValue()));
-
- // Next element check
- // Retrieve values and check device4
- lspLocalLabelInfo = iterator.next();
- deviceId = lspLocalLabelInfo.deviceId();
- inLabelId = lspLocalLabelInfo.inLabelId();
- outLabelId = lspLocalLabelInfo.outLabelId();
- inPort = lspLocalLabelInfo.inPort();
- outPort = lspLocalLabelInfo.outPort();
-
- assertThat(deviceId, is(deviceId4));
- assertThat(inLabelId, is(notNullValue()));
- assertThat(outLabelId, is(notNullValue()));
- assertThat(inPort, is(port4));
- assertThat(outPort, is(port5));
-
- // Next element check
- // Retrieve values and check device3
- lspLocalLabelInfo = iterator.next();
- deviceId = lspLocalLabelInfo.deviceId();
- inLabelId = lspLocalLabelInfo.inLabelId();
- outLabelId = lspLocalLabelInfo.outLabelId();
- inPort = lspLocalLabelInfo.inPort();
- outPort = lspLocalLabelInfo.outPort();
-
- assertThat(deviceId, is(deviceId3));
- assertThat(inLabelId, is(notNullValue()));
- assertThat(outLabelId, is(notNullValue()));
- assertThat(inPort, is(port3));
- assertThat(outPort, is(port4));
-
- // Next element check
- // Retrieve values and check device2
- lspLocalLabelInfo = iterator.next();
- deviceId = lspLocalLabelInfo.deviceId();
- inLabelId = lspLocalLabelInfo.inLabelId();
- outLabelId = lspLocalLabelInfo.outLabelId();
- inPort = lspLocalLabelInfo.inPort();
- outPort = lspLocalLabelInfo.outPort();
-
- assertThat(deviceId, is(deviceId2));
- assertThat(inLabelId, is(notNullValue()));
- assertThat(outLabelId, is(notNullValue()));
- assertThat(inPort, is(port2));
- assertThat(outPort, is(port3));
-
- // Next element check
- // Retrieve values and check device1
- lspLocalLabelInfo = iterator.next();
- deviceId = lspLocalLabelInfo.deviceId();
- inLabelId = lspLocalLabelInfo.inLabelId();
- outLabelId = lspLocalLabelInfo.outLabelId();
- inPort = lspLocalLabelInfo.inPort();
- outPort = lspLocalLabelInfo.outPort();
-
- assertThat(deviceId, is(deviceId1));
- assertThat(inLabelId, is(nullValue()));
- assertThat(outLabelId, is(notNullValue()));
- assertThat(inPort, is(nullValue()));
- assertThat(outPort, is(port2));
- }
-
- /**
- * Checks the operation of releaseLabel() method.
- */
- @Test
- public void testReleaseLabel() {
- // Release tunnels
- assertThat(pceccHandler.allocateLabel(tunnel), is(true));
- pceccHandler.releaseLabel(tunnel);
-
- // Retrieve from store. Store should not contain this tunnel info.
- lspLocalLabelInfoList = pceStore.getTunnelInfo(tunnel.tunnelId());
- assertThat(lspLocalLabelInfoList, is(nullValue()));
- }
-
- private class MockDevice extends DefaultDevice {
- MockDevice(DeviceId id, Annotations annotations) {
- super(null, id, null, null, null, null, null, null, annotations);
- }
- }
-}
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/label/PceccSrTeBeHandlerTest.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/label/PceccSrTeBeHandlerTest.java
deleted file mode 100644
index cf832c4..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/label/PceccSrTeBeHandlerTest.java
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore.label;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.graph.ScalarWeight;
-import org.onlab.packet.IpAddress;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdapter;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-import org.onosproject.incubator.net.tunnel.LabelStack;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultDevice;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.DefaultPath;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pcelabelstore.api.PceLabelStore;
-import org.onosproject.pcelabelstore.api.PceLabelStoreAdapter;
-import org.onosproject.pcelabelstore.util.MockDeviceService;
-import org.onosproject.pcelabelstore.util.MockNetConfigRegistryAdapter;
-import org.onosproject.pcelabelstore.util.MockPcepClientController;
-import org.onosproject.pcep.server.PcepClientAdapter;
-import org.onosproject.pcep.api.DeviceCapability;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.impl.PceccSrTeBeHandler;
-import org.onosproject.pcepio.protocol.PcepVersion;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-import static org.onosproject.net.Link.Type.DIRECT;
-
-/**
- * Unit tests for PceccSrTeBeHandler class.
- */
-public class PceccSrTeBeHandlerTest {
-
- public static final long GLOBAL_LABEL_SPACE_MIN = 4097;
- public static final long GLOBAL_LABEL_SPACE_MAX = 5121;
- private static final String L3 = "L3";
- private static final String LSRID = "lsrId";
-
- private PceccSrTeBeHandler srTeHandler;
- private LabelResourceAdminService labelRsrcAdminService;
- private LabelResourceService labelRsrcService;
- private PceLabelStore pceStore;
- private MockDeviceService deviceService;
- private MockNetConfigRegistryAdapter netCfgService = new MockNetConfigRegistryAdapter();
- private MockPcepClientController clientController = new MockPcepClientController();
- private ProviderId providerId;
- private DeviceId deviceId1, deviceId2, deviceId3, deviceId4, deviceId5;
- private Device deviceD1;
- private Device deviceD2;
- private Device deviceD3;
- private Device deviceD4;
- private Device deviceD5;
- private PortNumber port1;
- private PortNumber port2;
- private PortNumber port3;
- private PortNumber port4;
- private PortNumber port5;
- private Link link1;
- private Link link2;
- private Link link3;
- private Link link4;
- private Path path1;
- LabelResourceId labelId;
-
- @Before
- public void setUp() throws Exception {
- // Initialization of member variables
- srTeHandler = PceccSrTeBeHandler.getInstance();
- labelRsrcService = new LabelResourceAdapter();
- labelRsrcAdminService = new LabelResourceAdapter();
- pceStore = new PceLabelStoreAdapter();
- deviceService = new MockDeviceService();
-
- srTeHandler.initialize(labelRsrcAdminService,
- labelRsrcService,
- clientController,
- pceStore,
- deviceService);
-
- // Creates path
- // Creates list of links
- providerId = new ProviderId("of", "foo");
-
- PccId pccId1 = PccId.pccId(IpAddress.valueOf("11.1.1.1"));
- PccId pccId2 = PccId.pccId(IpAddress.valueOf("12.1.1.1"));
- PccId pccId3 = PccId.pccId(IpAddress.valueOf("13.1.1.1"));
- PccId pccId4 = PccId.pccId(IpAddress.valueOf("14.1.1.1"));
- PccId pccId5 = PccId.pccId(IpAddress.valueOf("15.1.1.1"));
-
- PcepClientAdapter pc1 = new PcepClientAdapter();
- pc1.init(pccId1, PcepVersion.PCEP_1);
-
- PcepClientAdapter pc2 = new PcepClientAdapter();
- pc2.init(pccId2, PcepVersion.PCEP_1);
-
- PcepClientAdapter pc3 = new PcepClientAdapter();
- pc3.init(pccId3, PcepVersion.PCEP_1);
-
- PcepClientAdapter pc4 = new PcepClientAdapter();
- pc4.init(pccId4, PcepVersion.PCEP_1);
-
- PcepClientAdapter pc5 = new PcepClientAdapter();
- pc5.init(pccId5, PcepVersion.PCEP_1);
-
- clientController.addClient(pccId1, pc1);
- clientController.addClient(pccId2, pc2);
- clientController.addClient(pccId3, pc3);
- clientController.addClient(pccId4, pc4);
- clientController.addClient(pccId5, pc5);
-
- deviceId1 = DeviceId.deviceId("11.1.1.1");
- deviceId2 = DeviceId.deviceId("12.1.1.1");
- deviceId3 = DeviceId.deviceId("13.1.1.1");
- deviceId4 = DeviceId.deviceId("14.1.1.1");
- deviceId5 = DeviceId.deviceId("15.1.1.1");
-
- // Devices
- DefaultAnnotations.Builder builderDev1 = DefaultAnnotations.builder();
- DefaultAnnotations.Builder builderDev2 = DefaultAnnotations.builder();
- DefaultAnnotations.Builder builderDev3 = DefaultAnnotations.builder();
- DefaultAnnotations.Builder builderDev4 = DefaultAnnotations.builder();
- DefaultAnnotations.Builder builderDev5 = DefaultAnnotations.builder();
-
- builderDev1.set(AnnotationKeys.TYPE, L3);
- builderDev1.set(LSRID, "11.1.1.1");
-
- builderDev2.set(AnnotationKeys.TYPE, L3);
- builderDev2.set(LSRID, "12.1.1.1");
-
- builderDev3.set(AnnotationKeys.TYPE, L3);
- builderDev3.set(LSRID, "13.1.1.1");
-
- builderDev4.set(AnnotationKeys.TYPE, L3);
- builderDev4.set(LSRID, "14.1.1.1");
-
- builderDev5.set(AnnotationKeys.TYPE, L3);
- builderDev5.set(LSRID, "15.1.1.1");
-
- deviceD1 = new MockDevice(deviceId1, builderDev1.build());
- deviceD2 = new MockDevice(deviceId2, builderDev2.build());
- deviceD3 = new MockDevice(deviceId3, builderDev3.build());
- deviceD4 = new MockDevice(deviceId4, builderDev4.build());
- deviceD5 = new MockDevice(deviceId5, builderDev5.build());
-
- deviceService.addDevice(deviceD1);
- deviceService.addDevice(deviceD2);
- deviceService.addDevice(deviceD3);
- deviceService.addDevice(deviceD4);
- deviceService.addDevice(deviceD5);
-
- DeviceCapability device1Cap = netCfgService.addConfig(deviceId1, DeviceCapability.class);
- device1Cap.setLabelStackCap(true).setLocalLabelCap(false).setSrCap(true).apply();
-
- DeviceCapability device2Cap = netCfgService.addConfig(deviceId2, DeviceCapability.class);
- device2Cap.setLabelStackCap(true).setLocalLabelCap(false).setSrCap(true).apply();
-
- DeviceCapability device3Cap = netCfgService.addConfig(deviceId3, DeviceCapability.class);
- device3Cap.setLabelStackCap(true).setLocalLabelCap(false).setSrCap(true).apply();
-
- DeviceCapability device4Cap = netCfgService.addConfig(deviceId4, DeviceCapability.class);
- device4Cap.setLabelStackCap(true).setLocalLabelCap(false).setSrCap(true).apply();
-
- DeviceCapability device5Cap = netCfgService.addConfig(deviceId5, DeviceCapability.class);
- device5Cap.setLabelStackCap(true).setLocalLabelCap(false).setSrCap(true).apply();
-
- // Port Numbers
- port1 = PortNumber.portNumber(1);
- port2 = PortNumber.portNumber(2);
- port3 = PortNumber.portNumber(3);
- port4 = PortNumber.portNumber(4);
- port5 = PortNumber.portNumber(5);
- List<Link> linkList = new LinkedList<>();
-
- link1 = DefaultLink.builder().providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key1", "yahoo").build())
- .src(new ConnectPoint(deviceD1.id(), port1)).dst(new ConnectPoint(deviceD2.id(), port2)).type(DIRECT)
- .state(Link.State.ACTIVE).build();
- linkList.add(link1);
- link2 = DefaultLink.builder().providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key2", "yahoo").build())
- .src(new ConnectPoint(deviceD2.id(), port2)).dst(new ConnectPoint(deviceD3.id(), port3)).type(DIRECT)
- .state(Link.State.ACTIVE).build();
- linkList.add(link2);
- link3 = DefaultLink.builder().providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key3", "yahoo").build())
- .src(new ConnectPoint(deviceD3.id(), port3)).dst(new ConnectPoint(deviceD4.id(), port4)).type(DIRECT)
- .state(Link.State.ACTIVE).build();
- linkList.add(link3);
- link4 = DefaultLink.builder().providerId(providerId)
- .annotations(DefaultAnnotations.builder().set("key4", "yahoo").build())
- .src(new ConnectPoint(deviceD4.id(), port4)).dst(new ConnectPoint(deviceD5.id(), port5)).type(DIRECT)
- .state(Link.State.ACTIVE).build();
- linkList.add(link4);
-
- // Path
- path1 = new DefaultPath(providerId, linkList, ScalarWeight.toWeight(10));
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- /**
- * Checks the operation of getInstance() method.
- */
- @Test
- public void testGetInstance() {
- assertThat(srTeHandler, is(notNullValue()));
- }
-
- /**
- * Checks the operation of reserveGlobalPool() method.
- */
- @Test
- public void testReserveGlobalPool() {
- assertThat(srTeHandler.reserveGlobalPool(GLOBAL_LABEL_SPACE_MIN, GLOBAL_LABEL_SPACE_MAX), is(true));
- }
-
- /**
- * Checks the operation of allocateNodeLabel() method on node label.
- */
- @Test
- public void testAllocateNodeLabel() {
- // Specific device D1.deviceId
-
- //device 1
- String lsrId1 = "11.1.1.1";
- // Allocate node label for specific device D1deviceId
- assertThat(srTeHandler.allocateNodeLabel(deviceId1, lsrId1), is(true));
- // Retrieve label from store
- LabelResourceId labelId = pceStore.getGlobalNodeLabel(deviceId1);
- // Check whether label is generated for this device D1.deviceId()
- assertThat(labelId, is(notNullValue()));
-
- // device 2
- String lsrId2 = "12.1.1.1";
- // Allocate node label for specific device D2.deviceId()
- assertThat(srTeHandler.allocateNodeLabel(deviceId2, lsrId2), is(true));
- // Retrieve label from store
- labelId = pceStore.getGlobalNodeLabel(deviceId2);
- // Check whether label is generated for this device D2.deviceId()
- assertThat(labelId, is(notNullValue()));
-
- // device 3
- String lsrId3 = "13.1.1.1";
- // Allocate node label for specific device D3.deviceId()
- assertThat(srTeHandler.allocateNodeLabel(deviceId3, lsrId3), is(true));
- // Retrieve label from store
- labelId = pceStore.getGlobalNodeLabel(deviceId3);
- // Check whether label is generated for this device D3.deviceId()
- assertThat(labelId, is(notNullValue()));
-
- // device 4
- String lsrId4 = "14.1.1.1";
- // Allocate node label for specific device D4.deviceId()
- assertThat(srTeHandler.allocateNodeLabel(deviceId4, lsrId4), is(true));
- // Retrieve label from store
- labelId = pceStore.getGlobalNodeLabel(deviceId4);
- // Check whether label is generated for this device D4.deviceId()
- assertThat(labelId, is(notNullValue()));
-
- // device 5
- String lsrId5 = "15.1.1.1";
- // Allocate node label for specific device D5.deviceId()
- assertThat(srTeHandler.allocateNodeLabel(deviceId5, lsrId5), is(true));
- // Retrieve label from store
- labelId = pceStore.getGlobalNodeLabel(deviceId5);
- // Check whether label is generated for this device D5.deviceId()
- assertThat(labelId, is(notNullValue()));
- }
-
- /**
- * Checks the operation of releaseNodeLabel() method on node label.
- */
- @Test
- public void testReleaseNodeLabelSuccess() {
- testAllocateNodeLabel();
- // Specific device D1.deviceId()
-
- //device 1
- String lsrId1 = "11.1.1.1";
- // Check whether successfully released node label
- assertThat(srTeHandler.releaseNodeLabel(deviceId1, lsrId1), is(true));
- // Check whether successfully removed label from store
- LabelResourceId labelId = pceStore.getGlobalNodeLabel(deviceId1);
- assertThat(labelId, is(nullValue()));
-
- //device 2
- String lsrId2 = "12.1.1.1";
- // Check whether successfully released node label
- assertThat(srTeHandler.releaseNodeLabel(deviceId2, lsrId2), is(true));
- // Check whether successfully removed label from store
- labelId = pceStore.getGlobalNodeLabel(deviceId2);
- assertThat(labelId, is(nullValue()));
-
- //device 3
- String lsrId3 = "13.1.1.1";
- // Check whether successfully released node label
- assertThat(srTeHandler.releaseNodeLabel(deviceId3, lsrId3), is(true));
- // Check whether successfully removed label from store
- labelId = pceStore.getGlobalNodeLabel(deviceId3);
- assertThat(labelId, is(nullValue()));
-
- //device 4
- String lsrId4 = "14.1.1.1";
- // Check whether successfully released node label
- assertThat(srTeHandler.releaseNodeLabel(deviceId4, lsrId4), is(true));
- // Check whether successfully removed label from store
- labelId = pceStore.getGlobalNodeLabel(deviceId4);
- assertThat(labelId, is(nullValue()));
-
- //device 5
- String lsrId5 = "15.1.1.1";
- // Check whether successfully released node label
- assertThat(srTeHandler.releaseNodeLabel(deviceId5, lsrId5), is(true));
- // Check whether successfully removed label from store
- labelId = pceStore.getGlobalNodeLabel(deviceId5);
- assertThat(labelId, is(nullValue()));
- }
-
- @Test
- public void testReleaseNodeLabelFailure() {
- testAllocateNodeLabel();
-
- //device 6
- String lsrId6 = "16.1.1.1";
- // Check whether successfully released node label
- DeviceId deviceId6 = DeviceId.deviceId("foo6");
- assertThat(srTeHandler.releaseNodeLabel(deviceId6, lsrId6), is(false));
- }
-
- /**
- * Checks the operation of allocateAdjacencyLabel() method on adjacency label.
- */
- @Test
- public void testAllocateAdjacencyLabel() {
- // test link1
- // Check whether adjacency label is allocated successfully.
- assertThat(srTeHandler.allocateAdjacencyLabel(link1), is(true));
- // Retrieve from store and check whether adjacency label is generated successfully for this device.
- LabelResourceId labelId = pceStore.getAdjLabel(link1);
- assertThat(labelId, is(notNullValue()));
-
- // test link2
- // Check whether adjacency label is allocated successfully.
- assertThat(srTeHandler.allocateAdjacencyLabel(link2), is(true));
- // Retrieve from store and check whether adjacency label is generated successfully for this device.
- labelId = pceStore.getAdjLabel(link2);
- assertThat(labelId, is(notNullValue()));
-
- // test link3
- // Check whether adjacency label is allocated successfully.
- assertThat(srTeHandler.allocateAdjacencyLabel(link3), is(true));
- // Retrieve from store and check whether adjacency label is generated successfully for this device.
- labelId = pceStore.getAdjLabel(link3);
- assertThat(labelId, is(notNullValue()));
-
- // test link4
- // Check whether adjacency label is allocated successfully.
- assertThat(srTeHandler.allocateAdjacencyLabel(link4), is(true));
- // Retrieve from store and check whether adjacency label is generated successfully for this device.
- labelId = pceStore.getAdjLabel(link4);
- assertThat(labelId, is(notNullValue()));
- }
-
- /**
- * Checks the operation of releaseAdjacencyLabel() method on adjacency label.
- */
- @Test
- public void testReleaseAdjacencyLabel() {
- // Test link1
- // Check whether adjacency label is released successfully.
- assertThat(srTeHandler.allocateAdjacencyLabel(link1), is(true));
- assertThat(srTeHandler.releaseAdjacencyLabel(link1), is(true));
- // Retrieve from store and check whether adjacency label is removed successfully for this device.
- LabelResourceId labelId = pceStore.getAdjLabel(link1);
- assertThat(labelId, is(nullValue()));
-
- // Test link2
- // Check whether adjacency label is released successfully.
- assertThat(srTeHandler.allocateAdjacencyLabel(link2), is(true));
- assertThat(srTeHandler.releaseAdjacencyLabel(link2), is(true));
- // Retrieve from store and check whether adjacency label is removed successfully for this device.
- labelId = pceStore.getAdjLabel(link2);
- assertThat(labelId, is(nullValue()));
- }
-
- /**
- * Checks the operation of computeLabelStack() method.
- */
- @Test
- public void testComputeLabelStack() {
- // Allocate node labels to each devices
- labelId = LabelResourceId.labelResourceId(4097);
- pceStore.addGlobalNodeLabel(deviceId1, labelId);
- labelId = LabelResourceId.labelResourceId(4098);
- pceStore.addGlobalNodeLabel(deviceId2, labelId);
- labelId = LabelResourceId.labelResourceId(4099);
- pceStore.addGlobalNodeLabel(deviceId3, labelId);
- labelId = LabelResourceId.labelResourceId(4100);
- pceStore.addGlobalNodeLabel(deviceId4, labelId);
- labelId = LabelResourceId.labelResourceId(4101);
- pceStore.addGlobalNodeLabel(deviceId5, labelId);
-
- // Allocate adjacency labels to each devices
- labelId = LabelResourceId.labelResourceId(5122);
- pceStore.addAdjLabel(link1, labelId);
- labelId = LabelResourceId.labelResourceId(5123);
- pceStore.addAdjLabel(link2, labelId);
- labelId = LabelResourceId.labelResourceId(5124);
- pceStore.addAdjLabel(link3, labelId);
- labelId = LabelResourceId.labelResourceId(5125);
- pceStore.addAdjLabel(link4, labelId);
-
- // Compute label stack
- LabelStack labelStack = srTeHandler.computeLabelStack(path1);
-
- List<LabelResourceId> labelList = labelStack.labelResources();
- Iterator<LabelResourceId> iterator = labelList.iterator();
-
- // check adjacency label of D1.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(5122)));
-
- // check node-label of D2.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(4098)));
-
- // check adjacency label of D2.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(5123)));
-
- // check node-label of D3.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(4099)));
-
- // check adjacency label of D3.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(5124)));
-
- // check node-label of D4.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(4100)));
-
- // check adjacency label of D4.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(5125)));
-
- // check node-label of D5.deviceId()
- labelId = iterator.next();
- assertThat(labelId, is(LabelResourceId.labelResourceId(4101)));
- }
-
- private class MockDevice extends DefaultDevice {
- MockDevice(DeviceId id, Annotations annotations) {
- super(null, id, null, null, null, null, null, null, annotations);
- }
- }
-}
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/MockDeviceService.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/MockDeviceService.java
deleted file mode 100644
index 298fd39..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/MockDeviceService.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore.util;
-
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceServiceAdapter;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Test fixture for the device service.
- */
-public class MockDeviceService extends DeviceServiceAdapter {
- private List<Device> devices = new LinkedList<>();
- private DeviceListener listener;
-
- /**
- * Adds a new device.
- *
- * @param dev device to be added
- */
- public void addDevice(Device dev) {
- devices.add(dev);
- }
-
- /**
- * Removes the specified device.
- *
- * @param dev device to be removed
- */
- public void removeDevice(Device dev) {
- devices.remove(dev);
- }
-
- @Override
- public Device getDevice(DeviceId deviceId) {
- for (Device dev : devices) {
- if (dev.id().equals(deviceId)) {
- return dev;
- }
- }
- return null;
- }
-
- @Override
- public Iterable<Device> getAvailableDevices() {
- return devices;
- }
-
- @Override
- public void addListener(DeviceListener listener) {
- this.listener = listener;
- }
-
- /**
- * Get the listener.
- */
- public DeviceListener getListener() {
- return listener;
- }
-}
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/MockNetConfigRegistryAdapter.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/MockNetConfigRegistryAdapter.java
deleted file mode 100644
index b5a67fb..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/MockNetConfigRegistryAdapter.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore.util;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.config.Config;
-import org.onosproject.net.config.ConfigApplyDelegate;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigRegistryAdapter;
-import org.onosproject.pcep.api.DeviceCapability;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/* Mock test for network config registry. */
-public class MockNetConfigRegistryAdapter extends NetworkConfigRegistryAdapter {
- private ConfigFactory cfgFactory;
- private Map<DeviceId, DeviceCapability> classConfig = new HashMap<>();
-
- @Override
- public void registerConfigFactory(ConfigFactory configFactory) {
- cfgFactory = configFactory;
- }
-
- @Override
- public void unregisterConfigFactory(ConfigFactory configFactory) {
- cfgFactory = null;
- }
-
- @Override
- public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) {
- if (configClass == DeviceCapability.class) {
- DeviceCapability devCap = new DeviceCapability();
- classConfig.put((DeviceId) subject, devCap);
-
- JsonNode node = new ObjectNode(new MockJsonNode());
- ObjectMapper mapper = new ObjectMapper();
- ConfigApplyDelegate delegate = new InternalApplyDelegate();
- devCap.init((DeviceId) subject, null, node, mapper, delegate);
- return (C) devCap;
- }
-
- return null;
- }
-
- @Override
- public <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass) {
- classConfig.remove(subject);
- }
-
- @Override
- public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) {
- if (configClass == DeviceCapability.class) {
- return (C) classConfig.get(subject);
- }
- return null;
- }
-
- private class MockJsonNode extends JsonNodeFactory {
- }
-
- // Auxiliary delegate to receive notifications about changes applied to
- // the network configuration - by the apps.
- private class InternalApplyDelegate implements ConfigApplyDelegate {
- @Override
- public void onApply(Config config) {
- //configs.put(config.subject(), config.node());
- }
- }
-
-}
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/MockPcepClientController.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/MockPcepClientController.java
deleted file mode 100644
index 07bf81c..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/MockPcepClientController.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore.util;
-
-
-
-import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
-import org.onosproject.incubator.net.tunnel.LabelStack;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.net.Path;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepClient;
-import org.onosproject.pcep.server.PcepClientController;
-import org.onosproject.pcep.server.PcepClientListener;
-import org.onosproject.pcep.server.PcepEventListener;
-import org.onosproject.pcep.server.PcepNodeListener;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.types.PcepValueType;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.List;
-
-public class MockPcepClientController implements PcepClientController {
-
- Map<PccId, PcepClient> clientMap = new HashMap<>();
-
- @Override
- public Collection<PcepClient> getClients() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void addClient(PccId pccId, PcepClient pc) {
- clientMap.put(pccId, pc);
- return;
- }
-
- @Override
- public PcepClient getClient(PccId pccId) {
- return clientMap.get(pccId);
- }
-
- @Override
- public void addListener(PcepClientListener listener) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void removeListener(PcepClientListener listener) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void addEventListener(PcepEventListener listener) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void removeEventListener(PcepEventListener listener) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void addNodeListener(PcepNodeListener listener) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void removeNodeListener(PcepNodeListener listener) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void writeMessage(PccId pccId, PcepMessage msg) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void processClientMessage(PccId pccId, PcepMessage msg) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void closeConnectedClients() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public LabelStack computeLabelStack(Path path) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Map<String, List<String>> getPcepExceptions() {
- return null;
- }
-
- @Override
- public Map<Integer, Integer> getPcepErrorMsg() {
- return null;
- }
-
- @Override
- public Map<String, String> getPcepSessionMap() {
- return null;
- }
-
- @Override
- public Map<String, Byte> getPcepSessionIdMap() {
- return null;
- }
-
- @Override
- public void peerErrorMsg(String peerId, Integer errorType, Integer errValue) {
-
- }
-
- @Override
- public boolean allocateLocalLabel(Tunnel tunnel) {
- // TODO Auto-generated method stub
- return false;
- }
-
-}
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/StorageServiceAdapter.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/StorageServiceAdapter.java
deleted file mode 100644
index 3a20e01..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/StorageServiceAdapter.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore.util;
-
-import org.onosproject.store.service.AsyncDocumentTree;
-import org.onosproject.store.service.AsyncConsistentMultimap;
-import org.onosproject.store.service.AsyncConsistentTreeMap;
-import org.onosproject.store.service.AtomicCounterBuilder;
-import org.onosproject.store.service.AtomicCounterMapBuilder;
-import org.onosproject.store.service.AtomicIdGeneratorBuilder;
-import org.onosproject.store.service.AtomicValueBuilder;
-import org.onosproject.store.service.ConsistentMapBuilder;
-import org.onosproject.store.service.ConsistentMultimapBuilder;
-import org.onosproject.store.service.ConsistentTreeMapBuilder;
-import org.onosproject.store.service.DistributedLockBuilder;
-import org.onosproject.store.service.DistributedSetBuilder;
-import org.onosproject.store.service.DocumentTreeBuilder;
-import org.onosproject.store.service.EventuallyConsistentMapBuilder;
-import org.onosproject.store.service.LeaderElectorBuilder;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.Topic;
-import org.onosproject.store.service.TopicBuilder;
-import org.onosproject.store.service.TransactionContextBuilder;
-import org.onosproject.store.service.WorkQueue;
-import org.onosproject.store.service.WorkQueueBuilder;
-
-/**
- * Adapter for the storage service.
- */
-public class StorageServiceAdapter implements StorageService {
- @Override
- public <K, V> EventuallyConsistentMapBuilder<K, V> eventuallyConsistentMapBuilder() {
- return null;
- }
-
- @Override
- public <K, V> ConsistentMapBuilder<K, V> consistentMapBuilder() {
- return null;
- }
-
- @Override
- public <V> DocumentTreeBuilder<V> documentTreeBuilder() {
- return null;
- }
-
- @Override
- public <E> DistributedSetBuilder<E> setBuilder() {
- return null;
- }
-
- @Override
- public AtomicCounterBuilder atomicCounterBuilder() {
- return null;
- }
-
- @Override
- public AtomicIdGeneratorBuilder atomicIdGeneratorBuilder() {
- return null;
- }
-
- @Override
- public <V> AtomicValueBuilder<V> atomicValueBuilder() {
- return null;
- }
-
- @Override
- public TransactionContextBuilder transactionContextBuilder() {
- return null;
- }
-
- @Override
- public DistributedLockBuilder lockBuilder() {
- return null;
- }
-
- @Override
- public LeaderElectorBuilder leaderElectorBuilder() {
- return null;
- }
-
- @Override
- public <T> TopicBuilder<T> topicBuilder() {
- return null;
- }
-
- @Override
- public <E> WorkQueueBuilder<E> workQueueBuilder() {
- return null;
- }
-
- @Override
- public <E> WorkQueue<E> getWorkQueue(String name, Serializer serializer) {
- return null;
- }
-
- @Override
- public <K, V> AsyncConsistentMultimap<K, V> getAsyncSetMultimap(String name, Serializer serializer) {
- return null;
- }
-
- @Override
- public <V> AsyncConsistentTreeMap<V> getAsyncTreeMap(String name, Serializer serializer) {
- return null;
- }
-
- @Override
- public <T> Topic<T> getTopic(String name, Serializer serializer) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public <V> ConsistentTreeMapBuilder<V> consistentTreeMapBuilder() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public <V> AsyncDocumentTree<V> getDocumentTree(String name, Serializer serializer) {
- return null;
- }
-
- public <K, V> ConsistentMultimapBuilder<K, V> consistentMultimapBuilder() {
- return null;
- }
-
- @Override
- public <K> AtomicCounterMapBuilder<K> atomicCounterMapBuilder() {
- return null;
- }
-}
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestAtomicCounter.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestAtomicCounter.java
deleted file mode 100644
index 88ca5e1..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestAtomicCounter.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore.util;
-
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.onosproject.store.service.AsyncAtomicCounter;
-import org.onosproject.store.service.AtomicCounterBuilder;
-
-/**
- * Test implementation of atomic counter.
- */
-public final class TestAtomicCounter implements AsyncAtomicCounter {
- final AtomicLong value;
-
- @Override
- public String name() {
- return null;
- }
-
- private TestAtomicCounter() {
- value = new AtomicLong();
- }
-
- @Override
- public CompletableFuture<Long> incrementAndGet() {
- return CompletableFuture.completedFuture(value.incrementAndGet());
- }
-
- @Override
- public CompletableFuture<Long> getAndIncrement() {
- return CompletableFuture.completedFuture(value.getAndIncrement());
- }
-
- @Override
- public CompletableFuture<Long> getAndAdd(long delta) {
- return CompletableFuture.completedFuture(value.getAndAdd(delta));
- }
-
- @Override
- public CompletableFuture<Long> addAndGet(long delta) {
- return CompletableFuture.completedFuture(value.addAndGet(delta));
- }
-
- @Override
- public CompletableFuture<Void> set(long value) {
- this.value.set(value);
- return CompletableFuture.completedFuture(null);
- }
-
- @Override
- public CompletableFuture<Boolean> compareAndSet(long expectedValue, long updateValue) {
- return CompletableFuture.completedFuture(value.compareAndSet(expectedValue, updateValue));
- }
-
- @Override
- public CompletableFuture<Long> get() {
- return CompletableFuture.completedFuture(value.get());
- }
-
- public static AtomicCounterBuilder builder() {
- return new Builder();
- }
-
- public static class Builder extends AtomicCounterBuilder {
- @Override
- public AsyncAtomicCounter build() {
- return new TestAtomicCounter();
- }
- }
-}
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestConsistentMap.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestConsistentMap.java
deleted file mode 100644
index 4c02ba9..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestConsistentMap.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore.util;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-
-import org.onosproject.store.primitives.ConsistentMapBackedJavaMap;
-import org.onosproject.store.service.AsyncConsistentMap;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.ConsistentMapAdapter;
-import org.onosproject.store.service.ConsistentMapBuilder;
-import org.onosproject.store.service.MapEvent;
-import org.onosproject.store.service.MapEventListener;
-import org.onosproject.store.service.Versioned;
-
-import com.google.common.base.Objects;
-
-/**
- * Test implementation of the consistent map.
- */
-public final class TestConsistentMap<K, V> extends ConsistentMapAdapter<K, V> {
-
- private final List<MapEventListener<K, V>> listeners;
- private final Map<K, Versioned<V>> map;
- private final String mapName;
- private final AtomicLong counter = new AtomicLong(0);
-
- private TestConsistentMap(String mapName) {
- map = new HashMap<>();
- listeners = new LinkedList<>();
- this.mapName = mapName;
- }
-
- private Versioned<V> version(V v) {
- return new Versioned<>(v, counter.incrementAndGet(), System.currentTimeMillis());
- }
-
- /**
- * Notify all listeners of an event.
- */
- private void notifyListeners(String mapName,
- K key, Versioned<V> newvalue, Versioned<V> oldValue) {
- MapEvent<K, V> event = new MapEvent<>(mapName, key, newvalue, oldValue);
- listeners.forEach(
- listener -> listener.event(event)
- );
- }
-
- @Override
- public int size() {
- return map.size();
- }
-
- @Override
- public boolean isEmpty() {
- return map.isEmpty();
- }
-
- @Override
- public boolean containsKey(K key) {
- return map.containsKey(key);
- }
-
- @Override
- public boolean containsValue(V value) {
- return map.containsValue(value);
- }
-
- @Override
- public Versioned<V> get(K key) {
- return map.get(key);
- }
-
- @Override
- public Versioned<V> computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
- AtomicBoolean updated = new AtomicBoolean(false);
- Versioned<V> result = map.compute(key, (k, v) -> {
- if (v == null) {
- updated.set(true);
- return version(mappingFunction.apply(key));
- }
- return v;
- });
- if (updated.get()) {
- notifyListeners(mapName, key, result, null);
- }
- return result;
- }
-
- @Override
- public Versioned<V> compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
- AtomicBoolean updated = new AtomicBoolean(false);
- AtomicReference<Versioned<V>> previousValue = new AtomicReference<>();
- Versioned<V> result = map.compute(key, (k, v) -> {
- updated.set(true);
- previousValue.set(v);
- return version(remappingFunction.apply(k, Versioned.valueOrNull(v)));
- });
- if (updated.get()) {
- notifyListeners(mapName, key, result, previousValue.get());
- }
- return result;
- }
-
- @Override
- public Versioned<V> computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
- AtomicBoolean updated = new AtomicBoolean(false);
- AtomicReference<Versioned<V>> previousValue = new AtomicReference<>();
- Versioned<V> result = map.compute(key, (k, v) -> {
- if (v != null) {
- updated.set(true);
- previousValue.set(v);
- return version(remappingFunction.apply(k, v.value()));
- }
- return v;
- });
- if (updated.get()) {
- notifyListeners(mapName, key, result, previousValue.get());
- }
- return result;
- }
-
- @Override
- public Versioned<V> computeIf(K key, Predicate<? super V> condition,
- BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
- AtomicBoolean updated = new AtomicBoolean(false);
- AtomicReference<Versioned<V>> previousValue = new AtomicReference<>();
- Versioned<V> result = map.compute(key, (k, v) -> {
- if (condition.test(Versioned.valueOrNull(v))) {
- previousValue.set(v);
- updated.set(true);
- return version(remappingFunction.apply(k, Versioned.valueOrNull(v)));
- }
- return v;
- });
- if (updated.get()) {
- notifyListeners(mapName, key, result, previousValue.get());
- }
- return result;
- }
-
- @Override
- public Versioned<V> put(K key, V value) {
- Versioned<V> newValue = version(value);
- Versioned<V> previousValue = map.put(key, newValue);
- notifyListeners(mapName, key, newValue, previousValue);
- return previousValue;
- }
-
- @Override
- public Versioned<V> putAndGet(K key, V value) {
- Versioned<V> newValue = version(value);
- Versioned<V> previousValue = map.put(key, newValue);
- notifyListeners(mapName, key, newValue, previousValue);
- return newValue;
- }
-
- @Override
- public Versioned<V> remove(K key) {
- Versioned<V> result = map.remove(key);
- notifyListeners(mapName, key, null, result);
- return result;
- }
-
- @Override
- public void clear() {
- map.keySet().forEach(this::remove);
- }
-
- @Override
- public Set<K> keySet() {
- return map.keySet();
- }
-
- @Override
- public Collection<Versioned<V>> values() {
- return map.values()
- .stream()
- .collect(Collectors.toList());
- }
-
- @Override
- public Set<Map.Entry<K, Versioned<V>>> entrySet() {
- return map.entrySet();
- }
-
- @Override
- public Versioned<V> putIfAbsent(K key, V value) {
- Versioned<V> newValue = version(value);
- Versioned<V> result = map.putIfAbsent(key, newValue);
- if (result == null) {
- notifyListeners(mapName, key, newValue, result);
- }
- return result;
- }
-
- @Override
- public boolean remove(K key, V value) {
- Versioned<V> existingValue = map.get(key);
- if (Objects.equal(Versioned.valueOrNull(existingValue), value)) {
- map.remove(key);
- notifyListeners(mapName, key, null, existingValue);
- return true;
- }
- return false;
- }
-
- @Override
- public boolean remove(K key, long version) {
- Versioned<V> existingValue = map.get(key);
- if (existingValue == null) {
- return false;
- }
- if (existingValue.version() == version) {
- map.remove(key);
- notifyListeners(mapName, key, null, existingValue);
- return true;
- }
- return false;
- }
-
- @Override
- public Versioned<V> replace(K key, V value) {
- Versioned<V> existingValue = map.get(key);
- if (existingValue == null) {
- return null;
- }
- Versioned<V> newValue = version(value);
- Versioned<V> result = map.put(key, newValue);
- notifyListeners(mapName, key, newValue, result);
- return result;
- }
-
- @Override
- public boolean replace(K key, V oldValue, V newValue) {
- Versioned<V> existingValue = map.get(key);
- if (existingValue == null || !existingValue.value().equals(oldValue)) {
- return false;
- }
- Versioned<V> value = version(newValue);
- Versioned<V> result = map.put(key, value);
- notifyListeners(mapName, key, value, result);
- return true;
- }
-
- @Override
- public boolean replace(K key, long oldVersion, V newValue) {
- Versioned<V> existingValue = map.get(key);
- if (existingValue == null || existingValue.version() != oldVersion) {
- return false;
- }
- Versioned<V> value = version(newValue);
- Versioned<V> result = map.put(key, value);
- notifyListeners(mapName, key, value, result);
- return true;
- }
-
- @Override
- public void addListener(MapEventListener<K, V> listener) {
- listeners.add(listener);
- }
-
- @Override
- public void removeListener(MapEventListener<K, V> listener) {
- listeners.remove(listener);
- }
-
- @Override
- public Map<K, V> asJavaMap() {
- return new ConsistentMapBackedJavaMap<>(this);
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder<K, V> extends ConsistentMapBuilder<K, V> {
-
- @Override
- public ConsistentMap<K, V> build() {
- return new TestConsistentMap<>(name());
- }
-
- @Override
- public AsyncConsistentMap<K, V> buildAsyncMap() {
- return null;
- }
-
- }
-
-}
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestDistributedSet.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestDistributedSet.java
deleted file mode 100644
index aa4468a..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestDistributedSet.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcelabelstore.util;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
-import org.onosproject.store.primitives.DefaultDistributedSet;
-import org.onosproject.store.service.AsyncDistributedSet;
-import org.onosproject.store.service.DistributedSet;
-import org.onosproject.store.service.DistributedSetAdapter;
-import org.onosproject.store.service.DistributedSetBuilder;
-import org.onosproject.store.service.SetEvent;
-import org.onosproject.store.service.SetEventListener;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CompletableFuture;
-
-/**
- * Test implementation of the distributed set.
- */
-public final class TestDistributedSet<E> extends DistributedSetAdapter<E> {
- private final List<SetEventListener<E>> listeners;
- private final Set<E> set;
- private final String setName;
-
- /**
- * Public constructor.
- *
- * @param setName name to be assigned to this set
- */
- public TestDistributedSet(String setName) {
- set = new HashSet<>();
- listeners = new LinkedList<>();
- this.setName = setName;
- }
-
- /**
- * Notify all listeners of a set event.
- *
- * @param event the SetEvent
- */
- private void notifyListeners(SetEvent<E> event) {
- listeners.forEach(
- listener -> listener.event(event)
- );
- }
-
- @Override
- public CompletableFuture<Void> addListener(SetEventListener<E> listener) {
- listeners.add(listener);
- return CompletableFuture.completedFuture(null);
- }
-
- @Override
- public CompletableFuture<Void> removeListener(SetEventListener<E> listener) {
- listeners.remove(listener);
- return CompletableFuture.completedFuture(null);
- }
-
- @Override
- public CompletableFuture<Boolean> add(E element) {
- SetEvent<E> event =
- new SetEvent<>(setName, SetEvent.Type.ADD, element);
- notifyListeners(event);
- return CompletableFuture.completedFuture(set.add(element));
- }
-
- @Override
- public CompletableFuture<Boolean> remove(E element) {
- SetEvent<E> event =
- new SetEvent<>(setName, SetEvent.Type.REMOVE, element);
- notifyListeners(event);
- return CompletableFuture.completedFuture(set.remove(element));
- }
-
- @Override
- public CompletableFuture<Integer> size() {
- return CompletableFuture.completedFuture(set.size());
- }
-
- @Override
- public CompletableFuture<Boolean> isEmpty() {
- return CompletableFuture.completedFuture(set.isEmpty());
- }
-
- @Override
- public CompletableFuture<Void> clear() {
- removeAll(ImmutableSet.copyOf(set));
- return CompletableFuture.completedFuture(null);
- }
-
- @Override
- public CompletableFuture<Boolean> contains(E element) {
- return CompletableFuture.completedFuture(set.contains(element));
- }
-
- @Override
- public CompletableFuture<Boolean> addAll(Collection<? extends E> c) {
- c.forEach(this::add);
- return CompletableFuture.completedFuture(true);
- }
-
- @Override
- public CompletableFuture<Boolean> containsAll(Collection<? extends E> c) {
- return CompletableFuture.completedFuture(set.containsAll(c));
- }
-
- @Override
- public CompletableFuture<Boolean> retainAll(Collection<? extends E> c) {
- Set notInSet2;
- notInSet2 = Sets.difference(set, (Set<?>) c);
- return removeAll(ImmutableSet.copyOf(notInSet2));
- }
-
- @Override
- public CompletableFuture<Boolean> removeAll(Collection<? extends E> c) {
- c.forEach(this::remove);
- return CompletableFuture.completedFuture(true);
- }
-
- @Override
- public CompletableFuture<? extends Set<E>> getAsImmutableSet() {
- return CompletableFuture.completedFuture(ImmutableSet.copyOf(set));
- }
-
- @Override
- public String name() {
- return this.setName;
- }
-
- @Override
- public DistributedSet<E> asDistributedSet() {
- return new DefaultDistributedSet<>(this, 0);
- }
-
- @Override
- public DistributedSet<E> asDistributedSet(long timeoutMillis) {
- return new DefaultDistributedSet<>(this, timeoutMillis);
- }
-
- /**
- * Returns a new Builder instance.
- *
- * @return Builder
- **/
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder constructor that instantiates a TestDistributedSet.
- *
- * @param <E>
- */
- public static class Builder<E> extends DistributedSetBuilder<E> {
- @Override
- public AsyncDistributedSet<E> build() {
- return new TestDistributedSet(name());
- }
- }
-}
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestEventuallyConsistentMap.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestEventuallyConsistentMap.java
deleted file mode 100644
index 7872355..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestEventuallyConsistentMap.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore.util;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.function.BiFunction;
-
-import org.onlab.util.KryoNamespace;
-import org.onosproject.cluster.NodeId;
-import org.onosproject.store.Timestamp;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.EventuallyConsistentMapAdapter;
-import org.onosproject.store.service.EventuallyConsistentMapBuilder;
-import org.onosproject.store.service.EventuallyConsistentMapEvent;
-import org.onosproject.store.service.EventuallyConsistentMapListener;
-
-import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.PUT;
-import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.REMOVE;
-
-/**
- * Testing version of an Eventually Consistent Map.
- */
-
-public final class TestEventuallyConsistentMap<K, V> extends EventuallyConsistentMapAdapter<K, V> {
-
- private final HashMap<K, V> map;
- private final String mapName;
- private final List<EventuallyConsistentMapListener<K, V>> listeners;
- private final BiFunction<K, V, Collection<NodeId>> peerUpdateFunction;
-
- private TestEventuallyConsistentMap(String mapName,
- BiFunction<K, V, Collection<NodeId>> peerUpdateFunction) {
- map = new HashMap<>();
- listeners = new LinkedList<>();
- this.mapName = mapName;
- this.peerUpdateFunction = peerUpdateFunction;
- }
-
- /**
- * Notify all listeners of an event.
- */
- private void notifyListeners(EventuallyConsistentMapEvent<K, V> event) {
- listeners.forEach(
- listener -> listener.event(event)
- );
- }
-
- @Override
- public int size() {
- return map.size();
- }
-
- @Override
- public boolean isEmpty() {
- return map.isEmpty();
- }
-
- @Override
- public boolean containsKey(K key) {
- return map.containsKey(key);
- }
-
- @Override
- public boolean containsValue(V value) {
- return map.containsValue(value);
- }
-
- @Override
- public V get(K key) {
- return map.get(key);
- }
-
- @SuppressWarnings("ReturnValueIgnored")
- @Override
- public void put(K key, V value) {
- map.put(key, value);
- EventuallyConsistentMapEvent<K, V> addEvent =
- new EventuallyConsistentMapEvent<>(mapName, PUT, key, value);
- notifyListeners(addEvent);
- if (peerUpdateFunction != null) {
- peerUpdateFunction.apply(key, value);
- }
- }
-
- @Override
- public V remove(K key) {
- V result = map.remove(key);
- if (result != null) {
- EventuallyConsistentMapEvent<K, V> removeEvent =
- new EventuallyConsistentMapEvent<>(mapName, REMOVE,
- key, map.get(key));
- notifyListeners(removeEvent);
- }
- return result;
- }
-
- @Override
- public void remove(K key, V value) {
- boolean removed = map.remove(key, value);
- if (removed) {
- EventuallyConsistentMapEvent<K, V> removeEvent =
- new EventuallyConsistentMapEvent<>(mapName, REMOVE, key, value);
- notifyListeners(removeEvent);
- }
- }
-
- @Override
- public V compute(K key, BiFunction<K, V, V> recomputeFunction) {
- return map.compute(key, recomputeFunction);
- }
-
- @Override
- public void putAll(Map<? extends K, ? extends V> m) {
- map.putAll(m);
- }
-
- @Override
- public void clear() {
- map.clear();
- }
-
- @Override
- public Set<K> keySet() {
- return map.keySet();
- }
-
- @Override
- public Collection<V> values() {
- return map.values();
- }
-
- @Override
- public Set<Map.Entry<K, V>> entrySet() {
- return map.entrySet();
- }
-
- public static <K, V> Builder<K, V> builder() {
- return new Builder<>();
- }
-
- @Override
- public void addListener(EventuallyConsistentMapListener<K, V> listener) {
- listeners.add(listener);
- }
-
- @Override
- public void removeListener(EventuallyConsistentMapListener<K, V> listener) {
- listeners.remove(listener);
- }
-
- public static class Builder<K, V> implements EventuallyConsistentMapBuilder<K, V> {
- private String name;
- private BiFunction<K, V, Collection<NodeId>> peerUpdateFunction;
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withName(String name) {
- this.name = name;
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withSerializer(KryoNamespace.Builder serializerBuilder) {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withSerializer(KryoNamespace serializer) {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V>
- withTimestampProvider(BiFunction<K, V, Timestamp> timestampProvider) {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withEventExecutor(ExecutorService executor) {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withCommunicationExecutor(ExecutorService executor) {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withBackgroundExecutor(ScheduledExecutorService executor) {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V>
- withPeerUpdateFunction(BiFunction<K, V, Collection<NodeId>> peerUpdateFunction) {
- this.peerUpdateFunction = peerUpdateFunction;
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withTombstonesDisabled() {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withAntiEntropyPeriod(long period, TimeUnit unit) {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withFasterConvergence() {
- return this;
- }
-
- @Override
- public EventuallyConsistentMapBuilder<K, V> withPersistence() {
- return this;
- }
-
- @Override
- public EventuallyConsistentMap<K, V> build() {
- if (name == null) {
- name = "test";
- }
- return new TestEventuallyConsistentMap<>(name, peerUpdateFunction);
- }
- }
-
-}
-
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestStorageService.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestStorageService.java
deleted file mode 100644
index cc09bef..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcelabelstore/util/TestStorageService.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcelabelstore.util;
-
-import org.onosproject.store.service.AtomicCounterBuilder;
-import org.onosproject.store.service.AtomicValueBuilder;
-import org.onosproject.store.service.ConsistentMapBuilder;
-import org.onosproject.store.service.ConsistentMultimapBuilder;
-import org.onosproject.store.service.DistributedSetBuilder;
-import org.onosproject.store.service.EventuallyConsistentMapBuilder;
-import org.onosproject.store.service.StorageServiceAdapter;
-import org.onosproject.store.service.TransactionContextBuilder;
-
-public class TestStorageService extends StorageServiceAdapter {
-
-
- @Override
- public <K, V> EventuallyConsistentMapBuilder<K, V> eventuallyConsistentMapBuilder() {
- return TestEventuallyConsistentMap.builder();
- }
-
- @Override
- public <K, V> ConsistentMapBuilder<K, V> consistentMapBuilder() {
- return TestConsistentMap.builder();
- }
-
- @Override
- public <K, V> ConsistentMultimapBuilder<K, V> consistentMultimapBuilder() {
- return null;
- }
-
- @Override
- public <E> DistributedSetBuilder<E> setBuilder() {
- return TestDistributedSet.builder();
- }
-
- @Override
- public AtomicCounterBuilder atomicCounterBuilder() {
- return TestAtomicCounter.builder();
- }
-
- @Override
- public <V> AtomicValueBuilder<V> atomicValueBuilder() {
- throw new UnsupportedOperationException("atomicValueBuilder");
- }
-
- @Override
- public TransactionContextBuilder transactionContextBuilder() {
- throw new UnsupportedOperationException("transactionContextBuilder");
- }
-
-}
diff --git a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcep/controller/impl/PcepClientControllerImplTest.java b/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcep/controller/impl/PcepClientControllerImplTest.java
deleted file mode 100644
index 73ff8d6..0000000
--- a/protocols/pcep/server/ctl/src/test/java/org/onosproject/pcep/controller/impl/PcepClientControllerImplTest.java
+++ /dev/null
@@ -1,555 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.pcep.controller.impl;
-
-import static org.onosproject.pcep.server.PcepLspSyncAction.SEND_UPDATE;
-import static org.onosproject.pcep.server.PcepLspSyncAction.UNSTABLE;
-
-import java.net.SocketAddress;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelConfig;
-import org.jboss.netty.channel.ChannelFactory;
-import org.jboss.netty.channel.ChannelFuture;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelListener;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.incubator.net.tunnel.TunnelSubscription;
-import org.onosproject.incubator.net.tunnel.Tunnel.Type;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.ElementId;
-import org.onosproject.net.Path;
-import org.onosproject.pcep.server.ClientCapability;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepEventListener;
-import org.onosproject.pcep.server.PcepLspSyncAction;
-import org.onosproject.pcep.server.PcepPacketStats;
-import org.onosproject.pcep.server.PcepSyncStatus;
-import org.onosproject.pcep.server.driver.PcepAgent;
-import org.onosproject.pcep.server.impl.PcepClientControllerImpl;
-import org.onosproject.pcep.server.impl.PcepClientImpl;
-import org.onosproject.pcep.server.impl.PcepPacketStatsImpl;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepFactories;
-import org.onosproject.pcepio.protocol.PcepInitiateMsg;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import com.google.common.collect.ImmutableSet;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-
-public class PcepClientControllerImplTest {
- TestPcepClientControllerImpl controllerImpl = new TestPcepClientControllerImpl();
- TunnelService tunnelService = new MockTunnelService();
- private PcepEventListener listener;
- private Channel channel;
-
- @Before
- public void startUp() {
- controllerImpl.setTunnelService(tunnelService);
- listener = new PcepEventListenerAdapter();
- controllerImpl.addEventListener(listener);
- channel = new MockChannel();
- }
-
- @After
- public void tearDown() {
- controllerImpl.removeEventListener(listener);
- listener = null;
- controllerImpl.setTunnelService(null);
- }
-
- @Test
- public void tunnelProviderAddedTest1() throws PcepParseException, PcepOutOfBoundMessageException {
- PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1"));
-
- byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x50, 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, // SRP object
- 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
- 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x00, 0x24, // LSP object
- 0x00, 0x00, 0x10, (byte) 0xAB,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path tlv
- 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
- 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05,
- 0x05, 0x05, 0x05,
-
- 0x07, 0x10, 0x00, 0x14, // ERO object
- 0x01, 0x08, (byte) 0x01, 0x01, // ERO IPv4 sub objects
- 0x01, 0x01, 0x04, 0x00,
- 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = reader.readFrom(buffer);
-
- PcepClientImpl pc = new PcepClientImpl();
- PcepPacketStats pktStats = new PcepPacketStatsImpl();
-
- pc.init(pccId, PcepVersion.PCEP_1, pktStats);
- pc.setChannel(channel);
- pc.setAgent(controllerImpl.agent());
- pc.setConnected(true);
- pc.setCapability(new ClientCapability(true, true, true, true, true));
-
- controllerImpl.agent().addConnectedClient(pccId, pc);
- controllerImpl.processClientMessage(pccId, message);
-
- pc.setLspDbSyncStatus(PcepSyncStatus.SYNCED);
- pc.setLabelDbSyncStatus(PcepSyncStatus.IN_SYNC);
- pc.setLabelDbSyncStatus(PcepSyncStatus.SYNCED);
-
- List<PcepMessage> deleteMsgs = ((MockChannel) channel).msgsWritten();
- assertThat(deleteMsgs.size(), is(1));
-
- for (PcepMessage msg : deleteMsgs) {
- assertThat(((PcepInitiateMsg) msg).getPcInitiatedLspRequestList().getFirst().getSrpObject().getRFlag(),
- is(true));
- }
- }
-
- @Test
- public void tunnelProviderAddedTest2() throws PcepParseException, PcepOutOfBoundMessageException {
- PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1"));
-
- byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x50, 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, // SRP object
- 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
- 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x00, 0x24, 0x00, // LSP object
- 0x00, 0x10, (byte) 0xAB,
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path tlv
- 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
- 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05,
- 0x05, 0x05, 0x05,
-
- 0x07, 0x10, 0x00, 0x14, // ERO object
- 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
- 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = reader.readFrom(buffer);
-
- PcepClientImpl pc = new PcepClientImpl();
- PcepPacketStats pktStats = new PcepPacketStatsImpl();
-
- pc.init(pccId, PcepVersion.PCEP_1, pktStats);
- pc.setChannel(channel);
- pc.setAgent(controllerImpl.agent());
- pc.setConnected(true);
- pc.setCapability(new ClientCapability(true, true, true, true, true));
-
- controllerImpl.agent().addConnectedClient(pccId, pc);
- controllerImpl.processClientMessage(pccId, message);
-
- pc.setLspDbSyncStatus(PcepSyncStatus.SYNCED);
- pc.setLabelDbSyncStatus(PcepSyncStatus.IN_SYNC);
- pc.setLabelDbSyncStatus(PcepSyncStatus.SYNCED);
- }
-
- class PcepEventListenerAdapter implements PcepEventListener {
-
- public List<PcepMessage> handledMsg = new ArrayList<>();
- public List<Tunnel> tunnelsToBeUpdatedToNw = new ArrayList<>();
- public List<Tunnel> deletedFromNwTunnels = new ArrayList<>();
-
- @Override
- public void handleMessage(PccId pccId, PcepMessage msg) {
- handledMsg.add(msg);
- }
-
- @Override
- public void handleEndOfSyncAction(Tunnel tunnel, PcepLspSyncAction endOfSyncAction) {
- if (endOfSyncAction == SEND_UPDATE) {
- tunnelsToBeUpdatedToNw.add(tunnel);
- return;
- } else if (endOfSyncAction == UNSTABLE) {
- deletedFromNwTunnels.add(tunnel);
- }
- }
- }
-
- class MockChannel implements Channel {
- private List<PcepMessage> msgOnWire = new ArrayList<>();
-
- @Override
- public ChannelFuture write(Object o) {
- if (o instanceof List<?>) {
- @SuppressWarnings("unchecked")
- List<PcepMessage> msgs = (List<PcepMessage>) o;
- for (PcepMessage msg : msgs) {
- if (msg instanceof PcepInitiateMsg) {
- msgOnWire.add(msg);
- }
- }
- }
- return null;
- }
-
- public List<PcepMessage> msgsWritten() {
- return msgOnWire;
- }
-
- @Override
- public int compareTo(Channel o) {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public Integer getId() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ChannelFactory getFactory() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Channel getParent() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ChannelConfig getConfig() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ChannelPipeline getPipeline() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean isOpen() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean isBound() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean isConnected() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public SocketAddress getLocalAddress() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public SocketAddress getRemoteAddress() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ChannelFuture write(Object message, SocketAddress remoteAddress) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ChannelFuture bind(SocketAddress localAddress) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ChannelFuture connect(SocketAddress remoteAddress) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ChannelFuture disconnect() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ChannelFuture unbind() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ChannelFuture close() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ChannelFuture getCloseFuture() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public int getInterestOps() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public boolean isReadable() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean isWritable() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public ChannelFuture setInterestOps(int interestOps) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ChannelFuture setReadable(boolean readable) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean getUserDefinedWritability(int index) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public void setUserDefinedWritability(int index, boolean isWritable) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public Object getAttachment() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void setAttachment(Object attachment) {
- // TODO Auto-generated method stub
-
- }
- }
-
- class MockTunnelService implements TunnelService {
- private HashMap<TunnelId, Tunnel> tunnelIdAsKeyStore = new HashMap<TunnelId, Tunnel>();
- private int tunnelIdCounter = 0;
-
- @Override
- public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) {
- TunnelId tunnelId = TunnelId.valueOf(String.valueOf(++tunnelIdCounter));
- Tunnel tunnelToInsert = new DefaultTunnel(tunnel.providerId(), tunnel.src(), tunnel.dst(), tunnel.type(),
- tunnel.state(), tunnel.groupId(), tunnelId, tunnel.tunnelName(),
- path, tunnel.annotations());
- tunnelIdAsKeyStore.put(tunnelId, tunnelToInsert);
- return tunnelId;
- }
-
- @Override
- public Tunnel queryTunnel(TunnelId tunnelId) {
- for (TunnelId tunnelIdKey : tunnelIdAsKeyStore.keySet()) {
- if (tunnelIdKey.equals(tunnelId)) {
- return tunnelIdAsKeyStore.get(tunnelId);
- }
- }
- return null;
- }
-
- @Override
- public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) {
- Collection<Tunnel> result = new HashSet<Tunnel>();
- Tunnel tunnel = null;
- for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
- tunnel = tunnelIdAsKeyStore.get(tunnelId);
-
- if ((null != tunnel) && (src.equals(tunnel.src())) && (dst.equals(tunnel.dst()))) {
- result.add(tunnel);
- }
- }
-
- return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result);
- }
-
- @Override
- public Collection<Tunnel> queryTunnel(Tunnel.Type type) {
- Collection<Tunnel> result = new HashSet<Tunnel>();
-
- for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
- result.add(tunnelIdAsKeyStore.get(tunnelId));
- }
-
- return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result);
- }
-
- @Override
- public Collection<Tunnel> queryAllTunnels() {
- Collection<Tunnel> result = new HashSet<Tunnel>();
-
- for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
- result.add(tunnelIdAsKeyStore.get(tunnelId));
- }
-
- return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result);
- }
-
- @Override
- public void addListener(TunnelListener listener) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void removeListener(TunnelListener listener) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public Tunnel borrowTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelName tunnelName,
- Annotations... annotations) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst,
- Annotations... annotations) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst,
- Type type, Annotations... annotations) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean downTunnel(ApplicationId producerId, TunnelId tunnelId) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean returnTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean returnTunnel(ApplicationId consumerId, TunnelName tunnelName, Annotations... annotations) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, Type type,
- Annotations... annotations) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst,
- Annotations... annotations) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public int tunnelCount() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public Iterable<Tunnel> getTunnels(DeviceId deviceId) {
- // TODO Auto-generated method stub
- return null;
- }
- }
-
- private class TestPcepClientControllerImpl extends PcepClientControllerImpl {
- public void setTunnelService(TunnelService tunnelService) {
- this.tunnelService = tunnelService;
- }
-
- public PcepAgent agent() {
- return this.agent;
- }
- }
-}
diff --git a/providers/bgp/BUILD b/providers/bgp/BUILD
deleted file mode 100644
index b47739a..0000000
--- a/providers/bgp/BUILD
+++ /dev/null
@@ -1,22 +0,0 @@
-BUNDLES = [
- "//providers/bgp/cfg:onos-providers-bgp-cfg",
- "//providers/bgp/topology:onos-providers-bgp-topology",
- "//providers/bgp/route:onos-providers-bgp-route",
- "//providers/bgp/cli:onos-providers-bgp-cli",
- "//protocols/bgp/api:onos-protocols-bgp-api",
- "//protocols/bgp/ctl:onos-protocols-bgp-ctl",
- "//protocols/bgp/bgpio:onos-protocols-bgp-bgpio",
-]
-
-onos_app(
- category = "Provider",
- description = "BGP protocol southbound providers.",
- included_bundles = BUNDLES,
- required_apps = [
- "org.onosproject.evpn-route-service",
- "org.onosproject.tunnel",
- "org.onosproject.pcep-api",
- ],
- title = "BGP Provider",
- url = "http://onosproject.org",
-)
diff --git a/providers/bgp/cfg/BUILD b/providers/bgp/cfg/BUILD
deleted file mode 100644
index da88670..0000000
--- a/providers/bgp/cfg/BUILD
+++ /dev/null
@@ -1,7 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + JACKSON + [
- "//protocols/bgp/api:onos-protocols-bgp-api",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
diff --git a/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java b/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java
deleted file mode 100644
index d090420..0000000
--- a/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java
+++ /dev/null
@@ -1,498 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.bgp.cfg.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onlab.packet.IpAddress;
-import org.onosproject.bgp.controller.BgpCfg;
-import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.config.Config;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.net.config.Config.FieldPresence.MANDATORY;
-import static org.onosproject.net.config.Config.FieldPresence.OPTIONAL;
-
-/**
- * Configuration object for BGP.
- */
-public class BgpAppConfig extends Config<ApplicationId> {
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- BgpController bgpController;
-
- BgpCfg bgpConfig = null;
-
- protected final Logger log = LoggerFactory.getLogger(BgpAppConfig.class);
- public static final String ROUTER_ID = "routerId";
- public static final String LOCAL_AS = "localAs";
- public static final String MAX_SESSION = "maxSession";
- public static final String LS_CAPABILITY = "lsCapability";
- public static final String HOLD_TIME = "holdTime";
- public static final String LARGE_AS_CAPABILITY = "largeAsCapability";
- public static final String FLOW_SPEC_CAPABILITY = "flowSpecCapability";
- public static final String FLOW_SPEC_RPD_CAPABILITY = "flowSpecRpdCapability";
- public static final String EVPN_CAPABILITY = "evpnCapability";
-
- public static final String BGP_PEER = "bgpPeer";
- public static final String PEER_IP = "peerIp";
- public static final String REMOTE_AS = "remoteAs";
- public static final String PEER_HOLD_TIME = "peerHoldTime";
- public static final String PEER_CONNECT_MODE = "connectMode";
- public static final String PEER_CONNECT_PASSIVE = "passive";
- public static final String PEER_CONNECT_ACTIVE = "active";
-
- public static final String CONNECTION_TYPE = "connectionType";
- public static final String CONNECTION_TYPE_IPV4 = "IPV4";
- public static final String CONNECTION_TYPE_IPV6 = "IPV6";
- public static final String CONNECTION_TYPE_IPV4_AND_IPV6 = "IPV4_IPV6";
-
- public static final String ROUTE_REFRESH_ENABLED = "routeRefreshEnabled";
- public static final String RR_PERIODIC_TIMER = "rrPeriodicTimer";
- public static final String RR_COOLDOWN_TIMER = "rrCooldownTimer";
- public static final String RR_WARMUP_TIMER = "rrWarmupTimer";
-
- static final int MAX_SHORT_AS_NUMBER = 65535;
- static final long MAX_LONG_AS_NUMBER = 4294967295L;
-
- static final int MIN_SESSION_NUMBER = 1;
- static final long MAX_SESSION_NUMBER = 21;
-
- static final int MIN_HOLDTIME = 0;
- static final long MAX_HOLDTIME = 65535;
-
- static final String RR_ENABLED_DEFAULT_VALUE = "false";
- static final String PERIODIC_TIMER_DEFAULT_VALUE = "1800"; //30 minutes
- static final String COOLDOWN_TIMER_DEFAULT_VALUE = "300"; //5 minutes
- static final String WARMUP_TIMER_DEFAULT_VALUE = "30"; //30 seconds
-
- static final long MIN_PERIODIC_TIMER = 1;
- static final long MAX_PERIODIC_TIMER = Integer.MAX_VALUE;
- static final long MIN_COOLDOWN_TIMER = 1;
- static final long MAX_COOLDOWN_TIMER = Integer.MAX_VALUE;
- static final long MIN_WARMUP_TIMER = 1;
- static final long MAX_WARMUP_TIMER = Integer.MAX_VALUE;
-
- @Override
- public boolean isValid() {
- boolean fields = false;
-
- this.bgpController = DefaultServiceDirectory.getService(BgpController.class);
- bgpConfig = bgpController.getConfig();
-
- fields = hasOnlyFields(ROUTER_ID, LOCAL_AS, MAX_SESSION, LS_CAPABILITY,
- HOLD_TIME, LARGE_AS_CAPABILITY, FLOW_SPEC_CAPABILITY,
- FLOW_SPEC_RPD_CAPABILITY, BGP_PEER, EVPN_CAPABILITY, CONNECTION_TYPE,
- ROUTE_REFRESH_ENABLED, RR_PERIODIC_TIMER, RR_COOLDOWN_TIMER, RR_WARMUP_TIMER) &&
- isIpAddress(ROUTER_ID, MANDATORY) && isNumber(LOCAL_AS, MANDATORY) &&
- isNumber(MAX_SESSION, OPTIONAL, MIN_SESSION_NUMBER, MAX_SESSION_NUMBER)
- && isNumber(HOLD_TIME, OPTIONAL, MIN_HOLDTIME, MAX_HOLDTIME) &&
- isBoolean(LS_CAPABILITY, OPTIONAL) && isBoolean(LARGE_AS_CAPABILITY, OPTIONAL) &&
- isString(FLOW_SPEC_CAPABILITY, OPTIONAL) && isBoolean(FLOW_SPEC_RPD_CAPABILITY, OPTIONAL)
- && isBoolean(EVPN_CAPABILITY, OPTIONAL) && isString(CONNECTION_TYPE, OPTIONAL)
- && isBoolean(ROUTE_REFRESH_ENABLED, OPTIONAL)
- && isNumber(RR_PERIODIC_TIMER, OPTIONAL, MIN_PERIODIC_TIMER, MAX_PERIODIC_TIMER)
- && isNumber(RR_COOLDOWN_TIMER, OPTIONAL, MIN_COOLDOWN_TIMER, MAX_COOLDOWN_TIMER)
- && isNumber(RR_WARMUP_TIMER, OPTIONAL, MIN_WARMUP_TIMER, MAX_WARMUP_TIMER);
-
- if (!fields) {
- return fields;
- }
-
- return validateBgpConfiguration();
- }
-
- /**
- * Returns routerId from the configuration.
- *
- * @return routerId
- */
- public String routerId() {
- return get(ROUTER_ID, null);
- }
-
- /**
- * Returns localAs number from the configuration.
- *
- * @return local As number
- */
- public int localAs() {
- return Integer.parseInt(get(LOCAL_AS, null));
- }
-
- /**
- * Returns max session from the configuration.
- *
- * @return max session
- */
- public int maxSession() {
- return Integer.parseInt(get(MAX_SESSION, null));
- }
-
- /**
- * Returns BGP-LS capability support from the configuration.
- *
- * @return true if BGP-LS capability is set else false
- */
- public boolean lsCapability() {
- return Boolean.parseBoolean(get(LS_CAPABILITY, null));
- }
-
- /**
- * Returns flow spec route policy distribution capability support from the configuration.
- *
- * @return true if flow spec route policy distribution capability is set otherwise false
- */
- public boolean rpdCapability() {
- return Boolean.parseBoolean(get(FLOW_SPEC_RPD_CAPABILITY, null));
- }
-
- /**
- * Returns largeAs capability support from the configuration.
- *
- * @return largeAs capability
- */
- public boolean largeAsCapability() {
- return Boolean.parseBoolean(get(LARGE_AS_CAPABILITY, null));
- }
-
- /**
- * Returns flow specification capability support from the configuration.
- *
- * @return flow specification capability
- */
- public String flowSpecCapability() {
- return get(FLOW_SPEC_CAPABILITY, null);
- }
-
- /**
- * Returns holdTime of the local node from the configuration.
- *
- * @return holdTime
- */
- public short holdTime() {
- return Short.parseShort(get(HOLD_TIME, null));
- }
-
- /**
- * Returns BGP connection type from the configuration.
- *
- * @return BGP connection type
- */
- public String connectionType() {
- return get(CONNECTION_TYPE, null);
- }
-
- /**
- * Returns if route refresh is enabled in the configuration.
- *
- * @return route refresh enabled
- */
- public boolean routeRefreshEnabled() {
- return Boolean.parseBoolean(get(ROUTE_REFRESH_ENABLED, RR_ENABLED_DEFAULT_VALUE));
- }
-
- /**
- * Returns value of route refresh periodic timer from the configuration.
- *
- * @return route refresh periodic timer
- */
- public long rrPeriodicTimer() {
- return Long.parseLong(get(RR_PERIODIC_TIMER, PERIODIC_TIMER_DEFAULT_VALUE));
- }
-
- /**
- * Returns value of route refresh warmup timer from the configuration.
- *
- * @return route refresh warmup timer
- */
- public long rrWarmupTimer() {
- return Long.parseLong(get(RR_WARMUP_TIMER, WARMUP_TIMER_DEFAULT_VALUE));
- }
-
- /**
- * Returns value of route refresh cooldown timer from the configuration.
- *
- * @return route refresh cooldown timer
- */
- public long rrCooldownTimer() {
- return Long.parseLong(get(RR_COOLDOWN_TIMER, COOLDOWN_TIMER_DEFAULT_VALUE));
- }
-
- /**
- * Validates the BGP connection type.
- *
- * @return true if valid else false
- */
- public boolean validateConnectionType() {
- if (connectionType() != null) {
- String connectionType = connectionType();
- if (!connectionType.equals(CONNECTION_TYPE_IPV4) && !connectionType.equals(CONNECTION_TYPE_IPV6)
- && !connectionType.equals(CONNECTION_TYPE_IPV4_AND_IPV6)) {
- log.error("Connection Type is invalid");
- return false;
- }
- }
- log.debug("Connection Type is valid");
- return true;
- }
-
- /**
- * Validates the flow specification capability.
- *
- * @return true if valid else false
- */
- public boolean validateFlowSpec() {
- if (flowSpecCapability() != null) {
- String flowSpec = flowSpecCapability();
- if ((!flowSpec.equals("IPV4")) && (!flowSpec.equals("VPNV4")) && (!flowSpec.equals("IPV4_VPNV4"))) {
- log.debug("Flow specification capabality is false");
- return false;
- }
- }
- log.debug("Flow specification capabality is true");
- return true;
- }
-
- /**
- * Returns evpn capability support from the configuration.
- *
- * @return evpn capability
- */
- public boolean evpnCapability() {
- return Boolean.parseBoolean(get(EVPN_CAPABILITY, null));
- }
-
- /**
- * Validates the hold time value.
- *
- * @return true if valid else false
- */
- public boolean validateHoldTime() {
- if (holdTime() != 0) {
- short holdTime = holdTime();
- if ((holdTime == 1) || (holdTime == 2)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Validates the Bgp local and peer configuration.
- *
- * @return true if valid else false
- */
- public boolean validateBgpConfiguration() {
-
- if (!validateLocalAs()) {
- return false;
- }
-
- if (!validateRouterId()) {
- return false;
- }
-
- if (!validateBgpPeers()) {
- return false;
- }
-
- if (!validateFlowSpec()) {
- return false;
- }
-
- if (!validateHoldTime()) {
- return false;
- }
-
- if (!validateConnectionType()) {
- return false;
- }
- return true;
- }
-
- /**
- * Validates the Bgp As number.
- *
- * @return true if valid else false
- */
- public boolean validateLocalAs() {
-
- long localAs = 0;
- localAs = localAs();
-
- if (largeAsCapability()) {
-
- if (localAs == 0 || localAs >= MAX_LONG_AS_NUMBER) {
- return false;
- }
- } else {
- if (localAs == 0 || localAs >= MAX_SHORT_AS_NUMBER) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Validates the Bgp peer As number.
- *
- * @param remoteAs remote As number
- * @return true if valid else false
- */
- public boolean validateRemoteAs(long remoteAs) {
- if (largeAsCapability()) {
-
- if (remoteAs == 0 || remoteAs >= MAX_LONG_AS_NUMBER) {
- return false;
- }
- } else {
- if (remoteAs == 0 || remoteAs >= MAX_SHORT_AS_NUMBER) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Validates the Bgp Router ID configuration.
- *
- * @return true if valid else false
- */
- public boolean validateRouterId() {
- String routerId = routerId();
- // TODO: router ID validation
- return true;
- }
-
- /**
- * Validates the Bgp peer holdTime.
- *
- * @param remoteAs remote As number
- * @return true if valid else false
- */
- public boolean validatePeerHoldTime(long remoteAs) {
- //TODO:Validate it later..
- return true;
- }
-
- /**
- * Validates the Bgp peer configuration.
- *
- * @return true if valid else false
- */
- public boolean validateBgpPeers() {
- List<BgpPeerConfig> nodes;
- String connectMode;
-
- nodes = bgpPeer();
- for (int i = 0; i < nodes.size(); i++) {
- connectMode = nodes.get(i).connectMode();
- if ((IpAddress.valueOf(nodes.get(i).hostname()) == null) ||
- !validateRemoteAs(nodes.get(i).asNumber()) ||
- !validatePeerHoldTime(nodes.get(i).holdTime()) ||
- !(connectMode.equals(PEER_CONNECT_ACTIVE) || connectMode.equals(PEER_CONNECT_PASSIVE))) {
- log.debug("BGP peer configration false");
- return false;
- }
- }
- log.debug("BGP peer configration true");
- return true;
- }
-
- /**
- * Returns the set of nodes read from network config.
- *
- * @return list of BgpPeerConfig or null
- */
- public List<BgpPeerConfig> bgpPeer() {
- List<BgpPeerConfig> nodes = new ArrayList<BgpPeerConfig>();
- JsonNode jsonNodes = object.get(BGP_PEER);
- if (jsonNodes == null) {
- return null;
- }
-
- jsonNodes.forEach(jsonNode -> nodes.add(new BgpPeerConfig(
- jsonNode.path(PEER_IP).asText(),
- jsonNode.path(REMOTE_AS).asInt(),
- jsonNode.path(PEER_HOLD_TIME).asInt(),
- jsonNode.path(PEER_CONNECT_MODE).asText())));
-
- return nodes;
- }
-
- /**
- * Configuration for Bgp peer nodes.
- */
- public static class BgpPeerConfig {
-
- private final String hostname;
- private final int asNumber;
- private final short holdTime;
- private final String connectMode;
-
- public BgpPeerConfig(String hostname, int asNumber, int holdTime, String connectMode) {
- this.hostname = checkNotNull(hostname);
- this.asNumber = asNumber;
- this.holdTime = (short) holdTime;
- this.connectMode = connectMode;
- }
-
- /**
- * Returns hostname of the peer node.
- *
- * @return hostname
- */
- public String hostname() {
- return this.hostname;
- }
-
- /**
- * Returns asNumber if peer.
- *
- * @return asNumber
- */
- public int asNumber() {
- return this.asNumber;
- }
-
- /**
- * Returns holdTime of the peer node.
- *
- * @return holdTime
- */
- public short holdTime() {
- return this.holdTime;
- }
-
- /**
- * Returns connection mode for the peer node.
- *
- * @return active or passive connection
- */
- public String connectMode() {
- return this.connectMode;
- }
- }
-}
diff --git a/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpCfgProvider.java b/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpCfgProvider.java
deleted file mode 100644
index 798c0a2..0000000
--- a/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpCfgProvider.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.bgp.cfg.impl;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-
-import org.onosproject.bgp.controller.BgpCfg;
-import org.onosproject.bgp.controller.BgpPeerCfg;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigRegistry;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.config.basics.SubjectFactories;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.bgp.controller.BgpController;
-import org.slf4j.Logger;
-import org.osgi.service.component.ComponentContext;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * BGP config provider to validate and populate the configuration.
- */
-@Component(immediate = true)
-public class BgpCfgProvider extends AbstractProvider {
-
- private static final Logger log = getLogger(BgpCfgProvider.class);
-
- static final String PROVIDER_ID = "org.onosproject.provider.bgp.cfg";
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected BgpController bgpController;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigRegistry configRegistry;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigService configService;
-
- private final ConfigFactory configFactory =
- new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, BgpAppConfig.class, "bgpapp") {
- @Override
- public BgpAppConfig createConfig() {
- return new BgpAppConfig();
- }
- };
-
- private final NetworkConfigListener configListener = new InternalConfigListener();
-
- private ApplicationId appId;
-
- /**
- * Creates a Bgp config provider.
- */
- public BgpCfgProvider() {
- super(new ProviderId("bgp", PROVIDER_ID));
- }
-
- @Activate
- public void activate(ComponentContext context) {
- appId = coreService.registerApplication(PROVIDER_ID);
- configService.addListener(configListener);
- configRegistry.registerConfigFactory(configFactory);
- readConfiguration();
- log.info("BGP cfg provider started");
- }
-
- @Deactivate
- public void deactivate(ComponentContext context) {
- configRegistry.unregisterConfigFactory(configFactory);
- configService.removeListener(configListener);
- }
-
- void setBgpController(BgpController bgpController) {
- this.bgpController = bgpController;
- }
-
- /**
- * Reads the configuration and set it to the BGP-LS south bound protocol.
- */
- private void readConfiguration() {
- BgpCfg bgpConfig = null;
- List<BgpAppConfig.BgpPeerConfig> nodes;
- bgpConfig = bgpController.getConfig();
- BgpAppConfig config = configRegistry.getConfig(appId, BgpAppConfig.class);
-
- if (config == null) {
- log.warn("No configuration found");
- return;
- }
-
- /*Set the configuration */
- bgpConfig.setRouterId(config.routerId());
- bgpConfig.setAsNumber(config.localAs());
- bgpConfig.setLsCapability(config.lsCapability());
- bgpConfig.setHoldTime(config.holdTime());
- bgpConfig.setMaxSession(config.maxSession());
- bgpConfig.setLargeASCapability(config.largeAsCapability());
- bgpConfig.setEvpnCapability(config.evpnCapability());
-
- if (config.flowSpecCapability() == null) {
- bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.NONE);
- } else {
- if (config.flowSpecCapability().equals("IPV4")) {
- bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.IPV4);
- } else if (config.flowSpecCapability().equals("VPNV4")) {
- bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.VPNV4);
- } else if (config.flowSpecCapability().equals("IPV4_VPNV4")) {
- bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.IPV4_VPNV4);
- } else {
- bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.NONE);
- }
- }
- bgpConfig.setFlowSpecRpdCapability(config.rpdCapability());
-
- nodes = config.bgpPeer();
- for (int i = 0; i < nodes.size(); i++) {
- String connectMode = nodes.get(i).connectMode();
- bgpConfig.addPeer(nodes.get(i).hostname(), nodes.get(i).asNumber(), nodes.get(i).holdTime());
- if (connectMode.equals(BgpAppConfig.PEER_CONNECT_ACTIVE)) {
- bgpConfig.connectPeer(nodes.get(i).hostname());
- }
- }
-
- bgpConfig.setConnectionType(getBgpConnectionTypeFromConfig(config));
-
- bgpConfig.setRouteRefreshEnabled(config.routeRefreshEnabled());
- bgpConfig.setRouteRefreshPeriodicTimer(config.rrPeriodicTimer());
- bgpConfig.setRouteRefreshWarmupTimer(config.rrWarmupTimer());
- bgpConfig.setRouteRefreshCooldownTimer(config.rrCooldownTimer());
- }
-
- /**
- * Read the configuration and update it to the BGP-LS south bound protocol.
- */
- private void updateConfiguration() {
- BgpCfg bgpConfig = null;
- List<BgpAppConfig.BgpPeerConfig> nodes;
- TreeMap<String, BgpPeerCfg> bgpPeerTree;
- bgpConfig = bgpController.getConfig();
- BgpPeerCfg peer = null;
- BgpAppConfig config = configRegistry.getConfig(appId, BgpAppConfig.class);
-
- if (config == null) {
- log.warn("No configuration found");
- return;
- }
-
-
- /* Update the self configuration */
- if (bgpController.connectedPeerCount() != 0) {
- //TODO: If connections already exist, disconnect
- bgpController.closeConnectedPeers();
- }
- bgpConfig.setRouterId(config.routerId());
- bgpConfig.setAsNumber(config.localAs());
- bgpConfig.setLsCapability(config.lsCapability());
- bgpConfig.setHoldTime(config.holdTime());
- bgpConfig.setMaxSession(config.maxSession());
- bgpConfig.setLargeASCapability(config.largeAsCapability());
-
- if (config.flowSpecCapability() == null) {
- bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.NONE);
- } else {
- if (config.flowSpecCapability().equals("IPV4")) {
- bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.IPV4);
- } else if (config.flowSpecCapability().equals("VPNV4")) {
- bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.VPNV4);
- } else if (config.flowSpecCapability().equals("IPV4_VPNV4")) {
- bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.IPV4_VPNV4);
- } else {
- bgpConfig.setFlowSpecCapability(BgpCfg.FlowSpec.NONE);
- }
- }
- bgpConfig.setFlowSpecRpdCapability(config.rpdCapability());
-
- /* update the peer configuration */
- bgpPeerTree = bgpConfig.getPeerTree();
- if (bgpPeerTree.isEmpty()) {
- log.info("There are no BGP peers to iterate");
- } else {
- Set set = bgpPeerTree.entrySet();
- Iterator i = set.iterator();
- List<BgpPeerCfg> absPeerList = new ArrayList<BgpPeerCfg>();
-
- boolean exists = false;
-
- while (i.hasNext()) {
- Map.Entry me = (Map.Entry) i.next();
- peer = (BgpPeerCfg) me.getValue();
-
- nodes = config.bgpPeer();
- for (int j = 0; j < nodes.size(); j++) {
- String peerIp = nodes.get(j).hostname();
- if (peerIp.equals(peer.getPeerRouterId())) {
-
- if (bgpConfig.isPeerConnectable(peer.getPeerRouterId())) {
- peer.setAsNumber(nodes.get(j).asNumber());
- peer.setHoldtime(nodes.get(j).holdTime());
- log.debug("Peer neighbor IP successfully modified :" + peer.getPeerRouterId());
- } else {
- log.debug("Peer neighbor IP cannot be modified :" + peer.getPeerRouterId());
- }
-
- nodes.remove(j);
- exists = true;
- break;
- }
- }
-
- if (!exists) {
- absPeerList.add(peer);
- exists = false;
- }
-
- if (peer.connectPeer() != null) {
- peer.connectPeer().disconnectPeer();
- peer.setConnectPeer(null);
- }
- }
-
- /* Remove the absent nodes. */
- for (int j = 0; j < absPeerList.size(); j++) {
- bgpConfig.removePeer(absPeerList.get(j).getPeerRouterId());
- }
- }
-
-
- nodes = config.bgpPeer();
- for (int i = 0; i < nodes.size(); i++) {
- String connectMode = nodes.get(i).connectMode();
- bgpConfig.addPeer(nodes.get(i).hostname(), nodes.get(i).asNumber(), nodes.get(i).holdTime());
- if (connectMode.equals(BgpAppConfig.PEER_CONNECT_ACTIVE)) {
- bgpConfig.connectPeer(nodes.get(i).hostname());
- }
- }
-
- bgpConfig.setConnectionType(getBgpConnectionTypeFromConfig(config));
-
- bgpConfig.setRouteRefreshEnabled(config.routeRefreshEnabled());
- bgpConfig.setRouteRefreshPeriodicTimer(config.rrPeriodicTimer());
- bgpConfig.setRouteRefreshWarmupTimer(config.rrWarmupTimer());
- bgpConfig.setRouteRefreshCooldownTimer(config.rrCooldownTimer());
- }
-
- /**
- * Function to get Bgp Connection type from config.
- * @param config The BgpAppConfig from which connection type is to be fetched
- * @return Bgp connection type
- */
- private BgpCfg.ConnectionType getBgpConnectionTypeFromConfig(BgpAppConfig config) {
- //config cannot be null here, because of the function call sequence
-
- //But, let's put a sanity check for connectionType
- if (null == config.connectionType()) {
- //IPv4 is the default connection type
- return BgpCfg.ConnectionType.IPV4;
- }
-
- if (config.connectionType().equals(BgpAppConfig.CONNECTION_TYPE_IPV4)) {
- return BgpCfg.ConnectionType.IPV6;
- } else if (config.connectionType().equals(BgpAppConfig.CONNECTION_TYPE_IPV4_AND_IPV6)) {
- return BgpCfg.ConnectionType.IPV4_IPV6;
- } else {
- return BgpCfg.ConnectionType.IPV4;
- }
- }
-
- /**
- * BGP config listener to populate the configuration.
- */
- private class InternalConfigListener implements NetworkConfigListener {
-
- @Override
- public void event(NetworkConfigEvent event) {
- if (!event.configClass().equals(BgpAppConfig.class)) {
- return;
- }
-
- switch (event.type()) {
- case CONFIG_ADDED:
- readConfiguration();
- break;
- case CONFIG_UPDATED:
- updateConfiguration();
- break;
- case CONFIG_REMOVED:
- default:
- break;
- }
- }
- }
-}
diff --git a/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/package-info.java b/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/package-info.java
deleted file mode 100644
index d14447a..0000000
--- a/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- *Bgp configuration provider.
- */
-package org.onosproject.provider.bgp.cfg.impl;
diff --git a/providers/bgp/cli/BUILD b/providers/bgp/cli/BUILD
deleted file mode 100644
index 5a6b1e6..0000000
--- a/providers/bgp/cli/BUILD
+++ /dev/null
@@ -1,12 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + CLI + [
- "//providers/bgp/cfg:onos-providers-bgp-cfg",
- "//providers/bgp/topology:onos-providers-bgp-topology",
- "//protocols/bgp/api:onos-protocols-bgp-api",
- "//protocols/bgp/ctl:onos-protocols-bgp-ctl",
- "//protocols/bgp/bgpio:onos-protocols-bgp-bgpio",
-]
-
-osgi_jar_with_tests(
- karaf_command_packages = ["org.onosproject.bgp.cli"],
- deps = COMPILE_DEPS,
-)
diff --git a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpConfiguration.java b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpConfiguration.java
deleted file mode 100644
index 3123001..0000000
--- a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpConfiguration.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp.cli;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.bgp.controller.BgpCfg;
-import org.onosproject.bgp.controller.BgpConnectPeer;
-import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.bgp.controller.BgpPeerCfg;
-import org.onosproject.cli.AbstractShellCommand;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Set;
-import java.util.TreeMap;
-
-@Service
-@Command(scope = "onos", name = "bgp", description = "lists configuration")
-public class BgpConfiguration extends AbstractShellCommand {
- private static final Logger log = LoggerFactory.getLogger(BgpConfiguration.class);
- private static final String CONFIGURATION = "configuration";
- private static final String PEER = "peer";
- protected BgpController bgpController;
- protected BgpConnectPeer bgpConnectPeer;
- protected BgpPeerCfg bgpPeerCfg;
- protected BgpCfg bgpCfg;
- @Argument(index = 0, name = "name",
- description = "configuration" + "\n" + "peer",
- required = true, multiValued = false)
- String name = null;
- @Argument(index = 1, name = "peer",
- description = "peerIp",
- required = false, multiValued = false)
- String peer = null;
-
- @Override
- protected void doExecute() {
- switch (name) {
- case CONFIGURATION:
- displayBgpConfiguration();
- break;
- case PEER:
- displayBgpPeerConfiguration();
- break;
- default:
- System.out.print("Unknown command...!!");
- break;
- }
- }
-
- private void displayBgpConfiguration() {
- try {
-
- this.bgpController = get(BgpController.class);
- bgpCfg = bgpController.getConfig();
- print("RouterID = %s, ASNumber = %s, MaxSession = %s, HoldingTime = %s, LsCapabality = %s," +
- " LargeAsCapabality = %s, FlowSpecCapabality = %s", bgpCfg.getRouterId(),
- bgpCfg.getAsNumber(), bgpCfg.getMaxSession(), bgpCfg.getHoldTime(),
- bgpCfg.getLsCapability(), bgpCfg.getLargeASCapability(), bgpCfg.flowSpecCapability());
-
- } catch (Exception e) {
- log.debug("Error occurred while displaying BGP configuration: {}", e.getMessage());
- }
- }
-
- private void displayBgpPeerConfiguration() {
- try {
- this.bgpController = get(BgpController.class);
- BgpCfg bgpCfg = bgpController.getConfig();
- if (bgpCfg == null) {
- return;
- }
- TreeMap<String, BgpPeerCfg> displayPeerTree = bgpCfg.getPeerTree();
- Set<String> peerKey = displayPeerTree.keySet();
- if (peer != null) {
- if (!peerKey.isEmpty()) {
- for (String peerIdKey : peerKey) {
- bgpPeerCfg = displayPeerTree.get(peerIdKey);
- bgpConnectPeer = bgpPeerCfg.connectPeer();
- if (peerIdKey.equals(peer)) {
- print("PeerRouterID = %s, PeerHoldingTime = %s, ASNumber = %s, PeerState = %s," +
- " PeerPort = %s, ConnectRetryCounter = %s",
- peer, bgpPeerCfg.getHoldtime(), bgpPeerCfg.getAsNumber(),
- bgpPeerCfg.getState(), bgpConnectPeer.getPeerPort(),
- bgpConnectPeer.getConnectRetryCounter());
- }
- }
- }
- } else {
- if (!peerKey.isEmpty()) {
- for (String peerIdKey : peerKey) {
- bgpPeerCfg = displayPeerTree.get(peerIdKey);
- bgpConnectPeer = bgpPeerCfg.connectPeer();
- print("PeerRouterID = %s, PeerHoldingTime = %s, ASNumber = %s, PeerState = %s, PeerPort = %s," +
- " ConnectRetryCounter = %s",
- bgpPeerCfg.getPeerRouterId(), bgpPeerCfg.getHoldtime(), bgpPeerCfg.getAsNumber(),
- bgpPeerCfg.getState(), bgpConnectPeer.getPeerPort(),
- bgpConnectPeer.getConnectRetryCounter());
- }
- }
-
- }
- } catch (Exception e) {
- log.debug("Error occurred while displaying BGP peer configuration: {}", e.getMessage());
- }
- }
-
-
-}
\ No newline at end of file
diff --git a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpExceptions.java b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpExceptions.java
deleted file mode 100644
index d4e14f8..0000000
--- a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpExceptions.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp.cli;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.cli.AbstractShellCommand;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-@Service
-@Command(scope = "onos", name = "bgp-exception", description = "Displays Exceptions")
-public class BgpExceptions extends AbstractShellCommand {
- public static final String ACTIVESESSION = "activesession";
- public static final String CLOSEDSESSION = "closedsession";
- private static final Logger log = LoggerFactory.getLogger(BgpExceptions.class);
- protected BgpController bgpController;
- @Argument(index = 0, name = "name",
- description = "activesession" + "\n" + "closedsession",
- required = true, multiValued = false)
- String name = null;
- @Argument(index = 1, name = "peerIp",
- description = "peerId",
- required = false, multiValued = false)
- String peerId = null;
- private Set<String> activeSessionExceptionkeySet;
- private Set<String> closedSessionExceptionKeySet;
-
- @Override
- protected void doExecute() {
- switch (name) {
- case ACTIVESESSION:
- displayActiveSessionException();
- break;
- case CLOSEDSESSION:
- displayClosedSessionException();
- break;
- default:
- System.out.print("Unknown Command");
- break;
- }
- }
-
- private void displayActiveSessionException() {
- try {
- this.bgpController = get(BgpController.class);
- Map<String, List<String>> activeSessionExceptionMap = bgpController.activeSessionMap();
- activeSessionExceptionkeySet = activeSessionExceptionMap.keySet();
- if (!activeSessionExceptionkeySet.isEmpty()) {
- if (peerId != null) {
- if (activeSessionExceptionkeySet.contains(peerId)) {
- for (String peerIdKey : activeSessionExceptionkeySet) {
- List activeSessionExceptionlist = activeSessionExceptionMap.get(peerIdKey);
- System.out.println(activeSessionExceptionlist);
- }
- } else {
- System.out.print("Wrong argument");
- }
- } else {
- activeSessionExceptionkeySet = activeSessionExceptionMap.keySet();
- if (!activeSessionExceptionkeySet.isEmpty()) {
- for (String peerId : activeSessionExceptionkeySet) {
- print("PeerId = %s, Exception = %s ", peerId, activeSessionExceptionMap.get(peerId));
- }
- }
- }
- }
- } catch (Exception e) {
- log.debug("Error occurred while displaying BGP exceptions: {}", e.getMessage());
- }
- }
-
- private void displayClosedSessionException() {
- try {
- this.bgpController = get(BgpController.class);
- Map<String, List<String>> closedSessionExceptionMap = bgpController.closedSessionMap();
- closedSessionExceptionKeySet = closedSessionExceptionMap.keySet();
- if (!closedSessionExceptionKeySet.isEmpty()) {
- if (peerId != null) {
- if (closedSessionExceptionKeySet.contains(peerId)) {
- for (String peerIdKey : closedSessionExceptionKeySet) {
- List closedSessionExceptionlist = closedSessionExceptionMap.get(peerIdKey);
- print("Exceptions = %s", closedSessionExceptionlist);
- }
- } else {
- System.out.print("Wrong argument");
- }
- } else {
- closedSessionExceptionKeySet = closedSessionExceptionMap.keySet();
- if (!closedSessionExceptionKeySet.isEmpty()) {
- for (String peerId : closedSessionExceptionKeySet) {
- print("PeerId = %s, Exception = %s", peerId, closedSessionExceptionMap.get(peerId));
- }
- }
- }
- }
- } catch (Exception e) {
- log.debug("Error occurred while displaying resons for session closure: {}", e.getMessage());
- }
- }
-
-
-}
-
-
diff --git a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpLocalRibDisplay.java b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpLocalRibDisplay.java
deleted file mode 100644
index 4e6911f..0000000
--- a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpLocalRibDisplay.java
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.bgp.cli;
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.bgp.controller.BgpLocalRib;
-import org.onosproject.bgpio.protocol.BgpLSNlri;
-
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
-import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.BgpPrefixLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.NodeDescriptors;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
-import org.onosproject.bgpio.types.IPv4AddressTlv;
-import org.onosproject.bgpio.types.RouteDistinguisher;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.LinkStateAttributes;
-import org.onosproject.bgpio.types.MpReachNlri;
-import org.onosproject.bgpio.types.AutonomousSystemTlv;
-import org.onosproject.bgpio.types.IsIsNonPseudonode;
-import org.onosproject.bgpio.types.LocalPref;
-import org.onosproject.bgpio.types.Origin;
-import org.onosproject.bgpio.types.attr.BgpAttrRouterIdV4;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrMaxLinkBandwidth;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrUnRsrvdLinkBandwidth;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrIgpMetric;
-import org.onosproject.cli.AbstractShellCommand;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.List;
-import java.util.Iterator;
-import java.util.Arrays;
-
-
-@Service
-@Command(scope = "onos", name = "bgp-rib", description = "lists RIB configuration")
-public class BgpLocalRibDisplay extends AbstractShellCommand {
- private static final Logger log = LoggerFactory.getLogger(BgpLocalRibDisplay.class);
- private static final String NODETREE = "nodes";
- private static final String LINKTREE = "links";
- private static final String PREFIXTREE = "prefix";
- private static final String VPNNODETREE = "vpnnodes";
- private static final String VPNLINKTREE = "vpnlinkS";
- private static final String VPNPREFIXTREE = "vpnprefix";
- protected Origin origin;
- protected LocalPref localPref;
- protected BgpAttrRouterIdV4 bgpAttrRouterIdV4;
- protected IsIsNonPseudonode isIsNonPseudonode;
- protected AutonomousSystemTlv autonomousSystemTlv;
- protected IPv4AddressTlv iPv4AddressTlv;
- protected BgpLinkAttrMaxLinkBandwidth bgpLinkAttrMaxLinkBandwidth;
- protected BgpLinkAttrUnRsrvdLinkBandwidth bgpLinkAttrUnRsrvdLinkBandwidth;
- protected BgpLinkAttrTeDefaultMetric bgpLinkAttrTeDefaultMetric;
- protected BgpLinkAttrIgpMetric bgpLinkAttrIgpMetric;
- protected PathAttrNlriDetailsLocalRib pathAttrNlriDetailsLocalRib;
- protected MpReachNlri mpReachNlri;
- protected PathAttrNlriDetails pathAttrNlriDetails;
- protected BgpNodeLSNlriVer4.ProtocolType protocolType;
- protected BgpController bgpController = get(BgpController.class);
- protected BgpLocalRib bgpLocalRib = bgpController.bgpLocalRib();
- Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib> nodeTreeMap = bgpLocalRib.nodeTree();
- Set<BgpNodeLSIdentifier> nodekeySet = nodeTreeMap.keySet();
- Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib> linkTreeMap = bgpLocalRib.linkTree();
- Set<BgpLinkLSIdentifier> linkkeySet = linkTreeMap.keySet();
- @Argument(index = 0, name = "name",
- description = "nodetree" + "\n" + "linktree" + "\n" + "prefixtree" + "\n" + "vpnnodetree" + "\n" +
- "vpnlinktree" + "\n" + "vpnprefixtree", required = true, multiValued = false)
- String name = null;
- @Argument(index = 1, name = "numberofentries",
- description = "numberofentries", required = false, multiValued = false)
- int numberofentries;
- @Argument(index = 2, name = "vpnId",
- description = "vpnId", required = false, multiValued = false)
- String vpnId = null;
- private int count = 0;
-
- @Override
- protected void doExecute() {
- switch (name) {
- case NODETREE:
- displayNodes();
- break;
- case LINKTREE:
- displayLinks();
- break;
- case PREFIXTREE:
- displayPrefix();
- break;
- case VPNNODETREE:
- displayVpnNodes();
- break;
- case VPNLINKTREE:
- displayVpnLinks();
- break;
- case VPNPREFIXTREE:
- displayVpnPrefix();
- break;
- default:
- System.out.print("Unknown Command");
- break;
- }
-
- }
-
- private void displayNodes() {
- try {
- int counter = 0;
- print("Total number of entries = %s", nodeTreeMap.size());
- for (BgpNodeLSIdentifier nodes : nodekeySet) {
- if (numberofentries > nodeTreeMap.size() || numberofentries < 0) {
- System.out.print("Wrong Argument");
- break;
- } else if (counter < numberofentries) {
- pathAttrNlriDetailsLocalRib = nodeTreeMap.get(nodes);
- displayNode();
- counter++;
- } else if (counter == 0) {
- pathAttrNlriDetailsLocalRib = nodeTreeMap.get(nodes);
- displayNode();
-
-
- }
-
- }
- } catch (Exception e) {
- log.debug("Error occurred while displaying BGP nodes: {}", e.getMessage());
- }
-
- }
-
-
- private void displayLinks() {
- try {
- int counter = 0;
- print("Total Number of entries = %d", linkTreeMap.size());
- for (BgpLinkLSIdentifier links : linkkeySet) {
- if (numberofentries > linkTreeMap.size() || numberofentries < 0) {
- System.out.print("Wrong Argument");
- break;
- } else if (counter < numberofentries) {
- pathAttrNlriDetailsLocalRib = linkTreeMap.get(links);
- print("Total number of entries = %d", linkTreeMap.size());
- displayLink();
- counter++;
- } else if (counter == 0) {
- pathAttrNlriDetailsLocalRib = linkTreeMap.get(links);
- displayLink();
- }
-
- }
- } catch (Exception e) {
- log.debug("Error occurred while displaying BGP links: {}", e.getMessage());
- }
- }
-
- private void displayPrefix() {
- try {
- this.bgpController = get(BgpController.class);
- bgpLocalRib = bgpController.bgpLocalRib();
- Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib> prefixmap = bgpLocalRib.prefixTree();
- Set<BgpPrefixLSIdentifier> prefixkeySet = prefixmap.keySet();
- for (BgpPrefixLSIdentifier prefix : prefixkeySet) {
- pathAttrNlriDetailsLocalRib = prefixmap.get(prefix);
- pathAttrNlriDetails = pathAttrNlriDetailsLocalRib.localRibNlridetails();
- print("No of entries = %d", prefixmap.size());
- System.out.print(pathAttrNlriDetailsLocalRib.toString());
-
- }
-
-
- } catch (Exception e) {
- log.debug("Error occurred while displaying BGP prefixes: {}", e.getMessage());
-
- }
- }
-
- private void displayVpnNodes() {
- try {
- this.bgpController = get(BgpController.class);
- bgpLocalRib = bgpController.bgpLocalRib();
- Map<RouteDistinguisher, Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnNode =
- bgpLocalRib.vpnNodeTree();
- Set<RouteDistinguisher> vpnNodekeySet = vpnNode.keySet();
- for (RouteDistinguisher vpnNodes : vpnNodekeySet) {
- boolean invalidProcess = true;
- if (vpnId != null && Integer.parseInt(vpnId.trim()) == vpnNodes.hashCode()) {
- invalidProcess = false;
- displayNodes();
- }
- if (invalidProcess) {
- print("%s\n", "Id " + vpnId + "does not exist...!!!");
- }
- }
- } catch (Exception e) {
- log.debug("Error occurred while displaying BGP nodes based on VPN : {}", e.getMessage());
- }
-
- }
-
- private void displayVpnLinks() {
- try {
- this.bgpController = get(BgpController.class);
- bgpLocalRib = bgpController.bgpLocalRib();
- Map<RouteDistinguisher, Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnLink =
- bgpLocalRib.vpnLinkTree();
- Set<RouteDistinguisher> vpnLinkkeySet = vpnLink.keySet();
- for (RouteDistinguisher vpnLinks : vpnLinkkeySet) {
- boolean invalidProcess = true;
- if (vpnId != null && Integer.parseInt(vpnId.trim()) == vpnLinks.hashCode()) {
- invalidProcess = false;
- displayLinks();
- }
- if (invalidProcess) {
- print("%s\n", "Id " + vpnId + "does not exist...!!!");
- }
- }
- } catch (Exception e) {
- log.debug("Error occurred while displaying BGP links based on VPN : {}", e.getMessage());
- }
- }
-
- private void displayVpnPrefix() {
- try {
- this.bgpController = get(BgpController.class);
- bgpLocalRib = bgpController.bgpLocalRib();
- Map<RouteDistinguisher, Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnPrefix =
- bgpLocalRib.vpnPrefixTree();
- Set<RouteDistinguisher> vpnPrefixkeySet = vpnPrefix.keySet();
- for (RouteDistinguisher vpnprefixId : vpnPrefixkeySet) {
- boolean invalidProcess = true;
- if (vpnId != null && Integer.parseInt(vpnId.trim()) == vpnprefixId.hashCode()) {
- invalidProcess = false;
- displayPrefix();
- }
- if (invalidProcess) {
- print("%s\n", "Id " + vpnId + "does not exist...!!!");
- }
- }
- } catch (Exception e) {
- log.debug("Error occurred while displaying BGP prefixes based on VPN : {}", e.getMessage());
- }
- }
-
- private void displayNode() {
-
-
- pathAttrNlriDetails = pathAttrNlriDetailsLocalRib.localRibNlridetails();
- List<BgpValueType> bgpValueTypeList = pathAttrNlriDetails.pathAttributes();
- protocolType = pathAttrNlriDetails.protocolID();
- Iterator<BgpValueType> itrBgpValueType = bgpValueTypeList.iterator();
- while (itrBgpValueType.hasNext()) {
- BgpValueType bgpValueType = itrBgpValueType.next();
- if (bgpValueType instanceof Origin) {
- origin = (Origin) bgpValueType;
- } else if (bgpValueType instanceof LocalPref) {
- localPref = (LocalPref) bgpValueType;
- } else if (bgpValueType instanceof LinkStateAttributes) {
- LinkStateAttributes linkStateAttributes = (LinkStateAttributes) bgpValueType;
- List linkStateAttribiuteList = linkStateAttributes.linkStateAttributes();
- Iterator<BgpValueType> linkStateAttribiteIterator = linkStateAttribiuteList.iterator();
- while (linkStateAttribiteIterator.hasNext()) {
- BgpValueType bgpValueType1 = linkStateAttribiteIterator.next();
- if (bgpValueType1 instanceof BgpAttrRouterIdV4) {
- bgpAttrRouterIdV4 = (BgpAttrRouterIdV4) bgpValueType1;
- }
- }
- } else if (bgpValueType instanceof MpReachNlri) {
- mpReachNlri = (MpReachNlri) bgpValueType;
- List<BgpLSNlri> bgpLSNlris = mpReachNlri.mpReachNlri();
- Iterator<BgpLSNlri> bgpLsnlrisIterator = bgpLSNlris.iterator();
- while (bgpLsnlrisIterator.hasNext()) {
- BgpLSNlri bgpLSNlri = bgpLsnlrisIterator.next();
- if (bgpLSNlri instanceof BgpNodeLSNlriVer4) {
- BgpNodeLSNlriVer4 bgpNodeLSNlriVer4 = (BgpNodeLSNlriVer4) bgpLSNlri;
- BgpNodeLSIdentifier bgpNodeLSIdentifier = bgpNodeLSNlriVer4.getLocalNodeDescriptors();
- NodeDescriptors nodeDescriptors = bgpNodeLSIdentifier.getNodedescriptors();
- List<BgpValueType> bgpvalueTypesList = nodeDescriptors.getSubTlvs();
- Iterator<BgpValueType> bgpValueTypeIterator = bgpvalueTypesList.iterator();
- while (bgpValueTypeIterator.hasNext()) {
- BgpValueType valueType = bgpValueTypeIterator.next();
- if (valueType instanceof IsIsNonPseudonode) {
- isIsNonPseudonode = (IsIsNonPseudonode) valueType;
-
- }
- }
- }
- }
- }
- }
- print("RibAsNumber = %s,PeerIdentifier = %s,RibIpAddress = %s,ProtocolType = %s,Origin = %s,LocalPref = %s," +
- "RouterID = %s,IsoNodeID = %s,NextHop = %s", pathAttrNlriDetailsLocalRib.localRibAsNum(),
- pathAttrNlriDetailsLocalRib.localRibIdentifier(), pathAttrNlriDetailsLocalRib.localRibIpAddress(),
- protocolType.toString(), origin.origin(), localPref.localPref(), bgpAttrRouterIdV4.attrRouterId(),
- Arrays.toString(isIsNonPseudonode.getIsoNodeId()), mpReachNlri.nexthop());
- }
-
- private void displayLink() {
-
- pathAttrNlriDetails = pathAttrNlriDetailsLocalRib.localRibNlridetails();
- List<BgpValueType> valueTypes = pathAttrNlriDetails.pathAttributes();
- Iterator<BgpValueType> itrBgpValueType = valueTypes.iterator();
- while (itrBgpValueType.hasNext()) {
- BgpValueType bgpValueType = itrBgpValueType.next();
- if (bgpValueType instanceof Origin) {
- origin = (Origin) bgpValueType;
- } else if (bgpValueType instanceof LocalPref) {
- localPref = (LocalPref) bgpValueType;
- } else if (bgpValueType instanceof LinkStateAttributes) {
- LinkStateAttributes linkStateAttributes = (LinkStateAttributes) bgpValueType;
- List linkStateAttributelist = linkStateAttributes.linkStateAttributes();
- Iterator<BgpValueType> linkStateAttributeIterator = linkStateAttributelist.iterator();
- while (linkStateAttributeIterator.hasNext()) {
- BgpValueType bgpValueType1 = linkStateAttributeIterator.next();
- if (bgpValueType1 instanceof BgpAttrRouterIdV4) {
- bgpAttrRouterIdV4 = (BgpAttrRouterIdV4) bgpValueType1;
- } else if (bgpValueType1 instanceof BgpLinkAttrMaxLinkBandwidth) {
- bgpLinkAttrMaxLinkBandwidth = (BgpLinkAttrMaxLinkBandwidth) bgpValueType1;
- } else if (bgpValueType1 instanceof BgpLinkAttrUnRsrvdLinkBandwidth) {
- bgpLinkAttrUnRsrvdLinkBandwidth = (BgpLinkAttrUnRsrvdLinkBandwidth) bgpValueType1;
- } else if (bgpValueType1 instanceof BgpLinkAttrTeDefaultMetric) {
- bgpLinkAttrTeDefaultMetric = (BgpLinkAttrTeDefaultMetric) bgpValueType1;
- } else if (bgpValueType1 instanceof BgpLinkAttrIgpMetric) {
- bgpLinkAttrIgpMetric = (BgpLinkAttrIgpMetric) bgpValueType1;
- }
-
- }
- } else if (bgpValueType instanceof MpReachNlri) {
- mpReachNlri = (MpReachNlri) bgpValueType;
- List<BgpLSNlri> bgpLSNlris = mpReachNlri.mpReachNlri();
- Iterator<BgpLSNlri> bgpLsnlrisIterator = bgpLSNlris.iterator();
- while (bgpLsnlrisIterator.hasNext()) {
- BgpLSNlri bgpLSNlri = bgpLsnlrisIterator.next();
- if (bgpLSNlri instanceof BgpLinkLsNlriVer4) {
- BgpLinkLsNlriVer4 bgpLinkLsNlriVer4 = (BgpLinkLsNlriVer4) bgpLSNlri;
- BgpLinkLSIdentifier bgpLinkLSIdentifier = bgpLinkLsNlriVer4.getLinkIdentifier();
- NodeDescriptors localnodeDescriptors = bgpLinkLSIdentifier.localNodeDescriptors();
- NodeDescriptors remotenodeDescriptors = bgpLinkLSIdentifier.remoteNodeDescriptors();
- List<BgpValueType> linkDescriptors = bgpLinkLSIdentifier.linkDescriptors();
- List<BgpValueType> subTlvList = localnodeDescriptors.getSubTlvs();
- Iterator<BgpValueType> subTlvIterator = subTlvList.iterator();
- while (subTlvIterator.hasNext()) {
- BgpValueType valueType = subTlvIterator.next();
- if (valueType instanceof IsIsNonPseudonode) {
- isIsNonPseudonode = (IsIsNonPseudonode) valueType;
- } else if (valueType instanceof AutonomousSystemTlv) {
- autonomousSystemTlv = (AutonomousSystemTlv) valueType;
- }
- }
- List<BgpValueType> remotevalueTypes = remotenodeDescriptors.getSubTlvs();
- Iterator<BgpValueType> remoteValueTypesIterator = remotevalueTypes.iterator();
- while (remoteValueTypesIterator.hasNext()) {
- BgpValueType valueType = remoteValueTypesIterator.next();
- if (valueType instanceof IsIsNonPseudonode) {
- isIsNonPseudonode = (IsIsNonPseudonode) valueType;
- } else if (valueType instanceof AutonomousSystemTlv) {
- autonomousSystemTlv = (AutonomousSystemTlv) valueType;
- }
- }
- Iterator<BgpValueType> listIterator = linkDescriptors.iterator();
- while (listIterator.hasNext()) {
- BgpValueType valueType = listIterator.next();
- if (valueType instanceof IPv4AddressTlv) {
- iPv4AddressTlv = (IPv4AddressTlv) valueType;
- }
-
- }
- }
- }
- }
- }
- print("PeerIdentifier = %s,Origin = %s,LocalPref = %s,RouterID = %s,MaxBandwidth = %s," +
- "UnreservedBandwidth = %s,DefaultMetric = %s,IGPMetric = %s,IsoNodeID = %s,ASNum = %s," +
- "IPAddress = %s,NextHop = %s", pathAttrNlriDetailsLocalRib.localRibIdentifier(),
- origin.origin(), localPref.localPref(), bgpAttrRouterIdV4.attrRouterId(),
- bgpLinkAttrMaxLinkBandwidth.linkAttrMaxLinkBandwidth(),
- bgpLinkAttrUnRsrvdLinkBandwidth.getLinkAttrUnRsrvdLinkBandwidth().toString(),
- bgpLinkAttrTeDefaultMetric.attrLinkDefTeMetric(), bgpLinkAttrIgpMetric.attrLinkIgpMetric(),
- Arrays.toString(isIsNonPseudonode.getIsoNodeId()), autonomousSystemTlv.getAsNum(),
- iPv4AddressTlv.address(), mpReachNlri.nexthop().toString(),
- pathAttrNlriDetailsLocalRib.localRibIpAddress(), origin.origin(), localPref.localPref(),
- bgpAttrRouterIdV4.attrRouterId());
-
- }
-}
diff --git a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/package-info.java b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/package-info.java
deleted file mode 100644
index c7a7692..0000000
--- a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Created by root1 on 23/8/16.
- */
-package org.onosproject.bgp.cli;
diff --git a/providers/bgp/route/BUILD b/providers/bgp/route/BUILD
deleted file mode 100644
index 80d23a0..0000000
--- a/providers/bgp/route/BUILD
+++ /dev/null
@@ -1,10 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + [
- "//protocols/bgp/api:onos-protocols-bgp-api",
- "//protocols/bgp/bgpio:onos-protocols-bgp-bgpio",
- "//apps/evpn-route-service/api:onos-apps-evpn-route-service-api",
-]
-
-osgi_jar_with_tests(
- test_deps = TEST_ADAPTERS,
- deps = COMPILE_DEPS,
-)
diff --git a/providers/bgp/route/src/main/java/org/onosproject/provider/bgp/route/impl/BgpRouteProvider.java b/providers/bgp/route/src/main/java/org/onosproject/provider/bgp/route/impl/BgpRouteProvider.java
deleted file mode 100644
index bb1c8d1..0000000
--- a/providers/bgp/route/src/main/java/org/onosproject/provider/bgp/route/impl/BgpRouteProvider.java
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package org.onosproject.provider.bgp.route.impl;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.bgp.controller.BgpId;
-import org.onosproject.bgp.controller.BgpPeer.FlowSpecOperation;
-import org.onosproject.bgp.controller.BgpRouteListener;
-import org.onosproject.bgpio.protocol.BgpEvpnNlri;
-import org.onosproject.bgpio.protocol.BgpUpdateMsg;
-import org.onosproject.bgpio.protocol.evpn.BgpEvpnNlriImpl;
-import org.onosproject.bgpio.protocol.evpn.BgpEvpnRouteType;
-import org.onosproject.bgpio.protocol.evpn.BgpEvpnRouteType2Nlri;
-import org.onosproject.bgpio.types.BgpEvpnEsi;
-import org.onosproject.bgpio.types.BgpEvpnLabel;
-import org.onosproject.bgpio.types.BgpExtendedCommunity;
-import org.onosproject.bgpio.types.BgpNlriType;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.MpReachNlri;
-import org.onosproject.bgpio.types.MpUnReachNlri;
-import org.onosproject.bgpio.types.RouteDistinguisher;
-import org.onosproject.bgpio.types.RouteTarget;
-import org.onosproject.evpnrouteservice.EvpnRoute;
-import org.onosproject.evpnrouteservice.EvpnRoute.Source;
-import org.onosproject.evpnrouteservice.EvpnRouteAdminService;
-import org.onosproject.evpnrouteservice.EvpnRouteEvent;
-import org.onosproject.evpnrouteservice.EvpnRouteListener;
-import org.onosproject.evpnrouteservice.VpnRouteTarget;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Provider which uses an BGP controller to update/delete route.
- */
-@Component(immediate = true)
-public class BgpRouteProvider extends AbstractProvider {
-
- /**
- * Creates an instance of BGP route provider.
- */
- public BgpRouteProvider() {
- super(new ProviderId("route",
- "org.onosproject.provider.bgp.route.impl"));
- }
-
- private static final Logger log = LoggerFactory
- .getLogger(BgpRouteProvider.class);
-
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected BgpController controller;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected EvpnRouteAdminService evpnRouteAdminService;
-
- private final InternalEvpnRouteListener routeListener = new
- InternalEvpnRouteListener();
- private final InternalBgpRouteListener bgpRouteListener = new
- InternalBgpRouteListener();
-
-
- @Activate
- public void activate() {
- controller.addRouteListener(bgpRouteListener);
- evpnRouteAdminService.addListener(routeListener);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- controller.removeRouteListener(bgpRouteListener);
- evpnRouteAdminService.removeListener(routeListener);
- log.info("Stopped");
- }
-
- /**
- * Handles the bgp route update message.
- *
- * @param operationType operationType
- * @param rdString rd
- * @param exportRtList rt export
- * @param nextHop next hop
- * @param macAddress mac address
- * @param ipAddress ip address
- * @param labelInt label
- */
- private void sendUpdateMessage(FlowSpecOperation operationType,
- String rdString,
- List<VpnRouteTarget> exportRtList,
- IpAddress nextHop,
- MacAddress macAddress,
- InetAddress ipAddress,
- int labelInt) {
- log.info("sendUpdateMessage 1");
-
- List<BgpEvpnNlri> eVpnNlri = new ArrayList<BgpEvpnNlri>();
- RouteDistinguisher rd = stringToRD(rdString);
- BgpEvpnEsi esi = new BgpEvpnEsi(new byte[10]);
- int ethernetTagID = 0;
- BgpEvpnLabel mplsLabel1 = intToLabel(labelInt);
- BgpEvpnLabel mplsLabel2 = null;
-
- List<BgpValueType> extCom = new ArrayList<BgpValueType>();
- if ((operationType == FlowSpecOperation.UPDATE)
- && (!exportRtList.isEmpty())) {
- for (VpnRouteTarget rt : exportRtList) {
- RouteTarget rTarget = stringToRT(rt.getRouteTarget());
- extCom.add(rTarget);
- }
- }
- BgpEvpnRouteType2Nlri routeTypeSpec =
- new BgpEvpnRouteType2Nlri(rd,
- esi,
- ethernetTagID,
- macAddress,
- ipAddress,
- mplsLabel1,
- mplsLabel2);
- BgpEvpnNlri nlri = new BgpEvpnNlriImpl(BgpEvpnRouteType
- .MAC_IP_ADVERTISEMENT
- .getType(),
- routeTypeSpec);
- eVpnNlri.add(nlri);
- log.info("sendUpdateMessage 2");
- controller.getPeers().forEach(peer -> {
- log.info("Send route update eVpnComponents {} to peer {}",
- eVpnNlri, peer);
- peer.updateEvpnNlri(operationType, nextHop, extCom, eVpnNlri);
- });
-
- }
-
- private static RouteDistinguisher stringToRD(String rdString) {
- if (rdString.contains(":")) {
- if ((rdString.indexOf(":") != 0)
- && (rdString.indexOf(":") != rdString.length() - 1)) {
- String[] tem = rdString.split(":");
- short as = (short) Integer.parseInt(tem[0]);
- int assignednum = Integer.parseInt(tem[1]);
- long rd = ((long) assignednum & 0xFFFFFFFFL)
- | (((long) as << 32) & 0xFFFFFFFF00000000L);
- return new RouteDistinguisher(rd);
- }
- }
- return null;
-
- }
-
- private static String rdToString(RouteDistinguisher rd) {
- long rdLong = rd.getRouteDistinguisher();
- int as = (int) ((rdLong & 0xFFFFFFFF00000000L) >> 32);
- int assignednum = (int) (rdLong & 0xFFFFFFFFL);
- String result = as + ":" + assignednum;
- return result;
- }
-
- private static RouteTarget stringToRT(String rdString) {
- if (rdString.contains(":")) {
- if ((rdString.indexOf(":") != 0)
- && (rdString.indexOf(":") != rdString.length() - 1)) {
- String[] tem = rdString.split(":");
- short as = Short.parseShort(tem[0]);
- int assignednum = Integer.parseInt(tem[1]);
-
- byte[] rt = new byte[]{(byte) ((as >> 8) & 0xFF),
- (byte) (as & 0xFF),
- (byte) ((assignednum >> 24) & 0xFF),
- (byte) ((assignednum >> 16) & 0xFF),
- (byte) ((assignednum >> 8) & 0xFF),
- (byte) (assignednum & 0xFF)};
- short type = 0x02;
- return new RouteTarget(type, rt);
- }
- }
- return null;
-
- }
-
- private static String rtToString(RouteTarget rt) {
- byte[] b = rt.getRouteTarget();
-
- int assignednum = b[5] & 0xFF | (b[4] & 0xFF) << 8 | (b[3] & 0xFF) << 16
- | (b[2] & 0xFF) << 24;
- short as = (short) (b[1] & 0xFF | (b[0] & 0xFF) << 8);
- String result = as + ":" + assignednum;
- return result;
- }
-
- private static BgpEvpnLabel intToLabel(int labelInt) {
- byte[] label = new byte[]{(byte) ((labelInt >> 16) & 0xFF),
- (byte) ((labelInt >> 8) & 0xFF),
- (byte) (labelInt & 0xFF)};
-
- return new BgpEvpnLabel(label);
- }
-
- private static int labelToInt(BgpEvpnLabel label) {
- byte[] b = label.getMplsLabel();
- return b[2] & 0xFF | (b[1] & 0xFF) << 8 | (b[0] & 0xFF) << 16;
-
- }
-
- private class InternalBgpRouteListener implements BgpRouteListener {
-
- @Override
- public void processRoute(BgpId bgpId, BgpUpdateMsg updateMsg) {
- log.info("Evpn route event received from BGP protocol");
- List<BgpValueType> pathAttr = updateMsg.bgpPathAttributes()
- .pathAttributes();
- Iterator<BgpValueType> iterator = pathAttr.iterator();
- RouteTarget rt = null;
- List<VpnRouteTarget> exportRt = new LinkedList<>();
- List<BgpEvpnNlri> evpnReachNlri = new LinkedList<>();
- List<BgpEvpnNlri> evpnUnreachNlri = new LinkedList<>();
-
- IpAddress ipNextHop = null;
- while (iterator.hasNext()) {
- BgpValueType attr = iterator.next();
- if (attr instanceof MpReachNlri) {
- MpReachNlri mpReachNlri = (MpReachNlri) attr;
- ipNextHop = mpReachNlri.nexthop();
- if (mpReachNlri
- .getNlriDetailsType() == BgpNlriType.EVPN) {
- evpnReachNlri.addAll(mpReachNlri.bgpEvpnNlri());
- }
-
- }
- if (attr instanceof MpUnReachNlri) {
- MpUnReachNlri mpUnReachNlri = (MpUnReachNlri) attr;
- if (mpUnReachNlri
- .getNlriDetailsType() == BgpNlriType.EVPN) {
- evpnUnreachNlri.addAll(mpUnReachNlri.bgpEvpnNlri());
- }
- }
-
- if (attr instanceof BgpExtendedCommunity) {
- BgpExtendedCommunity extCom = (BgpExtendedCommunity) attr;
- Iterator<BgpValueType> extIte = extCom.fsActionTlv()
- .iterator();
- while (extIte.hasNext()) {
- BgpValueType extAttr = extIte.next();
- if (extAttr instanceof RouteTarget) {
- rt = (RouteTarget) extAttr;
- exportRt.add(VpnRouteTarget
- .routeTarget(rtToString(rt)));
- break;
- }
- }
- }
- }
-
- if ((!exportRt.isEmpty()) && (!evpnReachNlri.isEmpty())) {
- for (BgpEvpnNlri nlri : evpnReachNlri) {
- if (nlri.getRouteType() == BgpEvpnRouteType
- .MAC_IP_ADVERTISEMENT) {
- BgpEvpnRouteType2Nlri macIpAdvNlri
- = (BgpEvpnRouteType2Nlri) nlri
- .getNlri();
- MacAddress macAddress = macIpAdvNlri.getMacAddress();
- Ip4Address ipAddress = Ip4Address
- .valueOf(macIpAdvNlri.getIpAddress());
- RouteDistinguisher rd = macIpAdvNlri
- .getRouteDistinguisher();
- BgpEvpnLabel label = macIpAdvNlri.getMplsLable1();
- log.info("Route Provider received bgp packet {} " +
- "to route system.",
- macIpAdvNlri.toString());
- // Add route to route system
- Source source = Source.REMOTE;
- EvpnRoute evpnRoute = new EvpnRoute(source,
- macAddress,
- IpPrefix.valueOf(ipAddress, 32),
- ipNextHop,
- rdToString(rd),
- null, //empty rt
- exportRt,
- labelToInt(label));
-
- evpnRouteAdminService.update(Collections
- .singleton(evpnRoute));
- }
- }
- }
-
- if (!evpnUnreachNlri.isEmpty()) {
- for (BgpEvpnNlri nlri : evpnUnreachNlri) {
- if (nlri.getRouteType() == BgpEvpnRouteType
- .MAC_IP_ADVERTISEMENT) {
- BgpEvpnRouteType2Nlri macIpAdvNlri
- = (BgpEvpnRouteType2Nlri) nlri
- .getNlri();
- MacAddress macAddress = macIpAdvNlri.getMacAddress();
- Ip4Address ipAddress = Ip4Address
- .valueOf(macIpAdvNlri.getIpAddress());
- RouteDistinguisher rd = macIpAdvNlri
- .getRouteDistinguisher();
- BgpEvpnLabel label = macIpAdvNlri.getMplsLable1();
- log.info("Route Provider received bgp packet {} " +
- "and remove from route system.",
- macIpAdvNlri.toString());
- // Delete route from route system
- Source source = Source.REMOTE;
- // For mpUnreachNlri, nexthop and rt is null
- EvpnRoute evpnRoute = new EvpnRoute(source,
- macAddress,
- IpPrefix.valueOf(ipAddress, 32),
- null,
- rdToString(rd),
- null,
- null,
- labelToInt(label));
-
- evpnRouteAdminService.withdraw(Collections
- .singleton(evpnRoute));
- }
- }
- }
- }
- }
-
- private class InternalEvpnRouteListener implements EvpnRouteListener {
-
- @Override
- public void event(EvpnRouteEvent event) {
- log.info("evpnroute event is received from evpn route manager");
- FlowSpecOperation operationType = null;
- EvpnRoute route = event.subject();
- EvpnRoute evpnRoute = route;
- log.info("Event received for public route {}", evpnRoute);
- if (evpnRoute.source().equals(Source.REMOTE)) {
- return;
- }
- switch (event.type()) {
- case ROUTE_ADDED:
- case ROUTE_UPDATED:
- log.info("route added");
- operationType = FlowSpecOperation.UPDATE;
- break;
- case ROUTE_REMOVED:
- log.info("route deleted");
- operationType = FlowSpecOperation.DELETE;
- break;
- default:
- break;
- }
-
- String rdString = evpnRoute.routeDistinguisher()
- .getRouteDistinguisher();
- MacAddress macAddress = evpnRoute.prefixMac();
- InetAddress inetAddress = evpnRoute.prefixIp().address().toInetAddress();
- IpAddress nextHop = evpnRoute.ipNextHop();
- List<VpnRouteTarget> exportRtList = evpnRoute
- .exportRouteTarget();
- int labelInt = evpnRoute.label().getLabel();
-
- sendUpdateMessage(operationType,
- rdString,
- exportRtList,
- nextHop,
- macAddress,
- inetAddress,
- labelInt);
- }
- }
-}
diff --git a/providers/bgp/route/src/main/java/org/onosproject/provider/bgp/route/impl/package-info.java b/providers/bgp/route/src/main/java/org/onosproject/provider/bgp/route/impl/package-info.java
deleted file mode 100644
index 97f14ab..0000000
--- a/providers/bgp/route/src/main/java/org/onosproject/provider/bgp/route/impl/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * Provider that uses BGP controller as a means of infrastructure route exchange.
- */
-package org.onosproject.provider.bgp.route.impl;
\ No newline at end of file
diff --git a/providers/bgp/topology/BUILD b/providers/bgp/topology/BUILD
deleted file mode 100644
index 9851523..0000000
--- a/providers/bgp/topology/BUILD
+++ /dev/null
@@ -1,11 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + JACKSON + [
- "//protocols/bgp/api:onos-protocols-bgp-api",
- "//protocols/bgp/bgpio:onos-protocols-bgp-bgpio",
- "//apps/tunnel/api:onos-apps-tunnel-api",
- "//apps/pcep-api:onos-apps-pcep-api",
-]
-
-osgi_jar_with_tests(
- test_deps = TEST_ADAPTERS,
- deps = COMPILE_DEPS,
-)
diff --git a/providers/bgp/topology/src/main/java/org/onosproject/provider/bgp/topology/impl/BgpTopologyProvider.java b/providers/bgp/topology/src/main/java/org/onosproject/provider/bgp/topology/impl/BgpTopologyProvider.java
deleted file mode 100644
index 88aff2f..0000000
--- a/providers/bgp/topology/src/main/java/org/onosproject/provider/bgp/topology/impl/BgpTopologyProvider.java
+++ /dev/null
@@ -1,605 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package org.onosproject.provider.bgp.topology.impl;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onlab.packet.ChassisId;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.bgp.controller.BgpDpid;
-import org.onosproject.bgp.controller.BgpLinkListener;
-import org.onosproject.bgp.controller.BgpNodeListener;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.NodeDescriptors;
-import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
-import org.onosproject.bgpio.types.AutonomousSystemTlv;
-import org.onosproject.bgpio.types.BgpLSIdentifierTlv;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.IPv4AddressTlv;
-import org.onosproject.bgpio.types.IsIsNonPseudonode;
-import org.onosproject.bgpio.types.IsIsPseudonode;
-import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv;
-import org.onosproject.bgpio.types.LinkStateAttributes;
-import org.onosproject.bgpio.types.OspfNonPseudonode;
-import org.onosproject.bgpio.types.OspfPseudonode;
-import org.onosproject.bgpio.types.attr.BgpAttrNodeFlagBitTlv;
-import org.onosproject.bgpio.types.attr.BgpAttrNodeIsIsAreaId;
-import org.onosproject.bgpio.types.attr.BgpAttrRouterIdV4;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrIgpMetric;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrMaxLinkBandwidth;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrUnRsrvdLinkBandwidth;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.device.DefaultDeviceDescription;
-import org.onosproject.net.device.DefaultPortDescription;
-import org.onosproject.net.device.DeviceDescription;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceProvider;
-import org.onosproject.net.device.DeviceProviderRegistry;
-import org.onosproject.net.device.DeviceProviderService;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.link.DefaultLinkDescription;
-import org.onosproject.net.link.LinkDescription;
-import org.onosproject.net.link.LinkProvider;
-import org.onosproject.net.link.LinkProviderRegistry;
-import org.onosproject.net.link.LinkProviderService;
-import org.onosproject.net.link.LinkService;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pcep.api.TeLinkConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
-
-import static java.util.stream.Collectors.toList;
-import static org.onosproject.bgp.controller.BgpDpid.uri;
-import static org.onosproject.incubator.net.resource.label.LabelResourceId.labelResourceId;
-import static org.onosproject.net.Device.Type.ROUTER;
-import static org.onosproject.net.Device.Type.VIRTUAL;
-import static org.onosproject.net.DeviceId.deviceId;
-
-/**
- * Provider which uses an BGP controller to detect network infrastructure topology.
- */
-@Component(immediate = true)
-public class BgpTopologyProvider extends AbstractProvider implements DeviceProvider, LinkProvider {
-
- /**
- * Creates an instance of BGP topology provider.
- */
- public BgpTopologyProvider() {
- super(new ProviderId("l3", "org.onosproject.provider.bgp"));
- }
-
- private static final Logger log = LoggerFactory.getLogger(BgpTopologyProvider.class);
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceProviderRegistry deviceProviderRegistry;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LinkProviderRegistry linkProviderRegistry;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected BgpController controller;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LinkService linkService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceService deviceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected MastershipService mastershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LabelResourceAdminService labelResourceAdminService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigService networkConfigService;
-
- private DeviceProviderService deviceProviderService;
- private LinkProviderService linkProviderService;
-
- private DeviceListener deviceListener = new InternalDeviceListener();
- private InternalBgpProvider listener = new InternalBgpProvider();
- private static final String UNKNOWN = "unknown";
- public static final long IDENTIFIER_SET = 0x100000000L;
- public static final String AS_NUMBER = "asNumber";
- public static final String DOMAIN_IDENTIFIER = "domainIdentifier";
- public static final String ROUTING_UNIVERSE = "routingUniverse";
-
- public static final String EXTERNAL_BIT = "externalBit";
- public static final String ABR_BIT = "abrBit";
- public static final String INTERNAL_BIT = "internalBit";
- public static final String PSEUDO = "psuedo";
- public static final String AREAID = "areaId";
- public static final String LSRID = "lsrId";
- public static final String COST = "cost";
- public static final String TE_COST = "teCost";
-
- public static final long PSEUDO_PORT = 0xffffffff;
- public static final int DELAY = 2;
- private LabelResourceId beginLabel = labelResourceId(5122);
- private LabelResourceId endLabel = labelResourceId(9217);
- private HashMap<DeviceId, List<PortDescription>> portMap = new HashMap<>();
-
- @Activate
- public void activate() {
- log.debug("BgpTopologyProvider activate");
- deviceProviderService = deviceProviderRegistry.register(this);
- linkProviderService = linkProviderRegistry.register(this);
- controller.addListener(listener);
- deviceService.addListener(deviceListener);
- controller.addLinkListener(listener);
- }
-
- @Deactivate
- public void deactivate() {
- log.debug("BgpTopologyProvider deactivate");
- deviceProviderRegistry.unregister(this);
- deviceProviderService = null;
- linkProviderRegistry.unregister(this);
- linkProviderService = null;
- controller.removeListener(listener);
- controller.removeLinkListener(listener);
- deviceService.removeListener(deviceListener);
- }
-
- private class InternalDeviceListener implements DeviceListener {
- @Override
- public boolean isRelevant(DeviceEvent event) {
- return event.type() == DeviceEvent.Type.DEVICE_ADDED &&
- mastershipService.isLocalMaster(event.subject().id());
- }
-
- @Override
- public void event(DeviceEvent event) {
- Device device = event.subject();
- // Reserve device label pool for L3 devices
- if (device.annotations().value(LSRID) != null) {
- createDevicePool(device.id());
- }
- }
- }
-
- /*
- * Implements device and link update.
- */
- private class InternalBgpProvider implements BgpNodeListener, BgpLinkListener {
-
- @Override
- public void addNode(BgpNodeLSNlriVer4 nodeNlri, PathAttrNlriDetails details) {
- log.debug("Add node {}", nodeNlri.toString());
-
- if (deviceProviderService == null || deviceService == null) {
- return;
- }
- Device.Type deviceType = ROUTER;
- BgpDpid nodeUri = new BgpDpid(nodeNlri);
- DeviceId deviceId = deviceId(uri(nodeUri.toString()));
- ChassisId cId = new ChassisId();
-
- /*
- * Check if device is already there (available) , if yes not updating to core.
- */
- if (deviceService.isAvailable(deviceId)) {
- return;
- }
-
- DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
-
- newBuilder.set(AnnotationKeys.TYPE, "L3");
- newBuilder.set(ROUTING_UNIVERSE, Long.toString(nodeNlri.getIdentifier()));
-
- List<BgpValueType> tlvs = nodeNlri.getLocalNodeDescriptors().getNodedescriptors().getSubTlvs();
- for (BgpValueType tlv : tlvs) {
- if (tlv instanceof AutonomousSystemTlv) {
- newBuilder.set(AS_NUMBER, Integer.toString(((AutonomousSystemTlv) tlv).getAsNum()));
- } else if (tlv instanceof BgpLSIdentifierTlv) {
- newBuilder.set(DOMAIN_IDENTIFIER,
- Integer.toString(((BgpLSIdentifierTlv) tlv).getBgpLsIdentifier()));
- }
- if (tlv.getType() == NodeDescriptors.IGP_ROUTERID_TYPE) {
- if (tlv instanceof IsIsPseudonode) {
- deviceType = VIRTUAL;
- newBuilder.set(AnnotationKeys.ROUTER_ID, nodeUri.isoNodeIdString(((IsIsPseudonode) tlv)
- .getIsoNodeId()));
- } else if (tlv instanceof OspfPseudonode) {
- deviceType = VIRTUAL;
- newBuilder
- .set(AnnotationKeys.ROUTER_ID, Integer.toString(((OspfPseudonode) tlv).getrouterID()));
- } else if (tlv instanceof IsIsNonPseudonode) {
- newBuilder.set(AnnotationKeys.ROUTER_ID, nodeUri.isoNodeIdString(((IsIsNonPseudonode) tlv)
- .getIsoNodeId()));
- } else if (tlv instanceof OspfNonPseudonode) {
- newBuilder.set(AnnotationKeys.ROUTER_ID,
- Integer.toString(((OspfNonPseudonode) tlv).getrouterID()));
- }
- }
- }
- DefaultAnnotations.Builder anntotations = DefaultAnnotations.builder();
- anntotations = getAnnotations(newBuilder, true, details);
-
- DeviceDescription description = new DefaultDeviceDescription(uri(nodeUri.toString()), deviceType, UNKNOWN,
- UNKNOWN, UNKNOWN, UNKNOWN, cId, anntotations.build());
-
- deviceProviderService.deviceConnected(deviceId, description);
- }
-
- @Override
- public void deleteNode(BgpNodeLSNlriVer4 nodeNlri) {
- log.debug("Delete node {}", nodeNlri.toString());
-
- if (deviceProviderService == null) {
- return;
- }
-
- BgpDpid deviceUri = new BgpDpid(nodeNlri);
- DeviceId deviceId = deviceId(uri(deviceUri.toString()));
-
- if (labelResourceAdminService != null) {
- //Destroy local device label pool reserved for that device
- labelResourceAdminService.destroyDevicePool(deviceId);
- }
-
- deviceProviderService.deviceDisconnected(deviceId);
- }
-
- private List<PortDescription> buildPortDescriptions(DeviceId deviceId,
- PortNumber portNumber) {
-
- List<PortDescription> portList;
-
- if (portMap.containsKey(deviceId)) {
- portList = portMap.get(deviceId);
- } else {
- portList = new ArrayList<>();
- }
- if (portNumber != null) {
- PortDescription portDescriptions = DefaultPortDescription.builder().withPortNumber(portNumber)
- .isEnabled(true).build();
- portList.add(portDescriptions);
- }
-
- portMap.put(deviceId, portList);
- return portList;
- }
-
- @Override
- public void addLink(BgpLinkLsNlriVer4 linkNlri, PathAttrNlriDetails details) throws BgpParseException {
- log.debug("Addlink {}", linkNlri.toString());
-
- LinkDescription linkDes = buildLinkDes(linkNlri, details, true);
-
-
-
- /*
- * Update link ports and configure bandwidth on source and destination port using networkConfig service
- * Only master of source link registers for bandwidth
- */
- if (mastershipService.isLocalMaster(linkDes.src().deviceId())) {
- registerBandwidthAndTeMetric(linkDes, details);
- }
-
- //Updating ports of the link
- deviceProviderService.updatePorts(linkDes.src().deviceId(), buildPortDescriptions(linkDes.src().deviceId(),
- linkDes.src().port()));
-
- deviceProviderService.updatePorts(linkDes.dst().deviceId(), buildPortDescriptions(linkDes.dst().deviceId(),
- linkDes.dst().port()));
-
- linkProviderService.linkDetected(linkDes);
- }
-
- //Build link description.
- private LinkDescription buildLinkDes(BgpLinkLsNlriVer4 linkNlri, PathAttrNlriDetails details, boolean isAddLink)
- throws BgpParseException {
- long srcAddress = 0;
- long dstAddress = 0;
- boolean localPseduo = false;
- boolean remotePseduo = false;
-
- List<BgpValueType> localTlvs = linkNlri.getLinkIdentifier().localNodeDescriptors().getSubTlvs();
- for (BgpValueType localTlv : localTlvs) {
- if (localTlv instanceof IsIsPseudonode || localTlv instanceof OspfPseudonode) {
- localPseduo = true;
- }
- }
- List<BgpValueType> remoteTlvs = linkNlri.getLinkIdentifier().remoteNodeDescriptors().getSubTlvs();
- for (BgpValueType remoteTlv : remoteTlvs) {
- if (remoteTlv instanceof IsIsPseudonode || remoteTlv instanceof OspfPseudonode) {
- remotePseduo = true;
- }
- }
-
- List<BgpValueType> tlvs = linkNlri.getLinkIdentifier().linkDescriptors();
- for (BgpValueType tlv : tlvs) {
- if (tlv instanceof LinkLocalRemoteIdentifiersTlv) {
- srcAddress = ((LinkLocalRemoteIdentifiersTlv) tlv).getLinkLocalIdentifier();
- //Set 32nd bit.
- srcAddress = srcAddress | IDENTIFIER_SET;
- dstAddress = ((LinkLocalRemoteIdentifiersTlv) tlv).getLinkRemoteIdentifier();
- dstAddress = dstAddress | IDENTIFIER_SET;
- } else if (tlv instanceof IPv4AddressTlv) {
- if (tlv.getType() == BgpLinkLSIdentifier.IPV4_INTERFACE_ADDRESS_TYPE) {
- srcAddress = ((IPv4AddressTlv) tlv).address().toInt();
- } else {
- dstAddress = ((IPv4AddressTlv) tlv).address().toInt();
- }
- }
- }
-
- DeviceId srcId = deviceId(uri(new BgpDpid(linkNlri, BgpDpid.NODE_DESCRIPTOR_LOCAL).toString()));
- DeviceId dstId = deviceId(uri(new BgpDpid(linkNlri, BgpDpid.NODE_DESCRIPTOR_REMOTE).toString()));
-
- if (localPseduo && srcAddress == 0) {
- srcAddress = PSEUDO_PORT;
- } else if (remotePseduo && dstAddress == 0) {
- dstAddress = PSEUDO_PORT;
- }
-
- ConnectPoint src = new ConnectPoint(srcId, PortNumber.portNumber(srcAddress));
- ConnectPoint dst = new ConnectPoint(dstId, PortNumber.portNumber(dstAddress));
- BgpNodeLSNlriVer4 srcNodeNlri = new BgpNodeLSNlriVer4(linkNlri.getIdentifier(), linkNlri.getProtocolId()
- .getType(), new BgpNodeLSIdentifier(linkNlri.getLinkIdentifier().localNodeDescriptors()), false,
- linkNlri.getRouteDistinguisher());
-
- BgpNodeLSNlriVer4 dstNodeNlri = new BgpNodeLSNlriVer4(linkNlri.getIdentifier(), linkNlri.getProtocolId()
- .getType(), new BgpNodeLSIdentifier(linkNlri.getLinkIdentifier().remoteNodeDescriptors()), false,
- linkNlri.getRouteDistinguisher());
-
- addOrDeletePseudoNode(isAddLink, localPseduo, remotePseduo, srcNodeNlri,
- dstNodeNlri, srcId, dstId, details);
- DefaultAnnotations.Builder annotationBuilder = DefaultAnnotations.builder();
- if (details != null) {
- annotationBuilder = getAnnotations(annotationBuilder, false, details);
- }
-
- return new DefaultLinkDescription(src, dst, Link.Type.DIRECT, false, annotationBuilder.build());
- }
-
- private void addOrDeletePseudoNode(boolean isAddLink, boolean localPseduo, boolean remotePseduo,
- BgpNodeLSNlriVer4 srcNodeNlri, BgpNodeLSNlriVer4 dstNodeNlri, DeviceId srcId, DeviceId dstId,
- PathAttrNlriDetails details) {
- if (isAddLink) {
- if (localPseduo) {
- if (deviceService.getDevice(srcId) == null) {
- for (BgpNodeListener l : controller.listener()) {
- l.addNode(srcNodeNlri, details);
- }
- }
- } else if (remotePseduo) {
- if (deviceService.getDevice(dstId) == null) {
- for (BgpNodeListener l : controller.listener()) {
- l.addNode(dstNodeNlri, details);
- }
- }
- }
- } else {
- if (localPseduo) {
- Set<Link> links = linkService.getDeviceLinks(srcId);
- if (links == null || links.isEmpty()) {
- for (BgpNodeListener l : controller.listener()) {
- l.deleteNode(srcNodeNlri);
- }
- }
- } else if (remotePseduo) {
- log.info("Remote pseudo delete link ");
- Set<Link> links = linkService.getDeviceLinks(dstId);
- if (links == null || links.isEmpty()) {
- for (BgpNodeListener l : controller.listener()) {
- l.deleteNode(dstNodeNlri);
- }
- }
- }
- }
- }
-
- @Override
- public void deleteLink(BgpLinkLsNlriVer4 linkNlri) throws BgpParseException {
- log.debug("Delete link {}", linkNlri.toString());
-
- if (linkProviderService == null) {
- return;
- }
-
- LinkDescription linkDes = buildLinkDes(linkNlri, null, false);
-
- /*
- * Only master for the link src will release the bandwidth resource.
- */
- if (networkConfigService != null && mastershipService.isLocalMaster(linkDes.src().deviceId())) {
- // Releases registered resource for this link
- networkConfigService.removeConfig(LinkKey.linkKey(linkDes.src(), linkDes.dst()), TeLinkConfig.class);
- }
-
- linkProviderService.linkVanished(linkDes);
-
- linkDes = new DefaultLinkDescription(linkDes.dst(), linkDes.src(), Link.Type.DIRECT,
- false, linkDes.annotations());
- linkProviderService.linkVanished(linkDes);
- if (networkConfigService != null && mastershipService.isLocalMaster(linkDes.src().deviceId())) {
- // Releases registered resource for this link
- networkConfigService.removeConfig(LinkKey.linkKey(linkDes.src(), linkDes.dst()), TeLinkConfig.class);
- }
-
- }
- }
-
- // Creates label resource pool for the specific device. For all devices label range is 5122-9217
- private void createDevicePool(DeviceId deviceId) {
- if (labelResourceAdminService == null) {
- return;
- }
-
- labelResourceAdminService.createDevicePool(deviceId, beginLabel, endLabel);
- }
-
- private void registerBandwidthAndTeMetric(LinkDescription linkDes, PathAttrNlriDetails details) {
- if (details == null) {
- log.error("Unable to register bandwidth ");
- return;
- }
-
- List<BgpValueType> attribute = details.pathAttributes().stream()
- .filter(attr -> attr instanceof LinkStateAttributes).collect(toList());
- if (attribute.isEmpty()) {
- return;
- }
-
- List<BgpValueType> tlvs = ((LinkStateAttributes) attribute.iterator().next()).linkStateAttributes();
- double maxReservableBw = 0;
- List<Float> unreservedBw = new ArrayList<>();
- int teMetric = 0;
- int igpMetric = 0;
-
- for (BgpValueType tlv : tlvs) {
- switch (tlv.getType()) {
- case LinkStateAttributes.ATTR_LINK_MAX_RES_BANDWIDTH:
- maxReservableBw = ((BgpLinkAttrMaxLinkBandwidth) tlv).linkAttrMaxLinkBandwidth();
- //will get in bits/second , convert to MBPS to store in network config service
- maxReservableBw = maxReservableBw / 1000000;
- break;
- case LinkStateAttributes.ATTR_LINK_UNRES_BANDWIDTH:
- unreservedBw = ((BgpLinkAttrUnRsrvdLinkBandwidth) tlv).getLinkAttrUnRsrvdLinkBandwidth();
- break;
- case LinkStateAttributes.ATTR_LINK_TE_DEFAULT_METRIC:
- teMetric = ((BgpLinkAttrTeDefaultMetric) tlv).attrLinkDefTeMetric();
- break;
- case LinkStateAttributes.ATTR_LINK_IGP_METRIC:
- igpMetric = ((BgpLinkAttrIgpMetric) tlv).attrLinkIgpMetric();
- break;
- default: // do nothing
- }
- }
-
- //Configure bandwidth for src and dst port
- TeLinkConfig config = networkConfigService.addConfig(LinkKey.linkKey(linkDes.src(), linkDes.dst()),
- TeLinkConfig.class);
- Double bw = 0.0;
- if (unreservedBw.size() > 0) {
- bw = unreservedBw.get(0).doubleValue(); //Low priority
- }
-
- config.maxResvBandwidth(maxReservableBw)
- .unResvBandwidth(bw).teCost(teMetric).igpCost(igpMetric);
- //.apply();
-
- networkConfigService.applyConfig(LinkKey.linkKey(linkDes.src(),
- linkDes.dst()), TeLinkConfig.class, config.node());
- }
-
- private DefaultAnnotations.Builder getAnnotations(DefaultAnnotations.Builder annotationBuilder, boolean isNode,
- PathAttrNlriDetails details) {
-
- List<BgpValueType> attribute = details.pathAttributes().stream()
- .filter(attr -> attr instanceof LinkStateAttributes).collect(toList());
- if (attribute.isEmpty()) {
- return annotationBuilder;
- }
- List<BgpValueType> tlvs = ((LinkStateAttributes) attribute.iterator().next()).linkStateAttributes();
- boolean abrBit = false;
- boolean externalBit = false;
- boolean pseudo = false;
- byte[] areaId = null;
- Ip4Address routerId = null;
- for (BgpValueType tlv : tlvs) {
- switch (tlv.getType()) {
- case LinkStateAttributes.ATTR_NODE_FLAG_BITS:
- abrBit = ((BgpAttrNodeFlagBitTlv) tlv).abrBit();
- externalBit = ((BgpAttrNodeFlagBitTlv) tlv).externalBit();
- break;
- case NodeDescriptors.IGP_ROUTERID_TYPE:
- if (tlv instanceof IsIsPseudonode || tlv instanceof OspfPseudonode) {
- pseudo = true;
- }
- break;
- case LinkStateAttributes.ATTR_NODE_ISIS_AREA_ID:
- areaId = ((BgpAttrNodeIsIsAreaId) tlv).attrNodeIsIsAreaId();
- break;
- case LinkStateAttributes.ATTR_NODE_IPV4_LOCAL_ROUTER_ID:
- routerId = ((BgpAttrRouterIdV4) tlv).attrRouterId();
- break;
- default: // do nothing
- }
- }
-
- // Annotations for device
- if (isNode) {
- boolean internalBit = false;
- if (!abrBit && !externalBit) {
- internalBit = true;
- }
-
- annotationBuilder.set(EXTERNAL_BIT, String.valueOf(externalBit));
- annotationBuilder.set(ABR_BIT, String.valueOf(abrBit));
- annotationBuilder.set(INTERNAL_BIT, String.valueOf(internalBit));
- annotationBuilder.set(PSEUDO, String.valueOf(pseudo));
-
- if (areaId != null) {
- annotationBuilder.set(AREAID, new String(areaId));
- }
- if (routerId != null) {
- // LsrID
- annotationBuilder.set(LSRID, String.valueOf(routerId));
- }
- }
- return annotationBuilder;
- }
-
- @Override
- public void triggerProbe(DeviceId deviceId) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void roleChanged(DeviceId deviceId, MastershipRole newRole) {
- }
-
- @Override
- public boolean isReachable(DeviceId deviceId) {
- return deviceService.isAvailable(deviceId);
- }
-
- @Override
- public void changePortState(DeviceId deviceId, PortNumber portNumber,
- boolean enable) {
- }
-}
diff --git a/providers/bgp/topology/src/main/java/org/onosproject/provider/bgp/topology/impl/package-info.java b/providers/bgp/topology/src/main/java/org/onosproject/provider/bgp/topology/impl/package-info.java
deleted file mode 100644
index d868dce..0000000
--- a/providers/bgp/topology/src/main/java/org/onosproject/provider/bgp/topology/impl/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- *Provider that uses BGP controller as a means of infrastructure topology discovery.
- */
-package org.onosproject.provider.bgp.topology.impl;
\ No newline at end of file
diff --git a/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpControllerAdapter.java b/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpControllerAdapter.java
deleted file mode 100644
index 8ba85bf..0000000
--- a/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpControllerAdapter.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.bgp.topology.impl;
-
-import org.onosproject.bgp.controller.BgpCfg;
-import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.bgp.controller.BgpId;
-import org.onosproject.bgp.controller.BgpLinkListener;
-import org.onosproject.bgp.controller.BgpLocalRib;
-import org.onosproject.bgp.controller.BgpNodeListener;
-import org.onosproject.bgp.controller.BgpPeer;
-import org.onosproject.bgp.controller.BgpPeerManager;
-import org.onosproject.bgp.controller.BgpPrefixListener;
-import org.onosproject.bgp.controller.BgpRouteListener;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.BgpMessage;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Adapter implementation for BGP controller.
- */
-public class BgpControllerAdapter implements BgpController {
- @Override
- public Iterable<BgpPeer> getPeers() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public BgpPeer getPeer(BgpId bgpId) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void writeMsg(BgpId bgpId, BgpMessage msg) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void processBgpPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void closeConnectedPeers() {
- // TODO Auto-generated method stub
- }
-
- @Override
- public BgpCfg getConfig() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public int connectedPeerCount() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public BgpLocalRib bgpLocalRibVpn() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public BgpLocalRib bgpLocalRib() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public BgpPeerManager peerManager() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Map<BgpId, BgpPeer> connectedPeers() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Set<BgpNodeListener> listener() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Set<BgpLinkListener> linkListener() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Set<BgpPrefixListener> prefixListener() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void activeSessionExceptionAdd(String peerId, String exception) {
- return;
- }
-
- @Override
- public void closedSessionExceptionAdd(String peerId, String exception) {
- return;
- }
-
- @Override
- public Map<String, List<String>> activeSessionMap() {
- return null;
- }
-
- @Override
- public Map<String, List<String>> closedSessionMap() {
- return null;
- }
-
- @Override
- public void addRouteListener(BgpRouteListener listener) {
-
- }
-
- @Override
- public void removeRouteListener(BgpRouteListener listener) {
-
- }
-
- @Override
- public Set<BgpRouteListener> routeListener() {
- return null;
- }
-
- @Override
- public void addListener(BgpNodeListener listener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeListener(BgpNodeListener listener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void addLinkListener(BgpLinkListener listener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeLinkListener(BgpLinkListener listener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void addPrefixListener(BgpPrefixListener listener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removePrefixListener(BgpPrefixListener listener) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void notifyTopologyChange() {
- // TODO Auto-generated method stub
- }
-}
diff --git a/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpTopologyProviderTest.java b/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpTopologyProviderTest.java
deleted file mode 100644
index f7a7ce1..0000000
--- a/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpTopologyProviderTest.java
+++ /dev/null
@@ -1,1077 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.onosproject.provider.bgp.topology.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.junit.TestUtils;
-import org.onlab.junit.TestUtils.TestUtilsException;
-import org.onlab.packet.ChassisId;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.bgp.controller.BgpLinkListener;
-import org.onosproject.bgp.controller.BgpNodeListener;
-import org.onosproject.bgpio.exceptions.BgpParseException;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
-import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType;
-import org.onosproject.bgpio.protocol.linkstate.NodeDescriptors;
-import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
-import org.onosproject.bgpio.types.AutonomousSystemTlv;
-import org.onosproject.bgpio.types.BgpValueType;
-import org.onosproject.bgpio.types.IsIsNonPseudonode;
-import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv;
-import org.onosproject.bgpio.types.LinkStateAttributes;
-import org.onosproject.bgpio.types.RouteDistinguisher;
-import org.onosproject.bgpio.types.attr.BgpAttrNodeFlagBitTlv;
-import org.onosproject.bgpio.types.attr.BgpAttrNodeIsIsAreaId;
-import org.onosproject.bgpio.types.attr.BgpAttrRouterIdV4;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrIgpMetric;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrMaxLinkBandwidth;
-import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric;
-import org.onosproject.bgpio.util.Constants;
-import org.onosproject.cluster.NodeId;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourcePool;
-import org.onosproject.mastership.MastershipServiceAdapter;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultDevice;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.config.Config;
-import org.onosproject.net.config.ConfigApplyDelegate;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigRegistryAdapter;
-import org.onosproject.net.config.basics.BandwidthCapacity;
-import org.onosproject.net.device.DeviceDescription;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceProvider;
-import org.onosproject.net.device.DeviceProviderRegistry;
-import org.onosproject.net.device.DeviceProviderService;
-import org.onosproject.net.device.DeviceServiceAdapter;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.device.PortStatistics;
-import org.onosproject.net.link.LinkDescription;
-import org.onosproject.net.link.LinkProvider;
-import org.onosproject.net.link.LinkProviderRegistry;
-import org.onosproject.net.link.LinkProviderService;
-import org.onosproject.net.link.LinkServiceAdapter;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.net.resource.Resource;
-import org.onosproject.net.resource.ResourceAdminService;
-import org.onosproject.net.resource.ResourceId;
-import org.onosproject.pcep.api.TeLinkConfig;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArraySet;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNot.not;
-import static org.onosproject.net.Link.State.ACTIVE;
-import static org.onosproject.net.MastershipRole.MASTER;
-
-/**
- * Test for BGP topology provider.
- */
-public class BgpTopologyProviderTest {
- private static final DeviceId DID2 = DeviceId.deviceId("l3:rd=0::routinguniverse=0:asn=10");
- private static final String UNKNOWN = "unknown";
- public static ProviderId providerId = new ProviderId("l3", "foo");
- private static final NodeId NODE1 = new NodeId("Master1");
-
- private final BgpTopologyProvider provider = new BgpTopologyProvider();
- private final TestDeviceRegistry nodeRegistry = new TestDeviceRegistry();
- private final TestLinkRegistry linkRegistry = new TestLinkRegistry();
- private final MockBgpController controller = new MockBgpController();
- private MockDeviceService deviceService = new MockDeviceService();
- private MockLinkService linkService = new MockLinkService();
- private MockMastershipService mastershipService = new MockMastershipService();
- private MockNetConfigRegistryAdapter networkConfigService = new MockNetConfigRegistryAdapter();
- private MockLabelResourceService labelResourceAdminService = new MockLabelResourceService();
- private Map<DeviceId, Device> deviceMap = new HashMap<>();
- private DeviceListener listener;
-
- @Before
- public void startUp() throws TestUtilsException {
- provider.deviceProviderRegistry = nodeRegistry;
- provider.linkProviderRegistry = linkRegistry;
- provider.controller = controller;
- provider.deviceService = deviceService;
- provider.linkService = linkService;
- provider.labelResourceAdminService = labelResourceAdminService;
- provider.mastershipService = mastershipService;
- provider.networkConfigService = networkConfigService;
- listener = TestUtils.getField(provider, "deviceListener");
- provider.activate();
- assertThat("device provider should be registered", not(nodeRegistry.provider));
- assertThat("link provider should be registered", not(linkRegistry.linkProvider));
- assertThat("node listener should be registered", not(controller.nodeListener));
- assertThat("link listener should be registered", not(controller.linkListener));
- }
-
- @After
- public void tearDown() {
- provider.deactivate();
- provider.controller = null;
- provider.deviceService = null;
- provider.deviceProviderRegistry = null;
- provider.linkService = null;
- provider.mastershipService = null;
- provider.networkConfigService = null;
- provider.labelResourceAdminService = null;
- assertThat(controller.nodeListener, is(new HashSet<BgpNodeListener>()));
- assertThat(controller.linkListener, is(new HashSet<BgpLinkListener>()));
- }
-
- private class MockLabelResourceService implements LabelResourceAdminService {
-
- Map<DeviceId, LabelResourcePool> resourcePool = new HashMap<>();
-
- @Override
- public boolean createDevicePool(DeviceId deviceId, LabelResourceId beginLabel, LabelResourceId endLabel) {
- LabelResourcePool labelResource = new LabelResourcePool(deviceId.toString(),
- beginLabel.labelId(),
- endLabel.labelId());
- if (resourcePool.containsValue(labelResource)) {
- return false;
- }
-
- resourcePool.put(deviceId, labelResource);
- return true;
- }
-
- @Override
- public boolean createGlobalPool(LabelResourceId beginLabel, LabelResourceId endLabel) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean destroyDevicePool(DeviceId deviceId) {
- LabelResourcePool devicePool = resourcePool.get(deviceId);
-
- if (devicePool == null) {
- return false;
- }
-
- resourcePool.remove(deviceId);
- return true;
- }
-
- @Override
- public boolean destroyGlobalPool() {
- // TODO Auto-generated method stub
- return false;
- }
- }
-
- /* Mock test for device service */
- private class MockNetConfigRegistryAdapter extends NetworkConfigRegistryAdapter {
- private ConfigFactory cfgFactory;
- private Map<ConnectPoint, BandwidthCapacity> classConfig = new HashMap<>();
- private Map<LinkKey, TeLinkConfig> teLinkConfig = new HashMap<>();
-
- public Map<LinkKey, TeLinkConfig> getTeLinkConfig() {
- return teLinkConfig;
- }
-
- @Override
- public void registerConfigFactory(ConfigFactory configFactory) {
- cfgFactory = configFactory;
- }
-
- @Override
- public void unregisterConfigFactory(ConfigFactory configFactory) {
- cfgFactory = null;
- }
-
- @Override
- public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) {
- if (configClass == BandwidthCapacity.class) {
- BandwidthCapacity devCap = new BandwidthCapacity();
- classConfig.put((ConnectPoint) subject, devCap);
-
- JsonNode node = new ObjectNode(new MockJsonNode());
- ObjectMapper mapper = new ObjectMapper();
- ConfigApplyDelegate delegate = new InternalApplyDelegate();
- devCap.init((ConnectPoint) subject, null, node, mapper, delegate);
- return (C) devCap;
- } else if (configClass == TeLinkConfig.class) {
- TeLinkConfig linkConfig = new TeLinkConfig();
- teLinkConfig.put((LinkKey) subject, linkConfig);
-
- JsonNode node = new ObjectNode(new MockJsonNode());
- ObjectMapper mapper = new ObjectMapper();
- ConfigApplyDelegate delegate = new InternalApplyDelegate();
- linkConfig.init((LinkKey) subject, null, node, mapper, delegate);
- return (C) linkConfig;
- }
-
- return null;
- }
-
- @Override
- public <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass) {
- if (configClass == BandwidthCapacity.class) {
- classConfig.remove(subject);
- } else if (configClass == TeLinkConfig.class) {
- teLinkConfig.remove(subject);
- }
- }
-
- @Override
- public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) {
- if (configClass == BandwidthCapacity.class) {
- return (C) classConfig.get(subject);
- } else if (configClass == TeLinkConfig.class) {
- return (C) teLinkConfig.get(subject);
- }
- return null;
- }
-
- private class MockJsonNode extends JsonNodeFactory {
- }
-
- // Auxiliary delegate to receive notifications about changes applied to
- // the network configuration - by the apps.
- private class InternalApplyDelegate implements ConfigApplyDelegate {
- @Override
- public void onApply(Config config) {
- }
- }
- }
-
- private class MockMastershipService extends MastershipServiceAdapter {
- @Override
- public MastershipRole getLocalRole(DeviceId deviceId) {
- return MASTER;
- }
-
- @Override
- public boolean isLocalMaster(DeviceId deviceId) {
- return getLocalRole(deviceId) == MASTER;
- }
-
- @Override
- public NodeId getMasterFor(DeviceId deviceId) {
- return NODE1;
- }
- }
-
- private class MockResourceAdminService implements ResourceAdminService {
- Map<ResourceId, List<Resource>> registeredRes = new HashMap<>();
-
- @Override
- public boolean register(List<? extends Resource> resources) {
- for (Resource res : resources) {
- List<Resource> resource = new LinkedList<>();
- resource.add(res);
- if (registeredRes.containsKey(res.id())) {
- resource.addAll(registeredRes.get(res.id()));
- }
- registeredRes.put(res.id(), resource);
- }
- return true;
- }
-
- @Override
- public boolean unregister(List<? extends ResourceId> ids) {
- for (ResourceId id : ids) {
- if (registeredRes.containsKey(id)) {
- registeredRes.remove(id);
- } else {
- return false;
- }
- }
- return true;
- }
- }
-
- private class MockLinkService extends LinkServiceAdapter {
-
- @Override
- public Link getLink(ConnectPoint src, ConnectPoint dst) {
- for (Link link : linkRegistry.links) {
- if (link.src().equals(src) && link.dst().equals(dst)) {
- return link;
- }
- }
- return null;
- }
- }
-
- /* Class implement device test registry */
- private class TestDeviceRegistry implements DeviceProviderRegistry {
- DeviceProvider provider;
-
- Set<DeviceId> connected = new HashSet<>();
- Map<DeviceId, List<PortDescription>> portUpdated = new HashMap<>();
-
- @Override
- public DeviceProviderService register(DeviceProvider provider) {
- this.provider = provider;
- return new TestProviderService();
- }
-
- @Override
- public void unregister(DeviceProvider provider) {
- }
-
- @Override
- public Set<ProviderId> getProviders() {
- return null;
- }
-
- private class TestProviderService implements DeviceProviderService {
-
- @Override
- public DeviceProvider provider() {
- return null;
- }
-
- @Override
- public void deviceConnected(DeviceId deviceId, DeviceDescription deviceDescription) {
- if (!deviceId.equals(DID2)) {
- connected.add(deviceId);
- Device device = new DefaultDevice(BgpTopologyProviderTest.providerId, deviceId, Device.Type.ROUTER,
- UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), deviceDescription.annotations());
- deviceMap.put(deviceId, device);
- }
- }
-
- @Override
- public void deviceDisconnected(DeviceId deviceId) {
- if (!deviceId.equals(DID2)) {
- connected.remove(deviceId);
- deviceMap.remove(deviceId);
- }
- }
-
- @Override
- public void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) {
- portUpdated.put(deviceId, portDescriptions);
- }
-
- @Override
- public void portStatusChanged(DeviceId deviceId, PortDescription portDescription) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void receivedRoleReply(DeviceId deviceId, MastershipRole requested, MastershipRole response) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void updatePortStatistics(DeviceId deviceId, Collection<PortStatistics> portStatistics) {
- // TODO Auto-generated method stub
-
- }
- }
- }
-
- /* Class implement device test registry */
- private class TestLinkRegistry implements LinkProviderRegistry {
- LinkProvider linkProvider;
- LinkedList<Link> links = new LinkedList<>();
-
- @Override
- public LinkProviderService register(LinkProvider provider) {
- this.linkProvider = provider;
- return new TestProviderService();
- }
-
- @Override
- public void unregister(LinkProvider provider) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public Set<ProviderId> getProviders() {
- return null;
- }
-
- private class TestProviderService implements LinkProviderService {
-
- @Override
- public void linkDetected(LinkDescription linkDescription) {
- links.add(DefaultLink.builder()
- .src(linkDescription.src())
- .dst(linkDescription.dst())
- .state(ACTIVE)
- .type(linkDescription.type())
- .providerId(BgpTopologyProviderTest.providerId)
- .annotations(linkDescription.annotations())
- .build());
- }
-
- @Override
- public void linkVanished(LinkDescription linkDescription) {
- links.remove(DefaultLink.builder().src(linkDescription.src())
- .dst(linkDescription.dst()).state(ACTIVE).type(linkDescription.type())
- .providerId(BgpTopologyProviderTest.providerId).build());
- }
-
- @Override
- public void linksVanished(ConnectPoint connectPoint) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void linksVanished(DeviceId deviceId) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public LinkProvider provider() {
- // TODO Auto-generated method stub
- return null;
- }
- }
- }
-
- /* Test class for BGP controller */
- private class MockBgpController extends BgpControllerAdapter {
- protected Set<BgpNodeListener> nodeListener = new CopyOnWriteArraySet<>();
- protected Set<BgpLinkListener> linkListener = new CopyOnWriteArraySet<>();
-
- @Override
- public void addListener(BgpNodeListener nodeListener) {
- this.nodeListener.add(nodeListener);
- }
-
- @Override
- public void removeListener(BgpNodeListener nodeListener) {
- this.nodeListener.remove(nodeListener);
- }
-
- @Override
- public void addLinkListener(BgpLinkListener linkListener) {
- this.linkListener.add(linkListener);
- }
-
- @Override
- public void removeLinkListener(BgpLinkListener linkListener) {
- this.linkListener.remove(linkListener);
- }
- }
-
- /* Mock test for device service */
- private class MockDeviceService extends DeviceServiceAdapter {
- @Override
- public Device getDevice(DeviceId deviceId) {
- return deviceMap.get(deviceId);
- }
- }
-
- /**
- * Validate node is added to the device validating URI, RIB should get updated properly.
- */
- @Test
- public void bgpTopologyProviderTestAddDevice1() {
- LinkedList<BgpValueType> subTlvs = new LinkedList<>();
- BgpValueType tlv = new AutonomousSystemTlv(100);
- short deslength = AutonomousSystemTlv.LENGTH;
- short desType = AutonomousSystemTlv.TYPE;
-
- subTlvs.add(tlv);
- BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(new NodeDescriptors(subTlvs, deslength,
- desType));
- BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
- new RouteDistinguisher());
-
- PathAttrNlriDetails details = new PathAttrNlriDetails();
- details.setIdentifier(0);
- details.setProtocolID(ProtocolType.DIRECT);
- List<BgpValueType> pathAttributes = new LinkedList<>();
- details.setPathAttribute(pathAttributes);
-
- for (BgpNodeListener l : controller.nodeListener) {
- l.addNode(nodeNlri, details);
- assertThat(nodeRegistry.connected.size(), is(1));
- l.deleteNode(nodeNlri);
- assertThat(nodeRegistry.connected.size(), is(0));
- }
- }
-
- /**
- * Validate node is not added to the device for invalid URI, RIB count should be zero.
- */
- @Test
- public void bgpTopologyProviderTestAddDevice2() {
- LinkedList<BgpValueType> subTlvs;
- BgpValueType tlv = new AutonomousSystemTlv(10);
- short deslength = AutonomousSystemTlv.LENGTH;
- short desType = AutonomousSystemTlv.TYPE;
-
- PathAttrNlriDetails details = new PathAttrNlriDetails();
- details.setIdentifier(0);
- details.setProtocolID(ProtocolType.DIRECT);
- List<BgpValueType> pathAttributes = new LinkedList<>();
- details.setPathAttribute(pathAttributes);
-
- subTlvs = new LinkedList<>();
- subTlvs.add(tlv);
- BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(new NodeDescriptors(subTlvs, deslength,
- desType));
- BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
- new RouteDistinguisher());
-
-
- for (BgpNodeListener l : controller.nodeListener) {
- l.addNode(nodeNlri, details);
- assertThat(nodeRegistry.connected.size(), is(0));
- }
- }
-
- /**
- * Delete node when node does not exist, RIB count should be zero.
- */
- @Test
- public void bgpTopologyProviderTestAddDevice3() {
- LinkedList<BgpValueType> subTlvs;
- BgpValueType tlv = new AutonomousSystemTlv(10);
- short deslength = AutonomousSystemTlv.LENGTH;
- short desType = AutonomousSystemTlv.TYPE;
-
- subTlvs = new LinkedList<>();
- subTlvs.add(tlv);
- BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(new NodeDescriptors(subTlvs, deslength,
- desType));
- BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
- new RouteDistinguisher());
-
- for (BgpNodeListener l : controller.nodeListener) {
- l.deleteNode(nodeNlri);
- assertThat(nodeRegistry.connected.size(), is(0));
- }
- }
-
-
- /**
- * Validate node is added to the device with all device annotations.
- */
- @Test
- public void bgpTopologyProviderTestAddDevice4() {
- LinkedList<BgpValueType> subTlvs = new LinkedList<>();
- BgpValueType tlv = new AutonomousSystemTlv(100);
- short deslength = AutonomousSystemTlv.LENGTH;
- short desType = AutonomousSystemTlv.TYPE;
-
- subTlvs.add(tlv);
- BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(new NodeDescriptors(subTlvs, deslength,
- desType));
- BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
- new RouteDistinguisher());
-
- PathAttrNlriDetails details = new PathAttrNlriDetails();
- details.setIdentifier(0);
- details.setProtocolID(ProtocolType.DIRECT);
- List<BgpValueType> pathAttributes = new LinkedList<>();
- List<BgpValueType> linkStateAttr = new LinkedList<>();
- tlv = BgpAttrNodeFlagBitTlv.of(true, true, true, false);
- linkStateAttr.add(tlv);
- tlv = BgpAttrNodeIsIsAreaId.of(new byte[] {01, 01, 01, 01});
- linkStateAttr.add(tlv);
- tlv = BgpAttrRouterIdV4.of(Ip4Address.valueOf("1.1.1.1"), LinkStateAttributes.ATTR_NODE_IPV4_LOCAL_ROUTER_ID);
- linkStateAttr.add(tlv);
- pathAttributes.add(new LinkStateAttributes(linkStateAttr));
- details.setPathAttribute(pathAttributes);
-
- for (BgpNodeListener l : controller.nodeListener) {
- l.addNode(nodeNlri, details);
-
- assertThat(deviceMap.values().iterator().next().annotations().value(BgpTopologyProvider.ABR_BIT),
- is("false"));
- assertThat(deviceMap.values().iterator().next().annotations().value(BgpTopologyProvider.EXTERNAL_BIT),
- is("true"));
- assertThat(deviceMap.values().iterator().next().annotations().value(BgpTopologyProvider.INTERNAL_BIT),
- is("false"));
- assertThat(deviceMap.values().iterator().next().annotations().value(BgpTopologyProvider.PSEUDO),
- is("false"));
- assertThat(deviceMap.values().iterator().next().annotations().value(BgpTopologyProvider.AREAID).getBytes(),
- is(new byte[] {01, 01, 01, 01}));
- assertThat(deviceMap.values().iterator().next().annotations().value(BgpTopologyProvider.LSRID),
- is("1.1.1.1"));
-
- assertThat(nodeRegistry.connected.size(), is(1));
- l.deleteNode(nodeNlri);
- assertThat(nodeRegistry.connected.size(), is(0));
- }
- }
-
- /**
- * Add a link and two devices.
- *
- * @throws BgpParseException while adding a link.
- */
- @Test
- public void bgpTopologyProviderTestAddLink1() throws BgpParseException {
- LinkedList<BgpValueType> localTlvs = new LinkedList<>();
- LinkedList<BgpValueType> remoteTlvs = new LinkedList<>();
- LinkedList<BgpValueType> linkdes = new LinkedList<>();
- BgpValueType tlv = new AutonomousSystemTlv(10);
- short deslength = AutonomousSystemTlv.LENGTH;
- short desType = AutonomousSystemTlv.TYPE;
-
- localTlvs.add(tlv);
- remoteTlvs.add(tlv);
- tlv = IsIsNonPseudonode.of(new byte[] {20, 20, 20, 20, 00, 20});
- localTlvs.add(tlv);
- tlv = IsIsNonPseudonode.of(new byte[] {30, 30, 30, 30, 00, 30});
- remoteTlvs.add(tlv);
- NodeDescriptors localNode = new NodeDescriptors(localTlvs, deslength, desType);
- NodeDescriptors remoteNode = new NodeDescriptors(remoteTlvs, deslength, desType);
- BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(localNode);
- BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
- new RouteDistinguisher());
-
- BgpNodeLSIdentifier remoteNodeDescriptors = new BgpNodeLSIdentifier(remoteNode);
- BgpNodeLSNlriVer4 remNodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, remoteNodeDescriptors, false,
- new RouteDistinguisher());
-
- PathAttrNlriDetails details = new PathAttrNlriDetails();
- details.setIdentifier(0);
- details.setProtocolID(ProtocolType.DIRECT);
- List<BgpValueType> pathAttributes = new LinkedList<>();
- details.setPathAttribute(pathAttributes);
-
- tlv = LinkLocalRemoteIdentifiersTlv.of(99, 100);
- linkdes.add(tlv);
- BgpLinkLSIdentifier linkId = new BgpLinkLSIdentifier(localNode, remoteNode, linkdes);
- BgpLinkLsNlriVer4 linkNlri = new BgpLinkLsNlriVer4((byte) Constants.DIRECT, 0, linkId,
- new RouteDistinguisher(), false);
- for (BgpNodeListener l : controller.nodeListener) {
- l.addNode(nodeNlri, details);
- assertThat(nodeRegistry.connected.size(), is(1));
- l.addNode(remNodeNlri, details);
- assertThat(nodeRegistry.connected.size(), is(2));
- }
- for (BgpLinkListener l : controller.linkListener) {
- l.addLink(linkNlri, details);
- assertThat(linkRegistry.links.size(), is(1));
- }
- }
-
- /**
- * Add a link and delete a link.
- *
- * @throws BgpParseException while adding or removing the link
- */
- @Test
- public void bgpTopologyProviderTestAddLink2() throws BgpParseException {
- LinkedList<BgpValueType> localTlvs = new LinkedList<>();
- LinkedList<BgpValueType> remoteTlvs = new LinkedList<>();
- LinkedList<BgpValueType> linkdes = new LinkedList<>();
- BgpValueType tlv = new AutonomousSystemTlv(10);
- short deslength = AutonomousSystemTlv.LENGTH;
- short desType = AutonomousSystemTlv.TYPE;
-
- localTlvs.add(tlv);
- remoteTlvs.add(tlv);
- tlv = IsIsNonPseudonode.of(new byte[] {20, 20, 20, 20, 00, 20});
- localTlvs.add(tlv);
- tlv = IsIsNonPseudonode.of(new byte[] {30, 30, 30, 30, 00, 30});
- remoteTlvs.add(tlv);
- NodeDescriptors localNode = new NodeDescriptors(localTlvs, deslength, desType);
- NodeDescriptors remoteNode = new NodeDescriptors(remoteTlvs, deslength, desType);
- BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(localNode);
- BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
- new RouteDistinguisher());
-
- BgpNodeLSIdentifier remoteNodeDescriptors = new BgpNodeLSIdentifier(remoteNode);
- BgpNodeLSNlriVer4 remNodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, remoteNodeDescriptors, false,
- new RouteDistinguisher());
-
- PathAttrNlriDetails details = new PathAttrNlriDetails();
- details.setIdentifier(0);
- details.setProtocolID(ProtocolType.DIRECT);
- List<BgpValueType> pathAttributes = new LinkedList<>();
- details.setPathAttribute(pathAttributes);
-
- tlv = LinkLocalRemoteIdentifiersTlv.of(99, 100);
- linkdes.add(tlv);
- BgpLinkLSIdentifier linkId = new BgpLinkLSIdentifier(localNode, remoteNode, linkdes);
- BgpLinkLsNlriVer4 linkNlri = new BgpLinkLsNlriVer4((byte) Constants.DIRECT, 0, linkId,
- new RouteDistinguisher(), false);
- for (BgpNodeListener l : controller.nodeListener) {
- l.addNode(nodeNlri, details);
- assertThat(nodeRegistry.connected.size(), is(1));
- l.addNode(remNodeNlri, details);
- assertThat(nodeRegistry.connected.size(), is(2));
- l.deleteNode(nodeNlri);
- assertThat(nodeRegistry.connected.size(), is(1));
- }
- for (BgpLinkListener l : controller.linkListener) {
- l.addLink(linkNlri, details);
- assertThat(linkRegistry.links.size(), is(1));
- l.deleteLink(linkNlri);
- assertThat(linkRegistry.links.size(), is(0));
- }
- }
-
- /**
- * Add a link and delete a link with registering/unregistering bandwidth.
- *
- * @throws BgpParseException while adding or removing the link
- * @throws InterruptedException while registering for bandwidth
- */
- @Test
- public void bgpTopologyProviderTestAddLink3() throws BgpParseException, InterruptedException {
- LinkedList<BgpValueType> localTlvs = new LinkedList<>();
- LinkedList<BgpValueType> remoteTlvs = new LinkedList<>();
- LinkedList<BgpValueType> linkdes = new LinkedList<>();
- BgpValueType tlv = new AutonomousSystemTlv(10);
- short deslength = AutonomousSystemTlv.LENGTH;
- short desType = AutonomousSystemTlv.TYPE;
-
- localTlvs.add(tlv);
- remoteTlvs.add(tlv);
- tlv = IsIsNonPseudonode.of(new byte[] {20, 20, 20, 20, 00, 20});
- localTlvs.add(tlv);
- tlv = IsIsNonPseudonode.of(new byte[] {30, 30, 30, 30, 00, 30});
- remoteTlvs.add(tlv);
- NodeDescriptors localNode = new NodeDescriptors(localTlvs, deslength, desType);
- NodeDescriptors remoteNode = new NodeDescriptors(remoteTlvs, deslength, desType);
- BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(localNode);
- BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
- new RouteDistinguisher());
-
- BgpNodeLSIdentifier remoteNodeDescriptors = new BgpNodeLSIdentifier(remoteNode);
- BgpNodeLSNlriVer4 remNodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, remoteNodeDescriptors, false,
- new RouteDistinguisher());
-
- PathAttrNlriDetails details = new PathAttrNlriDetails();
- details.setIdentifier(0);
- details.setProtocolID(ProtocolType.DIRECT);
- List<BgpValueType> pathAttributes = new LinkedList<>();
- details.setPathAttribute(pathAttributes);
-
- tlv = LinkLocalRemoteIdentifiersTlv.of(99, 100);
- linkdes.add(tlv);
- BgpLinkLSIdentifier linkId = new BgpLinkLSIdentifier(localNode, remoteNode, linkdes);
- BgpLinkLsNlriVer4 linkNlri = new BgpLinkLsNlriVer4((byte) Constants.DIRECT, 0, linkId,
- new RouteDistinguisher(), false);
-
- for (BgpNodeListener l : controller.nodeListener) {
- l.addNode(nodeNlri, details);
- assertThat(nodeRegistry.connected.size(), is(1));
- l.addNode(remNodeNlri, details);
- assertThat(nodeRegistry.connected.size(), is(2));
- l.deleteNode(remNodeNlri);
- assertThat(nodeRegistry.connected.size(), is(1));
- }
-
- List<BgpValueType> linkPathAttributes = new LinkedList<>();
- List<BgpValueType> linkStateAttr = new LinkedList<>();
- tlv = BgpLinkAttrIgpMetric.of(10, 4);
- linkStateAttr.add(tlv);
- tlv = BgpLinkAttrTeDefaultMetric.of(20);
- linkStateAttr.add(tlv);
- tlv = BgpLinkAttrMaxLinkBandwidth.of(30, LinkStateAttributes.ATTR_LINK_MAX_RES_BANDWIDTH);
- linkStateAttr.add(tlv);
- linkPathAttributes.add(new LinkStateAttributes(linkStateAttr));
- details.setPathAttribute(linkPathAttributes);
-
- for (BgpLinkListener l : controller.linkListener) {
- l.addLink(linkNlri, details);
- assertThat(linkRegistry.links.size(), is(1));
- TeLinkConfig config = networkConfigService.getTeLinkConfig().get(LinkKey.linkKey(linkRegistry.links
- .getFirst().src(), linkRegistry.links.getLast().dst()));
-
- assertThat(config.igpCost(), is(10));
- assertThat(config.teCost(), is(20));
-
- l.deleteLink(linkNlri);
- assertThat(linkRegistry.links.size(), is(0));
- }
- }
-
- /**
- * Invalid link.
- *
- * @throws BgpParseException while adding or deleting a link
- */
- @Test
- public void bgpTopologyProviderTestDeleteLink3() throws BgpParseException {
- LinkedList<BgpValueType> localTlvs = new LinkedList<>();
- LinkedList<BgpValueType> remoteTlvs = new LinkedList<>();
- LinkedList<BgpValueType> linkdes = new LinkedList<>();
- BgpValueType tlv = new AutonomousSystemTlv(10);
- short deslength = AutonomousSystemTlv.LENGTH;
- short desType = AutonomousSystemTlv.TYPE;
-
- localTlvs.add(tlv);
- remoteTlvs.add(tlv);
- tlv = IsIsNonPseudonode.of(new byte[] {20, 20, 20, 20, 00, 20});
- localTlvs.add(tlv);
- tlv = IsIsNonPseudonode.of(new byte[] {30, 30, 30, 30, 00, 30});
- remoteTlvs.add(tlv);
- NodeDescriptors localNode = new NodeDescriptors(localTlvs, deslength, desType);
- NodeDescriptors remoteNode = new NodeDescriptors(remoteTlvs, deslength, desType);
- BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(localNode);
- BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
- new RouteDistinguisher());
-
- BgpNodeLSIdentifier remoteNodeDescriptors = new BgpNodeLSIdentifier(remoteNode);
- BgpNodeLSNlriVer4 remNodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, remoteNodeDescriptors, false,
- new RouteDistinguisher());
-
- PathAttrNlriDetails details = new PathAttrNlriDetails();
- details.setIdentifier(0);
- details.setProtocolID(ProtocolType.DIRECT);
- List<BgpValueType> pathAttributes = new LinkedList<>();
- details.setPathAttribute(pathAttributes);
-
- tlv = LinkLocalRemoteIdentifiersTlv.of(99, 100);
- linkdes.add(tlv);
- BgpLinkLSIdentifier linkId = new BgpLinkLSIdentifier(localNode, remoteNode, linkdes);
- BgpLinkLsNlriVer4 linkNlri = new BgpLinkLsNlriVer4((byte) Constants.DIRECT, 0, linkId,
- new RouteDistinguisher(), false);
- for (BgpNodeListener l : controller.nodeListener) {
- l.addNode(nodeNlri, details);
- l.addNode(remNodeNlri, details);
- assertThat(nodeRegistry.connected.size(), is(2));
- l.deleteNode(nodeNlri);
- assertThat(nodeRegistry.connected.size(), is(1));
- }
- for (BgpLinkListener l : controller.linkListener) {
- l.deleteLink(linkNlri);
- assertThat(linkRegistry.links.size(), is(0));
- }
- }
-
- /**
- * Add device check label registration is done.
- *
- * @throws BgpParseException while adding a device
- */
- @Test
- public void bgpTopologyProviderDeviceTestLabel1() throws BgpParseException {
- LinkedList<BgpValueType> subTlvs = new LinkedList<>();
- BgpValueType tlv = new AutonomousSystemTlv(100);
- short deslength = AutonomousSystemTlv.LENGTH;
- short desType = AutonomousSystemTlv.TYPE;
-
- subTlvs.add(tlv);
- BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(new NodeDescriptors(subTlvs, deslength,
- desType));
- BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
- new RouteDistinguisher());
-
- PathAttrNlriDetails details = new PathAttrNlriDetails();
- details.setIdentifier(0);
- details.setProtocolID(ProtocolType.DIRECT);
- List<BgpValueType> pathAttributes = new LinkedList<>();
- List<BgpValueType> linkStateAttributes = new LinkedList<>();
- tlv = BgpAttrRouterIdV4.of(Ip4Address.valueOf("1.1.1.1"), LinkStateAttributes.ATTR_NODE_IPV4_LOCAL_ROUTER_ID);
- linkStateAttributes.add(tlv);
- pathAttributes.add(new LinkStateAttributes(linkStateAttributes));
- details.setPathAttribute(pathAttributes);
-
- for (BgpNodeListener l : controller.nodeListener) {
- l.addNode(nodeNlri, details);
- assertThat(nodeRegistry.connected.size(), is(1));
- }
- DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
-
- newBuilder.set("lsrId", "1.1.1.1");
-
- Device device = new DefaultDevice(BgpTopologyProviderTest.providerId, nodeRegistry.connected.iterator().next(),
- Device.Type.ROUTER, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), newBuilder.build());
-
- DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device);
- listener.event(event);
- assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1));
- }
-
- /**
- * Add device check label registration is done and delete node destroy label pool.
- *
- * @throws BgpParseException while adding a device
- */
- @Test
- public void bgpTopologyProviderDeviceTestLabel2() throws BgpParseException {
- LinkedList<BgpValueType> subTlvs = new LinkedList<>();
- BgpValueType tlv = new AutonomousSystemTlv(100);
- short deslength = AutonomousSystemTlv.LENGTH;
- short desType = AutonomousSystemTlv.TYPE;
-
- subTlvs.add(tlv);
- BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(new NodeDescriptors(subTlvs, deslength,
- desType));
- BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
- new RouteDistinguisher());
-
- PathAttrNlriDetails details = new PathAttrNlriDetails();
- details.setIdentifier(0);
- details.setProtocolID(ProtocolType.DIRECT);
- List<BgpValueType> pathAttributes = new LinkedList<>();
- List<BgpValueType> linkStateAttributes = new LinkedList<>();
- tlv = BgpAttrRouterIdV4.of(Ip4Address.valueOf("1.1.1.1"), LinkStateAttributes.ATTR_NODE_IPV4_LOCAL_ROUTER_ID);
- linkStateAttributes.add(tlv);
- pathAttributes.add(new LinkStateAttributes(linkStateAttributes));
- details.setPathAttribute(pathAttributes);
-
- for (BgpNodeListener l : controller.nodeListener) {
- l.addNode(nodeNlri, details);
- assertThat(nodeRegistry.connected.size(), is(1));
-
- DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
-
- newBuilder.set("lsrId", "1.1.1.1");
-
- Device device = new DefaultDevice(BgpTopologyProviderTest.providerId,
- nodeRegistry.connected.iterator().next(), Device.Type.ROUTER, UNKNOWN,
- UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), newBuilder.build());
-
- DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device);
- listener.event(event);
- assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1));
-
- l.deleteNode(nodeNlri);
- assertThat(nodeRegistry.connected.size(), is(0));
- assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(0));
- }
- }
-
- /**
- * Add a link register bandwidth and remove link unregister bandwidth.
- *
- * @throws BgpParseException while registering/unregistering bandwidth
- */
- @Test
- public void bgpTopologyProviderDeviceTestLabel3() throws BgpParseException {
- LinkedList<BgpValueType> localTlvs = new LinkedList<>();
- LinkedList<BgpValueType> remoteTlvs = new LinkedList<>();
- LinkedList<BgpValueType> linkdes = new LinkedList<>();
- BgpValueType tlv = new AutonomousSystemTlv(10);
- short deslength = AutonomousSystemTlv.LENGTH;
- short desType = AutonomousSystemTlv.TYPE;
-
- localTlvs.add(tlv);
- remoteTlvs.add(tlv);
- tlv = IsIsNonPseudonode.of(new byte[] {20, 20, 20, 20, 00, 20});
- localTlvs.add(tlv);
- tlv = IsIsNonPseudonode.of(new byte[] {30, 30, 30, 30, 00, 30});
- remoteTlvs.add(tlv);
- NodeDescriptors localNode = new NodeDescriptors(localTlvs, deslength, desType);
- NodeDescriptors remoteNode = new NodeDescriptors(remoteTlvs, deslength, desType);
- BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(localNode);
- BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
- new RouteDistinguisher());
-
- BgpNodeLSIdentifier remoteNodeDescriptors = new BgpNodeLSIdentifier(remoteNode);
- BgpNodeLSNlriVer4 remNodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, remoteNodeDescriptors, false,
- new RouteDistinguisher());
-
- PathAttrNlriDetails details = new PathAttrNlriDetails();
- details.setIdentifier(0);
- details.setProtocolID(ProtocolType.DIRECT);
- List<BgpValueType> pathAttributes = new LinkedList<>();
- List<BgpValueType> linkStateAttributes = new LinkedList<>();
- tlv = BgpAttrRouterIdV4.of(Ip4Address.valueOf("1.1.1.1"), LinkStateAttributes.ATTR_NODE_IPV4_LOCAL_ROUTER_ID);
- linkStateAttributes.add(tlv);
- pathAttributes.add(new LinkStateAttributes(linkStateAttributes));
- details.setPathAttribute(pathAttributes);
-
- tlv = LinkLocalRemoteIdentifiersTlv.of(99, 100);
- linkdes.add(tlv);
- BgpLinkLSIdentifier linkId = new BgpLinkLSIdentifier(localNode, remoteNode, linkdes);
- BgpLinkLsNlriVer4 linkNlri = new BgpLinkLsNlriVer4((byte) Constants.DIRECT, 0, linkId,
- new RouteDistinguisher(), false);
-
- for (BgpNodeListener l : controller.nodeListener) {
- l.addNode(nodeNlri, details);
- assertThat(nodeRegistry.connected.size(), is(1));
- //Check label resource reserved for that device
- DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
-
- newBuilder.set("lsrId", "1.1.1.1");
-
- Device device = new DefaultDevice(BgpTopologyProviderTest.providerId,
- nodeRegistry.connected.iterator().next(), Device.Type.ROUTER,
- UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, new ChassisId(), newBuilder.build());
-
- DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device);
- listener.event(event);
- assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1));
- l.addNode(remNodeNlri, details);
- assertThat(nodeRegistry.connected.size(), is(2));
- l.deleteNode(remNodeNlri);
- assertThat(nodeRegistry.connected.size(), is(1));
- assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1));
- }
-
- List<BgpValueType> linkPathAttributes = new LinkedList<>();
- List<BgpValueType> linkStateAttr = new LinkedList<>();
- tlv = BgpLinkAttrIgpMetric.of(10, 4);
- linkStateAttr.add(tlv);
- tlv = BgpLinkAttrTeDefaultMetric.of(20);
- linkStateAttr.add(tlv);
- tlv = BgpLinkAttrMaxLinkBandwidth.of((float) 70 * 1_000_000L,
- LinkStateAttributes.ATTR_LINK_MAX_RES_BANDWIDTH);
- linkStateAttr.add(tlv);
- linkPathAttributes.add(new LinkStateAttributes(linkStateAttr));
- details.setPathAttribute(linkPathAttributes);
-
- for (BgpLinkListener l : controller.linkListener) {
- l.addLink(linkNlri, details);
- LinkKey linkKey = LinkKey.linkKey(linkRegistry.links.getFirst().src(),
- linkRegistry.links.getLast().dst());
- assertThat(linkRegistry.links.size(), is(1));
- TeLinkConfig config = networkConfigService.getTeLinkConfig().get(linkKey);
-
- assertThat(config.igpCost(), is(10));
- assertThat(config.teCost(), is(20));
-
- ConnectPoint src = new ConnectPoint(
- DeviceId.deviceId("l3:rd=0::routinguniverse=0:asn=10:isoid=1414.1414.0014"),
- PortNumber.portNumber(4294967395L));
- ConnectPoint dst = new ConnectPoint(
- DeviceId.deviceId("l3:rd=0::routinguniverse=0:asn=10:isoid=1e1e.1e1e.001e"),
- PortNumber.portNumber(4294967396L));
-
- assertThat(config.maxResvBandwidth(), is(70.0));
-
- l.deleteLink(linkNlri);
- assertThat(linkRegistry.links.size(), is(0));
- config = networkConfigService.getTeLinkConfig().get(linkKey);
- assertThat(config, is(nullValue()));
- }
- }
-}
diff --git a/providers/bgpcep/BUILD b/providers/bgpcep/BUILD
deleted file mode 100644
index 9910827..0000000
--- a/providers/bgpcep/BUILD
+++ /dev/null
@@ -1,30 +0,0 @@
-BUNDLES = [
- "//protocols/bgp/bgpio:onos-protocols-bgp-bgpio",
- "//protocols/bgp/api:onos-protocols-bgp-api",
- "//protocols/bgp/ctl:onos-protocols-bgp-ctl",
- "//protocols/pcep/pcepio:onos-protocols-pcep-pcepio",
- "//apps/pcep-api:onos-apps-pcep-api",
- "//protocols/pcep/server/api:onos-protocols-pcep-server-api",
- "//providers/bgp/topology:onos-providers-bgp-topology",
- "//providers/bgp/cfg:onos-providers-bgp-cfg",
- "//protocols/pcep/server/ctl:onos-protocols-pcep-server-ctl",
- "//providers/pcep/topology:onos-providers-pcep-topology",
- "//providers/pcep/tunnel:onos-providers-pcep-tunnel",
- "//providers/bgpcep/flow:onos-providers-bgpcep-flow",
- "//apps/pce/app:onos-apps-pce-app",
- "//apps/pce/pceweb:onos-apps-pce-pceweb",
- "//apps/pce/bandwidthmgmt:onos-apps-pce-bandwidthmgmt",
-]
-
-onos_app(
- category = "Provider",
- description = "BGPCEP providers.",
- included_bundles = BUNDLES,
- required_apps = [
- "org.onosproject.tunnel",
- "org.onosproject.bgp",
- "org.onosproject.pcep-api",
- ],
- title = "BGPCEP Provider",
- url = "http://onosproject.org",
-)
diff --git a/providers/bgpcep/flow/BUILD b/providers/bgpcep/flow/BUILD
deleted file mode 100644
index 53c3dda0..0000000
--- a/providers/bgpcep/flow/BUILD
+++ /dev/null
@@ -1,9 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + [
- "//protocols/bgp/api:onos-protocols-bgp-api",
- "//protocols/pcep/server/api:onos-protocols-pcep-server-api",
- "//protocols/pcep/pcepio:onos-protocols-pcep-pcepio",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
diff --git a/providers/bgpcep/flow/src/main/java/org/onosproject/provider/bgpcep/flow/impl/BgpcepFlowRuleProvider.java b/providers/bgpcep/flow/src/main/java/org/onosproject/provider/bgpcep/flow/impl/BgpcepFlowRuleProvider.java
deleted file mode 100644
index 9593920..0000000
--- a/providers/bgpcep/flow/src/main/java/org/onosproject/provider/bgpcep/flow/impl/BgpcepFlowRuleProvider.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.bgpcep.flow.impl;
-
-import org.onosproject.net.flow.FlowRule;
-import org.onosproject.net.flow.FlowRuleProvider;
-import org.onosproject.net.flow.FlowRuleProviderRegistry;
-import org.onosproject.net.flow.FlowRuleProviderService;
-import org.onosproject.net.flow.oldbatch.FlowRuleBatchOperation;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Implementation of BGP-PCEP flow provider.
- */
-@Component(immediate = true)
-public class BgpcepFlowRuleProvider extends AbstractProvider
- implements FlowRuleProvider {
-
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected FlowRuleProviderRegistry providerRegistry;
-
- private FlowRuleProviderService providerService;
-
- /**
- * Creates a BgpFlow host provider.
- */
- public BgpcepFlowRuleProvider() {
- super(new ProviderId("l3", "org.onosproject.provider.bgpcep"));
- }
-
- @Activate
- public void activate(ComponentContext context) {
- providerService = providerRegistry.register(this);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate(ComponentContext context) {
- providerRegistry.unregister(this);
- providerService = null;
- log.info("Stopped");
- }
-
- @Override
- public void applyFlowRule(FlowRule... flowRules) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void removeFlowRule(FlowRule... flowRules) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void executeBatch(FlowRuleBatchOperation batch) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/providers/bgpcep/flow/src/main/java/org/onosproject/provider/bgpcep/flow/impl/package-info.java b/providers/bgpcep/flow/src/main/java/org/onosproject/provider/bgpcep/flow/impl/package-info.java
deleted file mode 100644
index 3286376..0000000
--- a/providers/bgpcep/flow/src/main/java/org/onosproject/provider/bgpcep/flow/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Representation of BGP-PCEP flow provider.
- */
-package org.onosproject.provider.bgpcep.flow.impl;
diff --git a/providers/ietfte/topology/src/main/java/org/onosproject/provider/te/topology/RestconfServerConfig.java b/providers/ietfte/topology/src/main/java/org/onosproject/provider/te/topology/RestconfServerConfig.java
deleted file mode 100644
index 1d4dec8..0000000
--- a/providers/ietfte/topology/src/main/java/org/onosproject/provider/te/topology/RestconfServerConfig.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.te.topology;
-
-import java.util.Set;
-
-import org.onlab.packet.IpAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.config.basics.ConfigException;
-import org.onosproject.net.config.Config;
-import org.onosproject.protocol.rest.DefaultRestSBDevice;
-import org.onosproject.protocol.rest.RestSBDevice;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.google.common.collect.Sets;
-
-/**
- * Configuration for Restconf Server.
- */
-public class RestconfServerConfig extends Config<ApplicationId> {
- private static final String CONFIG_VALUE_ERROR = "Error parsing config value";
- private static final String IP = "ip";
- private static final int DEFAULT_HTTP_PORT = 80;
- private static final String PORT = "port";
- private static final String USERNAME = "username";
- private static final String PASSWORD = "password";
- private static final String PROTOCOL = "protocol";
- private static final String URL = "url";
-
- /**
- * Returns the device addresses from JSON.
- *
- * @return A set of RESTCONF Server devices
- * @throws ConfigException if there is a configuration error
- */
- public Set<RestSBDevice> getDevicesAddresses() throws ConfigException {
- Set<RestSBDevice> devicesAddresses = Sets.newHashSet();
-
- try {
- for (JsonNode node : array) {
- String ip = node.path(IP).asText();
- IpAddress ipAddr = ip.isEmpty() ? null : IpAddress.valueOf(ip);
- int port = node.path(PORT).asInt(DEFAULT_HTTP_PORT);
- String username = node.path(USERNAME).asText();
- String password = node.path(PASSWORD).asText();
- String protocol = node.path(PROTOCOL).asText();
- String url = node.path(URL).asText();
- devicesAddresses.add(new DefaultRestSBDevice(ipAddr, port, username,
- password, protocol,
- url, false));
-
- }
- } catch (IllegalArgumentException e) {
- throw new ConfigException(CONFIG_VALUE_ERROR, e);
- }
-
- return devicesAddresses;
- }
-
-}
diff --git a/providers/ietfte/topology/src/main/java/org/onosproject/provider/te/topology/TeTopologyRestconfProvider.java b/providers/ietfte/topology/src/main/java/org/onosproject/provider/te/topology/TeTopologyRestconfProvider.java
deleted file mode 100644
index 8bc44da..0000000
--- a/providers/ietfte/topology/src/main/java/org/onosproject/provider/te/topology/TeTopologyRestconfProvider.java
+++ /dev/null
@@ -1,472 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.te.topology;
-
-import static org.onlab.util.Tools.groupedThreads;
-import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_ADDED;
-import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_UPDATED;
-import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
-import static org.onosproject.provider.te.utils.TeTopologyRestconfEventType.TE_TOPOLOGY_LINK_NOTIFICATION;
-import static org.onosproject.provider.te.utils.TeTopologyRestconfEventType.TE_TOPOLOGY_NODE_NOTIFICATION;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.nio.charset.StandardCharsets;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.apache.commons.io.IOUtils;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.incubator.net.config.basics.ConfigException;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigRegistry;
-import org.onosproject.net.device.DeviceProviderRegistry;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.protocol.rest.RestSBDevice;
-import org.onosproject.protocol.restconf.RestConfSBController;
-import org.onosproject.provider.te.utils.DefaultJsonCodec;
-import org.onosproject.provider.te.utils.RestconfNotificationEventProcessor;
-import org.onosproject.provider.te.utils.TeTopologyRestconfEventListener;
-import org.onosproject.provider.te.utils.YangCompositeEncodingImpl;
-import org.onosproject.tetopology.management.api.TeTopologyProvider;
-import org.onosproject.tetopology.management.api.TeTopologyProviderRegistry;
-import org.onosproject.tetopology.management.api.TeTopologyProviderService;
-import org.onosproject.tetopology.management.api.TeTopologyService;
-import org.onosproject.tetopology.management.api.link.NetworkLink;
-import org.onosproject.tetopology.management.api.link.NetworkLinkKey;
-import org.onosproject.tetopology.management.api.node.NetworkNode;
-import org.onosproject.tetopology.management.api.node.NetworkNodeKey;
-import org.onosproject.teyang.utils.topology.LinkConverter;
-import org.onosproject.teyang.utils.topology.NetworkConverter;
-import org.onosproject.teyang.utils.topology.NodeConverter;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.IetfNetwork;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev20151208.ietfnetwork.networks.Network;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev20151208.IetfNetworkTopology;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.IetfTeTopology;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.IetfTeTopologyEvent;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.TeLinkEvent;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.topology.rev20170110.ietftetopology.TeNodeEvent;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.ietftetypes.tetopologyeventtype.TeTopologyEventTypeEnum;
-import org.onosproject.yms.ych.YangCodecHandler;
-import org.onosproject.yms.ych.YangProtocolEncodingFormat;
-import org.onosproject.yms.ych.YangResourceIdentifierType;
-import org.onosproject.yms.ydt.YmsOperationType;
-import org.onosproject.yms.ymsm.YmsService;
-import org.slf4j.Logger;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Provider for IETF TE Topology that use RESTCONF as means of communication.
- */
-@Component(immediate = true)
-public class TeTopologyRestconfProvider extends AbstractProvider
- implements TeTopologyProvider {
- private static final String APP_NAME = "org.onosproject.teprovider";
- private static final String RESTCONF = "restconf";
- private static final String PROVIDER =
- "org.onosproject.teprovider.restconf.domain";
- private static final String IETF_NETWORK_URI = "ietf-network:networks";
- private static final String IETF_NETWORKS_PREFIX =
- "{\"ietf-network:networks\":";
- private static final String TE_LINK_EVENT_PREFIX =
- "{\"ietf-te-topology:te-link-event\":";
- private static final String TE_NODE_EVENT_PREFIX =
- "{\"ietf-te-topology:te-node-event\":";
- private static final String IETF_NOTIFICATION_URI = "netconf";
- private static final String JSON = "json";
- private static final String E_DEVICE_NULL = "Restconf device is null";
-
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceProviderRegistry deviceProviderRegistry;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TeTopologyProviderRegistry topologyProviderRegistry;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected RestConfSBController restconfClient;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigRegistry cfgService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected YmsService ymsService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TeTopologyService teTopologyService;
-
- private YangCodecHandler codecHandler;
-
- private TeTopologyProviderService topologyProviderService;
-
- private final ExecutorService executor =
- Executors.newFixedThreadPool(5, groupedThreads("onos/restconfsbprovider",
- "device-installer-%d", log));
-
- private final ConfigFactory<ApplicationId, RestconfServerConfig> factory =
- new ConfigFactory<ApplicationId, RestconfServerConfig>(APP_SUBJECT_FACTORY,
- RestconfServerConfig.class,
- "restconfDevices",
- true) {
- @Override
- public RestconfServerConfig createConfig() {
- return new RestconfServerConfig();
- }
- };
-
- private final NetworkConfigListener cfgLister = new InternalNetworkConfigListener();
- private ApplicationId appId;
-
- private Set<DeviceId> addedDevices = new HashSet<>();
-
- @Activate
- public void activate() {
- // Get the codec handler.
- codecHandler = ymsService.getYangCodecHandler();
- // Register all three IETF Topology YANG model schema with YMS.
- codecHandler.addDeviceSchema(IetfNetwork.class);
- codecHandler.addDeviceSchema(IetfNetworkTopology.class);
- codecHandler.addDeviceSchema(IetfTeTopology.class);
- // Register JSON CODEC functions
- codecHandler.registerOverriddenCodec(new DefaultJsonCodec(ymsService),
- YangProtocolEncodingFormat.JSON);
-
- appId = coreService.registerApplication(APP_NAME);
- topologyProviderService = topologyProviderRegistry.register(this);
- cfgService.registerConfigFactory(factory);
- cfgService.addListener(cfgLister);
- executor.execute(TeTopologyRestconfProvider.this::connectDevices);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- cfgService.removeListener(cfgLister);
- restconfClient.getDevices().keySet().forEach(this::deviceRemoved);
- topologyProviderRegistry.unregister(this);
- cfgService.unregisterConfigFactory(factory);
- log.info("Stopped");
- }
-
- /**
- * Creates an instance of TeTopologyRestconf provider.
- */
- public TeTopologyRestconfProvider() {
- super(new ProviderId(RESTCONF, PROVIDER));
- }
-
- private void deviceAdded(RestSBDevice nodeId) {
- Preconditions.checkNotNull(nodeId, E_DEVICE_NULL);
- nodeId.setActive(true);
- addedDevices.add(nodeId.deviceId());
- }
-
- private void deviceRemoved(DeviceId deviceId) {
- Preconditions.checkNotNull(deviceId, E_DEVICE_NULL);
- restconfClient.removeDevice(deviceId);
- }
-
- private void connectDevices() {
-
- RestconfServerConfig cfg = cfgService.getConfig(appId,
- RestconfServerConfig.class);
- try {
- if (cfg != null && cfg.getDevicesAddresses() != null) {
- //Precomputing the devices to be removed
- Set<RestSBDevice> toBeRemoved = new HashSet<>(restconfClient.
- getDevices().values());
- toBeRemoved.removeAll(cfg.getDevicesAddresses());
- //Adding new devices
- for (RestSBDevice device : cfg.getDevicesAddresses()) {
- device.setActive(false);
- restconfClient.addDevice(device);
- deviceAdded(device);
- }
-
- //Removing devices not wanted anymore
- toBeRemoved.forEach(device -> deviceRemoved(device.deviceId()));
- }
- } catch (ConfigException e) {
- log.error("Configuration error {}", e);
- }
-
- // Discover the topology from RESTCONF server
- addedDevices.forEach(this::retrieveTopology);
- addedDevices.clear();
- }
-
- private void retrieveTopology(DeviceId deviceId) {
- // Retrieve IETF Network at top level.
- InputStream jsonStream = restconfClient.get(deviceId,
- IETF_NETWORK_URI,
- JSON);
- if (jsonStream == null) {
- log.warn("Unable to retrieve network Topology from restconf " +
- "server {}", deviceId);
- return;
- }
-
- // Need to convert Input stream to String.
- StringWriter writer = new StringWriter();
- try {
- IOUtils.copy(jsonStream, writer, StandardCharsets.UTF_8);
- } catch (IOException e) {
- log.warn("There is an exception {} for copy jsonStream to " +
- "stringWriter for restconf {}",
- e.getMessage(), deviceId);
- return;
- }
- String jsonString = writer.toString();
- String networkLevelJsonString = removePrefixTagFromJson(jsonString,
- IETF_NETWORKS_PREFIX);
-
- YangCompositeEncodingImpl yce =
- new YangCompositeEncodingImpl(YangResourceIdentifierType.URI,
- IETF_NETWORK_URI,
- networkLevelJsonString);
-
- Object yo = codecHandler.decode(yce,
- YangProtocolEncodingFormat.JSON,
- YmsOperationType.QUERY_REPLY);
-
- if (yo == null) {
- log.error("YMS decoder returns null for restconf {}", deviceId);
- return;
- }
-
- // YMS returns an ArrayList in a single Object (i.e. yo in this case)
- // this means yo is actually an ArrayList of size 1
- IetfNetwork ietfNetwork = ((List<IetfNetwork>) yo).get(0);
-
- if (ietfNetwork.networks() != null &&
- ietfNetwork.networks().network() != null) {
- //Convert the YO to TE Core data and update TE Core.
- for (Network nw : ietfNetwork.networks().network()) {
- topologyProviderService.networkUpdated(
- NetworkConverter.yang2TeSubsystemNetwork(nw, ietfNetwork.networks(), deviceId));
- }
- }
-
- //TODO: Uncomment when YMS fixes the issue in NetworkState translation (network-ref)
-// org.onosproject.tetopology.management.api.Networks networks =
-// NetworkConverter.yang2TeSubsystemNetworks(ietfNetwork.networks(),
-// ietfNetwork.networksState());
-// if (networks == null || networks.networks() == null) {
-// log.error("Yang2Te returns null for restconf {}", deviceId);
-// return;
-// }
-// for (org.onosproject.tetopology.management.api.Network network : networks.networks()) {
-// topologyProviderService.networkUpdated(network);
-// }
-
- subscribeRestconfNotification(deviceId);
- }
-
- private void subscribeRestconfNotification(DeviceId deviceId) {
-
- TeTopologyRestconfEventListener listener =
- new TeTopologyRestconfEventListener();
-
- listener.addCallbackFunction(TE_TOPOLOGY_LINK_NOTIFICATION,
- new InternalLinkEventProcessor());
- listener.addCallbackFunction(TE_TOPOLOGY_NODE_NOTIFICATION,
- new InternalNodeEventProcessor());
-
- if (!restconfClient.isNotificationEnabled(deviceId)) {
- restconfClient.enableNotifications(deviceId,
- IETF_NOTIFICATION_URI,
- "application/json",
- listener);
- } else {
- restconfClient.addNotificationListener(deviceId, listener);
- }
- }
-
- private String removePrefixTagFromJson(String jsonString, String prefixTag) {
- if (jsonString.startsWith(prefixTag)) {
- return jsonString.substring(prefixTag.length(), jsonString.length() - 1);
- }
- return jsonString;
- }
-
- private class InternalLinkEventProcessor implements
- RestconfNotificationEventProcessor<String> {
-
- @Override
- public void processEventPayload(String payload) {
- String linkString = removePrefixTagFromJson(payload,
- TE_LINK_EVENT_PREFIX);
- log.debug("link event={}", linkString);
- handleRestconfLinkNotification(linkString);
- }
-
- private void handleRestconfLinkNotification(String linkString) {
-
- IetfTeTopologyEvent event = convertJson2IetfTeTopologyEvent(
- "ietf-te-topology:te-link-event",
- linkString);
- if (event == null) {
- log.error("ERROR: json to YO conversion failure");
- return;
- }
-
- if (event.type() != IetfTeTopologyEvent.Type.TE_LINK_EVENT) {
- log.error("ERROR: wrong YO event type: {}", event.type());
- return;
- }
-
- TeLinkEvent teLinkEvent = event.subject().teLinkEvent();
-
- log.debug("TeLinkEvent: {}", teLinkEvent);
-
- NetworkLinkKey linkKey = LinkConverter.yangLinkEvent2NetworkLinkKey(
- teLinkEvent);
-
- TeTopologyEventTypeEnum teLinkEventType = teLinkEvent.eventType()
- .enumeration();
-
- if (teLinkEventType == TeTopologyEventTypeEnum.REMOVE) {
- topologyProviderService.linkRemoved(linkKey);
- return;
- }
-
- NetworkLink networkLink = LinkConverter.yangLinkEvent2NetworkLink(teLinkEvent,
- teTopologyService);
-
- if (networkLink == null) {
- log.error("ERROR: yangLinkEvent2NetworkLink returns null");
- return;
- }
-
- log.debug("networkLink: {}", networkLink);
-
- topologyProviderService.linkUpdated(linkKey, networkLink);
- }
- }
-
- private class InternalNodeEventProcessor implements
- RestconfNotificationEventProcessor<String> {
-
- @Override
- public void processEventPayload(String payload) {
- String nodeString = removePrefixTagFromJson(payload, TE_NODE_EVENT_PREFIX);
- log.debug("node event={}", nodeString);
- handleRestconfNodeNotification(nodeString);
- }
-
- private void handleRestconfNodeNotification(String nodeString) {
-
- IetfTeTopologyEvent event = convertJson2IetfTeTopologyEvent(
- "ietf-te-topology:te-node-event",
- nodeString);
-
- if (event == null) {
- log.error("ERROR: json to YO conversion failure");
- return;
- }
-
- if (event.type() != IetfTeTopologyEvent.Type.TE_NODE_EVENT) {
- log.error("ERROR: wrong YO event type: {}", event.type());
- return;
- }
-
- TeNodeEvent teNodeEvent = event.subject().teNodeEvent();
-
- log.debug("TeNodeEvent: {}", teNodeEvent);
-
- NetworkNodeKey nodeKey = NodeConverter.yangNodeEvent2NetworkNodeKey(
- teNodeEvent);
-
- TeTopologyEventTypeEnum teNodeEventType = teNodeEvent.eventType()
- .enumeration();
-
- if (teNodeEventType == TeTopologyEventTypeEnum.REMOVE) {
- topologyProviderService.nodeRemoved(nodeKey);
- return;
- }
-
- NetworkNode networkNode = NodeConverter.yangNodeEvent2NetworkNode(
- teNodeEvent,
- teTopologyService);
-
- if (networkNode == null) {
- log.error("ERROR: yangNodeEvent2NetworkNode returns null");
- return;
- }
-
- topologyProviderService.nodeUpdated(nodeKey, networkNode);
- }
- }
-
- private class InternalNetworkConfigListener implements NetworkConfigListener {
-
- @Override
- public void event(NetworkConfigEvent event) {
- executor.execute(TeTopologyRestconfProvider.this::connectDevices);
- }
-
- @Override
- public boolean isRelevant(NetworkConfigEvent event) {
- return event.configClass().equals(RestconfServerConfig.class) &&
- (event.type() == CONFIG_ADDED ||
- event.type() == CONFIG_UPDATED);
- }
- }
-
- private IetfTeTopologyEvent convertJson2IetfTeTopologyEvent(String uriString,
- String jsonBody) {
-
- YangCompositeEncodingImpl yce =
- new YangCompositeEncodingImpl(YangResourceIdentifierType.URI,
- uriString,
- jsonBody);
- Object yo = codecHandler.decode(yce,
- YangProtocolEncodingFormat.JSON,
- YmsOperationType.NOTIFICATION);
-
- if (yo == null) {
- log.error("YMS decoder error");
- return null;
- }
-
- if (!(yo instanceof IetfTeTopologyEvent)) {
- log.error("ERROR: YO is not IetfTeTopologyEvent");
- return null;
- }
-
- return (IetfTeTopologyEvent) yo;
- }
-}
diff --git a/providers/ietfte/topology/src/main/java/org/onosproject/provider/te/topology/package-info.java b/providers/ietfte/topology/src/main/java/org/onosproject/provider/te/topology/package-info.java
deleted file mode 100644
index 44cad2b..0000000
--- a/providers/ietfte/topology/src/main/java/org/onosproject/provider/te/topology/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * IETF TE Topology provider implementation using RESTCONF protocol.
- */
-package org.onosproject.provider.te.topology;
diff --git a/providers/ietfte/tunnel/src/main/java/org/onosproject/provider/te/tunnel/TeTunnelRestconfProvider.java b/providers/ietfte/tunnel/src/main/java/org/onosproject/provider/te/tunnel/TeTunnelRestconfProvider.java
deleted file mode 100644
index 3c765aa..0000000
--- a/providers/ietfte/tunnel/src/main/java/org/onosproject/provider/te/tunnel/TeTunnelRestconfProvider.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.te.tunnel;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelDescription;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelProvider;
-import org.onosproject.incubator.net.tunnel.TunnelProviderRegistry;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.ElementId;
-import org.onosproject.net.Path;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.protocol.restconf.RestConfSBController;
-import org.onosproject.protocol.restconf.RestconfNotificationEventListener;
-import org.onosproject.provider.te.utils.DefaultJsonCodec;
-import org.onosproject.provider.te.utils.YangCompositeEncodingImpl;
-import org.onosproject.tetopology.management.api.TeTopology;
-import org.onosproject.tetopology.management.api.TeTopologyKey;
-import org.onosproject.tetopology.management.api.TeTopologyService;
-import org.onosproject.tetunnel.api.TeTunnelProviderService;
-import org.onosproject.tetunnel.api.TeTunnelService;
-import org.onosproject.tetunnel.api.tunnel.DefaultTeTunnel;
-import org.onosproject.tetunnel.api.tunnel.TeTunnel;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.IetfTe;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.rev20160705.ietfte.tunnelsgrouping.Tunnels;
-import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev20160705.IetfTeTypes;
-import org.onosproject.yms.ych.YangCodecHandler;
-import org.onosproject.yms.ych.YangCompositeEncoding;
-import org.onosproject.yms.ych.YangProtocolEncodingFormat;
-import org.onosproject.yms.ymsm.YmsService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.List;
-import java.util.Optional;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static org.onosproject.provider.te.utils.CodecTools.jsonToString;
-import static org.onosproject.provider.te.utils.CodecTools.toJson;
-import static org.onosproject.tetopology.management.api.TeTopology.BIT_MERGED;
-import static org.onosproject.teyang.utils.tunnel.TunnelConverter.buildIetfTe;
-import static org.onosproject.teyang.utils.tunnel.TunnelConverter.yang2TeTunnel;
-import static org.onosproject.yms.ych.YangProtocolEncodingFormat.JSON;
-import static org.onosproject.yms.ych.YangResourceIdentifierType.URI;
-import static org.onosproject.yms.ydt.YmsOperationType.EDIT_CONFIG_REQUEST;
-import static org.onosproject.yms.ydt.YmsOperationType.QUERY_REPLY;
-
-
-/**
- * Provider which uses RESTCONF to do cross-domain tunnel creation/deletion/
- * update/deletion and so on operations on the domain networks.
- */
-
-@Component(immediate = true)
-public class TeTunnelRestconfProvider extends AbstractProvider
- implements TunnelProvider {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private static final String SCHEMA = "ietf";
- private static final String IETF = "ietf";
- private static final String TE = "te";
- private static final int DEFAULT_INDEX = 1;
- private static final String TUNNELS = "tunnels";
- private static final String TUNNELS_URL = IETF + ":" + TE + "/" + TUNNELS;
- private static final String IETF_NOTIFICATION_URI = "netconf";
- private static final String MEDIA_TYPE_JSON = "json";
-
- private static final String SHOULD_IN_ONE = "Tunnel should be setup in one topo";
- private static final String PROVIDER_ID = "org.onosproject.provider.ietf";
- private static final String RESTCONF_ROOT = "/onos/restconf";
- private static final String TE_TUNNEL_KEY = "TeTunnelKey";
-
- //private final RestconfNotificationEventListener listener =
- // new InternalTunnelNotificationListener();
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected RestConfSBController controller;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected YmsService ymsService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TeTunnelService tunnelService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TeTunnelProviderService providerService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TeTopologyService topologyService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TunnelProviderRegistry tunnelProviderRegistry;
-
- private YangCodecHandler codecHandler;
-
- @Activate
- public void activate() {
- tunnelProviderRegistry.register(this);
- codecHandler = ymsService.getYangCodecHandler();
- codecHandler.addDeviceSchema(IetfTe.class);
- codecHandler.addDeviceSchema(IetfTeTypes.class);
- codecHandler.registerOverriddenCodec(new DefaultJsonCodec(ymsService),
- YangProtocolEncodingFormat.JSON);
- collectInitialTunnels();
- subscribe();
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- tunnelProviderRegistry.unregister(this);
- unsubscribe();
- log.info("Stopped");
-
- }
-
- public TeTunnelRestconfProvider() {
- super(new ProviderId(SCHEMA, PROVIDER_ID));
- }
-
- private void collectInitialTunnels() {
- for (DeviceId deviceId : controller.getDevices().keySet()) {
- ObjectNode jsonNodes = executeGetRequest(deviceId);
- if (jsonNodes == null) {
- continue;
- }
- ObjectNode tunnelsNode = (ObjectNode) jsonNodes.get(TUNNELS);
- if (tunnelsNode == null) {
- continue;
- }
- Tunnels teTunnels = getYangTunnelsObject(tunnelsNode);
- if (teTunnels == null) {
- continue;
- }
- updateTeTunnels(teTunnels);
- }
- }
-
- private void subscribe() {
- for (DeviceId deviceId : controller.getDevices().keySet()) {
- try {
- if (!controller.isNotificationEnabled(deviceId)) {
- controller.enableNotifications(deviceId, IETF_NOTIFICATION_URI,
- "application/json",
- new InternalTunnelNotificationListener());
- } else {
- controller.addNotificationListener(deviceId,
- new InternalTunnelNotificationListener());
- }
- } catch (Exception e) {
- log.error("Failed to subscribe for {} : {}", deviceId,
- e.getMessage());
- }
- }
- }
-
- private void unsubscribe() {
- controller.getDevices()
- .keySet()
- .forEach(deviceId -> controller
- .removeNotificationListener(deviceId,
- new InternalTunnelNotificationListener()));
- }
-
- @Override
- public void setupTunnel(Tunnel tunnel, Path path) {
- TeTunnel teTunnel = tunnelService.getTeTunnel(tunnel.tunnelId());
- long tid = teTunnel.srcNode().topologyId();
- checkState(tid == teTunnel.dstNode().topologyId(), SHOULD_IN_ONE);
- setupTunnel(getOwnDevice(tid), tunnel, path);
- }
-
- @Override
- public void setupTunnel(ElementId srcElement, Tunnel tunnel, Path path) {
- if (!tunnel.annotations().keys().contains(TE_TUNNEL_KEY)) {
- log.warn("No tunnel key info in tunnel {}", tunnel);
- return;
- }
-
- String teTunnelKey = tunnel.annotations().value(TE_TUNNEL_KEY);
-
- Optional<TeTunnel> optTunnel = tunnelService.getTeTunnels()
- .stream()
- .filter(t -> t.teTunnelKey().toString().equals(teTunnelKey))
- .findFirst();
-
- if (!optTunnel.isPresent()) {
- log.warn("No te tunnel map to tunnel {}", tunnel);
- return;
- }
-
- IetfTe ietfTe = buildIetfTe(optTunnel.get(), true);
-
- YangCompositeEncoding encoding = codecHandler.
- encodeCompositeOperation(RESTCONF_ROOT, null, ietfTe,
- JSON, EDIT_CONFIG_REQUEST);
- String identifier = encoding.getResourceIdentifier();
- String resourceInformation = encoding.getResourceInformation();
-
- if (srcElement == null) {
- log.error("Can't find remote device for tunnel : {}", tunnel);
- return;
- }
- controller.post((DeviceId) srcElement, identifier,
- new ByteArrayInputStream(resourceInformation.getBytes()),
- MEDIA_TYPE_JSON, ObjectNode.class);
- }
-
- @Override
- public void releaseTunnel(Tunnel tunnel) {
- //TODO implement release tunnel method
- }
-
- @Override
- public void releaseTunnel(ElementId srcElement, Tunnel tunnel) {
- //TODO implement release tunnel with src method
- }
-
- @Override
- public void updateTunnel(Tunnel tunnel, Path path) {
- //TODO implement update tunnel method
-
- }
-
- @Override
- public void updateTunnel(ElementId srcElement, Tunnel tunnel, Path path) {
- //TODO implement update tunnel with src method
- }
-
- @Override
- public TunnelId tunnelAdded(TunnelDescription tunnel) {
- //TODO implement tunnel add method when te tunnel app merged to core
- return null;
- }
-
- @Override
- public void tunnelRemoved(TunnelDescription tunnel) {
- //TODO implement tunnel remove method when te tunnel app merged to core
-
- }
-
- @Override
- public void tunnelUpdated(TunnelDescription tunnel) {
- //TODO implement tunnel update method when te tunnel app merged to core
- }
-
- @Override
- public Tunnel tunnelQueryById(TunnelId tunnelId) {
- return null;
- }
-
- private ObjectNode executeGetRequest(DeviceId deviceId) {
- //the request url is ietf-te:te/tunnels
- //the response node will begin with tunnels
- //be careful here to when get the tunnels data
- InputStream resultStream =
- controller.get(deviceId, TUNNELS_URL, MEDIA_TYPE_JSON);
- return toJson(resultStream);
- }
-
- private Tunnels getYangTunnelsObject(ObjectNode tunnelsNode) {
- checkNotNull(tunnelsNode, "Input object node should not be null");
-
- YangCompositeEncoding yce =
- new YangCompositeEncodingImpl(URI,
- TUNNELS_URL,
- jsonToString(tunnelsNode));
-
- Object yo = codecHandler.decode(yce, JSON, QUERY_REPLY);
-
- if (yo == null) {
- log.error("YMS decoder returns null");
- return null;
- }
- IetfTe ietfTe = null;
- Tunnels tunnels = null;
- if (yo instanceof List) {
- List<Object> list = (List<Object>) yo;
- ietfTe = (IetfTe) list.get(DEFAULT_INDEX);
- }
- if (ietfTe != null && ietfTe.te() != null) {
- tunnels = ietfTe.te().tunnels();
- }
- return tunnels;
- }
-
- private void updateTeTunnels(Tunnels tunnels) {
- TeTopologyKey key = getTopologyKey();
-
- tunnels.tunnel().forEach(tunnel -> {
- DefaultTeTunnel teTunnel = yang2TeTunnel(tunnel, key);
- providerService.updateTeTunnel(teTunnel);
- });
- }
-
- private TeTopologyKey getTopologyKey() {
- TeTopologyKey key = null;
- Optional<TeTopology> teTopology = topologyService.teTopologies()
- .teTopologies()
- .values()
- .stream()
- .filter(topology -> topology.flags().get(BIT_MERGED))
- .findFirst();
- if (teTopology.isPresent()) {
- TeTopology topology = teTopology.get();
- key = topology.teTopologyId();
- }
- return key;
- }
-
- private DeviceId getOwnDevice(long topologyId) {
- DeviceId deviceId = null;
- Optional<TeTopology> topoOpt = topologyService.teTopologies()
- .teTopologies()
- .values()
- .stream()
- .filter(tp -> tp.teTopologyId().topologyId() == topologyId)
- .findFirst();
-
- if (topoOpt.isPresent()) {
- deviceId = topoOpt.get().ownerId();
- }
- return deviceId;
- }
-
-
- private class InternalTunnelNotificationListener implements
- RestconfNotificationEventListener {
-
- @Override
- public void handleNotificationEvent(DeviceId deviceId, Object eventJsonString) {
- ObjectNode response = toJson((String) eventJsonString);
- if (response == null) {
- return;
- }
- JsonNode teNode = response.get(TE);
- if (teNode == null) {
- log.error("Illegal te json object from {}", deviceId);
- return;
- }
- JsonNode tunnelsNode = teNode.get(TUNNELS);
- if (tunnelsNode == null) {
- log.error("Illegal tunnel json object from {}", deviceId);
- return;
- }
-
- Tunnels tunnels = getYangTunnelsObject((ObjectNode) tunnelsNode);
- if (tunnels == null) {
- return;
- }
- updateTeTunnels(tunnels);
- }
- }
-}
diff --git a/providers/ietfte/tunnel/src/main/java/org/onosproject/provider/te/tunnel/package-info.java b/providers/ietfte/tunnel/src/main/java/org/onosproject/provider/te/tunnel/package-info.java
deleted file mode 100644
index de207de..0000000
--- a/providers/ietfte/tunnel/src/main/java/org/onosproject/provider/te/tunnel/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright 2016 Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * IETF TE Tunnel provider implementation using RESTCONF protocol.
- */
-package org.onosproject.provider.te.tunnel;
\ No newline at end of file
diff --git a/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/CodecTools.java b/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/CodecTools.java
deleted file mode 100644
index d10c877..0000000
--- a/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/CodecTools.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.te.utils;
-
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.slf4j.Logger;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import static org.onlab.util.Tools.readTreeFromStream;
-import static org.slf4j.LoggerFactory.getLogger;
-
-
-/**
- * Convert utility methods for IETF SB.
- */
-public final class CodecTools {
- private static final Logger log = getLogger(CodecTools.class);
- private static final ObjectMapper MAPPER = new ObjectMapper();
-
- //no instantiation
- private CodecTools() {
- }
-
- /**
- * Returns an object node from a InputStream type input which usually comes
- * from the HTTP response.
- *
- * @param stream stream data comes from a HTTP response
- * @return object node
- */
- public static ObjectNode toJson(InputStream stream) {
- ObjectNode response = null;
- try {
- response = readTreeFromStream(MAPPER, stream);
- } catch (IOException e) {
- log.error("Parse json string failed {}", e.getMessage());
- }
-
- return response;
- }
-
- /**
- * Returns an object node from a string.
- *
- * @param jsonString string with JSON format
- * @return object node
- */
- public static ObjectNode toJson(String jsonString) {
- ObjectNode response = null;
- try {
- response = (ObjectNode) MAPPER.readTree(jsonString);
- } catch (IOException e) {
- log.error("Parse json string failed {}", e.getMessage());
- }
-
- return response;
- }
-
- /**
- * Returns a JSON format string from a Jackson object node.
- *
- * @param node JSON object node
- * @return string with JSON format
- */
- public static String jsonToString(ObjectNode node) {
- ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
- String jsonString = null;
- try {
- jsonString = ow.writeValueAsString(node);
- } catch (JsonProcessingException e) {
- log.error("Parse json to string failed {}", e.getMessage());
- }
-
- return jsonString;
- }
-}
diff --git a/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/DefaultJsonCodec.java b/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/DefaultJsonCodec.java
deleted file mode 100644
index 42125c6..0000000
--- a/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/DefaultJsonCodec.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.te.utils;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onosproject.yms.ych.YangCompositeEncoding;
-import org.onosproject.yms.ych.YangDataTreeCodec;
-import org.onosproject.yms.ydt.YdtBuilder;
-import org.onosproject.yms.ydt.YdtContext;
-import org.onosproject.yms.ydt.YmsOperationType;
-import org.onosproject.yms.ymsm.YmsService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.onosproject.protocol.restconf.server.utils.parser.json.ParserUtils.convertJsonToYdt;
-import static org.onosproject.protocol.restconf.server.utils.parser.json.ParserUtils.convertUriToYdt;
-import static org.onosproject.protocol.restconf.server.utils.parser.json.ParserUtils.convertYdtToJson;
-import static org.onosproject.protocol.restconf.server.utils.parser.json.ParserUtils.getJsonNameFromYdtNode;
-import static org.onosproject.provider.te.utils.CodecTools.jsonToString;
-import static org.onosproject.provider.te.utils.CodecTools.toJson;
-import static org.onosproject.yms.ydt.YdtContextOperationType.NONE;
-import static org.onosproject.yms.ych.YangResourceIdentifierType.URI;
-
-
-/**
- * JSON/YDT Codec implementation.
- */
-public class DefaultJsonCodec implements YangDataTreeCodec {
- private static final String RESTCONF_ROOT = "/onos/restconf";
- private static final String DATA = "data";
- private static final String SLASH = "/";
-
- private final YmsService ymsService;
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- public DefaultJsonCodec(YmsService service) {
- ymsService = service;
- }
-
- @Override
- public String encodeYdtToProtocolFormat(YdtBuilder builder) {
- YdtContext context = builder.getRootNode();
- ObjectNode jsonNode = convertYdtToJson(getJsonNameFromYdtNode(context),
- builder.getRootNode(),
- ymsService.getYdtWalker());
- return jsonToString(jsonNode);
- }
-
- @Override
- public YangCompositeEncoding encodeYdtToCompositeProtocolFormat(
- YdtBuilder builder) {
- YdtContext rootNode = builder.getRootNode();
- String rootName = rootNode.getName();
- YdtContext child = rootNode.getFirstChild();
- String name = child.getName();
- String url = rootName + SLASH + DATA + SLASH + name;
- String jsonRoot = getJsonNameFromYdtNode(child);
- ObjectNode objectNode = convertYdtToJson(jsonRoot, child,
- ymsService.getYdtWalker());
- String payload = jsonToString((ObjectNode) objectNode.get(jsonRoot));
- return new YangCompositeEncodingImpl(URI, url, payload);
- }
-
- @Override
- public YdtBuilder decodeProtocolDataToYdt(String protocolData,
- Object schemaRegistry,
- YmsOperationType opType) {
- // Get a new builder
- YdtBuilder builder = ymsService.getYdtBuilder(RESTCONF_ROOT,
- null,
- opType,
- schemaRegistry);
-
- convertJsonToYdt(toJson(protocolData), builder);
- return builder;
- }
-
- @Override
- public YdtBuilder decodeCompositeProtocolDataToYdt(YangCompositeEncoding protocolData,
- Object schemaRegistry,
- YmsOperationType opType) {
-
- YdtBuilder builder = ymsService.getYdtBuilder(RESTCONF_ROOT,
- null,
- opType,
- schemaRegistry);
-
- // YdtContextOperationType should be NONE for URI in QUERY_RESPONSE.
- convertUriToYdt(protocolData.getResourceIdentifier(), builder, NONE);
-
- // NULL/EMPTY for Resource data
- builder.setDefaultEditOperationType(null);
-
- // Convert the payload json body to ydt
- convertJsonToYdt(toJson(protocolData.getResourceInformation()), builder);
- return builder;
- }
-}
diff --git a/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/RestconfNotificationEventProcessor.java b/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/RestconfNotificationEventProcessor.java
deleted file mode 100644
index 77985cc..0000000
--- a/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/RestconfNotificationEventProcessor.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.te.utils;
-
-/**
- * Abstraction of the RESTCONF notification callback function. The callback
- * is invoked by the notification listener when it receives an event.
- */
-public interface RestconfNotificationEventProcessor<T> {
- void processEventPayload(T event);
-}
diff --git a/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/TeTopologyRestconfEventListener.java b/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/TeTopologyRestconfEventListener.java
deleted file mode 100644
index 5a80154..0000000
--- a/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/TeTopologyRestconfEventListener.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.te.utils;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.protocol.restconf.RestconfNotificationEventListener;
-import org.slf4j.Logger;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Implementation of the RESTCONF notification event
- * listener for TE Topology.
- */
-public class TeTopologyRestconfEventListener implements
- RestconfNotificationEventListener<String> {
- private static final String TE_TOPOLOGY_NOTIFICATION_PREFIX =
- "{\"ietf-te-topology:ietf-te-topology\":";
- private static final String TE_LINK_EVENT_PREFIX =
- "{\"ietf-te-topology:te-link-event\":";
- private static final String TE_NODE_EVENT_PREFIX =
- "{\"ietf-te-topology:te-node-event\":";
-
- private final Logger log = getLogger(getClass());
-
- private Map<TeTopologyRestconfEventType, RestconfNotificationEventProcessor>
- eventCallbackFunctionMap = new ConcurrentHashMap<>();
-
- @Override
- public void handleNotificationEvent(DeviceId deviceId,
- String eventJsonString) {
- log.debug("New notification: {} for device: {}",
- eventJsonString, deviceId.toString());
-
- if (!eventJsonString.startsWith(TE_TOPOLOGY_NOTIFICATION_PREFIX)) {
- // This is not a TE topology event.
- return;
- }
-
- String teEventString = removePrefixTagFromJson(eventJsonString,
- TE_TOPOLOGY_NOTIFICATION_PREFIX);
-
- TeTopologyRestconfEventType eventType = getEventType(teEventString);
-
- if (eventType == TeTopologyRestconfEventType.TE_UNKNOWN_EVENT) {
- log.error("handleNotificationEvent: unknown event: {}", eventJsonString);
- return;
- }
-
- RestconfNotificationEventProcessor eventProcessor =
- eventCallbackFunctionMap.get(eventType);
-
- if (eventProcessor != null) {
- eventProcessor.processEventPayload(teEventString);
- } else {
- log.info("Event callback not installed for event type: {}", eventType);
- }
- }
-
- /**
- * Registers an notification event callback function which is called by
- * the listener when it receives an event.
- *
- * @param eventType notification event type corresponding to the
- * callback function
- * @param eventProcessor callback function
- */
- public void addCallbackFunction(TeTopologyRestconfEventType eventType,
- RestconfNotificationEventProcessor eventProcessor) {
- if (eventCallbackFunctionMap.containsKey(eventType)) {
- removeCallbackFunction(eventType);
- }
-
- eventCallbackFunctionMap.put(eventType, eventProcessor);
- }
-
- /**
- * Removes the callback function associated with the given event type.
- *
- * @param eventType notification event type
- */
- public void removeCallbackFunction(TeTopologyRestconfEventType eventType) {
- eventCallbackFunctionMap.remove(eventType);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- TeTopologyRestconfEventListener that = (TeTopologyRestconfEventListener) o;
-
- return eventCallbackFunctionMap != null ?
- eventCallbackFunctionMap.equals(that.eventCallbackFunctionMap) :
- that.eventCallbackFunctionMap == null;
- }
-
- @Override
- public int hashCode() {
- return eventCallbackFunctionMap != null ? eventCallbackFunctionMap.hashCode() : 0;
- }
-
- private String removePrefixTagFromJson(String jsonString, String prefixTag) {
- if (jsonString.startsWith(prefixTag)) {
- return jsonString.substring(prefixTag.length(), jsonString.length() - 1);
- }
- return jsonString;
- }
-
- private TeTopologyRestconfEventType getEventType(String teEventString) {
- if (teEventString.startsWith(TE_LINK_EVENT_PREFIX)) {
- return TeTopologyRestconfEventType.TE_TOPOLOGY_LINK_NOTIFICATION;
- }
-
- if (teEventString.startsWith(TE_NODE_EVENT_PREFIX)) {
- return TeTopologyRestconfEventType.TE_TOPOLOGY_NODE_NOTIFICATION;
- }
-
- return TeTopologyRestconfEventType.TE_UNKNOWN_EVENT;
- }
-}
-
diff --git a/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/TeTopologyRestconfEventType.java b/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/TeTopologyRestconfEventType.java
deleted file mode 100644
index d306f50..0000000
--- a/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/TeTopologyRestconfEventType.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.te.utils;
-
-/**
- * Types of TE Topology RESTCONF notification events.
- */
-public enum TeTopologyRestconfEventType {
- /**
- * TE topology link event type.
- */
- TE_TOPOLOGY_LINK_NOTIFICATION,
-
- /**
- * TE topology node event type.
- */
- TE_TOPOLOGY_NODE_NOTIFICATION,
-
- /**
- * Unknown or unsupported event type.
- */
- TE_UNKNOWN_EVENT,
-}
diff --git a/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/YangCompositeEncodingImpl.java b/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/YangCompositeEncodingImpl.java
deleted file mode 100644
index f6f0d42..0000000
--- a/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/YangCompositeEncodingImpl.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.te.utils;
-
-import org.onosproject.yms.ych.YangCompositeEncoding;
-import org.onosproject.yms.ych.YangResourceIdentifierType;
-
-/**
- * Represents implementation of YangCompositeEncoding interfaces.
- */
-public class YangCompositeEncodingImpl implements YangCompositeEncoding {
-
- /**
- * Resource identifier for composite encoding.
- */
- private String resourceIdentifier;
-
- /**
- * Resource information for composite encoding.
- */
- private String resourceInformation;
-
- /**
- * Resource identifier type.
- */
- private YangResourceIdentifierType resourceIdentifierType;
-
- /**
- * Creates an instance of YangCompositeEncodingImpl.
- *
- * @param resIdType is URI
- * @param resId is the URI string
- * @param resInfo is the JSON body string
- */
- public YangCompositeEncodingImpl(YangResourceIdentifierType resIdType,
- String resId,
- String resInfo) {
- this.resourceIdentifierType = resIdType;
- this.resourceIdentifier = resId;
- this.resourceInformation = resInfo;
- }
-
- public String getResourceIdentifier() {
- return resourceIdentifier;
- }
-
- public YangResourceIdentifierType getResourceIdentifierType() {
- return resourceIdentifierType;
- }
-
- public String getResourceInformation() {
- return resourceInformation;
- }
-
- public void setResourceIdentifier(String resourceId) {
- resourceIdentifier = resourceId;
- }
-
- public void setResourceInformation(String resourceInfo) {
- resourceInformation = resourceInfo;
- }
-
- public void setResourceIdentifierType(YangResourceIdentifierType idType) {
- resourceIdentifierType = idType;
- }
-}
-
diff --git a/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/package-info.java b/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/package-info.java
deleted file mode 100644
index 72fc8de..0000000
--- a/providers/ietfte/utils/src/main/java/org/onosproject/provider/te/utils/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Public codec classes for ietf provider.
- */
-package org.onosproject.provider.te.utils;
\ No newline at end of file
diff --git a/providers/ietfte/utils/src/test/java/org/onosproject/provider/te/utils/CodecToolsTest.java b/providers/ietfte/utils/src/test/java/org/onosproject/provider/te/utils/CodecToolsTest.java
deleted file mode 100644
index ff9d24c..0000000
--- a/providers/ietfte/utils/src/test/java/org/onosproject/provider/te/utils/CodecToolsTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.te.utils;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Unit test for codec tools.
- */
-public class CodecToolsTest {
- private static final ObjectMapper MAP = new ObjectMapper();
- private final ObjectNode simpleObject = MAP.createObjectNode();
- private String simpleString;
-
-
- @Before
- public void setup() throws Exception {
- simpleObject.put("field1", 1);
- simpleString = "{\n" +
- " \"field1\" : 1\n" +
- "}";
- }
-
- @Test
- public void toJson() throws Exception {
- Assert.assertEquals(simpleObject, CodecTools.toJson(simpleString));
- }
-
- @Test
- public void jsonToString() throws Exception {
- assertEquals(simpleString, CodecTools.jsonToString(simpleObject));
- }
-}
\ No newline at end of file
diff --git a/providers/ietfte/utils/src/test/java/org/onosproject/provider/te/utils/YangCompositeEncodingImplTest.java b/providers/ietfte/utils/src/test/java/org/onosproject/provider/te/utils/YangCompositeEncodingImplTest.java
deleted file mode 100644
index 21c602c..0000000
--- a/providers/ietfte/utils/src/test/java/org/onosproject/provider/te/utils/YangCompositeEncodingImplTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.te.utils;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onosproject.yms.ych.YangCompositeEncoding;
-
-import static org.junit.Assert.assertEquals;
-import static org.onosproject.yms.ych.YangResourceIdentifierType.URI;
-
-/**
- * Unit test for YangCompositeEncodingImpl.
- */
-public class YangCompositeEncodingImplTest {
-
- private YangCompositeEncoding encode;
- private static final String RES_ID = "/restconf/data/ietf";
- private static final String RES_INFO = "tunnel";
- private static final String C_FAILED = "Construct failed: ";
-
- @Before
- public void setup() {
- encode = new YangCompositeEncodingImpl(URI,
- RES_ID,
- RES_INFO);
-
- }
-
- @Test
- public void testConstruction() {
- assertEquals(C_FAILED + "type", URI, encode.getResourceIdentifierType());
- assertEquals(C_FAILED + "id", RES_ID, encode.getResourceIdentifier());
- assertEquals(C_FAILED + "info", RES_INFO, encode.getResourceInformation());
- }
-}
\ No newline at end of file
diff --git a/providers/isis/BUILD b/providers/isis/BUILD
deleted file mode 100644
index e91c3bf..0000000
--- a/providers/isis/BUILD
+++ /dev/null
@@ -1,15 +0,0 @@
-BUNDLES = [
- "//protocols/isis/api:onos-protocols-isis-api",
- "//protocols/isis/ctl:onos-protocols-isis-ctl",
- "//protocols/isis/isisio:onos-protocols-isis-isisio",
- "//providers/isis/cfg:onos-providers-isis-cfg",
- "//providers/isis/topology:onos-providers-isis-topology",
-]
-
-onos_app(
- category = "Provider",
- description = "ONOS ISIS protocol adapters.",
- included_bundles = BUNDLES,
- title = "ISIS Provider",
- url = "http://onosproject.org",
-)
diff --git a/providers/isis/cfg/BUILD b/providers/isis/cfg/BUILD
deleted file mode 100644
index 82b592b..0000000
--- a/providers/isis/cfg/BUILD
+++ /dev/null
@@ -1,7 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + JACKSON + [
- "//protocols/isis/api:onos-protocols-isis-api",
-]
-
-osgi_jar_with_tests(
- deps = COMPILE_DEPS,
-)
diff --git a/providers/isis/cfg/src/main/java/org/onosproject/provider/isis/cfg/impl/IsisAppConfig.java b/providers/isis/cfg/src/main/java/org/onosproject/provider/isis/cfg/impl/IsisAppConfig.java
deleted file mode 100644
index a880bd0..0000000
--- a/providers/isis/cfg/src/main/java/org/onosproject/provider/isis/cfg/impl/IsisAppConfig.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.isis.cfg.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.isis.controller.IsisController;
-import org.onosproject.net.config.Config;
-
-/**
- * Configuration object for ISIS.
- */
-public class IsisAppConfig extends Config<ApplicationId> {
- public static final String METHOD = "method";
- public static final String PROCESSES = "processes";
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- IsisController isisController;
-
- /**
- * Returns the configuration method, add, delete etc.
- *
- * @return the configuration method, add, delete etc
- */
- public String method() {
- return get(METHOD, null);
- }
-
- /**
- * Returns the configured processes.
- *
- * @return the configured processes
- */
- public JsonNode processes() {
-
- JsonNode jsonNodes = object.get(PROCESSES);
-
- return jsonNodes;
- }
-
- @Override
- public boolean isValid() {
- this.isisController = DefaultServiceDirectory.getService(IsisController.class);
-
- return true;
- }
-}
\ No newline at end of file
diff --git a/providers/isis/cfg/src/main/java/org/onosproject/provider/isis/cfg/impl/IsisCfgProvider.java b/providers/isis/cfg/src/main/java/org/onosproject/provider/isis/cfg/impl/IsisCfgProvider.java
deleted file mode 100644
index f25d00d..0000000
--- a/providers/isis/cfg/src/main/java/org/onosproject/provider/isis/cfg/impl/IsisCfgProvider.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.isis.cfg.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.isis.controller.IsisController;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigRegistry;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.config.basics.SubjectFactories;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * ISIS config provider to validate and populate the configuration.
- */
-@Component(immediate = true, service = IsisCfgProvider.class)
-public class IsisCfgProvider extends AbstractProvider {
-
- private static final String PROVIDER_ID = "org.onosproject.provider.isis.cfg";
- private static final Logger log = getLogger(IsisCfgProvider.class);
- private final ConfigFactory configFactory =
- new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, IsisAppConfig.class, "isisapp") {
- @Override
- public IsisAppConfig createConfig() {
- return new IsisAppConfig();
- }
- };
- private final NetworkConfigListener configListener = new InternalConfigListener();
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected IsisController isisController;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigRegistry configRegistry;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigService configService;
- private ApplicationId appId;
-
- /**
- * Creates an ISIS config provider.
- */
- public IsisCfgProvider() {
- super(new ProviderId("isis", PROVIDER_ID));
- }
-
- @Activate
- public void activate() {
- log.debug("Activate...!!!");
- appId = coreService.registerApplication(PROVIDER_ID);
- configService.addListener(configListener);
- configRegistry.registerConfigFactory(configFactory);
- log.debug("ISIS cfg service got started");
- }
-
- @Deactivate
- public void deactivate() {
- log.debug("Deactivate...!!!");
- configRegistry.unregisterConfigFactory(configFactory);
- configService.removeListener(configListener);
- }
-
- /**
- * Pushes the configuration changes to ISIS controller.
- */
- private void updateConfig() {
- IsisAppConfig isisAppConfig = configRegistry.getConfig(appId, IsisAppConfig.class);
- log.debug("IsisAppConfig::config processes::" + isisAppConfig.processes());
- log.debug("IsisAppConfig::prop 1::" + isisAppConfig.method());
- if ("ADD".equalsIgnoreCase(isisAppConfig.method())) {
- JsonNode jsonNode = isisAppConfig.processes();
- isisController.updateConfig(jsonNode);
- }
- }
-
- /**
- * Isis config listener to populate the configuration.
- */
- private class InternalConfigListener implements NetworkConfigListener {
-
- @Override
- public void event(NetworkConfigEvent event) {
- log.debug("config event is getting called...!!!");
- if (!event.configClass().equals(IsisAppConfig.class)) {
- return;
- }
-
- switch (event.type()) {
- case CONFIG_ADDED:
- updateConfig();
- break;
- case CONFIG_UPDATED:
- updateConfig();
- break;
- case CONFIG_REMOVED:
- break;
- default:
- break;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/providers/isis/cfg/src/main/java/org/onosproject/provider/isis/cfg/impl/package-info.java b/providers/isis/cfg/src/main/java/org/onosproject/provider/isis/cfg/impl/package-info.java
deleted file mode 100644
index c7b47ee..0000000
--- a/providers/isis/cfg/src/main/java/org/onosproject/provider/isis/cfg/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provider that uses network configuration capability as a means of infrastructure configuration.
- */
-package org.onosproject.provider.isis.cfg.impl;
diff --git a/providers/isis/cli/src/main/java/org/onosproject/isis/cli/ApplicationIsisCommand.java b/providers/isis/cli/src/main/java/org/onosproject/isis/cli/ApplicationIsisCommand.java
deleted file mode 100644
index f15555c..0000000
--- a/providers/isis/cli/src/main/java/org/onosproject/isis/cli/ApplicationIsisCommand.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.isis.cli;
-
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Deactivate;
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.onlab.packet.MacAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.isis.controller.IsisController;
-import org.onosproject.isis.controller.IsisInterface;
-import org.onosproject.isis.controller.IsisLsdb;
-import org.onosproject.isis.controller.IsisNeighbor;
-import org.onosproject.isis.controller.IsisNetworkType;
-import org.onosproject.isis.controller.IsisProcess;
-import org.onosproject.isis.controller.IsisRouterType;
-import org.onosproject.isis.controller.LspWrapper;
-import org.onosproject.isis.io.isispacket.pdu.LsPdu;
-import org.onosproject.isis.io.util.IsisConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.NetworkInterface;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Lists ISIS neighbors, database and interfaces details.
- */
-@Service
-@Command(scope = "onos", name = "isis", description = "lists database, neighbors and interfaces")
-public class ApplicationIsisCommand extends AbstractShellCommand {
- private static final Logger log = LoggerFactory.getLogger(ApplicationIsisCommand.class);
- private static final String INTERFACE = "interface";
- private static final String DATABASE = "database";
- private static final String NEIGHBOR = "neighbor";
- private static final String P2P = "P2P";
- private static final String LAN = "LAN";
- private static final String L1 = "L1";
- private static final String L2 = "L2";
- private static final String L1L2 = "L1L2";
- protected IsisController isisController;
- @Argument(index = 0, name = "name",
- description = "interface|database|neighbor",
- required = true, multiValued = false)
- String name = null;
- @Argument(index = 1, name = "processId",
- description = "processId", required = true, multiValued = false)
- String processId = null;
-
- @Activate
- public void activate() {
- log.debug("Activated...!!!");
- }
-
- @Deactivate
- public void deactivate() {
- log.debug("Deactivated...!!!");
- }
-
- @Override
- protected void doExecute() {
- switch (name) {
- case INTERFACE:
- displayIsisInterfaces();
- break;
- case NEIGHBOR:
- displayIsisNeighbors();
- break;
- case DATABASE:
- displayIsisDatabase();
- break;
- default:
- log.debug("Unknown command...!!");
- break;
- }
- }
-
- /**
- * Displays ISIS neighbor details.
- */
- private void displayIsisNeighbors() {
- String interfaceName = "";
- String circuitType = "";
- boolean invalidProcess = true;
- try {
- this.isisController = get(IsisController.class);
- List<IsisProcess> listOfProcess = isisController.allConfiguredProcesses();
- if (listOfProcess == null) {
- return;
- }
- displayNeighborHeader();
- Iterator<IsisProcess> itrProcess = listOfProcess.iterator();
- while (itrProcess.hasNext()) {
- IsisProcess isisProcess = itrProcess.next();
- if (processId != null && processId.trim().equals(isisProcess.processId())) {
- invalidProcess = false;
- List<IsisInterface> interfaceList = isisProcess.isisInterfaceList();
- Iterator<IsisInterface> itrInterface = interfaceList.iterator();
- while (itrInterface.hasNext()) {
- IsisInterface isisInterface = itrInterface.next();
- interfaceName = NetworkInterface.getByIndex(isisInterface.interfaceIndex()).getName();
- Set<MacAddress> getNeighborList = isisInterface.neighbors();
- for (MacAddress mac : getNeighborList) {
- IsisNeighbor neighbor = isisInterface.lookup(mac);
- switch (neighbor.routerType()) {
- case L1:
- circuitType = L1;
- break;
- case L2:
- circuitType = L2;
- break;
- case L1L2:
- circuitType = L1L2;
- break;
- default:
- log.debug("Unknown circuit type...!!");
- break;
- }
- print("%-20s%-20s%-20s%-20s%-20s%-20s\n", neighbor.neighborSystemId(),
- neighbor.neighborMacAddress().toString(), interfaceName,
- circuitType, neighbor.interfaceState(), neighbor.holdingTime());
- }
- }
- }
- }
- if (invalidProcess) {
- print("%s\n", "Process " + processId + " not exist...!!!");
- }
- } catch (Exception e) {
- log.debug("Error occurred while displaying ISIS neighbor: {}", e.getMessage());
- }
- }
-
- /**
- * Displays ISIS database details.
- */
- private void displayIsisDatabase() {
- try {
- this.isisController = get(IsisController.class);
- List<IsisProcess> listOfProcess = isisController.allConfiguredProcesses();
- Iterator<IsisProcess> itrProcess = listOfProcess.iterator();
- boolean invalidProcess = true;
- while (itrProcess.hasNext()) {
- IsisProcess isisProcess = itrProcess.next();
- if (processId != null && processId.trim().equals(isisProcess.processId())) {
- invalidProcess = false;
- List<IsisInterface> interfaceList = isisProcess.isisInterfaceList();
- Iterator<IsisInterface> itrInterface = interfaceList.iterator();
- if (itrInterface.hasNext()) {
- IsisInterface isisInterface = itrInterface.next();
- IsisLsdb isisLsdb = isisInterface.isisLsdb();
- if (isisLsdb != null) {
- Map<String, LspWrapper> lsWrapperListL1 = isisLsdb.getL1Db();
- Map<String, LspWrapper> lsWrapperListL2 = isisLsdb.getL2Db();
- Set<String> l1Wrapper = lsWrapperListL1.keySet();
- Set<String> l2Wrapper = lsWrapperListL2.keySet();
- if (l1Wrapper.size() > 0) {
- print("IS-IS Level-1 link-state database:");
- displayDatabaseHeader();
- for (String string : l1Wrapper) {
- LspWrapper lspWrapper = lsWrapperListL1.get(string);
- LsPdu lsPdu = (LsPdu) lspWrapper.lsPdu();
- print("%-25s%-25s%-25s%-25s%-25s\n", lsPdu.lspId(), lsPdu.pduLength(),
- lsPdu.sequenceNumber(),
- Integer.toHexString(lsPdu.checkSum()), lspWrapper.remainingLifetime());
- }
- }
- if (l2Wrapper.size() > 0) {
- print("IS-IS Level-2 link-state database:");
- displayDatabaseHeader();
- for (String string2 : l2Wrapper) {
- LspWrapper lspWrapper2 = lsWrapperListL2.get(string2);
- LsPdu lsPdu2 = (LsPdu) lspWrapper2.lsPdu();
- print("%-25s%-25s%-25s%-25s%-25s\n", lsPdu2.lspId(), lsPdu2.pduLength(),
- lsPdu2.sequenceNumber(), Integer.toHexString(lsPdu2.checkSum()),
- IsisConstants.LSPMAXAGE - lspWrapper2.currentAge());
- }
- }
- break;
- }
- }
- }
- }
- if (invalidProcess) {
- print("%s\n", "Process " + processId + " not exist...!!!");
- }
- } catch (Exception e) {
- log.debug("Error occurred while displaying ISIS database: {}", e.getMessage());
- }
- }
-
- /**
- * Displays ISIS interfaces.
- */
- private void displayIsisInterfaces() {
- String interfaceName = "";
- String networkType = "";
- String circuitType = "";
- boolean invalidProcess = true;
- try {
- this.isisController = get(IsisController.class);
- List<IsisProcess> listOfProcess = isisController.allConfiguredProcesses();
- if (listOfProcess == null) {
- return;
- }
- displayInterfaceHeader();
- Iterator<IsisProcess> itrProcess = listOfProcess.iterator();
- while (itrProcess.hasNext()) {
- IsisProcess isisProcess = itrProcess.next();
- if (processId != null && processId.trim().equals(isisProcess.processId())) {
- invalidProcess = false;
- List<IsisInterface> interfaceList = isisProcess.isisInterfaceList();
- for (IsisInterface isisInterface : interfaceList) {
-
- if (isisInterface.networkType() == IsisNetworkType.P2P) {
- networkType = P2P;
- } else {
- networkType = LAN;
- }
-
- switch (IsisRouterType.get(isisInterface.reservedPacketCircuitType())) {
- case L1:
- circuitType = L1;
- break;
- case L2:
- circuitType = L2;
- break;
- case L1L2:
- circuitType = L1L2;
- break;
- default:
- log.debug("Unknown circuit type...!!");
- break;
- }
- interfaceName = NetworkInterface.getByIndex(isisInterface.interfaceIndex()).getName();
- print("%-20s%-20s%-20s%-20s\n", interfaceName, isisInterface.areaAddress(),
- networkType, circuitType);
- }
- }
- }
- if (invalidProcess) {
- print("%s\n", "Process " + processId + " not exist...!!!");
- }
- } catch (Exception e) {
- log.debug("Error occurred while displaying ISIS interface: {}", e.getMessage());
- }
- }
-
- /**
- * Displays ISIS interface header.
- */
- private void displayInterfaceHeader() {
- print("%-20s%-20s%-20s%-20s\n", "Interface", "Area Id", "TYPE", "Level");
- }
-
- /**
- * Displays ISIS neighbor header.
- */
- private void displayNeighborHeader() {
- print("%-20s%-20s%-20s%-20s%-20s%-20s\n", "System Id", "Mac Id", "Interface",
- "Level", "State", "Holding Time");
- }
-
- /**
- * Displays ISIS database header.
- */
- private void displayDatabaseHeader() {
- print("%-25s%-25s%-25s%-25s%-25s\n", "LSP ID ", "PduLen", "SeqNumber", "Checksum",
- "Remaining Life Time");
- }
-}
diff --git a/providers/isis/cli/src/main/java/org/onosproject/isis/cli/package-info.java b/providers/isis/cli/src/main/java/org/onosproject/isis/cli/package-info.java
deleted file mode 100644
index b75785b..0000000
--- a/providers/isis/cli/src/main/java/org/onosproject/isis/cli/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * ISIS cli implementation.
- */
-package org.onosproject.isis.cli;
diff --git a/providers/isis/topology/BUILD b/providers/isis/topology/BUILD
deleted file mode 100644
index 1e3324d..0000000
--- a/providers/isis/topology/BUILD
+++ /dev/null
@@ -1,9 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + JACKSON + [
- "//protocols/isis/api:onos-protocols-isis-api",
- "//protocols/isis/ctl:onos-protocols-isis-ctl",
-]
-
-osgi_jar_with_tests(
- test_deps = TEST_ADAPTERS,
- deps = COMPILE_DEPS,
-)
diff --git a/providers/isis/topology/src/main/java/org/onosproject/provider/isis/topology/impl/IsisTopologyProvider.java b/providers/isis/topology/src/main/java/org/onosproject/provider/isis/topology/impl/IsisTopologyProvider.java
deleted file mode 100644
index a8d3fc7..0000000
--- a/providers/isis/topology/src/main/java/org/onosproject/provider/isis/topology/impl/IsisTopologyProvider.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.isis.topology.impl;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onlab.packet.ChassisId;
-import org.onlab.util.Bandwidth;
-import org.onosproject.isis.controller.IsisController;
-import org.onosproject.isis.controller.topology.IsisLink;
-import org.onosproject.isis.controller.topology.IsisLinkListener;
-import org.onosproject.isis.controller.topology.IsisLinkTed;
-import org.onosproject.isis.controller.topology.IsisRouter;
-import org.onosproject.isis.controller.topology.IsisRouterId;
-import org.onosproject.isis.controller.topology.IsisRouterListener;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.config.basics.BandwidthCapacity;
-import org.onosproject.net.device.DefaultDeviceDescription;
-import org.onosproject.net.device.DefaultPortDescription;
-import org.onosproject.net.device.DeviceDescription;
-import org.onosproject.net.device.DeviceProvider;
-import org.onosproject.net.device.DeviceProviderRegistry;
-import org.onosproject.net.device.DeviceProviderService;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.link.DefaultLinkDescription;
-import org.onosproject.net.link.LinkDescription;
-import org.onosproject.net.link.LinkProvider;
-import org.onosproject.net.link.LinkProviderRegistry;
-import org.onosproject.net.link.LinkProviderService;
-import org.onosproject.net.link.LinkService;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.slf4j.Logger;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provider which advertises device descriptions to the core.
- */
-@Component(immediate = true)
-public class IsisTopologyProvider extends AbstractProvider implements DeviceProvider, LinkProvider {
-
- public static final long PSEUDO_PORT = 0xffffffff;
- public static final String ADMINISTRATIVEGROUP = "administrativeGroup";
- public static final String TE_METRIC = "teMetric";
- public static final String MAXRESERVABLEBANDWIDTH = "maxReservableBandwidth";
- public static final String ROUTERID = "routerId";
- public static final String NEIGHBORID = "neighborId";
- private static final Logger log = getLogger(IsisTopologyProvider.class);
- // Default values for tunable parameters
- private static final String UNKNOWN = "unknown";
- final InternalTopologyProvider listener = new InternalTopologyProvider();
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceProviderRegistry deviceProviderRegistry;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LinkProviderRegistry linkProviderRegistry;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigService networkConfigService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LinkService linkService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected IsisController controller;
- //This Interface that defines how this provider can interact with the core.
- private LinkProviderService linkProviderService;
- // The interface that defines how this Provider can interact with the core
- private DeviceProviderService deviceProviderService;
- private HashMap<DeviceId, List<PortDescription>> portMap = new HashMap<>();
-
- /**
- * Creates an ISIS device provider.
- */
- public IsisTopologyProvider() {
- super(new ProviderId("l3", "org.onosproject.provider.isis"));
- }
-
- @Activate
- public void activate() {
- deviceProviderService = deviceProviderRegistry.register(this);
- linkProviderService = linkProviderRegistry.register(this);
- controller.addRouterListener(listener);
- controller.addLinkListener(listener);
- log.debug("IsisDeviceProvider::activate...!!!!");
- }
-
- @Deactivate
- public void deactivate() {
- log.debug("IsisDeviceProvider::deactivate...!!!!");
- deviceProviderRegistry.unregister(this);
- deviceProviderService = null;
- linkProviderRegistry.unregister(this);
- linkProviderService = null;
- controller.removeRouterListener(listener);
- controller.removeLinkListener(listener);
- }
-
- @Override
- public void triggerProbe(DeviceId deviceId) {
- log.debug("IsisDeviceProvider::triggerProbe...!!!!");
- }
-
- @Override
- public void roleChanged(DeviceId deviceId, MastershipRole newRole) {
- log.debug("IsisDeviceProvider::roleChanged...!!!!");
- }
-
- @Override
- public boolean isReachable(DeviceId deviceId) {
- log.debug("IsisDeviceProvider::isReachable...!!!!");
- return true;
- }
-
- @Override
- public void changePortState(DeviceId deviceId, PortNumber portNumber, boolean enable) {
- log.debug("IsisDeviceProvider::changePortState...!!!!");
- }
-
- /**
- * Builds link description.
- *
- * @param isisLink ISIS link instance
- * @return link description
- */
- private LinkDescription buildLinkDes(IsisLink isisLink) {
- checkNotNull(isisLink);
- long srcAddress = 0;
- long dstAddress = 0;
- boolean localPseduo = false;
- boolean remotePseduo = false;
- String localSystemId = isisLink.localSystemId();
- String remoteSystemId = isisLink.remoteSystemId();
- //Changing of port numbers
- if (isisLink.interfaceIp() != null) {
- //srcAddress = isisLink.interfaceIp().toInt();
- srcAddress = (long) Long.parseUnsignedLong(Integer.toBinaryString(isisLink.interfaceIp().toInt()), 2);
- }
- if (isisLink.neighborIp() != null) {
- //dstAddress = isisLink.neighborIp().toInt();
- dstAddress = (long) Long.parseUnsignedLong(Integer.toBinaryString(isisLink.neighborIp().toInt()), 2);
- }
- DeviceId srcId = DeviceId.deviceId(IsisRouterId.uri(localSystemId));
- DeviceId dstId = DeviceId.deviceId(IsisRouterId.uri(remoteSystemId));
- if (checkIsDis(isisLink.localSystemId())) {
- localPseduo = true;
- } else if (checkIsDis(isisLink.remoteSystemId())) {
- remotePseduo = true;
- } else {
- log.debug("IsisDeviceProvider::buildLinkDes : unknown type.!");
- }
-
- if (localPseduo && srcAddress == 0) {
- srcAddress = PSEUDO_PORT;
- } else if (remotePseduo && dstAddress == 0) {
- dstAddress = PSEUDO_PORT;
- }
-
- ConnectPoint src = new ConnectPoint(srcId, PortNumber.portNumber(srcAddress));
- ConnectPoint dst = new ConnectPoint(dstId, PortNumber.portNumber(dstAddress));
- DefaultAnnotations.Builder annotationBuilder = DefaultAnnotations.builder();
-
- annotationBuilder = buildAnnotations(annotationBuilder, isisLink);
-
- return new DefaultLinkDescription(src, dst, Link.Type.DIRECT, false, annotationBuilder.build());
- }
-
- /**
- * Return the DIS value from the systemId.
- *
- * @param systemId system Id.
- * @return return true if DIS else false
- */
- public static boolean checkIsDis(String systemId) {
- StringTokenizer stringTokenizer = new StringTokenizer(systemId, "." + "-");
- int count = 0;
- while (stringTokenizer.hasMoreTokens()) {
- String str = stringTokenizer.nextToken();
- if (count == 3) {
- int x = Integer.parseInt(str);
- if (x > 0) {
- return true;
- }
- }
- count++;
- }
- return false;
- }
-
- /**
- * Builds port description.
- *
- * @param deviceId device ID for the port
- * @param portNumber port number of the link
- * @return list of port description
- */
- private List<PortDescription> buildPortDescriptions(DeviceId deviceId,
- PortNumber portNumber) {
- List<PortDescription> portList;
- if (portMap.containsKey(deviceId)) {
- portList = portMap.get(deviceId);
- } else {
- portList = new ArrayList<>();
- }
- if (portNumber != null) {
- PortDescription portDescriptions = DefaultPortDescription.builder()
- .withPortNumber(portNumber).isEnabled(true).build();
- portList.add(portDescriptions);
- }
- portMap.put(deviceId, portList);
-
- return portList;
- }
-
- /**
- * Builds the annotation details.
- *
- * @param annotationBuilder default annotation builder instance
- * @param isisLink ISIS link instance
- * @return annotation builder instance
- */
- private DefaultAnnotations.Builder buildAnnotations(DefaultAnnotations.Builder annotationBuilder,
- IsisLink isisLink) {
- int administrativeGroup = 0;
- long teMetric = 0;
- Bandwidth maxReservableBandwidth = Bandwidth.bps(0);
- String routerId = null;
- String neighborId = null;
-
- //TE Info
- IsisLinkTed isisLinkTed = isisLink.linkTed();
- log.info("Ted Information: {}", isisLinkTed.toString());
- administrativeGroup = isisLinkTed.administrativeGroup();
- teMetric = isisLinkTed.teDefaultMetric();
- maxReservableBandwidth = isisLinkTed.maximumReservableLinkBandwidth();
- routerId = isisLink.localSystemId();
- neighborId = isisLink.remoteSystemId();
- annotationBuilder.set(ADMINISTRATIVEGROUP, String.valueOf(administrativeGroup));
- annotationBuilder.set(TE_METRIC, String.valueOf(teMetric));
- annotationBuilder.set(MAXRESERVABLEBANDWIDTH, String.valueOf(maxReservableBandwidth));
- annotationBuilder.set(ROUTERID, String.valueOf(routerId));
- annotationBuilder.set(NEIGHBORID, String.valueOf(neighborId));
- return annotationBuilder;
- }
-
- /**
- * Internal device provider implementation.
- */
- private class InternalTopologyProvider implements IsisRouterListener, IsisLinkListener {
-
- @Override
- public void routerAdded(IsisRouter isisRouter) {
- String systemId = isisRouter.systemId();
- log.info("Added device {}", systemId);
- DeviceId deviceId = DeviceId.deviceId(IsisRouterId.uri(systemId));
- Device.Type deviceType = Device.Type.ROUTER;
- //If our routerType is Dr or Bdr type is PSEUDO
- if (isisRouter.isDis()) {
- deviceType = Device.Type.ROUTER;
- } else {
- deviceType = Device.Type.VIRTUAL;
- }
- ChassisId cId = new ChassisId();
- DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
- newBuilder.set(AnnotationKeys.TYPE, "L3");
- newBuilder.set("RouterId", systemId);
- DeviceDescription description =
- new DefaultDeviceDescription(IsisRouterId.uri(systemId), deviceType, UNKNOWN, UNKNOWN, UNKNOWN,
- UNKNOWN, cId, newBuilder.build());
- deviceProviderService.deviceConnected(deviceId, description);
- System.out.println("Device added: " + systemId);
- }
-
- @Override
- public void routerRemoved(IsisRouter isisRouter) {
- String systemId = isisRouter.systemId();
- log.info("Delete device {}", systemId);
- DeviceId deviceId = DeviceId.deviceId(IsisRouterId.uri(systemId));
- if (deviceProviderService == null) {
- return;
- }
- deviceProviderService.deviceDisconnected(deviceId);
- log.info("delete device {}", systemId);
- }
-
- @Override
- public void addLink(IsisLink isisLink) {
- log.debug("Addlink {}", isisLink.localSystemId());
-
- LinkDescription linkDes = buildLinkDes(isisLink);
- //Updating ports of the link
- //If already link exists, return
- if (linkService.getLink(linkDes.src(), linkDes.dst()) != null || linkProviderService == null) {
- return;
- }
- ConnectPoint destconnectPoint = linkDes.dst();
- PortNumber destport = destconnectPoint.port();
- if (destport.toLong() != 0) {
- deviceProviderService.updatePorts(linkDes.src().deviceId(),
- buildPortDescriptions(linkDes.src().deviceId(),
- linkDes.src().port()));
- deviceProviderService.updatePorts(linkDes.dst().deviceId(),
- buildPortDescriptions(linkDes.dst().deviceId(),
- linkDes.dst().port()));
- registerBandwidth(linkDes, isisLink);
- linkProviderService.linkDetected(linkDes);
- System.out.println("link desc " + linkDes.toString());
- }
- }
-
- @Override
- public void deleteLink(IsisLink isisLink) {
- log.debug("Delete link {}", isisLink.localSystemId());
- if (linkProviderService == null) {
- return;
- }
- LinkDescription linkDes = buildLinkDes(isisLink);
- linkProviderService.linkVanished(linkDes);
- }
-
- /**
- * Registers the bandwidth for source and destination points.
- *
- * @param linkDes link description instance
- * @param isisLink ISIS link instance
- */
- private void registerBandwidth(LinkDescription linkDes, IsisLink isisLink) {
- if (isisLink == null) {
- log.error("Could not able to register bandwidth ");
- return;
- }
- IsisLinkTed isisLinkTed = isisLink.linkTed();
- Bandwidth maxReservableBw = isisLinkTed.maximumReservableLinkBandwidth();
- if (maxReservableBw != null) {
- if (maxReservableBw.compareTo(Bandwidth.bps(0)) == 0) {
- return;
- }
- //Configure bandwidth for src and dst port
- BandwidthCapacity config = networkConfigService.addConfig(linkDes.src(), BandwidthCapacity.class);
- config.capacity(maxReservableBw).apply();
-
- config = networkConfigService.addConfig(linkDes.dst(), BandwidthCapacity.class);
- config.capacity(maxReservableBw).apply();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/providers/isis/topology/src/main/java/org/onosproject/provider/isis/topology/impl/package-info.java b/providers/isis/topology/src/main/java/org/onosproject/provider/isis/topology/impl/package-info.java
deleted file mode 100644
index 24c17eb..0000000
--- a/providers/isis/topology/src/main/java/org/onosproject/provider/isis/topology/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provider that uses ISIS request as a means of infrastructure device discovery.
- */
-package org.onosproject.provider.isis.topology.impl;
diff --git a/providers/isis/topology/src/test/java/org/onosproject/provider/isis/topology/impl/IsisTopologyProviderTest.java b/providers/isis/topology/src/test/java/org/onosproject/provider/isis/topology/impl/IsisTopologyProviderTest.java
deleted file mode 100644
index 9a5b8c1..0000000
--- a/providers/isis/topology/src/test/java/org/onosproject/provider/isis/topology/impl/IsisTopologyProviderTest.java
+++ /dev/null
@@ -1,478 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-
-package org.onosproject.provider.isis.topology.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onlab.util.Bandwidth;
-import org.onosproject.isis.controller.IsisController;
-import org.onosproject.isis.controller.IsisProcess;
-import org.onosproject.isis.controller.impl.topology.DefaultIsisLink;
-import org.onosproject.isis.controller.impl.topology.DefaultIsisLinkTed;
-import org.onosproject.isis.controller.impl.topology.DefaultIsisRouter;
-import org.onosproject.isis.controller.topology.IsisLink;
-import org.onosproject.isis.controller.topology.IsisLinkListener;
-import org.onosproject.isis.controller.topology.IsisLinkTed;
-import org.onosproject.isis.controller.topology.IsisRouter;
-import org.onosproject.isis.controller.topology.IsisRouterListener;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.config.Config;
-import org.onosproject.net.config.ConfigApplyDelegate;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigRegistryAdapter;
-import org.onosproject.net.config.basics.BandwidthCapacity;
-import org.onosproject.net.device.DeviceDescription;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceProvider;
-import org.onosproject.net.device.DeviceProviderRegistry;
-import org.onosproject.net.device.DeviceProviderService;
-import org.onosproject.net.device.DeviceServiceAdapter;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.device.PortStatistics;
-import org.onosproject.net.link.LinkDescription;
-import org.onosproject.net.link.LinkListener;
-import org.onosproject.net.link.LinkProvider;
-import org.onosproject.net.link.LinkProviderRegistry;
-import org.onosproject.net.link.LinkProviderService;
-import org.onosproject.net.link.LinkServiceAdapter;
-import org.onosproject.net.provider.ProviderId;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArraySet;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Test cases for ISIS topology provider.
- */
-public class IsisTopologyProviderTest {
-
- private final IsisTopologyProvider provider = new IsisTopologyProvider();
- private final TestDeviceRegistry nodeRegistry = new TestDeviceRegistry();
- private final TestLinkRegistry linkRegistry = new TestLinkRegistry();
- private final TestController controller = new TestController();
- private final TestLinkService linkService = new TestLinkService();
- private MockNetConfigRegistryAdapter networkConfigService = new MockNetConfigRegistryAdapter();
-
- @Before
- public void setUp() throws Exception {
- provider.deviceProviderRegistry = nodeRegistry;
- provider.linkProviderRegistry = linkRegistry;
- provider.networkConfigService = networkConfigService;
- provider.controller = controller;
- provider.linkService = linkService;
- provider.activate();
- assertNotNull("provider should be registered", nodeRegistry.provider);
- assertNotNull("listener should be registered", controller.nodeListener);
- }
-
- @After
- public void tearDown() throws Exception {
- provider.deactivate();
- provider.controller = null;
- provider.deviceProviderRegistry = null;
- provider.networkConfigService = null;
- }
-
- @Test
- public void triggerProbe() {
- DeviceId deviceId = DeviceId.deviceId("2929.2929.2929.00-00");
- provider.triggerProbe(deviceId);
- }
-
- @Test
- public void roleChanged() {
- DeviceId deviceId = DeviceId.deviceId("1111.1111.1111.00-00");
- provider.roleChanged(deviceId, MastershipRole.MASTER);
- }
-
- @Test
- public void changePortState() {
- DeviceId deviceId = DeviceId.deviceId("2222.2222.2222.00-82");
- provider.changePortState(deviceId, PortNumber.portNumber(168430087), false);
- }
-
- @Test
- public void isReachable() {
- DeviceId deviceId = DeviceId.deviceId("1010.1010.1111.00-22");
- provider.isReachable(deviceId);
- }
-
-
- /* Validate node is added to the device validating URI and should get updated properly */
- @Test
- public void isisTopologyProviderTestAddDevice1() {
- int deviceAddCount = 0;
- IsisRouter isisRouter = new DefaultIsisRouter();
- isisRouter.setSystemId("2929.2929.2929.00");
- isisRouter.setNeighborRouterId(Ip4Address.valueOf("10.10.10.1"));
- isisRouter.setInterfaceId(Ip4Address.valueOf("10.10.10.2"));
- isisRouter.setDis(false);
-
- for (IsisRouterListener l : controller.nodeListener) {
- l.routerAdded(isisRouter);
- deviceAddCount = nodeRegistry.connected.size();
- assertTrue(deviceAddCount == 1);
- l.routerRemoved(isisRouter);
- deviceAddCount = nodeRegistry.connected.size();
- assertTrue(deviceAddCount == 0);
- }
- }
-
- @Test
- public void isisTopologyProviderTestAddDevice2() {
- int deviceAddCount = 0;
- IsisRouter isisRouter = new DefaultIsisRouter();
- isisRouter.setSystemId("7777.7777.7777.00");
- isisRouter.setNeighborRouterId(Ip4Address.valueOf("10.10.10.1"));
- isisRouter.setInterfaceId(Ip4Address.valueOf("10.10.10.7"));
- isisRouter.setDis(false);
- IsisRouter isisRouter1 = new DefaultIsisRouter();
- isisRouter1.setSystemId("1111.1111.1111.00");
- isisRouter1.setNeighborRouterId(Ip4Address.valueOf("10.10.10.7"));
- isisRouter1.setInterfaceId(Ip4Address.valueOf("10.10.10.1"));
- isisRouter1.setDis(true);
- for (IsisRouterListener l : controller.nodeListener) {
- l.routerAdded(isisRouter);
- deviceAddCount = nodeRegistry.connected.size();
- assertTrue(deviceAddCount == 1);
- l.routerAdded(isisRouter1);
- deviceAddCount = nodeRegistry.connected.size();
- assertTrue(deviceAddCount == 2);
- l.routerRemoved(isisRouter);
- deviceAddCount = nodeRegistry.connected.size();
- assertTrue(deviceAddCount == 1);
- }
- }
-
- @Test
- public void isisTopologyProviderTestAddLink() {
- int deviceAddCount = 0;
- IsisRouter isisRouter = new DefaultIsisRouter();
- isisRouter.setSystemId("7777.7777.7777.00");
- isisRouter.setNeighborRouterId(Ip4Address.valueOf("10.10.10.1"));
- isisRouter.setInterfaceId(Ip4Address.valueOf("10.10.10.7"));
- isisRouter.setDis(false);
- IsisRouter isisRouter1 = new DefaultIsisRouter();
- isisRouter1.setSystemId("1111.1111.1111.00");
- isisRouter1.setNeighborRouterId(Ip4Address.valueOf("10.10.10.7"));
- isisRouter1.setInterfaceId(Ip4Address.valueOf("10.10.10.1"));
- isisRouter1.setDis(true);
- IsisLink isisLink = new DefaultIsisLink();
- isisLink.setRemoteSystemId("7777.7777.7777.00");
- isisLink.setLocalSystemId("1111.1111.1111.00");
- isisLink.setInterfaceIp(Ip4Address.valueOf("10.10.10.1"));
- isisLink.setNeighborIp(Ip4Address.valueOf("10.10.10.7"));
- IsisLinkTed isisLinkTed = new DefaultIsisLinkTed();
- isisLinkTed.setTeDefaultMetric(10);
- isisLinkTed.setAdministrativeGroup(5);
- isisLinkTed.setIpv4InterfaceAddress(Ip4Address.valueOf("10.10.10.1"));
- isisLinkTed.setIpv4NeighborAddress(Ip4Address.valueOf("10.10.10.7"));
- isisLinkTed.setMaximumLinkBandwidth(Bandwidth.bps(0));
- isisLinkTed.setMaximumReservableLinkBandwidth(Bandwidth.bps(1.0));
- List<Bandwidth> unresList = new ArrayList<>();
- unresList.add(Bandwidth.bps(0.0));
- unresList.add(Bandwidth.bps(1.0));
- unresList.add(Bandwidth.bps(2.0));
- unresList.add(Bandwidth.bps(3.0));
- isisLinkTed.setUnreservedBandwidth(unresList);
- isisLink.setLinkTed(isisLinkTed);
- for (IsisRouterListener l : controller.nodeListener) {
- l.routerAdded(isisRouter);
- deviceAddCount = nodeRegistry.connected.size();
- assertTrue(deviceAddCount == 1);
- l.routerAdded(isisRouter1);
- deviceAddCount = nodeRegistry.connected.size();
- assertTrue(deviceAddCount == 2);
- }
- for (IsisLinkListener l : controller.linkListener) {
- l.addLink(isisLink);
- l.deleteLink(isisLink);
-
- }
- }
-
-
- /* Class implement device test registry */
- private class TestDeviceRegistry implements DeviceProviderRegistry {
- DeviceProvider provider;
-
- Set<DeviceId> connected = new HashSet<>();
-
- @Override
- public DeviceProviderService register(DeviceProvider provider) {
- this.provider = provider;
- return new TestProviderService();
- }
-
- @Override
- public void unregister(DeviceProvider provider) {
- }
-
- @Override
- public Set<ProviderId> getProviders() {
- return null;
- }
-
- private class TestProviderService implements DeviceProviderService {
-
- @Override
- public DeviceProvider provider() {
- return null;
- }
-
- @Override
- public void deviceConnected(DeviceId deviceId, DeviceDescription deviceDescription) {
-
- connected.add(deviceId);
-
- }
-
- @Override
- public void deviceDisconnected(DeviceId deviceId) {
-
- connected.remove(deviceId);
- }
-
-
- @Override
- public void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void portStatusChanged(DeviceId deviceId, PortDescription portDescription) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void receivedRoleReply(DeviceId deviceId, MastershipRole requested, MastershipRole response) {
- // TODO Auto-generated method stub
-
- }
-
-
- @Override
- public void updatePortStatistics(DeviceId deviceId, Collection<PortStatistics> portStatistics) {
- // TODO Auto-generated method stub
-
- }
- }
- }
-
-
-
- private class TestDeviceService extends DeviceServiceAdapter {
- private DeviceListener listener;
-
- @Override
- public void addListener(DeviceListener listener) {
- this.listener = listener;
- }
-
- @Override
- public Iterable<Device> getDevices() {
- return Collections.emptyList();
- }
- }
-
- private class TestLinkService extends LinkServiceAdapter {
- private LinkListener listener;
-
- @Override
- public void addListener(LinkListener listener) {
- this.listener = listener;
- }
-
- @Override
- public Iterable<Link> getLinks() {
- return Collections.emptyList();
- }
- }
-
- /* Class implement device test registry */
- private class TestLinkRegistry implements LinkProviderRegistry {
- LinkProvider provider;
-
- Set<DeviceId> connected = new HashSet<>();
-
- @Override
- public LinkProviderService register(LinkProvider provider) {
- this.provider = provider;
- return new TestLinkProviderService();
- }
-
- @Override
- public void unregister(LinkProvider provider) {
-
- }
-
- @Override
- public Set<ProviderId> getProviders() {
- return null;
- }
-
- private class TestLinkProviderService implements LinkProviderService {
-
- @Override
- public void linkDetected(LinkDescription linkDescription) {
-
- }
-
- @Override
- public void linkVanished(LinkDescription linkDescription) {
-
- }
-
- @Override
- public void linksVanished(ConnectPoint connectPoint) {
-
- }
-
- @Override
- public void linksVanished(DeviceId deviceId) {
-
- }
-
- @Override
- public LinkProvider provider() {
- return null;
- }
- }
- }
-
- /* class implement test controller */
- private class TestController implements IsisController {
- protected Set<IsisRouterListener> nodeListener = new CopyOnWriteArraySet<>();
- protected Set<IsisLinkListener> linkListener = new CopyOnWriteArraySet<>();
-
- @Override
- public void addRouterListener(IsisRouterListener nodeListener) {
- this.nodeListener.add(nodeListener);
- }
-
- @Override
- public void removeRouterListener(IsisRouterListener nodeListener) {
- this.nodeListener.remove(nodeListener);
- }
-
- @Override
- public void addLinkListener(IsisLinkListener listener) {
- this.linkListener.add(listener);
- }
-
- @Override
- public void removeLinkListener(IsisLinkListener listener) {
- this.linkListener.remove(listener);
- }
-
- @Override
- public void updateConfig(JsonNode processesNode) {
-
- }
-
- @Override
- public List<IsisProcess> allConfiguredProcesses() {
- return null;
- }
-
- @Override
- public Set<IsisRouterListener> listener() {
- return null;
- }
-
- @Override
- public Set<IsisLinkListener> linkListener() {
- return null;
- }
-
- }
-
- /* Mock test for device service */
- private class MockNetConfigRegistryAdapter extends NetworkConfigRegistryAdapter {
- private ConfigFactory cfgFactory;
- private Map<ConnectPoint, BandwidthCapacity> classConfig = new HashMap<>();
-
- @Override
- public void registerConfigFactory(ConfigFactory configFactory) {
- cfgFactory = configFactory;
- }
-
- @Override
- public void unregisterConfigFactory(ConfigFactory configFactory) {
- cfgFactory = null;
- }
-
- @Override
- public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) {
- if (configClass == BandwidthCapacity.class) {
- BandwidthCapacity devCap = new BandwidthCapacity();
- classConfig.put((ConnectPoint) subject, devCap);
-
- JsonNode node = new ObjectNode(new MockJsonNode());
- ObjectMapper mapper = new ObjectMapper();
- ConfigApplyDelegate delegate = new InternalApplyDelegate();
- devCap.init((ConnectPoint) subject, null, node, mapper, delegate);
- return (C) devCap;
- }
-
- return null;
- }
-
- @Override
- public <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass) {
- classConfig.remove(subject);
- }
-
- @Override
- public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) {
- if (configClass == BandwidthCapacity.class) {
- return (C) classConfig.get(subject);
- }
- return null;
- }
-
- private class MockJsonNode extends JsonNodeFactory {
- }
-
- // Auxiliary delegate to receive notifications about changes applied to
- // the network configuration - by the apps.
- private class InternalApplyDelegate implements ConfigApplyDelegate {
- @Override
- public void onApply(Config config) {
- }
- }
- }
-}
\ No newline at end of file
diff --git a/providers/ospf/cfg/src/main/java/org/onosproject/provider/ospf/cfg/impl/OspfAppConfig.java b/providers/ospf/cfg/src/main/java/org/onosproject/provider/ospf/cfg/impl/OspfAppConfig.java
deleted file mode 100644
index ca1e461..0000000
--- a/providers/ospf/cfg/src/main/java/org/onosproject/provider/ospf/cfg/impl/OspfAppConfig.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-* Copyright 2016-present Open Networking Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package org.onosproject.provider.ospf.cfg.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.config.Config;
-import org.onosproject.ospf.controller.OspfController;
-
-/**
- * Configuration object for OSPF.
- */
-public class OspfAppConfig extends Config<ApplicationId> {
- public static final String METHOD = "method";
- public static final String ATTRIBUTE = "attribute";
- public static final String PROCESSES = "processes";
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- private OspfController ospfController;
-
- /**
- * Returns the configuration method, add, delete etc.
- *
- * @return the configuration method, add, delete etc
- */
- public String method() {
- return get(METHOD, null);
- }
-
- /**
- * Returns the configuration attribute, area, process etc.
- *
- * @return the configuration attribute, area, process etc
- */
- public String attribute() {
- return get(ATTRIBUTE, null);
- }
-
- /**
- * Returns the configured processes.
- *
- * @return the configured processes
- */
- public JsonNode processes() {
- JsonNode jsonNodes = object.get(PROCESSES);
-
- return jsonNodes;
- }
-
- @Override
- public boolean isValid() {
- this.ospfController = DefaultServiceDirectory.getService(OspfController.class);
-
- return true;
- }
-}
\ No newline at end of file
diff --git a/providers/ospf/cfg/src/main/java/org/onosproject/provider/ospf/cfg/impl/OspfCfgProvider.java b/providers/ospf/cfg/src/main/java/org/onosproject/provider/ospf/cfg/impl/OspfCfgProvider.java
deleted file mode 100644
index 4e62d28..0000000
--- a/providers/ospf/cfg/src/main/java/org/onosproject/provider/ospf/cfg/impl/OspfCfgProvider.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.ospf.cfg.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigRegistry;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.config.basics.SubjectFactories;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.ospf.controller.OspfController;
-import org.slf4j.Logger;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provider which advertises device descriptions to the core.
- */
-@Component(immediate = true, service = OspfCfgProvider.class)
-public class OspfCfgProvider extends AbstractProvider {
-
- static final String PROVIDER_ID = "org.onosproject.provider.ospf.cfg";
- private static final Logger log = getLogger(OspfCfgProvider.class);
- private final ConfigFactory configFactory =
- new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, OspfAppConfig.class, "ospfapp") {
- @Override
- public OspfAppConfig createConfig() {
- return new OspfAppConfig();
- }
- };
- private final NetworkConfigListener configListener = new InternalConfigListener();
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected OspfController ospfController;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected CoreService coreService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigRegistry configRegistry;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigService configService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected OspfController controller;
- private ApplicationId appId;
-
- /**
- * Creates an OSPF device provider.
- */
- public OspfCfgProvider() {
- super(new ProviderId("ospf", PROVIDER_ID));
- }
-
- public void setOspfController(OspfController ospfController) {
- this.ospfController = ospfController;
- }
-
- @Activate
- public void activate() {
- appId = coreService.registerApplication(PROVIDER_ID);
- configService.addListener(configListener);
- configRegistry.registerConfigFactory(configFactory);
- log.info("activated...!!!");
- }
-
- @Deactivate
- public void deactivate() {
- configRegistry.unregisterConfigFactory(configFactory);
- configService.removeListener(configListener);
- log.info("deactivated...!!!");
- }
-
- private void updateConfig() {
- OspfAppConfig ospfAppConfig = configRegistry.getConfig(appId, OspfAppConfig.class);
- if ("ADD".equalsIgnoreCase(ospfAppConfig.method())) {
- JsonNode jsonNode = ospfAppConfig.processes();
- ospfController.updateConfig(jsonNode);
- } else {
- log.debug("Please signify prop1 and prop2");
- }
- }
-
- /**
- * OSPF config listener to populate the configuration.
- */
- private class InternalConfigListener implements NetworkConfigListener {
- @Override
- public void event(NetworkConfigEvent event) {
- log.debug("InternalConfigListener:: event is getting called");
- if (!event.configClass().equals(OspfAppConfig.class)) {
- return;
- }
- switch (event.type()) {
- case CONFIG_ADDED:
- updateConfig();
- break;
- case CONFIG_UPDATED:
- updateConfig();
- break;
- case CONFIG_REMOVED:
- break;
- default:
- break;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/providers/ospf/cfg/src/main/java/org/onosproject/provider/ospf/cfg/impl/package-info.java b/providers/ospf/cfg/src/main/java/org/onosproject/provider/ospf/cfg/impl/package-info.java
deleted file mode 100644
index 33d6448..0000000
--- a/providers/ospf/cfg/src/main/java/org/onosproject/provider/ospf/cfg/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provider that uses OSPF capability request as a means of infrastructure device discovery.
- */
-package org.onosproject.provider.ospf.cfg.impl;
diff --git a/providers/ospf/cli/src/main/java/org/onosproject/ospf/cli/ApplicationOspfCommand.java b/providers/ospf/cli/src/main/java/org/onosproject/ospf/cli/ApplicationOspfCommand.java
deleted file mode 100644
index 15cfa9b..0000000
--- a/providers/ospf/cli/src/main/java/org/onosproject/ospf/cli/ApplicationOspfCommand.java
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
-* Copyright 2016-present Open Networking Foundation
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.onosproject.ospf.cli;
-
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.ospf.controller.OspfArea;
-import org.onosproject.ospf.controller.OspfController;
-import org.onosproject.ospf.controller.OspfInterface;
-import org.onosproject.ospf.controller.OspfLsaType;
-import org.onosproject.ospf.controller.OspfNbr;
-import org.onosproject.ospf.controller.OspfProcess;
-import org.onosproject.ospf.protocol.lsa.LsaHeader;
-import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Representation of OSPF cli commands.
- */
-@Service
-@Component(immediate = true)
-@Command(scope = "onos", name = "ospf", description = "list database")
-public class ApplicationOspfCommand extends AbstractShellCommand {
-
- protected static final String FORMAT6 = "%-20s%-20s%-20s%-20s%-20s%-20s\n";
- protected static final String FORMAT5 = "%-20s%-20s%-20s%-20s%-20s\n";
- protected static final String NETWORK = "NETWORK";
- protected static final String SUMMARY = "SUMMARY";
- protected static final String ASBR = "ABSR";
- protected static final String EXTERNAL = "EXTERNAL";
- protected static final String LINKLOOPAQ = "LINKLOCALOPAQUE";
- protected static final String AREALOCOPAQ = "AREALOCALOPAQUE";
- protected static final String ASOPAQ = "ASOPAQUE";
- protected static final String DR = "DR";
- protected static final String BACKUP = "BACKUP";
- protected static final String DROTHER = "DROther";
- static final String DATABASE = "database";
- static final String NEIGHBORLIST = "neighbors";
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected OspfController ospfController;
- @Argument(index = 0, name = "name",
- description = "database|neighborlist",
- required = true, multiValued = false)
- private String name = null;
- @Argument(index = 1, name = "processid",
- description = "processId",
- required = true, multiValued = false)
- private String process = null;
- @Argument(index = 2, name = "areaid",
- description = "areaId",
- required = false, multiValued = false)
- private String area = null;
- private List<String> routerLsa = new ArrayList<>();
- private List<String> networkLsa = new ArrayList<>();
- private List<String> summaryLsa = new ArrayList<>();
- private List<String> externalLsa = new ArrayList<>();
- private List<String> asbrSumm = new ArrayList<>();
- private List<String> areaLocalOpaqLsa = new ArrayList<>();
- private List<String> linkLocalOpqLsa = new ArrayList<>();
- private List<String> asOpqLsa = new ArrayList<>();
- private List<String> undefinedLsa = new ArrayList<>();
- private List<OspfArea> areaList = new ArrayList<>();
-
-
- @Activate
- public void activate() {
- print("OSPF cli activated...!!!");
- log.debug("OSPF cli activated...!!!");
- }
-
- @Deactivate
- public void deactivate() {
- log.debug("OSPF cli deactivated...!!!");
- }
-
- @Override
- protected void doExecute() {
- if (DATABASE.equals(name)) {
- buildOspfDatabaseInformation();
- } else if (NEIGHBORLIST.equals(name)) {
- buildNeighborInformation();
- } else {
- print("Please check the command (database|neighbor)");
- }
- }
-
- /**
- * Clears all the lists.
- */
- private void clearLists() {
- routerLsa.clear();
- networkLsa.clear();
- summaryLsa.clear();
- externalLsa.clear();
- asbrSumm.clear();
- areaLocalOpaqLsa.clear();
- linkLocalOpqLsa.clear();
- asOpqLsa.clear();
- undefinedLsa.clear();
- areaList.clear();
- }
-
- /**
- * Builds OSPF database information.
- */
- private void buildOspfDatabaseInformation() {
- try {
- //Builds LSA details
- buildLsaLists();
- for (OspfArea area : areaList) {
- if (routerLsa.size() > 0) {
- printRouterFormat(area.areaId().toString(), area.routerId().toString(), process);
- for (String str : routerLsa) {
- String[] lsaVal = str.split("\\,");
- if (area.areaId().toString().equalsIgnoreCase(lsaVal[0])) {
- print(FORMAT6, lsaVal[2], lsaVal[3], lsaVal[4], lsaVal[5], lsaVal[6], lsaVal[7]);
- }
- }
- }
- if (networkLsa.size() > 0) {
- printNetworkFormat(area.areaId().toString(), NETWORK);
- printDetails(networkLsa, area.areaId().toString());
- }
- if (summaryLsa.size() > 0) {
- printNetworkFormat(area.areaId().toString(), SUMMARY);
- printDetails(summaryLsa, area.areaId().toString());
- }
- if (externalLsa.size() > 0) {
- printNetworkFormat(area.areaId().toString(), EXTERNAL);
- printDetails(externalLsa, area.areaId().toString());
- }
- if (asbrSumm.size() > 0) {
- printNetworkFormat(area.areaId().toString(), ASBR);
- printDetails(asbrSumm, area.areaId().toString());
- }
- if (areaLocalOpaqLsa.size() > 0) {
- printNetworkFormat(area.areaId().toString(), AREALOCOPAQ);
- printDetails(areaLocalOpaqLsa, area.areaId().toString());
- }
- if (linkLocalOpqLsa.size() > 0) {
- printNetworkFormat(area.areaId().toString(), LINKLOOPAQ);
- printDetails(linkLocalOpqLsa, area.areaId().toString());
- }
- if (asOpqLsa.size() > 0) {
- printNetworkFormat(area.areaId().toString(), ASOPAQ);
- printDetails(asOpqLsa, area.areaId().toString());
- }
- if (undefinedLsa.size() > 0) {
- printRouterFormat(area.areaId().toString(), area.routerId().toString(), process);
- printDetails(undefinedLsa, area.areaId().toString());
- }
- }
- clearLists();
- } catch (Exception ex) {
- clearLists();
- print("Error occured while Ospf controller getting called" + ex.getMessage());
- }
- }
-
- /**
- * Prints LSA details.
- *
- * @param lsaDetails LSA details
- * @param areaId area ID
- */
- private void printDetails(List<String> lsaDetails, String areaId) {
- for (String str : lsaDetails) {
- String[] lsaVal = str.split("\\,");
- if (areaId.equalsIgnoreCase(lsaVal[0])) {
- print(FORMAT5, lsaVal[2], lsaVal[3], lsaVal[4], lsaVal[5], lsaVal[6]);
- }
- }
- }
-
- /**
- * Builds all LSA lists with LSA details.
- */
- private void buildLsaLists() {
- this.ospfController = get(OspfController.class);
- List<OspfProcess> listOfProcess = ospfController.getAllConfiguredProcesses();
- Iterator<OspfProcess> itrProcess = listOfProcess.iterator();
- while (itrProcess.hasNext()) {
- OspfProcess ospfProcess = itrProcess.next();
- if (process.equalsIgnoreCase(ospfProcess.processId())) {
- List<OspfArea> listAreas = ospfProcess.areas();
- Iterator<OspfArea> itrArea = listAreas.iterator();
- while (itrArea.hasNext()) {
- OspfArea area = itrArea.next();
- List<LsaHeader> lsas = area.database()
- .getAllLsaHeaders(false, area.isOpaqueEnabled());
- List<LsaHeader> tmpLsaList = new ArrayList<>(lsas);
- log.debug("OSPFController::size of database::" + (lsas != null ? lsas.size() : null));
- Iterator<LsaHeader> itrLsaHeader = tmpLsaList.iterator();
- areaList.add(area);
- if (itrLsaHeader != null) {
- while (itrLsaHeader.hasNext()) {
- LsaHeader header = itrLsaHeader.next();
- populateLsaLists(header, area);
- }
- }
- }
- }
- }
- }
-
- /**
- * Populates the LSA lists based on the input.
- *
- * @param header LSA header instance
- * @param area OSPF area instance
- */
- private void populateLsaLists(LsaHeader header, OspfArea area) {
- String seqNo = Long.toHexString(header.lsSequenceNo());
- String checkSum = Long.toHexString(header.lsCheckSum());
- if (seqNo.length() == 16) {
- seqNo = seqNo.substring(8, seqNo.length());
- }
- if (checkSum.length() == 16) {
- checkSum = checkSum.substring(8, checkSum.length());
- }
- StringBuffer strBuf = getBuffList(area.areaId().toString(), area.routerId().toString(),
- header.linkStateId(),
- header.advertisingRouter().toString(),
- header.age(), seqNo, checkSum);
- if (header.lsType() == OspfLsaType.ROUTER.value()) {
- strBuf.append(",");
- strBuf.append(((RouterLsa) header).noLink());
- routerLsa.add(strBuf.toString());
- } else if (header.lsType() == OspfLsaType.NETWORK.value()) {
- strBuf.append(",");
- strBuf.append("0");
- networkLsa.add(strBuf.toString());
- } else if (header.lsType() == OspfLsaType.SUMMARY.value()) {
- strBuf.append(",");
- strBuf.append("0");
- summaryLsa.add(strBuf.toString());
- } else if (header.lsType() == OspfLsaType.EXTERNAL_LSA.value()) {
- strBuf.append(",");
- strBuf.append("0");
- externalLsa.add(strBuf.toString());
- } else if (header.lsType() == OspfLsaType.ASBR_SUMMARY.value()) {
- strBuf.append(",");
- strBuf.append("0");
- asbrSumm.add(strBuf.toString());
- } else if (header.lsType() == OspfLsaType.AREA_LOCAL_OPAQUE_LSA.value()) {
- strBuf.append(",");
- strBuf.append("0");
- areaLocalOpaqLsa.add(strBuf.toString());
- } else if (header.lsType() == OspfLsaType.LINK_LOCAL_OPAQUE_LSA.value()) {
- strBuf.append(",");
- strBuf.append("0");
- linkLocalOpqLsa.add(strBuf.toString());
- } else if (header.lsType() == OspfLsaType.AS_OPAQUE_LSA.value()) {
- strBuf.append(",");
- strBuf.append("0");
- asOpqLsa.add(strBuf.toString());
- } else {
- strBuf.append(",");
- strBuf.append("0");
- undefinedLsa.add(strBuf.toString());
- }
- }
-
- /**
- * Builds OSPF neighbor information.
- */
- private void buildNeighborInformation() {
- try {
- this.ospfController = get(OspfController.class);
- List<OspfProcess> listOfProcess = ospfController.getAllConfiguredProcesses();
- boolean flag = false;
- printNeighborsFormat();
- Iterator<OspfProcess> itrProcess = listOfProcess.iterator();
- while (itrProcess.hasNext()) {
- OspfProcess process = itrProcess.next();
- List<OspfArea> listAreas = process.areas();
- Iterator<OspfArea> itrArea = listAreas.iterator();
- while (itrArea.hasNext()) {
- OspfArea area = itrArea.next();
- List<OspfInterface> itrefaceList = area.ospfInterfaceList();
- for (OspfInterface interfc : itrefaceList) {
- List<OspfNbr> nghbrList = new ArrayList<>(interfc.listOfNeighbors().values());
- for (OspfNbr neigbor : nghbrList) {
- print("%-20s%-20s%-20s%-20s%-20s\n", neigbor.neighborId(), neigbor.routerPriority(),
- neigbor.getState() + "/" + checkDrBdrOther(neigbor.neighborIpAddr().toString(),
- neigbor.neighborDr().toString(),
- neigbor.neighborBdr().toString()),
- neigbor.neighborIpAddr().toString(), interfc.ipAddress());
- }
- }
- }
- }
- } catch (Exception ex) {
- print("Error occured while Ospf controller getting called" + ex.getMessage());
- }
- }
-
- /**
- * Prints input after formatting.
- *
- * @param areaId area ID
- * @param routerId router ID
- * @param processId process ID
- */
- private void printRouterFormat(String areaId, String routerId, String processId) {
- print("%s (%s) %s %s\n", "OSPF Router with ID", routerId, "Process Id", processId);
- print("%s ( Area %s)\n", "Router Link States", areaId);
- print("%-20s%-20s%-20s%-20s%-20s%-20s\n", "Link Id", "ADV Router", "Age", "Seq#",
- "CkSum", "Link Count");
- }
-
- /**
- * Prints input after formatting.
- *
- * @param areaId area ID
- * @param type network type
- */
- private void printNetworkFormat(String areaId, String type) {
- print("%s %s ( Area %s)\n", type, "Link States", areaId);
- print("%-20s%-20s%-20s%-20s%-20s\n", "Link Id", "ADV Router", "Age", "Seq#", "CkSum");
- }
-
- /**
- * Prints input after formatting.
- */
- private void printNeighborsFormat() {
- print("%-20s%-20s%-20s%-20s%-20s\n", "Neighbor Id", "Pri", "State",
- "Address", "Interface");
- }
-
- /**
- * Checks whether the neighbor is DR or BDR.
- *
- * @param ip IP address to check
- * @param drIP DRs IP address
- * @param bdrIp BDRs IP address
- * @return 1- neighbor is DR, 2- neighbor is BDR, 3- DROTHER
- */
- public String checkDrBdrOther(String ip, String drIP, String bdrIp) {
-
- if (ip.equalsIgnoreCase(drIP)) {
- return DR;
- } else if (ip.equalsIgnoreCase(bdrIp)) {
- return BACKUP;
- } else {
- return DROTHER;
- }
- }
-
- /**
- * Returns inputs as formatted string.
- *
- * @param areaId area id
- * @param routerId router id
- * @param linkStateId link state id
- * @param advertisingRouter advertising router
- * @param age age
- * @param seqNo sequence number
- * @param checkSum checksum
- * @return formatted string
- */
- private StringBuffer getBuffList(String areaId, String routerId, String linkStateId,
- String advertisingRouter, int age, String seqNo, String checkSum) {
- StringBuffer strBuf = new StringBuffer();
- strBuf.append(areaId);
- strBuf.append(",");
- strBuf.append(routerId);
- strBuf.append(",");
- strBuf.append(linkStateId);
- strBuf.append(",");
- strBuf.append(advertisingRouter);
- strBuf.append(",");
- strBuf.append(age);
- strBuf.append(",");
- strBuf.append(seqNo);
- strBuf.append(",");
- strBuf.append(checkSum);
- return strBuf;
- }
-}
\ No newline at end of file
diff --git a/providers/ospf/cli/src/main/java/org/onosproject/ospf/cli/package-info.java b/providers/ospf/cli/src/main/java/org/onosproject/ospf/cli/package-info.java
deleted file mode 100644
index 6b4ef08..0000000
--- a/providers/ospf/cli/src/main/java/org/onosproject/ospf/cli/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * OSPF cli implementation.
- */
-package org.onosproject.ospf.cli;
diff --git a/providers/ospf/topology/src/main/java/org/onosproject/provider/ospf/topology/impl/OspfTopologyProvider.java b/providers/ospf/topology/src/main/java/org/onosproject/provider/ospf/topology/impl/OspfTopologyProvider.java
deleted file mode 100644
index 702d61a..0000000
--- a/providers/ospf/topology/src/main/java/org/onosproject/provider/ospf/topology/impl/OspfTopologyProvider.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.ospf.topology.impl;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onlab.packet.ChassisId;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DefaultDeviceDescription;
-import org.onosproject.net.device.DefaultPortDescription;
-import org.onosproject.net.device.DeviceDescription;
-import org.onosproject.net.device.DeviceProvider;
-import org.onosproject.net.device.DeviceProviderRegistry;
-import org.onosproject.net.device.DeviceProviderService;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.link.DefaultLinkDescription;
-import org.onosproject.net.link.LinkDescription;
-import org.onosproject.net.link.LinkProvider;
-import org.onosproject.net.link.LinkProviderRegistry;
-import org.onosproject.net.link.LinkProviderService;
-import org.onosproject.net.link.LinkService;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.ospf.controller.OspfController;
-import org.onosproject.ospf.controller.OspfLinkTed;
-import org.onosproject.ospf.controller.OspfRouter;
-import org.onosproject.ospf.controller.OspfRouterId;
-import org.onosproject.ospf.controller.OspfRouterListener;
-import org.onosproject.ospf.controller.OspfLinkListener;
-import org.slf4j.Logger;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provider which advertises device descriptions to the core.
- */
-@Component(immediate = true)
-public class OspfTopologyProvider extends AbstractProvider implements DeviceProvider, LinkProvider {
-
- public static final long PSEUDO_PORT = 0xffffffff;
- private static final Logger log = getLogger(OspfTopologyProvider.class);
- // Default values for tunable parameters
- private static final String UNKNOWN = "unknown";
- final InternalTopologyProvider listener = new InternalTopologyProvider();
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceProviderRegistry deviceProviderRegistry;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LinkProviderRegistry linkProviderRegistry;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LinkService linkService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected OspfController controller;
- //This Interface that defines how this provider can interact with the core.
- private LinkProviderService linkProviderService;
- // The interface that defines how this Provider can interact with the core
- private DeviceProviderService deviceProviderService;
-
- /**
- * Creates an OSPF device provider.
- */
- public OspfTopologyProvider() {
- super(new ProviderId("l3", "org.onosproject.provider.ospf"));
- }
-
- @Activate
- public void activate() {
- deviceProviderService = deviceProviderRegistry.register(this);
- linkProviderService = linkProviderRegistry.register(this);
- controller.addRouterListener(listener);
- controller.addLinkListener(listener);
- log.debug("IsisDeviceProvider::activate...!!!!");
- }
-
- @Deactivate
- public void deactivate() {
- log.debug("IsisDeviceProvider::deactivate...!!!!");
- deviceProviderRegistry.unregister(this);
- deviceProviderService = null;
- linkProviderRegistry.unregister(this);
- linkProviderService = null;
- controller.removeRouterListener(listener);
- controller.removeLinkListener(listener);
- log.info("deactivated...!!!");
- }
-
- @Override
- public boolean isReachable(DeviceId deviceId) {
- return true;
- }
-
- @Override
- public void changePortState(DeviceId deviceId, PortNumber portNumber, boolean enable) {
- log.info("changePortState on device {}", deviceId);
- }
-
- @Override
- public void triggerProbe(DeviceId deviceId) {
- log.info("Triggering probe on device {}", deviceId);
- }
-
- @Override
- public void roleChanged(DeviceId deviceId, MastershipRole newRole) {
- log.info("Accepting mastership role change for device {}", deviceId);
- }
-
- /**
- * Builds link description.
- *
- * @param ospfRouter OSPF router instance
- * @param ospfLinkTed OSPF link TED instance
- * @return link description instance
- */
- private LinkDescription buildLinkDes(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
- long srcAddress = 0;
- long dstAddress = 0;
- boolean localPseduo = false;
- //Changing of port numbers
- srcAddress = Ip4Address.valueOf(ospfRouter.routerIp().toString()).toInt();
- dstAddress = Ip4Address.valueOf(ospfRouter.neighborRouterId().toString()).toInt();
- DeviceId srcId = DeviceId.deviceId(OspfRouterId.uri(ospfRouter.routerIp()));
- DeviceId dstId = DeviceId.deviceId(OspfRouterId.uri(ospfRouter.neighborRouterId()));
- if (ospfRouter.isDr()) {
- localPseduo = true;
- }
- if (localPseduo && srcAddress == 0) {
- srcAddress = PSEUDO_PORT;
- }
-
- ConnectPoint src = new ConnectPoint(srcId, PortNumber.portNumber(srcAddress));
- ConnectPoint dst = new ConnectPoint(dstId, PortNumber.portNumber(dstAddress));
-
- return new DefaultLinkDescription(src, dst, Link.Type.DIRECT, false);
- }
-
- /**
- * Internal topology Provider implementation.
- */
- protected class InternalTopologyProvider implements OspfRouterListener, OspfLinkListener {
-
- @Override
- public void routerAdded(OspfRouter ospfRouter) {
- String routerId = ospfRouter.routerIp().toString();
- log.info("Added device {}", routerId);
- DeviceId deviceId = DeviceId.deviceId(OspfRouterId.uri(ospfRouter.routerIp()));
- Device.Type deviceType = Device.Type.ROUTER;
- //If our routerType is Dr or Bdr type is PSEUDO
- if (ospfRouter.isDr()) {
- deviceType = Device.Type.ROUTER;
- } else {
- deviceType = Device.Type.VIRTUAL;
- }
- //deviceId = DeviceId.deviceId(routerDetails);
- ChassisId cId = new ChassisId();
- DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
-
- newBuilder.set(AnnotationKeys.TYPE, "l3");
- newBuilder.set("routerId", routerId);
- DeviceDescription description =
- new DefaultDeviceDescription(OspfRouterId.uri(ospfRouter.routerIp()),
- deviceType, UNKNOWN, UNKNOWN, UNKNOWN,
- UNKNOWN, cId, newBuilder.build());
- deviceProviderService.deviceConnected(deviceId, description);
- }
-
- @Override
- public void routerRemoved(OspfRouter ospfRouter) {
- String routerId = ospfRouter.routerIp().toString();
- log.info("Delete device {}", routerId);
- DeviceId deviceId = DeviceId.deviceId(OspfRouterId.uri(ospfRouter.routerIp()));
- if (deviceProviderService == null) {
- return;
- }
- deviceProviderService.deviceDisconnected(deviceId);
- log.info("delete device {}", routerId);
- }
-
- @Override
- public void addLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
- log.debug("Addlink {}", ospfRouter.routerIp());
- LinkDescription linkDes = buildLinkDes(ospfRouter, ospfLinkTed);
- //If already link exists, return
- if (linkService.getLink(linkDes.src(), linkDes.dst()) != null || linkProviderService == null) {
- return;
- }
- //Updating ports of the link
- List<PortDescription> srcPortDescriptions = new LinkedList<>();
- srcPortDescriptions.add(DefaultPortDescription.builder()
- .withPortNumber(linkDes.src().port()).isEnabled(true).build());
- deviceProviderService.updatePorts(linkDes.src().deviceId(), srcPortDescriptions);
-
- List<PortDescription> dstPortDescriptions = new LinkedList<>();
- dstPortDescriptions.add(DefaultPortDescription.builder()
- .withPortNumber(linkDes.dst().port()).isEnabled(true).build());
- deviceProviderService.updatePorts(linkDes.dst().deviceId(), dstPortDescriptions);
- linkProviderService.linkDetected(linkDes);
- }
-
- @Override
- public void deleteLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
- log.debug("Delete link {}", ospfRouter.routerIp().toString());
- if (linkProviderService == null) {
- return;
- }
- LinkDescription linkDes = buildLinkDes(ospfRouter, ospfLinkTed);
- //Updating ports of the link
- List<PortDescription> srcPortDescriptions = new LinkedList<>();
- srcPortDescriptions.add(DefaultPortDescription.builder()
- .withPortNumber(linkDes.src().port()).isEnabled(true).build());
- deviceProviderService.updatePorts(linkDes.src().deviceId(), srcPortDescriptions);
-
- List<PortDescription> dstPortDescriptions = new LinkedList<>();
- dstPortDescriptions.add(DefaultPortDescription.builder()
- .withPortNumber(linkDes.dst().port()).isEnabled(true).build());
- deviceProviderService.updatePorts(linkDes.dst().deviceId(), dstPortDescriptions);
- linkProviderService.linkVanished(linkDes);
- }
-
- @Override
- public void routerChanged(OspfRouter ospfRouter) {
- log.info("Router changed is not supported currently");
- }
- }
-}
diff --git a/providers/ospf/topology/src/main/java/org/onosproject/provider/ospf/topology/impl/package-info.java b/providers/ospf/topology/src/main/java/org/onosproject/provider/ospf/topology/impl/package-info.java
deleted file mode 100644
index 59a7a4e..0000000
--- a/providers/ospf/topology/src/main/java/org/onosproject/provider/ospf/topology/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provider that uses OSPF as a means of topology discovery.
- */
-package org.onosproject.provider.ospf.topology.impl;
diff --git a/providers/ospf/topology/src/test/java/org/onosproject/provider/ospf/topology/impl/OspfTopologyProviderTest.java b/providers/ospf/topology/src/test/java/org/onosproject/provider/ospf/topology/impl/OspfTopologyProviderTest.java
deleted file mode 100644
index acd8340..0000000
--- a/providers/ospf/topology/src/test/java/org/onosproject/provider/ospf/topology/impl/OspfTopologyProviderTest.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.ospf.topology.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.Ip4Address;
-import org.onlab.util.Bandwidth;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DeviceDescription;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceProvider;
-import org.onosproject.net.device.DeviceProviderRegistry;
-import org.onosproject.net.device.DeviceProviderService;
-import org.onosproject.net.device.DeviceServiceAdapter;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.device.PortStatistics;
-import org.onosproject.net.link.LinkDescription;
-import org.onosproject.net.link.LinkListener;
-import org.onosproject.net.link.LinkProvider;
-import org.onosproject.net.link.LinkProviderRegistry;
-import org.onosproject.net.link.LinkProviderService;
-import org.onosproject.net.link.LinkServiceAdapter;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.ospf.controller.OspfController;
-import org.onosproject.ospf.controller.OspfDeviceTed;
-import org.onosproject.ospf.controller.OspfLinkListener;
-import org.onosproject.ospf.controller.OspfLinkTed;
-import org.onosproject.ospf.controller.OspfProcess;
-import org.onosproject.ospf.controller.OspfRouter;
-import org.onosproject.ospf.controller.OspfRouterListener;
-import org.onosproject.ospf.controller.impl.OspfDeviceTedImpl;
-import org.onosproject.ospf.controller.impl.OspfLinkTedImpl;
-import org.onosproject.ospf.controller.impl.OspfRouterImpl;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArraySet;
-
-import static org.junit.Assert.*;
-
-/**
- * Test cases for OSPF topology provider.
- */
-public class OspfTopologyProviderTest {
-
- private final OspfTopologyProvider provider = new OspfTopologyProvider();
- private final TestDeviceRegistry nodeRegistry = new TestDeviceRegistry();
- private final TestLinkRegistry linkRegistry = new TestLinkRegistry();
- private final TestController controller = new TestController();
- private final TestLinkService linkService = new TestLinkService();
-
- @Before
- public void setUp() throws Exception {
- provider.deviceProviderRegistry = nodeRegistry;
- provider.linkProviderRegistry = linkRegistry;
- provider.controller = controller;
- provider.linkService = linkService;
- provider.activate();
- assertNotNull("provider should be registered", nodeRegistry.provider);
- assertNotNull("listener should be registered", controller.nodeListener);
-
- }
-
- @After
- public void tearDown() throws Exception {
- provider.deactivate();
- assertNull("listener should be removed", controller.nodeListener);
- provider.controller = null;
- provider.deviceProviderRegistry = null;
- }
-
- @Test
- public void triggerProbe() {
- DeviceId deviceId = DeviceId.deviceId("2.2.2.2");
- provider.triggerProbe(deviceId);
- }
-
- @Test
- public void roleChanged() {
- DeviceId deviceId = DeviceId.deviceId("2.2.2.2");
- provider.roleChanged(deviceId, MastershipRole.MASTER);
- }
-
- @Test
- public void changePortState() {
- DeviceId deviceId = DeviceId.deviceId("2.2.2.2");
- provider.changePortState(deviceId, PortNumber.portNumber(0), false);
- }
-
- @Test
- public void isReachable() {
- DeviceId deviceId = DeviceId.deviceId("1.1.1.1");
- provider.isReachable(deviceId);
- }
-
- /* Validate node is added to the device validating URI, RIB should get updated properly */
- @Test
- public void ospfTopologyProviderTestAddDevice1() {
- int deviceAddCount = 0;
- OspfRouter ospfRouter = new OspfRouterImpl();
- ospfRouter.setDr(false);
- ospfRouter.setOpaque(false);
- ospfRouter.setNeighborRouterId(Ip4Address.valueOf("2.2.2.2"));
- ospfRouter.setInterfaceId(Ip4Address.valueOf("10.10.10.2"));
- ospfRouter.setAreaIdOfInterface(Ip4Address.valueOf("5.5.5.5"));
- ospfRouter.setRouterIp(Ip4Address.valueOf("1.1.1.1"));
- OspfDeviceTed ospfDeviceTed = new OspfDeviceTedImpl();
- ospfDeviceTed.setAbr(false);
- ospfDeviceTed.setAsbr(false);
- ospfRouter.setDeviceTed(ospfDeviceTed);
- OspfLinkTed ospfLinkTed = new OspfLinkTedImpl();
- ospfLinkTed.setMaximumLink(Bandwidth.bps(10));
- ospfLinkTed.setMaxReserved(Bandwidth.bps(20));
- ospfLinkTed.setTeMetric(10);
- OspfRouter ospfRouter1 = new OspfRouterImpl();
- ospfRouter1.setDr(true);
- ospfRouter1.setOpaque(true);
- ospfRouter1.setNeighborRouterId(Ip4Address.valueOf("2.2.2.2"));
- ospfRouter1.setInterfaceId(Ip4Address.valueOf("10.10.10.2"));
- ospfRouter1.setAreaIdOfInterface(Ip4Address.valueOf("5.5.5.5"));
- ospfRouter1.setRouterIp(Ip4Address.valueOf("1.1.1.1"));
- OspfDeviceTed ospfDeviceTed1 = new OspfDeviceTedImpl();
- ospfDeviceTed1.setAbr(false);
- ospfDeviceTed1.setAsbr(false);
- ospfRouter.setDeviceTed(ospfDeviceTed);
- OspfLinkTed ospfLinkTed1 = new OspfLinkTedImpl();
- ospfLinkTed1.setMaximumLink(Bandwidth.bps(10));
- ospfLinkTed1.setMaxReserved(Bandwidth.bps(20));
- ospfLinkTed1.setTeMetric(10);
- for (OspfRouterListener l : controller.nodeListener) {
- l.routerAdded(ospfRouter);
-
- deviceAddCount = nodeRegistry.connected.size();
- assertTrue(deviceAddCount == 1);
- l.routerRemoved(ospfRouter);
- deviceAddCount = nodeRegistry.connected.size();
- assertTrue(deviceAddCount == 0);
- }
- for (OspfLinkListener l : controller.linkListener) {
- l.addLink(ospfRouter, ospfLinkTed);
- l.deleteLink(ospfRouter, ospfLinkTed);
-
- }
- }
-
- @Test
- public void ospfTopologyProviderTestAddDevice2() {
- int deviceAddCount = 0;
- OspfRouter ospfRouter = new OspfRouterImpl();
- ospfRouter.setDr(true);
- ospfRouter.setOpaque(true);
- ospfRouter.setNeighborRouterId(Ip4Address.valueOf("3.3.3.3"));
- ospfRouter.setInterfaceId(Ip4Address.valueOf("10.10.10.3"));
- ospfRouter.setAreaIdOfInterface(Ip4Address.valueOf("6.6.6.6"));
- ospfRouter.setRouterIp(Ip4Address.valueOf("7.7.7.7"));
- OspfDeviceTed ospfDeviceTed = new OspfDeviceTedImpl();
- ospfDeviceTed.setAbr(true);
- ospfDeviceTed.setAsbr(true);
- ospfRouter.setDeviceTed(ospfDeviceTed);
- OspfLinkTed ospfLinkTed = new OspfLinkTedImpl();
- ospfLinkTed.setMaximumLink(Bandwidth.bps(30));
- ospfLinkTed.setMaxReserved(Bandwidth.bps(40));
- ospfLinkTed.setTeMetric(50);
- for (OspfRouterListener l : controller.nodeListener) {
- l.routerAdded(ospfRouter);
- deviceAddCount = nodeRegistry.connected.size();
- assertTrue(deviceAddCount == 1);
- l.routerRemoved(ospfRouter);
- deviceAddCount = nodeRegistry.connected.size();
- assertTrue(deviceAddCount == 0);
- }
- }
-
-
- /* Class implement device test registry */
- private class TestDeviceRegistry implements DeviceProviderRegistry {
- DeviceProvider provider;
- Set<DeviceId> connected = new HashSet<>();
-
- @Override
- public DeviceProviderService register(DeviceProvider provider) {
- this.provider = provider;
- return new TestProviderService();
- }
-
- @Override
- public void unregister(DeviceProvider provider) {
- }
-
- @Override
- public Set<ProviderId> getProviders() {
- return null;
- }
-
- private class TestProviderService implements DeviceProviderService {
-
- @Override
- public DeviceProvider provider() {
- return null;
- }
-
- @Override
- public void deviceConnected(DeviceId deviceId, DeviceDescription deviceDescription) {
- connected.add(deviceId);
- }
-
- @Override
- public void deviceDisconnected(DeviceId deviceId) {
- connected.remove(deviceId);
- }
-
- @Override
- public void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void portStatusChanged(DeviceId deviceId, PortDescription portDescription) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void receivedRoleReply(DeviceId deviceId, MastershipRole requested, MastershipRole response) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void updatePortStatistics(DeviceId deviceId, Collection<PortStatistics> portStatistics) {
- // TODO Auto-generated method stub
- }
- }
- }
-
- private class TestDeviceService extends DeviceServiceAdapter {
- private DeviceListener listener;
-
- @Override
- public void addListener(DeviceListener listener) {
- this.listener = listener;
- }
-
- @Override
- public Iterable<Device> getDevices() {
- return Collections.emptyList();
- }
- }
-
- private class TestLinkService extends LinkServiceAdapter {
- private LinkListener listener;
-
- @Override
- public void addListener(LinkListener listener) {
- this.listener = listener;
- }
-
- @Override
- public Iterable<Link> getLinks() {
- return Collections.emptyList();
- }
- }
-
- /* Class implement device test registry */
- private class TestLinkRegistry implements LinkProviderRegistry {
- LinkProvider provider;
- Set<DeviceId> connected = new HashSet<>();
-
- @Override
- public LinkProviderService register(LinkProvider provider) {
- this.provider = provider;
- return new TestLinkProviderService();
- }
-
- @Override
- public void unregister(LinkProvider provider) {
- }
-
- @Override
- public Set<ProviderId> getProviders() {
- return null;
- }
-
- private class TestLinkProviderService implements LinkProviderService {
- @Override
- public void linkDetected(LinkDescription linkDescription) {
- }
-
- @Override
- public void linkVanished(LinkDescription linkDescription) {
- }
-
- @Override
- public void linksVanished(ConnectPoint connectPoint) {
- }
-
- @Override
- public void linksVanished(DeviceId deviceId) {
- }
-
- @Override
- public LinkProvider provider() {
- return null;
- }
- }
- }
-
- /* class implement test controller */
- private class TestController implements OspfController {
- protected Set<OspfRouterListener> nodeListener = new CopyOnWriteArraySet<>();
- protected Set<OspfLinkListener> linkListener = new CopyOnWriteArraySet<>();
-
- @Override
- public void addRouterListener(OspfRouterListener nodeListener) {
- this.nodeListener.add(nodeListener);
- }
-
- @Override
- public void removeRouterListener(OspfRouterListener nodeListener) {
- this.nodeListener = null;
- }
-
- @Override
- public void addLinkListener(OspfLinkListener listener) {
- this.linkListener.add(listener);
- }
-
- @Override
- public void removeLinkListener(OspfLinkListener listener) {
- this.nodeListener = null;
- }
-
- @Override
- public void updateConfig(JsonNode processesNode) {
- }
-
-
- @Override
- public void deleteConfig(List<OspfProcess> processes, String attribute) {
- }
-
- @Override
- public Set<OspfRouterListener> listener() {
- return null;
- }
-
- @Override
- public Set<OspfLinkListener> linkListener() {
- return null;
- }
-
- @Override
- public List<OspfProcess> getAllConfiguredProcesses() {
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/providers/pcep/BUILD b/providers/pcep/BUILD
deleted file mode 100644
index fa0a676..0000000
--- a/providers/pcep/BUILD
+++ /dev/null
@@ -1,24 +0,0 @@
-BUNDLES = [
- "@io_netty_netty//jar",
- "//providers/pcep/topology:onos-providers-pcep-topology",
- "//providers/pcep/tunnel:onos-providers-pcep-tunnel",
- "//providers/pcep/cli:onos-providers-pcep-cli",
- "//protocols/pcep/server/api:onos-protocols-pcep-server-api",
- "//protocols/pcep/pcepio:onos-protocols-pcep-pcepio",
- "//protocols/pcep/server/ctl:onos-protocols-pcep-server-ctl",
- "//apps/pcep-api:onos-apps-pcep-api",
-]
-
-onos_app(
- category = "Provider",
- description = "PCEP protocol providers root.",
- included_bundles = BUNDLES,
- required_apps = [
- "org.onosproject.pcep-api",
- "org.onosproject.optical-model",
- "org.onosproject.tunnel",
- "org.onosproject.bgp",
- ],
- title = "PCEP Provider",
- url = "http://onosproject.org",
-)
diff --git a/providers/pcep/cli/BUILD b/providers/pcep/cli/BUILD
deleted file mode 100644
index 4eac8a7..0000000
--- a/providers/pcep/cli/BUILD
+++ /dev/null
@@ -1,9 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + CLI + [
- "//protocols/pcep/server/ctl:onos-protocols-pcep-server-ctl",
- "//protocols/pcep/server/api:onos-protocols-pcep-server-api",
-]
-
-osgi_jar_with_tests(
- karaf_command_packages = ["org.onosproject.pcep.cli"],
- deps = COMPILE_DEPS,
-)
diff --git a/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/PcepSessionCommand.java b/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/PcepSessionCommand.java
deleted file mode 100644
index 68315e3..0000000
--- a/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/PcepSessionCommand.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.pcep.cli;
-
-
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.pcep.server.PcepClientController;
-import org.onosproject.pcep.server.PcepErrorDetail;
-import org.onosproject.pcep.server.PcepErrorType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Set;
-import java.util.Map;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.TreeMap;
-
-@Service
-@Command(scope = "onos", name = "pcep", description = "Pcep Session Info")
-public class PcepSessionCommand extends AbstractShellCommand {
- private static final Logger log = LoggerFactory.getLogger(PcepSessionCommand.class);
- private static final String SESSION = "session";
- private static final String EXCEPTION = "exception";
- private static final String ERROR = "error";
- private PcepClientController pcepClientController;
- private byte sessionId;
- private Set<String> pcepSessionKeySet;
- private Set<String> pcepSessionIdKeySet;
- private Integer sessionIdValue = 0;
- private String sessionStatus;
- private List pcepSessionExceptions = new ArrayList();
- private Set<String> pcepSessionFailurekeySet;
- private PcepErrorDetail pcepErrorDetail;
- private PcepErrorType pcepErrorType;
- private Map<Integer, String> sessionEstablishmentFailureMap = new TreeMap<>();
- private Map<Integer, String> unknownObjectMap = new TreeMap<>();
- private Map<Integer, String> notSupportedObjectMap = new TreeMap<>();
- private Map<Integer, String> policyViolationMap = new TreeMap<>();
- private Map<Integer, String> mandatoryObjectMissingMap = new TreeMap<>();
- private Map<Integer, String> receptionOfInvalidObjectMap = new TreeMap<>();
- private Map<Integer, String> invalidOperationMap = new TreeMap<>();
- private Set<Integer> pcepErrorMsgKey;
- private Integer pcepErrorValue = 0;
-
- @Argument(index = 0, name = "name",
- description = "session" + "\n" + "exception" + "\n" + "error",
- required = true, multiValued = false)
- String name = null;
- @Argument(index = 1, name = "peer",
- description = "peerIp",
- required = false, multiValued = false)
- String peer = null;
-
- @Override
- protected void doExecute() {
- switch (name) {
- case SESSION:
- displayPcepSession();
- break;
- case EXCEPTION:
- displayPcepSessionFailureReason();
- break;
- case ERROR:
- displayPcepErrorMsgs();
- break;
- default:
- System.out.print("Unknown Command");
- break;
- }
- }
-
- private void displayPcepSession() {
- try {
- this.pcepClientController = get(PcepClientController.class);
- Map<String, String> pcepSessionMap = pcepClientController.getPcepSessionMap();
- Map<String, Byte> pcepSessionIdMap = pcepClientController.getPcepSessionIdMap();
- pcepSessionKeySet = pcepSessionMap.keySet();
- pcepSessionIdKeySet = pcepSessionIdMap.keySet();
- if (peer != null) {
- if (!pcepSessionKeySet.isEmpty()) {
- if (pcepSessionKeySet.contains(peer)) {
- for (String pcepSessionPeer : pcepSessionKeySet) {
- if (pcepSessionPeer.equals(peer)) {
- for (String pcepSessionId : pcepSessionIdKeySet) {
- if (pcepSessionId.equals(peer)) {
- sessionId = pcepSessionIdMap.get(pcepSessionId);
- sessionStatus = pcepSessionMap.get(pcepSessionPeer);
- if (sessionId < 0) {
- sessionIdValue = sessionId + 256;
- } else {
- sessionIdValue = (int) sessionId;
- }
- }
- }
- print("SessionIp = %s, Status = %s, sessionId = %s", pcepSessionPeer, sessionStatus, sessionIdValue);
- }
- }
- } else {
- System.out.print("Wrong Peer IP");
- }
- }
- } else {
- if (!pcepSessionKeySet.isEmpty()) {
- for (String pcepSessionPeer : pcepSessionKeySet) {
- for (String pcepSessionId : pcepSessionIdKeySet) {
- if (pcepSessionId.equals(pcepSessionPeer)) {
- sessionId = pcepSessionIdMap.get(pcepSessionId);
- sessionStatus = pcepSessionMap.get(pcepSessionPeer);
- if (sessionId < 0) {
- sessionIdValue = sessionId + 256;
- } else {
- sessionIdValue = (int) sessionId;
- }
- }
- }
- print("SessionIp = %s, Status = %s, sessionId = %s", pcepSessionPeer, sessionStatus, sessionIdValue);
- }
- }
- }
- } catch (Exception e) {
- log.debug("Error occurred while displaying PCEP session information: {}", e.getMessage());
- }
- }
-
- private void displayPcepSessionFailureReason() {
- try {
- this.pcepClientController = get(PcepClientController.class);
- Map<String, List<String>> pcepSessionFailureReasonMap = pcepClientController.getPcepExceptions();
- pcepSessionFailurekeySet = pcepSessionFailureReasonMap.keySet();
- if (!pcepSessionFailurekeySet.isEmpty()) {
- if (peer != null) {
- if (pcepSessionFailurekeySet.contains(peer)) {
- for (String pcepSessionPeerId : pcepSessionFailurekeySet) {
- if (pcepSessionPeerId.equals(peer)) {
- pcepSessionExceptions = pcepSessionFailureReasonMap.get(pcepSessionPeerId);
- print("PeerId = %s, FailureReason = %s", pcepSessionPeerId, pcepSessionExceptions);
- }
- }
- } else {
- System.out.print("Wrong Peer IP");
- }
-
- } else {
- pcepSessionFailurekeySet = pcepSessionFailureReasonMap.keySet();
- if (!pcepSessionFailurekeySet.isEmpty()) {
- for (String pcepSessionPeerId : pcepSessionFailurekeySet) {
- pcepSessionExceptions = pcepSessionFailureReasonMap.get(pcepSessionPeerId);
- print("PeerId = %s, FailureReason = %s", pcepSessionPeerId, pcepSessionExceptions);
- }
- }
- }
-
- }
-
-
- } catch (Exception e) {
- log.debug("Error occurred while displaying PCEP session failure reasons: {}", e.getMessage());
- }
-
- }
-
-
- private void displayPcepErrorMsgs() {
- try {
- this.pcepClientController = get(PcepClientController.class);
- Map<Integer, Integer> pcepErrorMsgMap = pcepClientController.getPcepErrorMsg();
- pcepErrorMsgKey = pcepErrorMsgMap.keySet();
- if (!pcepErrorMsgKey.isEmpty()) {
- for (Integer errorType : pcepErrorMsgKey) {
- pcepErrorValue = pcepErrorMsgMap.get(errorType);
- pcepErrorType = PcepErrorType.values()[errorType];
- switch (pcepErrorType) {
- case SESSIONESTABLISHMENTFAILURE:
- sessionEstablishmentFailureMap = pcepErrorDetail.sessionEstablishmentFailure();
- Set<Integer> sessionFailureKeySet = sessionEstablishmentFailureMap.keySet();
- for (Integer sessionFailureKey : sessionFailureKeySet) {
- if (sessionFailureKey.equals(pcepErrorValue)) {
- System.out.print(sessionEstablishmentFailureMap.get(sessionFailureKey));
- }
- }
- break;
- case CAPABALITYNOTSUPPORTED:
- System.out.print("Capability not supported");
- break;
- case UNKNOWNOBJECT:
- unknownObjectMap = pcepErrorDetail.unknownObject();
- Set<Integer> unknownObjectKeySet = unknownObjectMap.keySet();
- for (Integer unknownObjectKey : unknownObjectKeySet) {
- if (unknownObjectKey.equals(pcepErrorValue)) {
- System.out.print(unknownObjectMap.get(unknownObjectKey));
- }
- }
- break;
- case NOTSUPPORTEDOBJECT:
- notSupportedObjectMap = pcepErrorDetail.notSupportedObject();
- Set<Integer> notSupportedObjectKeySet = notSupportedObjectMap.keySet();
- for (Integer notSupportedObjectKey : notSupportedObjectKeySet) {
- if (notSupportedObjectKey.equals(pcepErrorValue)) {
- System.out.print(notSupportedObjectMap.get(notSupportedObjectKey));
- }
- }
- break;
- case POLICYVIOLATION:
- policyViolationMap = pcepErrorDetail.policyViolation();
- Set<Integer> policyViolationKeySet = policyViolationMap.keySet();
- for (Integer policyViolationKey : policyViolationKeySet) {
- if (policyViolationKey.equals(pcepErrorValue)) {
- System.out.print(policyViolationMap.get(policyViolationKey));
- }
- }
- break;
- case MANDATORYOBJECTMISSING:
- mandatoryObjectMissingMap = pcepErrorDetail.mandatoryObjectMissing();
- Set<Integer> mandatoryObjectMissingKeySet = mandatoryObjectMissingMap.keySet();
- for (Integer mandatoryObjectMissingKey : mandatoryObjectMissingKeySet) {
- if (mandatoryObjectMissingKey.equals(pcepErrorValue)) {
- System.out.print(mandatoryObjectMissingMap.get(mandatoryObjectMissingKey));
- }
- }
- break;
- case SYNCHRONIZEDPATHCOMPUTATIONREQUESTMISSING:
- System.out.print("Synchronized path computation request missing");
- break;
- case UNKNOWNREQUESTREFERENCE:
- System.out.print("Unknown request reference");
- break;
- case ESTABLISHINGSECONDPCEPSESSION:
- System.out.print("Attempt to establish a second PCEP session");
- break;
- case RECEPTIONOFINVALIDOBJECT:
- receptionOfInvalidObjectMap = pcepErrorDetail.receptionOfInvalidObject();
- Set<Integer> receptionOfInvalidObjectKeySet = receptionOfInvalidObjectMap.keySet();
- for (Integer receptionOfInvalidObjectKey : receptionOfInvalidObjectKeySet) {
- if (receptionOfInvalidObjectKey.equals(pcepErrorValue)) {
- System.out.print(receptionOfInvalidObjectMap.get(receptionOfInvalidObjectKey));
- }
- }
- break;
- case INVALIDOPERATION:
- invalidOperationMap = pcepErrorDetail.invalidOperation();
- Set<Integer> invalidOperationKeySet = invalidOperationMap.keySet();
- for (Integer invalidOperationKey : invalidOperationKeySet) {
- if (invalidOperationKey.equals(pcepErrorValue)) {
- System.out.print(invalidOperationMap.get(invalidOperationKey));
- }
- }
- break;
- case VIRTUALNETWORKTLVMISSING:
- System.out.print("VIRTUAL-NETWORK TLV missing");
- break;
- default:
- System.out.print("Unknown error message");
- break;
- }
- }
- }
- } catch (Exception e) {
- log.debug("Error occurred while displaying PCEP error messages received: {}", e.getMessage());
- }
- }
-}
diff --git a/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/package-info.java b/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/package-info.java
deleted file mode 100644
index 09ceb42..0000000
--- a/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * PCEP CLI.
- */
-package org.onosproject.pcep.cli;
diff --git a/providers/pcep/topology/BUILD b/providers/pcep/topology/BUILD
deleted file mode 100644
index 753bb67..0000000
--- a/providers/pcep/topology/BUILD
+++ /dev/null
@@ -1,20 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + NETTY + JACKSON + [
- "@io_netty_netty//jar",
- "//protocols/ovsdb/api:onos-protocols-ovsdb-api",
- "//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc",
- "//apps/pcep-api:onos-apps-pcep-api",
- "//protocols/pcep/server/api:onos-protocols-pcep-server-api",
- "//protocols/pcep/pcepio:onos-protocols-pcep-pcepio",
- "//core/api:onos-api-tests",
- "//apps/optical-model:onos-apps-optical-model",
-]
-
-TEST_DEPS = TEST + [
- "//protocols/pcep/server/api:onos-protocols-pcep-server-api-tests",
- "//apps/pcep-api:onos-apps-pcep-api-tests",
-]
-
-osgi_jar_with_tests(
- test_deps = TEST_DEPS,
- deps = COMPILE_DEPS,
-)
diff --git a/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/PcepTopologyProvider.java b/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/PcepTopologyProvider.java
deleted file mode 100644
index 26d6968..0000000
--- a/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/PcepTopologyProvider.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.pcep.topology.impl;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onlab.packet.ChassisId;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link.Type;
-import org.onosproject.net.SparseAnnotations;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigRegistry;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.config.basics.SubjectFactories;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DefaultDeviceDescription;
-import org.onosproject.net.device.DefaultPortDescription;
-import org.onosproject.net.device.DeviceDescription;
-import org.onosproject.net.device.DeviceProvider;
-import org.onosproject.net.device.DeviceProviderRegistry;
-import org.onosproject.net.device.DeviceProviderService;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.link.DefaultLinkDescription;
-import org.onosproject.net.link.LinkDescription;
-import org.onosproject.net.link.LinkProvider;
-import org.onosproject.net.link.LinkProviderRegistry;
-import org.onosproject.net.link.LinkProviderService;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pcep.api.DeviceCapability;
-import org.onosproject.pcep.api.PcepController;
-import org.onosproject.pcep.api.PcepDpid;
-import org.onosproject.pcep.api.PcepLink;
-import org.onosproject.pcep.api.PcepLinkListener;
-import org.onosproject.pcep.api.PcepOperator.OperationType;
-import org.onosproject.pcep.api.PcepSwitch;
-import org.onosproject.pcep.api.PcepSwitchListener;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepClient;
-import org.onosproject.pcep.server.PcepClientController;
-import org.onosproject.pcep.server.PcepNodeListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.net.DeviceId.deviceId;
-import static org.onosproject.pcep.api.PcepDpid.uri;
-
-/**
- * Provider which uses an PCEP controller to detect network infrastructure
- * topology.
- */
-@Component(immediate = true)
-public class PcepTopologyProvider extends AbstractProvider
- implements LinkProvider, DeviceProvider {
-
- /**
- * Creates instance of PCEP topology provider.
- */
- public PcepTopologyProvider() {
- //In BGP-PCEP app, since both BGP and PCEP topology provider have same scheme
- //so BGP will be primary and PCEP topology provider will be ancillary.
- super(new ProviderId("l3", "org.onosproject.provider.bgp", true));
- }
-
- private static final Logger log = LoggerFactory
- .getLogger(PcepTopologyProvider.class);
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LinkProviderRegistry linkProviderRegistry;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceProviderRegistry deviceProviderRegistry;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PcepController controller;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceService deviceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PcepClientController pcepClientController;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigRegistry netConfigRegistry;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected NetworkConfigService netConfigService;
-
- private DeviceProviderService deviceProviderService;
- private LinkProviderService linkProviderService;
-
- private HashMap<Long, List<PortDescription>> portMap = new HashMap<>();
- private InternalLinkProvider listener = new InternalLinkProvider();
-
- private final ConfigFactory<DeviceId, DeviceCapability> configFactory =
- new ConfigFactory<DeviceId, DeviceCapability>(SubjectFactories.DEVICE_SUBJECT_FACTORY,
- DeviceCapability.class, "deviceCapability", false) {
- @Override
- public DeviceCapability createConfig() {
- return new DeviceCapability();
- }
- };
-
- @Activate
- public void activate() {
- linkProviderService = linkProviderRegistry.register(this);
- deviceProviderService = deviceProviderRegistry.register(this);
- controller.addListener(listener);
- controller.addLinkListener(listener);
- pcepClientController.addNodeListener(listener);
- netConfigRegistry.registerConfigFactory(configFactory);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- linkProviderRegistry.unregister(this);
- linkProviderService = null;
- controller.removeListener(listener);
- controller.removeLinkListener(listener);
- pcepClientController.removeNodeListener(listener);
- netConfigRegistry.unregisterConfigFactory(configFactory);
- log.info("Stopped");
- }
-
- private List<PortDescription> buildPortDescriptions(PcepDpid dpid,
- Port port) {
-
- List<PortDescription> portList;
-
- if (portMap.containsKey(dpid.value())) {
- portList = portMap.get(dpid.value());
- } else {
- portList = new ArrayList<>();
- }
- if (port != null) {
- SparseAnnotations annotations = DefaultAnnotations.builder()
- .putAll(port.annotations()).build();
- portList.add(DefaultPortDescription.builder()
- .withPortNumber(port.number())
- .isEnabled(port.isEnabled())
- .type(port.type())
- .portSpeed(port.portSpeed())
- .annotations(annotations)
- .build());
- }
-
- portMap.put(dpid.value(), portList);
- return portList;
- }
-
- /**
- * Build a link description from a pcep link.
- *
- * @param pceLink pcep link
- * @return LinkDescription onos link description
- */
- private LinkDescription buildLinkDescription(PcepLink pceLink) {
- LinkDescription ld;
- checkNotNull(pceLink);
- DeviceId srcDeviceID = deviceId(uri(pceLink.linkSrcDeviceID()));
- DeviceId dstDeviceID = deviceId(uri(pceLink.linkDstDeviceId()));
-
- deviceProviderService
- .updatePorts(srcDeviceID,
- buildPortDescriptions(pceLink.linkSrcDeviceID(),
- pceLink.linkSrcPort()));
-
- deviceProviderService
- .updatePorts(dstDeviceID,
- buildPortDescriptions(pceLink.linkDstDeviceId(),
- pceLink.linkDstPort()));
-
- ConnectPoint src = new ConnectPoint(srcDeviceID, pceLink.linkSrcPort().number());
-
- ConnectPoint dst = new ConnectPoint(dstDeviceID, pceLink.linkDstPort().number());
-
- DefaultAnnotations extendedAttributes = DefaultAnnotations
- .builder()
- .set("subType", String.valueOf(pceLink.linkSubType()))
- .set("workState", pceLink.linkState())
- .set("distance", String.valueOf(pceLink.linkDistance()))
- .set("capType", pceLink.linkCapacityType().toLowerCase())
- .set("avail_" + pceLink.linkCapacityType().toLowerCase(),
- String.valueOf(pceLink.linkAvailValue()))
- .set("max_" + pceLink.linkCapacityType().toLowerCase(),
- String.valueOf(pceLink.linkMaxValue())).build();
- // construct the link
- ld = new DefaultLinkDescription(src, dst, Type.OPTICAL, extendedAttributes);
- return ld;
- }
-
- private class InternalLinkProvider
- implements PcepSwitchListener, PcepLinkListener, PcepNodeListener {
-
- @Override
- public void switchAdded(PcepDpid dpid) {
- if (deviceProviderService == null) {
- return;
- }
- DeviceId deviceId = deviceId(uri(dpid));
- PcepSwitch sw = controller.getSwitch(dpid);
- checkNotNull(sw, "device should not null.");
- // The default device type is switch.
- ChassisId cId = new ChassisId(dpid.value());
- Device.Type deviceType;
-
- switch (sw.getDeviceType()) {
- case ROADM:
- deviceType = Device.Type.ROADM;
- break;
- case OTN:
- deviceType = Device.Type.SWITCH;
- break;
- case ROUTER:
- deviceType = Device.Type.ROUTER;
- break;
- default:
- deviceType = Device.Type.OTHER;
- }
-
- DeviceDescription description = new DefaultDeviceDescription(
- deviceId.uri(),
- deviceType,
- sw.manufacturerDescription(),
- sw.hardwareDescription(),
- sw.softwareDescription(),
- sw.serialNumber(),
- cId);
- deviceProviderService.deviceConnected(deviceId, description);
-
- }
-
- @Override
- public void switchRemoved(PcepDpid dpid) {
- if (deviceProviderService == null || linkProviderService == null) {
- return;
- }
- deviceProviderService.deviceDisconnected(deviceId(uri(dpid)));
-
- linkProviderService.linksVanished(DeviceId.deviceId(uri(dpid)));
- }
-
- @Override
- public void switchChanged(PcepDpid dpid) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void handlePceplink(PcepLink link) {
-
- OperationType operType = link.getOperationType();
- LinkDescription ld = buildLinkDescription(link);
- if (ld == null) {
- log.error("Invalid link info.");
- return;
- }
- switch (operType) {
- case ADD:
- case UPDATE:
- linkProviderService.linkDetected(ld);
- break;
-
- case DELETE:
- linkProviderService.linkVanished(ld);
- break;
-
- default:
- break;
-
- }
- }
-
- @Override
- public void addDevicePcepConfig(PcepClient pc) {
- if (netConfigRegistry == null) {
- log.error("Cannot add PCEP device capability as network config service is not available.");
- return;
- }
- DeviceId pccDeviceId = DeviceId.deviceId(String.valueOf(pc.getPccId().ipAddress()));
- DeviceCapability deviceCap = netConfigService.addConfig(pccDeviceId, DeviceCapability.class);
- deviceCap.setLabelStackCap(pc.capability().labelStackCapability())
- .setLocalLabelCap(pc.capability().pceccCapability())
- .setSrCap(pc.capability().srCapability())
- .apply();
- }
-
- @Override
- public void deleteDevicePcepConfig(PccId pccId) {
- if (netConfigRegistry == null) {
- log.error("Cannot remove PCEP device capability as network config service is not available.");
- return;
- }
- DeviceId pccDeviceId = DeviceId.deviceId(String.valueOf(pccId.ipAddress()));
- netConfigService.removeConfig(pccDeviceId, DeviceCapability.class);
- }
- }
-
- @Override
- public void triggerProbe(DeviceId deviceId) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void roleChanged(DeviceId deviceId, MastershipRole newRole) {
- }
-
- @Override
- public boolean isReachable(DeviceId deviceId) {
- // TODO Auto-generated method stub
- return true;
- }
-
- @Override
- public void changePortState(DeviceId deviceId, PortNumber portNumber,
- boolean enable) {
- // TODO Auto-generated method stub
- }
-}
diff --git a/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/package-info.java b/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/package-info.java
deleted file mode 100644
index 7f6be53..0000000
--- a/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- *Provider that uses PCEP controller as a means of infrastructure topology discovery.
- */
-package org.onosproject.provider.pcep.topology.impl;
\ No newline at end of file
diff --git a/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepTopologyProviderTest.java b/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepTopologyProviderTest.java
deleted file mode 100644
index 84231e0..0000000
--- a/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepTopologyProviderTest.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- */
-package org.onosproject.provider.pcep.topology.impl;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.ChassisId;
-import org.onlab.packet.IpAddress;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultDevice;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.config.Config;
-import org.onosproject.net.config.ConfigApplyDelegate;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigRegistryAdapter;
-import org.onosproject.net.device.DeviceDescription;
-import org.onosproject.net.device.DeviceProvider;
-import org.onosproject.net.device.DeviceProviderRegistry;
-import org.onosproject.net.device.DeviceProviderService;
-import org.onosproject.net.device.DeviceServiceAdapter;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.device.PortStatistics;
-import org.onosproject.net.link.LinkDescription;
-import org.onosproject.net.link.LinkProvider;
-import org.onosproject.net.link.LinkProviderRegistry;
-import org.onosproject.net.link.LinkProviderService;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pcep.api.DeviceCapability;
-import org.onosproject.pcep.api.PcepControllerAdapter;
-import org.onosproject.pcep.server.ClientCapability;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepClient;
-import org.onosproject.pcep.server.PcepClientControllerAdapter;
-import org.onosproject.pcep.server.PcepNodeListener;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNull.nullValue;
-import static org.onosproject.net.Link.State.ACTIVE;
-/**
- * Test for PCEP topology provider.
- */
-public class PcepTopologyProviderTest {
- private static final String UNKNOWN = "unknown";
- public static ProviderId providerId = new ProviderId("l3", "foo");
- private final PcepClientControllerAdapter clientController = new PcepClientControllerAdapter();
- private final PcepTopologyProvider provider = new PcepTopologyProvider();
- private final MockDeviceRegistry nodeRegistry = new MockDeviceRegistry();
- private final PcepControllerAdapter controller = new PcepControllerAdapter();
- private final MockLinkRegistry linkRegistry = new MockLinkRegistry();
- private final MockDeviceService deviceService = new MockDeviceService();
- private final MockNetConfigRegistryAdapter netConfigRegistry = new MockNetConfigRegistryAdapter();
- private Map<DeviceId, Device> deviceMap = new HashMap<>();
-
- @Before
- public void startUp() {
- provider.pcepClientController = clientController;
- provider.deviceProviderRegistry = nodeRegistry;
- provider.linkProviderRegistry = linkRegistry;
- provider.controller = controller;
- provider.deviceService = deviceService;
- provider.netConfigRegistry = netConfigRegistry;
- provider.netConfigService = netConfigRegistry;
- provider.activate();
- }
-
- @After
- public void tearDown() {
- provider.deactivate();
- provider.deviceProviderRegistry = null;
- provider.pcepClientController = null;
- provider.linkProviderRegistry = null;
- provider.controller = null;
- provider.deviceService = null;
- provider.netConfigRegistry = null;
- provider.netConfigService = null;
- }
-
- /* Class implement device test registry */
- private class MockLinkRegistry implements LinkProviderRegistry {
- LinkProvider linkProvider;
- Set<Link> links = new HashSet<>();
-
- @Override
- public LinkProviderService register(LinkProvider provider) {
- this.linkProvider = provider;
- return new MockProviderService();
- }
-
- @Override
- public void unregister(LinkProvider provider) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public Set<ProviderId> getProviders() {
- return null;
- }
-
- private class MockProviderService implements LinkProviderService {
-
- @Override
- public void linkDetected(LinkDescription linkDescription) {
- links.add(DefaultLink.builder().src(linkDescription.src())
- .dst(linkDescription.dst()).state(ACTIVE).type(linkDescription.type())
- .providerId(ProviderId.NONE).build());
- }
-
- @Override
- public void linkVanished(LinkDescription linkDescription) {
- links.remove(DefaultLink.builder().src(linkDescription.src())
- .dst(linkDescription.dst()).state(ACTIVE).type(linkDescription.type())
- .providerId(ProviderId.NONE).build());
- }
-
- @Override
- public void linksVanished(ConnectPoint connectPoint) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void linksVanished(DeviceId deviceId) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public LinkProvider provider() {
- // TODO Auto-generated method stub
- return null;
- }
- }
- }
-
- /* Class implement device test registry */
- private class MockDeviceRegistry implements DeviceProviderRegistry {
- DeviceProvider provider;
-
- Set<DeviceId> connected = new HashSet<>();
-
- @Override
- public DeviceProviderService register(DeviceProvider provider) {
- this.provider = provider;
- return new MockProviderService();
- }
-
- @Override
- public void unregister(DeviceProvider provider) {
- }
-
- @Override
- public Set<ProviderId> getProviders() {
- return null;
- }
-
- private class MockProviderService implements DeviceProviderService {
-
- @Override
- public DeviceProvider provider() {
- return null;
- }
-
- @Override
- public void deviceConnected(DeviceId deviceId, DeviceDescription deviceDescription) {
- connected.add(deviceId);
- Device device = new DefaultDevice(ProviderId.NONE, deviceId, Device.Type.ROUTER, UNKNOWN, UNKNOWN,
- UNKNOWN, UNKNOWN, new ChassisId(), deviceDescription.annotations());
- deviceMap.put(deviceId, device);
- }
-
- @Override
- public void deviceDisconnected(DeviceId deviceId) {
- connected.remove(deviceId);
- deviceMap.remove(deviceId);
- }
-
- @Override
- public void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void portStatusChanged(DeviceId deviceId, PortDescription portDescription) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void receivedRoleReply(DeviceId deviceId, MastershipRole requested, MastershipRole response) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void updatePortStatistics(DeviceId deviceId, Collection<PortStatistics> portStatistics) {
- // TODO Auto-generated method stub
- }
- }
- }
-
- /* Mock test for device service */
- private class MockDeviceService extends DeviceServiceAdapter {
- @Override
- public Device getDevice(DeviceId deviceId) {
- return deviceMap.get(deviceId);
- }
- }
-
- /* Mock test for device service */
- private class MockNetConfigRegistryAdapter extends NetworkConfigRegistryAdapter {
- private ConfigFactory cfgFactory;
- private Map<DeviceId, DeviceCapability> classConfig = new HashMap<>();
-
- @Override
- public void registerConfigFactory(ConfigFactory configFactory) {
- cfgFactory = configFactory;
- }
-
- @Override
- public void unregisterConfigFactory(ConfigFactory configFactory) {
- cfgFactory = null;
- }
-
- @Override
- public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) {
- if (configClass == DeviceCapability.class) {
- DeviceCapability devCap = new DeviceCapability();
- classConfig.put((DeviceId) subject, devCap);
-
- JsonNode node = new ObjectNode(new MockJsonNode());
- ObjectMapper mapper = new ObjectMapper();
- ConfigApplyDelegate delegate = new InternalApplyDelegate();
- devCap.init((DeviceId) subject, null, node, mapper, delegate);
- return (C) devCap;
- }
-
- return null;
- }
-
- @Override
- public <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass) {
- classConfig.remove(subject);
- }
-
- @Override
- public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) {
- if (configClass == DeviceCapability.class) {
- return (C) classConfig.get(subject);
- }
- return null;
- }
-
- private class MockJsonNode extends JsonNodeFactory {
- }
-
- // Auxiliary delegate to receive notifications about changes applied to
- // the network configuration - by the apps.
- private class InternalApplyDelegate implements ConfigApplyDelegate {
- @Override
- public void onApply(Config config) {
- //configs.put(config.subject(), config.node());
- }
- }
- }
-
- /**
- * Adds the PCEP device with SR, label stack and local label capabilities and deletes the device.
- */
- @Test
- public void testPcepTopologyProviderTestAddDevice1() {
- PcepClient pc = clientController.getClient(PccId.pccId(IpAddress.valueOf("1.1.1.1")));
- for (PcepNodeListener l : clientController.pcepNodeListener) {
- pc.setCapability(new ClientCapability(true, true, false, true, true));
- l.addDevicePcepConfig(pc);
-
- DeviceId pccDeviceId = DeviceId.deviceId(String.valueOf(pc.getPccId().ipAddress()));
- DeviceCapability deviceCap = netConfigRegistry.getConfig(pccDeviceId, DeviceCapability.class);
- assertThat(deviceCap.srCap(), is(true));
- assertThat(deviceCap.labelStackCap(), is(true));
- assertThat(deviceCap.localLabelCap(), is(true));
-
- l.deleteDevicePcepConfig(pc.getPccId());
- deviceCap = netConfigRegistry.getConfig(pccDeviceId, DeviceCapability.class);
- assertThat(deviceCap, is(nullValue()));
- }
- }
-
- /**
- * Adds the PCEP device with SR, and local label capabilities and deletes the device.
- */
- @Test
- public void testPcepTopologyProviderTestAddDevice2() {
- PcepClient pc = clientController.getClient(PccId.pccId(IpAddress.valueOf("1.1.1.1")));
- for (PcepNodeListener l : clientController.pcepNodeListener) {
- pc.setCapability(new ClientCapability(true, true, false, false, true));
- l.addDevicePcepConfig(pc);
-
- DeviceId pccDeviceId = DeviceId.deviceId(String.valueOf(pc.getPccId().ipAddress()));
- DeviceCapability deviceCap = netConfigRegistry.getConfig(pccDeviceId, DeviceCapability.class);
- assertThat(deviceCap.srCap(), is(true));
- assertThat(deviceCap.labelStackCap(), is(false));
- assertThat(deviceCap.localLabelCap(), is(true));
-
- l.deleteDevicePcepConfig(pc.getPccId());
- deviceCap = netConfigRegistry.getConfig(pccDeviceId, DeviceCapability.class);
- assertThat(deviceCap, is(nullValue()));
- }
- }
-}
diff --git a/providers/pcep/tunnel/BUILD b/providers/pcep/tunnel/BUILD
deleted file mode 100644
index c28460d..0000000
--- a/providers/pcep/tunnel/BUILD
+++ /dev/null
@@ -1,22 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + NETTY + [
- "//protocols/ovsdb/api:onos-protocols-ovsdb-api",
- "//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc",
- "//apps/pcep-api:onos-apps-pcep-api",
- "//apps/tunnel/api:onos-apps-tunnel-api",
- "//protocols/pcep/pcepio:onos-protocols-pcep-pcepio",
- "//protocols/pcep/server/api:onos-protocols-pcep-server-api",
- "//protocols/pcep/server/ctl:onos-protocols-pcep-server-ctl",
-]
-
-TEST_DEPS = TEST_ADAPTERS + [
- "@io_netty_netty//jar",
- "@io_netty_netty_transport//jar",
- "//protocols/pcep/server/api:onos-protocols-pcep-server-api-tests",
- "//apps/pcep-api:onos-apps-pcep-api-tests",
- "//apps/tunnel/api:onos-apps-tunnel-api-tests",
-]
-
-osgi_jar_with_tests(
- test_deps = TEST_DEPS,
- deps = COMPILE_DEPS,
-)
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/OsgiPropertyConstants.java b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/OsgiPropertyConstants.java
deleted file mode 100644
index 4d7b840..0000000
--- a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/OsgiPropertyConstants.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.pcep.tunnel.impl;
-
-/**
- * Constants for default values of configurable properties.
- */
-public final class OsgiPropertyConstants {
-
- private OsgiPropertyConstants() {}
-
- public static final String POLL_FREQUENCY = "tunnelStatsPollFrequency";
- public static final int POLL_FREQUENCY_DEFAULT = 10;
-
-}
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelApiMapper.java b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelApiMapper.java
deleted file mode 100644
index ee55362..0000000
--- a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelApiMapper.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.pcep.tunnel.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelProviderService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Entity to provide tunnel DB and mapping for request/response between CORE to PCEP
- * and PCEP to PCC.
- */
-public class PcepTunnelApiMapper {
- private static final Logger log = LoggerFactory.getLogger(PcepTunnelApiMapper.class);
-
- static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep";
- // Map to store all the tunnel requests.
- private Map<Integer, PcepTunnelData> tunnelRequestQueue;
- //Map to store all core related tunnel requests.
- private Map<TunnelId, PcepTunnelData> coreTunnelRequestQueue;
- //Map to store all the created tunnels.
- private Map<Integer, PcepTunnelData> tunnelDB;
- // Map to store the tunnel ids, given by core and given by pcc.
- private Map<TunnelId, Integer> tunnelIdMap;
-
- TunnelProviderService tunnelApiMapperservice;
-
- /**
- * Default constructor.
- */
- public PcepTunnelApiMapper() {
- //TODO check if the map need to initialize
- tunnelRequestQueue = new HashMap<Integer, PcepTunnelData>();
- coreTunnelRequestQueue = new HashMap<TunnelId, PcepTunnelData>();
- tunnelDB = new HashMap<Integer, PcepTunnelData>();
- tunnelIdMap = new HashMap<TunnelId, Integer>();
- }
-
- /**
- * Add tunnels to tunnel Request queues.
- *
- * @param srpId srp id
- * @param pcepTunnelData pcep tunnel data
- */
- public void addToTunnelRequestQueue(int srpId, PcepTunnelData pcepTunnelData) {
- tunnelRequestQueue.put(new Integer(srpId), pcepTunnelData);
- log.debug("Tunnel Added to TunnelRequestQueue");
- }
-
- /**
- * Map between Tunnel ID and pcc provided Tunnel ID.
- *
- * @param pcepTunnelData pcep tunnel data
- */
- public void addToTunnelIdMap(PcepTunnelData pcepTunnelData) {
- int value = pcepTunnelData.statefulIpv4IndentifierTlv().getTunnelId() & 0xFFFF;
- tunnelIdMap.put(pcepTunnelData.tunnel().tunnelId(), (new Integer(value)));
- log.debug("Tunnel ID Added to tunnelIdMap");
- }
-
- /**
- * Add tunnels to core tunnel request queue.
- *
- * @param pcepTunnelData pcep tunnel data
- */
- public void addToCoreTunnelRequestQueue(PcepTunnelData pcepTunnelData) {
- coreTunnelRequestQueue.put(pcepTunnelData.tunnel().tunnelId(), pcepTunnelData);
- log.debug("Tunnel Added to CoreTunnelRequestQueue");
- }
-
- /**
- * Removes tunnels from the core tunnel request queue.
- *
- * @param tunnelId tunnel id
- */
- public void removeFromCoreTunnelRequestQueue(TunnelId tunnelId) {
- coreTunnelRequestQueue.remove(tunnelId);
- log.debug("Tunnnel create response sent to core and removed from CoreTunnelRequestQueue");
- }
-
- /**
- * Handle the report which comes after initiate message.
- *
- * @param srpId srp id
- * @param pcepTunnelData pcep tunnel data
- */
- public void handleCreateTunnelRequestQueue(int srpId, PcepTunnelData pcepTunnelData) {
-
- int value = tunnelIdMap.get(pcepTunnelData.tunnel().tunnelId());
- tunnelDB.put(new Integer(value), pcepTunnelData);
- tunnelRequestQueue.remove(new Integer(srpId), pcepTunnelData);
- log.debug("Tunnel Added to TunnelDBQueue and removed from TunnelRequestQueue. tunnel id {}"
- + (new Integer(value)).toString());
- }
-
- /**
- * Handle report which comes for update message.
- *
- * @param srpId srp id
- * @param pcepTunnelData pcep tunnel data
- */
- public void handleUpdateTunnelRequestQueue(int srpId, PcepTunnelData pcepTunnelData) {
- if (pcepTunnelData.rptFlag()) {
- pcepTunnelData.setRptFlag(false);
- int value = tunnelIdMap.get(pcepTunnelData.tunnel().tunnelId());
- tunnelDB.put(new Integer(value), pcepTunnelData);
- tunnelRequestQueue.remove(new Integer(srpId), pcepTunnelData);
- log.debug("Tunnel Added to TunnelDBQueue and removed from TunnelRequestQueue. tunnel id {}",
- (new Integer(value)).toString());
- } else {
- pcepTunnelData.setRptFlag(true);
- tunnelRequestQueue.put(new Integer(srpId), pcepTunnelData);
- log.debug("Tunnel updated in TunnelRequestQueue");
- }
- }
-
- /**
- * Handle report for tunnel Release request.
- *
- * @param srpId srp id
- * @param pcepTunnelData pcep tunnel data
- */
- public void handleRemoveFromTunnelRequestQueue(int srpId, PcepTunnelData pcepTunnelData) {
-
- int value = tunnelIdMap.get(pcepTunnelData.tunnel().tunnelId());
- tunnelIdMap.remove(pcepTunnelData.tunnel().tunnelId());
- tunnelDB.remove(new Integer(value));
- tunnelRequestQueue.remove(srpId);
- log.debug("Tunnel removed from TunnelDBQueue and TunnelRequestQueue");
- }
-
- /**
- * Returns PcepTunnelData from the tunnel request queue.
- *
- * @param srpId srp id
- * @return PcepTunnelData pcep tunnel data
- */
- public PcepTunnelData getDataFromTunnelRequestQueue(int srpId) {
- return tunnelRequestQueue.get(new Integer(srpId));
-
- }
-
- /**
- * Returns PcepTunnelData from the tunnel DB.
- *
- * @param tunnelId tunnel id
- * @return PcepTunnelData pcep tunnel data
- */
- public PcepTunnelData getDataFromTunnelDBQueue(TunnelId tunnelId) {
- int value = tunnelIdMap.get(tunnelId);
- return tunnelDB.get((new Integer(value)));
- }
-
- /**
- * Checks whether the tunnel exist in tunnel request queue.
- *
- * @param srpId srp id
- * @return true if tunnel exist in reuest queue, false otherwise
- */
- public boolean checkFromTunnelRequestQueue(int srpId) {
- boolean retValue = tunnelRequestQueue.containsKey(srpId);
- return retValue;
- }
-
- /**
- * Returns whether tunnel exist in tunnel db.
- *
- * @param tunnelId tunnel id
- * @return true/false if the tunnel exists in the tunnel db
- */
- public boolean checkFromTunnelDBQueue(TunnelId tunnelId) {
- int value = tunnelIdMap.get(tunnelId);
- boolean retValue = tunnelDB.containsKey((new Integer(value)));
- return retValue;
- }
-}
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelData.java b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelData.java
deleted file mode 100644
index 60a8dd4..0000000
--- a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelData.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.pcep.tunnel.impl;
-
-import java.util.Objects;
-
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.net.ElementId;
-import org.onosproject.net.Path;
-import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * To store all tunnel related information from Core and Path computation client.
- */
-public class PcepTunnelData {
-
- private Tunnel tunnel;
- private Path path;
- private int plspId;
- private ElementId elementId;
- private RequestType requestType;
- private boolean rptFlag;
-
- // data need to store from LSP object
- private boolean lspAFlag;
- private boolean lspDFlag;
- private byte lspOFlag;
- private short tunnelId;
- private int extTunnelId;
- private short lspId;
- private StatefulIPv4LspIdentifiersTlv statefulIpv4IndentifierTlv;
-
- /**
- * Default constructor.
- */
- public PcepTunnelData() {
- this.elementId = null;
- this.tunnel = null;
- this.path = null;
- this.requestType = null;
- this.rptFlag = false;
- this.plspId = 0;
- }
-
- /**
- * Constructor to initialize Tunnel, Path and Request type.
- *
- * @param tunnel mpls tunnel
- * @param path Path in network
- * @param requestType request type for tunnel
- */
- public PcepTunnelData(Tunnel tunnel, Path path, RequestType requestType) {
- this.tunnel = tunnel;
- this.path = path;
- this.requestType = requestType;
- }
-
- /**
- * Constructor to initialize ElemendId, Tunnel, Path and Request type.
- *
- * @param elementId Ip element id
- * @param tunnel mpls tunnel
- * @param path Path in network
- * @param requestType request type for tunnel
- */
- public PcepTunnelData(ElementId elementId, Tunnel tunnel, Path path, RequestType requestType) {
- this.elementId = elementId;
- this.tunnel = tunnel;
- this.path = path;
- this.requestType = requestType;
- }
-
- /**
- * Constructor to initialize Tunnel and Request type.
- *
- * @param tunnel Tunnel from core
- * @param requestType request type for tunnel
- */
- public PcepTunnelData(Tunnel tunnel, RequestType requestType) {
- this.tunnel = tunnel;
- this.requestType = requestType;
- }
-
- /**
- * Constructor to initialize ElementId, Tunnel and Request type.
- *
- * @param elementId Ip element id
- * @param tunnel mpls tunnel
- * @param requestType request type for tunnel
- */
- public PcepTunnelData(ElementId elementId, Tunnel tunnel, RequestType requestType) {
- this.elementId = elementId;
- this.tunnel = tunnel;
- this.requestType = requestType;
- }
-
- /**
- * Sets ip element id.
- *
- * @param elementId Ip element id
- */
- public void setElementId(ElementId elementId) {
- this.elementId = elementId;
- }
-
- /**
- * Sets tunnel.
- *
- * @param tunnel mpls tunnel
- */
- public void setTunnel(Tunnel tunnel) {
- this.tunnel = tunnel;
- }
-
- /**
- * Sets Path.
- *
- * @param path Path in network
- */
- public void setPath(Path path) {
- this.path = path;
- }
-
- /**
- * Request type for tunnel.
- *
- * @param requestType request type for tunnel
- */
- public void setRequestType(RequestType requestType) {
- this.requestType = requestType;
- }
-
- /**
- * Sets plspid generated from pcc.
- *
- * @param plspId plsp identifier
- */
- public void setPlspId(int plspId) {
- this.plspId = plspId;
- }
-
- /**
- * Sets A flag from lsp object.
- *
- * @param value A flag value
- */
- public void setLspAFlag(boolean value) {
- this.lspAFlag = value;
- }
-
- /**
- * Sets OF flag from lsp object.
- *
- * @param value OF flag value
- */
- public void setLspOFlag(byte value) {
- this.lspOFlag = value;
- }
-
- /**
- * Sets tunnel id from PCC.
- *
- * @param value tunnel id value
- */
- public void setTunnelId(short value) {
- this.tunnelId = value;
- }
-
- /**
- * Sets extended tunnel id from PCC.
- *
- * @param value extended tunnel id value
- */
- public void setExtTunnelId(int value) {
- this.extTunnelId = value;
- }
-
- /**
- * Sets lsp id from pcc.
- *
- * @param value lsp id
- */
- public void setLspId(short value) {
- this.lspId = value;
- }
-
- /**
- * Sets statefulIpv4Identifiers tlv.
- * @param value statefulIpv4Identifiers tlv
- */
- public void setStatefulIpv4IndentifierTlv(StatefulIPv4LspIdentifiersTlv value) {
- this.statefulIpv4IndentifierTlv = value;
- }
-
- /**
- * Sets report flag.
- *
- * @param rptFlag report flag
- */
- public void setRptFlag(boolean rptFlag) {
- this.rptFlag = rptFlag;
- }
-
- /**
- * Sets D flag from lsp object.
- *
- * @param value D flag value
- */
- public void setLspDFlag(boolean value) {
- this.lspDFlag = value;
- }
-
- /**
- * To get Ip element id.
- *
- * @return Ip elemend id
- */
- public ElementId elementId() {
- return this.elementId;
- }
-
- /**
- * To get Tunnel.
- *
- * @return tunnel
- */
- public Tunnel tunnel() {
- return this.tunnel;
- }
-
- /**
- * To get Path.
- *
- * @return path
- */
- public Path path() {
- return this.path;
- }
-
- /**
- * To get request type.
- *
- * @return request type
- */
- public RequestType requestType() {
- return this.requestType;
- }
-
- /**
- * To get pLspId.
- *
- * @return pLspId
- */
- public int plspId() {
- return this.plspId;
- }
-
- /**
- * To get A flag.
- *
- * @return A flag
- */
- public boolean lspAFlag() {
- return this.lspAFlag;
- }
-
- /**
- * To get OF flag.
- *
- * @return OF flag
- */
- public byte lspOFlag() {
- return this.lspOFlag;
- }
-
- /**
- * To get tunnel id.
- *
- * @return tunnel id
- */
- public short tunnelId() {
- return this.tunnelId;
- }
-
- /**
- * To get extended tunnel id.
- *
- * @return extended tunnel id
- */
- public int extTunnelId() {
- return this.extTunnelId;
- }
-
- /**
- * To get pLspId.
- *
- * @return pLspId
- */
- public short lspId() {
- return this.lspId;
- }
-
- /**
- * To get D Flag.
- *
- * @return d flag
- */
- public boolean lspDFlag() {
- return this.lspDFlag;
- }
-
- /**
- * To get statefulIpv4Indentifier tlv.
- *
- * @return statefulIpv4Indentifier tlv
- */
- public StatefulIPv4LspIdentifiersTlv statefulIpv4IndentifierTlv() {
- return this.statefulIpv4IndentifierTlv;
- }
-
- /**
- * To get report flag.
- *
- * @return report flag
- */
- public boolean rptFlag() {
- return this.rptFlag;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj instanceof PcepTunnelData) {
- PcepTunnelData other = (PcepTunnelData) obj;
- return Objects.equals(tunnel, other.tunnel)
- && Objects.equals(path, other.path)
- && Objects.equals(plspId, other.plspId)
- && Objects.equals(elementId, other.elementId)
- && Objects.equals(requestType, other.requestType)
- && Objects.equals(rptFlag, other.rptFlag)
- && Objects.equals(lspAFlag, other.lspAFlag)
- && Objects.equals(lspDFlag, other.lspDFlag)
- && Objects.equals(lspOFlag, other.lspOFlag)
- && Objects.equals(tunnelId, other.tunnelId)
- && Objects.equals(extTunnelId, other.extTunnelId)
- && Objects.equals(lspId, other.lspId)
- && Objects.equals(statefulIpv4IndentifierTlv, other.statefulIpv4IndentifierTlv);
- }
-
- return false;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(tunnel, path, plspId, elementId, requestType, rptFlag, lspAFlag,
- lspDFlag, lspOFlag, tunnelId, extTunnelId, lspId, statefulIpv4IndentifierTlv);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(getClass()).add("Tunnel", tunnel)
- .add("Path", path).add("PlspId", plspId).add("ElementId", elementId)
- .add("RequestType", requestType).add("RptFlag", rptFlag).add("LspAFlag", lspAFlag)
- .add("LspDFlag", lspDFlag).add("LspOFlag", lspOFlag).add("TunnelId", tunnelId)
- .add("ExtTunnelid", extTunnelId).add("LspId", lspId)
- .add("StatefulIpv4IndentifierTlv", statefulIpv4IndentifierTlv).toString();
- }
-}
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
deleted file mode 100644
index d25c95f..0000000
--- a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
+++ /dev/null
@@ -1,1977 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.pcep.tunnel.impl;
-
-import com.google.common.collect.Maps;
-import org.onlab.graph.ScalarWeight;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cfg.ComponentConfigService;
-import org.onosproject.core.GroupId;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
-import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription;
-import org.onosproject.incubator.net.tunnel.DefaultTunnelStatistics;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.OpticalLogicId;
-import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.Tunnel.State;
-import org.onosproject.incubator.net.tunnel.TunnelAdminService;
-import org.onosproject.incubator.net.tunnel.TunnelDescription;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.incubator.net.tunnel.TunnelProvider;
-import org.onosproject.incubator.net.tunnel.TunnelProviderRegistry;
-import org.onosproject.incubator.net.tunnel.TunnelProviderService;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.incubator.net.tunnel.TunnelStatistics;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultAnnotations.Builder;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.DefaultPath;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.ElementId;
-import org.onosproject.net.IpElementId;
-import org.onosproject.net.Link;
-import org.onosproject.net.NetworkResource;
-import org.onosproject.net.Path;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.SparseAnnotations;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.link.LinkService;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pcep.api.PcepController;
-import org.onosproject.pcep.api.PcepDpid;
-import org.onosproject.pcep.api.PcepHopNodeDescription;
-import org.onosproject.pcep.api.PcepOperator.OperationType;
-import org.onosproject.pcep.api.PcepTunnel;
-import org.onosproject.pcep.api.PcepTunnel.PathState;
-import org.onosproject.pcep.api.PcepTunnel.PathType;
-import org.onosproject.pcep.api.PcepTunnelListener;
-import org.onosproject.pcep.api.PcepTunnelStatistics;
-import org.onosproject.pcep.server.LspKey;
-import org.onosproject.pcep.server.LspType;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepClient;
-import org.onosproject.pcep.server.PcepClientController;
-import org.onosproject.pcep.server.PcepClientListener;
-import org.onosproject.pcep.server.PcepEventListener;
-import org.onosproject.pcep.server.PcepLspStatus;
-import org.onosproject.pcep.server.PcepLspSyncAction;
-import org.onosproject.pcep.server.PcepSyncStatus;
-import org.onosproject.pcep.server.SrpIdGenerators;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
-import org.onosproject.pcepio.protocol.PcepAttribute;
-import org.onosproject.pcepio.protocol.PcepBandwidthObject;
-import org.onosproject.pcepio.protocol.PcepEndPointsObject;
-import org.onosproject.pcepio.protocol.PcepEroObject;
-import org.onosproject.pcepio.protocol.PcepInitiateMsg;
-import org.onosproject.pcepio.protocol.PcepLspObject;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepMetricObject;
-import org.onosproject.pcepio.protocol.PcepMsgPath;
-import org.onosproject.pcepio.protocol.PcepReportMsg;
-import org.onosproject.pcepio.protocol.PcepSrpObject;
-import org.onosproject.pcepio.protocol.PcepStateReport;
-import org.onosproject.pcepio.protocol.PcepUpdateMsg;
-import org.onosproject.pcepio.protocol.PcepUpdateRequest;
-import org.onosproject.pcepio.types.IPv4SubObject;
-import org.onosproject.pcepio.types.PathSetupTypeTlv;
-import org.onosproject.pcepio.types.PcepNaiIpv4Adjacency;
-import org.onosproject.pcepio.types.PcepValueType;
-import org.onosproject.pcepio.types.SrEroSubObject;
-import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
-import org.onosproject.pcepio.types.SymbolicPathNameTlv;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Modified;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.slf4j.Logger;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static org.onlab.util.Tools.get;
-import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT;
-import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE;
-import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS;
-import static org.onosproject.net.DefaultAnnotations.EMPTY;
-import static org.onosproject.net.DeviceId.deviceId;
-import static org.onosproject.net.PortNumber.portNumber;
-import static org.onosproject.pcep.api.PcepDpid.uri;
-import static org.onosproject.pcep.server.LspType.SR_WITHOUT_SIGNALLING;
-import static org.onosproject.pcep.server.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
-import static org.onosproject.pcep.server.LspType.WITH_SIGNALLING;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.BANDWIDTH;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.COST_TYPE;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.DELEGATE;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.LOCAL_LSP_ID;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.LSP_SIG_TYPE;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.PCC_TUNNEL_ID;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.PCE_INIT;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.PLSP_ID;
-import static org.onosproject.pcep.server.PcepLspSyncAction.REMOVE;
-import static org.onosproject.pcep.server.PcepLspSyncAction.SEND_UPDATE;
-import static org.onosproject.pcepio.protocol.ver1.PcepMetricObjectVer1.IGP_METRIC;
-import static org.onosproject.pcepio.protocol.ver1.PcepMetricObjectVer1.TE_METRIC;
-import static org.onosproject.provider.pcep.tunnel.impl.OsgiPropertyConstants.POLL_FREQUENCY;
-import static org.onosproject.provider.pcep.tunnel.impl.OsgiPropertyConstants.POLL_FREQUENCY_DEFAULT;
-import static org.onosproject.provider.pcep.tunnel.impl.RequestType.CREATE;
-import static org.onosproject.provider.pcep.tunnel.impl.RequestType.DELETE;
-import static org.onosproject.provider.pcep.tunnel.impl.RequestType.LSP_STATE_RPT;
-import static org.onosproject.provider.pcep.tunnel.impl.RequestType.UPDATE;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provider which uses an PCEP controller to detect, update, create network
- * tunnels.
- */
-@Component(immediate = true, service = TunnelProvider.class,
- property = {
- POLL_FREQUENCY + ":Integer=" + POLL_FREQUENCY_DEFAULT,
- })
-public class PcepTunnelProvider extends AbstractProvider implements TunnelProvider {
-
- private static final Logger log = getLogger(PcepTunnelProvider.class);
- private static final long MAX_BANDWIDTH = 99999744;
- private static final long MIN_BANDWIDTH = 64;
- private static final String BANDWIDTH_UINT = "kbps";
- static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep";
- public static final long IDENTIFIER_SET = 0x100000000L;
- public static final long SET = 0xFFFFFFFFL;
- private static final int DELAY = 2;
- private static final int WAIT_TIME = 5;
- public static final String LSRID = "lsrId";
-
- /** Frequency (in seconds) for polling tunnel statistics. */
- private int tunnelStatsPollFrequency = POLL_FREQUENCY_DEFAULT;
-
- private static final String TUNNLE_NOT_NULL = "Create failed,The given port may be wrong or has been occupied.";
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TunnelProviderRegistry tunnelProviderRegistry;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PcepController controller;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PcepClientController pcepClientController;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TunnelService tunnelService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected ComponentConfigService cfgService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected TunnelAdminService tunnelAdminService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected MastershipService mastershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected DeviceService deviceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected LinkService linkService;
-
- TunnelProviderService service;
-
- HashMap<String, TunnelId> tunnelMap = new HashMap<>();
- HashMap<TunnelId, TunnelStatistics> tunnelStatisticsMap = new HashMap<>();
- private HashMap<String, TunnelStatsCollector> collectors = Maps.newHashMap();
-
- private InnerTunnelProvider listener = new InnerTunnelProvider();
-
- protected PcepTunnelApiMapper pcepTunnelApiMapper = new PcepTunnelApiMapper();
- private static final int DEFAULT_BANDWIDTH_VALUE = 10;
-
- /**
- * Creates a Tunnel provider.
- */
- public PcepTunnelProvider() {
- super(new ProviderId("pcep", PROVIDER_ID));
- }
-
- @Activate
- public void activate() {
- cfgService.registerProperties(getClass());
- service = tunnelProviderRegistry.register(this);
- controller.addTunnelListener(listener);
- pcepClientController.addListener(listener);
- pcepClientController.addEventListener(listener);
- tunnelService.queryAllTunnels().forEach(tunnel -> {
- String pcepTunnelId = getPcepTunnelKey(tunnel.tunnelId());
- TunnelStatsCollector tsc = new TunnelStatsCollector(pcepTunnelId, tunnelStatsPollFrequency);
- tsc.start();
- collectors.put(tunnel.tunnelId().id(), tsc);
-
- });
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- tunnelProviderRegistry.unregister(this);
- controller.removeTunnelListener(listener);
- collectors.values().forEach(TunnelStatsCollector::stop);
- pcepClientController.removeListener(listener);
- log.info("Stopped");
- }
-
- @Modified
- public void modified(ComponentContext context) {
- Dictionary<?, ?> properties = context.getProperties();
- int newTunnelStatsPollFrequency;
- try {
- String s = get(properties, POLL_FREQUENCY);
- newTunnelStatsPollFrequency = isNullOrEmpty(s) ? tunnelStatsPollFrequency : Integer.parseInt(s.trim());
-
- } catch (NumberFormatException | ClassCastException e) {
- newTunnelStatsPollFrequency = tunnelStatsPollFrequency;
- }
-
- if (newTunnelStatsPollFrequency != tunnelStatsPollFrequency) {
- tunnelStatsPollFrequency = newTunnelStatsPollFrequency;
- collectors.values().forEach(tsc -> tsc.adjustPollInterval(tunnelStatsPollFrequency));
- log.info("New setting: tunnelStatsPollFrequency={}", tunnelStatsPollFrequency);
- }
- }
-
- @Override
- public void setupTunnel(Tunnel tunnel, Path path) {
- if (tunnel.type() != MPLS) {
- log.error("Tunnel Type MPLS is only supported");
- return;
- }
-
- // check for tunnel end points
- if (!(tunnel.src() instanceof IpTunnelEndPoint) || !(tunnel.dst() instanceof IpTunnelEndPoint)) {
- log.error("Tunnel source or destination is not valid");
- return;
- }
-
- // Get the pcc client
- PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpTunnelEndPoint) tunnel.src()).ip()));
-
- if (pc == null) {
- log.error("There is no PCC connected with ip addresss {}"
- + ((IpTunnelEndPoint) tunnel.src()).ip().toString());
- return;
- }
-
- //If stateful and PC Initiation capability is not supported by client not sending Initiate msg
- //Only master will initiate setup tunnel
- if (pc.capability().pcInstantiationCapability() && mastershipService.isLocalMaster(getDevice(pc.getPccId()))) {
- pcepSetupTunnel(tunnel, path, pc);
- }
- }
-
- @Override
- public void setupTunnel(ElementId srcElement, Tunnel tunnel, Path path) {
-
- //TODO: tunnel which is passed doesn't have tunnelID
- if (tunnel.annotations().value(PLSP_ID) != null) {
- if (LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) != WITHOUT_SIGNALLING_AND_WITHOUT_SR) {
- updateTunnel(tunnel, path);
- } else {
- // Download labels and send update message.
- // To get new tunnel ID (modified tunnel ID)
- Collection<Tunnel> tunnels = tunnelService.queryTunnel(tunnel.src(), tunnel.dst());
- for (Tunnel t : tunnels) {
- if (t.state().equals(INIT) && t.tunnelName().equals(tunnel.tunnelName())) {
- tunnel = new DefaultTunnel(tunnel.providerId(), tunnel.src(),
- tunnel.dst(), tunnel.type(),
- t.state(), tunnel.groupId(),
- t.tunnelId(),
- tunnel.tunnelName(),
- tunnel.path(),
- tunnel.resource(),
- tunnel.annotations());
- break;
- }
- }
- if (!pcepClientController.allocateLocalLabel(tunnel)) {
- log.error("Unable to allocate labels for the tunnel {}.", tunnel.toString());
- }
- }
- return;
- }
-
- if (tunnel.type() != MPLS) {
- log.error("Tunnel Type MPLS is only supported");
- return;
- }
-
- // check for tunnel end points
- if (!(tunnel.src() instanceof IpTunnelEndPoint) || !(tunnel.dst() instanceof IpTunnelEndPoint)) {
- log.error("Tunnel source or destination is not valid");
- return;
- }
-
- PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpTunnelEndPoint) tunnel.src()).ip()));
-
- if (pc == null) {
- log.error("There is no PCC connected with this device {}"
- + srcElement.toString());
- return;
- }
-
- //If stateful and PC Initiation capability is not supported by client not sending Initiate msg
- //Only master will initiate setup tunnel
- if (pc.capability().pcInstantiationCapability()
- && mastershipService.isLocalMaster(getDevice(pc.getPccId()))) {
- pcepSetupTunnel(tunnel, path, pc);
- }
- }
-
- @Override
- public void releaseTunnel(Tunnel tunnel) {
-
- if (tunnel.type() != MPLS) {
- log.error("Tunnel Type MPLS is only supported");
- return;
- }
-
- // check for tunnel end points
- if (!(tunnel.src() instanceof IpTunnelEndPoint) || !(tunnel.dst() instanceof IpTunnelEndPoint)) {
- log.error("Tunnel source or destination is not valid");
- return;
- }
-
- PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpTunnelEndPoint) tunnel.src()).ip()));
-
- if (pc == null) {
- log.error("There is no PCC connected with ip addresss {}"
- + ((IpTunnelEndPoint) tunnel.src()).ip().toString());
- return;
- }
-
- //Only master will release tunnel
- if (pc.capability().pcInstantiationCapability()
- && mastershipService.isLocalMaster(getDevice(pc.getPccId()))) {
- pcepReleaseTunnel(tunnel, pc);
- }
- }
-
- @Override
- public void releaseTunnel(ElementId srcElement, Tunnel tunnel) {
- if (tunnel.type() != MPLS) {
- log.error("Tunnel Type MPLS is only supported");
- return;
- }
-
- if (!(srcElement instanceof IpElementId)) {
- log.error("Element id is not valid");
- return;
- }
-
- // check for tunnel end points
- if (!(tunnel.src() instanceof IpTunnelEndPoint) || !(tunnel.dst() instanceof IpTunnelEndPoint)) {
- log.error("Tunnel source or destination is not valid");
- return;
- }
-
- PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpElementId) srcElement).ipAddress()));
-
- if (pc == null) {
- log.error("There is no PCC connected with ip addresss {}"
- + ((IpElementId) srcElement).ipAddress().toString());
- return;
- }
-
- //Only master will release tunnel
- if (pc.capability().pcInstantiationCapability()
- && mastershipService.isLocalMaster(getDevice(pc.getPccId()))) {
- pcepReleaseTunnel(tunnel, pc);
- }
- }
-
- @Override
- public void updateTunnel(Tunnel tunnel, Path path) {
- if (tunnel.type() != MPLS) {
- log.error("Tunnel Type MPLS is only supported");
- return;
- }
-
- // check for tunnel end points
- if (!(tunnel.src() instanceof IpTunnelEndPoint) || !(tunnel.dst() instanceof IpTunnelEndPoint)) {
- log.error("Tunnel source or destination is not valid");
- return;
- }
-
- //To get new tunnel ID (modified tunnel ID)
- Collection<Tunnel> tunnels = tunnelService.queryTunnel(tunnel.src(), tunnel.dst());
- for (Tunnel t : tunnels) {
- if (t.state().equals(INIT) && t.tunnelName().equals(tunnel.tunnelName())) {
- tunnel = new DefaultTunnel(tunnel.providerId(), tunnel.src(),
- tunnel.dst(), tunnel.type(),
- t.state(), tunnel.groupId(),
- t.tunnelId(),
- tunnel.tunnelName(),
- tunnel.path(),
- tunnel.resource(),
- tunnel.annotations());
- break;
- }
- }
-
- PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpTunnelEndPoint) tunnel.src()).ip()));
-
- if (pc == null) {
- log.error("There is no PCC connected with ip addresss {}"
- + ((IpTunnelEndPoint) tunnel.src()).ip().toString());
- return;
- }
-
- //PCInitiate tunnels are always have D flag set, else check for tunnels who are delegated via LspKey
- if (pc.capability().statefulPceCapability()) {
- if (tunnel.annotations().value(PCE_INIT) != null && tunnel.annotations().value(PCE_INIT).equals("true")) {
- pcepUpdateTunnel(tunnel, path, pc);
- } else {
- // If delegation flag is set then only send update message[means delegated PCE can send update msg for
- // that LSP. If annotation is null D flag is not set else it is set.
- Short localLspId = 0;
- for (Tunnel t : tunnels) {
- if (!t.tunnelId().equals(tunnel.tunnelId()) && t.tunnelName().equals(tunnel.tunnelName())) {
- localLspId = Short.valueOf(t.annotations().value(LOCAL_LSP_ID));
- }
- }
-
- if (localLspId == 0) {
- log.error("Local LSP ID for old tunnel not found");
- return;
- }
-
- if (pc.delegationInfo(new LspKey(Integer.valueOf(tunnel.annotations().value(PLSP_ID)),
- localLspId.shortValue())) != null) {
-
- pcepUpdateTunnel(tunnel, path, pc);
- }
- }
- }
- }
-
- @Override
- public void updateTunnel(ElementId srcElement, Tunnel tunnel, Path path) {
-
- if (tunnel.type() != MPLS) {
- log.error("Tunnel Type MPLS is only supported");
- return;
- }
-
- if (!(srcElement instanceof IpElementId)) {
- log.error("Element id is not valid");
- return;
- }
-
- // check for tunnel end points
- if (!(tunnel.src() instanceof IpTunnelEndPoint) || !(tunnel.dst() instanceof IpTunnelEndPoint)) {
- log.error("Tunnel source or destination is not valid");
- return;
- }
-
- PcepClient pc = pcepClientController.getClient(PccId.pccId(((IpElementId) srcElement).ipAddress()));
-
- if (pc == null) {
- log.error("There is no PCC connected with ip addresss {}"
- + ((IpElementId) srcElement).ipAddress().toString());
- return;
- }
-
- // If delegation flag is set then only send update message[means delegated PCE can send update msg for that
- // LSP].If annotation is null D flag is not set else it is set.
- if (pc.capability().statefulPceCapability()
- && pc.delegationInfo(
- new LspKey(Integer.valueOf(tunnel.annotations().value(PLSP_ID)), Short.valueOf(tunnel
- .annotations().value(LOCAL_LSP_ID)))) != null) {
- pcepUpdateTunnel(tunnel, path, pc);
- }
- }
-
- @Override
- public TunnelId tunnelAdded(TunnelDescription tunnel) {
- return handleTunnelAdded(tunnel, null);
- }
-
- public TunnelId tunnelAdded(TunnelDescription tunnel, State tunnelState) {
- return handleTunnelAdded(tunnel, tunnelState);
- }
-
- private TunnelId handleTunnelAdded(TunnelDescription tunnel, State tunnelState) {
-
- if (tunnel.type() == MPLS) {
- pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.id());
-
- if (tunnelState == null) {
- return service.tunnelAdded(tunnel);
- } else {
- return service.tunnelAdded(tunnel, tunnelState);
- }
- }
-
- long bandwidth = Long.parseLong(tunnel.annotations().value(BANDWIDTH));
-
- if (bandwidth < MIN_BANDWIDTH || bandwidth > MAX_BANDWIDTH) {
- error("Update failed, invalid bandwidth.");
- return null;
- }
-
- // endpoints
- OpticalTunnelEndPoint src = (org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint) tunnel
- .src();
- OpticalTunnelEndPoint dst = (OpticalTunnelEndPoint) tunnel.dst();
- // devices
- DeviceId srcId = (DeviceId) src.elementId().get();
- DeviceId dstId = (DeviceId) dst.elementId().get();
-
- // ports
- long srcPort = src.portNumber().get().toLong();
- long dstPort = dst.portNumber().get().toLong();
-
- // type
- if (tunnel.type() != Tunnel.Type.VLAN) {
- error("Illegal tunnel type. Only support VLAN tunnel creation.");
- return null;
- }
-
- PcepTunnel pcepTunnel = controller.applyTunnel(srcId, dstId, srcPort,
- dstPort, bandwidth,
- tunnel.tunnelName()
- .value());
-
- checkNotNull(pcepTunnel, TUNNLE_NOT_NULL);
- TunnelDescription tunnelAdded = buildOpticalTunnel(pcepTunnel, null);
- TunnelId tunnelId = service.tunnelAdded(tunnelAdded);
-
- tunnelMap.put(String.valueOf(pcepTunnel.id()), tunnelId);
- return tunnelId;
- }
-
- private void tunnelUpdated(Tunnel tunnel, Path path, State tunnelState) {
- handleTunnelUpdate(tunnel, path, tunnelState);
- }
-
- //Handles tunnel updated using tunnel admin service[specially to update annotations].
- private void handleTunnelUpdate(Tunnel tunnel, Path path, State tunnelState) {
-
- if (tunnel.type() == MPLS) {
- pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.tunnelId());
-
- TunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), tunnel.dst(),
- tunnel.type(), tunnel.groupId(), tunnel.providerId(),
- tunnel.tunnelName(), path, tunnel.resource(),
- (SparseAnnotations) tunnel.annotations());
-
- service.tunnelUpdated(td, tunnelState);
- return;
- }
-
- Tunnel tunnelOld = tunnelQueryById(tunnel.tunnelId());
- if (tunnelOld.type() != Tunnel.Type.VLAN) {
- error("Illegal tunnel type. Only support VLAN tunnel update.");
- return;
- }
-
- long bandwidth = Long
- .parseLong(tunnel.annotations().value("bandwidth"));
- if (bandwidth < MIN_BANDWIDTH || bandwidth > MAX_BANDWIDTH) {
- error("Update failed, invalid bandwidth.");
- return;
- }
- String pcepTunnelId = getPcepTunnelKey(tunnel.tunnelId());
-
- checkNotNull(pcepTunnelId, "Invalid tunnel id");
- if (!controller.updateTunnelBandwidth(pcepTunnelId, bandwidth)) {
- error("Update failed,maybe invalid bandwidth.");
- return;
- }
- tunnelAdminService.updateTunnel(tunnel, path);
- }
-
- @Override
- public void tunnelRemoved(TunnelDescription tunnel) {
- if (tunnel.type() == MPLS) {
- pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.id());
- service.tunnelRemoved(tunnel);
- return;
- }
-
- Tunnel tunnelOld = tunnelQueryById(tunnel.id());
- checkNotNull(tunnelOld, "The tunnel id is not exsited.");
- if (tunnelOld.type() != Tunnel.Type.VLAN) {
- error("Illegal tunnel type. Only support VLAN tunnel deletion.");
- return;
- }
- String pcepTunnelId = getPcepTunnelKey(tunnel.id());
- checkNotNull(pcepTunnelId, "The tunnel id is not exsited.");
- if (!controller.deleteTunnel(pcepTunnelId)) {
- error("Delete tunnel failed, Maybe some devices have been disconnected.");
- return;
- }
- tunnelMap.remove(pcepTunnelId);
- service.tunnelRemoved(tunnel);
- }
-
- @Override
- public void tunnelUpdated(TunnelDescription tunnel) {
- handleTunnelUpdate(tunnel, null);
- }
-
- public void tunnelUpdated(TunnelDescription tunnel, State tunnelState) {
- handleTunnelUpdate(tunnel, tunnelState);
- }
-
- private void handleTunnelUpdate(TunnelDescription tunnel, State tunnelState) {
- if (tunnel.type() == MPLS) {
- pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.id());
-
- if (tunnelState == null) {
- service.tunnelUpdated(tunnel);
- } else {
- service.tunnelUpdated(tunnel, tunnelState);
- }
- return;
- }
-
- Tunnel tunnelOld = tunnelQueryById(tunnel.id());
- if (tunnelOld.type() != Tunnel.Type.VLAN) {
- error("Illegal tunnel type. Only support VLAN tunnel update.");
- return;
- }
- long bandwidth = Long
- .parseLong(tunnel.annotations().value("bandwidth"));
- if (bandwidth < MIN_BANDWIDTH || bandwidth > MAX_BANDWIDTH) {
- error("Update failed, invalid bandwidth.");
- return;
- }
- String pcepTunnelId = getPcepTunnelKey(tunnel.id());
-
- checkNotNull(pcepTunnelId, "Invalid tunnel id");
- if (!controller.updateTunnelBandwidth(pcepTunnelId, bandwidth)) {
-
- error("Update failed,maybe invalid bandwidth.");
- return;
-
- }
- service.tunnelUpdated(tunnel);
- }
-
- private void error(String info) {
- System.err.println(info);
- }
-
- // Short-hand for creating a connection point.
- private ConnectPoint connectPoint(PcepDpid id, long port) {
- return new ConnectPoint(deviceId(uri(id)), portNumber(port));
- }
-
- // Short-hand for creating a link.
- private Link link(PcepDpid src, long sp, PcepDpid dst, long dp) {
- return DefaultLink.builder()
- .providerId(id())
- .src(connectPoint(src, sp))
- .dst(connectPoint(dst, dp))
- .type(Link.Type.TUNNEL)
- .build();
- }
-
- // Creates a path that leads through the given devices.
- private Path createPath(List<PcepHopNodeDescription> hopList,
- PathType pathtype, PathState pathState) {
- if (hopList == null || hopList.isEmpty()) {
- return null;
- }
- List<Link> links = new ArrayList<>();
- for (int i = 1; i < hopList.size() - 1; i = i + 2) {
- links.add(link(hopList.get(i).getDeviceId(), hopList.get(i)
- .getPortNum(), hopList.get(i + 1).getDeviceId(), hopList
- .get(i + 1).getPortNum()));
- }
-
- int hopNum = hopList.size() - 2;
- DefaultAnnotations extendAnnotations = DefaultAnnotations.builder()
- .set("pathNum", String.valueOf(hopNum))
- .set("pathState", String.valueOf(pathState))
- .set("pathType", String.valueOf(pathtype)).build();
- return new DefaultPath(id(), links, ScalarWeight.toWeight(hopNum), extendAnnotations);
- }
-
- // convert the path description to a string.
- public String pathToString(List<Link> links) {
- StringBuilder builder = new StringBuilder();
- builder.append("{");
- for (Link link : links) {
- builder.append("(Device:" + link.src().deviceId() + " Port:"
- + link.src().port().toLong());
- builder.append(" Device:" + link.dst().deviceId() + " Port:"
- + link.dst().port().toLong());
- builder.append(")");
- }
- builder.append("}");
- return builder.toString();
- }
-
- // build a TunnelDescription.
- private TunnelDescription buildOpticalTunnel(PcepTunnel pcepTunnel,
- TunnelId tunnelId) {
- TunnelEndPoint srcPoint = null;
- TunnelEndPoint dstPoint = null;
- Tunnel.Type tunnelType = null;
- TunnelName name = TunnelName.tunnelName(pcepTunnel.name());
-
- // add path after codes of tunnel's path merged
- Path path = createPath(pcepTunnel.getHopList(),
- pcepTunnel.getPathType(),
- pcepTunnel.getPathState());
-
- OpticalTunnelEndPoint.Type endPointType = null;
- switch (pcepTunnel.type()) {
- case OCH:
- tunnelType = Tunnel.Type.OCH;
- endPointType = OpticalTunnelEndPoint.Type.LAMBDA;
- break;
-
- case OTN:
- tunnelType = Tunnel.Type.ODUK;
- endPointType = OpticalTunnelEndPoint.Type.TIMESLOT;
- break;
-
- case UNI:
- tunnelType = Tunnel.Type.VLAN;
- endPointType = null;
- break;
-
- default:
- break;
- }
- DeviceId srcDid = deviceId(uri(pcepTunnel.srcDeviceID()));
- DeviceId dstDid = deviceId(uri(pcepTunnel.dstDeviceId()));
- PortNumber srcPort = PortNumber.portNumber(pcepTunnel.srcPort());
- PortNumber dstPort = PortNumber.portNumber(pcepTunnel.dstPort());
-
- srcPoint = new DefaultOpticalTunnelEndPoint(id(), Optional.of(srcDid),
- Optional.of(srcPort), null,
- endPointType,
- OpticalLogicId.logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(id(), Optional.of(dstDid),
- Optional.of(dstPort), null,
- endPointType,
- OpticalLogicId.logicId(0),
- true);
-
- // basic annotations
- DefaultAnnotations annotations = DefaultAnnotations
- .builder()
- .set("SLA", String.valueOf(pcepTunnel.getSla()))
- .set("bandwidth",
- String.valueOf(pcepTunnel.bandWidth()) + BANDWIDTH_UINT)
- .set("index", String.valueOf(pcepTunnel.id())).build();
-
- // a VLAN tunnel always carry OCH tunnel, this annotation is the index
- // of a OCH tunnel.
- if (pcepTunnel.underlayTunnelId() != 0) {
- DefaultAnnotations extendAnnotations = DefaultAnnotations
- .builder()
- .set("underLayTunnelIndex",
- String.valueOf(pcepTunnel.underlayTunnelId())).build();
- annotations = DefaultAnnotations.merge(annotations,
- extendAnnotations);
-
- }
- TunnelDescription tunnel = new DefaultTunnelDescription(tunnelId,
- srcPoint,
- dstPoint,
- tunnelType,
- new GroupId(0),
- id(), name,
- path,
- annotations);
- return tunnel;
- }
-
- /**
- * Get the tunnelID according to the tunnel key.
- *
- * @param tunnelKey tunnel key
- * @return corresponding tunnel id of the a tunnel key.
- */
- private TunnelId getTunnelId(String tunnelKey) {
- for (String key : tunnelMap.keySet()) {
- if (key.equals(tunnelKey)) {
- return tunnelMap.get(key);
- }
- }
- return null;
- }
-
- /**
- * Get the tunnel key according to the tunnelID.
- *
- * @param tunnelId tunnel id
- * @return corresponding a tunnel key of the tunnel id.
- */
- private String getPcepTunnelKey(TunnelId tunnelId) {
- for (String key : tunnelMap.keySet()) {
- if (Objects.equals(tunnelMap.get(key).id(), tunnelId.id())) {
- return key;
- }
- }
- return null;
-
- }
-
- /**
- * Build a DefaultTunnelStatistics from a PcepTunnelStatistics.
- *
- * @param statistics statistics data from a PCEP tunnel
- * @return TunnelStatistics
- */
- private TunnelStatistics buildTunnelStatistics(PcepTunnelStatistics statistics) {
- DefaultTunnelStatistics.Builder builder = new DefaultTunnelStatistics.Builder();
- DefaultTunnelStatistics tunnelStatistics = builder.setBwUtilization(statistics.bandwidthUtilization())
- .setPacketLossRatio(statistics.packetLossRate())
- .setFlowDelay(statistics.flowDelay())
- .setAlarms(statistics.alarms())
- .build();
- return tunnelStatistics;
- }
- /**
- * Creates list of hops for ERO object from Path.
- *
- * @param path network path
- * @return list of ERO subobjects
- */
- private LinkedList<PcepValueType> createPcepPath(Path path) {
- LinkedList<PcepValueType> llSubObjects = new LinkedList<>();
- List<Link> listLink = path.links();
- ConnectPoint source = null;
- ConnectPoint destination = null;
- IpAddress ipDstAddress = null;
- IpAddress ipSrcAddress = null;
- PcepValueType subObj = null;
- long portNo;
-
- for (Link link : listLink) {
- source = link.src();
- if (!(source.equals(destination))) {
- //set IPv4SubObject for ERO object
- portNo = source.port().toLong();
- portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo;
- ipSrcAddress = Ip4Address.valueOf((int) portNo);
- subObj = new IPv4SubObject(ipSrcAddress.getIp4Address().toInt());
- llSubObjects.add(subObj);
- }
-
- destination = link.dst();
- portNo = destination.port().toLong();
- portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo;
- ipDstAddress = Ip4Address.valueOf((int) portNo);
- subObj = new IPv4SubObject(ipDstAddress.getIp4Address().toInt());
- llSubObjects.add(subObj);
- }
-
- return llSubObjects;
- }
-
- /**
- * Creates PcInitiated lsp request list for setup tunnel.
- *
- * @param tunnel mpls tunnel
- * @param path network path
- * @param pc pcep client
- * @param srpId unique id for pcep message
- * @return list of PcInitiatedLspRequest
- * @throws PcepParseException while building pcep objects fails
- */
- LinkedList<PcInitiatedLspRequest> createPcInitiatedLspReqList(Tunnel tunnel, Path path,
- PcepClient pc, int srpId)
- throws PcepParseException {
- PcepValueType tlv;
- LinkedList<PcepValueType> llSubObjects = null;
- LspType lspType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE));
-
- if (lspType == SR_WITHOUT_SIGNALLING) {
- NetworkResource labelStack = tunnel.resource();
- if (labelStack == null || !(labelStack instanceof DefaultLabelStack)) {
- labelStack = pcepClientController.computeLabelStack(tunnel.path());
- if (labelStack == null) {
- log.error("Unable to create label stack.");
- return null;
- }
- }
- llSubObjects = pcepClientController.createPcepLabelStack((DefaultLabelStack) labelStack, path);
- } else {
- llSubObjects = createPcepPath(path);
- }
-
- if (llSubObjects == null || llSubObjects.isEmpty()) {
- log.error("There is no link information to create tunnel");
- return null;
- }
-
- LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
-
- // set PathSetupTypeTlv of SRP object
- tlv = new PathSetupTypeTlv(lspType.type());
- llOptionalTlv.add(tlv);
-
- // build SRP object
- PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(srpId).setRFlag(false)
- .setOptionalTlv(llOptionalTlv).build();
-
- llOptionalTlv = new LinkedList<>();
- LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList = new LinkedList<>();
-
- // set LSP identifiers TLV
- short localLspId = 0;
- if (LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) != WITH_SIGNALLING) {
- String localLspIdString = tunnel.annotations().value(LOCAL_LSP_ID);
- if (localLspIdString != null) {
- localLspId = Short.valueOf(localLspIdString);
- }
- }
-
- tunnel.annotations().value(LSP_SIG_TYPE);
- tlv = new StatefulIPv4LspIdentifiersTlv((((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt()),
- localLspId, (short) 0, 0, (((IpTunnelEndPoint) tunnel.dst()).ip()
- .getIp4Address().toInt()));
- llOptionalTlv.add(tlv);
- //set SymbolicPathNameTlv of LSP object
- tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes());
- llOptionalTlv.add(tlv);
-
- //build LSP object
- PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true).setDFlag(true).setOFlag((byte) 0)
- .setPlspId(0).setOptionalTlv(llOptionalTlv).build();
-
- //build ENDPOINTS object
- PcepEndPointsObject endpointsobj = pc.factory().buildEndPointsObject()
- .setSourceIpAddress(((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt())
- .setDestIpAddress(((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt())
- .setPFlag(true).build();
-
- //build ERO object
- PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build();
-
- float iBandwidth = DEFAULT_BANDWIDTH_VALUE;
- if (tunnel.annotations().value(BANDWIDTH) != null) {
- iBandwidth = Float.valueOf(tunnel.annotations().value(BANDWIDTH));
- }
- // build bandwidth object
- PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build();
- // build pcep attribute
- PcepAttribute pcepAttribute = pc.factory().buildPcepAttribute().setBandwidthObject(bandwidthObject).build();
-
- PcInitiatedLspRequest initiateLspRequest = pc.factory().buildPcInitiatedLspRequest().setSrpObject(srpobj)
- .setLspObject(lspobj).setEndPointsObject(endpointsobj).setEroObject(eroobj)
- .setPcepAttribute(pcepAttribute).build();
- llPcInitiatedLspRequestList.add(initiateLspRequest);
- return llPcInitiatedLspRequestList;
- }
-
- /**
- * To send initiate tunnel message to pcc.
- *
- * @param tunnel mpls tunnel info
- * @param path explicit route for the tunnel
- * @param pc pcep client to send message
- */
- private void pcepSetupTunnel(Tunnel tunnel, Path path, PcepClient pc) {
- try {
- if (!(pc.lspDbSyncStatus().equals(PcepSyncStatus.SYNCED))) {
- log.error("Setup tunnel has failed as LSP DB sync is not finished");
- return;
- }
-
- int srpId = SrpIdGenerators.create();
- Collection<Tunnel> tunnels = tunnelService.queryTunnel(tunnel.src(), tunnel.dst());
- for (Tunnel t : tunnels) {
- if (t.tunnelName().equals(tunnel.tunnelName())) {
- tunnel = new DefaultTunnel(tunnel.providerId(), tunnel.src(),
- tunnel.dst(), tunnel.type(),
- t.state(), tunnel.groupId(),
- t.tunnelId(),
- tunnel.tunnelName(),
- tunnel.path(),
- tunnel.resource(),
- tunnel.annotations());
- break;
- }
- }
-
- if (tunnel.tunnelId() == null) {
- log.error("Tunnel ID not found");
- return;
- }
-
- PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, CREATE);
-
- pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData);
-
- LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList = createPcInitiatedLspReqList(tunnel, path,
- pc, srpId);
- if (llPcInitiatedLspRequestList == null || llPcInitiatedLspRequestList.isEmpty()) {
- log.error("Failed to create PcInitiatedLspRequestList");
- return;
- }
-
- //build PCInitiate message
- PcepInitiateMsg pcInitiateMsg = pc.factory().buildPcepInitiateMsg()
- .setPcInitiatedLspRequestList(llPcInitiatedLspRequestList)
- .build();
-
- pc.sendMessage(Collections.singletonList(pcInitiateMsg));
-
- pcepTunnelApiMapper.addToTunnelRequestQueue(srpId, pcepTunnelData);
- } catch (PcepParseException e) {
- log.error("PcepParseException occurred while processing setup tunnel {}", e.getMessage());
- }
- }
-
- /**
- * To send Release tunnel message to pcc.
- *
- * @param tunnel mpls tunnel info
- * @param pc pcep client to send message
- */
- private void pcepReleaseTunnel(Tunnel tunnel, PcepClient pc) {
- try {
- if (!(pc.lspDbSyncStatus().equals(PcepSyncStatus.SYNCED))) {
- log.error("Release tunnel has failed as LSP DB sync is not finished");
- return;
- }
-
- PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, DELETE);
- pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData);
- int srpId = SrpIdGenerators.create();
-
- PcepValueType tlv;
- LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
-
- // set PathSetupTypeTlv of SRP object
- tlv = new PathSetupTypeTlv(LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE))
- .type());
- llOptionalTlv.add(tlv);
-
- // build SRP object
- PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(srpId).setRFlag(true)
- .setOptionalTlv(llOptionalTlv).build();
-
- llOptionalTlv = new LinkedList<>();
- LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList = new LinkedList<>();
-
- tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes());
- llOptionalTlv.add(tlv);
-
- String localLspIdString = tunnel.annotations().value(LOCAL_LSP_ID);
- String pccTunnelIdString = tunnel.annotations().value(PCC_TUNNEL_ID);
- String pLspIdString = tunnel.annotations().value(PLSP_ID);
-
- short localLspId = 0;
- short pccTunnelId = 0;
- int plspId = 0;
-
- if (localLspIdString != null) {
- localLspId = Short.valueOf(localLspIdString);
- }
-
- if (pccTunnelIdString != null) {
- pccTunnelId = Short.valueOf(pccTunnelIdString);
- }
-
- if (pLspIdString != null) {
- plspId = Integer.valueOf(pLspIdString);
- }
-
- tlv = new StatefulIPv4LspIdentifiersTlv((((IpTunnelEndPoint) tunnel.src())
- .ip().getIp4Address().toInt()),
- localLspId, pccTunnelId, 0, (((IpTunnelEndPoint) tunnel.dst()).ip()
- .getIp4Address().toInt()));
- llOptionalTlv.add(tlv);
-
- // build lsp object, set r flag as false to delete the tunnel
- PcepLspObject lspobj = pc.factory().buildLspObject().setRFlag(false).setPlspId(plspId)
- .setOptionalTlv(llOptionalTlv).build();
-
- PcInitiatedLspRequest releaseLspRequest = pc.factory().buildPcInitiatedLspRequest().setSrpObject(srpobj)
- .setLspObject(lspobj).build();
-
- llPcInitiatedLspRequestList.add(releaseLspRequest);
-
- PcepInitiateMsg pcInitiateMsg = pc.factory().buildPcepInitiateMsg()
- .setPcInitiatedLspRequestList(llPcInitiatedLspRequestList).build();
-
- pc.sendMessage(Collections.singletonList(pcInitiateMsg));
-
- pcepTunnelApiMapper.addToTunnelRequestQueue(srpId, pcepTunnelData);
- } catch (PcepParseException e) {
- log.error("PcepParseException occurred while processing release tunnel {}", e.getMessage());
- }
- }
-
- /**
- * To send Update tunnel request message to pcc.
- *
- * @param tunnel mpls tunnel info
- * @param path explicit route for the tunnel
- * @param pc pcep client to send message
- */
- private void pcepUpdateTunnel(Tunnel tunnel, Path path, PcepClient pc) {
- try {
- PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, UPDATE);
- pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData);
- int srpId = SrpIdGenerators.create();
- PcepValueType tlv;
-
- LinkedList<PcepValueType> llSubObjects = null;
- LspType lspSigType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE));
-
- if (lspSigType == SR_WITHOUT_SIGNALLING) {
- NetworkResource labelStack = tunnel.resource();
- if (labelStack == null || !(labelStack instanceof DefaultLabelStack)) {
- labelStack = pcepClientController.computeLabelStack(tunnel.path());
- if (labelStack == null) {
- log.error("Unable to create label stack.");
- return;
- }
- }
- llSubObjects = pcepClientController.createPcepLabelStack((DefaultLabelStack) labelStack, path);
- } else {
- llSubObjects = createPcepPath(path);
- }
-
- LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
- LinkedList<PcepUpdateRequest> llUpdateRequestList = new LinkedList<>();
-
- // set PathSetupTypeTlv of SRP object
- tlv = new PathSetupTypeTlv(lspSigType.type());
- llOptionalTlv.add(tlv);
-
- // build SRP object
- PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(srpId).setRFlag(false)
- .setOptionalTlv(llOptionalTlv).build();
-
- llOptionalTlv = new LinkedList<>();
-
- // Lsp Identifier tlv is required for all modes of lsp
- String localLspIdString = tunnel.annotations().value(LOCAL_LSP_ID);
- String pccTunnelIdString = tunnel.annotations().value(PCC_TUNNEL_ID);
- short localLspId = 0;
- short pccTunnelId = 0;
-
- if (localLspIdString != null) {
- localLspId = Short.valueOf(localLspIdString);
- }
-
- if (pccTunnelIdString != null) {
- pccTunnelId = Short.valueOf(pccTunnelIdString);
- }
-
- tlv = new StatefulIPv4LspIdentifiersTlv((((IpTunnelEndPoint) tunnel.src())
- .ip().getIp4Address().toInt()),
- localLspId, pccTunnelId,
- ((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt(),
- (((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt()));
- llOptionalTlv.add(tlv);
-
- if (tunnel.tunnelName().value() != null) {
- tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes());
- llOptionalTlv.add(tlv);
- }
- boolean delegated = (tunnel.annotations().value(DELEGATE) == null) ? false
- : Boolean.valueOf(tunnel.annotations()
- .value(DELEGATE));
- boolean initiated = (tunnel.annotations().value(PCE_INIT) == null) ? false
- : Boolean.valueOf(tunnel.annotations()
- .value(PCE_INIT));
- // build lsp object
- PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true)
- .setPlspId(Integer.valueOf(tunnel.annotations().value(PLSP_ID)))
- .setDFlag(delegated)
- .setCFlag(initiated)
- .setOptionalTlv(llOptionalTlv).build();
- // build ero object
- PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build();
- float iBandwidth = DEFAULT_BANDWIDTH_VALUE;
- if (tunnel.annotations().value(BANDWIDTH) != null) {
- iBandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH));
- }
- // build bandwidth object
- PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build();
- // build pcep attribute
- PcepAttribute pcepAttribute = pc.factory().buildPcepAttribute().setBandwidthObject(bandwidthObject).build();
- // build pcep msg path
- PcepMsgPath msgPath = pc.factory().buildPcepMsgPath().setEroObject(eroobj).setPcepAttribute(pcepAttribute)
- .build();
-
- PcepUpdateRequest updateRequest = pc.factory().buildPcepUpdateRequest().setSrpObject(srpobj)
- .setLspObject(lspobj).setMsgPath(msgPath).build();
-
- llUpdateRequestList.add(updateRequest);
-
- PcepUpdateMsg pcUpdateMsg = pc.factory().buildUpdateMsg().setUpdateRequestList(llUpdateRequestList).build();
-
- pc.sendMessage(Collections.singletonList(pcUpdateMsg));
- pcepTunnelApiMapper.addToTunnelRequestQueue(srpId, pcepTunnelData);
- } catch (PcepParseException e) {
- log.error("PcepParseException occurred while processing release tunnel {}", e.getMessage());
- }
- }
-
- private class InnerTunnelProvider implements PcepTunnelListener, PcepEventListener, PcepClientListener {
-
- @Override
- public void handlePcepTunnel(PcepTunnel pcepTunnel) {
- TunnelDescription tunnel = null;
- // instance and id identify a tunnel together
- String tunnelKey = String.valueOf(pcepTunnel.getInstance())
- + String.valueOf(pcepTunnel.id());
-
- if (tunnelKey == null || "".equals(tunnelKey)) {
- log.error("Invalid PCEP tunnel");
- return;
- }
-
- TunnelId tunnelId = getTunnelId(tunnelKey);
- tunnel = buildOpticalTunnel(pcepTunnel, tunnelId);
-
- OperationType operType = pcepTunnel.getOperationType();
- switch (operType) {
- case ADD:
- tunnelId = service.tunnelAdded(tunnel);
- tunnelMap.put(tunnelKey, tunnelId);
- break;
-
- case UPDATE:
- service.tunnelUpdated(tunnel);
- break;
-
- case DELETE:
- service.tunnelRemoved(tunnel);
- tunnelMap.remove(tunnelKey);
- break;
-
- default:
- log.error("Invalid tunnel operation");
- }
- }
-
- @Override
- public void handleMessage(PccId pccId, PcepMessage msg) {
- try {
- log.debug("tunnel provider handle message {}", msg.getType().toString());
- switch (msg.getType()) {
- case REPORT:
- int srpId = 0;
- LinkedList<PcepStateReport> llStateReportList = null;
- llStateReportList = ((PcepReportMsg) msg).getStateReportList();
- ListIterator<PcepStateReport> listIterator = llStateReportList.listIterator();
- PcepSrpObject srpObj = null;
- PcepLspObject lspObj = null;
- while (listIterator.hasNext()) {
- PcepStateReport stateRpt = listIterator.next();
- srpObj = stateRpt.getSrpObject();
- lspObj = stateRpt.getLspObject();
-
- if (srpObj != null) {
- srpId = srpObj.getSrpID();
- }
-
- log.debug("Plsp ID in handle message " + lspObj.getPlspId());
- log.debug("SRP ID in handle message " + srpId);
-
- if (!(pcepTunnelApiMapper.checkFromTunnelRequestQueue(srpId))) {
- // For PCRpt without matching SRP id.
- handleRptWithoutSrpId(stateRpt, pccId);
- continue;
- }
-
- handleReportMessage(srpId, lspObj, stateRpt);
- }
- break;
-
- default:
- log.debug("Received unsupported message type {}", msg.getType().toString());
- }
- } catch (Exception e) {
- log.error("Exception occurred while processing report message {}", e.getMessage());
- }
- }
-
- /**
- * Handles report message for setup/update/delete tunnel request.
- *
- * @param srpId unique identifier for PCEP message
- * @param lspObj LSP object
- * @param stateRpt parsed PCEP report msg.
- */
- private void handleReportMessage(int srpId, PcepLspObject lspObj, PcepStateReport stateRpt) {
- ProviderId providerId = new ProviderId("pcep", PROVIDER_ID);
- PcepTunnelData pcepTunnelData = pcepTunnelApiMapper.getDataFromTunnelRequestQueue(srpId);
-
- // store the values required from report message
- pcepTunnelData.setPlspId(lspObj.getPlspId());
- pcepTunnelData.setLspAFlag(lspObj.getAFlag());
- pcepTunnelData.setLspOFlag(lspObj.getOFlag());
- pcepTunnelData.setLspDFlag(lspObj.getDFlag());
-
- StatefulIPv4LspIdentifiersTlv ipv4LspTlv = null;
- ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator();
- while (listTlvIterator.hasNext()) {
- PcepValueType tlv = listTlvIterator.next();
- if (tlv.getType() == StatefulIPv4LspIdentifiersTlv.TYPE) {
- ipv4LspTlv = (StatefulIPv4LspIdentifiersTlv) tlv;
- break;
- }
- }
- if (ipv4LspTlv != null) {
- pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspTlv);
- }
-
- Path path = pcepTunnelData.path();
- Tunnel tunnel = pcepTunnelData.tunnel();
- Builder annotationBuilder = DefaultAnnotations.builder();
- annotationBuilder.putAll(pcepTunnelData.tunnel().annotations());
-
- // PCRpt in response to PCInitate msg will carry PLSP id allocated by PCC.
- if (tunnel.annotations().value(PLSP_ID) == null) {
- annotationBuilder.set(PLSP_ID, String.valueOf(lspObj.getPlspId()));
- }
-
- // Signalled LSPs will carry local LSP id allocated by signalling protocol(PCC).
- if (tunnel.annotations().value(LOCAL_LSP_ID) == null) {
- annotationBuilder.set(LOCAL_LSP_ID, String.valueOf(ipv4LspTlv.getLspId()));
- }
-
- if (tunnel.annotations().value(PCC_TUNNEL_ID) == null) {
- annotationBuilder.set(PCC_TUNNEL_ID, String.valueOf(ipv4LspTlv.getTunnelId()));
- }
-
- SparseAnnotations annotations = annotationBuilder.build();
- DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(),
- tunnel.dst(), tunnel.type(), tunnel.groupId(),
- providerId, tunnel.tunnelName(), path,
- tunnel.resource(), annotations);
-
- if (CREATE == pcepTunnelData.requestType()) {
- pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
- pcepTunnelApiMapper.handleCreateTunnelRequestQueue(srpId, pcepTunnelData);
- } else if (DELETE == pcepTunnelData.requestType()) {
- pcepTunnelApiMapper.handleRemoveFromTunnelRequestQueue(srpId, pcepTunnelData);
- } else if (UPDATE == pcepTunnelData.requestType()) {
- pcepTunnelData.setRptFlag(true);
- pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
- pcepTunnelApiMapper.handleUpdateTunnelRequestQueue(srpId, pcepTunnelData);
- }
-
- PcepLspStatus pcepLspStatus = PcepLspStatus.values()[lspObj.getOFlag()];
-
- if (lspObj.getRFlag()) {
- tunnelRemoved(td);
- } else {
- State tunnelState = PcepLspStatus.getTunnelStatusFromLspStatus(pcepLspStatus);
- tunnelUpdated(td, tunnelState);
- }
-
- // SR-TE also needs PCUpd msg after receiving PCRpt with status GOING-UP even
- // though there are no labels to download for SR-TE.
- if (((pcepLspStatus == PcepLspStatus.GOING_UP)
- && (LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) == SR_WITHOUT_SIGNALLING))
- // For PCInit tunnel up, few PCC expects PCUpd message after PCInit message,
- || ((tunnel.state() == State.INIT)
- && (pcepLspStatus == PcepLspStatus.DOWN)
- && (tunnel.annotations().value(PCE_INIT) != null
- && tunnel.annotations().value(PCE_INIT).equals("true"))
- && (LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) == WITH_SIGNALLING))) {
-
- // Query again to get latest tunnel updated with protocol values from PCRpt msg.
- updateTunnel(service.tunnelQueryById(tunnel.tunnelId()), tunnel.path());
- }
- }
-
- private SparseAnnotations getAnnotations(PcepLspObject lspObj, StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv,
- String bandwidth, LspType lspType, String costType, boolean isPceInit) {
- Builder builder = DefaultAnnotations.builder();
- /*
- * [RFC 5440] The absence of the METRIC object MUST be interpreted by the PCE as a path computation request
- * for which no constraints need be applied to any of the metrics.
- */
- if (costType != null) {
- builder.set(COST_TYPE, costType);
- }
-
- if (isPceInit) {
- builder.set(PCE_INIT, String.valueOf(isPceInit));
- }
-
- if (bandwidth != null) {
- builder.set(BANDWIDTH, bandwidth);
- }
-
- SparseAnnotations annotations = builder
- .set(LSP_SIG_TYPE, lspType.name())
- .set(PCC_TUNNEL_ID, String.valueOf(ipv4LspIdenTlv.getTunnelId()))
- .set(PLSP_ID, String.valueOf(lspObj.getPlspId()))
- .set(LOCAL_LSP_ID, String.valueOf(ipv4LspIdenTlv.getLspId()))
- .set(DELEGATE, String.valueOf(lspObj.getDFlag()))
- .build();
- return annotations;
- }
-
- private LspType getLspType(PcepSrpObject srpObj) {
- LspType lspType = WITH_SIGNALLING;
-
- if (null != srpObj) {
- LinkedList<PcepValueType> llOptionalTlv = srpObj.getOptionalTlv();
- ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
-
- while (listIterator.hasNext()) {
- PcepValueType tlv = listIterator.next();
- switch (tlv.getType()) {
- case PathSetupTypeTlv.TYPE:
- lspType = LspType.values()[Integer.valueOf(((PathSetupTypeTlv) tlv).getPst())];
- break;
- default:
- break;
- }
- }
- }
- return lspType;
- }
-
- private void handleRptWithoutSrpId(PcepStateReport stateRpt, PccId pccId) {
- ProviderId providerId = new ProviderId("pcep", PROVIDER_ID);
- String costType = null;
- PcepStateReport.PcepMsgPath msgPath = stateRpt.getMsgPath();
- checkNotNull(msgPath);
- PcepEroObject eroObj = msgPath.getEroObject();
- if (eroObj == null) {
- log.error("ERO object is null in report message.");
- return;
- }
- PcepAttribute attributes = msgPath.getPcepAttribute();
- float bandwidth = 0;
- int cost = 0;
- if (attributes != null) {
- if (attributes.getMetricObjectList() != null) {
- ListIterator<PcepMetricObject> iterator = attributes.getMetricObjectList().listIterator();
- PcepMetricObject metricObj = iterator.next();
-
- while (metricObj != null) {
- if (metricObj.getBType() == IGP_METRIC) {
- costType = "COST";
- } else if (metricObj.getBType() == TE_METRIC) {
- costType = "TE_COST";
- }
- if (costType != null) {
- cost = metricObj.getMetricVal();
- log.debug("Path cost {}", cost);
- break;
- }
- metricObj = iterator.next();
- }
- }
- if (attributes.getBandwidthObject() != null) {
- bandwidth = attributes.getBandwidthObject().getBandwidth();
- }
- }
- PcepLspObject lspObj = stateRpt.getLspObject();
- List<Object> eroSubObjList = buildPathFromEroObj(eroObj, providerId);
- List<Link> links = new ArrayList<>();
- List<LabelResourceId> labels = new ArrayList<>();
- for (Object linkOrLabel : eroSubObjList) {
- if (linkOrLabel instanceof Link) {
- links.add((Link) linkOrLabel);
- } else if (linkOrLabel instanceof Integer) {
- labels.add(LabelResourceId.labelResourceId(((Integer) linkOrLabel).longValue()));
- }
- }
- Path path = null;
- if (!links.isEmpty()) {
- path = new DefaultPath(providerId, links, ScalarWeight.toWeight(cost), EMPTY);
- } else if (!lspObj.getRFlag()) {
- return;
- }
- NetworkResource labelStack = new DefaultLabelStack(labels);
- // To carry PST TLV, SRP object can be present with value 0 even when PCRpt is not in response to any action
- // from PCE.
- PcepSrpObject srpObj = stateRpt.getSrpObject();
- LspType lspType = getLspType(srpObj);
- ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator();
- StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv = null;
- SymbolicPathNameTlv pathNameTlv = null;
- while (listTlvIterator.hasNext()) {
- PcepValueType tlv = listTlvIterator.next();
- switch (tlv.getType()) {
- case StatefulIPv4LspIdentifiersTlv.TYPE:
- ipv4LspIdenTlv = (StatefulIPv4LspIdentifiersTlv) tlv;
- break;
- case SymbolicPathNameTlv.TYPE:
- pathNameTlv = (SymbolicPathNameTlv) tlv;
- break;
- default:
- break;
- }
- }
- /*
- * Draft says: The LSP-IDENTIFIERS TLV MUST be included in the LSP object in PCRpt messages for
- * RSVP-signaled LSPs. For ONOS PCECC implementation, it is mandatory.
- */
- if (ipv4LspIdenTlv == null) {
- log.error("Stateful IPv4 identifier TLV is null in PCRpt msg.");
- return;
- }
- IpTunnelEndPoint tunnelEndPointSrc = IpTunnelEndPoint
- .ipTunnelPoint(IpAddress.valueOf(ipv4LspIdenTlv.getIpv4IngressAddress()));
- IpTunnelEndPoint tunnelEndPointDst = IpTunnelEndPoint
- .ipTunnelPoint(IpAddress.valueOf(ipv4LspIdenTlv.getIpv4EgressAddress()));
- Collection<Tunnel> tunnelQueryResult = tunnelService.queryTunnel(tunnelEndPointSrc, tunnelEndPointDst);
- // Store delegation flag info and that LSP info because only delegated PCE sends update message
- // Storing if D flag is set, if not dont store. while checking whether delegation if annotation for D flag
- // not present then non-delegated , if present it is delegated.
- if (lspObj.getDFlag()) {
- pcepClientController.getClient(pccId).setLspAndDelegationInfo(
- new LspKey(lspObj.getPlspId(), ipv4LspIdenTlv.getLspId()), lspObj.getDFlag());
- }
- Tunnel tunnel = null;
- SparseAnnotations oldTunnelAnnotations = null;
- // Asynchronous status change message from PCC for LSP reported earlier.
- for (Tunnel tunnelObj : tunnelQueryResult) {
- if (tunnelObj.annotations().value(PLSP_ID) == null) {
- /*
- * PLSP_ID is null while Tunnel is created at PCE and PCInit msg carries it as 0. It is allocated by
- * PCC and in that case it becomes the first PCRpt msg from PCC for this LSP, and hence symbolic
- * path name must be carried in the PCRpt msg. Draft says: The SYMBOLIC-PATH-NAME TLV "MUST" be
- * included in the LSP object in the LSP State Report (PCRpt) message when during a given PCEP
- * session an LSP is "first" reported to a PCE.
- */
- if ((pathNameTlv != null)
- && Arrays.equals(tunnelObj.tunnelName().value().getBytes(), pathNameTlv.getValue())) {
- tunnel = tunnelObj;
- break;
- }
- continue;
- }
- if ((Integer.valueOf(tunnelObj.annotations().value(PLSP_ID)) == lspObj.getPlspId())) {
- if ((Integer
- .valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) == ipv4LspIdenTlv.getLspId())) {
- tunnel = tunnelObj;
- }
- if ((Integer
- .valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) != ipv4LspIdenTlv.getLspId())) {
- oldTunnelAnnotations = (SparseAnnotations) tunnelObj.annotations();
- }
- }
- }
- DefaultTunnelDescription td;
- SparseAnnotations annotations = null;
- State tunnelState = PcepLspStatus.getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]);
- if (tunnel == null && pathNameTlv != null) {
- if (lspObj.getRFlag()) {
- /*
- * If PCC sends remove message and for any reason PCE does not have that entry, simply discard the
- * message. Or if PCRpt for initiated LSP received and PCE doesn't know, then too discard.
- */
- return;
- }
- DeviceId deviceId = getDevice(pccId);
- if (deviceId == null) {
- log.error("Ingress deviceId not found");
- return;
- }
- String tempBandwidth = null;
- String temoCostType = null;
- if (oldTunnelAnnotations != null) {
- tempBandwidth = oldTunnelAnnotations.value(BANDWIDTH);
- temoCostType = oldTunnelAnnotations.value(COST_TYPE);
- }
- annotations = getAnnotations(lspObj, ipv4LspIdenTlv, tempBandwidth, lspType,
- temoCostType, lspObj.getCFlag());
- td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new GroupId(
- 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack,
- annotations);
- // Do not support PCC initiated LSP after LSP DB sync is completed.
- if (!lspObj.getSFlag() && !lspObj.getCFlag()) {
- log.error("Received PCC initiated LSP while not in sync.");
- return;
- }
- /*
- * If ONOS instance is master for PCC then set delegated flag as annotation and add the tunnel to store.
- * Because all LSPs need not be delegated, hence mastership for the PCC is confirmed whereas not the
- * delegation set to all LSPs.If ONOS is not the master for that PCC then check if D flag is set, if yes
- * wait for 2 seconds [while master has added the tunnel to the store] then update the tunnel. Tunnel is
- * updated because in case of resilency only delegated LSPs are recomputed and only delegated PCE can
- * send update message to that client.
- *
- * 1)Master can 1st get the Rpt message
- * a)Master adds the tunnel into core.
- * b)If a non-master for ingress gets Rpt message with D flag set[as delegation owner]
- * after master, then runs timer then update the tunnel with D flag set.
- * 2)Non-Master can 1st get the Rpt message
- * a)Non-Master runs the timer check for the tunnel then updates the tunnel with D flag set
- * b)Master would have got the message while the non-master running timer, hence master adds
- * tunnel to core
- *
- * In general always master adds the tunnel to the core
- * while delegated owner [master or non-master with D flag set] always updates the tunnel running timer
- */
- if (mastershipService.isLocalMaster(deviceId)) {
- TunnelId tId = tunnelAdded(td, tunnelState);
- Tunnel tunnelInserted = new DefaultTunnel(providerId, tunnelEndPointSrc, tunnelEndPointDst, MPLS,
- tunnelState, new GroupId(0), tId, TunnelName.tunnelName(Arrays.toString(pathNameTlv
- .getValue())), path, labelStack, annotations);
-
- PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnelInserted, path, LSP_STATE_RPT);
- pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdenTlv);
- pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
- } else if (!mastershipService.isLocalMaster(deviceId) && lspObj.getDFlag()) {
- //Start timer then update the tunnel with D flag
- tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId, tunnelState, ipv4LspIdenTlv);
- }
- return;
- }
- //delegated owner will update can be a master or non-master
- if (lspObj.getDFlag() && !lspObj.getRFlag()) {
- tunnelUpdateForDelegatedLsp(tunnel, lspObj,
- lspType, tunnelState, pccId, labelStack, ipv4LspIdenTlv);
- return;
- }
- removeOrUpdatetunnel(tunnel, lspObj, providerId, tunnelState, ipv4LspIdenTlv);
- }
-
- private void tunnelUpdateForDelegatedLsp(Tunnel tunnel, PcepLspObject lspObj,
- LspType lspType, State tunnelState, PccId pccId,
- NetworkResource labelStack,
- StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv) {
- SparseAnnotations annotations = null;
- DefaultTunnelDescription td;
- boolean isPceInit = tunnel.annotations().value(PCE_INIT) == null ? false :
- Boolean.valueOf((tunnel.annotations().value(PCE_INIT))).booleanValue();
- annotations = getAnnotations(lspObj, ipv4LspIdenTlv,
- tunnel.annotations().value(BANDWIDTH), lspType,
- tunnel.annotations().value(COST_TYPE), isPceInit);
- td = new DefaultTunnelDescription(null, tunnel.src(), tunnel.dst(), MPLS, new GroupId(
- 0), tunnel.providerId(), tunnel.tunnelName(),
- tunnel.path(), labelStack, annotations);
- tunnelUpdateInDelegatedCase(pccId, annotations, td, tunnel.providerId(), tunnelState, ipv4LspIdenTlv);
- }
-
- private void removeOrUpdatetunnel(Tunnel tunnel, PcepLspObject lspObj, ProviderId providerId,
- State tunnelState, StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv) {
- DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), tunnel.dst(),
- tunnel.type(), tunnel.groupId(), providerId, tunnel.tunnelName(), tunnel.path(),
- (SparseAnnotations) tunnel.annotations());
- if (lspObj.getRFlag()) {
- tunnelRemoved(td);
- } else {
- PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, tunnel.path(), LSP_STATE_RPT);
- pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdenTlv);
- pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
- tunnelUpdated(td, tunnelState);
- }
- }
-
- private void tunnelUpdateInDelegatedCase(PccId pccId, SparseAnnotations annotations,
- DefaultTunnelDescription td, ProviderId providerId, State tunnelState,
- StatefulIPv4LspIdentifiersTlv ipv4LspIdentifiersTlv) {
- // Wait for 2sec then query tunnel based on ingress PLSP-ID and local LSP-ID
-
- /*
- * If ONOS is not the master for that PCC then check if D flag is set, if yes wait [while
- * master has added the tunnel to the store] then update the tunnel.
- */
- ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
-
- // Thread is started after 2 seconds first time later periodically after 2 seconds to update the tunnel
- executor.scheduleAtFixedRate(new UpdateDelegation(td, providerId, annotations, pccId,
- executor, tunnelState, ipv4LspIdentifiersTlv), DELAY, DELAY, TimeUnit.SECONDS);
- }
-
- /**
- * To build Path in network from ERO object.
- *
- * @param eroObj ERO object
- * @param providerId provider id
- * @return list of links and labels
- */
- private List<Object> buildPathFromEroObj(PcepEroObject eroObj, ProviderId providerId) {
- checkNotNull(eroObj);
- List<Object> subObjList = new ArrayList<>();
- LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects();
- if (llSubObj.isEmpty()) {
- log.error("ERO in report message does not have hop information");
- return new ArrayList<>();
- }
- ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator();
-
- ConnectPoint src = null;
- ConnectPoint dst = null;
- boolean isSrcSet = false;
- while (tlvIterator.hasNext()) {
- PcepValueType subObj = tlvIterator.next();
- switch (subObj.getType()) {
-
- case IPv4SubObject.TYPE:
-
- IPv4SubObject ipv4SubObj = (IPv4SubObject) subObj;
- if (!isSrcSet) {
- Iterable<Link> links = linkService.getActiveLinks();
- for (Link l : links) {
- if (l.src().port().equals(PortNumber.portNumber(ipv4SubObj.getIpAddress()))) {
- src = l.src();
- isSrcSet = true;
- break;
- } else if (l.dst().port().equals(PortNumber.portNumber(ipv4SubObj.getIpAddress()))) {
- src = l.dst();
- isSrcSet = true;
- break;
- }
- }
- } else {
- Iterable<Link> links = linkService.getActiveLinks();
- for (Link l : links) {
- if (l.src().port().equals(PortNumber.portNumber(ipv4SubObj.getIpAddress()))) {
- dst = l.src();
- break;
- } else if (l.dst().port().equals(PortNumber.portNumber(ipv4SubObj.getIpAddress()))) {
- dst = l.dst();
- break;
- }
- }
- Link link = DefaultLink.builder()
- .providerId(providerId)
- .src(src)
- .dst(dst)
- .type(Link.Type.DIRECT)
- .build();
- subObjList.add(link);
- src = dst;
- }
- break;
- case SrEroSubObject.TYPE:
- SrEroSubObject srEroSubObj = (SrEroSubObject) subObj;
- subObjList.add(srEroSubObj.getSid());
-
- if (srEroSubObj.getSt() == PcepNaiIpv4Adjacency.ST_TYPE) {
- PcepNaiIpv4Adjacency nai = (PcepNaiIpv4Adjacency) (srEroSubObj.getNai());
- int srcIp = nai.getLocalIpv4Addr();
- int dstIp = nai.getRemoteIpv4Addr();
- Iterable<Link> links = linkService.getActiveLinks();
- for (Link l : links) {
- long lSrc = l.src().port().toLong();
- long lDst = l.dst().port().toLong();
- if (lSrc == srcIp) {
- src = l.src();
- } else if (lDst == srcIp) {
- src = l.dst();
- }
- if (lSrc == dstIp) {
- dst = l.src();
- } else if (lDst == dstIp) {
- dst = l.dst();
- }
- if (src != null && dst != null) {
- break;
- }
- }
- if (src == null || dst == null) {
- return new ArrayList<>();
- }
- Link link = DefaultLink.builder()
- .providerId(providerId)
- .src(src)
- .dst(dst)
- .type(Link.Type.DIRECT)
- .build();
- subObjList.add(link);
- }
- default:
- // the other sub objects are not required
- }
- }
- return subObjList;
- }
-
- @Override
- public void clientConnected(PccId pccId) {
- // TODO
- }
-
- @Override
- public void clientDisconnected(PccId pccId) {
- // TODO
- }
-
- @Override
- public void handlePcepTunnelStatistics(PcepTunnelStatistics pcepTunnelStatistics) {
- TunnelId id = getTunnelId(String.valueOf(pcepTunnelStatistics.id()));
- TunnelStatistics tunnelStatistics = buildTunnelStatistics(pcepTunnelStatistics);
- tunnelStatisticsMap.put(id, tunnelStatistics);
- }
-
- @Override
- public void handleEndOfSyncAction(Tunnel tunnel, PcepLspSyncAction endOfSyncAction) {
-
- if (endOfSyncAction == SEND_UPDATE) {
- updateTunnel(tunnel, tunnel.path());
- return;
- }
-
- TunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(),
- tunnel.src(), tunnel.dst(),
- tunnel.type(),
- tunnel.groupId(),
- tunnel.providerId(),
- tunnel.tunnelName(),
- tunnel.path(),
- (SparseAnnotations) tunnel.annotations());
-
-
- if (endOfSyncAction == PcepLspSyncAction.UNSTABLE) {
- // Send PCInit msg again after global reoptimization.
- tunnelUpdated(td, UNSTABLE);
-
- // To remove the old tunnel from store whose PLSPID is not recognized by ingress PCC.
- tunnelRemoved(td);
- } else if (endOfSyncAction == REMOVE) {
- tunnelRemoved(td);
- }
- }
- }
- @Override
- public Tunnel tunnelQueryById(TunnelId tunnelId) {
- return service.tunnelQueryById(tunnelId);
- }
-
- private DeviceId getDevice(PccId pccId) {
- // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID.
- IpAddress lsrId = pccId.ipAddress();
- String lsrIdentifier = String.valueOf(lsrId);
-
- // Find PCC deviceID from lsrId stored as annotations
- Iterable<Device> devices = deviceService.getAvailableDevices();
- for (Device dev : devices) {
- if (dev.annotations().value(AnnotationKeys.TYPE).equals("L3")
- && dev.annotations().value(LSRID).equals(lsrIdentifier)) {
- return dev.id();
- }
- }
- return null;
- }
-
- /**
- * Updates the tunnel with updated tunnel annotation after a delay of two seconds and checks it till
- * tunnel is found.
- */
- private class UpdateDelegation implements Runnable {
- DefaultTunnelDescription td;
- ProviderId providerId;
- SparseAnnotations annotations;
- PccId pccId;
- ScheduledExecutorService executor;
- State tunnelState;
- StatefulIPv4LspIdentifiersTlv ipv4LspIdentifiersTlv;
-
- /**
- * Creates an instance of UpdateDelegation.
- *
- * @param td tunnel description
- * @param providerId provider id
- * @param annotations tunnel annotations
- * @param pccId PCEP client id
- * @param executor service of delegated owner
- */
- public UpdateDelegation(DefaultTunnelDescription td, ProviderId providerId, SparseAnnotations annotations,
- PccId pccId, ScheduledExecutorService executor, State tunnelState,
- StatefulIPv4LspIdentifiersTlv ipv4LspIdentifiersTlv) {
- this.td = td;
- this.providerId = providerId;
- this.annotations = annotations;
- this.pccId = pccId;
- this.executor = executor;
- this.tunnelState = tunnelState;
- this.ipv4LspIdentifiersTlv = ipv4LspIdentifiersTlv;
- }
-
- //Temporary using annotations later will use projection/network config service
- @Override
- public void run() {
- Collection<Tunnel> tunnelQueryResult = tunnelService.queryTunnel(td.src(), td.dst());
- TunnelId tempTunnelId = null;
- for (Tunnel t : tunnelQueryResult) {
- if (t.annotations().value(LOCAL_LSP_ID) == null || t.annotations().value(PLSP_ID) == null) {
- continue;
- }
-
- if (t.annotations().value(LOCAL_LSP_ID).equals(td.annotations().value(LOCAL_LSP_ID))
- && t.annotations().value(PLSP_ID).equals(td.annotations().value(PLSP_ID))
- && ((IpTunnelEndPoint) t.src()).ip().equals(pccId.id())) {
- tempTunnelId = t.tunnelId();
- break;
- }
- }
-
- //If tunnel is found update the tunnel and shutdown the thread otherwise thread will be executing
- //periodically
- if (tempTunnelId != null) {
- Tunnel tunnel = new DefaultTunnel(providerId, td.src(), td.dst(), MPLS, new GroupId(0),
- tempTunnelId, td.tunnelName(), td.path(), annotations);
- PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, tunnel.path(), LSP_STATE_RPT);
- pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdentifiersTlv);
- pcepTunnelData.setLspDFlag(Boolean.valueOf(tunnel.annotations().value(DELEGATE)));
- pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
- tunnelUpdated(tunnel, td.path(), tunnelState);
- executor.shutdown();
- try {
- executor.awaitTermination(WAIT_TIME, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- log.error("updating delegation failed");
- Thread.currentThread().interrupt();
- }
- }
- }
- }
-}
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/RequestType.java b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/RequestType.java
deleted file mode 100644
index 64a4177..0000000
--- a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/RequestType.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.pcep.tunnel.impl;
-
-/**
- * Enum of request types between pcc and pcep.
- */
-public enum RequestType {
- /**
- * Specifies the request type for PCC is to create new tunnel.
- */
- CREATE,
-
- /**
- * Specifies the request type for PCC is to update existing tunnel.
- */
- UPDATE,
-
- /**
- * Specifies the request type for PCC is to delete existing tunnel.
- */
- DELETE,
-
- /**
- * Specifies the request type for PCC to report existing tunnel.
- */
- LSP_STATE_RPT
-}
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/TunnelStatsCollector.java b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/TunnelStatsCollector.java
deleted file mode 100644
index bae93fc..0000000
--- a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/TunnelStatsCollector.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.pcep.tunnel.impl;
-
-
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.onlab.util.Timer;
-import org.onosproject.pcep.api.PcepController;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import io.netty.util.Timeout;
-import io.netty.util.TimerTask;
-
-import java.util.concurrent.TimeUnit;
-
-/*
- * Sends Stats Request and collect the tunnel statistics with a time interval.
- */
-public class TunnelStatsCollector implements TimerTask {
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected PcepController controller;
-
- private int refreshInterval;
-
- private String pcepTunnelId;
- private Timeout timeout;
- private volatile boolean stopped;
-
-
- /**
- * Create a tunnel status collector object.
- *
- * @param id tunnel whose status data will be collected
- * @param refreshInterval time interval for collecting statistic
- */
- public TunnelStatsCollector(String id, int refreshInterval) {
- this.pcepTunnelId = id;
- this.refreshInterval = refreshInterval;
- }
-
- @Override
- public void run(Timeout timeout) throws Exception {
- if (stopped || timeout.isCancelled()) {
- return;
- }
- log.trace("Collecting stats for {}", pcepTunnelId);
-
- sendTunnelStatistic();
- if (!stopped && !timeout.isCancelled()) {
- log.trace("Scheduling stats collection in {} seconds for {}",
- this.refreshInterval, pcepTunnelId);
- timeout.timer().newTimeout(this, refreshInterval, TimeUnit.SECONDS);
- }
-
- }
-
- private void sendTunnelStatistic() {
- controller.getTunnelStatistics(pcepTunnelId);
-
- }
-
- synchronized void adjustPollInterval(int pollInterval) {
- this.refreshInterval = pollInterval;
- }
-
- /**
- * Starts the collector.
- */
- public synchronized void start() {
- log.info("Starting Tunnel Stats collection thread for {}", pcepTunnelId);
- stopped = false;
- timeout = Timer.newTimeout(this, 1, TimeUnit.SECONDS);
- }
-
- /**
- * Stops the collector.
- */
- public synchronized void stop() {
- log.info("Stopping Tunnel Stats collection thread for {}", pcepTunnelId);
- stopped = true;
- timeout.cancel();
- }
-}
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/package-info.java b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/package-info.java
deleted file mode 100644
index c8a0b7e..0000000
--- a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- *Provider that uses PCEP controller as a means of infrastructure tunnel discovery.
- */
-package org.onosproject.provider.pcep.tunnel.impl;
\ No newline at end of file
diff --git a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepReleaseTunnelProviderTest.java b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepReleaseTunnelProviderTest.java
deleted file mode 100644
index 12579ae..0000000
--- a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepReleaseTunnelProviderTest.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.pcep.tunnel.impl;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.graph.ScalarWeight;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cfg.ComponentConfigAdapter;
-import org.onosproject.core.GroupId;
-import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.incubator.net.tunnel.TunnelServiceAdapter;
-import org.onosproject.mastership.MastershipServiceAdapter;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.DefaultPath;
-import org.onosproject.net.IpElementId;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DeviceServiceAdapter;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pcep.api.PcepControllerAdapter;
-import org.onosproject.pcep.server.ClientCapability;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepClientControllerAdapter;
-import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNot.not;
-import static org.onosproject.net.DefaultAnnotations.EMPTY;
-import static org.onosproject.pcep.server.LspType.SR_WITHOUT_SIGNALLING;
-import static org.onosproject.pcep.server.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
-import static org.onosproject.pcep.server.LspType.WITH_SIGNALLING;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.LSP_SIG_TYPE;
-
-/**
- * Test for PCEP release tunnel.
- */
-public class PcepReleaseTunnelProviderTest {
-
- private static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep";
- private PcepTunnelProvider tunnelProvider = new PcepTunnelProvider();
- private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter();
- private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter();
- private final PcepControllerAdapter ctl = new PcepControllerAdapter();
- private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper();
- private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter();
- private final DeviceServiceAdapter deviceService = new DeviceServiceAdapter();
- private final MastershipServiceAdapter mastershipService = new MastershipServiceAdapter();
-
- @Before
- public void setUp() throws IOException {
- tunnelProvider.tunnelProviderRegistry = registry;
- tunnelProvider.pcepClientController = controller;
- tunnelProvider.controller = ctl;
- tunnelProvider.deviceService = deviceService;
- tunnelProvider.mastershipService = mastershipService;
- tunnelProvider.tunnelService = tunnelService;
- tunnelProvider.pcepTunnelApiMapper = pcepTunnelAPIMapper;
- tunnelProvider.cfgService = new ComponentConfigAdapter();
- tunnelProvider.activate();
- }
-
- /**
- * Release tunnel with negotiated capability.
- */
- @Test
- public void testCasePcepReleaseTunnel() {
- Tunnel tunnel;
- Path path;
- List<Link> links = new ArrayList<>();
-
- ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
-
- IpAddress srcIp = IpAddress.valueOf(0xB6024E20);
- IpElementId srcElementId = IpElementId.ipElement(srcIp);
-
- IpAddress dstIp = IpAddress.valueOf(0xB6024E21);
- IpElementId dstElementId = IpElementId.ipElement(dstIp);
-
- IpTunnelEndPoint ipTunnelEndPointSrc;
- ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
-
- IpTunnelEndPoint ipTunnelEndPointDst;
- ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
-
- ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
-
- ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
-
- Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
- .type(Link.Type.DIRECT).build();
- links.add(link);
-
- path = new DefaultPath(pid, links, ScalarWeight.toWeight(20), EMPTY);
-
- Annotations annotations = DefaultAnnotations.builder()
- .set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
- .build();
-
- tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
- new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
- path, annotations);
-
- // for releasing tunnel tunnel should exist in db
- PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE);
- pcepTunnelData.setPlspId(1);
- StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
- pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
- tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
-
- tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
- controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability(
- new ClientCapability(true, true, true, true, true));
-
- tunnelProvider.releaseTunnel(tunnel);
- assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
- }
-
- /**
- * Doesn't send initiate message because PCC doesn't supports PCInitiate and stateful capability.
- */
- @Test
- public void testCasePcepReleaseTunnel2() {
- Tunnel tunnel;
- Path path;
- List<Link> links = new ArrayList<>();
-
- ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
-
- IpAddress srcIp = IpAddress.valueOf(0xB6024E22);
- IpElementId srcElementId = IpElementId.ipElement(srcIp);
-
- IpAddress dstIp = IpAddress.valueOf(0xB6024E21);
- IpElementId dstElementId = IpElementId.ipElement(dstIp);
-
- IpTunnelEndPoint ipTunnelEndPointSrc;
- ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
-
- IpTunnelEndPoint ipTunnelEndPointDst;
- ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
-
- ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
-
- ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
-
- Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
- .type(Link.Type.DIRECT).build();
- links.add(link);
-
- path = new DefaultPath(pid, links, ScalarWeight.toWeight(20), EMPTY);
-
- Annotations annotations = DefaultAnnotations.builder()
- .set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
- .build();
-
- tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
- new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
- path, annotations);
-
- // for releasing tunnel tunnel should exist in db
- PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE);
- pcepTunnelData.setPlspId(1);
- StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
- pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
- tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
-
- tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
- controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E22))).setCapability(
- new ClientCapability(true, false, false, true, true));
-
- tunnelProvider.releaseTunnel(tunnel);
- assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
- }
-
- /**
- * Tests releasing SR based tunnel.
- */
- @Test
- public void testCasePcepReleaseSrTunnel() {
- Tunnel tunnel;
- Path path;
- List<Link> links = new ArrayList<>();
-
- ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
-
- IpAddress srcIp = IpAddress.valueOf(0xB6024E20);
- IpElementId srcElementId = IpElementId.ipElement(srcIp);
-
- IpAddress dstIp = IpAddress.valueOf(0xB6024E21);
- IpElementId dstElementId = IpElementId.ipElement(dstIp);
-
- IpTunnelEndPoint ipTunnelEndPointSrc;
- ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
-
- IpTunnelEndPoint ipTunnelEndPointDst;
- ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
-
- ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
-
- ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
-
- Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
- .type(Link.Type.DIRECT).build();
- links.add(link);
-
- path = new DefaultPath(pid, links, ScalarWeight.toWeight(20), EMPTY);
-
- Annotations annotations = DefaultAnnotations.builder()
- .set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name())
- .build();
-
- tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
- new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
- path, annotations);
-
- // for releasing tunnel tunnel should exist in db
- PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE);
- pcepTunnelData.setPlspId(1);
- StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
- pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
- tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
-
- tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
- controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability(
- new ClientCapability(true, true, true, true, true));
-
- tunnelProvider.releaseTunnel(tunnel);
- assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
- }
-
- /**
- * Tests releasing tunnel without SR and without signalling.
- */
- @Test
- public void testCasePcepReleaseTunnelWithoutSigSr() {
- Tunnel tunnel;
- Path path;
- List<Link> links = new ArrayList<>();
-
- ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
-
- IpAddress srcIp = IpAddress.valueOf(0xB6024E20);
- IpElementId srcElementId = IpElementId.ipElement(srcIp);
-
- IpAddress dstIp = IpAddress.valueOf(0xB6024E21);
- IpElementId dstElementId = IpElementId.ipElement(dstIp);
-
- IpTunnelEndPoint ipTunnelEndPointSrc;
- ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
-
- IpTunnelEndPoint ipTunnelEndPointDst;
- ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
-
- ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
-
- ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
-
- Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
- .type(Link.Type.DIRECT).build();
- links.add(link);
-
- path = new DefaultPath(pid, links, ScalarWeight.toWeight(20), EMPTY);
-
- Annotations annotations = DefaultAnnotations.builder()
- .set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
- .build();
-
- tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
- new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
- path, annotations);
-
- // for releasing tunnel tunnel should exist in db
- PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE);
- pcepTunnelData.setPlspId(1);
- StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
- pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
- tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
-
- tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
- controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability(
- new ClientCapability(true, true, true, true, true));
-
- tunnelProvider.releaseTunnel(tunnel);
- assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
- }
-
- @After
- public void tearDown() throws IOException {
- tunnelProvider.deactivate();
- tunnelProvider.controller = null;
- tunnelProvider.pcepClientController = null;
- tunnelProvider.tunnelProviderRegistry = null;
- tunnelProvider.deviceService = null;
- tunnelProvider.mastershipService = null;
- }
-}
diff --git a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepSetupTunnelProviderTest.java b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepSetupTunnelProviderTest.java
deleted file mode 100644
index e176771..0000000
--- a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepSetupTunnelProviderTest.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.pcep.tunnel.impl;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.graph.ScalarWeight;
-import org.onlab.graph.Weight;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cfg.ComponentConfigAdapter;
-import org.onosproject.core.GroupId;
-import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.incubator.net.tunnel.TunnelServiceAdapter;
-import org.onosproject.mastership.MastershipServiceAdapter;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.DefaultPath;
-import org.onosproject.net.IpElementId;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DeviceServiceAdapter;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pcep.api.PcepControllerAdapter;
-import org.onosproject.pcep.server.ClientCapability;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepClientControllerAdapter;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNot.not;
-import static org.onosproject.net.DefaultAnnotations.EMPTY;
-import static org.onosproject.pcep.server.LspType.SR_WITHOUT_SIGNALLING;
-import static org.onosproject.pcep.server.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
-import static org.onosproject.pcep.server.LspType.WITH_SIGNALLING;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.LSP_SIG_TYPE;
-
-/**
- * Test for PCEP setup tunnel.
- */
-public class PcepSetupTunnelProviderTest {
-
- private static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep";
- private PcepTunnelProvider tunnelProvider = new PcepTunnelProvider();
- private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter();
- private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter();
- private final PcepControllerAdapter ctl = new PcepControllerAdapter();
- private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter();
- private final DeviceServiceAdapter deviceService = new DeviceServiceAdapter();
- private final MastershipServiceAdapter mastershipService = new MastershipServiceAdapter();
- private static final Weight TEN_WEIGHT = ScalarWeight.toWeight(10);
-
-
- @Before
- public void setUp() throws IOException {
- tunnelProvider.tunnelProviderRegistry = registry;
- tunnelProvider.pcepClientController = controller;
- tunnelProvider.controller = ctl;
- tunnelProvider.deviceService = deviceService;
- tunnelProvider.mastershipService = mastershipService;
- tunnelProvider.cfgService = new ComponentConfigAdapter();
- tunnelProvider.tunnelService = tunnelService;
- tunnelProvider.activate();
- }
-
- /**
- * Send PcInitiate message to PCC.
- */
- @Test
- public void testCasePcepSetupTunnel() {
- Tunnel tunnel;
- Path path;
- ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
- List<Link> links = new ArrayList<>();
- IpAddress srcIp = IpAddress.valueOf(0xC010101);
- IpElementId srcElementId = IpElementId.ipElement(srcIp);
-
- IpAddress dstIp = IpAddress.valueOf(0xC010102);
- IpElementId dstElementId = IpElementId.ipElement(dstIp);
-
- IpTunnelEndPoint ipTunnelEndPointSrc;
- ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
-
- IpTunnelEndPoint ipTunnelEndPointDst;
- ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
-
- ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
-
- ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
-
- Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
- .type(Link.Type.DIRECT).build();
- links.add(link);
-
- path = new DefaultPath(pid, links, TEN_WEIGHT, EMPTY);
-
- Annotations annotations = DefaultAnnotations.builder()
- .set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
- .build();
-
- tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
- new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
- path, annotations);
- controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability(
- new ClientCapability(true, true, true, true, true));
-
- tunnelProvider.setupTunnel(tunnel, path);
- assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
- }
-
- /**
- * Doesn't send PCInitiate message because PCC doesn't supports PCInitiate and stateful capability.
- */
- @Test
- public void testCasePcepSetupTunnel2() {
- Tunnel tunnel;
- Path path;
- ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
- List<Link> links = new ArrayList<>();
- IpAddress srcIp = IpAddress.valueOf(0xC010103);
- IpElementId srcElementId = IpElementId.ipElement(srcIp);
-
- IpAddress dstIp = IpAddress.valueOf(0xC010102);
- IpElementId dstElementId = IpElementId.ipElement(dstIp);
-
- IpTunnelEndPoint ipTunnelEndPointSrc;
- ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
-
- IpTunnelEndPoint ipTunnelEndPointDst;
- ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
-
- ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
-
- ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
-
- Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
- .type(Link.Type.DIRECT).build();
- links.add(link);
-
- path = new DefaultPath(pid, links, TEN_WEIGHT, EMPTY);
-
- Annotations annotations = DefaultAnnotations.builder()
- .set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
- .build();
-
- tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
- new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
- path, annotations);
- controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010103))).setCapability(
- new ClientCapability(true, true, true, true, true));
-
- tunnelProvider.setupTunnel(tunnel, path);
- assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
- }
-
- /**
- * Sends PCInitiate msg to setup a SR based tunnel.
- */
- @Test
- public void testCasePcepSetupSrTunnel() {
- Tunnel tunnel;
- Path path;
- ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
- List<Link> links = new ArrayList<>();
- IpAddress srcIp = IpAddress.valueOf(0xC010101);
- IpElementId srcElementId = IpElementId.ipElement(srcIp);
-
- IpAddress dstIp = IpAddress.valueOf(0xC010102);
- IpElementId dstElementId = IpElementId.ipElement(dstIp);
-
- IpTunnelEndPoint ipTunnelEndPointSrc;
- ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
-
- IpTunnelEndPoint ipTunnelEndPointDst;
- ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
-
- ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
-
- ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
-
- Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
- .type(Link.Type.DIRECT).build();
- links.add(link);
-
- path = new DefaultPath(pid, links, TEN_WEIGHT, EMPTY);
-
- Annotations annotations = DefaultAnnotations.builder()
- .set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name())
- .build();
-
- tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
- new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
- path, annotations);
- controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability(
- new ClientCapability(true, true, true, true, true));
-
- tunnelProvider.setupTunnel(tunnel, path);
- assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
- }
-
- /**
- * Sends PCInitiate msg to setup a tunnel without signalling and without SR.
- */
- @Test
- public void testCasePcepSetupTunnelWithoutSigSr() {
- Tunnel tunnel;
- Path path;
- ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
- List<Link> links = new ArrayList<>();
- IpAddress srcIp = IpAddress.valueOf(0xC010101);
- IpElementId srcElementId = IpElementId.ipElement(srcIp);
-
- IpAddress dstIp = IpAddress.valueOf(0xC010102);
- IpElementId dstElementId = IpElementId.ipElement(dstIp);
-
- IpTunnelEndPoint ipTunnelEndPointSrc;
- ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
-
- IpTunnelEndPoint ipTunnelEndPointDst;
- ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
-
- ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
-
- ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
-
- Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
- .type(Link.Type.DIRECT).build();
- links.add(link);
-
- path = new DefaultPath(pid, links, TEN_WEIGHT, EMPTY);
-
- Annotations annotations = DefaultAnnotations.builder()
- .set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
- .build();
-
- tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
- new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
- path, annotations);
- controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability(
- new ClientCapability(true, true, true, true, true));
-
- tunnelProvider.setupTunnel(tunnel, path);
- assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
- }
-
- @After
- public void tearDown() throws IOException {
- tunnelProvider.deactivate();
- tunnelProvider.controller = null;
- tunnelProvider.pcepClientController = null;
- tunnelProvider.tunnelProviderRegistry = null;
- tunnelProvider.deviceService = null;
- tunnelProvider.mastershipService = null;
- }
-}
diff --git a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelAddedTest.java b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelAddedTest.java
deleted file mode 100644
index 0db45cb..0000000
--- a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelAddedTest.java
+++ /dev/null
@@ -1,700 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.pcep.tunnel.impl;
-
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableSet;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.ChassisId;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cfg.ComponentConfigAdapter;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.Tunnel.State;
-import org.onosproject.incubator.net.tunnel.Tunnel.Type;
-import org.onosproject.incubator.net.tunnel.TunnelAdminService;
-import org.onosproject.incubator.net.tunnel.TunnelDescription;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.incubator.net.tunnel.TunnelProvider;
-import org.onosproject.incubator.net.tunnel.TunnelProviderService;
-import org.onosproject.incubator.net.tunnel.TunnelServiceAdapter;
-import org.onosproject.mastership.MastershipServiceAdapter;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultDevice;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.ElementId;
-import org.onosproject.net.Link;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.Path;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.SparseAnnotations;
-import org.onosproject.net.device.DeviceServiceAdapter;
-import org.onosproject.net.link.LinkServiceAdapter;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pcep.api.PcepControllerAdapter;
-import org.onosproject.pcep.server.ClientCapability;
-import org.onosproject.pcep.server.LspKey;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepClientAdapter;
-import org.onosproject.pcep.server.PcepClientControllerAdapter;
-import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException;
-import org.onosproject.pcepio.exceptions.PcepParseException;
-import org.onosproject.pcepio.protocol.PcepFactories;
-import org.onosproject.pcepio.protocol.PcepMessage;
-import org.onosproject.pcepio.protocol.PcepMessageReader;
-import org.onosproject.pcepio.protocol.PcepVersion;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT;
-import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS;
-import static org.onosproject.net.Device.Type.ROUTER;
-import static org.onosproject.net.Link.State.ACTIVE;
-import static org.onosproject.net.MastershipRole.MASTER;
-import static org.onosproject.pcep.server.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.BANDWIDTH;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.DELEGATE;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.LOCAL_LSP_ID;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.LSP_SIG_TYPE;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.PCC_TUNNEL_ID;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.PLSP_ID;
-import static org.onosproject.pcep.server.PcepSyncStatus.SYNCED;
-
-/**
- * Tests handling of PCEP report message.
- */
-public class PcepTunnelAddedTest {
-
- public static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep";
- public static final String UNKOWN = "UNKOWN";
- PcepTunnelProvider tunnelProvider = new PcepTunnelProvider();
- private final MockTunnelProviderRegistryAdapter registry = new MockTunnelProviderRegistryAdapter();
- private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter();
- private final PcepControllerAdapter ctl = new PcepControllerAdapter();
- private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper();
- private final MockTunnelServiceAdapter tunnelService = new MockTunnelServiceAdapter();
- public final MockDeviceService deviceService = new MockDeviceService();
- private final MockMasterShipService masterShipService = new MockMasterShipService();
- private final MockLinkService linkService = new MockLinkService();
- private final MockTunnelAdminService tunnelAdminService = new MockTunnelAdminService();
-
- private class MockLinkService extends LinkServiceAdapter {
- LinkedList<Link> links = new LinkedList<>();
- void addLink(Link link) {
- links.add(link);
- }
-
- @Override
- public Iterable<Link> getActiveLinks() {
-
- return FluentIterable.from(links)
- .filter(input -> input.state() == ACTIVE);
- }
- }
-
- private class MockTunnelAdminService implements TunnelAdminService {
-
- @Override
- public void removeTunnel(TunnelId tunnelId) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeTunnels(TunnelEndPoint src, TunnelEndPoint dst, ProviderId producerName) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void removeTunnels(TunnelEndPoint src, TunnelEndPoint dst, Type type, ProviderId producerName) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void updateTunnel(Tunnel tunnel, Path path) {
- if (tunnelService.tunnelIdAsKeyStore.containsKey(tunnel.tunnelId())) {
- tunnelService.tunnelIdAsKeyStore.replace(tunnel.tunnelId(), tunnel);
- }
- }
-
- @Override
- public void updateTunnelState(Tunnel tunnel, State state) {
- // TODO Auto-generated method stub
- }
- }
-
- private class MockMasterShipService extends MastershipServiceAdapter {
- boolean set;
-
- private void setMaster(boolean isMaster) {
- this.set = isMaster;
- }
-
- @Override
- public MastershipRole getLocalRole(DeviceId deviceId) {
- return set ? MastershipRole.MASTER : MastershipRole.STANDBY;
- }
-
- @Override
- public boolean isLocalMaster(DeviceId deviceId) {
- return getLocalRole(deviceId) == MASTER;
- }
- }
-
- private class MockDeviceService extends DeviceServiceAdapter {
- List<Device> devices = new LinkedList<>();
-
- private void addDevice(Device dev) {
- devices.add(dev);
- }
-
- @Override
- public Iterable<Device> getAvailableDevices() {
- return devices;
- }
- }
-
- private class MockTunnelProviderRegistryAdapter extends TunnelProviderRegistryAdapter {
- public long tunnelIdCounter;
-
- @Override
- public TunnelProviderService register(TunnelProvider provider) {
- this.provider = provider;
- return new TestProviderService();
- }
-
- private class TestProviderService implements TunnelProviderService {
-
- @Override
- public TunnelProvider provider() {
- return null;
- }
-
- @Override
- public TunnelId tunnelAdded(TunnelDescription tunnel) {
- TunnelId id = TunnelId.valueOf(String.valueOf(++tunnelIdCounter));
- Tunnel storedTunnel = new DefaultTunnel(ProviderId.NONE,
- tunnel.src(), tunnel.dst(),
- tunnel.type(),
- tunnel.groupId(),
- id,
- tunnel.tunnelName(),
- tunnel.path(),
- tunnel.resource(),
- tunnel.annotations());
- tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel);
- return id;
- }
-
- @Override
- public TunnelId tunnelAdded(TunnelDescription tunnel, State state) {
- TunnelId id = TunnelId.valueOf(String.valueOf(++tunnelIdCounter));
- Tunnel storedTunnel = new DefaultTunnel(ProviderId.NONE,
- tunnel.src(), tunnel.dst(),
- tunnel.type(),
- tunnel.groupId(),
- id,
- tunnel.tunnelName(),
- tunnel.path(),
- tunnel.resource(),
- tunnel.annotations());
- tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel);
- return id;
- }
-
- @Override
- public void tunnelRemoved(TunnelDescription tunnel) {
- }
-
- @Override
- public void tunnelUpdated(TunnelDescription tunnel) {
- }
-
- @Override
- public void tunnelUpdated(TunnelDescription tunnel, State state) {
- TunnelId id = TunnelId.valueOf(String.valueOf(++tunnelIdCounter));
- Tunnel storedTunnel = new DefaultTunnel(ProviderId.NONE,
- tunnel.src(), tunnel.dst(),
- tunnel.type(),
- tunnel.groupId(),
- id,
- tunnel.tunnelName(),
- tunnel.path(),
- tunnel.resource(),
- tunnel.annotations());
- tunnelService.tunnelIdAsKeyStore.put(id, storedTunnel);
- }
-
- @Override
- public Tunnel tunnelQueryById(TunnelId tunnelId) {
- return null;
- }
- }
- }
-
- private class MockTunnelServiceAdapter extends TunnelServiceAdapter {
- private HashMap<TunnelId, Tunnel> tunnelIdAsKeyStore = new HashMap<>();
- private int tunnelIdCounter = 0;
-
- @Override
- public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) {
- TunnelId tunnelId = TunnelId.valueOf(String.valueOf(++tunnelIdCounter));
- tunnelIdAsKeyStore.put(tunnelId, tunnel);
- return tunnelId;
- }
-
- @Override
- public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) {
- Collection<Tunnel> result = new HashSet<>();
- Tunnel tunnel = null;
- for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
- tunnel = tunnelIdAsKeyStore.get(tunnelId);
-
- if ((null != tunnel) && (src.equals(tunnel.src())) && (dst.equals(tunnel.dst()))) {
- result.add(tunnel);
- }
- }
-
- return result.isEmpty() ? Collections.emptySet() : ImmutableSet.copyOf(result);
- }
-
- @Override
- public Collection<Tunnel> queryAllTunnels() {
- Collection<Tunnel> result = new HashSet<>();
-
- for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) {
- result.add(tunnelIdAsKeyStore.get(tunnelId));
- }
-
- return result.isEmpty() ? Collections.emptySet() : ImmutableSet.copyOf(result);
-
- }
- }
-
- @Before
- public void preSetup() {
- tunnelProvider.tunnelProviderRegistry = registry;
- tunnelProvider.pcepClientController = controller;
- tunnelProvider.controller = ctl;
- tunnelProvider.deviceService = deviceService;
- tunnelProvider.mastershipService = masterShipService;
- tunnelProvider.pcepTunnelApiMapper = pcepTunnelAPIMapper;
- tunnelProvider.cfgService = new ComponentConfigAdapter();
- tunnelProvider.tunnelService = tunnelService;
- tunnelProvider.tunnelAdminService = tunnelAdminService;
- tunnelProvider.service = registry.register(tunnelProvider);
- tunnelProvider.linkService = linkService;
- tunnelProvider.activate();
- }
-
- /**
- * Tests PCRpt msg with sync flag set.
- */
- @Test
- public void tunnelProviderAddedTest1() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
- 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
- 0x00, 0x00, 0x00, 0x02,
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
- 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x01, 0x00, 0x01,
- 0x01, 0x01, 0x01, 0x01,
- 0x05, 0x05, 0x05, 0x05,
-
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
- 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
-
- 0x08, 0x10, 0x00, 0x34, //RRO object
- 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects
- 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00,
- 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00,
- 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00,
- 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
- 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = reader.readFrom(buffer);
-
- DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
- newBuilder.set(PcepTunnelProvider.LSRID, "1.1.1.1");
- newBuilder.set(AnnotationKeys.TYPE, "L3");
- Device device = new DefaultDevice(ProviderId.NONE, DeviceId.deviceId("1.1.1.1"), ROUTER,
- UNKOWN, UNKOWN, UNKOWN,
- UNKOWN, new ChassisId(),
- newBuilder.build());
-
- deviceService.addDevice(device);
- controller.getClient(PccId.pccId(IpAddress.valueOf("1.1.1.1"))).setCapability(
- new ClientCapability(true, true, true, true, true));
- masterShipService.setMaster(true);
- Link link = DefaultLink.builder()
- .src(new ConnectPoint(device.id(), PortNumber.portNumber(16843009)))
- .dst(new ConnectPoint(device.id(), PortNumber.portNumber(84215045)))
- .state(ACTIVE)
- .type(Link.Type.DIRECT)
- .providerId(ProviderId.NONE)
- .build();
- linkService.addLink(link);
- controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message);
-
- assertThat(registry.tunnelIdCounter, is((long) 1));
- }
-
- /**
- * Tests updating an existing tunnel on receiving asynchronous PCRpt msg,
- * i.e. without any SRP id.
- */
- @Test
- public void tunnelProviderAddedTest2() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x50,
- 0x21, 0x10, 0x00, 0x14, //SRP object
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
- 0x00, 0x00, 0x00, 0x02,
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x19, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path TLV
- 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
- 0x4e, 0x1f, 0x04, 0x00,
- 0x00, 0x01, 0x00, 0x01,
- 0x4e, 0x1f, 0x04, 0x00,
- 0x4e, 0x20, 0x04, 0x00,
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, // ERO IPv4 sub objects
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = reader.readFrom(buffer);
-
- // create an existing tunnel.
- IpTunnelEndPoint tunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(0x4e1f0400));
- IpTunnelEndPoint tunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(0x4e200400));
-
- SparseAnnotations annotations = DefaultAnnotations.builder()
- .set(BANDWIDTH, (new Integer(1)).toString())
- .set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
- .set(PCC_TUNNEL_ID, String.valueOf(1))
- .set(PLSP_ID, String.valueOf(1))
- .set(LOCAL_LSP_ID, String.valueOf(1))
- .set(DELEGATE, String.valueOf("true"))
- .build();
-
- Tunnel tunnel = new DefaultTunnel(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, INIT, null, null,
- TunnelName.tunnelName("T123"), null, annotations);
- tunnelService.setupTunnel(null, null, tunnel, null);
-
- PccId pccId = PccId.pccId(IpAddress.valueOf(0x4e1f0400));
- PcepClientAdapter pc = new PcepClientAdapter();
- pc.init(pccId, PcepVersion.PCEP_1);
- masterShipService.setMaster(true);
- controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
- controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
- controller.getClient(pccId).setLspDbSyncStatus(SYNCED);
-
- // Process update message.
- controller.processClientMessage(pccId, message);
- assertThat(tunnelService.queryAllTunnels().size(), is(1));
- }
-
- /**
- * Tests adding a new tunnel on receiving asynchronous PCRpt msg,
- * i.e. without any SRP id.
- */
- @Test
- public void tunnelProviderAddedTest3() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
- 0x21, 0x10, 0x00, 0x14, //SRP object
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
- 0x00, 0x00, 0x00, 0x02,
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x1B, // LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV
- 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x01, 0x00, 0x01,
- 0x01, 0x01, 0x01, 0x01,
- 0x05, 0x05, 0x05, 0x05,
-
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
- 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
-
- 0x08, 0x10, 0x00, 0x34, //RRO object
- 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects
- 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00,
- 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00,
- 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00,
- 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
- 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = reader.readFrom(buffer);
-
- DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
- newBuilder.set(PcepTunnelProvider.LSRID, "1.1.1.1");
- newBuilder.set(AnnotationKeys.TYPE, "L3");
- Device device = new DefaultDevice(ProviderId.NONE, DeviceId.deviceId("1.1.1.1"), ROUTER,
- UNKOWN, UNKOWN, UNKOWN,
- UNKOWN, new ChassisId(),
- newBuilder.build());
-
- deviceService.addDevice(device);
-
- PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1"));
- controller.getClient(pccId).setLspDbSyncStatus(SYNCED);
- controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
-
- Link link = DefaultLink.builder()
- .src(new ConnectPoint(device.id(), PortNumber.portNumber(16843009)))
- .dst(new ConnectPoint(device.id(), PortNumber.portNumber(84215045)))
- .state(ACTIVE)
- .type(Link.Type.DIRECT)
- .providerId(ProviderId.NONE)
- .build();
- linkService.addLink(link);
- PcepClientAdapter pc = new PcepClientAdapter();
- pc.init(pccId, PcepVersion.PCEP_1);
- controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
- masterShipService.setMaster(true);
- controller.processClientMessage(pccId, message);
-
- assertThat(registry.tunnelIdCounter, is((long) 1));
- }
-
- /**
- * Tests PCRpt msg with D flag set and delegated to non-master.
- *
- * @throws InterruptedException while waiting for delay
- */
- @Test
- public void tunnelProviderAddedTest4() throws PcepParseException, PcepOutOfBoundMessageException,
- InterruptedException {
- byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
- 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
- 0x00, 0x00, 0x00, 0x02,
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x02, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
- 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x01, 0x00, 0x01,
- 0x01, 0x01, 0x01, 0x01,
- 0x05, 0x05, 0x05, 0x05,
-
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
- 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
-
- 0x08, 0x10, 0x00, 0x34, //RRO object
- 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects
- 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00,
- 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00,
- 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00,
- 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
- 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = reader.readFrom(buffer);
-
- //PCC 1.1.1.1, D=0, ONOS as master
- masterShipService.setMaster(true);
- DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
- newBuilder.set(PcepTunnelProvider.LSRID, "1.1.1.1");
- newBuilder.set(AnnotationKeys.TYPE, "L3");
- Device device = new DefaultDevice(ProviderId.NONE, DeviceId.deviceId("1.1.1.1"), ROUTER,
- UNKOWN, UNKOWN, UNKOWN,
- UNKOWN, new ChassisId(),
- newBuilder.build());
-
- deviceService.addDevice(device);
- controller.getClient(PccId.pccId(IpAddress.valueOf("1.1.1.1"))).setCapability(
- new ClientCapability(true, true, true, true, true));
- Link link = DefaultLink.builder()
- .src(new ConnectPoint(device.id(), PortNumber.portNumber(16843009)))
- .dst(new ConnectPoint(device.id(), PortNumber.portNumber(84215045)))
- .state(ACTIVE)
- .type(Link.Type.DIRECT)
- .providerId(ProviderId.NONE)
- .build();
- linkService.addLink(link);
- controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message);
- assertThat(tunnelService.tunnelIdAsKeyStore.values().iterator().next().annotations().value(DELEGATE),
- is("false"));
-
- //PCC 1.1.1.1, D=1, non-master
- masterShipService.setMaster(false);
-
- reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
- 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
- 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
- 0x00, 0x00, 0x00, 0x02,
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
- 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x01, 0x00, 0x01,
- 0x01, 0x01, 0x01, 0x01,
- 0x05, 0x05, 0x05, 0x05,
-
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
- 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
-
- 0x08, 0x10, 0x00, 0x34, //RRO object
- 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects
- 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00,
- 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00,
- 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00,
- 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
- 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00
- };
-
- buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- reader = PcepFactories.getGenericReader();
- message = reader.readFrom(buffer);
-
- controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message);
- TimeUnit.MILLISECONDS.sleep(4000);
- assertThat(registry.tunnelIdCounter, is((long) 2));
-
- Iterator<Tunnel> iterator = tunnelService.tunnelIdAsKeyStore.values().iterator();
- iterator.next();
- assertThat(iterator.next().annotations().value(DELEGATE),
- is("true"));
- }
-
- /**
- * Tests adding PCC Init LSP after LSP DB sync is over.
- */
- @Test
- public void tunnelProviderAddedTest5() throws PcepParseException, PcepOutOfBoundMessageException {
- byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
- 0x21, 0x10, 0x00, 0x14, //SRP object
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
- 0x00, 0x00, 0x00, 0x02,
- 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x19, // LSP object
- 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV
- 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
- 0x01, 0x01, 0x01, 0x01,
- 0x00, 0x01, 0x00, 0x01,
- 0x01, 0x01, 0x01, 0x01,
- 0x05, 0x05, 0x05, 0x05,
-
- 0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
- 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
-
- 0x08, 0x10, 0x00, 0x34, //RRO object
- 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects
- 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00,
- 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00,
- 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00,
- 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
- 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00
- };
-
- ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
- buffer.writeBytes(reportMsg);
-
- PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
- PcepMessage message = reader.readFrom(buffer);
-
- DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
- newBuilder.set(PcepTunnelProvider.LSRID, "1.1.1.1");
- newBuilder.set(AnnotationKeys.TYPE, "L3");
- Device device = new DefaultDevice(ProviderId.NONE, DeviceId.deviceId("1.1.1.1"), ROUTER,
- UNKOWN, UNKOWN, UNKOWN,
- UNKOWN, new ChassisId(),
- newBuilder.build());
-
- deviceService.addDevice(device);
-
- PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1"));
- controller.getClient(pccId).setLspDbSyncStatus(SYNCED);
- controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
-
- PcepClientAdapter pc = new PcepClientAdapter();
- pc.init(pccId, PcepVersion.PCEP_1);
- controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
- masterShipService.setMaster(true);
- controller.processClientMessage(pccId, message);
-
- assertThat(registry.tunnelIdCounter, is((long) 0));
- }
-
- @After
- public void tearDown() throws IOException {
- tunnelProvider.deactivate();
- tunnelProvider.controller = null;
- tunnelProvider.pcepClientController = null;
- tunnelProvider.tunnelProviderRegistry = null;
-
- tunnelProvider.pcepTunnelApiMapper = null;
- tunnelProvider.cfgService = null;
- tunnelProvider.tunnelService = null;
- tunnelProvider.tunnelAdminService = null;
- tunnelProvider.deviceService = null;
- tunnelProvider.mastershipService = null;
- tunnelProvider.linkService = null;
- tunnelProvider.service = null;
- }
-}
diff --git a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProviderTest.java b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProviderTest.java
deleted file mode 100644
index 9f70e1e..0000000
--- a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProviderTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.pcep.tunnel.impl;
-
-import org.junit.After;
-import org.junit.Test;
-import org.onlab.graph.ScalarWeight;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cfg.ComponentConfigAdapter;
-import org.onosproject.core.GroupId;
-import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.incubator.net.tunnel.TunnelServiceAdapter;
-import org.onosproject.mastership.MastershipServiceAdapter;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.DefaultPath;
-import org.onosproject.net.IpElementId;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DeviceServiceAdapter;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pcep.api.PcepControllerAdapter;
-import org.onosproject.pcep.server.ClientCapability;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepClientControllerAdapter;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.core.IsNot.not;
-import static org.onosproject.net.DefaultAnnotations.EMPTY;
-import static org.onosproject.pcep.server.LspType.WITH_SIGNALLING;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.LSP_SIG_TYPE;
-
-public class PcepTunnelProviderTest {
-
- private static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep";
- private PcepTunnelProvider tunnelProvider = new PcepTunnelProvider();
- private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter();
- private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter();
- private final PcepControllerAdapter ctl = new PcepControllerAdapter();
- private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter();
- private final DeviceServiceAdapter deviceService = new DeviceServiceAdapter();
- private final MastershipServiceAdapter mastershipService = new MastershipServiceAdapter();
-
- @Test
- public void testCasePcepSetupTunnel() {
-
- tunnelProvider.tunnelProviderRegistry = registry;
- tunnelProvider.pcepClientController = controller;
- tunnelProvider.controller = ctl;
- tunnelProvider.deviceService = deviceService;
- tunnelProvider.mastershipService = mastershipService;
- tunnelProvider.cfgService = new ComponentConfigAdapter();
- tunnelProvider.tunnelService = tunnelService;
- tunnelProvider.activate();
-
- Tunnel tunnel;
- Path path;
- ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
- List<Link> links = new ArrayList<>();
- IpAddress srcIp = IpAddress.valueOf(0xC010101);
- IpElementId srcElementId = IpElementId.ipElement(srcIp);
-
- IpAddress dstIp = IpAddress.valueOf(0xC010102);
- IpElementId dstElementId = IpElementId.ipElement(dstIp);
-
- IpTunnelEndPoint ipTunnelEndPointSrc;
- ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
-
- IpTunnelEndPoint ipTunnelEndPointDst;
- ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
-
- ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
-
- ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
-
- Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
- .type(Link.Type.DIRECT).build();
- links.add(link);
-
- path = new DefaultPath(pid, links, ScalarWeight.toWeight(10), EMPTY);
-
- Annotations annotations = DefaultAnnotations.builder()
- .set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
- .build();
-
- tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
- new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
- path, annotations);
- controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability(
- new ClientCapability(true, true, true, true, true));
-
- tunnelProvider.setupTunnel(tunnel, path);
-
- assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
- }
-
- @After
- public void tearDown() throws IOException {
- tunnelProvider.deactivate();
- tunnelProvider.controller = null;
- tunnelProvider.deviceService = null;
- tunnelProvider.mastershipService = null;
- tunnelProvider.pcepClientController = null;
- tunnelProvider.tunnelProviderRegistry = null;
- }
-}
\ No newline at end of file
diff --git a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepUpdateTunnelProviderTest.java b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepUpdateTunnelProviderTest.java
deleted file mode 100644
index 99e6e28..0000000
--- a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepUpdateTunnelProviderTest.java
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.pcep.tunnel.impl;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.graph.ScalarWeight;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cfg.ComponentConfigAdapter;
-import org.onosproject.core.GroupId;
-import org.onosproject.incubator.net.tunnel.DefaultTunnel;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.incubator.net.tunnel.TunnelServiceAdapter;
-import org.onosproject.net.Annotations;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DefaultLink;
-import org.onosproject.net.DefaultPath;
-import org.onosproject.net.IpElementId;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.provider.ProviderId;
-import org.onosproject.pcep.api.PcepControllerAdapter;
-import org.onosproject.pcep.server.ClientCapability;
-import org.onosproject.pcep.server.LspKey;
-import org.onosproject.pcep.server.PccId;
-import org.onosproject.pcep.server.PcepClientAdapter;
-import org.onosproject.pcep.server.PcepClientControllerAdapter;
-import org.onosproject.pcepio.protocol.PcepVersion;
-import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNot.not;
-import static org.onosproject.net.DefaultAnnotations.EMPTY;
-import static org.onosproject.pcep.server.LspType.SR_WITHOUT_SIGNALLING;
-import static org.onosproject.pcep.server.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
-import static org.onosproject.pcep.server.LspType.WITH_SIGNALLING;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.LOCAL_LSP_ID;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.LSP_SIG_TYPE;
-import static org.onosproject.pcep.server.PcepAnnotationKeys.PLSP_ID;
-/**
- * Test for PCEP update tunnel.
- */
-public class PcepUpdateTunnelProviderTest {
-
- private static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep";
- private PcepTunnelProvider tunnelProvider = new PcepTunnelProvider();
- private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter();
- private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter();
- private final PcepControllerAdapter ctl = new PcepControllerAdapter();
- private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper();
- private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter();
-
- @Before
- public void setUp() throws IOException {
- tunnelProvider.tunnelProviderRegistry = registry;
- tunnelProvider.pcepClientController = controller;
- tunnelProvider.controller = ctl;
- tunnelProvider.pcepTunnelApiMapper = pcepTunnelAPIMapper;
- tunnelProvider.cfgService = new ComponentConfigAdapter();
- tunnelProvider.tunnelService = tunnelService;
- tunnelProvider.activate();
- }
-
- /**
- * Send update message to PCC.
- */
- @Test
- public void testCasePcepUpdateTunnel() {
- Tunnel tunnel;
- Path path;
- ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
- List<Link> links = new ArrayList<>();
- IpAddress srcIp = IpAddress.valueOf(0xD010101);
- IpElementId srcElementId = IpElementId.ipElement(srcIp);
-
- IpAddress dstIp = IpAddress.valueOf(0xD010102);
- IpElementId dstElementId = IpElementId.ipElement(dstIp);
-
- IpTunnelEndPoint ipTunnelEndPointSrc;
- ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
-
- IpTunnelEndPoint ipTunnelEndPointDst;
- ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
-
- ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
-
- ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024));
-
- Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
- .type(Link.Type.DIRECT).build();
- links.add(link);
-
- path = new DefaultPath(pid, links, ScalarWeight.toWeight(20), EMPTY);
-
- Annotations annotations = DefaultAnnotations.builder()
- .set(PLSP_ID, "1")
- .set(LOCAL_LSP_ID, "1")
- .set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
- .build();
-
- tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
- new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
- path, annotations);
-
- // for updating tunnel tunnel should exist in db
- PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE);
- pcepTunnelData.setPlspId(1);
- StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
- pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
- tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
-
- tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
-
- PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101));
- PcepClientAdapter pc = new PcepClientAdapter();
- pc.init(pccId, PcepVersion.PCEP_1);
- controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
- controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
-
- tunnelProvider.updateTunnel(tunnel, path);
- assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
- }
-
- /**
- * Doesn't send update message because PCC doesn't supports PCE stateful capability.
- */
- @Test
- public void testCasePcepUpdateTunnel2() {
- Tunnel tunnel;
- Path path;
- ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
- List<Link> links = new ArrayList<>();
- IpAddress srcIp = IpAddress.valueOf(0xD010101);
- IpElementId srcElementId = IpElementId.ipElement(srcIp);
-
- IpAddress dstIp = IpAddress.valueOf(0xD010102);
- IpElementId dstElementId = IpElementId.ipElement(dstIp);
-
- IpTunnelEndPoint ipTunnelEndPointSrc;
- ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
-
- IpTunnelEndPoint ipTunnelEndPointDst;
- ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
-
- ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
-
- ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024));
-
- Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
- .type(Link.Type.DIRECT).build();
- links.add(link);
-
- path = new DefaultPath(pid, links, ScalarWeight.toWeight(20), EMPTY);
-
- Annotations annotations = DefaultAnnotations.builder()
- .set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
- .set(PLSP_ID, "1")
- .set(LOCAL_LSP_ID, "1")
- .build();
-
- tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
- new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
- path, annotations);
-
- // for updating tunnel tunnel should exist in db
- PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE);
- pcepTunnelData.setPlspId(1);
- StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
- pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
- tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
-
- tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
-
- PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101));
- PcepClientAdapter pc = new PcepClientAdapter();
- pc.init(pccId, PcepVersion.PCEP_1);
- controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
- controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
-
- tunnelProvider.updateTunnel(tunnel, path);
- assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
- }
-
- /**
- * Sends update message to PCC for SR based tunnel.
- */
- @Test
- public void testCasePcepUpdateSrTunnel() {
- Tunnel tunnel;
- Path path;
- ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
- List<Link> links = new ArrayList<>();
- IpAddress srcIp = IpAddress.valueOf(0xD010101);
- IpElementId srcElementId = IpElementId.ipElement(srcIp);
-
- IpAddress dstIp = IpAddress.valueOf(0xD010102);
- IpElementId dstElementId = IpElementId.ipElement(dstIp);
-
- IpTunnelEndPoint ipTunnelEndPointSrc;
- ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
-
- IpTunnelEndPoint ipTunnelEndPointDst;
- ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
-
- ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
-
- ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024));
-
- Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
- .type(Link.Type.DIRECT).build();
- links.add(link);
-
- path = new DefaultPath(pid, links, ScalarWeight.toWeight(20), EMPTY);
-
- Annotations annotations = DefaultAnnotations.builder()
- .set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name())
- .set(PLSP_ID, "1")
- .set(LOCAL_LSP_ID, "1")
- .build();
-
- tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
- new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
- path, annotations);
-
- // for updating tunnel tunnel should exist in db
- PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE);
- pcepTunnelData.setPlspId(1);
- StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
- pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
- tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
-
- tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
-
- PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101));
- PcepClientAdapter pc = new PcepClientAdapter();
- pc.init(pccId, PcepVersion.PCEP_1);
- controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
- controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
-
- tunnelProvider.updateTunnel(tunnel, path);
- assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
- }
-
- /**
- * Sends update message to PCC for tunnel without signalling and without SR.
- */
- @Test
- public void testCasePcepUpdateTunnelWithoutSigSr() {
- Tunnel tunnel;
- Path path;
- ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
- List<Link> links = new ArrayList<>();
- IpAddress srcIp = IpAddress.valueOf(0xD010101);
- IpElementId srcElementId = IpElementId.ipElement(srcIp);
-
- IpAddress dstIp = IpAddress.valueOf(0xD010102);
- IpElementId dstElementId = IpElementId.ipElement(dstIp);
-
- IpTunnelEndPoint ipTunnelEndPointSrc;
- ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
-
- IpTunnelEndPoint ipTunnelEndPointDst;
- ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
-
- ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
-
- ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024));
-
- Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
- .type(Link.Type.DIRECT).build();
- links.add(link);
-
- path = new DefaultPath(pid, links, ScalarWeight.toWeight(20), EMPTY);
-
- Annotations annotations = DefaultAnnotations.builder()
- .set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
- .set(PLSP_ID, "1")
- .set(LOCAL_LSP_ID, "1")
- .build();
-
- tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
- new GroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
- path, annotations);
-
- // for updating tunnel tunnel should exist in db
- PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE);
- pcepTunnelData.setPlspId(1);
- StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
- pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
- tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
-
- tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
-
- PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101));
- PcepClientAdapter pc = new PcepClientAdapter();
- pc.init(pccId, PcepVersion.PCEP_1);
- controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
- controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
-
- tunnelProvider.updateTunnel(tunnel, path);
- assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
- }
-
- @After
- public void tearDown() throws IOException {
- tunnelProvider.deactivate();
- tunnelProvider.controller = null;
- tunnelProvider.pcepClientController = null;
- tunnelProvider.tunnelProviderRegistry = null;
- }
-}
diff --git a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelProviderRegistryAdapter.java b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelProviderRegistryAdapter.java
deleted file mode 100644
index 250e376..0000000
--- a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/TunnelProviderRegistryAdapter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.pcep.tunnel.impl;
-
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.Tunnel.State;
-import org.onosproject.incubator.net.tunnel.TunnelDescription;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelProvider;
-import org.onosproject.incubator.net.tunnel.TunnelProviderRegistry;
-import org.onosproject.incubator.net.tunnel.TunnelProviderService;
-import org.onosproject.net.provider.ProviderId;
-
-import java.util.Set;
-
-public class TunnelProviderRegistryAdapter implements TunnelProviderRegistry {
- TunnelProvider provider;
-
- @Override
- public TunnelProviderService register(TunnelProvider provider) {
- this.provider = provider;
- return new TestProviderService();
- }
-
- @Override
- public void unregister(TunnelProvider provider) {
- }
-
- @Override
- public Set<ProviderId> getProviders() {
- return null;
- }
-
- private class TestProviderService implements TunnelProviderService {
-
- @Override
- public TunnelProvider provider() {
- return null;
- }
-
- @Override
- public TunnelId tunnelAdded(TunnelDescription tunnel) {
- return null;
- }
-
- @Override
- public TunnelId tunnelAdded(TunnelDescription tunnel, State state) {
- return null;
- }
-
- @Override
- public void tunnelRemoved(TunnelDescription tunnel) {
- }
-
- @Override
- public void tunnelUpdated(TunnelDescription tunnel) {
- }
-
- @Override
- public void tunnelUpdated(TunnelDescription tunnel, State state) {
- }
-
- @Override
- public Tunnel tunnelQueryById(TunnelId tunnelId) {
- return null;
- }
- }
-}
diff --git a/tools/build/bazel/modules.bzl b/tools/build/bazel/modules.bzl
index ff86c45..4f323db 100644
--- a/tools/build/bazel/modules.bzl
+++ b/tools/build/bazel/modules.bzl
@@ -18,7 +18,6 @@
"//core/store/primitives:onos-core-primitives",
"//core/store/serializers:onos-core-serializers",
"//core/store/dist:onos-core-dist",
- # "//core/security:onos-security",
"//core/store/persistence:onos-core-persistence",
"//cli:onos-cli",
"//drivers/utilities:onos-drivers-utilities",
@@ -33,7 +32,6 @@
"//tools/package/features:onos-core",
"//tools/package/features:onos-cli",
"//tools/package/features:onos-rest",
- # "//tools/package/features:onos-security",
]
#
@@ -54,9 +52,6 @@
"//protocols/bgp/bgpio:onos-protocols-bgp-bgpio": [],
"//protocols/bgp/api:onos-protocols-bgp-api": [],
"//protocols/bgp/ctl:onos-protocols-bgp-ctl": [],
- "//protocols/isis/api:onos-protocols-isis-api": [],
- "//protocols/isis/ctl:onos-protocols-isis-ctl": [],
- "//protocols/isis/isisio:onos-protocols-isis-isisio": [],
"//protocols/lisp/api:onos-protocols-lisp-api": [],
"//protocols/lisp/ctl:onos-protocols-lisp-ctl": [],
"//protocols/lisp/msg:onos-protocols-lisp-msg": [],
@@ -64,17 +59,11 @@
"//protocols/netconf/ctl:onos-protocols-netconf-ctl": [],
"//protocols/openflow/api:onos-protocols-openflow-api": ["seba", "sona"],
"//protocols/openflow/ctl:onos-protocols-openflow-ctl": ["seba", "sona"],
- "//protocols/ospf/api:onos-protocols-ospf-api": [],
- "//protocols/ospf/protocol:onos-protocols-ospf-protocol": [],
- "//protocols/ospf/ctl:onos-protocols-ospf-ctl": [],
"//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc": ["sona"],
"//protocols/ovsdb/api:onos-protocols-ovsdb-api": ["sona"],
"//protocols/ovsdb/ctl:onos-protocols-ovsdb-ctl": ["sona"],
"//protocols/p4runtime/api:onos-protocols-p4runtime-api": ["stratum"],
"//protocols/p4runtime/model:onos-protocols-p4runtime-model": ["stratum"],
- "//protocols/pcep/pcepio:onos-protocols-pcep-pcepio": [],
- "//protocols/pcep/server/api:onos-protocols-pcep-server-api": [],
- "//protocols/pcep/server/ctl:onos-protocols-pcep-server-ctl": [],
"//protocols/rest/api:onos-protocols-rest-api": ["stratum", "tost"],
"//protocols/rest/ctl:onos-protocols-rest-ctl": ["stratum", "tost"],
"//protocols/restconf/client/api:onos-protocols-restconf-client-api": [],
@@ -109,19 +98,14 @@
"//providers/p4runtime/packet:onos-providers-p4runtime-packet": ["stratum"],
"//providers/rest/device:onos-providers-rest-device": ["stratum"],
"//providers/snmp/device:onos-providers-snmp-device": [],
- "//providers/isis/cfg:onos-providers-isis-cfg": [],
- "//providers/isis/topology:onos-providers-isis-topology": [],
"//providers/lisp/device:onos-providers-lisp-device": [],
"//providers/tl1/device:onos-providers-tl1-device": [],
}
PROVIDER_APP_MAP = {
"//providers/general:onos-providers-general-oar": ["stratum", "tost", "sona"],
- "//providers/bgp:onos-providers-bgp-oar": [],
- "//providers/bgpcep:onos-providers-bgpcep-oar": [],
"//providers/host:onos-providers-host-oar": ["seba", "stratum", "tost", "sona"],
"//providers/hostprobing:onos-providers-hostprobing-oar": ["seba", "stratum", "tost", "sona"],
- "//providers/isis:onos-providers-isis-oar": [],
"//providers/link:onos-providers-link-oar": ["stratum"],
"//providers/lldp:onos-providers-lldp-oar": ["seba", "stratum", "tost", "sona"],
"//providers/netcfghost:onos-providers-netcfghost-oar": ["seba", "stratum", "tost", "sona"],
@@ -135,13 +119,11 @@
"//providers/ovsdb/host:onos-providers-ovsdb-host-oar": ["sona"],
"//providers/ovsdb/base:onos-providers-ovsdb-base-oar": ["sona"],
"//providers/p4runtime:onos-providers-p4runtime-oar": ["stratum", "tost"],
- "//providers/pcep:onos-providers-pcep-oar": [],
"//providers/rest:onos-providers-rest-oar": ["stratum", "tost"],
"//providers/snmp:onos-providers-snmp-oar": [],
"//providers/lisp:onos-providers-lisp-oar": [],
"//providers/tl1:onos-providers-tl1-oar": [],
"//providers/xmpp/device:onos-providers-xmpp-device-oar": [],
- # "//providers/ietfte:onos-providers-ietfte-oar": [],
}
#
@@ -166,7 +148,6 @@
"//drivers/gnmi:onos-drivers-gnmi-oar": ["stratum", "tost", "sona"],
"//drivers/gnoi:onos-drivers-gnoi-oar": ["stratum", "tost"],
"//drivers/hp:onos-drivers-hp-oar": [],
- "//drivers/huawei:onos-drivers-huawei-oar": [],
"//drivers/juniper:onos-drivers-juniper-oar": [],
"//drivers/lisp:onos-drivers-lisp-oar": [],
"//drivers/lumentum:onos-drivers-lumentum-oar": [],
@@ -202,10 +183,6 @@
"//apps/kafka-integration/api:onos-apps-kafka-integration-api": [],
"//apps/kafka-integration/app:onos-apps-kafka-integration-app": [],
"//apps/routing/common:onos-apps-routing-common": [],
- "//apps/vtn/vtnrsc:onos-apps-vtn-vtnrsc": [],
- "//apps/vtn/sfcmgr:onos-apps-vtn-sfcmgr": [],
- "//apps/vtn/vtnmgr:onos-apps-vtn-vtnmgr": [],
- "//apps/vtn/vtnweb:onos-apps-vtn-vtnweb": [],
}
APP_MAP = {
@@ -214,18 +191,13 @@
"//apps/bgprouter:onos-apps-bgprouter-oar": [],
"//apps/castor:onos-apps-castor-oar": [],
"//apps/cfm:onos-apps-cfm-oar": [],
- "//apps/cip:onos-apps-cip-oar": [],
"//apps/config:onos-apps-config-oar": ["stratum", "tost"],
- "//apps/configsync-netconf:onos-apps-configsync-netconf-oar": [],
- "//apps/configsync:onos-apps-configsync-oar": [],
"//apps/cord-support:onos-apps-cord-support-oar": [],
"//apps/cpman/app:onos-apps-cpman-app-oar": [],
"//apps/dhcp:onos-apps-dhcp-oar": [],
"//apps/dhcprelay:onos-apps-dhcprelay-oar": ["tost"],
"//apps/drivermatrix:onos-apps-drivermatrix-oar": [],
"//apps/events:onos-apps-events-oar": [],
- "//apps/evpn-route-service:onos-apps-evpn-route-service-oar": [],
- "//apps/evpnopenflow:onos-apps-evpnopenflow-oar": [],
"//apps/faultmanagement:onos-apps-faultmanagement-oar": ["stratum", "tost"],
"//apps/flowanalyzer:onos-apps-flowanalyzer-oar": [],
"//apps/flowspec-api:onos-apps-flowspec-api-oar": [],
@@ -240,7 +212,6 @@
"//apps/k8s-networking:onos-apps-k8s-networking-oar": ["sona"],
"//apps/k8s-node:onos-apps-k8s-node-oar": ["sona"],
"//apps/kafka-integration:onos-apps-kafka-integration-oar": [],
- "//apps/l3vpn:onos-apps-l3vpn-oar": [],
"//apps/layout:onos-apps-layout-oar": [],
"//apps/linkprops:onos-apps-linkprops-oar": [],
"//apps/mappingmanagement:onos-apps-mappingmanagement-oar": [],
@@ -273,7 +244,6 @@
"//apps/packet-stats:onos-apps-packet-stats-oar": [],
"//apps/packet-throttle:onos-apps-packet-throttle-oar": [],
"//apps/pathpainter:onos-apps-pathpainter-oar": [],
- "//apps/pcep-api:onos-apps-pcep-api-oar": [],
"//apps/pim:onos-apps-pim-oar": [],
"//apps/portloadbalancer:onos-apps-portloadbalancer-oar": ["seba", "tost"],
"//apps/powermanagement:onos-apps-powermanagement-oar": [],
@@ -290,8 +260,6 @@
"//apps/scalablegateway:onos-apps-scalablegateway-oar": [],
"//apps/sdnip:onos-apps-sdnip-oar": [],
"//apps/simplefabric:onos-apps-simplefabric-oar": [],
- # "//apps/tenbi:onos-apps-tenbi-oar": [],
- # "//apps/tenbi/yangmodel:onos-apps-tenbi-yangmodel-feature": [],
"//apps/test/cluster-ha:onos-apps-test-cluster-ha-oar": [],
"//apps/test/demo:onos-apps-test-demo-oar": [],
"//apps/test/distributed-primitives:onos-apps-test-distributed-primitives-oar": [],
@@ -304,19 +272,15 @@
"//apps/test/primitive-perf:onos-apps-test-primitive-perf-oar": [],
"//apps/test/route-scale:onos-apps-test-route-scale-oar": [],
"//apps/test/transaction-perf:onos-apps-test-transaction-perf-oar": [],
- "//apps/tetopology:onos-apps-tetopology-oar": [],
- "//apps/tetunnel:onos-apps-tetunnel-oar": [],
"//apps/tunnel:onos-apps-tunnel-oar": ["sona"],
"//apps/virtual:onos-apps-virtual-oar": [],
"//apps/virtualbng:onos-apps-virtualbng-oar": [],
"//apps/vpls:onos-apps-vpls-oar": [],
"//apps/vrouter:onos-apps-vrouter-oar": [],
- "//apps/vtn:onos-apps-vtn-oar": [],
"//apps/workflow/ofoverlay:onos-apps-workflow-ofoverlay-oar": [],
"//apps/workflow:onos-apps-workflow-oar": [],
"//apps/yang-gui:onos-apps-yang-gui-oar": [],
"//apps/yang:onos-apps-yang-oar": ["stratum", "tost"],
- # "//apps/yms:onos-apps-yms-oar": [],
"//web/gui:onos-web-gui-oar": ["sona", "tost"],
"//web/gui2:onos-web-gui2-oar": ["stratum", "tost"],
}
@@ -333,13 +297,11 @@
MODELS_MAP = {
"//models/ietf:onos-models-ietf-oar": ["stratum", "tost"],
"//models/common:onos-models-common-oar": [],
- "//models/huawei:onos-models-huawei-oar": [],
"//models/openconfig:onos-models-openconfig-oar": ["stratum", "tost"],
"//models/openconfig-infinera:onos-models-openconfig-infinera-oar": ["stratum", "tost"],
"//models/openconfig-odtn:onos-models-openconfig-odtn-oar": ["stratum", "tost"],
"//models/openroadm:onos-models-openroadm-oar": [],
"//models/tapi:onos-models-tapi-oar": ["stratum", "tost"],
- "//models/l3vpn:onos-models-l3vpn-oar": [],
"//models/polatis:onos-models-polatis-oar": [],
"//models/ciena/waveserverai:onos-models-ciena-waveserverai-oar": [],
}